* [PATCH BlueZ v1 1/3] btdev: Add le_big on BT_HCI_CMD_LE_CREATE_BIG
@ 2025-07-24 20:24 Luiz Augusto von Dentz
2025-07-24 20:24 ` [PATCH BlueZ v1 2/3] btdev: Fix handling of BT_HCI_CMD_LE_TERM_BIG Luiz Augusto von Dentz
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2025-07-24 20:24 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When handling BT_HCI_CMD_LE_CREATE_BIG create a struct le_big to
represent it otherwise the likes of BT_HCI_CMD_LE_TERM_BIG will not be
able to detect a BIG was created.
---
emulator/btdev.c | 77 +++++++++++++++++++++++++++++++++++-------------
1 file changed, 57 insertions(+), 20 deletions(-)
diff --git a/emulator/btdev.c b/emulator/btdev.c
index cc844fc3a8ec..7293e2f2e5f1 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -6417,16 +6417,59 @@ static int cmd_reject_cis(struct btdev *dev, const void *data, uint8_t len)
static int cmd_create_big(struct btdev *dev, const void *data, uint8_t len)
{
- cmd_status(dev, BT_HCI_ERR_SUCCESS, BT_HCI_CMD_LE_CREATE_BIG);
+ const struct bt_hci_cmd_le_big_create_sync *cmd = data;
+ uint8_t status = BT_HCI_ERR_SUCCESS;
+
+ /* If the Advertising_Handle does not identify a periodic advertising
+ * train,, the Controller shall return the error code Unknown
+ * Advertising Identifier (0x42).
+ */
+ if (!dev->le_pa_enable) {
+ status = BT_HCI_ERR_UNKNOWN_ADVERTISING_ID;
+ goto done;
+ }
+
+ /* If the Host sends this command with a BIG_Handle that is already
+ * allocated, the Controller shall return the error code Command
+ * Disallowed (0x0C).
+ */
+ if (queue_find(dev->le_big, match_big_handle,
+ UINT_TO_PTR(cmd->handle))) {
+ status = BT_HCI_ERR_COMMAND_DISALLOWED;
+ goto done;
+ }
+
+done:
+ cmd_status(dev, status, BT_HCI_CMD_LE_CREATE_BIG);
return 0;
}
+static struct le_big *le_big_new(struct btdev *btdev, uint8_t handle)
+{
+ struct le_big *big;
+
+ big = new0(struct le_big, 1);
+
+ big->dev = btdev;
+ big->handle = handle;
+ big->bis = queue_new();
+
+ /* Add to queue */
+ if (!queue_push_tail(btdev->le_big, big)) {
+ le_big_free(big);
+ return NULL;
+ }
+
+ return big;
+}
+
static int cmd_create_big_complete(struct btdev *dev, const void *data,
uint8_t len)
{
const struct bt_hci_cmd_le_create_big *cmd = data;
const struct bt_hci_bis *bis = &cmd->bis;
+ struct le_big *big;
int i;
struct bt_hci_evt_le_big_complete evt;
uint16_t *bis_handle;
@@ -6439,6 +6482,16 @@ static int cmd_create_big_complete(struct btdev *dev, const void *data,
if (!pdu)
return -ENOMEM;
+ /* If the Controller cannot create all BISes of the BIG or if Num_BIS
+ * exceeds the maximum value supported by the Controller, then it shall
+ * return the error code Rejected due to Limited Resources (0x0D).
+ */
+ big = le_big_new(dev, cmd->handle);
+ if (!big) {
+ evt.status = BT_HCI_ERR_MEM_CAPACITY_EXCEEDED;
+ goto done;
+ }
+
bis_handle = (uint16_t *)(pdu + sizeof(evt));
memset(&evt, 0, sizeof(evt));
@@ -6448,10 +6501,13 @@ static int cmd_create_big_complete(struct btdev *dev, const void *data,
conn = conn_add_bis(dev, ISO_HANDLE + i, bis);
if (!conn) {
+ queue_remove(dev->le_big, big);
+ le_big_free(big);
evt.status = BT_HCI_ERR_MEM_CAPACITY_EXCEEDED;
goto done;
}
+ queue_push_tail(big->bis, conn);
*bis_handle = cpu_to_le16(conn->handle);
bis_handle++;
}
@@ -6540,25 +6596,6 @@ done:
return 0;
}
-static struct le_big *le_big_new(struct btdev *btdev, uint8_t handle)
-{
- struct le_big *big;
-
- big = new0(struct le_big, 1);
-
- big->dev = btdev;
- big->handle = handle;
- big->bis = queue_new();
-
- /* Add to queue */
- if (!queue_push_tail(btdev->le_big, big)) {
- le_big_free(big);
- return NULL;
- }
-
- return big;
-}
-
static int cmd_big_create_sync_complete(struct btdev *dev, const void *data,
uint8_t len)
{
--
2.50.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH BlueZ v1 2/3] btdev: Fix handling of BT_HCI_CMD_LE_TERM_BIG
2025-07-24 20:24 [PATCH BlueZ v1 1/3] btdev: Add le_big on BT_HCI_CMD_LE_CREATE_BIG Luiz Augusto von Dentz
@ 2025-07-24 20:24 ` Luiz Augusto von Dentz
2025-07-24 20:24 ` [PATCH BlueZ v1 3/3] btio: Fix handling of getpeername Luiz Augusto von Dentz
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2025-07-24 20:24 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
BT_HCI_CMD_LE_TERM_BIG shall cleanup the BIS connections and if there
are remote connected then they shall be notified with
BT_HCI_EVT_LE_BIG_SYNC_LOST so they can proceed to cleanup as well.
---
emulator/btdev.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 66 insertions(+), 1 deletion(-)
diff --git a/emulator/btdev.c b/emulator/btdev.c
index 7293e2f2e5f1..3747eaaef842 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -6538,7 +6538,33 @@ static int cmd_create_big_test(struct btdev *dev, const void *data, uint8_t len)
static int cmd_term_big(struct btdev *dev, const void *data, uint8_t len)
{
- cmd_status(dev, BT_HCI_ERR_SUCCESS, BT_HCI_CMD_LE_TERM_BIG);
+ const struct bt_hci_cmd_le_term_big *cmd = data;
+ struct le_big *big;
+ uint8_t status = BT_HCI_ERR_SUCCESS;
+
+ /* Check that PA advertising is enabled othewise it is not possible to
+ * have a BIG.
+ */
+ if (!dev->le_pa_enable) {
+ status = BT_HCI_ERR_UNKNOWN_ADVERTISING_ID;
+ goto done;
+ }
+
+ /* If the BIG_Handle does not identify a BIG, the Controller shall
+ * return the error code Unknown Advertising Identifier (0x42).
+ */
+ big = queue_find(dev->le_big, match_big_handle,
+ UINT_TO_PTR(cmd->handle));
+ if (!big) {
+ status = BT_HCI_ERR_UNKNOWN_ADVERTISING_ID;
+ goto done;
+ }
+
+done:
+ cmd_status(dev, status, BT_HCI_CMD_LE_TERM_BIG);
+
+ if (status)
+ return -EALREADY;
return 0;
}
@@ -6548,6 +6574,9 @@ static int cmd_term_big_complete(struct btdev *dev, const void *data,
{
const struct bt_hci_cmd_le_term_big *cmd = data;
struct bt_hci_evt_le_big_terminate rsp;
+ struct le_big *big;
+ struct btdev_conn *conn;
+ struct btdev *remote = NULL;
memset(&rsp, 0, sizeof(rsp));
rsp.reason = cmd->reason;
@@ -6555,6 +6584,40 @@ static int cmd_term_big_complete(struct btdev *dev, const void *data,
le_meta_event(dev, BT_HCI_EVT_LE_BIG_TERMINATE, &rsp, sizeof(rsp));
+ big = queue_find(dev->le_big, match_big_handle,
+ UINT_TO_PTR(cmd->handle));
+
+ if (!big)
+ return 0;
+
+ /* Cleanup existing connections */
+ while ((conn = queue_pop_head(big->bis))) {
+ if (!conn->link) {
+ conn_remove(conn);
+ continue;
+ }
+
+ /* Send BIG Sync Lost event once per remote device */
+ if (conn->link->dev != remote) {
+ struct bt_hci_evt_le_big_sync_lost evt;
+
+ memset(&evt, 0, sizeof(evt));
+ evt.big_handle = cmd->handle;
+ evt.reason = cmd->reason;
+
+ remote = conn->link->dev;
+ le_meta_event(remote, BT_HCI_EVT_LE_BIG_SYNC_LOST,
+ &evt, sizeof(evt));
+ }
+
+ /* Unlink conn from remote BIS */
+ conn_unlink(conn, conn->link);
+ conn_remove(conn);
+ }
+
+ queue_remove(dev->le_big, big);
+ le_big_free(big);
+
return 0;
}
@@ -7587,6 +7650,8 @@ static const struct btdev_cmd *run_cmd(struct btdev *btdev,
case -ENOENT:
status = BT_HCI_ERR_UNKNOWN_CONN_ID;
break;
+ case -EALREADY:
+ return NULL;
default:
status = BT_HCI_ERR_UNSPECIFIED_ERROR;
break;
--
2.50.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH BlueZ v1 3/3] btio: Fix handling of getpeername
2025-07-24 20:24 [PATCH BlueZ v1 1/3] btdev: Add le_big on BT_HCI_CMD_LE_CREATE_BIG Luiz Augusto von Dentz
2025-07-24 20:24 ` [PATCH BlueZ v1 2/3] btdev: Fix handling of BT_HCI_CMD_LE_TERM_BIG Luiz Augusto von Dentz
@ 2025-07-24 20:24 ` Luiz Augusto von Dentz
2025-07-24 21:53 ` [BlueZ,v1,1/3] btdev: Add le_big on BT_HCI_CMD_LE_CREATE_BIG bluez.test.bot
2025-07-25 13:40 ` [PATCH BlueZ v1 1/3] " patchwork-bot+bluetooth
3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2025-07-24 20:24 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
getpeername can either return an error set in the errno or the
returned size can be invalid but in that case errno is not set so
printing it would generate bogus message.
---
btio/btio.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/btio/btio.c b/btio/btio.c
index 30804cab96af..43275cb86e89 100644
--- a/btio/btio.c
+++ b/btio/btio.c
@@ -1665,12 +1665,16 @@ static bool get_bc_sid(int sock, uint8_t *sid, GError **err)
olen = sizeof(addr);
memset(&addr, 0, olen);
- if (getpeername(sock, (void *)&addr, &olen) < 0 ||
- olen != sizeof(addr)) {
+ if (getpeername(sock, (void *)&addr, &olen) < 0) {
ERROR_FAILED(err, "getpeername", errno);
return false;
}
+ if (olen != sizeof(addr)) {
+ ERROR_FAILED(err, "getpeername: size mismatch", EINVAL);
+ return false;
+ }
+
*sid = addr.iso.iso_bc->bc_sid;
return true;
--
2.50.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* RE: [BlueZ,v1,1/3] btdev: Add le_big on BT_HCI_CMD_LE_CREATE_BIG
2025-07-24 20:24 [PATCH BlueZ v1 1/3] btdev: Add le_big on BT_HCI_CMD_LE_CREATE_BIG Luiz Augusto von Dentz
2025-07-24 20:24 ` [PATCH BlueZ v1 2/3] btdev: Fix handling of BT_HCI_CMD_LE_TERM_BIG Luiz Augusto von Dentz
2025-07-24 20:24 ` [PATCH BlueZ v1 3/3] btio: Fix handling of getpeername Luiz Augusto von Dentz
@ 2025-07-24 21:53 ` bluez.test.bot
2025-07-25 13:40 ` [PATCH BlueZ v1 1/3] " patchwork-bot+bluetooth
3 siblings, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2025-07-24 21:53 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz
[-- Attachment #1: Type: text/plain, Size: 1491 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=985699
---Test result---
Test Summary:
CheckPatch PENDING 0.31 seconds
GitLint PENDING 0.27 seconds
BuildEll PASS 19.93 seconds
BluezMake PASS 2510.46 seconds
MakeCheck PASS 20.00 seconds
MakeDistcheck PASS 185.67 seconds
CheckValgrind PASS 239.22 seconds
CheckSmatch WARNING 307.46 seconds
bluezmakeextell PASS 128.05 seconds
IncrementalBuild PENDING 0.32 seconds
ScanBuild PASS 910.12 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
emulator/btdev.c:456:29: warning: Variable length array is used.emulator/btdev.c:456:29: warning: Variable length array is used.
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH BlueZ v1 1/3] btdev: Add le_big on BT_HCI_CMD_LE_CREATE_BIG
2025-07-24 20:24 [PATCH BlueZ v1 1/3] btdev: Add le_big on BT_HCI_CMD_LE_CREATE_BIG Luiz Augusto von Dentz
` (2 preceding siblings ...)
2025-07-24 21:53 ` [BlueZ,v1,1/3] btdev: Add le_big on BT_HCI_CMD_LE_CREATE_BIG bluez.test.bot
@ 2025-07-25 13:40 ` patchwork-bot+bluetooth
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+bluetooth @ 2025-07-25 13:40 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
Hello:
This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Thu, 24 Jul 2025 16:24:22 -0400 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> When handling BT_HCI_CMD_LE_CREATE_BIG create a struct le_big to
> represent it otherwise the likes of BT_HCI_CMD_LE_TERM_BIG will not be
> able to detect a BIG was created.
> ---
> emulator/btdev.c | 77 +++++++++++++++++++++++++++++++++++-------------
> 1 file changed, 57 insertions(+), 20 deletions(-)
Here is the summary with links:
- [BlueZ,v1,1/3] btdev: Add le_big on BT_HCI_CMD_LE_CREATE_BIG
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=6939c4706c90
- [BlueZ,v1,2/3] btdev: Fix handling of BT_HCI_CMD_LE_TERM_BIG
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=d427a2a5f197
- [BlueZ,v1,3/3] btio: Fix handling of getpeername
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=00ffc553a194
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-07-25 13:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-24 20:24 [PATCH BlueZ v1 1/3] btdev: Add le_big on BT_HCI_CMD_LE_CREATE_BIG Luiz Augusto von Dentz
2025-07-24 20:24 ` [PATCH BlueZ v1 2/3] btdev: Fix handling of BT_HCI_CMD_LE_TERM_BIG Luiz Augusto von Dentz
2025-07-24 20:24 ` [PATCH BlueZ v1 3/3] btio: Fix handling of getpeername Luiz Augusto von Dentz
2025-07-24 21:53 ` [BlueZ,v1,1/3] btdev: Add le_big on BT_HCI_CMD_LE_CREATE_BIG bluez.test.bot
2025-07-25 13:40 ` [PATCH BlueZ v1 1/3] " patchwork-bot+bluetooth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox