Skip to content

Commit e1d5723

Browse files
committed
Bluetooth: Configure controller address resolution if available
When the LL Privacy support is available, then as part of enabling or disabling passive background scanning, it is required to set up the controller based address resolution as well. Since only passive background scanning is utilizing the whitelist, the address resolution is now bound to the whitelist and passive background scanning. All other resolution can be easily done by the host stack. Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Sathish Narsimman <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent 6540351 commit e1d5723

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

include/net/bluetooth/hci_core.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,9 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
13591359
#define scan_coded(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_CODED) || \
13601360
((dev)->le_rx_def_phys & HCI_LE_SET_PHY_CODED))
13611361

1362+
/* Use LL Privacy based address resolution if supported */
1363+
#define use_ll_privacy(dev) ((dev)->le_features[0] & HCI_LE_LL_PRIVACY)
1364+
13621365
/* Use ext scanning if set ext scan param and ext scan enable is supported */
13631366
#define use_ext_scan(dev) (((dev)->commands[37] & 0x20) && \
13641367
((dev)->commands[37] & 0x40))

net/bluetooth/hci_request.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,12 @@ void hci_req_add_le_scan_disable(struct hci_request *req)
675675
cp.enable = LE_SCAN_DISABLE;
676676
hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp);
677677
}
678+
679+
if (use_ll_privacy(hdev) &&
680+
hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) {
681+
__u8 enable = 0x00;
682+
hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable);
683+
}
678684
}
679685

680686
static void del_from_white_list(struct hci_request *req, bdaddr_t *bdaddr,
@@ -816,7 +822,8 @@ static bool scan_use_rpa(struct hci_dev *hdev)
816822
}
817823

818824
static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval,
819-
u16 window, u8 own_addr_type, u8 filter_policy)
825+
u16 window, u8 own_addr_type, u8 filter_policy,
826+
bool addr_resolv)
820827
{
821828
struct hci_dev *hdev = req->hdev;
822829

@@ -825,6 +832,11 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval,
825832
return;
826833
}
827834

835+
if (use_ll_privacy(hdev) && addr_resolv) {
836+
u8 enable = 0x01;
837+
hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable);
838+
}
839+
828840
/* Use ext scanning if set ext scan param and ext scan enable is
829841
* supported
830842
*/
@@ -898,12 +910,18 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval,
898910
}
899911
}
900912

913+
/* Ensure to call hci_req_add_le_scan_disable() first to disable the
914+
* controller based address resolution to be able to reconfigure
915+
* resolving list.
916+
*/
901917
void hci_req_add_le_passive_scan(struct hci_request *req)
902918
{
903919
struct hci_dev *hdev = req->hdev;
904920
u8 own_addr_type;
905921
u8 filter_policy;
906922
u16 window, interval;
923+
/* Background scanning should run with address resolution */
924+
bool addr_resolv = true;
907925

908926
if (hdev->scanning_paused) {
909927
bt_dev_dbg(hdev, "Scanning is paused for suspend");
@@ -949,7 +967,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req)
949967

950968
bt_dev_dbg(hdev, "LE passive scan with whitelist = %d", filter_policy);
951969
hci_req_start_scan(req, LE_SCAN_PASSIVE, interval, window,
952-
own_addr_type, filter_policy);
970+
own_addr_type, filter_policy, addr_resolv);
953971
}
954972

955973
static u8 get_adv_instance_scan_rsp_len(struct hci_dev *hdev, u8 instance)
@@ -2789,6 +2807,8 @@ static int active_scan(struct hci_request *req, unsigned long opt)
27892807
u8 own_addr_type;
27902808
/* White list is not used for discovery */
27912809
u8 filter_policy = 0x00;
2810+
/* Discovery doesn't require controller address resolution */
2811+
bool addr_resolv = false;
27922812
int err;
27932813

27942814
BT_DBG("%s", hdev->name);
@@ -2811,7 +2831,7 @@ static int active_scan(struct hci_request *req, unsigned long opt)
28112831

28122832
hci_req_start_scan(req, LE_SCAN_ACTIVE, interval,
28132833
hdev->le_scan_window_discovery, own_addr_type,
2814-
filter_policy);
2834+
filter_policy, addr_resolv);
28152835
return 0;
28162836
}
28172837

0 commit comments

Comments
 (0)