Bluetooth: host: Skip set passive scan when not scanning with identity

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 <Trond.Einar.Snekvik@nordicsemi.no>
This commit is contained in:
Trond Einar Snekvik 2020-01-29 15:01:02 +01:00 committed by Johan Hedberg
commit a112f1568d

View file

@ -3644,7 +3644,6 @@ 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) {
@ -3652,7 +3651,13 @@ static int start_le_scan(u8_t scan_type, u16_t interval, u16_t window)
}
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;
@ -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;
@ -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) */