2013-07-17 16:30:38

by Syam Sidhardhan

[permalink] [raw]
Subject: [PATCH 1/1 v2] Bluetooth: Fix ACL alive for long in case of non pariable devices

From: Syam Sidhardhan <[email protected]>

For certain devices (ex: HID mouse), support for authentication,
pairing and bonding is optional. For such devices, the ACL alive
for too long after the L2CAP disconnection.

To avoid the ACL alive for too long after L2CAP disconnection, reset the ACL
disconnect timeout back to HCI_DISCONN_TIMEOUT when L2CAP is connected.

While merging the commit id:a9ea3ed9b71cc3271dd59e76f65748adcaa76422
this issue might have introduced.

Signed-off-by: Sang-Ki Park <[email protected]>
Signed-off-by: Syam Sidhardhan <[email protected]>
---
v1 -> Modified the code as per the latest code.
v2 -> Add descriptive comment as per Marcel request.

net/bluetooth/l2cap_core.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 9af3a76..e7ff7d5 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1383,6 +1383,15 @@ static void l2cap_conn_ready(struct l2cap_conn *conn)

BT_DBG("conn %p", conn);

+ /* For certain devices (ex: HID mouse), support for authentication,
+ * pairing and bonding is optional. For such devices, inorder to avoid
+ * the ACL alive for too long after L2CAP disconnection, reset the ACL
+ * disc_timeout back to HCI_DISCONN_TIMEOUT when L2CAP is connected.
+ */
+ hci_conn_hold(conn->hcon);
+ conn->hcon->disc_timeout = HCI_DISCONN_TIMEOUT;
+ hci_conn_drop(conn->hcon);
+
/* For outgoing pairing which doesn't necessarily have an
* associated socket (e.g. mgmt_pair_device).
*/
--
1.7.9.5



2013-07-24 16:38:29

by Syam Sidhardhan

[permalink] [raw]
Subject: Re: [PATCH 1/1 v2] Bluetooth: Fix ACL alive for long in case of non pariable devices

Hi,

On Wed, Jul 17, 2013 at 10:10 PM, Marcel Holtmann <[email protected]> wrote:
> Hi Syam,
>
>> For certain devices (ex: HID mouse), support for authentication,
>> pairing and bonding is optional. For such devices, the ACL alive
>> for too long after the L2CAP disconnection.
>>
>> To avoid the ACL alive for too long after L2CAP disconnection, reset the ACL
>> disconnect timeout back to HCI_DISCONN_TIMEOUT when L2CAP is connected.
>>
>> While merging the commit id:a9ea3ed9b71cc3271dd59e76f65748adcaa76422
>> this issue might have introduced.
>>
>> Signed-off-by: Sang-Ki Park <[email protected]>
>> Signed-off-by: Syam Sidhardhan <[email protected]>
>> ---
>> v1 -> Modified the code as per the latest code.
>> v2 -> Add descriptive comment as per Marcel request.
>>
>> net/bluetooth/l2cap_core.c | 9 +++++++++
>> 1 file changed, 9 insertions(+)
>
While testing this patch more with a remote non SSP device, we have noticed that
when the remote device is busy with entering the pin key(over a UI),
we are initiating
a HCI disconnection exactly after 4 seconds. This happens because
l2cap_conn_ready()
is getting called from multiple locations (ex:hci_remote_ext_features_evt() ->
hci_proto_connect_cfm() -> l2cap_connect_cfm()->l2cap_conn_ready()) and the
disconnect timeout is reseted to 2 seconds.

As Szymon mentioned, we have to apply the reset logic during
l2cap_connect_req(), not in l2cap_le_conn_ready(). After this modification
its working fine. I'll soon send an another patchset version.

Regards,
Syam

2013-07-17 16:40:52

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH 1/1 v2] Bluetooth: Fix ACL alive for long in case of non pariable devices

Hi Syam,

> For certain devices (ex: HID mouse), support for authentication,
> pairing and bonding is optional. For such devices, the ACL alive
> for too long after the L2CAP disconnection.
>
> To avoid the ACL alive for too long after L2CAP disconnection, reset the ACL
> disconnect timeout back to HCI_DISCONN_TIMEOUT when L2CAP is connected.
>
> While merging the commit id:a9ea3ed9b71cc3271dd59e76f65748adcaa76422
> this issue might have introduced.
>
> Signed-off-by: Sang-Ki Park <[email protected]>
> Signed-off-by: Syam Sidhardhan <[email protected]>
> ---
> v1 -> Modified the code as per the latest code.
> v2 -> Add descriptive comment as per Marcel request.
>
> net/bluetooth/l2cap_core.c | 9 +++++++++
> 1 file changed, 9 insertions(+)

Acked-by: Marcel Holtmann <[email protected]>

Regards

Marcel