btdev: Add le_big on BT_HCI_CMD_LE_CREATE_BIG
Luiz Augusto von Dentz
maintainerPATCH 1/3 btdev: Add le_big on BT_HCI_CMD_LE_CREATE_BIG
From: Luiz Augusto von Dentz <[email protected]>
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(-)
emulator/btdev.c +57 -20
@@ -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) {
Signature · 1 line
2.50.1
Luiz Augusto von Dentz
maintainerPATCH 2/3 btdev: Fix handling of BT_HCI_CMD_LE_TERM_BIG
From: Luiz Augusto von Dentz <[email protected]>
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(-)
emulator/btdev.c +66 -1
@@ -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 ;
Signature · 1 line
2.50.1
Luiz Augusto von Dentz
maintainerPATCH 3/3 btio: Fix handling of getpeername
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
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(-)
btio/btio.c +6 -2
@@ -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;
Signature · 1 line
2.50.1
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
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 8 lines · On Thu, 24 Jul 2025 16:24:22 -0400 you wrote:
From: Luiz Augusto von Dentz <[email protected]>
When handling
BT_HCI_CMD_LE_CREATE_BIGcreate a structle_bigto represent it otherwise the likes ofBT_HCI_CMD_LE_TERM_BIGwill 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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html