Skip to content

Commit 1c22d3c

Browse files
Vudentzholtmann
authored andcommitted
Bluetooth: RFCOMM: Use MTU auto tune logic
This reuse the L2CAP MTU auto logic to select the MTU used for RFCOMM channels, this should increase the maximum from 1013 to 1021 when 3-DH5 is supported. Since it does not set an L2CAP MTU we no longer need a debugfs so that is removed. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent a2a8b0b commit 1c22d3c

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

‎include/net/bluetooth/rfcomm.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#define RFCOMM_DEFAULT_MTU 127
3535
#define RFCOMM_DEFAULT_CREDITS 7
3636

37-
#define RFCOMM_MAX_L2CAP_MTU 1013
3837
#define RFCOMM_MAX_CREDITS 40
3938

4039
#define RFCOMM_SKB_HEAD_RESERVE 8

‎net/bluetooth/rfcomm/core.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
static bool disable_cfc;
4141
static bool l2cap_ertm;
4242
static int channel_mtu = -1;
43-
static unsigned int l2cap_mtu = RFCOMM_MAX_L2CAP_MTU;
4443

4544
static struct task_struct *rfcomm_thread;
4645

@@ -749,7 +748,8 @@ static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src,
749748
/* Set L2CAP options */
750749
sk = sock->sk;
751750
lock_sock(sk);
752-
l2cap_pi(sk)->chan->imtu = l2cap_mtu;
751+
/* Set MTU to 0 so L2CAP can auto select the MTU */
752+
l2cap_pi(sk)->chan->imtu = 0;
753753
l2cap_pi(sk)->chan->sec_level = sec_level;
754754
if (l2cap_ertm)
755755
l2cap_pi(sk)->chan->mode = L2CAP_MODE_ERTM;
@@ -2036,7 +2036,8 @@ static int rfcomm_add_listener(bdaddr_t *ba)
20362036
/* Set L2CAP options */
20372037
sk = sock->sk;
20382038
lock_sock(sk);
2039-
l2cap_pi(sk)->chan->imtu = l2cap_mtu;
2039+
/* Set MTU to 0 so L2CAP can auto select the MTU */
2040+
l2cap_pi(sk)->chan->imtu = 0;
20402041
release_sock(sk);
20412042

20422043
/* Start listening on the socket */
@@ -2234,9 +2235,6 @@ MODULE_PARM_DESC(disable_cfc, "Disable credit based flow control");
22342235
module_param(channel_mtu, int, 0644);
22352236
MODULE_PARM_DESC(channel_mtu, "Default MTU for the RFCOMM channel");
22362237

2237-
module_param(l2cap_mtu, uint, 0644);
2238-
MODULE_PARM_DESC(l2cap_mtu, "Default MTU for the L2CAP connection");
2239-
22402238
module_param(l2cap_ertm, bool, 0644);
22412239
MODULE_PARM_DESC(l2cap_ertm, "Use L2CAP ERTM mode for connection");
22422240

0 commit comments

Comments
 (0)