main.conf: GATT.ExchangeMTU

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

for testing purposes, I tried to lower GATT's ExchangeMTU in main.conf:

> # Exchange MTU size.
> # Possible values: 23-517
> # Defaults to 517
> ExchangeMTU = 23

Unfortunately, bluetoothd doesn't show my adapter anymore after this change:

> daemon.err bluetoothd[450]: /usr/src/debug/bluez5/5.82/src/gatt-database.c:btd_gatt_database_new() Failed to start listening: setsockopt(L2CAP_OPTIONS): Invalid argument (22)
> daemon.err bluetoothd[450]: Failed to create GATT database for adapter
> daemon.err bluetoothd[450]: Unable to register new adapter

The first error message seems to come from btd_gatt_database_new() [1].

...
bredr:
	/* BR/EDR socket */
	database->bredr_io = bt_io_listen(connect_cb, NULL, NULL, NULL, &gerr,
					BT_IO_OPT_SOURCE_BDADDR, addr,
					BT_IO_OPT_PSM, BT_ATT_PSM,
					BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
					BT_IO_OPT_MTU, btd_opts.gatt_mtu,
					BT_IO_OPT_INVALID);
	if (database->bredr_io == NULL) {
		error("Failed to start listening: %s", gerr->message);
		g_error_free(gerr);
		goto fail;
	}
...

Interestingly, the ExchangeMTU value from main.conf seems not to be used when
creating the 'le_io' socket (isn't this the most important one?), so I guess
that the error message is raised when creating the 'bredr_io' socket. The
kernel has different allowed ranges for the MTU, depending on the L2CAP CID
value:

static bool l2cap_valid_mtu(struct l2cap_chan *chan, u16 mtu)
{
	switch (chan->scid) {
	case L2CAP_CID_ATT:
		if (mtu && mtu < L2CAP_LE_MIN_MTU)
			return false;
		break;

	default:
		if (mtu && mtu < L2CAP_DEFAULT_MIN_MTU)
			return false;
	}

	return true;
}

As the 'bredr_io' (and the 'eatt_io') sockets are not created with the
L2CAP_CID_ATT cid, the default branch is taken here which imposes a minimum
MTU value of 48.

Questions:
1. Is it correct that the value of ExchangeMTU isn't used for the LE socket?
2. Should the kernel allow MTU values such as 23 for all (GATT) sockets?
3. Where/how should this be fixed (kernel / bluetoothd / main.conf)?

regards,
Christian

[1] https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/gatt-database.c#n4103
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/bluetooth/l2cap_sock.c#n709







[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux