Skip to contentSkip to conversation

mgmt-api: Add missing Device Flag

PATCH Superseded Luiz Augusto von Dentz 2 participants 4 messages Mar 21, 2025

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/3 mgmt-api: Add missing Device Flag

From: Luiz Augusto von Dentz <[email protected]>

This adds the missing Device Flag - Address Resolution = bit(2)

---
 doc/mgmt-api.txt | 1 +
 1 file changed, 1 insertion(+)
doc/mgmt-api.txt +1 -0
index b4a5776574f7..3181607d94fa 100644
@@ -3429,6 +3429,7 @@ Get Device Flags Command
 
 		0	Remote Wakeup enabled
 		1	Device Privacy Mode enabled
+		2	Address Resolution enabled
 
 	This command generates a Command Complete event on success
 	or a Command Status event on failure.
Signature · 1 line
2.48.1
author maintainer
#1 lore raw

PATCH 2/3 mgmt-api: Add LL Privacy setting

From: Luiz Augusto von Dentz <[email protected]>

This adds LL Privacy (bit 22) to Read Controller Information so it can be propagated to the likes of bluetoothd.

---
 doc/mgmt-api.txt | 1 +
 1 file changed, 1 insertion(+)
doc/mgmt-api.txt +1 -0
index 3181607d94fa..2fe8ca22b9b5 100644
@@ -336,6 +336,7 @@ Read Controller Information Command
 		19	Connected Isochronous Stream - Peripheral
 		20	Isochronous Broadcaster
 		21	Synchronized Receiver
+		22	LL Privacy
 
 	This command generates a Command Complete event on success or
 	a Command Status event on failure.
Signature · 1 line
2.48.1
author maintainer
#2 lore raw

PATCH 3/3 gatt-database: Fix always registering CentralAddressResolution

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

CentralAddressResolution shall be conditional to LL Privacy to avoid peripherals assuming Directed Advertising can be used which may lead to issues like:

---
 lib/mgmt.h          |  1 +
 src/gatt-database.c | 30 +++++++++++++++++-------------
 2 files changed, 18 insertions(+), 13 deletions(-)
lib/mgmt.h +1 -0
index 6a397645bcf2..6af82fc4a1a5 100644
@@ -104,6 +104,7 @@ struct mgmt_rp_read_index_list {
 #define MGMT_SETTING_CIS_PERIPHERAL	BIT(19)
 #define MGMT_SETTING_ISO_BROADCASTER	BIT(20)
 #define MGMT_SETTING_ISO_SYNC_RECEIVER	BIT(21)
+#define MGMT_SETTING_LL_PRIVACY		BIT(22)
 
 #define MGMT_OP_READ_INFO		0x0004
 struct mgmt_rp_read_info {
src/gatt-database.c +17 -13
index 239a0dc72be9..a5706e61ce1e 100644
@@ -740,17 +740,14 @@ static void gap_car_read_cb(struct gatt_db_attribute *attrib,
 					void *user_data)
 {
 	uint8_t value = 0x00;
+	struct btd_device *device;
 
 	DBG("GAP Central Address Resolution read request\n");
 
-	if (btd_opts.defaults.le.addr_resolution) {
-		struct btd_device *device;
-
-		device = btd_adapter_find_device_by_fd(bt_att_get_fd(att));
-		if (device)
-			value = btd_device_flags_enabled(device,
+	device = btd_adapter_find_device_by_fd(bt_att_get_fd(att));
+	if (device)
+		value = btd_device_flags_enabled(device,
 					DEVICE_FLAG_ADDRESS_RESOLUTION);
-	}
 
 	gatt_db_attribute_read_result(attrib, id, 0, &value, sizeof(value));
 }
@@ -873,10 +870,13 @@ static void populate_gap_service(struct btd_gatt_database *database)
 {
 	bt_uuid_t uuid;
 	struct gatt_db_attribute *service, *attrib;
+	bool ll_privacy = btd_adapter_has_settings(database->adapter,
+						MGMT_SETTING_LL_PRIVACY);
 
 	/* Add the GAP service */
 	bt_uuid16_create(&uuid, UUID_GAP);
-	service = gatt_db_add_service(database->db, &uuid, true, 7);
+	service = gatt_db_add_service(database->db, &uuid, true,
+						ll_privacy ? 7 : 5);
 
 	/*
 	 * Device Name characteristic.
@@ -898,15 +898,19 @@ static void populate_gap_service(struct btd_gatt_database *database)
 							NULL, database);
 	gatt_db_attribute_set_fixed_length(attrib, 2);
 
-	/*
-	 * Central Address Resolution characteristic.
-	 */
-	bt_uuid16_create(&uuid, GATT_CHARAC_CAR);
-	attrib = gatt_db_service_add_characteristic(service, &uuid,
+	/* Only enable Central Address Resolution if LL Privacy is supported */
+	if (ll_privacy) {
+		/*
+		 * Central Address Resolution characteristic.
+		 */
+		bt_uuid16_create(&uuid, GATT_CHARAC_CAR);
+		attrib = gatt_db_service_add_characteristic(service, &uuid,
 							BT_ATT_PERM_READ,
 							BT_GATT_CHRC_PROP_READ,
 							gap_car_read_cb,
 							NULL, database);
+	}
+
 	gatt_db_attribute_set_fixed_length(attrib, 1);
 
 	gatt_db_service_set_active(service, true);
Signature · 1 line
2.48.1
#3 lore raw
In reply to Luiz Augusto von Dentz

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=946404

---Test result---

Test Summary:

CheckPatch                    PENDING   0.33 seconds
GitLint                       PENDING   0.28 seconds
BuildEll                      PASS      21.25 seconds
BluezMake                     PASS      1542.58 seconds
MakeCheck                     PASS      13.57 seconds
MakeDistcheck                 PASS      161.48 seconds
CheckValgrind                 PASS      213.63 seconds
CheckSmatch                   PASS      284.50 seconds
bluezmakeextell               PASS      98.57 seconds
IncrementalBuild              PENDING   0.32 seconds
ScanBuild                     PASS      871.05 seconds

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

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

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

---
Regards,
Linux Bluetooth