Skip to content

Commit 5db93cb

Browse files
Vudentzgregkh
authored andcommitted
Bluetooth: L2CAP: Fix attempting to adjust outgoing MTU
[ Upstream commit d24e4a7 ] 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 <luiz.von.dentz@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 1259b78 commit 5db93cb

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
@@ -3485,12 +3485,28 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data, size_t data
34853485
/* Configure output options and let the other side know
34863486
* which ones we don't like. */
34873487

3488-
/* If MTU is not provided in configure request, use the most recently
3489-
* explicitly or implicitly accepted value for the other direction,
3490-
* or the default value.
3488+
/* If MTU is not provided in configure request, try adjusting it
3489+
* to the current output MTU if it has been set
3490+
*
3491+
* Bluetooth Core 6.1, Vol 3, Part A, Section 4.5
3492+
*
3493+
* Each configuration parameter value (if any is present) in an
3494+
* L2CAP_CONFIGURATION_RSP packet reflects an ‘adjustment’ to a
3495+
* configuration parameter value that has been sent (or, in case
3496+
* of default values, implied) in the corresponding
3497+
* L2CAP_CONFIGURATION_REQ packet.
34913498
*/
3492-
if (mtu == 0)
3493-
mtu = chan->imtu ? chan->imtu : L2CAP_DEFAULT_MTU;
3499+
if (!mtu) {
3500+
/* Only adjust for ERTM channels as for older modes the
3501+
* remote stack may not be able to detect that the
3502+
* adjustment causing it to silently drop packets.
3503+
*/
3504+
if (chan->mode == L2CAP_MODE_ERTM &&
3505+
chan->omtu && chan->omtu != L2CAP_DEFAULT_MTU)
3506+
mtu = chan->omtu;
3507+
else
3508+
mtu = L2CAP_DEFAULT_MTU;
3509+
}
34943510

34953511
if (mtu < L2CAP_DEFAULT_MIN_MTU)
34963512
result = L2CAP_CONF_UNACCEPT;

0 commit comments

Comments
 (0)