Skip to contentSkip to conversation

Bluetooth: mgmt: report extended advertising SID to userspace

PATCH In review Yang Li 3 participants 3 messages Jan 7

Subsystems (4)
lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH 1/1 Bluetooth: mgmt: report extended advertising SID to userspace

Add a new mgmt event to report the SID of extended advertising to userspace. This allows userspace to obtain the SID before initiating PA sync, without waiting for the next extended advertising report to update the SID.

By providing the SID earlier, the PA sync flow can be simplified and the overall latency reduced.

---
 include/net/bluetooth/hci_core.h |  2 ++
 include/net/bluetooth/mgmt.h     |  7 +++++++
 net/bluetooth/hci_event.c        |  3 +++
 net/bluetooth/mgmt.c             | 13 +++++++++++++
 4 files changed, 25 insertions(+)
include/net/bluetooth/hci_core.h +2 -0
index a7bffb908c1e..81ef3e94e3af 100644
@@ -2469,6 +2469,8 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
 		       u8 addr_type, u8 *dev_class, s8 rssi, u32 flags,
 		       u8 *eir, u16 eir_len, u8 *scan_rsp, u8 scan_rsp_len,
 		       u64 instant);
+void mgmt_ext_adv_sid_changed(struct hci_dev *hdev, bdaddr_t *bdaddr,
+				     u8 addr_type, u8 sid);
 void mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
 		      u8 addr_type, s8 rssi, u8 *name, u8 name_len);
 void mgmt_discovering(struct hci_dev *hdev, u8 discovering);
include/net/bluetooth/mgmt.h +7 -0
index 8234915854b6..7ee38ebaccd8 100644
@@ -1195,3 +1195,10 @@ struct mgmt_ev_mesh_device_found {
 struct mgmt_ev_mesh_pkt_cmplt {
 	__u8	handle;
 } __packed;
+
+#define MGMT_EV_EXT_ADV_SID_CHANGED		0x0033
+struct mgmt_ev_ext_adv_sid_changed {
+	struct mgmt_addr_info addr;
+	__u8	sid;
+} __packed;
+
net/bluetooth/hci_event.c +3 -0
index 467710a42d45..f4463e71b424 100644
@@ -6519,6 +6519,9 @@ static void hci_le_ext_adv_report_evt(struct hci_dev *hdev, void *data,
 					   info->rssi, info->data, info->length,
 					   !(evt_type & LE_EXT_ADV_LEGACY_PDU),
 					   false, instant);
+			mgmt_ext_adv_sid_changed(hdev, &info->bdaddr,
+						      info->bdaddr_type,
+						      info->sid);
 		}
 	}
 
net/bluetooth/mgmt.c +13 -0
index 5be9b8c91949..4e0f8c43e387 100644
@@ -208,6 +208,7 @@ static const u16 mgmt_untrusted_events[] = {
 	MGMT_EV_EXT_INDEX_REMOVED,
 	MGMT_EV_EXT_INFO_CHANGED,
 	MGMT_EV_EXP_FEATURE_CHANGED,
+	MGMT_EV_EXT_ADV_SID_CHANGED,
 };
 
 #define CACHE_TIMEOUT	secs_to_jiffies(2)
@@ -10516,6 +10517,18 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
 	mgmt_adv_monitor_device_found(hdev, bdaddr, report_device, skb, NULL);
 }
 
+void mgmt_ext_adv_sid_changed(struct hci_dev *hdev, bdaddr_t *bdaddr,
+				     u8 addr_type, u8 sid)
+{
+	struct mgmt_ev_ext_adv_sid_changed ev;
+
+	bacpy(&ev.addr.bdaddr, bdaddr);
+	ev.addr.type = link_to_bdaddr(LE_LINK, addr_type);
+	ev.sid = sid;
+
+	mgmt_event(MGMT_EV_EXT_ADV_SID_CHANGED, hdev, &ev, sizeof(ev), NULL);
+}
+
 void mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
 		      u8 addr_type, s8 rssi, u8 *name, u8 name_len)
 {

---
base-commit: 030d2c0e9c1d68e67f91c08704482ad9881583eb
change-id: 20260107-mgmt_ext_adv_sid-7ea503e46791

Best regards,

Signature · 1 line
Yang Li <[email protected]>
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1039290

---Test result---

Test Summary:

CheckPatch                    PENDING   0.39 seconds
GitLint                       PENDING   0.27 seconds
SubjectPrefix                 PASS      0.08 seconds
BuildKernel                   PASS      25.36 seconds
CheckAllWarning               PASS      28.03 seconds
CheckSparse                   WARNING   31.58 seconds
BuildKernel32                 PASS      25.32 seconds
TestRunnerSetup               PASS      552.30 seconds
TestRunner_l2cap-tester       FAIL      28.82 seconds
TestRunner_iso-tester         FAIL      56.41 seconds
TestRunner_bnep-tester        PASS      6.31 seconds
TestRunner_mgmt-tester        FAIL      122.98 seconds
TestRunner_rfcomm-tester      PASS      9.40 seconds
TestRunner_sco-tester         FAIL      14.41 seconds
TestRunner_ioctl-tester       PASS      10.06 seconds
TestRunner_mesh-tester        FAIL      11.52 seconds
TestRunner_smp-tester         PASS      8.62 seconds
TestRunner_userchan-tester    PASS      6.72 seconds
IncrementalBuild              PENDING   0.51 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:
net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):
##############################
Test: TestRunner_l2cap-tester - FAIL
Desc: Run l2cap-tester with test-runner
Output:
Total: 96, Passed: 95 (99.0%), Failed: 1, Not Run: 0

