Bluetooth: Ensure hci_conn always contains the local identity address
authorJohan Hedberg <johan.hedberg@intel.com>
Sun, 23 Feb 2014 17:42:17 +0000 (19:42 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Sun, 23 Feb 2014 20:24:25 +0000 (12:24 -0800)
To be consistent with the remote address info in hci_conn we want it to
also contain the local identity address information. This patch updates
the code to copy the right values in place whenever an LE connection has
been established.

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

index 4327b12..064d619 100644 (file)
@@ -3625,6 +3625,26 @@ static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
                }
        }
 
+       /* Ensure that the hci_conn contains the identity address type
+        * regardless of which address the connection was made with.
+        *
+        * If the controller has a public BD_ADDR, then by default
+        * use that one. If this is a LE only controller without
+        * a public address, default to the static random address.
+        *
+        * For debugging purposes it is possible to force
+        * controllers with a public address to use the static
+        * random address instead.
+        */
+       if (test_bit(HCI_FORCE_STATIC_ADDR, &hdev->dev_flags) ||
+           !bacmp(&hdev->bdaddr, BDADDR_ANY)) {
+               bacpy(&conn->src, &hdev->static_addr);
+               conn->src_type = ADDR_LE_DEV_RANDOM;
+       } else {
+               bacpy(&conn->src, &hdev->bdaddr);
+               conn->src_type = ADDR_LE_DEV_PUBLIC;
+       }
+
        /* Lookup the identity address from the stored connection
         * address and address type.
         *