Skip to content

Commit

Permalink
Bluetooth: host: Skip set passive scan when not scanning with identity
Browse files Browse the repository at this point in the history
When privacy is disabled by default the scanner still protects it's
identity with the use of NRPA addresses. We should not set the identity
address for the passive scanner unless the Kconfig option to scan with
the identity has been enabled.

This makes passive scanner behave the same way as an active scanner
since none of them will report directed advertising reports towards
the scanners identity.

This also enables the advertiser to switch out the random address which
is needed for the Bluetooth Mesh LPN case.

Fixes #22088.

Signed-off-by: Trond Einar Snekvik <[email protected]>
  • Loading branch information
trond-snekvik authored and jhedberg committed Feb 3, 2020
1 parent ab2902e commit a112f15
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions subsys/bluetooth/host/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3644,15 +3644,20 @@ static int start_le_scan(u8_t scan_type, u16_t interval, u16_t window)
* (through Kconfig), or if there is no advertising ongoing.
*/
if (!IS_ENABLED(CONFIG_BT_SCAN_WITH_IDENTITY) &&
scan_type == BT_HCI_LE_SCAN_ACTIVE &&
!atomic_test_bit(bt_dev.flags, BT_DEV_ADVERTISING)) {
err = le_set_private_addr(BT_ID_DEFAULT);
if (err) {
return err;
}

set_param.addr_type = BT_ADDR_LE_RANDOM;
} else if (set_param.addr_type == BT_ADDR_LE_RANDOM) {
} else if (IS_ENABLED(CONFIG_BT_SCAN_WITH_IDENTITY) &&
set_param.addr_type == BT_ADDR_LE_RANDOM) {
/* If scanning with Identity Address we must set the
* random identity address for both active and passive
* scanner in order to receive adv reports that are
* directed towards this identity.
*/
err = set_random_address(&bt_dev.id_addr[0].a);
if (err) {
return err;
Expand Down Expand Up @@ -5058,6 +5063,17 @@ static int hci_init(void)
BT_ERR("Unable to set identity address");
return err;
}

/* The passive scanner just sends a dummy address type in the
* command. If the first activity does this, and the dummy type
* is a random address, it needs a valid value, even though it's
* not actually used.
*/
err = set_random_address(&bt_dev.id_addr[0].a);
if (err) {
BT_ERR("Unable to set random address");
return err;
}
}

return 0;
Expand Down Expand Up @@ -5750,7 +5766,7 @@ int bt_setup_random_id_addr(void)
id_create(i, &addr, irk);
}

return set_random_address(&bt_dev.id_addr[0].a);
return 0;
}
}
#endif /* defined(CONFIG_BT_HCI_VS_EXT) || defined(CONFIG_BT_CTLR) */
Expand Down

0 comments on commit a112f15

Please sign in to comment.