client/btpclient: Security Level reporting
v2 cover client/btpclient: Security Level reporting
Set org.bluez.Device SecurityLevel and EncryptionType properties to optional so application can access them only when they are meaningful.
Send BTP_EV_GAP_SEC_LEVEL_CHANGED event from SecurityLevel property changes once the device's services are resolved, matching the BTP levels expected by auto-pts.
This reduces connection time for the BAP tests.
v1->v2: Retitled patch 1 from "device: Provide Security Level related
props when supported by kernel" (subject line was exceeding the mailing list's 80-character limit with the series prefix).
Frédéric Danis (3):
device: Provide Security Level props when kernel supports them org.bluez.Device: Make Security Level props optional client/btpclient: Add BTP_EV_GAP_SEC_LEVEL_CHANGED support
client/btpclient/gap.c | 52 ++++++++++++++++++++++++++++++++++++++++ doc/org.bluez.Device.rst | 8 +++---- src/adapter.c | 4 ++++ src/adapter.h | 1 + src/device.c | 13 ++++++++-- src/shared/btp.h | 11 +++++++++ 6 files changed, 83 insertions(+), 6 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/3 device: Provide Security Level props when kernel supports them
The SecurityLevel and EncryptionType properties should be available in org.bluez.Device only when kernel supports MGMT_EV_SECURITY_LEVEL_CHANGED events.
This allows applications to check those properties when they are meaningful.
---v1->v2: Retitled from "device: Provide Security Level related props when
supported by kernel" (subject line was exceeding the mailing list's 80-character limit with the series prefix).
src/adapter.c | 4 ++++ src/adapter.h | 1 + src/device.c | 13 +++++++++++-- 3 files changed, 16 insertions(+), 2 deletions(-)
src/adapter.c +4 -0
@@ -11398,6 +11398,10 @@ static void read_commands_complete(uint8_t status, uint16_t length,DBG ("kernel supports suspend/resume events" ); kernel_features |=KERNEL_HAS_RESUME_EVT ;break ; +case MGMT_EV_SECURITY_LEVEL_CHANGED : +DBG ("kernel supports security level events" ); + kernel_features |=KERNEL_HAS_SECURITY_LEVEL_EVT ; +break ; } } }
src/adapter.h +1 -0
@@ -292,6 +292,7 @@ enum kernel_features {KERNEL_HAS_RESUME_EVT =1 <<4 ,KERNEL_HAS_EXT_ADV_ADD_CMDS =1 <<5 ,KERNEL_HAS_CONTROLLER_CAP_CMD =1 <<6 , + KERNEL_HAS_SECURITY_LEVEL_EVT = 1 << 7, };bool btd_has_kernel_features (uint32_t feature);
src/device.c +11 -2
@@ -3785,6 +3785,13 @@ static gboolean dev_get_encryption_type(const GDBusPropertyTable *property,return TRUE; } +static gboolean +dev_security_level_exists (const GDBusPropertyTable *property, +void *data) +{ +return btd_has_kernel_features (KERNEL_HAS_SECURITY_LEVEL_EVT ); +} +static const GDBusPropertyTable device_properties[] = { {"Address" ,"s" , dev_property_get_address }, {"AddressType" ,"s" , property_get_address_type },
@@ -3830,9 +3837,11 @@ static const GDBusPropertyTable device_properties[] = { dev_property_set_prefer_bearer, dev_property_prefer_bearer_exists, G_DBUS_PROPERTY_FLAG_EXPERIMENTAL }, - { "SecurityLevel", "y", dev_get_security_level, NULL, NULL, + { "SecurityLevel", "y", dev_get_security_level, NULL, + dev_security_level_exists, G_DBUS_PROPERTY_FLAG_EXPERIMENTAL }, - { "EncryptionType", "y", dev_get_encryption_type, NULL, NULL, + { "EncryptionType", "y", dev_get_encryption_type, NULL, + dev_security_level_exists, G_DBUS_PROPERTY_FLAG_EXPERIMENTAL }, { } };
Signature · 1 line
2.43.0
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/series/1220644/
---Test result---
Test Summary:
CheckPatch PASS 0.99 seconds GitLint PASS 0.69 seconds BuildEll PASS 15.91 seconds BluezMake PASS 229.50 seconds MakeCheck PASS 13.53 seconds MakeDistcheck PASS 117.21 seconds CheckValgrind PASS 280.36 seconds CheckSmatch PASS 234.25 seconds bluezmakeextell PASS 75.46 seconds TestFunctional PASS 1003.52 seconds IncrementalBuild PASS 235.64 seconds ScanBuild PASS 844.91 seconds
https://github.com/bluez/bluez/pull/2896
---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz
maintainerHi Frederic,
Quoted 27 lines · On Tue, Nov 24, 2026 at 6:31 AM <[email protected]> wrote:
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/series/1220644/---Test result---
Test Summary:
CheckPatch PASS 0.99 seconds GitLint PASS 0.69 seconds BuildEll PASS 15.91 seconds BluezMake PASS 229.50 seconds MakeCheck PASS 13.53 seconds MakeDistcheck PASS 117.21 seconds CheckValgrind PASS 280.36 seconds CheckSmatch PASS 234.25 seconds bluezmakeextell PASS 75.46 seconds TestFunctional PASS 1003.52 seconds IncrementalBuild PASS 235.64 seconds ScanBuild PASS 844.91 seconds
Quoted 1 line
Copilot flagged a problem:
https://github.com/bluez/bluez/pull/2896#pullrequestreview-6038693469
Signature · 1 line
Luiz Augusto von Dentz
Hi Luiz,
Quoted 29 lines · Luiz Augusto von Dentz
Hi Frederic,
Quoted 26 lines · On Tue, Nov 24, 2026 at 6:31 AM <[email protected]> wrote:
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/series/1220644/---Test result---
Test Summary:
CheckPatch PASS 0.99 seconds GitLint PASS 0.69 seconds BuildEll PASS 15.91 seconds BluezMake PASS 229.50 seconds MakeCheck PASS 13.53 seconds MakeDistcheck PASS 117.21 seconds CheckValgrind PASS 280.36 seconds CheckSmatch PASS 234.25 seconds bluezmakeextell PASS 75.46 seconds TestFunctional PASS 1003.52 seconds IncrementalBuild PASS 235.64 seconds ScanBuild PASS 844.91 seconds
Quoted 5 lines
Quoted 1 line
Copilot flagged a problem:
https://github.com/bluez/bluez/pull/2896#pullrequestreview-6038693469
This has been fixed in version 3.
Regards,
Fred
Signature · 6 lines
Frédéric Danis Senior Software Engineer Collabora Ltd. Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, United Kingdom Registered in England & Wales, no. 5513718
PATCH v2 2/3 org.bluez.Device: Make Security Level props optional
In reply to Frédéric DanisThe SecurityLevel and EncryptionType properties are available only when kernel supports MGMT_EV_SECURITY_LEVEL_CHANGED events.
--- doc/org.bluez.Device.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
doc/org.bluez.Device.rst +4 -4
@@ -490,8 +490,8 @@ Examples: :bluetoothctl: > bearer <dev> [last-seen/bredr/le] -byte SecurityLevel [readonly, experimental] -``````````````````````````````````````````` +byte SecurityLevel [readonly, optional, experimental] +````````````````````````````````````````````````````` Indicate the Security Level of a connection. Possible values:
@@ -511,8 +511,8 @@ Possible values: :4: FIPS authenticated pairing with encryption -byte EncryptionType [readonly, experimental] -```````````````````````````````````````````` +byte EncryptionType [readonly, optional, experimental] +`````````````````````````````````````````````````````` Indicate the Encryption type in use for a connection. Possible values:
Signature · 1 line
2.43.0
PATCH v2 3/3 client/btpclient: Add BTP_EV_GAP_SEC_LEVEL_CHANGED support
In reply to Frédéric DanisWhen supported, send BTP_EV_GAP_SEC_LEVEL_CHANGED from org.bluez.Device1 SecurityLevel property changes, mapped to the matching BTP level, and skip levels with no BTP equivalent (no security/encryption yet). Postponed this BTP event after device services has been retrieved to be in sync with auto-pts expectation.
This reduces connection time for the BAP tests.
--- client/btpclient/gap.c | 52 ++++++++++++++++++++++++++++++++++++++++++ src/shared/btp.h | 11 +++++++++ 2 files changed, 63 insertions(+)
client/btpclient/gap.c +52 -0
@@ -2564,6 +2564,37 @@ static void btp_gap_device_connection_ev(struct l_dbus_proxy *proxy, } } +static void btp_security_level_changed_ev (struct l_dbus_proxy *proxy, +uint8_t level) +{ +struct btp_device *device =find_device_by_proxy (proxy); +struct btp_adapter *adapter =find_adapter_by_device (device); +struct btp_gap_sec_level_changed_ev ev; + +if (!device || !adapter) +return ; + +memcpy (&ev.address, &device->address,sizeof (ev.address)); + ev.address_type = device->address_type; +switch (level) { +case BT_SECURITY_MEDIUM : + ev.sec_level =BTP_GAP_SEC_LEVEL_UNAUTH_ENC ; +break ; +case BT_SECURITY_HIGH : + ev.sec_level =BTP_GAP_SEC_LEVEL_AUTH_ENC ; +break ; +case BT_SECURITY_FIPS : + ev.sec_level =BTP_GAP_SEC_LEVEL_AUTH_SC ; +break ; +default : +/* No security/encryption yet, no BTP level to report. */ +return ; + } + +btp_send (btp,BTP_GAP_SERVICE ,BTP_EV_GAP_SEC_LEVEL_CHANGED , + adapter->index,sizeof (ev), &ev); +} +static void btp_identity_resolved_ev (struct l_dbus_proxy *proxy) {struct btp_device *dev =find_device_by_proxy (proxy);
@@ -2736,6 +2767,22 @@ void gap_property_changed(struct l_dbus_proxy *proxy, const char *name,*/ if (!prop)btp_gap_device_connection_ev (proxy, prop); + }else if (!strcmp (name,"SecurityLevel" )) { +uint8_t level; +bool resolved; + +/* Postpone security level changed event after services +* has been resolved. +*/ +if (l_dbus_proxy_get_property (proxy, +"ServicesResolved" ,"b" , &resolved) && + !resolved) +return ; + +if (!l_dbus_message_get_arguments (msg,"y" , &level)) +return ; + +btp_security_level_changed_ev (proxy, level); }else if (!strcmp (name,"AddressType" )) {/* Address property change came first along with address * type.
@@ -2743,12 +2790,17 @@ void gap_property_changed(struct l_dbus_proxy *proxy, const char *name,btp_identity_resolved_ev (proxy); }else if (!strcmp (name,"ServicesResolved" )) {bool prop; +uint8_t level;if (!l_dbus_message_get_arguments (msg,"b" , &prop))return ;if (prop)btp_gap_device_connection_ev (proxy, prop); + +if (l_dbus_proxy_get_property (proxy, +"SecurityLevel" ,"y" , &level)) +btp_security_level_changed_ev (proxy, level); } } }
src/shared/btp.h +11 -0
@@ -296,6 +296,17 @@ struct btp_gap_identity_resolved_ev {bdaddr_t identity_address; } __packed; +#define BTP_GAP_SEC_LEVEL_UNAUTH_ENC 0x01 +#define BTP_GAP_SEC_LEVEL_AUTH_ENC 0x02 +#define BTP_GAP_SEC_LEVEL_AUTH_SC 0x03 + +#define BTP_EV_GAP_SEC_LEVEL_CHANGED 0x89 +struct btp_gap_sec_level_changed_ev { +uint8_t address_type; +bdaddr_t address; +uint8_t sec_level; +} __packed; +struct btp_gatt_service {uint16_t start_handle;uint16_t end_handle;
Signature · 1 line
2.43.0