Skip to contentSkip to conversation

profile: Set L2CAP IMTU for external profile listeners

PATCH Superseded Wei Deng 4 participants 10 messages May 22 – Jun 4 Bluetooth drivers

lore
Share & tools
lore

Wei Deng

author
#0 lore raw

PATCH 1/1 profile: Set L2CAP IMTU for external profile listeners

bt_io_listen() in ext_start_servers() creates the L2CAP listening socket for external profiles without an explicit IMTU, causing the socket to default to the L2CAP minimum of 672 bytes. This is advertised to the peer in L2CAP_CONFIGURATION_RSP and limits PDU size, degrading Rx throughput.

The obexd client side (obexd/client/bluetooth.c) already sets IMTU to BT_RX_MTU (32767) when connecting. Mirror that on the server side by setting BT_IO_OPT_IMTU to 32767 in ext_start_servers().

---
 src/profile.c | 3 +++
 1 file changed, 3 insertions(+)
src/profile.c +3 -0
index dfc5f7161..297959f3c 100644
@@ -55,6 +55,8 @@
 #define MAS_DEFAULT_CHANNEL	16
 #define MNS_DEFAULT_CHANNEL	17
 
+#define BT_RX_MTU		32767
+
 #define BTD_PROFILE_PSM_AUTO	-1
 #define BTD_PROFILE_CHAN_AUTO	-1
 
