Skip to content

Commit 5c49bcc

Browse files
nsathish41holtmann
authored andcommitted
Bluetooth: Enable/Disable address resolution during le create conn
In this patch if le_create_conn process is started restrict to disable address resolution and same is disabled during le_enh_connection_complete Signed-off-by: Sathish Narasimman <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent d03c759 commit 5c49bcc

File tree

5 files changed

+47
-14
lines changed

5 files changed

+47
-14
lines changed

net/bluetooth/hci_conn.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,11 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
10031003
struct hci_request req;
10041004
int err;
10051005

1006+
/* This ensures that during disable le_scan address resolution
1007+
* will not be disabled if it is followed by le_create_conn
1008+
*/
1009+
bool rpa_le_conn = true;
1010+
10061011
/* Let's make sure that le is enabled.*/
10071012
if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) {
10081013
if (lmp_le_capable(hdev))
@@ -1103,7 +1108,7 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
11031108
* state.
11041109
*/
11051110
if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) {
1106-
hci_req_add_le_scan_disable(&req);
1111+
hci_req_add_le_scan_disable(&req, rpa_le_conn);
11071112
hci_dev_set_flag(hdev, HCI_LE_SCAN_INTERRUPTED);
11081113
}
11091114

net/bluetooth/hci_event.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5228,6 +5228,10 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev,
52285228
le16_to_cpu(ev->interval),
52295229
le16_to_cpu(ev->latency),
52305230
le16_to_cpu(ev->supervision_timeout));
5231+
5232+
if (use_ll_privacy(hdev) &&
5233+
hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION))
5234+
hci_req_disable_address_resolution(hdev);
52315235
}
52325236

52335237
static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, struct sk_buff *skb)

net/bluetooth/hci_request.c

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ static void __hci_update_background_scan(struct hci_request *req)
428428
if (!hci_dev_test_flag(hdev, HCI_LE_SCAN))
429429
return;
430430

431-
hci_req_add_le_scan_disable(req);
431+
hci_req_add_le_scan_disable(req, false);
432432

433433
BT_DBG("%s stopping background scanning", hdev->name);
434434
} else {
@@ -447,7 +447,7 @@ static void __hci_update_background_scan(struct hci_request *req)
447447
* don't miss any advertising (due to duplicates filter).
448448
*/
449449
if (hci_dev_test_flag(hdev, HCI_LE_SCAN))
450-
hci_req_add_le_scan_disable(req);
450+
hci_req_add_le_scan_disable(req, false);
451451

452452
hci_req_add_le_passive_scan(req);
453453

@@ -652,7 +652,7 @@ void __hci_req_update_eir(struct hci_request *req)
652652
hci_req_add(req, HCI_OP_WRITE_EIR, sizeof(cp), &cp);
653653
}
654654

655-
void hci_req_add_le_scan_disable(struct hci_request *req)
655+
void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn)
656656
{
657657
struct hci_dev *hdev = req->hdev;
658658

@@ -676,8 +676,9 @@ void hci_req_add_le_scan_disable(struct hci_request *req)
676676
hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp);
677677
}
678678

679+
/* Disable address resolution */
679680
if (use_ll_privacy(hdev) &&
680-
hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) {
681+
hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn) {
681682
__u8 enable = 0x00;
682683
hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable);
683684
}
@@ -1072,7 +1073,7 @@ static void hci_req_config_le_suspend_scan(struct hci_request *req)
10721073
{
10731074
/* Before changing params disable scan if enabled */
10741075
if (hci_dev_test_flag(req->hdev, HCI_LE_SCAN))
1075-
hci_req_add_le_scan_disable(req);
1076+
hci_req_add_le_scan_disable(req, false);
10761077

10771078
/* Configure params and enable scanning */
10781079
hci_req_add_le_passive_scan(req);
@@ -1140,7 +1141,7 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next)
11401141

11411142
/* Disable LE passive scan if enabled */
11421143
if (hci_dev_test_flag(hdev, HCI_LE_SCAN))
1143-
hci_req_add_le_scan_disable(&req);
1144+
hci_req_add_le_scan_disable(&req, false);
11441145

