From: Sathish Narasimman <nsathish41@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Sathish Narasimman <sathish.narasimman@intel.com>
Subject: [PATCH v3 8/8] Bluetooth: Add support to enable LL PRIVACY using set_privacy
Date: Wed, 1 Jul 2020 15:34:32 +0530 [thread overview]
Message-ID: <20200701100432.28038-9-sathish.narasimman@intel.com> (raw)
In-Reply-To: <20200701100432.28038-1-sathish.narasimman@intel.com>
Enable LL Privacy using mgmt set_privacy command. The privacy
value 0x03 is used here to enable LL Privacy.
Still to use LL Privacy controller support is must.
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
---
include/net/bluetooth/hci.h | 1 +
net/bluetooth/hci_event.c | 6 ++++--
net/bluetooth/hci_request.c | 15 ++++++++++-----
net/bluetooth/mgmt.c | 6 +++++-
4 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 4ff2fc4498f3..2a42c7ceabb2 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -286,6 +286,7 @@ enum {
HCI_SC_ONLY,
HCI_PRIVACY,
HCI_LIMITED_PRIVACY,
+ HCI_ENABLE_LL_PRIVACY,
HCI_RPA_EXPIRED,
HCI_RPA_RESOLVING,
HCI_HS_ENABLED,
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 47a4050462ed..589bac9859ce 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2301,7 +2301,8 @@ static void cs_le_create_conn(struct hci_dev *hdev, bdaddr_t *peer_addr,
* converted back into either public address or random address type
*/
if (use_ll_privacy(hdev) &&
- hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) {
+ hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) &&
+ hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) {
switch (own_address_type) {
case ADDR_LE_DEV_PUBLIC_RESOLVED:
own_address_type = ADDR_LE_DEV_PUBLIC;
@@ -5223,7 +5224,8 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev,
le16_to_cpu(ev->supervision_timeout));
if (use_ll_privacy(hdev) &&
- hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION))
+ hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) &&
+ hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY))
hci_req_disable_address_resolution(hdev);
}
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index 0dc587026753..e1c2e2c13456 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -678,7 +678,8 @@ void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn)
/* Disable address resolution */
if (use_ll_privacy(hdev) &&
- hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn) {
+ hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn &&
+ hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) {
__u8 enable = 0x00;
hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable);
}
@@ -696,7 +697,8 @@ static void del_from_white_list(struct hci_request *req, bdaddr_t *bdaddr,
cp.bdaddr_type);
hci_req_add(req, HCI_OP_LE_DEL_FROM_WHITE_LIST, sizeof(cp), &cp);
- if (use_ll_privacy(req->hdev)) {
+ if (use_ll_privacy(req->hdev) &&
+ hci_dev_test_flag(req->hdev, HCI_ENABLE_LL_PRIVACY)) {
struct smp_irk *irk;
irk = hci_find_irk_by_addr(req->hdev, bdaddr, bdaddr_type);
@@ -748,7 +750,8 @@ static int add_to_white_list(struct hci_request *req,
cp.bdaddr_type);
hci_req_add(req, HCI_OP_LE_ADD_TO_WHITE_LIST, sizeof(cp), &cp);
- if (use_ll_privacy(hdev)) {
+ if (use_ll_privacy(hdev) &&
+ hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) {
struct smp_irk *irk;
irk = hci_find_irk_by_addr(hdev, ¶ms->addr,
@@ -869,7 +872,8 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval,
return;
}
- if (use_ll_privacy(hdev) && addr_resolv) {
+ if (use_ll_privacy(hdev) && addr_resolv &&
+ hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) {
u8 enable = 0x01;
hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable);
}
@@ -2226,7 +2230,8 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy,
/* If Controller supports LL Privacy use own address type is
* 0x03
*/
- if (use_ll_privacy(hdev))
+ if (use_ll_privacy(hdev) &&
+ hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY))
*own_addr_type = ADDR_LE_DEV_RANDOM_RESOLVED;
else
*own_addr_type = ADDR_LE_DEV_RANDOM;
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 65d93a38e5b3..c1106d97e3a9 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -5652,7 +5652,8 @@ static int set_privacy(struct sock *sk, struct hci_dev *hdev, void *cp_data,
return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_PRIVACY,
MGMT_STATUS_NOT_SUPPORTED);
- if (cp->privacy != 0x00 && cp->privacy != 0x01 && cp->privacy != 0x02)
+ if (cp->privacy != 0x00 && cp->privacy != 0x01 && cp->privacy != 0x02
+ && cp->privacy != 0x03)
return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_PRIVACY,
MGMT_STATUS_INVALID_PARAMS);
@@ -5674,6 +5675,8 @@ static int set_privacy(struct sock *sk, struct hci_dev *hdev, void *cp_data,
hci_adv_instances_set_rpa_expired(hdev, true);
if (cp->privacy == 0x02)
hci_dev_set_flag(hdev, HCI_LIMITED_PRIVACY);
+ else if (cp->privacy == 0x03)
+ hci_dev_set_flag(hdev, HCI_ENABLE_LL_PRIVACY);
else
hci_dev_clear_flag(hdev, HCI_LIMITED_PRIVACY);
} else {
@@ -5682,6 +5685,7 @@ static int set_privacy(struct sock *sk, struct hci_dev *hdev, void *cp_data,
hci_dev_clear_flag(hdev, HCI_RPA_EXPIRED);
hci_adv_instances_set_rpa_expired(hdev, false);
hci_dev_clear_flag(hdev, HCI_LIMITED_PRIVACY);
+ hci_dev_clear_flag(hdev, HCI_ENABLE_LL_PRIVACY);
}
err = send_settings_rsp(sk, MGMT_OP_SET_PRIVACY, hdev);
--
2.17.1
next prev parent reply other threads:[~2020-07-01 10:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-01 10:04 [PATCH v3 0/8] LL Privacy support Sathish Narasimman
2020-07-01 10:04 ` [PATCH v3 1/8] Bluetooth: Translate additional address type correctly Sathish Narasimman
2020-07-01 10:04 ` [PATCH v2 2/8] Bluetooth: Configure controller address resolution if available Sathish Narasimman
2020-07-01 10:04 ` [PATCH v3 3/8] Bluetooth: Update resolving list when updating whitelist Sathish Narasimman
2020-07-01 10:04 ` [PATCH v3 4/8] Bluetooth: Translate additional address type during le_conn Sathish Narasimman
2020-07-01 10:04 ` [PATCH v3 5/8] Bluetooth: Let controller creates RPA during le create conn Sathish Narasimman
2020-07-01 10:04 ` [PATCH v3 6/8] Bluetooth: Enable/Disable address resolution " Sathish Narasimman
2020-07-01 10:04 ` [PATCH v3 7/8] Bluetooth: Enable RPA Timeout Sathish Narasimman
2020-07-01 10:04 ` Sathish Narasimman [this message]
2020-07-02 13:21 ` [PATCH v3 8/8] Bluetooth: Add support to enable LL PRIVACY using set_privacy Marcel Holtmann
2020-07-13 6:20 ` Sathish Narasimman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200701100432.28038-9-sathish.narasimman@intel.com \
--to=nsathish41@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=sathish.narasimman@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).