Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: Enable new connection establishment procedure.

Currently, when trying to connect to already paired device that just
rotated its RPA MAC address, old address would be used and connection
would fail. In order to fix that, kernel must scan and receive
advertisement with fresh RPA before connecting.

This patch enables new connection establishment procedure. Instead of just
sending HCI_OP_LE_CREATE_CONN to controller, "connect" will add device to
kernel whitelist and start scan. If advertisement is received, it'll be
compared against whitelist and then trigger connection if it matches.
That fixes mentioned reconnect issue for already paired devices. It also
make whole connection procedure more robust. We can try to connect to
multiple devices at same time now, even though controller allow only one.

Signed-off-by: Jakub Pawlowski <jpawlowski@google.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

authored by

Jakub Pawlowski and committed by
Marcel Holtmann
fa142220 cc2b6911

+8 -5
+4 -2
net/bluetooth/l2cap_core.c
··· 7113 7113 else 7114 7114 role = HCI_ROLE_MASTER; 7115 7115 7116 - hcon = hci_connect_le(hdev, dst, dst_type, chan->sec_level, 7117 - HCI_LE_CONN_TIMEOUT, role); 7116 + hcon = hci_connect_le_scan(hdev, dst, dst_type, 7117 + chan->sec_level, 7118 + HCI_LE_CONN_TIMEOUT, 7119 + role); 7118 7120 } else { 7119 7121 u8 auth_type = l2cap_get_auth_type(chan); 7120 7122 hcon = hci_connect_acl(hdev, dst, chan->sec_level, auth_type);
+4 -3
net/bluetooth/mgmt.c
··· 3564 3564 */ 3565 3565 hci_conn_params_add(hdev, &cp->addr.bdaddr, addr_type); 3566 3566 3567 - conn = hci_connect_le(hdev, &cp->addr.bdaddr, addr_type, 3568 - sec_level, HCI_LE_CONN_TIMEOUT, 3569 - HCI_ROLE_MASTER); 3567 + conn = hci_connect_le_scan(hdev, &cp->addr.bdaddr, 3568 + addr_type, sec_level, 3569 + HCI_LE_CONN_TIMEOUT, 3570 + HCI_ROLE_MASTER); 3570 3571 } 3571 3572 3572 3573 if (IS_ERR(conn)) {