diff mbox series

[v2,2/3] Bluetooth: hci_conn: Fix not matching by CIS ID

Message ID 20230413183113.896669-2-luiz.dentz@gmail.com (mailing list archive)
State Superseded
Headers show
Series [v2,1/3] Bluetooth: hci_conn: Add support for linking multiple hcon | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/SubjectPrefix success Gitlint PASS
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

Luiz Augusto von Dentz April 13, 2023, 6:31 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This fixes only matching CIS by address which prevents creating new hcon
if upper layer is requesting a specific CIS ID.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 include/net/bluetooth/hci_core.h | 7 ++++++-
 net/bluetooth/hci_conn.c         | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

Comments

Pauli Virtanen April 14, 2023, 7:53 p.m. UTC | #1
Hi Luiz,

to, 2023-04-13 kello 11:31 -0700, Luiz Augusto von Dentz kirjoitti:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> This fixes only matching CIS by address which prevents creating new hcon
> if upper layer is requesting a specific CIS ID.
> 
> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> ---
>  include/net/bluetooth/hci_core.h | 7 ++++++-
>  net/bluetooth/hci_conn.c         | 2 +-
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index 4fe1e71cb9d8..6f5e8594ff2d 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -1180,7 +1180,8 @@ static inline struct hci_conn *hci_conn_hash_lookup_le(struct hci_dev *hdev,
>  
>  static inline struct hci_conn *hci_conn_hash_lookup_cis(struct hci_dev *hdev,
>  							bdaddr_t *ba,
> -							__u8 ba_type)
> +							__u8 ba_type,
> +							__u8 id)
>  {
>  	struct hci_conn_hash *h = &hdev->conn_hash;
>  	struct hci_conn  *c;
> @@ -1191,6 +1192,10 @@ static inline struct hci_conn *hci_conn_hash_lookup_cis(struct hci_dev *hdev,
>  		if (c->type != ISO_LINK)
>  			continue;
>  
> +		/* Match CIS ID if set */
> +		if (id != BT_ISO_QOS_CIS_UNSET && id != c->iso_qos.ucast.cis)
> +			continue;
> +

Should this also check the CIG ID?

Core v5.3 4.E Sec. 5.3: "The CIS_ID has a separate number space for
each CIG_ID.", and I didn't manage to find restriction that you
couldn't have the same peripheral in multiple CIG.

>  		if (ba_type == c->dst_type && !bacmp(&c->dst, ba)) {
>  			rcu_read_unlock();
>  			return c;
> diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
> index 204164ee5f9a..b9ecfc782be9 100644
> --- a/net/bluetooth/hci_conn.c
> +++ b/net/bluetooth/hci_conn.c
> @@ -1842,7 +1842,7 @@ struct hci_conn *hci_bind_cis(struct hci_dev *hdev, bdaddr_t *dst,
>  {
>  	struct hci_conn *cis;
>  
> -	cis = hci_conn_hash_lookup_cis(hdev, dst, dst_type);
> +	cis = hci_conn_hash_lookup_cis(hdev, dst, dst_type, qos->ucast.cis);
>  	if (!cis) {
>  		cis = hci_conn_add(hdev, ISO_LINK, dst, HCI_ROLE_MASTER);
>  		if (!cis)
Luiz Augusto von Dentz April 14, 2023, 8:13 p.m. UTC | #2
Hi Pauli,

On Fri, Apr 14, 2023 at 12:53 PM Pauli Virtanen <pav@iki.fi> wrote:
>
> Hi Luiz,
>
> to, 2023-04-13 kello 11:31 -0700, Luiz Augusto von Dentz kirjoitti:
> > From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> >
> > This fixes only matching CIS by address which prevents creating new hcon
> > if upper layer is requesting a specific CIS ID.
> >
> > Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> > ---
> >  include/net/bluetooth/hci_core.h | 7 ++++++-
> >  net/bluetooth/hci_conn.c         | 2 +-
> >  2 files changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> > index 4fe1e71cb9d8..6f5e8594ff2d 100644
> > --- a/include/net/bluetooth/hci_core.h
> > +++ b/include/net/bluetooth/hci_core.h
> > @@ -1180,7 +1180,8 @@ static inline struct hci_conn *hci_conn_hash_lookup_le(struct hci_dev *hdev,
> >
> >  static inline struct hci_conn *hci_conn_hash_lookup_cis(struct hci_dev *hdev,
> >                                                       bdaddr_t *ba,
> > -                                                     __u8 ba_type)
> > +                                                     __u8 ba_type,
> > +                                                     __u8 id)
> >  {
> >       struct hci_conn_hash *h = &hdev->conn_hash;
> >       struct hci_conn  *c;
> > @@ -1191,6 +1192,10 @@ static inline struct hci_conn *hci_conn_hash_lookup_cis(struct hci_dev *hdev,
> >               if (c->type != ISO_LINK)
> >                       continue;
> >
> > +             /* Match CIS ID if set */
> > +             if (id != BT_ISO_QOS_CIS_UNSET && id != c->iso_qos.ucast.cis)
> > +                     continue;
> > +
>
> Should this also check the CIG ID?
>
> Core v5.3 4.E Sec. 5.3: "The CIS_ID has a separate number space for
> each CIG_ID.", and I didn't manage to find restriction that you
> couldn't have the same peripheral in multiple CIG.

That is a good point, it seems the BAP Audio Configurations are
limited to just one CIG but in theory there could be multiple if they
don't need to be synchronized, I will fix that to check both CIG and
CIS.

> >               if (ba_type == c->dst_type && !bacmp(&c->dst, ba)) {
> >                       rcu_read_unlock();
> >                       return c;
> > diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
> > index 204164ee5f9a..b9ecfc782be9 100644
> > --- a/net/bluetooth/hci_conn.c
> > +++ b/net/bluetooth/hci_conn.c
> > @@ -1842,7 +1842,7 @@ struct hci_conn *hci_bind_cis(struct hci_dev *hdev, bdaddr_t *dst,
> >  {
> >       struct hci_conn *cis;
> >
> > -     cis = hci_conn_hash_lookup_cis(hdev, dst, dst_type);
> > +     cis = hci_conn_hash_lookup_cis(hdev, dst, dst_type, qos->ucast.cis);
> >       if (!cis) {
> >               cis = hci_conn_add(hdev, ISO_LINK, dst, HCI_ROLE_MASTER);
> >               if (!cis)
>
> --
> Pauli Virtanen
diff mbox series

Patch

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 4fe1e71cb9d8..6f5e8594ff2d 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1180,7 +1180,8 @@  static inline struct hci_conn *hci_conn_hash_lookup_le(struct hci_dev *hdev,
 
 static inline struct hci_conn *hci_conn_hash_lookup_cis(struct hci_dev *hdev,
 							bdaddr_t *ba,
-							__u8 ba_type)
+							__u8 ba_type,
+							__u8 id)
 {
 	struct hci_conn_hash *h = &hdev->conn_hash;
 	struct hci_conn  *c;
@@ -1191,6 +1192,10 @@  static inline struct hci_conn *hci_conn_hash_lookup_cis(struct hci_dev *hdev,
 		if (c->type != ISO_LINK)
 			continue;
 
+		/* Match CIS ID if set */
+		if (id != BT_ISO_QOS_CIS_UNSET && id != c->iso_qos.ucast.cis)
+			continue;
+
 		if (ba_type == c->dst_type && !bacmp(&c->dst, ba)) {
 			rcu_read_unlock();
 			return c;
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 204164ee5f9a..b9ecfc782be9 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -1842,7 +1842,7 @@  struct hci_conn *hci_bind_cis(struct hci_dev *hdev, bdaddr_t *dst,
 {
 	struct hci_conn *cis;
 
-	cis = hci_conn_hash_lookup_cis(hdev, dst, dst_type);
+	cis = hci_conn_hash_lookup_cis(hdev, dst, dst_type, qos->ucast.cis);
 	if (!cis) {
 		cis = hci_conn_add(hdev, ISO_LINK, dst, HCI_ROLE_MASTER);
 		if (!cis)