Skip to content

Commit 0bdd889

Browse files
committed
Bluetooth: hci_event: Fix enabling passive scanning
Passive scanning shall only be enabled when disconnecting LE links, otherwise it may start result in triggering scanning when e.g. an ISO link disconnects: > HCI Event: LE Meta Event (0x3e) plen 29 LE Connected Isochronous Stream Established (0x19) Status: Success (0x00) Connection Handle: 257 CIG Synchronization Delay: 0 us (0x000000) CIS Synchronization Delay: 0 us (0x000000) Central to Peripheral Latency: 10000 us (0x002710) Peripheral to Central Latency: 10000 us (0x002710) Central to Peripheral PHY: LE 2M (0x02) Peripheral to Central PHY: LE 2M (0x02) Number of Subevents: 1 Central to Peripheral Burst Number: 1 Peripheral to Central Burst Number: 1 Central to Peripheral Flush Timeout: 2 Peripheral to Central Flush Timeout: 2 Central to Peripheral MTU: 320 Peripheral to Central MTU: 160 ISO Interval: 10.00 msec (0x0008) ... > HCI Event: Disconnect Complete (0x05) plen 4 Status: Success (0x00) Handle: 257 Reason: Remote User Terminated Connection (0x13) < HCI Command: LE Set Extended Scan Enable (0x08|0x0042) plen 6 Extended scan: Enabled (0x01) Filter duplicates: Enabled (0x01) Duration: 0 msec (0x0000) Period: 0.00 sec (0x0000) Fixes: 9fcb18e ("Bluetooth: Introduce LE auto connect options") Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 8d74c91 commit 0bdd889

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

net/bluetooth/hci_event.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3391,23 +3391,30 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, void *data,
33913391
hci_update_scan(hdev);
33923392
}
33933393

3394-
params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type);
3395-
if (params) {
3396-
switch (params->auto_connect) {
3397-
case HCI_AUTO_CONN_LINK_LOSS:
3398-
if (ev->reason != HCI_ERROR_CONNECTION_TIMEOUT)
3394+
/* Re-enable passive scanning if disconnected device is marked
3395+
* as auto-connectable.
3396+
*/
3397+
if (conn->type == LE_LINK) {
3398+
params = hci_conn_params_lookup(hdev, &conn->dst,
3399+
conn->dst_type);
3400+
if (params) {
3401+
switch (params->auto_connect) {
3402+
case HCI_AUTO_CONN_LINK_LOSS:
3403+
if (ev->reason != HCI_ERROR_CONNECTION_TIMEOUT)
3404+
break;
3405+
fallthrough;
3406+
3407+
case HCI_AUTO_CONN_DIRECT:
3408+
case HCI_AUTO_CONN_ALWAYS:
3409+
hci_pend_le_list_del_init(params);
3410+
hci_pend_le_list_add(params,
3411+
&hdev->pend_le_conns);
3412+
hci_update_passive_scan(hdev);
33993413
break;
3400-
fallthrough;
34013414

3402-
case HCI_AUTO_CONN_DIRECT:
3403-
case HCI_AUTO_CONN_ALWAYS:
3404-
hci_pend_le_list_del_init(params);
3405-
hci_pend_le_list_add(params, &hdev->pend_le_conns);
3406-
hci_update_passive_scan(hdev);
3407-
break;
3408-
3409-
default:
3410-
break;
3415+
default:
3416+
break;
3417+
}
34113418
}
34123419
}
34133420

0 commit comments

Comments
 (0)