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: Cherry-pick various important fixes #2014

Closed
wants to merge 12 commits into from

Conversation

rugeGerritsen
Copy link
Contributor

Found by looking examining what I could find here: https://rugegerritsen.github.io/fork_sync_status/

Without these fixes buffer leaks can occur.

pdgendt and others added 12 commits September 9, 2024 16:09
Some public API functions do not modify the net_buf instances and can
declare these arguments as const.

Signed-off-by: Pieter De Gendt <[email protected]>
(cherry picked from commit 0e9a6ee)
…ogic

Don't push the TS flag on `buf` itself.

This messes up the MTU calculations: a packet that would exactly fit the
MTU and has a timestamp would be unnecessarily fragmented.

The MTU check is done on `buf` as a whole. At the point where the
fragmentation length is decided, `buf` includes one extra byte to pass the
TS bit around. That byte shouldn't count towards the MTU.

Instead, infer the presence of the timestamp by inspecting the amount of
headroom that the buffer has. This works because we always reserve
enough memory to push the timestamp, but not always push a timestamp on
the buffer. #tightlycoupled

This method is slightly uglier IMO, but eases MTU confusion and doesn't
rely on user_data.

Signed-off-by: Jonathan Rico <[email protected]>
(cherry picked from commit 58ec516)
Set sec_adv_max_skip

Signed-off-by: Troels Nilsson <[email protected]>
(cherry picked from commit e816a13)
…an param failure

Fix scan_update() implementation for missing flags clear
that prevented starting scanning after previous attempt to
start failed due to parameters being rejected by the
Controller.

Example, attempting to start coded PHY scanning with a
Controller implementation that does not support it can fail,
but attempting again without coded PHY scanning should
succeed.

Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
(cherry picked from commit 2eafc82)
This is a bug-fix:

When upper layers want to send something, they add a `conn` object to a
list. They do so by adding a node on `struct conn` rather than the object
itself.

We forgot to increase the reference count of the connection object when
doing so. This means that there can be a scenario where the conn object is
destroyed and re-used while still being on the TX list/queue.

This is bad for obvious reasons.

This patch fixes that by:
- increasing the refcount when putting on the TX list
- decreasing the refcount *only* when popping off the TX list
- passing a new reference from `get_conn_ready` into `bt_conn_tx_processor`

Signed-off-by: Jonathan Rico <[email protected]>
(cherry picked from commit 85c57c2)
- De-duplicate code
- Add `LOG_WRN` on unsubscribe error

Fixes #74720
Fixes #74721

Signed-off-by: Jonathan Rico <[email protected]>
(cherry picked from commit a7c5fb7)
It was not being set, and thus if the user_data contained garbage from
before, then conn.c would attempt to call that garbage.

Static channels don't have this issue, as every "SDU" fits into one PDU.

Signed-off-by: Jonathan Rico <[email protected]>
Co-authored-by: Huajiang Zheng <[email protected]>
(cherry picked from commit 1c65103)
Refactor. The deferred work is rescheduled just after it's canceled.
This is hopefully equivalent to just the reschedule, so the cancel can
be removed.

Signed-off-by: Aleksander Wasaznik <[email protected]>
(cherry picked from commit e37140b)
This function call frees the buffer kept by the host for reassembling L2CAP
PDUs into.

Without this call, the current buffer will eventually be
leaked, leading to a non-functional host due to lack of RX buffers.

The effect is worse when host flow control is not enabled, as the RX
buffer pool is shared with events, which means communication with the
controller is essentially dead.

Signed-off-by: Jonathan Rico <[email protected]>
(cherry picked from commit 8a2fe27)
The `struct bt_l2cap_le_chan` and `struct bt_l2cap_br_chan` objects
should be memset before passing them to the stack.

This was not stated anywhere, but all the in-tree users are doing it, so
it must be API.

Signed-off-by: Jonathan Rico <[email protected]>
(cherry picked from commit e1ac386)
…mbers

We own those fields, so we should initialize them before use.

Signed-off-by: Jonathan Rico <[email protected]>
(cherry picked from commit 73572e4)
Trigger the TX processor on connection teardown.

When a disconnection happens before the controller has acknowledged some
ACL fragments the host has sent, we run `process_unack_tx()` to free
those unacknowledged buffers and their associated TX contexts.

The problem is that the TX processor still holds a reference to the conn
object. That reference is not released until the TX processor is
triggered again and figures out that the connection is invalid.

Signed-off-by: Jonathan Rico <[email protected]>
(cherry picked from commit 80a92f5)
@rugeGerritsen
Copy link
Contributor Author

Closing because upmerge is ongoing

@rugeGerritsen rugeGerritsen deleted the bt-cherry branch September 10, 2024 11:03
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.

7 participants