Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: hci_sync: Don't announce a broadcast from an NRPA
@ 2026-11-22 20:09 Simon Mikuda
  2026-11-22 22:55 ` bluez.test.bot
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Mikuda @ 2026-11-22 20:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Simon Mikuda, Marcel Holtmann, Luiz Augusto von Dentz

A source registered over MGMT becomes periodic only when its PA starts, so
until then it advertises from a non-resolvable private address without a
PA, and from another address once the PA starts. Scanners list it twice,
and an assistant that picks the first entry can never sync:

    broadcast [1] 7C:A3:38:7A:00:38  Broadcast ID EAE7E6
    broadcast [2] 50:1E:2D:9E:E7:92  Broadcast ID EAE7E6

Treat a set with a Broadcast Audio Announcement as a broadcast set too, and
set it up again once its data is known.

Fixes: 03ddb4ac2514 ("Bluetooth: hci_sync: Fix using random address for BIG/PA advertisements")
Signed-off-by: Simon Mikuda <simon.mikuda@streamunlimited.com>
---
 net/bluetooth/hci_sync.c | 12 ++++++++++--
 net/bluetooth/mgmt.c     | 14 ++++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 638589f77081..c7533cc94ec1 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -1483,7 +1483,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;
@@ -1518,6 +1518,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.
 	 */
@@ -1534,7 +1542,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,
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index f5f32860782d..edfbdf2942f7 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -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: 4fe38719e6738feaa90486e36b0790dd5d960a96
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-22 22:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-22 20:09 [PATCH] Bluetooth: hci_sync: Don't announce a broadcast from an NRPA Simon Mikuda
2026-11-22 22:55 ` bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox