From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ] adapter: Fix toggling of experimental features
Date: Thu, 24 Jun 2021 15:08:44 -0700 [thread overview]
Message-ID: <20210624220844.3920039-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When toggling experimental features it may cause the old value to still
be in effect since it was read after read info which upon completion
would attempt to call adapter_register without first updating the
experimental features which could affect the likes of advertising
instances when LL Privacy is enabled.
---
src/adapter.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 2175120f4..84bc5a1b0 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -9253,14 +9253,15 @@ static void set_exp_debug_complete(uint8_t status, uint16_t len,
static void exp_debug_func(struct btd_adapter *adapter, uint32_t flags)
{
struct mgmt_cp_set_exp_feature cp;
+ uint8_t action = btd_opts.experimental ? 0x01 : 0x00;
- /* If already enabled don't attempt to set it again */
- if (flags & BIT(0))
+ /* If already set don't attempt to set it again */
+ if (action == (flags & BIT(0)))
return;
memset(&cp, 0, sizeof(cp));
memcpy(cp.uuid, debug_uuid, 16);
- cp.action = 0x01;
+ cp.action = btd_opts.experimental ? 0x01 : 0x00;
if (mgmt_send(adapter->mgmt, MGMT_OP_SET_EXP_FEATURE,
adapter->dev_id, sizeof(cp), &cp,
@@ -9289,14 +9290,15 @@ static void set_rpa_resolution_complete(uint8_t status, uint16_t len,
static void rpa_resolution_func(struct btd_adapter *adapter, uint32_t flags)
{
struct mgmt_cp_set_exp_feature cp;
+ uint8_t action = btd_opts.experimental ? 0x01 : 0x00;
- /* If already enabled don't attempt to set it again */
- if (flags & BIT(0))
+ /* If already set don't attempt to set it again */
+ if (action == (flags & BIT(0)))
return;
memset(&cp, 0, sizeof(cp));
memcpy(cp.uuid, rpa_resolution_uuid, 16);
- cp.action = 0x01;
+ cp.action = action;
if (mgmt_send(adapter->mgmt, MGMT_OP_SET_EXP_FEATURE,
adapter->dev_id, sizeof(cp), &cp,
@@ -9480,10 +9482,6 @@ static void read_info_complete(uint8_t status, uint16_t length,
(missing_settings & MGMT_SETTING_FAST_CONNECTABLE))
set_mode(adapter, MGMT_OP_SET_FAST_CONNECTABLE, 0x01);
- if (btd_opts.experimental &&
- btd_has_kernel_features(KERNEL_EXP_FEATURES))
- read_exp_features(adapter);
-
err = adapter_register(adapter);
if (err < 0) {
btd_error(adapter->dev_id, "Unable to register new adapter");
@@ -9707,6 +9705,9 @@ static void index_added(uint16_t index, uint16_t length, const void *param,
return;
}
+ if (btd_has_kernel_features(KERNEL_EXP_FEATURES))
+ read_exp_features(adapter);
+
/*
* Protect against potential two executions of read controller info.
*
--
2.31.1
next reply other threads:[~2021-06-24 22:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-24 22:08 Luiz Augusto von Dentz [this message]
2021-06-24 22:36 ` [BlueZ] adapter: Fix toggling of experimental features bluez.test.bot
2021-06-28 17:35 ` Luiz Augusto von Dentz
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=20210624220844.3920039-1-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/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).