Skip to content

Commit e209e5c

Browse files
committed
Bluetooth: MGMT: Mark LL Privacy as stable
This marks LL Privacy as stable by removing its experimental UUID and move its functionality to Device Flag (HCI_CONN_FLAG_ADDRESS_RESOLUTION) which can be set by MGMT Device Set Flags so userspace retain control of the feature. Link: bluez/bluez#1028 Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 0e6dfac commit e209e5c

File tree

4 files changed

+35
-162
lines changed

4 files changed

+35
-162
lines changed

include/net/bluetooth/hci.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,6 @@ enum {
438438
HCI_FORCE_BREDR_SMP,
439439
HCI_FORCE_STATIC_ADDR,
440440
HCI_LL_RPA_RESOLUTION,
441-
HCI_ENABLE_LL_PRIVACY,
442441
HCI_CMD_PENDING,
443442
HCI_FORCE_NO_MITM,
444443
HCI_QUALITY_REPORT,

include/net/bluetooth/hci_core.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@ struct bdaddr_list_with_irk {
157157

158158
/* Bitmask of connection flags */
159159
enum hci_conn_flags {
160-
HCI_CONN_FLAG_REMOTE_WAKEUP = 1,
161-
HCI_CONN_FLAG_DEVICE_PRIVACY = 2,
160+
HCI_CONN_FLAG_REMOTE_WAKEUP = BIT(0),
161+
HCI_CONN_FLAG_DEVICE_PRIVACY = BIT(1),
162+
HCI_CONN_FLAG_ADDRESS_RESOLUTION = BIT(2),
162163
};
163164
typedef u8 hci_conn_flags_t;
164165

@@ -1919,11 +1920,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
19191920

19201921
#define ll_privacy_capable(dev) ((dev)->le_features[0] & HCI_LE_LL_PRIVACY)
19211922

1922-
/* Use LL Privacy based address resolution if supported */
1923-
#define use_ll_privacy(dev) (ll_privacy_capable(dev) && \
1924-
hci_dev_test_flag(dev, HCI_ENABLE_LL_PRIVACY))
1925-
1926-
#define privacy_mode_capable(dev) (use_ll_privacy(dev) && \
1923+
#define privacy_mode_capable(dev) (ll_privacy_capable(dev) && \
19271924
(hdev->commands[39] & 0x04))
19281925

19291926
#define read_key_size_capable(dev) \

