Skip to content

Commit d24e4a7

Browse files
committed
Bluetooth: L2CAP: Fix attempting to adjust outgoing MTU
Configuration request only configure the incoming direction of the peer initiating the request, so using the MTU is the other direction shall not be used, that said the spec allows the peer responding to adjust: Bluetooth Core 6.1, Vol 3, Part A, Section 4.5 'Each configuration parameter value (if any is present) in an L2CAP_CONFIGURATION_RSP packet reflects an ‘adjustment’ to a configuration parameter value that has been sent (or, in case of default values, implied) in the corresponding L2CAP_CONFIGURATION_REQ packet.' That said adjusting the MTU in the response shall be limited to ERTM channels only as for older modes the remote stack may not be able to detect the adjustment causing it to silently drop packets. Link: bluez/bluez#1422 Link: https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/issues/149 Link: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/4793 Fixes: 042bb96 ("Bluetooth: L2CAP: Fix L2CAP MTU negotiation") Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 4301595 commit d24e4a7

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

net/bluetooth/l2cap_core.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3520,12 +3520,28 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data, size_t data
35203520
/* Configure output options and let the other side know
35213521
* which ones we don't like. */
35223522

3523-
/* If MTU is not provided in configure request, use the most recently
3524-
* explicitly or implicitly accepted value for the other direction,
3525-
* or the default value.
3523+
/* If MTU is not provided in configure request, try adjusting it
3524+
* to the current output MTU if it has been set
3525+
*
3526+
* Bluetooth Core 6.1, Vol 3, Part A, Section 4.5
3527+
*
3528+
* Each configuration parameter value (if any is present) in an
3529+
* L2CAP_CONFIGURATION_RSP packet reflects an ‘adjustment’ to a
3530+
* configuration parameter value that has been sent (or, in case
3531+
* of default values, implied) in the corresponding
3532+
* L2CAP_CONFIGURATION_REQ packet.
35263533
*/
3527-
if (mtu == 0)
3528-
mtu = chan->imtu ? chan->imtu : L2CAP_DEFAULT_MTU;
3534+
if (!mtu) {
3535+
/* Only adjust for ERTM channels as for older modes the
3536+
* remote stack may not be able to detect that the
3537+
* adjustment causing it to silently drop packets.
3538+
*/
3539+
if (chan->mode == L2CAP_MODE_ERTM &&
3540+
chan->omtu && chan->omtu != L2CAP_DEFAULT_MTU)
3541+
mtu = chan->omtu;
3542+
else
3543+
mtu = L2CAP_DEFAULT_MTU;
3544+
}
35293545

35303546
if (mtu < L2CAP_DEFAULT_MIN_MTU)
35313547
result = L2CAP_CONF_UNACCEPT;

0 commit comments

Comments
 (0)