Bluetooth: Introduce a flag to track who really initiates authentication
authorJohan Hedberg <johan.hedberg@intel.com>
Thu, 17 Jul 2014 12:35:39 +0000 (15:35 +0300)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 17 Jul 2014 12:39:40 +0000 (14:39 +0200)
Even though our side requests authentication, the original action that
caused it may be remotely triggered, such as an incoming L2CAP or RFCOMM
connect request. To track this information introduce a new hci_conn flag
called HCI_CONN_AUTH_INITIATOR.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
include/net/bluetooth/hci_core.h
net/bluetooth/hci_conn.c
net/bluetooth/hci_event.c

index eb2b9c9e3480546a6d11ac1953be2949db33a510..996ed065b6c23d04d1c274b7352591bf54aca0d8 100644 (file)
@@ -547,6 +547,7 @@ enum {
        HCI_CONN_SECURE,
        HCI_CONN_FIPS,
        HCI_CONN_STK_ENCRYPT,
+       HCI_CONN_AUTH_INITIATOR,
 };
 
 static inline bool hci_conn_ssp_enabled(struct hci_conn *conn)
index 76c5a38e599714ba51f5ee285a2491e0942192a4..0d76054efd268bc66fe557d099fb2c47707d61b9 100644 (file)
@@ -1027,6 +1027,9 @@ auth:
        if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags))
                return 0;
 
+       if (initiator)
+               set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags);
+
        if (!hci_conn_auth(conn, sec_level, auth_type))
                return 0;
 
index 495d6d5c11467019001c8f51ff38923a09962330..af2cdca03d737a7c25b066b94b55e9ad2d5e610a 100644 (file)
@@ -1645,6 +1645,8 @@ static void hci_cs_remote_name_req(struct hci_dev *hdev, __u8 status)
        if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) {
                struct hci_cp_auth_requested auth_cp;
 
+               set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags);
+
                auth_cp.handle = __cpu_to_le16(conn->handle);
                hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED,
                             sizeof(auth_cp), &auth_cp);
@@ -2387,6 +2389,9 @@ check_auth:
 
        if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) {
                struct hci_cp_auth_requested cp;
+
+               set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags);
+
                cp.handle = __cpu_to_le16(conn->handle);
                hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, sizeof(cp), &cp);
        }