net/bluetooth/hci_sync.c

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ int hci_update_random_address_sync(struct hci_dev *hdev, bool require_privacy,
10661066
/* If Controller supports LL Privacy use own address type is
10671067
* 0x03
10681068
*/
1069-
if (use_ll_privacy(hdev))
1069+
if (ll_privacy_capable(hdev))
10701070
*own_addr_type = ADDR_LE_DEV_RANDOM_RESOLVED;
10711071
else
10721072
*own_addr_type = ADDR_LE_DEV_RANDOM;
@@ -2162,7 +2162,7 @@ static int hci_le_set_scan_enable_sync(struct hci_dev *hdev, u8 val,
21622162

21632163
static int hci_le_set_addr_resolution_enable_sync(struct hci_dev *hdev, u8 val)
21642164
{
2165-
if (!use_ll_privacy(hdev))
2165+
if (!ll_privacy_capable(hdev))
21662166
return 0;
21672167

21682168
/* If controller is not/already resolving we are done. */
@@ -2254,7 +2254,7 @@ static int hci_le_del_resolve_list_sync(struct hci_dev *hdev,
22542254
struct hci_cp_le_del_from_resolv_list cp;
22552255
struct bdaddr_list_with_irk *entry;
22562256

2257-
if (!use_ll_privacy(hdev))
2257+
if (!ll_privacy_capable(hdev))
22582258
return 0;
22592259

22602260
/* Check if the IRK has been programmed */
@@ -2319,7 +2319,7 @@ static int hci_le_add_resolve_list_sync(struct hci_dev *hdev,
23192319
struct bdaddr_list_with_irk *entry;
23202320
struct hci_conn_params *p;
23212321

2322-
if (!use_ll_privacy(hdev))
2322+
if (!ll_privacy_capable(hdev))
23232323
return 0;
23242324

23252325
/* Attempt to program local identity address, type and irk if params is
@@ -2332,7 +2332,8 @@ static int hci_le_add_resolve_list_sync(struct hci_dev *hdev,
23322332
hci_copy_identity_address(hdev, &cp.bdaddr, &cp.bdaddr_type);
23332333
memcpy(cp.peer_irk, hdev->irk, 16);
23342334
goto done;
2335-
}
2335+
} else if (!(params->flags & HCI_CONN_FLAG_ADDRESS_RESOLUTION))
2336+
return 0;
23362337

23372338
irk = hci_find_irk_by_addr(hdev, &params->addr, params->addr_type);
23382339
if (!irk)
@@ -2379,6 +2380,10 @@ static int hci_le_set_privacy_mode_sync(struct hci_dev *hdev,
23792380
struct hci_cp_le_set_privacy_mode cp;
23802381
struct smp_irk *irk;
23812382

2383+
if (!ll_privacy_capable(hdev) ||
2384+
!(params->flags & HCI_CONN_FLAG_ADDRESS_RESOLUTION))
2385+
return 0;
2386+
23822387
/* If device privacy mode has already been set there is nothing to do */
23832388
if (params->privacy_mode == HCI_DEVICE_PRIVACY)
23842389
return 0;
@@ -2428,11 +2433,6 @@ static int hci_le_add_accept_list_sync(struct hci_dev *hdev,
24282433
if (*num_entries >= hdev->le_accept_list_size)
24292434
return -ENOSPC;
24302435

2431-
/* Accept list can not be used with RPAs */
2432-
if (!use_ll_privacy(hdev) &&
2433-
hci_find_irk_by_addr(hdev, &params->addr, params->addr_type))
2434-
return -EINVAL;
2435-
24362436
/* Attempt to program the device in the resolving list first to avoid
24372437
* having to rollback in case it fails since the resolving list is
24382438
* dynamic it can probably be smaller than the accept list.
@@ -2567,7 +2567,7 @@ static int hci_pause_addr_resolution(struct hci_dev *hdev)
25672567
{
25682568
int err;
25692569

2570-
if (!use_ll_privacy(hdev))
2570+
if (!ll_privacy_capable(hdev))
25712571
return 0;
25722572

25732573
if (!hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION))
@@ -2671,12 +2671,12 @@ static int hci_le_clear_accept_list_sync(struct hci_dev *hdev)
26712671
*
26722672
* Update is done using the following sequence:
26732673
*
2674-
* use_ll_privacy((Disable Advertising) -> Disable Resolving List) ->
2674+
* ll_privacy_capable((Disable Advertising) -> Disable Resolving List) ->
26752675
* Remove Devices From Accept List ->
2676-
* (has IRK && use_ll_privacy(Remove Devices From Resolving List))->
2676+
* (has IRK && ll_privacy_capable(Remove Devices From Resolving List))->
26772677
* Add Devices to Accept List ->
2678-
* (has IRK && use_ll_privacy(Remove Devices From Resolving List)) ->
2679-
* use_ll_privacy(Enable Resolving List -> (Enable Advertising)) ->
2678+
* (has IRK && ll_privacy_capable(Remove Devices From Resolving List)) ->
2679+
* ll_privacy_capable(Enable Resolving List -> (Enable Advertising)) ->
26802680
* Enable Scanning
26812681
*
26822682
* In case of failure advertising shall be restored to its original state and
@@ -2697,7 +2697,7 @@ static u8 hci_update_accept_list_sync(struct hci_dev *hdev)
26972697
/* Pause advertising if resolving list can be used as controllers
26982698
* cannot accept resolving list modifications while advertising.
26992699
*/
2700-
if (use_ll_privacy(hdev)) {
2700+
if (ll_privacy_capable(hdev)) {
27012701
err = hci_pause_advertising_sync(hdev);
27022702
if (err) {
27032703
bt_dev_err(hdev, "pause advertising failed: %d", err);
@@ -2842,7 +2842,7 @@ static u8 hci_update_accept_list_sync(struct hci_dev *hdev)
28422842
bt_dev_err(hdev, "Unable to enable LL privacy: %d", err);
28432843

28442844
/* Resume advertising if it was paused */
2845-
if (use_ll_privacy(hdev))
2845+
if (ll_privacy_capable(hdev))
28462846
hci_resume_advertising_sync(hdev);
28472847

28482848
/* Select filter policy to use accept list */
@@ -3100,7 +3100,7 @@ static int hci_passive_scan_sync(struct hci_dev *hdev)
31003100
* If there are devices to scan:
31013101
*
31023102
* Disable Scanning -> Update Accept List ->
3103-
* use_ll_privacy((Disable Advertising) -> Disable Resolving List ->
3103+
* ll_privacy_capable((Disable Advertising) -> Disable Resolving List ->
31043104
* Update Resolving List -> Enable Resolving List -> (Enable Advertising)) ->
31053105
* Enable Scanning
31063106
*
@@ -3454,7 +3454,7 @@ int hci_update_name_sync(struct hci_dev *hdev)
34543454
*
34553455
* HCI_SSP_ENABLED(Enable SSP)
34563456
* HCI_LE_ENABLED(Enable LE)
3457-
* HCI_LE_ENABLED(use_ll_privacy(Add local IRK to Resolving List) ->
3457+
* HCI_LE_ENABLED(ll_privacy_capable(Add local IRK to Resolving List) ->
34583458
* Update adv data)
34593459
* Enable Authentication
34603460
* lmp_bredr_capable(Set Fast Connectable -> Set Scan Type -> Set Class ->
@@ -4229,6 +4229,14 @@ static int hci_le_set_event_mask_sync(struct hci_dev *hdev)
42294229
if (use_enhanced_conn_complete(hdev))
42304230
events[1] |= 0x02; /* LE Enhanced Connection Complete */
42314231

4232+
/* Mark Device Privacy if Privacy Mode is supported */
4233+
if (privacy_mode_capable(hdev))
4234+
hdev->conn_flags |= HCI_CONN_FLAG_DEVICE_PRIVACY;
4235+
4236+
/* Mark Address Resolution if LL Privacy is supported */
4237+
if (ll_privacy_capable(hdev))
4238+
hdev->conn_flags |= HCI_CONN_FLAG_ADDRESS_RESOLUTION;
4239+
42324240
/* If the controller supports Extended Scanner Filter
42334241
* Policies, enable the corresponding event.
42344242
*/
@@ -5385,7 +5393,7 @@ int hci_stop_discovery_sync(struct hci_dev *hdev)
53855393
}
53865394

53875395
/* Resume advertising if it was paused */
5388-
if (use_ll_privacy(hdev))
5396+
if (ll_privacy_capable(hdev))
53895397
hci_resume_advertising_sync(hdev);
53905398

53915399
/* No further actions needed for LE-only discovery */
@@ -5897,7 +5905,7 @@ static int hci_active_scan_sync(struct hci_dev *hdev, uint16_t interval)
58975905

58985906
failed:
58995907
/* Resume advertising if it was paused */
5900-
if (use_ll_privacy(hdev))
5908+
if (ll_privacy_capable(hdev))
59015909
hci_resume_advertising_sync(hdev);
59025910

59035911
/* Resume passive scanning */
@@ -6673,7 +6681,7 @@ int hci_get_random_address(struct hci_dev *hdev, bool require_privacy,
66736681
/* If Controller supports LL Privacy use own address type is
66746682
* 0x03
66756683
*/
6676-
if (use_ll_privacy(hdev))
6684+
if (ll_privacy_capable(hdev))
66776685
*own_addr_type = ADDR_LE_DEV_RANDOM_RESOLVED;
66786686
else
66796687
*own_addr_type = ADDR_LE_DEV_RANDOM;

0 commit comments

Comments
 (0)