Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth: Host: Downstream 21.10.2024 #2139

Merged
merged 19 commits into from
Oct 31, 2024

Conversation

PavelVPV
Copy link
Contributor

@PavelVPV PavelVPV commented Oct 21, 2024

This PR downstreams Bluetooth host changes as of 21.10.2024.

@PavelVPV
Copy link
Contributor Author

FYI: had to revert and re-revert b0ce7fe and 687cefa to bypass Commit tags job for this commit:
9d12650

@Thalley Thalley removed their request for review October 21, 2024 11:25
@PavelVPV
Copy link
Contributor Author

@carlescufi , can we skip the compliance check failure since it is probably because the upstream was not checking formatting when the failing commits were merged?

@PavelVPV PavelVPV removed this from the ncs-2.8.0 milestone Oct 22, 2024
@PavelVPV PavelVPV force-pushed the bt_host_downstream_21_10_2024 branch from 3acee83 to c89aecb Compare October 24, 2024 08:55
aescolar and others added 19 commits October 31, 2024 09:36
Let's run tests with security/privacy with the HW models acutually
running the encryptions, so in case of missaligned keys
tests fail.

Signed-off-by: Alberto Escolar Piedras <[email protected]>
(cherry picked from commit 53adf2c)
Let's run tests with security/privacy with the HW models acutually
running the encryption, so in case of missaligned keys
tests fail.

Signed-off-by: Alberto Escolar Piedras <[email protected]>
(cherry picked from commit 342e298)
Let's run tests with security/privacy with the HW models acutually
running the encryptions, so in case of missaligned keys
tests fail.

Signed-off-by: Alberto Escolar Piedras <[email protected]>
(cherry picked from commit 9182a7e)
…cryption

Let's run tests with security/privacy with the HW models acutually
running the encryptions, so in case of missaligned keys
tests fail.

Signed-off-by: Alberto Escolar Piedras <[email protected]>
(cherry picked from commit 3726cf3)
Changed the scan option type from uint32_t to
uint8_t.

There are 2 reasons for this:
1) This reduces the size of the struct bt_le_scan_param.
   Since we are now storing two copies of scan parameters
   statically in the host, this is not insignficant.
2) This fixes a "hole" in the struct. There are no longer
   3 empty octets between the `type` and the `options`, which
   caused valgrind warnings when using `memcpy` and `memcmp`
   of the struct.

Currently we only need 8 bits for the options available.
If additional options are added later, the field need
to be increased. For the above reasons some additional
refactoring my be required to avoid significant size
increases and the valgrind issue.

Signed-off-by: Emil Gydesen <[email protected]>
(cherry picked from commit e1e4f2a)
Update the string formatter according to the type of the
variables that it is printing to eliminate compilation
warnings.

Signed-off-by: Yong Cong Sin <[email protected]>
Signed-off-by: Yong Cong Sin <[email protected]>
(cherry picked from commit d250664)
…me in shell

Added a timeout for active scans (instead of using the host's scan
timeout) in the shell by submitting a k_work that stops the scan
after a specified period.

Fixes #78659

Signed-off-by: Babak Arisian <[email protected]>
(cherry picked from commit d8c1d4d)
Currently, the bonding type of Authentication
_Requirements parameter is always `Dedicated
Bonding` if the device is pairing initiator.

But if the bonding is performed during
connection setup or channel establishment as
a precursor to accessing a service, the
bonding type should be `General bonding`.

Add a flag BT_CONN_BR_GENERAL_BONDING.
Set the flag if the bonding is performed in
the L2CAP_BR/RFCOMM channel establishment.

Set bonding type depends on the flag when
receiving IO cap request.

Signed-off-by: Lyle Zhu <[email protected]>
(cherry picked from commit 08ceb14)
Add a function bt_get_bondable to get the bonding setting.

Signed-off-by: Lyle Zhu <[email protected]>
(cherry picked from commit c0ce5b4)
Correct the `help` of the configuration `BT_BONDABLE`.

Signed-off-by: Lyle Zhu <[email protected]>
(cherry picked from commit 0ed8866)
The timeout state is local and can block new ATT operations, but does
not affect the remote side. Disconnecting the GATT connection upon ATT
timeout simplifies error handling for developers. This reduces rare
failure conditions to a common one, without needing special cases for
ATT timeouts.

Signed-off-by: Pavel Vasilyev <[email protected]>
(cherry picked from commit f712bde)
This commit tests that the host correctly disconnects from peer when ATT
timeout happens.

Signed-off-by: Pavel Vasilyev <[email protected]>
(cherry picked from commit f7e8a87)
…nd_buf"

This reverts commit 687cefa.

Signed-off-by: Pavel Vasilyev <[email protected]>
…p_send_pdu"

This reverts commit b0ce7fe.

Signed-off-by: Pavel Vasilyev <[email protected]>
…ng PDU

In case of UATT, if a connection was lost while user was holding a read
or write attribute callback, `bt_l2cap_send_pdu` (called from
`att.c::chan_send`) will anyway queue a PDU and trigger tx work. The PDU
won't be sent eventually, but neither will hold an error code, which
will allow it to bypass the error check in `att_on_sent_cb` and call
`att_sent` function.

For EATT `bt_l2cap_chan_send` is used which already handles this case
and the error code is passed to `att_on_sent_cb`.

This change adds connection state check to `bt_l2cap_send_pdu`
preventing from unnecessary code execution when connection does not
exist anymore.

Signed-off-by: Pavel Vasilyev <[email protected]>
(cherry picked from commit 74972e6)
Allow for an additional buffer reference if callback is provided. This
can be used to extend lifetime of the net buffer until the data
transmission is confirmed by ACK of the remote.

Signed-off-by: Marek Pieta <[email protected]>
If ATT sent callback is delayed until data transmission is done by BLE
controller, the transmitted buffer may have an additional reference. The
reference is used to extend lifetime of the net buffer until the data
transmission is confirmed by ACK of the remote.

send_buf function can be called multiple times, if buffer has to be
fragmented over HCI. In that case, the callback is provided as an
argument only for the last transmitted fragment. The `buf->ref == 1`
check is skipped because it's impossible to properly validate number of
references for the sent fragments if buffers may have the additional
reference.

Jira: NCSDK-28624

Signed-off-by: Marek Pieta <[email protected]>
This commit adds a warning and a Kconfig option to `bt_conn_le_create`
and `bt_conn_le_create_synced` functions which are meant to warn a user
of a potential leakage of an active connection object.

This change is implemented due to frequent incorrect use of the
connection pointer where a pointer to an existing connection object
is overwritten by `bt_conn_le_create` and `bt_conn_le_create_synced`
functions which in turns leads to sporadic critical bugs. See
zephyrproject-rtos/zephyr#78284 (comment)
for more details.

The Kconfig option is introduced instead of always returning the error
to not affect current implementations. However, it is recommended to
keep this option enabled to avoid potential bugs.

Signed-off-by: Pavel Vasilyev <[email protected]>
(cherry picked from commit 8acb1cc)
…it test

Add a test that checks behavior of
CONFIG_BT_CONN_CHECK_NULL_BEFORE_CREATE Kconfig option.

Signed-off-by: Pavel Vasilyev <[email protected]>
(cherry picked from commit 1fbcc0e)
@PavelVPV PavelVPV force-pushed the bt_host_downstream_21_10_2024 branch from 6adbf41 to 9b4e9bc Compare October 31, 2024 08:36
@rlubos rlubos merged commit 765c23d into nrfconnect:main Oct 31, 2024
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants