aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/bluetooth/hci_core.h3
-rw-r--r--net/bluetooth/hci_conn.c6
-rw-r--r--net/bluetooth/hci_event.c3
-rw-r--r--net/bluetooth/l2cap_core.c6
-rw-r--r--net/bluetooth/mgmt.c3
5 files changed, 15 insertions, 6 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 8752ac674db1..5701d15779dd 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -704,7 +704,8 @@ void hci_chan_list_flush(struct hci_conn *conn);
704struct hci_chan *hci_chan_lookup_handle(struct hci_dev *hdev, __u16 handle); 704struct hci_chan *hci_chan_lookup_handle(struct hci_dev *hdev, __u16 handle);
705 705
706struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, 706struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
707 u8 dst_type, u8 sec_level, u16 conn_timeout); 707 u8 dst_type, u8 sec_level, u16 conn_timeout,
708 bool master);
708struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst, 709struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,
709 u8 sec_level, u8 auth_type); 710 u8 sec_level, u8 auth_type);
710struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst, 711struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst,
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 9323044f01cd..16fd55da9c1d 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -700,7 +700,8 @@ static void hci_req_directed_advertising(struct hci_request *req,
700} 700}
701 701
702struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, 702struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
703 u8 dst_type, u8 sec_level, u16 conn_timeout) 703 u8 dst_type, u8 sec_level, u16 conn_timeout,
704 bool master)
704{ 705{
705 struct hci_conn_params *params; 706 struct hci_conn_params *params;
706 struct hci_conn *conn; 707 struct hci_conn *conn;
@@ -760,7 +761,8 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
760 761
761 hci_req_init(&req, hdev); 762 hci_req_init(&req, hdev);
762 763
763 if (test_bit(HCI_ADVERTISING, &hdev->dev_flags)) { 764 /* If requested to connect as slave use directed advertising */
765 if (!master) {
764 hci_req_directed_advertising(&req, conn); 766 hci_req_directed_advertising(&req, conn);
765 goto create_conn; 767 goto create_conn;
766 } 768 }
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index ad39d9ad6fbc..a6816498b0b9 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -4253,8 +4253,9 @@ static void check_pending_le_conn(struct hci_dev *hdev, bdaddr_t *addr,
4253 return; 4253 return;
4254 4254
4255connect: 4255connect:
4256 /* Request connection in master = true role */
4256 conn = hci_connect_le(hdev, addr, addr_type, BT_SECURITY_LOW, 4257 conn = hci_connect_le(hdev, addr, addr_type, BT_SECURITY_LOW,
4257 HCI_LE_AUTOCONN_TIMEOUT); 4258 HCI_LE_AUTOCONN_TIMEOUT, true);
4258 if (!IS_ERR(conn)) 4259 if (!IS_ERR(conn))
4259 return; 4260 return;
4260 4261
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 3daab4588522..bf379a379fa0 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -7124,6 +7124,8 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
7124 chan->dcid = cid; 7124 chan->dcid = cid;
7125 7125
7126 if (bdaddr_type_is_le(dst_type)) { 7126 if (bdaddr_type_is_le(dst_type)) {
7127 bool master;
7128
7127 /* Convert from L2CAP channel address type to HCI address type 7129 /* Convert from L2CAP channel address type to HCI address type
7128 */ 7130 */
7129 if (dst_type == BDADDR_LE_PUBLIC) 7131 if (dst_type == BDADDR_LE_PUBLIC)
@@ -7131,8 +7133,10 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
7131 else 7133 else
7132 dst_type = ADDR_LE_DEV_RANDOM; 7134 dst_type = ADDR_LE_DEV_RANDOM;
7133 7135
7136 master = !test_bit(HCI_ADVERTISING, &hdev->dev_flags);
7137
7134 hcon = hci_connect_le(hdev, dst, dst_type, chan->sec_level, 7138 hcon = hci_connect_le(hdev, dst, dst_type, chan->sec_level,
7135 HCI_LE_CONN_TIMEOUT); 7139 HCI_LE_CONN_TIMEOUT, master);
7136 } else { 7140 } else {
7137 u8 auth_type = l2cap_get_auth_type(chan); 7141 u8 auth_type = l2cap_get_auth_type(chan);
7138 hcon = hci_connect_acl(hdev, dst, chan->sec_level, auth_type); 7142 hcon = hci_connect_acl(hdev, dst, chan->sec_level, auth_type);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index e7047de1ba11..b391e2fef4b6 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3117,8 +3117,9 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
3117 */ 3117 */
3118 hci_conn_params_add(hdev, &cp->addr.bdaddr, addr_type); 3118 hci_conn_params_add(hdev, &cp->addr.bdaddr, addr_type);
3119 3119
3120 /* Request a connection with master = true role */
3120 conn = hci_connect_le(hdev, &cp->addr.bdaddr, addr_type, 3121 conn = hci_connect_le(hdev, &cp->addr.bdaddr, addr_type,
3121 sec_level, HCI_LE_CONN_TIMEOUT); 3122 sec_level, HCI_LE_CONN_TIMEOUT, true);
3122 } 3123 }
3123 3124
3124 if (IS_ERR(conn)) { 3125 if (IS_ERR(conn)) {