summaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_core.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2014-02-23 20:39:22 -0800
committerJohan Hedberg <johan.hedberg@intel.com>2014-02-24 08:49:31 +0200
commit2b5224dca5a9257a3df8cc9f93978ecb3757b9c2 (patch)
tree95e92a6c212a6fd8251bc454fd7845b120ed0514 /net/bluetooth/hci_core.c
parent41c90c186a3b51207cb1f2583fbadec3c76e4730 (diff)
downloadlinux-2b5224dca5a9257a3df8cc9f93978ecb3757b9c2.tar.bz2
Bluetooth: Store current RPA and update it if needed
The RPA needs to be stored to know which is the current one. Otherwise it is impossible to ensure that always the correct RPA can be programmed into the controller when it is needed. Current code checks if the address in the controller is a RPA, but that can potentially lead to using a RPA that can not be resolved with the IRK that has been distributed. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth/hci_core.c')
-rw-r--r--net/bluetooth/hci_core.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 31e68ade309d..9f1c3d7d1d74 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -3339,26 +3339,25 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy,
int err;
/* If privacy is enabled use a resolvable private address. If
- * the current RPA has expired or there's something else than an
- * RPA currently in use regenerate a new one.
+ * current RPA has expired or there is something else than
+ * the current RPA in use, then generate a new one.
*/
if (test_bit(HCI_PRIVACY, &hdev->dev_flags)) {
- bdaddr_t rpa;
int to;
*own_addr_type = ADDR_LE_DEV_RANDOM;
if (!test_and_clear_bit(HCI_RPA_EXPIRED, &hdev->dev_flags) &&
- hci_bdaddr_is_rpa(&hdev->random_addr, ADDR_LE_DEV_RANDOM))
+ !bacmp(&hdev->random_addr, &hdev->rpa))
return 0;
- err = smp_generate_rpa(hdev->tfm_aes, hdev->irk, &rpa);
+ err = smp_generate_rpa(hdev->tfm_aes, hdev->irk, &hdev->rpa);
if (err < 0) {
BT_ERR("%s failed to generate new RPA", hdev->name);
return err;
}
- hci_req_add(req, HCI_OP_LE_SET_RANDOM_ADDR, 6, &rpa);
+ hci_req_add(req, HCI_OP_LE_SET_RANDOM_ADDR, 6, &hdev->rpa);
to = msecs_to_jiffies(hdev->rpa_timeout * 1000);
queue_delayed_work(hdev->workqueue, &hdev->rpa_expired, to);