From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>,
Marcel Holtmann <marcel@holtmann.org>
Subject: Re: [RFC 2/2] Bluetooth: L2CAP: Check bearer type on __l2cap_global_chan_by_addr
Date: Wed, 3 Jul 2019 16:57:25 +0300 [thread overview]
Message-ID: <CABBYNZLFxgB_smaNq=0HzH0BxqKS08dsrw=ZNSv05xFkE7F75g@mail.gmail.com> (raw)
In-Reply-To: <20190603104843.26848-2-luiz.dentz@gmail.com>
Hi Marcel, Johan,
On Mon, Jun 3, 2019 at 1:48 PM Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> The spec defines PSM and LE_PSM as different domains so a listen on the
> same PSM is valid if the address type points to a different bearer.
>
> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> ---
> net/bluetooth/l2cap_core.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index b53acd6c9a3d..8da73ca8c111 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -168,11 +168,18 @@ static struct l2cap_chan *l2cap_get_chan_by_ident(struct l2cap_conn *conn,
> return c;
> }
>
> -static struct l2cap_chan *__l2cap_global_chan_by_addr(__le16 psm, bdaddr_t *src)
> +static struct l2cap_chan *__l2cap_global_chan_by_addr(__le16 psm, bdaddr_t *src,
> + u8 src_type)
> {
> struct l2cap_chan *c;
>
> list_for_each_entry(c, &chan_list, global_l) {
> + if (src_type == BDADDR_BREDR && c->src_type != BDADDR_BREDR)
> + continue;
> +
> + if (src_type != BDADDR_BREDR && c->src_type == BDADDR_BREDR)
> + continue;
> +
> if (c->sport == psm && !bacmp(&c->src, src))
> return c;
> }
> @@ -185,7 +192,7 @@ int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm)
>
> write_lock(&chan_list_lock);
>
> - if (psm && __l2cap_global_chan_by_addr(psm, src)) {
> + if (psm && __l2cap_global_chan_by_addr(psm, src, chan->src_type)) {
> err = -EADDRINUSE;
> goto done;
> }
> @@ -209,7 +216,8 @@ int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm)
>
> err = -EINVAL;
> for (p = start; p <= end; p += incr)
> - if (!__l2cap_global_chan_by_addr(cpu_to_le16(p), src)) {
> + if (!__l2cap_global_chan_by_addr(cpu_to_le16(p), src,
> + chan->src_type)) {
> chan->psm = cpu_to_le16(p);
> chan->sport = cpu_to_le16(p);
> err = 0;
> --
> 2.21.0
Any chance to review this one.
--
Luiz Augusto von Dentz
next prev parent reply other threads:[~2019-07-03 13:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-03 10:48 [RFC 1/2] Bluetooth: Use controller sets when available Luiz Augusto von Dentz
2019-06-03 10:48 ` [RFC 2/2] Bluetooth: L2CAP: Check bearer type on __l2cap_global_chan_by_addr Luiz Augusto von Dentz
2019-07-03 13:57 ` Luiz Augusto von Dentz [this message]
2019-07-06 13:39 ` Marcel Holtmann
2019-07-06 13:39 ` [RFC 1/2] Bluetooth: Use controller sets when available Marcel Holtmann
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='CABBYNZLFxgB_smaNq=0HzH0BxqKS08dsrw=ZNSv05xFkE7F75g@mail.gmail.com' \
--to=luiz.dentz@gmail.com \
--cc=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=marcel@holtmann.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;
as well as URLs for NNTP newsgroup(s).