mbox series

[BlueZ,0/2] AVDTP SEID pool seems too small

Message ID 20210829155012.164880-1-pav@iki.fi (mailing list archive)
Headers show
Series AVDTP SEID pool seems too small | expand

Message

Pauli Virtanen Aug. 29, 2021, 3:50 p.m. UTC
Hi,

It seems that if media application is registered to multiple BT
adapters, BlueZ can easily run out of free AVDTP SEIDs.  This occurs in
practice when running Pipewire (or Pulseaudio) and plugging in 3+
adapters: their media application has 10+ SEPs for various vendor A2DP
codecs, registered for each adapter.  After having registered 32 SEPs
across all adapters, Media1.RegisterApplication starts failing, due to
SEP registration not finding free SEIDs.

However, if I understand the AVDTP spec and BlueZ implementation
correctly, this behavior is not quite correct: (i) the SEID pool in
BlueZ is limited to 8*sizeof(int) == 32 entries, which is smaller than
the 0x3E = 62 entries (AVDTP1.3, 8.20.1).  Also, (ii) BlueZ allocates
SEIDs from a pool shared by all adapters, whereas it seems they should
be device & connection local (AVDTP1.3, 4.10). Since adapters are
separate devices in this context, this then appears to imply that each
should have separate SEID pool.

If this interpretation is right (I don't know the AVDTP spec very
well, so...), here are two patches that address this.  In (limited)
tests this seemed to work.

Pauli Virtanen (2):
  shared/util: use 64-bit bitmap in util_get/clear_uid
  avdtp: use separate local SEID pool for each adapter

 android/avdtp.c        |  2 +-
 profiles/audio/a2dp.c  |  2 +-
 profiles/audio/avdtp.c | 55 ++++++++++++++++++++++++++++++++++++------
 profiles/audio/avdtp.h |  4 ++-
 src/advertising.c      |  2 +-
 src/shared/util.c      | 27 ++++++++++++---------
 src/shared/util.h      |  4 +--
 unit/test-avdtp.c      |  2 +-
 8 files changed, 71 insertions(+), 27 deletions(-)