Failed Test Cases
L2CAP BR/EDR Server - Set PHY 3M Failed 0.131 seconds
##############################
Test: TestRunner_iso-tester - FAIL
Desc: Run iso-tester with test-runner
Output:

BUG: KASAN: slab-use-after-free in le_read_features_complete+0x7e/0x2b0

Total: 141, Passed: 141 (100.0%), Failed: 0, Not Run: 0
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 494, Passed: 489 (99.0%), Failed: 1, Not Run: 4

Failed Test Cases
Read Exp Feature - Success Failed 0.102 seconds
##############################
Test: TestRunner_sco-tester - FAIL
Desc: Run sco-tester with test-runner
Output:
WARNING: possible circular locking dependency detected

BUG: sleeping function called from invalid context at net/core/sock.c:3782

Total: 30, Passed: 30 (100.0%), Failed: 0, Not Run: 0
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0

Failed Test Cases

Mesh - Send cancel - 1                               Timed out    1.903 seconds
Mesh - Send cancel - 2                               Timed out    1.999 seconds

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Yang Li

Hi Yang,

Quoted 8 lines · On Wed, Jan 7, 2026 at 3:48 AM Yang Li via B4 Relay…

From: Yang Li <[email protected]>

Add a new mgmt event to report the SID of extended advertising to userspace. This allows userspace to obtain the SID before initiating PA sync, without waiting for the next extended advertising report to update the SID.

Quoted 4 lines

By providing the SID earlier, the PA sync flow can be simplified and the overall latency reduced.

This is a new API so it can't possible fix the userspace issue above, there is clearly a bug when sid is set to 0xff we shall not proceed until it is resolved.

Quoted 26 lines
---
 include/net/bluetooth/hci_core.h |  2 ++
 include/net/bluetooth/mgmt.h     |  7 +++++++
 net/bluetooth/hci_event.c        |  3 +++
 net/bluetooth/mgmt.c             | 13 +++++++++++++
 4 files changed, 25 insertions(+)
include/net/bluetooth/hci_core.h +2 -0
index a7bffb908c1e..81ef3e94e3af 100644
@@ -2469,6 +2469,8 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
                       u8 addr_type, u8 *dev_class, s8 rssi, u32 flags,
                       u8 *eir, u16 eir_len, u8 *scan_rsp, u8 scan_rsp_len,
                       u64 instant);
+void mgmt_ext_adv_sid_changed(struct hci_dev *hdev, bdaddr_t *bdaddr,
+                                    u8 addr_type, u8 sid);
 void mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
                      u8 addr_type, s8 rssi, u8 *name, u8 name_len);
 void mgmt_discovering(struct hci_dev *hdev, u8 discovering);
include/net/bluetooth/mgmt.h +0 -0
index 8234915854b6..7ee38ebaccd8 100644

include/net/bluetooth/mgmt.h struct mgmt_ev_mesh_device_found { · line 1203

Quoted 9 lines
include/net/bluetooth/mgmt.h +6 -0
@@ -1195,3 +1195,10 @@ struct mgmt_ev_mesh_device_found {
 struct mgmt_ev_mesh_pkt_cmplt {
        __u8    handle;
 } __packed;
+
+#define MGMT_EV_EXT_ADV_SID_CHANGED            0x0033
+struct mgmt_ev_ext_adv_sid_changed {
+       struct mgmt_addr_info addr;
+       __u8    sid;
+} __packed;

I rather have a new device found event, or somehow embed the SID into the existing one.

Quoted 55 lines
net/bluetooth/hci_event.c +3 -0
index 467710a42d45..f4463e71b424 100644
@@ -6519,6 +6519,9 @@ static void hci_le_ext_adv_report_evt(struct hci_dev *hdev, void *data,
                                           info->rssi, info->data, info->length,
                                           !(evt_type & LE_EXT_ADV_LEGACY_PDU),
                                           false, instant);
+                       mgmt_ext_adv_sid_changed(hdev, &info->bdaddr,
+                                                     info->bdaddr_type,
+                                                     info->sid);
                }
        }
 
net/bluetooth/mgmt.c +13 -1
index 5be9b8c91949..4e0f8c43e387 100644
@@ -208,6 +208,7 @@ static const u16 mgmt_untrusted_events[] = {
        MGMT_EV_EXT_INDEX_REMOVED,
        MGMT_EV_EXT_INFO_CHANGED,
        MGMT_EV_EXP_FEATURE_CHANGED,
+       MGMT_EV_EXT_ADV_SID_CHANGED,
 };
 
 #define CACHE_TIMEOUT  secs_to_jiffies(2)
@@ -10516,6 +10517,18 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
        mgmt_adv_monitor_device_found(hdev, bdaddr, report_device, skb, NULL);
 }
 
+void mgmt_ext_adv_sid_changed(struct hci_dev *hdev, bdaddr_t *bdaddr,
+                                    u8 addr_type, u8 sid)
+{
+       struct mgmt_ev_ext_adv_sid_changed ev;
+
+       bacpy(&ev.addr.bdaddr, bdaddr);
+       ev.addr.type = link_to_bdaddr(LE_LINK, addr_type);
+       ev.sid = sid;
+
+       mgmt_event(MGMT_EV_EXT_ADV_SID_CHANGED, hdev, &ev, sizeof(ev), NULL);
+}
+
 void mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
                      u8 addr_type, s8 rssi, u8 *name, u8 name_len)
 {
 
---

base-commit: 030d2c0e9c1d68e67f91c08704482ad9881583eb
change-id: 20260107-mgmt_ext_adv_sid-7ea503e46791

Best regards,
--
Yang Li <[email protected]>

Signature · 1 line
Luiz Augusto von Dentz