Bluetooth: hci_sync: Don't announce a broadcast from an NRPA
Subsystems (2)
PATCH v2 1/1 Bluetooth: hci_sync: Don't announce a broadcast from an NRPA
MGMT Add Extended Advertising Parameters sets an advertising set up before its data is known, and the set becomes periodic only in hci_start_per_adv_sync(), when a broadcast ISO socket is connected on it. Until then a set without the connectable flag, on an adapter that is not connectable and has privacy off, gets a non-resolvable private address. If its data carries a Broadcast Audio Announcement, the broadcast is announced from that address, and the set is moved to the identity address when its periodic advertising starts:
< HCI Command: LE Set Extended Advertising Parameters 3.162678
Handle: 0x02
Properties: 0x0000
Own address type: Random (0x01)
< HCI Command: LE Set Advertising Set Random Address 3.164952
Advertising random address: 21:3E:30:B7:DE:A4 (Non-Resolvable)
< HCI Command: LE Set Extended Advertising Data 4.161538
Service Data: Broadcast Audio Announcement (0x1852)
Broadcast ID: 11645491 (0xb1b233)
< HCI Command: LE Set Extended Advertising Enable 4.164125
Extended advertising: Enabled (0x01)
< HCI Command: LE Set Extended Advertising Enable 11.280146
Extended advertising: Disabled (0x00)
< HCI Command: LE Set Extended Advertising Parameters 11.282026
Own address type: Public (0x00)
< HCI Command: LE Set Extended Advertising Enable 11.284922
Extended advertising: Enabled (0x01)
< HCI Command: LE Set Periodic Advertising Enable 11.291942
Periodic advertising: Enabled (0x01)The address the broadcast is first announced from never carries the periodic advertising. A scanner listed Broadcast ID 0xb1b233 under 21:3E:30:B7:DE:A4 before the socket was connected, and under the controller's public address in a scan started after it.
The commit in Fixes stopped giving a periodic set a non-resolvable address, but it looks only at adv->periodic. Treat a set whose data carries a Broadcast Audio Announcement as a broadcast set too, and set it up again in Add Extended Advertising Data, because its parameters were sent before the data was known. With this change LE Set Extended Advertising Parameters is sent a second time, with Own address type Public, before the set is first enabled, and the scanner lists the Broadcast ID only under the public address.
The address of other sets does not change: an NRPA is only asked for when neither the set's flag nor the adapter's setting makes it connectable, and a set that uses a resolvable private address gets that first.
Steps to reproduce, on an nRF54L15 with Zephyr 4.5.0's open link layer as hci1 (public address F4:26:7C:31:12:69) and BlueZ 5.87, with privacy off and the adapter not connectable ("btmgmt info" lists neither):
1. btmon -i hci1 -w FILE
2. In one "btmgmt --index 1" session, a second apart:
add-ext-adv-params -r 0xa0 -x 0xf0 -P 2M 2
add-ext-adv-data -d 0616521833b2b1 2
3. About 7 s later, a broadcast ISO socket on advertising set 2:
isotest -i hci1 -q -s 00:00:00:00:00:00 -B 16_2_1 -G 0 -T 2A Realtek RTL8763EFL next to it scanned for broadcast sources, 10 s from before step 2 and again from 2 s after step 3.
---
Changes in v2:
- no code change
- reworded git description
- steps to reproduce added
net/bluetooth/hci_sync.c | 12 ++++++++++-- net/bluetooth/mgmt.c | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-)
net/bluetooth/hci_sync.c +10 -2
@@ -1487,7 +1487,7 @@ int hci_setup_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance) {struct hci_cp_le_set_ext_adv_params cp;struct hci_rp_le_set_ext_adv_params rp; -bool connectable, require_privacy; +bool connectable, periodic, require_privacy;u32 flags;bdaddr_t random_addr;u8 own_addr_type;
@@ -1522,6 +1522,14 @@ int hci_setup_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance) flags =hci_adv_instance_flags (hdev, instance); +/* A set with a Broadcast Audio Announcement is a broadcast source even +* before its PA starts. +*/ + periodic = adv && (adv->periodic || +eir_get_service_data (adv->adv_data, + adv->adv_data_len,0x1852 , +NULL )); +/* If the "connectable" instance flag was not set, then choose between * ADV_IND and ADV_NONCONN_IND based on the global connectable setting, * unless the instance carries periodic advertising, which can only be
@@ -1540,7 +1548,7 @@ int hci_setup_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance)* advertising is used and it is not periodic. * In that case it is fine to use a non-resolvable private address. */ - require_privacy = !connectable && !(adv && adv->periodic); + require_privacy = !connectable && !periodic; err = hci_get_random_address(hdev, require_privacy, adv_use_rpa(hdev, flags), adv,
net/bluetooth/mgmt.c +14 -0
@@ -9646,6 +9646,20 @@ static int add_ext_adv_data_sync(struct hci_dev *hdev, void *data)int err;if (ext_adv_capable (hdev)) { +struct adv_info *adv; +bool bcast; + +/* The parameters were set before the data was known */ +hci_dev_lock (hdev); + adv =hci_find_adv_instance (hdev, cp->instance); + bcast = adv && !adv->periodic && +eir_get_service_data (adv->adv_data, adv->adv_data_len, +0x1852 ,NULL ); +hci_dev_unlock (hdev); + +if (bcast) +return hci_start_ext_adv_sync (hdev, cp->instance); + err =hci_update_adv_data_sync (hdev, cp->instance);if (err)return err;
base-commit: 62fd917f6d2df1a399a453138c2b7cbd563f8f95
Signature · 1 line
2.43.0