2012-10-11 11:19:50

by Syam Sidhardhan

[permalink] [raw]
Subject: Re: [PATCH 1/4] Bluetooth: Fix L2CAP PSM bind issue

Hi Marcel,

----- Original Message -----
From: "Marcel Holtmann" <[email protected]>
To: "Syam Sidhardhan" <[email protected]>
Cc: <[email protected]>
Sent: Wednesday, October 10, 2012 11:17 PM
Subject: Re: [PATCH 1/4] Bluetooth: Fix L2CAP PSM bind issue


> Hi Syam,
>
>> Problem: If we bind a particular PSM with source address as BDADDR_ANY,
>> then we are able to bind the same PSM with adapter address(or any other
>> address), which is incorrect.
>
> why is this incorrect? Explain that to me.
>

Here there is a correction required in the commit message.

As per my understanding the a particular PSM can be binded only once
for a single adapter address. Kindly correct me if I'm wrong here.

As I mentioned in the additional comment part of the patch, there is
a PSM conflict happens between the Obexd and HDP, because of the
source address differences. With this patch, it's getting resolved and
I'm able to run Obexd and HDP simultaniously.

The otherway to fix it, is in userspace. Always provide the source adapter
address during the PSM binding, rather than providing BDADDR_ANY.

If this patch code changes are valid, then I can send a seperate version
patch with
the following corrected commit message description.

"Problem: If we bind a particular PSM with source address as BDADDR_ANY,
then we are able to bind the same PSM with adapter address." ...

Kindly let me know.

Thanks,
Syam.


2012-10-11 14:29:26

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH 1/4] Bluetooth: Fix L2CAP PSM bind issue

Hi Marcel,

On Thu, Oct 11, 2012 at 3:56 PM, Marcel Holtmann <[email protected]> wrote:
> Hi Syam,
>
>> >> Problem: If we bind a particular PSM with source address as BDADDR_ANY,
>> >> then we are able to bind the same PSM with adapter address(or any other
>> >> address), which is incorrect.
>> >
>> > why is this incorrect? Explain that to me.
>> >
>>
>> Here there is a correction required in the commit message.
>>
>> As per my understanding the a particular PSM can be binded only once
>> for a single adapter address. Kindly correct me if I'm wrong here.
>
> a PSM can be bound once per adapter address. And of course once per
> BDADDR_ANY.
>
> So you can bind PSM 23 to BDADDR_ANY and 11:22:33:44:55:66. An incoming
> connection to 11:22:33:44:55:66 will arrive to that specific socket, but
> an incoming to all others will be handled by the BDADDR_ANY.
>
> The BDADDR_ANY is special. Consider it a wildcard bound with lower
> priority. If overwritten with a specific address bound, that will be
> considered first of course.
>
> If we are not doing it that way, than that is a bug.
>
> Outgoing connections should behave the same btw. If a specific address
> is bound, than that will be used. If not available, then you can not
> connect. If BDADDR_ANY is used, then the next available adapter will be
> used.

The real problem is by giving psm 0 the kernel should return the first
available psm in the non-reserved space, but since we reuse the same
code to do the matching it end up given both obexd and hdp the same
psm, IMO in this case we should consider using Syam code and not
__l2cap_global_chan_by_addr as the userspace is probably asking for a
psm not in use which should exclude those in use by BDADDR_ANY.

--
Luiz Augusto von Dentz

2012-10-11 13:56:50

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH 1/4] Bluetooth: Fix L2CAP PSM bind issue

Hi Syam,

> >> Problem: If we bind a particular PSM with source address as BDADDR_ANY,
> >> then we are able to bind the same PSM with adapter address(or any other
> >> address), which is incorrect.
> >
> > why is this incorrect? Explain that to me.
> >
>
> Here there is a correction required in the commit message.
>
> As per my understanding the a particular PSM can be binded only once
> for a single adapter address. Kindly correct me if I'm wrong here.

a PSM can be bound once per adapter address. And of course once per
BDADDR_ANY.

So you can bind PSM 23 to BDADDR_ANY and 11:22:33:44:55:66. An incoming
connection to 11:22:33:44:55:66 will arrive to that specific socket, but
an incoming to all others will be handled by the BDADDR_ANY.

The BDADDR_ANY is special. Consider it a wildcard bound with lower
priority. If overwritten with a specific address bound, that will be
considered first of course.

If we are not doing it that way, than that is a bug.

Outgoing connections should behave the same btw. If a specific address
is bound, than that will be used. If not available, then you can not
connect. If BDADDR_ANY is used, then the next available adapter will be
used.

Regards

Marcel