@@ -1411,6 +1413,7 @@ static uint32_t ext_start_servers(struct ext_profile *ext,
 					BT_IO_OPT_MODE, ext->mode,
 					BT_IO_OPT_PSM, psm,
 					BT_IO_OPT_SEC_LEVEL, ext->sec_level,
+					BT_IO_OPT_IMTU, BT_RX_MTU,
 					BT_IO_OPT_INVALID);
 		if (err != NULL) {
 			error("L2CAP server failed for %s: %s",
Signature · 1 line
2.34.1
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1099144

---Test result---

Test Summary:

CheckPatch                    PASS      0.39 seconds
GitLint                       PASS      0.28 seconds
BuildEll                      PASS      15.97 seconds
BluezMake                     PASS      489.53 seconds
CheckSmatch                   PASS      252.95 seconds
bluezmakeextell               PASS      129.96 seconds
IncrementalBuild              PASS      493.87 seconds
ScanBuild                     PASS      719.71 seconds

https://github.com/bluez/bluez/pull/2144

---
Regards,
Linux Bluetooth

author
#2 lore raw

PATCH v2 1/1 profile: Set L2CAP IMTU for external profile listeners

In reply to Wei Deng

bt_io_listen() in ext_start_servers() creates the L2CAP listening socket for external profiles without an explicit IMTU. This causes the socket to use the L2CAP minimum of 672 bytes, which is advertised to the peer in L2CAP_CONFIGURATION_RSP.

As a result, when acting as a server (receiver), the peer limits its outgoing PDU size to our advertised 672 bytes. This leads to small OBEX body chunks (~669 bytes) and severely degraded Rx throughput, while Tx throughput is unaffected since the peer's IMTU is not constrained by our setting.

The obexd client side (obexd/client/bluetooth.c) already sets IMTU to BT_RX_MTU (32767) for outgoing connections. Mirror that on the server side by setting BT_IO_OPT_IMTU to BT_RX_MTU in ext_start_servers(), so incoming connections advertise the same maximum receive capability.

---
 src/profile.c | 3 +++
 1 file changed, 3 insertions(+)
src/profile.c +3 -0
index dfc5f7161..297959f3c 100644
@@ -55,6 +55,8 @@
 #define MAS_DEFAULT_CHANNEL	16
 #define MNS_DEFAULT_CHANNEL	17
 
+#define BT_RX_MTU		32767
+
 #define BTD_PROFILE_PSM_AUTO	-1
 #define BTD_PROFILE_CHAN_AUTO	-1
 
@@ -1411,6 +1413,7 @@ static uint32_t ext_start_servers(struct ext_profile *ext,
 					BT_IO_OPT_MODE, ext->mode,
 					BT_IO_OPT_PSM, psm,
 					BT_IO_OPT_SEC_LEVEL, ext->sec_level,
+					BT_IO_OPT_IMTU, BT_RX_MTU,
 					BT_IO_OPT_INVALID);
 		if (err != NULL) {
 			error("L2CAP server failed for %s: %s",
Signature · 1 line
2.34.1
#3 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1104327

---Test result---

Test Summary:

CheckPatch                    PASS      0.42 seconds
GitLint                       PASS      1.32 seconds
BuildEll                      PASS      20.60 seconds
BluezMake                     PASS      666.26 seconds
CheckSmatch                   PASS      365.80 seconds
bluezmakeextell               PASS      187.14 seconds
IncrementalBuild              PASS      659.47 seconds
ScanBuild                     PASS      1050.72 seconds

https://github.com/bluez/bluez/pull/2164

---
Regards,
Linux Bluetooth

#4 lore raw
In reply to Wei Deng

Hi,

Quoted 36 lines · Wei Deng

bt_io_listen() in ext_start_servers() creates the L2CAP listening socket for external profiles without an explicit IMTU. This causes the socket to use the L2CAP minimum of 672 bytes, which is advertised to the peer in L2CAP_CONFIGURATION_RSP.

As a result, when acting as a server (receiver), the peer limits its outgoing PDU size to our advertised 672 bytes. This leads to small OBEX body chunks (~669 bytes) and severely degraded Rx throughput, while Tx throughput is unaffected since the peer's IMTU is not constrained by our setting.

The obexd client side (obexd/client/bluetooth.c) already sets IMTU to BT_RX_MTU (32767) for outgoing connections. Mirror that on the server side by setting BT_IO_OPT_IMTU to BT_RX_MTU in ext_start_servers(), so incoming connections advertise the same maximum receive capability.

---
 src/profile.c | 3 +++
 1 file changed, 3 insertions(+)
src/profile.c +2 -0
index dfc5f7161..297959f3c 100644
@@ -55,6 +55,8 @@
 #define MAS_DEFAULT_CHANNEL    16
 #define MNS_DEFAULT_CHANNEL    17
 
+#define BT_RX_MTU              32767
+
 #define BTD_PROFILE_PSM_AUTO   -1
 #define BTD_PROFILE_CHAN_AUTO  -1
 

src/profile.c static uint32_t ext_start_servers(struct ext_profile *ext, · line 1416

Quoted 4 lines
src/profile.c +1 -0
@@ -1411,6 +1413,7 @@ static uint32_t ext_start_servers(struct ext_profile *ext,
                                        BT_IO_OPT_MODE, ext->mode,
                                        BT_IO_OPT_PSM, psm,
                                        BT_IO_OPT_SEC_LEVEL, ext->sec_level,
+                                       BT_IO_OPT_IMTU, BT_RX_MTU,

This is doing it for all service registered via ProfileManager which is not going to fly, instead we probably need to add a MTU option so the profile entity can pass it instead of getting the default.

Quoted 7 lines
src/profile.c +0 -1
                                        BT_IO_OPT_INVALID);
                if (err != NULL) {
                        error("L2CAP server failed for %s: %s",
--

2.34.1

Signature · 1 line
Luiz Augusto von Dentz
#5 lore raw

Hi,

Quoted 39 lines · Luiz Augusto von Dentz

Hi,

Quoted 35 lines · Wei Deng

bt_io_listen() in ext_start_servers() creates the L2CAP listening socket for external profiles without an explicit IMTU. This causes the socket to use the L2CAP minimum of 672 bytes, which is advertised to the peer in L2CAP_CONFIGURATION_RSP.

As a result, when acting as a server (receiver), the peer limits its outgoing PDU size to our advertised 672 bytes. This leads to small OBEX body chunks (~669 bytes) and severely degraded Rx throughput, while Tx throughput is unaffected since the peer's IMTU is not constrained by our setting.

The obexd client side (obexd/client/bluetooth.c) already sets IMTU to BT_RX_MTU (32767) for outgoing connections. Mirror that on the server side by setting BT_IO_OPT_IMTU to BT_RX_MTU in ext_start_servers(), so incoming connections advertise the same maximum receive capability.

---
 src/profile.c | 3 +++
 1 file changed, 3 insertions(+)
src/profile.c +2 -0
index dfc5f7161..297959f3c 100644
@@ -55,6 +55,8 @@
 #define MAS_DEFAULT_CHANNEL    16
 #define MNS_DEFAULT_CHANNEL    17
 
+#define BT_RX_MTU              32767
+
 #define BTD_PROFILE_PSM_AUTO   -1
 #define BTD_PROFILE_CHAN_AUTO  -1
 
Quoted 9 lines

src/profile.c static uint32_t ext_start_servers(struct ext_profile *ext, · line 1416

Quoted 5 lines
src/profile.c +1 -0
@@ -1411,6 +1413,7 @@ static uint32_t ext_start_servers(struct ext_profile *ext,
                                        BT_IO_OPT_MODE, ext->mode,
                                        BT_IO_OPT_PSM, psm,
                                        BT_IO_OPT_SEC_LEVEL, ext->sec_level,
+                                       BT_IO_OPT_IMTU, BT_RX_MTU,

This is doing it for all service registered via ProfileManager which is not going to fly, instead we probably need to add a MTU option so the profile entity can pass it instead of getting the default.

Actually there are no options, it's built from default_setting, which doesn't set any MTU for some reason. For the OBEX profiles it probably makes sense to add an MTU field so it gets properly set.

author
#6 lore raw

Hi Luiz,

Quoted 4 lines · Luiz Augusto von Dentz

Actually there are no options, it's built from default_setting, which doesn't set any MTU for some reason. For the OBEX profiles it probably makes sense to add an MTU field so it gets properly set.

Thanks for the clarification. Agreed -- I'll add an imtu field to default_settings and populate it only for the OBEX profiles (OPP, FTP, PSE, MAS, MNS), then have ext_start_servers() apply it via bt_io_set() only when the field is set, so non-OBEX listeners keep their current behavior.

I'll send V3 with that approach shortly.

Signature · 2 lines
Best Regards,
Wei Deng
author
#7 lore raw

PATCH v3 1/1 profile: Set L2CAP IMTU for OBEX profile listeners

In reply to Wei Deng

The default_settings entries for OBEX profiles (OPP, FTP, PBAP, MAS, MNS) have no imtu field, so ext_start_servers() creates the L2CAP listening socket without an explicit IMTU. This causes the socket to advertise the L2CAP minimum of 672 bytes in L2CAP_CONFIGURATION_RSP, limiting the peer's outgoing PDU size and degrading Rx throughput.

Add an imtu field to default_settings and set it to 32767 for all OBEX profiles that use L2CAP. Copy the value in ext_set_defaults() and apply it to the listening socket via bt_io_set() after bt_io_listen() succeeds.

---
 src/profile.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
src/profile.c +17 -2
index dfc5f7161..65df0f7a0 100644
@@ -55,6 +55,8 @@
 #define MAS_DEFAULT_CHANNEL	16
 #define MNS_DEFAULT_CHANNEL	17
 
+#define BT_RX_MTU		32767
+
 #define BTD_PROFILE_PSM_AUTO	-1
 #define BTD_PROFILE_CHAN_AUTO	-1
 
@@ -678,6 +680,7 @@ struct ext_profile {
 
 	uint16_t version;
 	uint16_t features;
+	uint16_t imtu;
 
 	GSList *records;
 	GSList *servers;
@@ -1423,6 +1426,9 @@ static uint32_t ext_start_servers(struct ext_profile *ext,
 			if (psm == 0)
 				bt_io_get(io, NULL, BT_IO_OPT_PSM, &psm,
 							BT_IO_OPT_INVALID);
+			if (ext->imtu)
+				bt_io_set(io, NULL, BT_IO_OPT_IMTU, ext->imtu,
+							BT_IO_OPT_INVALID);
 			l2cap->io = io;
 			l2cap->proto = BTPROTO_L2CAP;
 			l2cap->psm = psm;
@@ -2075,6 +2081,7 @@ static struct default_settings {
 					struct ext_io *rfcomm);
 	uint16_t	version;
 	uint16_t	features;
+	uint16_t	imtu;
 } defaults[] = {
 	{
 		.uuid		= SPP_UUID,
@@ -2142,6 +2149,7 @@ static struct default_settings {
 		.authorize	= false,
 		.get_record	= get_opp_record,
 		.version	= 0x0102,
+		.imtu		= BT_RX_MTU,
 	}, {
 		.uuid		= OBEX_FTP_UUID,
 		.name		= "File Transfer",
@@ -2151,6 +2159,7 @@ static struct default_settings {
 		.authorize	= true,
 		.get_record	= get_ftp_record,
 		.version	= 0x0103,
+		.imtu		= BT_RX_MTU,
 	}, {
 		.uuid		= OBEX_SYNC_UUID,
 		.name		= "Synchronization",
@@ -2167,6 +2176,7 @@ static struct default_settings {
 		.authorize	= true,
 		.get_record	= get_pse_record,
 		.version	= 0x0101,
+		.imtu		= BT_RX_MTU,
 	}, {
 		.uuid		= OBEX_PCE_UUID,
 		.name		= "Phone Book Access Client",
@@ -2182,7 +2192,8 @@ static struct default_settings {
 		.mode		= BT_IO_MODE_ERTM,
 		.authorize	= true,
 		.get_record	= get_mas_record,
-		.version	= 0x0100
+		.version	= 0x0100,
+		.imtu		= BT_RX_MTU,
 	}, {
 		.uuid		= OBEX_MNS_UUID,
 		.name		= "Message Notification",
@@ -2191,7 +2202,8 @@ static struct default_settings {
 		.mode		= BT_IO_MODE_ERTM,
 		.authorize	= true,
 		.get_record	= get_mns_record,
-		.version	= 0x0104
+		.version	= 0x0104,
+		.imtu		= BT_RX_MTU,
 	},
 };
 
@@ -2249,6 +2261,9 @@ static void ext_set_defaults(struct ext_profile *ext)
 		if (settings->features)
 			ext->features = settings->features;
 
+		if (settings->imtu)
+			ext->imtu = settings->imtu;
+
 		if (settings->name)
 			ext->name = g_strdup(settings->name);
 	}
Signature · 1 line
2.34.1
#8 lore raw

RE: [v3] profile: Set L2CAP IMTU for OBEX profile listeners

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1105837

---Test result---

Test Summary:

CheckPatch                    PASS      0.36 seconds
GitLint                       PASS      0.23 seconds
BuildEll                      PASS      17.80 seconds
BluezMake                     PASS      634.83 seconds
CheckSmatch                   PASS      311.82 seconds
bluezmakeextell               PASS      166.60 seconds
IncrementalBuild              PASS      599.14 seconds
ScanBuild                     PASS      913.59 seconds

https://github.com/bluez/bluez/pull/2176

---
Regards,
Linux Bluetooth

#9 lore raw

Re: [PATCH v3] profile: Set L2CAP IMTU for OBEX profile listeners

In reply to Wei Deng
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 6 lines · On Thu, 4 Jun 2026 15:00:24 +0530 you wrote:

The default_settings entries for OBEX profiles (OPP, FTP, PBAP, MAS, MNS) have no imtu field, so ext_start_servers() creates the L2CAP listening socket without an explicit IMTU. This causes the socket to advertise the L2CAP minimum of 672 bytes in L2CAP_CONFIGURATION_RSP, limiting the peer's outgoing PDU size and degrading Rx throughput.

Quoted 6 lines

Add an imtu field to default_settings and set it to 32767 for all OBEX profiles that use L2CAP. Copy the value in ext_set_defaults() and apply it to the listening socket via bt_io_set() after bt_io_listen() succeeds.

[...]

Here is the summary with links:
- [v3] profile: Set L2CAP IMTU for OBEX profile listeners

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=646014a6a246

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html