Bluetooth: Introduce HCI_CONN_FLAG_DEVICE_PRIVACY device flag
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH 1/2 Bluetooth: Introduce HCI_CONN_FLAG_DEVICE_PRIVACY device flag
From: Luiz Augusto von Dentz <[email protected]>
This introduces HCI_CONN_FLAG_DEVICE_PRIVACY which can be used by userspace to indicate to the controller to use Device Privacy Mode to a specific device.
--- include/net/bluetooth/hci_core.h | 4 ++++ net/bluetooth/mgmt.c | 12 ++++++++++++ 2 files changed, 16 insertions(+)
include/net/bluetooth/hci_core.h +4 -0
@@ -154,6 +154,7 @@ struct bdaddr_list_with_irk {enum hci_conn_flags {HCI_CONN_FLAG_REMOTE_WAKEUP , +HCI_CONN_FLAG_DEVICE_PRIVACY , __HCI_CONN_NUM_FLAGS, };
@@ -1466,6 +1467,9 @@ void hci_conn_del_sysfs(struct hci_conn *conn);#define use_ll_privacy (dev) (ll_privacy_capable(dev) && \ hci_dev_test_flag(dev, HCI_ENABLE_LL_PRIVACY)) +#define privacy_mode_capable (dev) (use_ll_privacy(dev) && \ + (hdev->commands[39] & 0x04)) +/* Use enhanced synchronous connection if command is supported */ #define enhanced_sco_capable (dev) ((dev)->commands[29] & 0x08)
net/bluetooth/mgmt.c +12 -0
@@ -3978,6 +3978,11 @@ static int exp_ll_privacy_feature_changed(bool enabled, struct hci_dev *hdev,memcpy (ev.uuid, rpa_resolution_uuid,16 ); ev.flags =cpu_to_le32 ((enabled ?BIT (0 ) :0 ) |BIT (1 )); +if (enabled &&privacy_mode_capable (hdev)) +set_bit (HCI_CONN_FLAG_DEVICE_PRIVACY , hdev->conn_flags); +else +clear_bit (HCI_CONN_FLAG_DEVICE_PRIVACY , hdev->conn_flags); +return mgmt_limited_event (MGMT_EV_EXP_FEATURE_CHANGED , hdev, &ev,sizeof (ev),HCI_MGMT_EXP_FEATURE_EVENTS , skip);
@@ -4461,6 +4466,13 @@ static int set_device_flags(struct sock *sk, struct hci_dev *hdev, void *data,if (params) {bitmap_from_u64 (params->flags, current_flags); status =MGMT_STATUS_SUCCESS ; + +/* Update passive scan if HCI_CONN_FLAG_DEVICE_PRIVACY +* has been set. +*/ +if (test_bit (HCI_CONN_FLAG_DEVICE_PRIVACY , + params->flags)) +hci_update_passive_scan (hdev); }else { bt_dev_warn(hdev, "No such LE device %pMR (0x%x)", &cp->addr.bdaddr,
Signature · 1 line
2.33.1
Luiz Augusto von Dentz
maintainerPATCH 2/2 Bluetooth: hci_sync: Set Privacy Mode when updating the resolving list
From: Luiz Augusto von Dentz <[email protected]>
This adds support for Set Privacy Mode when updating the resolving list when HCI_CONN_FLAG_DEVICE_PRIVACY so the controller shall use Device Mode for devices programmed in the resolving list, Device Mode is actually required when the remote device are not able to use RPA as otherwise the default mode is Network Privacy Mode in which only allows RPAs thus the controller would filter out advertisement using identity addresses for which there is an IRK.
--- include/net/bluetooth/hci.h | 10 +++++++ include/net/bluetooth/hci_core.h | 1 + net/bluetooth/hci_event.c | 30 ++++++++++++++++++- net/bluetooth/hci_sync.c | 51 ++++++++++++++++++++++++++++---- 4 files changed, 85 insertions(+), 7 deletions(-)
include/net/bluetooth/hci.h +10 -0
@@ -1940,6 +1940,16 @@ struct hci_rp_le_read_transmit_power {__s8 max_le_tx_power; } __packed; +#define HCI_NETWORK_PRIVACY 0x00 +#define HCI_DEVICE_PRIVACY 0x01 + +#define HCI_OP_LE_SET_PRIVACY_MODE 0x204e +struct hci_cp_le_set_privacy_mode { +__u8 bdaddr_type; +bdaddr_t bdaddr; +__u8 mode; +} __packed; +#define HCI_OP_LE_READ_BUFFER_SIZE_V2 0x2060struct hci_rp_le_read_buffer_size_v2 {__u8 status;
include/net/bluetooth/hci_core.h +1 -0
@@ -757,6 +757,7 @@ struct hci_conn_params {struct hci_conn *conn;bool explicit_connect;DECLARE_BITMAP (flags, __HCI_CONN_NUM_FLAGS); +u8 privacy_mode; };extern struct list_head hci_dev_list;
net/bluetooth/hci_event.c +29 -1
@@ -1489,6 +1489,33 @@ static u8 hci_cc_le_read_transmit_power(struct hci_dev *hdev, void *data,return rp->status; } +static u8 hci_cc_le_set_privacy_mode (struct hci_dev *hdev,void *data, +struct sk_buff *skb) +{ +struct hci_ev_status *rp = data; +struct hci_cp_le_set_privacy_mode *cp; +struct hci_conn_params *params; + +bt_dev_dbg (hdev,"status 0x%2.2x" , rp->status); + +if (rp->status) +return rp->status; + + cp =hci_sent_cmd_data (hdev,HCI_OP_LE_SET_PRIVACY_MODE ); +if (!cp) +return rp->status; + +hci_dev_lock (hdev); + + params =hci_conn_params_lookup (hdev, &cp->bdaddr, cp->bdaddr_type); +if (params) + params->privacy_mode = cp->mode; + +hci_dev_unlock (hdev); + +return rp->status; +} +static u8 hci_cc_le_set_adv_enable (struct hci_dev *hdev,void *data,struct sk_buff *skb) {
@@ -3887,7 +3914,8 @@ static const struct hci_cc {HCI_CC_STATUS (HCI_OP_LE_REMOVE_ADV_SET , hci_cc_le_remove_adv_set),HCI_CC_STATUS (HCI_OP_LE_CLEAR_ADV_SETS , hci_cc_le_clear_adv_sets),HCI_CC (HCI_OP_LE_READ_TRANSMIT_POWER , hci_cc_le_read_transmit_power, -sizeof (struct hci_rp_le_read_transmit_power )) +sizeof (struct hci_rp_le_read_transmit_power )), +HCI_CC_STATUS (HCI_OP_LE_SET_PRIVACY_MODE , hci_cc_le_set_privacy_mode) }; static u8 hci_cc_func(struct hci_dev *hdev, const struct hci_cc *cc,
net/bluetooth/hci_sync.c +45 -6
70 lines not on this page · raw message
Signature · 1 line
2.33.1
Marcel Holtmann
maintainerRe: [PATCH 2/2] Bluetooth: hci_sync: Set Privacy Mode when updating the resolving list
Hi Luiz,
Quoted 8 lines
This adds support for Set Privacy Mode when updating the resolving list when
HCI_CONN_FLAG_DEVICE_PRIVACYso the controller shall use Device Mode for devices programmed in the resolving list, Device Mode is actually required when the remote device are not able to use RPA as otherwise the default mode is Network Privacy Mode in which only allows RPAs thus the controller would filter out advertisement using identity addresses for which there is an IRK.
Quoted 7 lines
Signed-off-by Luiz Augusto von Dentz <[email protected]>---
include/net/bluetooth/hci.h | 10 +++++++ include/net/bluetooth/hci_core.h | 1 + net/bluetooth/hci_event.c | 30 ++++++++++++++++++- net/bluetooth/hci_sync.c | 51 ++++++++++++++++++++++++++++---- 4 files changed, 85 insertions(+), 7 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
Marcel Holtmann
maintainerHi Luiz,
Quoted 9 lines
This introduces
HCI_CONN_FLAG_DEVICE_PRIVACYwhich can be used by userspace to indicate to the controller to use Device Privacy Mode to a specific device.Signed-off-by Luiz Augusto von Dentz <[email protected]>---
include/net/bluetooth/hci_core.h| 4 ++++net/bluetooth/mgmt.c| 12 ++++++++++++2 files changed, 16 insertions(+)
patch has been applied to bluetooth-next tree.
Regards
Marcel