Re: main.conf: GATT.ExchangeMTU

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

 



Hi Christian,

On Mon, May 12, 2025 at 6:04 AM Christian Eggers <ceggers@xxxxxxx> wrote:
>
> 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.

Yeah, you can't go with 23 for classic, perhaps we could split the
setting for setting it or something like it.

> Questions:
> 1. Is it correct that the value of ExchangeMTU isn't used for the LE socket?

It is used, it is not used in the socket though since it is a fixed
CID the MTU is not configurable, thus you need to use ATT to exchange
the MTU.

> 2. Should the kernel allow MTU values such as 23 for all (GATT) sockets?

Don't think that is an option for BR/EDR.

> 3. Where/how should this be fixed (kernel / bluetoothd / main.conf)?

Well if you think you can do 23 for all sockets, you don't, but if you
want just LE perhaps you should disable classic then? Otherwise we
will need a different setting for ATT over Classic.

>
> 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
>
>
>
>


-- 
Luiz Augusto von Dentz





[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