11451146
/* Mark task needing completion */
11461147
set_bit(SUSPEND_SCAN_DISABLE, hdev->suspend_tasks);
@@ -1696,6 +1697,28 @@ int hci_req_update_adv_data(struct hci_dev *hdev, u8 instance)
16961697
return hci_req_run(&req, NULL);
16971698
}
16981699

1700+
static void enable_addr_resolution_complete(struct hci_dev *hdev, u8 status,
1701+
u16 opcode)
1702+
{
1703+
BT_DBG("%s status %u", hdev->name, status);
1704+
}
1705+
1706+
void hci_req_disable_address_resolution(struct hci_dev *hdev)
1707+
{
1708+
struct hci_request req;
1709+
__u8 enable = 0x00;
1710+
1711+
if (!use_ll_privacy(hdev) &&
1712+
!hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION))
1713+
return;
1714+
1715+
hci_req_init(&req, hdev);
1716+
1717+
hci_req_add(&req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable);
1718+
1719+
hci_req_run(&req, enable_addr_resolution_complete);
1720+
}
1721+
16991722
static void adv_enable_complete(struct hci_dev *hdev, u8 status, u16 opcode)
17001723
{
17011724
BT_DBG("%s status %u", hdev->name, status);
@@ -2667,7 +2690,7 @@ static void bg_scan_update(struct work_struct *work)
26672690

26682691
static int le_scan_disable(struct hci_request *req, unsigned long opt)
26692692
{
2670-
hci_req_add_le_scan_disable(req);
2693+
hci_req_add_le_scan_disable(req, false);
26712694
return 0;
26722695
}
26732696

@@ -2770,7 +2793,7 @@ static int le_scan_restart(struct hci_request *req, unsigned long opt)
27702793
return 0;
27712794
}
27722795

2773-
hci_req_add_le_scan_disable(req);
2796+
hci_req_add_le_scan_disable(req, false);
27742797

27752798
if (use_ext_scan(hdev)) {
27762799
struct hci_cp_le_set_ext_scan_enable ext_enable_cp;
@@ -2861,7 +2884,7 @@ static int active_scan(struct hci_request *req, unsigned long opt)
28612884
* discovery scanning parameters.
28622885
*/
28632886
if (hci_dev_test_flag(hdev, HCI_LE_SCAN))
2864-
hci_req_add_le_scan_disable(req);
2887+
hci_req_add_le_scan_disable(req, false);
28652888

28662889
/* All active scans will be done with either a resolvable private
28672890
* address (when privacy feature has been enabled) or non-resolvable
@@ -2976,14 +2999,14 @@ bool hci_req_stop_discovery(struct hci_request *req)
29762999

29773000
if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) {
29783001
cancel_delayed_work(&hdev->le_scan_disable);
2979-
hci_req_add_le_scan_disable(req);
3002+
hci_req_add_le_scan_disable(req, false);
29803003
}
29813004

29823005
ret = true;
29833006
} else {
29843007
/* Passive scanning */
29853008
if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) {
2986-
hci_req_add_le_scan_disable(req);
3009+
hci_req_add_le_scan_disable(req, false);
29873010
ret = true;
29883011
}
29893012
}

net/bluetooth/hci_request.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ void __hci_req_write_fast_connectable(struct hci_request *req, bool enable);
6565
void __hci_req_update_name(struct hci_request *req);
6666
void __hci_req_update_eir(struct hci_request *req);
6767

68-
void hci_req_add_le_scan_disable(struct hci_request *req);
68+
void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn);
6969
void hci_req_add_le_passive_scan(struct hci_request *req);
7070

7171
void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next);
7272

73+
void hci_req_disable_address_resolution(struct hci_dev *hdev);
7374
void hci_req_reenable_advertising(struct hci_dev *hdev);
7475
void __hci_req_enable_advertising(struct hci_request *req);
7576
void __hci_req_disable_advertising(struct hci_request *req);

net/bluetooth/mgmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5226,7 +5226,7 @@ static int set_scan_params(struct sock *sk, struct hci_dev *hdev,
52265226

52275227
hci_req_init(&req, hdev);
52285228

5229-
hci_req_add_le_scan_disable(&req);
5229+
hci_req_add_le_scan_disable(&req, false);
52305230
hci_req_add_le_passive_scan(&req);
52315231

52325232
hci_req_run(&req, NULL);

0 commit comments

Comments
 (0)