Browse Source

Bluetooth: Check for matching IRK when looking for paired LE devices

If we're given an RPA when checking whether we're paired or not, we
should consult the local RPA storage whether there's a matching IRK.
This we we ensure that hci_bdaddr_is_paired() gives the right result
even when trying to pair a second time with the same device with an RPA.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg 10 years ago
parent
commit
4ba9faf35f
1 changed files with 7 additions and 0 deletions
  1. 7 0
      net/bluetooth/hci_core.c

+ 7 - 0
net/bluetooth/hci_core.c

@@ -2519,6 +2519,7 @@ void hci_remove_irk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type)
 bool hci_bdaddr_is_paired(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type)
 bool hci_bdaddr_is_paired(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type)
 {
 {
 	struct smp_ltk *k;
 	struct smp_ltk *k;
+	struct smp_irk *irk;
 	u8 addr_type;
 	u8 addr_type;
 
 
 	if (type == BDADDR_BREDR) {
 	if (type == BDADDR_BREDR) {
@@ -2533,6 +2534,12 @@ bool hci_bdaddr_is_paired(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type)
 	else
 	else
 		addr_type = ADDR_LE_DEV_RANDOM;
 		addr_type = ADDR_LE_DEV_RANDOM;
 
 
+	irk = hci_get_irk(hdev, bdaddr, addr_type);
+	if (irk) {
+		bdaddr = &irk->bdaddr;
+		addr_type = irk->addr_type;
+	}
+
 	rcu_read_lock();
 	rcu_read_lock();
 	list_for_each_entry_rcu(k, &hdev->long_term_keys, list) {
 	list_for_each_entry_rcu(k, &hdev->long_term_keys, list) {
 		if (k->bdaddr_type == addr_type && !bacmp(bdaddr, &k->bdaddr)) {
 		if (k->bdaddr_type == addr_type && !bacmp(bdaddr, &k->bdaddr)) {