Skip to content

Commit 4c7c12e

Browse files
committed
Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth
Johan Hedberg says: ==================== pull request: bluetooth 2018-04-08 Here's one important Bluetooth fix for the 4.17-rc series that's needed to pass several Bluetooth qualification test cases. Let me know if there are any issues pulling. Thanks. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents fc56be4 + 082f230 commit 4c7c12e

File tree

4 files changed

+34
-14
lines changed

4 files changed

+34
-14
lines changed

include/net/bluetooth/hci_core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ struct hci_conn *hci_connect_le_scan(struct hci_dev *hdev, bdaddr_t *dst,
895895
u16 conn_timeout);
896896
struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
897897
u8 dst_type, u8 sec_level, u16 conn_timeout,
898-
u8 role);
898+
u8 role, bdaddr_t *direct_rpa);
899899
struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,
900900
u8 sec_level, u8 auth_type);
901901
struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst,

net/bluetooth/hci_conn.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -749,18 +749,31 @@ static bool conn_use_rpa(struct hci_conn *conn)
749749
}
750750

751751
static void hci_req_add_le_create_conn(struct hci_request *req,
752-
struct hci_conn *conn)
752+
struct hci_conn *conn,
753+
bdaddr_t *direct_rpa)
753754
{
754755
struct hci_cp_le_create_conn cp;
755756
struct hci_dev *hdev = conn->hdev;
756757
u8 own_addr_type;
757758

758-
/* Update random address, but set require_privacy to false so
759-
* that we never connect with an non-resolvable address.
759+
/* If direct address was provided we use it instead of current
760+
* address.
760761
*/
761-
if (hci_update_random_address(req, false, conn_use_rpa(conn),
762-
&own_addr_type))
763-
return;
762+
if (direct_rpa) {
763+
if (bacmp(&req->hdev->random_addr, direct_rpa))
764+
hci_req_add(req, HCI_OP_LE_SET_RANDOM_ADDR, 6,
765+
direct_rpa);
766+
767+
/* direct address is always RPA */
768+
own_addr_type = ADDR_LE_DEV_RANDOM;
769+
} else {
770+
/* Update random address, but set require_privacy to false so
771+
* that we never connect with an non-resolvable address.
772+
*/
773+
if (hci_update_random_address(req, false, conn_use_rpa(conn),
774+
&own_addr_type))
775+
return;
776+
}
764777

765778
memset(&cp, 0, sizeof(cp));
766779

@@ -825,7 +838,7 @@ static void hci_req_directed_advertising(struct hci_request *req,
825838

826839
struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
827840
u8 dst_type, u8 sec_level, u16 conn_timeout,
828-
u8 role)
841+
u8 role, bdaddr_t *direct_rpa)
829842
{
830843
struct hci_conn_params *params;
831844
struct hci_conn *conn;
@@ -940,7 +953,7 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
940953
hci_dev_set_flag(hdev, HCI_LE_SCAN_INTERRUPTED);
941954
}
942955

943-
hci_req_add_le_create_conn(&req, conn);
956+
hci_req_add_le_create_conn(&req, conn, direct_rpa);
944957

945958
create_conn:
946959
err = hci_req_run(&req, create_le_conn_complete);

net/bluetooth/hci_event.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4648,7 +4648,8 @@ static void hci_le_conn_update_complete_evt(struct hci_dev *hdev,
46484648
/* This function requires the caller holds hdev->lock */
46494649
static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev,
46504650
bdaddr_t *addr,
4651-
u8 addr_type, u8 adv_type)
4651+
u8 addr_type, u8 adv_type,
4652+
bdaddr_t *direct_rpa)
46524653
{
46534654
struct hci_conn *conn;
46544655
struct hci_conn_params *params;
@@ -4699,7 +4700,8 @@ static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev,
46994700
}
47004701

47014702
conn = hci_connect_le(hdev, addr, addr_type, BT_SECURITY_LOW,
4702-
HCI_LE_AUTOCONN_TIMEOUT, HCI_ROLE_MASTER);
4703+
HCI_LE_AUTOCONN_TIMEOUT, HCI_ROLE_MASTER,
4704+
direct_rpa);
47034705
if (!IS_ERR(conn)) {
47044706
/* If HCI_AUTO_CONN_EXPLICIT is set, conn is already owned
47054707
* by higher layer that tried to connect, if no then
@@ -4808,8 +4810,13 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
48084810
bdaddr_type = irk->addr_type;
48094811
}
48104812

4811-
/* Check if we have been requested to connect to this device */
4812-
conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, type);
4813+
/* Check if we have been requested to connect to this device.
4814+
*
4815+
* direct_addr is set only for directed advertising reports (it is NULL
4816+
* for advertising reports) and is already verified to be RPA above.
4817+
*/
4818+
conn = check_pending_le_conn(hdev, bdaddr, bdaddr_type, type,
4819+
direct_addr);
48134820
if (conn && type == LE_ADV_IND) {
48144821
/* Store report for later inclusion by
48154822
* mgmt_device_connected

net/bluetooth/l2cap_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7156,7 +7156,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
71567156
hcon = hci_connect_le(hdev, dst, dst_type,
71577157
chan->sec_level,
71587158
HCI_LE_CONN_TIMEOUT,
7159-
HCI_ROLE_SLAVE);
7159+
HCI_ROLE_SLAVE, NULL);
71607160
else
71617161
hcon = hci_connect_le_scan(hdev, dst, dst_type,
71627162
chan->sec_level,

0 commit comments

Comments
 (0)