Linux bluetooth development
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ vRFC 2/7] monitor/analyze: Fix a new connection for each BIS or eSCO packet
Date: Fri,  2 Oct 2026 15:27:54 -0400	[thread overview]
Message-ID: <20261002192759.3071262-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20261002192759.3071262-1-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

The lookup of a CIS, and of a SCO, allocates a connection when the handle
belongs to another type, so the fallback to BIS, and to eSCO, was never
reached and each packet ended up on a connection of its own.

Fixes: 8157e2fde5d3 ("monitor: Print connection type in Disconnect Complete")
Assisted-by: OpenCode:claude-opus-5.5
---
 monitor/analyze.c | 37 +++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/monitor/analyze.c b/monitor/analyze.c
index 13d470ff566d..168efdb4b882 100644
--- a/monitor/analyze.c
+++ b/monitor/analyze.c
@@ -463,6 +463,23 @@ static struct hci_conn *conn_lookup_type(struct hci_dev *dev, uint16_t handle,
 	return conn;
 }
 
+/*
+ * Look up a connection of either type, only allocating one of the first type
+ * when there is none, so the packets of the second type do not end up on a
+ * new connection each.
+ */
+static struct hci_conn *conn_lookup_types(struct hci_dev *dev,
+					uint16_t handle, uint8_t type1,
+					uint8_t type2)
+{
+	struct hci_conn *conn = conn_lookup(dev, handle);
+
+	if (conn && (conn->type == type1 || conn->type == type2))
+		return conn;
+
+	return conn_lookup_type(dev, handle, type1);
+}
+
 static void dev_destroy(void *data)
 {
 	struct hci_dev *dev = data;
@@ -1386,14 +1403,8 @@ static void sco_pkt(struct timeval *tv, uint16_t index, bool out,
 	dev->num_hci++;
 	dev->num_sco++;
 
-	conn = conn_lookup_type(dev, le16_to_cpu(hdr->handle) & 0x0fff,
-							BTMON_CONN_SCO);
-	if (!conn) {
-		conn = conn_lookup_type(dev, le16_to_cpu(hdr->handle) & 0x0fff,
-							BTMON_CONN_ESCO);
-		if (!conn)
-			return;
-	}
+	conn = conn_lookup_types(dev, le16_to_cpu(hdr->handle) & 0x0fff,
+					BTMON_CONN_SCO, BTMON_CONN_ESCO);
 
 	if (out) {
 		conn_pkt_tx(conn, tv, size - sizeof(*hdr), NULL);
@@ -1481,14 +1492,8 @@ static void iso_pkt(struct timeval *tv, uint16_t index, bool out,
 	dev->num_hci++;
 	dev->num_iso++;
 
-	conn = conn_lookup_type(dev, le16_to_cpu(hdr->handle) & 0x0fff,
-							BTMON_CONN_CIS);
-	if (!conn) {
-		conn = conn_lookup_type(dev, le16_to_cpu(hdr->handle) & 0x0fff,
-							BTMON_CONN_BIS);
-		if (!conn)
-			return;
-	}
+	conn = conn_lookup_types(dev, le16_to_cpu(hdr->handle) & 0x0fff,
+					BTMON_CONN_CIS, BTMON_CONN_BIS);
 
 	handle = le16_to_cpu(hdr->handle);
 	flags = ISO_FLAGS(handle);
-- 
2.55.0


  reply	other threads:[~2026-10-02 19:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-02 19:27 [PATCH BlueZ vRFC 1/7] monitor: Add audio quality statistics for ISO streams Luiz Augusto von Dentz
2026-10-02 19:27 ` Luiz Augusto von Dentz [this message]
2026-10-02 19:27 ` [PATCH BlueZ vRFC 3/7] monitor/analyze: Fix the size of SCO packets Luiz Augusto von Dentz
2026-10-02 19:27 ` [PATCH BlueZ vRFC 4/7] monitor/analyze: Fix the type of synchronous connections Luiz Augusto von Dentz
2026-10-02 19:27 ` [PATCH BlueZ vRFC 5/7] monitor: Add audio quality statistics for SCO data Luiz Augusto von Dentz
2026-10-02 19:27 ` [PATCH BlueZ vRFC 6/7] monitor: Add ISO link details to the analyze mode Luiz Augusto von Dentz
2026-10-02 19:27 ` [PATCH BlueZ vRFC 7/7] monitor: Add audio quality statistics for A2DP streams Luiz Augusto von Dentz
2026-10-02 22:07 ` [BlueZ,vRFC,1/7] monitor: Add audio quality statistics for ISO streams bluez.test.bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261002192759.3071262-2-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox