Description
Describe the bug
When reconnecting, previous l2cap TX fragmentation state is kept, resulting in that we may send l2cap fragments to the controller without an l2cap header.
To Reproduce
- Run a connection with a long connection interval.
- Set max data length to 27 bytes.
- Send long ATT/L2CAP packets
- Disconnect one of the device
- Reconnect. Observe that the next L2CAP fragment will be sent without header
Setting le_chan._pdu_remaining = 0
in bt_l2cap_chan_del()
resolves this issue.
Expected behavior
Upon disconnection all previous state shall be cleared.
Impact
Showstopper
Logs and console output
Logs extracted from a custom test
bt_l2cap: L2CAP: push: pdu 0x819ddc8 len 200 cb 0x8055130 userdata (nil)
bt_l2cap: l2cap_pull: Adding L2CAP PDU header: buf 0x819ddf0 chan 0x8186280 len 200 / 200
app: disconnected: err 13 addr DC:52:5F:AA:9A:74 (random)
app: connected: err 0 addr DC:52:5F:AA:9A:74 (random)
bt_l2cap: L2CAP: push: pdu 0x819ddf0 len 200 cb 0x8055130 userdata (nil)
bt_l2cap: l2cap_pull: Not adding L2CAP header, handling remaining 123
Environment (please complete the following information):
Zephyr 3.7.0
Additional context
The bug was introduced in #72090