Bluetooth: hci_sync: Fix not setting Random Address when required
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH 1/3 Bluetooth: hci_sync: Fix not setting Random Address when required
From: Luiz Augusto von Dentz <[email protected]>
This fixes errors such as the following when Own address type is set to Random Address but it has not been programmed yet due to either be advertising or connecting:
< HCI Command: LE Set Exte.. (0x08|0x0041) plen 13
Own address type: Random (0x03)
Filter policy: Ignore not in accept list (0x01)
PHYs: 0x05
Entry 0: LE 1M
Type: Passive (0x00)
Interval: 60.000 msec (0x0060)
Window: 30.000 msec (0x0030)
Entry 1: LE Coded
Type: Passive (0x00)
Interval: 180.000 msec (0x0120)
Window: 90.000 msec (0x0090)Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 4
LE Set Extended Scan Parameters (0x08|0x0041) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Exten.. (0x08|0x0042) plen 6
Extended scan: Enabled (0x01)
Filter duplicates: Enabled (0x01)
Duration: 0 msec (0x0000)
Period: 0.00 sec (0x0000)Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 4
LE Set Extended Scan Enable (0x08|0x0042) ncmd 1
Status: Invalid HCI Command Parameters (0x12)--- net/bluetooth/hci_sync.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
net/bluetooth/hci_sync.c +6 -5
@@ -1031,9 +1031,9 @@ static bool adv_use_rpa(struct hci_dev *hdev, uint32_t flags)static int hci_set_random_addr_sync (struct hci_dev *hdev,bdaddr_t *rpa) { -/* If we're advertising or initiating an LE connection we can't -* go ahead and change the random address at this time. This is -* because the eventual initiator address used for the +/* If a random_addr has been set we're advertising or initiating an LE +* connection we can't go ahead and change the random address at this +* time. This is because the eventual initiator address used for the * subsequently created connection will be undefined (some * controllers use the new address and others the one we had * when the operation started).
@@ -1041,8 +1041,9 @@ static int hci_set_random_addr_sync(struct hci_dev *hdev, bdaddr_t *rpa)* In this kind of scenario skip the update and let the random * address be updated at the next cycle. */ -if (hci_dev_test_flag (hdev,HCI_LE_ADV ) || -hci_lookup_le_connect (hdev)) { +if (bacmp (&hdev->random_addr,BDADDR_ANY ) && + (hci_dev_test_flag (hdev,HCI_LE_ADV ) || +hci_lookup_le_connect (hdev))) {bt_dev_dbg (hdev,"Deferring random address update" );hci_dev_set_flag (hdev,HCI_RPA_EXPIRED );return 0 ;
Signature · 1 line
2.47.0
Luiz Augusto von Dentz
maintainerPATCH 2/3 Bluetooth: MGMT: Fix Add Device to responding before completing
From: Luiz Augusto von Dentz <[email protected]>
Add Device with LE type requires updating resolving/accept list which requires quite a number of commands to complete and each of them may fail, so instead of pretending it would always work this checks the return of hci_update_passive_scan_sync which indicates if everything worked as intended.
--- net/bluetooth/mgmt.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-)
net/bluetooth/mgmt.c +36 -2
@@ -7655,6 +7655,24 @@ static void device_added(struct sock *sk, struct hci_dev *hdev,mgmt_event (MGMT_EV_DEVICE_ADDED , hdev, &ev,sizeof (ev), sk); } +static void add_device_complete (struct hci_dev *hdev,void *data,int err) +{ +struct mgmt_pending_cmd *cmd = data; +struct mgmt_cp_add_device *cp = cmd->param; + +if (!err) { +device_added (cmd->sk, hdev, &cp->addr.bdaddr, cp->addr.type, + cp->action); +device_flags_changed (NULL , hdev, &cp->addr.bdaddr, + cp->addr.type, hdev->conn_flags, +PTR_UINT (cmd->user_data)); + } + +mgmt_cmd_complete (cmd->sk, hdev->id,MGMT_OP_ADD_DEVICE , +mgmt_status (err), &cp->addr,sizeof (cp->addr)); +mgmt_pending_free (cmd); +} +static int add_device_sync (struct hci_dev *hdev,void *data) {return hci_update_passive_scan_sync (hdev);
@@ -7663,6 +7681,7 @@ static int add_device_sync(struct hci_dev *hdev, void *data)static int add_device (struct sock *sk,struct hci_dev *hdev,void *data,u16 len) { +struct mgmt_pending_cmd *cmd;struct mgmt_cp_add_device *cp = data;u8 auto_conn, addr_type;struct hci_conn_params *params;
@@ -7743,9 +7762,24 @@ static int add_device(struct sock *sk, struct hci_dev *hdev, current_flags = params->flags; } - err =hci_cmd_sync_queue (hdev, add_device_sync,NULL ,NULL ); -if (err <0 ) + cmd =mgmt_pending_new (sk,MGMT_OP_ADD_DEVICE , hdev, data, len); +if (!cmd) { + err = -ENOMEM ; goto unlock; + } + + cmd->user_data =UINT_PTR (current_flags); + + err =hci_cmd_sync_queue (hdev, add_device_sync, cmd, + add_device_complete); +if (err <0 ) { + err =mgmt_cmd_complete (sk, hdev->id,MGMT_OP_ADD_DEVICE , +MGMT_STATUS_FAILED , &cp->addr, +sizeof (cp->addr)); +mgmt_pending_free (cmd); + } + + goto unlock; added:device_added (sk, hdev, &cp->addr.bdaddr, cp->addr.type, cp->action);
Signature · 1 line
2.47.0
Luiz Augusto von Dentz
maintainerPATCH 3/3 Bluetooth: MGMT: Mark LL Privacy as stable
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This marks LL Privacy as stable by removing its experimental UUID and move its functionality to Device Flag (HCI_CONN_FLAG_ADDRESS_RESOLUTION) which can be set by MGMT Device Set Flags so userspace retain control of the feature.
--- include/net/bluetooth/hci.h | 1 - include/net/bluetooth/hci_core.h | 11 +-- net/bluetooth/hci_sync.c | 52 +++++++----- net/bluetooth/mgmt.c | 133 +------------------------------ 4 files changed, 35 insertions(+), 162 deletions(-)
include/net/bluetooth/hci.h +0 -1
@@ -438,7 +438,6 @@ enum {HCI_FORCE_BREDR_SMP ,HCI_FORCE_STATIC_ADDR ,HCI_LL_RPA_RESOLUTION , -HCI_ENABLE_LL_PRIVACY ,HCI_CMD_PENDING ,HCI_FORCE_NO_MITM , HCI_QUALITY_REPORT,
include/net/bluetooth/hci_core.h +4 -7
@@ -157,8 +157,9 @@ struct bdaddr_list_with_irk {/* Bitmask of connection flags */ enum hci_conn_flags { -HCI_CONN_FLAG_REMOTE_WAKEUP =1 , -HCI_CONN_FLAG_DEVICE_PRIVACY =2 , +HCI_CONN_FLAG_REMOTE_WAKEUP =BIT (0 ), +HCI_CONN_FLAG_DEVICE_PRIVACY =BIT (1 ), +HCI_CONN_FLAG_ADDRESS_RESOLUTION =BIT (2 ), };typedef u8 hci_conn_flags_t ;
@@ -1920,11 +1921,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn);#define ll_privacy_capable (dev) ((dev)->le_features[0] & HCI_LE_LL_PRIVACY) -/* Use LL Privacy based address resolution if supported */ -#define use_ll_privacy (dev) (ll_privacy_capable(dev) && \ - hci_dev_test_flag(dev, HCI_ENABLE_LL_PRIVACY)) - -#define privacy_mode_capable (dev) (use_ll_privacy(dev) && \ +#define privacy_mode_capable (dev) (ll_privacy_capable(dev) && \ (hdev->commands[39] & 0x04))#define read_key_size_capable (dev) \
net/bluetooth/hci_sync.c +30 -22
156 lines not on this page · raw message
net/bluetooth/mgmt.c +1 -132
187 lines not on this page · raw message
Signature · 1 line
2.47.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/project/bluetooth/list/?series=912340
---Test result---
Test Summary:
CheckPatch PENDING 0.39 seconds GitLint PENDING 0.29 seconds SubjectPrefix PASS 0.18 seconds BuildKernel PASS 25.82 seconds CheckAllWarning PASS 27.63 seconds CheckSparse PASS 31.88 seconds BuildKernel32 PASS 25.48 seconds TestRunnerSetup PASS 440.95 seconds TestRunner_l2cap-tester PASS 20.45 seconds TestRunner_iso-tester FAIL 31.29 seconds TestRunner_bnep-tester PASS 8.00 seconds TestRunner_mgmt-tester FAIL 124.13 seconds TestRunner_rfcomm-tester PASS 7.55 seconds TestRunner_sco-tester PASS 11.38 seconds TestRunner_ioctl-tester PASS 8.62 seconds TestRunner_mesh-tester PASS 6.10 seconds TestRunner_smp-tester PASS 6.93 seconds TestRunner_userchan-tester PASS 4.96 seconds IncrementalBuild PENDING 0.68 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: TestRunner_iso-tester - FAIL
Desc: Run iso-tester with test-runner
Output:
WARNING: possible circular locking dependency detected
Total: 124, Passed: 120 (96.8%), Failed: 0, Not Run: 4
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 492, Passed: 461 (93.7%), Failed: 3, Not Run: 28
Failed Test Cases
Get Device Flags - Success Failed 0.116 seconds Set Device Flags - Success Failed 0.103 seconds Read Exp Feature - Success Failed 0.084 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth
This series was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 26 lines · On Mon, 25 Nov 2024 15:42:09 -0500 you wrote:
From: Luiz Augusto von Dentz <[email protected]>
This fixes errors such as the following when Own address type is set to Random Address but it has not been programmed yet due to either be advertising or connecting:
< HCI Command: LE Set Exte.. (0x08|0x0041) plen 13
Own address type: Random (0x03) Filter policy: Ignore not in accept list (0x01) PHYs: 0x05 Entry 0: LE 1M Type: Passive (0x00) Interval: 60.000 msec (0x0060) Window: 30.000 msec (0x0030) Entry 1: LE Coded Type: Passive (0x00) Interval: 180.000 msec (0x0120) Window: 90.000 msec (0x0090)Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 4LE Set Extended Scan Parameters (0x08|0x0041) ncmd 1 Status: Success (0x00) < HCI Command: LE Set Exten.. (0x08|0x0042) plen 6 Extended scan: Enabled (0x01) Filter duplicates: Enabled (0x01) Duration: 0 msec (0x0000) Period: 0.00 sec (0x0000)
Quoted 5 lines
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 4LE Set Extended Scan Enable (0x08|0x0042) ncmd 1 Status: Invalid HCI Command Parameters (0x12)[...]
Here is the summary with links:
- [v1,1/3] Bluetooth: hci_sync: Fix not setting Random Address when required
https://git.kernel.org/bluetooth/bluetooth-next/c/e8e5b0502559 - [v1,2/3] Bluetooth: MGMT: Fix Add Device to responding before completing https://git.kernel.org/bluetooth/bluetooth-next/c/fcd17fe2deb9 - [v1,3/3] Bluetooth: MGMT: Mark LL Privacy as stable https://git.kernel.org/bluetooth/bluetooth-next/c/514e14b1a7c3
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html