Commit 79321b06 authored by Iulia Tanasescu's avatar Iulia Tanasescu Committed by Luiz Augusto von Dentz
Browse files

Bluetooth: ISO: Fix matching parent socket for BIS slave



Currently, when a BIS slave connection is notified to the
ISO layer, the parent socket is tried to be matched by the
HCI_EVT_LE_BIG_SYNC_ESTABILISHED event. However, a BIS slave
connection is notified to the ISO layer after the Command
Complete for the LE Setup ISO Data Path command is received.
This causes the parent to be incorrectly matched if multiple
listen sockets are present.

This commit adds a fix by matching the parent based on the
BIG handle set in the notified connection.

Signed-off-by: default avatarIulia Tanasescu <iulia.tanasescu@nxp.com>
Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
parent 4a5e0ba6
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -1733,6 +1733,13 @@ static bool iso_match_big(struct sock *sk, void *data)
	return ev->handle == iso_pi(sk)->qos.bcast.big;
}

static bool iso_match_big_hcon(struct sock *sk, void *data)
{
	struct hci_conn *hcon = data;

	return hcon->iso_qos.bcast.big == iso_pi(sk)->qos.bcast.big;
}

static bool iso_match_pa_sync_flag(struct sock *sk, void *data)
{
	return test_bit(BT_SK_PA_SYNC, &iso_pi(sk)->flags);
@@ -1756,8 +1763,16 @@ static void iso_conn_ready(struct iso_conn *conn)
		if (!hcon)
			return;

		if (test_bit(HCI_CONN_BIG_SYNC, &hcon->flags) ||
		    test_bit(HCI_CONN_BIG_SYNC_FAILED, &hcon->flags)) {
		if (test_bit(HCI_CONN_BIG_SYNC, &hcon->flags)) {
			/* A BIS slave hcon is notified to the ISO layer
			 * after the Command Complete for the LE Setup
			 * ISO Data Path command is received. Get the
			 * parent socket that matches the hcon BIG handle.
			 */
			parent = iso_get_sock(&hcon->src, &hcon->dst,
					      BT_LISTEN, iso_match_big_hcon,
					      hcon);
		} else if (test_bit(HCI_CONN_BIG_SYNC_FAILED, &hcon->flags)) {
			ev = hci_recv_event_data(hcon->hdev,
						 HCI_EVT_LE_BIG_SYNC_ESTABILISHED);