From: Nicolas Thibert <nithibert@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Subject: [PATCH BlueZ v3 2/2] advertising: Fix duration and interval endianness
Date: Wed, 2 Dec 2026 16:17:38 +0100 [thread overview]
Message-ID: <20261202151738.1146722-3-nithibert@gmail.com> (raw)
In-Reply-To: <20261202151738.1146722-1-nithibert@gmail.com>
refresh_legacy_adv() and refresh_extended_adv() write the native-endian
duration and min/max intervals directly into the __le16/__le32 fields
of the MGMT_OP_ADD_ADVERTISING and MGMT_OP_ADD_EXT_ADV_PARAMS
commands, without cpu_to_le16()/cpu_to_le32(). This is a no-op on
little-endian hosts, but corrupts the values on big-endian hosts.
It is inert with the default values (0 stays 0), but A/B tested live on
MIPS big-endian (OpenWrt/ath79) with bluetoothctl's advertise submenu
and an explicit "interval 100 100": without the fix, the device stops
being discoverable by a BLE scanner as soon as a non-default interval
is requested; with the fix, it is discoverable again.
---
src/advertising.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/advertising.c b/src/advertising.c
index d07068c..ecb730c 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -1060,7 +1060,7 @@ static int refresh_legacy_adv(struct btd_adv_client *client,
cp->flags = htobl(flags);
cp->instance = client->instance;
- cp->duration = client->duration;
+ cp->duration = cpu_to_le16(client->duration);
cp->adv_data_len = adv_data_len;
cp->scan_rsp_len = scan_rsp_len;
memcpy(cp->data, adv_data, adv_data_len);
@@ -1111,13 +1111,13 @@ static int refresh_extended_adv(struct btd_adv_client *client,
*/
if (client->duration) {
- cp.duration = client->duration;
+ cp.duration = cpu_to_le16(client->duration);
flags |= MGMT_ADV_PARAM_DURATION;
}
if (client->min_interval && client->max_interval) {
- cp.min_interval = client->min_interval;
- cp.max_interval = client->max_interval;
+ cp.min_interval = cpu_to_le32(client->min_interval);
+ cp.max_interval = cpu_to_le32(client->max_interval);
flags |= MGMT_ADV_PARAM_INTERVALS;
}
--
2.34.1
prev parent reply other threads:[~2026-12-02 15:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 15:17 [PATCH BlueZ v3 0/2] Fix mgmt endianness on big-endian hosts Nicolas Thibert
2026-12-02 15:17 ` [PATCH BlueZ v3 1/2] adapter: Fix key_count endianness in MGMT_OP_SET_BLOCKED_KEYS Nicolas Thibert
2026-12-02 15:17 ` Nicolas Thibert [this message]
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=20261202151738.1146722-3-nithibert@gmail.com \
--to=nithibert@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.