Skip to contentSkip to conversation

Set connection state to BT_DISCONN to avoid multiple responses

PATCH In review Liang Bao 3 participants 4 messages Jan 29, 2011 – Feb 2, 2011

Subsystems (2)
lore
Share & tools
lore

Liang Bao

author
#0 lore raw

PATCH 1/1 Set connection state to BT_DISCONN to avoid multiple responses

From: Bao Liang <[email protected]>

This patch fixes a minor issue that two connection responses will be sent for one L2CAP connection request. If the L2CAP connection request is first blocked due to security reason and responded with reason "security block", the state of the connection remains BT_CONNECT2. If a pairing procedure completes successfully before the ACL connection is down, local host will send another connection complete response. See the following packets captured by hcidump.

2010-12-07 22:21:24.928096 < ACL data: handle 12 flags 0x00 dlen 16
    0000: 0c 00 01 00 03 19 08 00  41 00 53 00 03 00 00 00  ........A.S.....

... ...

2010-12-07 22:21:35.791747 > HCI Event: Auth Complete (0x06) plen 3
    status 0x00 handle 12

... ...

2010-12-07 22:21:35.872372 > ACL data: handle 12 flags 0x02 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0054 scid 0x0040 result 0 status 0
      Connection successful
---
 net/bluetooth/l2cap.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
net/bluetooth/l2cap.c +1 -0
index fadf26b..364197d 100644
@@ -848,6 +848,7 @@ static void __l2cap_sock_close(struct sock *sk, int reason)
 				result = L2CAP_CR_SEC_BLOCK;
 			else
 				result = L2CAP_CR_BAD_PSM;
+			sk->sk_state = BT_DISCONN;
 
 			rsp.scid   = cpu_to_le16(l2cap_pi(sk)->dcid);
 			rsp.dcid   = cpu_to_le16(l2cap_pi(sk)->scid);
Signature · 1 line
1.7.1
Acked-by on v1 1/1
#1 lore raw

Hi,

Quoted 16 lines · ext Liang Bao

From: Bao Liang <[email protected]>

This patch fixes a minor issue that two connection responses will be sent for one L2CAP connection request. If the L2CAP connection request is first blocked due to security reason and responded with reason "security block", the state of the connection remains BT_CONNECT2. If a pairing procedure completes successfully before the ACL connection is down, local host will send another connection complete response. See the following packets captured by hcidump.

2010-12-07 22:21:24.928096 < ACL data: handle 12 flags 0x00 dlen 16
    0000: 0c 00 01 00 03 19 08 00  41 00 53 00 03 00 00 00  ........A.S.....

... ...

2010-12-07 22:21:35.791747 > HCI Event: Auth Complete (0x06) plen 3
    status 0x00 handle 12
Quoted 7 lines

... ...

2010-12-07 22:21:35.872372 > ACL data: handle 12 flags 0x02 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0054 scid 0x0040 result 0 status 0
      Connection successful

Now it looks good to me.

Quoted 19 lines
---
 net/bluetooth/l2cap.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
net/bluetooth/l2cap.c +1 -0
index fadf26b..364197d 100644
@@ -848,6 +848,7 @@ static void __l2cap_sock_close(struct sock *sk, int reason)
 				result = L2CAP_CR_SEC_BLOCK;
 			else
 				result = L2CAP_CR_BAD_PSM;
+			sk->sk_state = BT_DISCONN;
 
 			rsp.scid   = cpu_to_le16(l2cap_pi(sk)->dcid);
 			rsp.dcid   = cpu_to_le16(l2cap_pi(sk)->scid);
Signature · 1 line
1.7.1
Signature · 1 line
Ville
author
#2 lore raw

2011/1/31 Ville Tervo <[email protected]>:

Quoted 25 lines

Hi,

Quoted 22 lines · ext Liang Bao

From: Bao Liang <[email protected]>

This patch fixes a minor issue that two connection responses will be sent for one L2CAP connection request. If the L2CAP connection request is first blocked due to security reason and responded with reason "security block", the state of the connection remains BT_CONNECT2. If a pairing procedure completes successfully before the ACL connection is down, local host will send another connection complete response. See the following packets captured by hcidump.

2010-12-07 22:21:24.928096 < ACL data: handle 12 flags 0x00 dlen 16

    0000: 0c 00 01 00 03 19 08 00  41 00 53 00 03 00 00 00  ........A.S..... ... ...

2010-12-07 22:21:35.791747 > HCI Event: Auth Complete (0x06) plen 3

    status 0x00 handle 12
... ...

2010-12-07 22:21:35.872372 > ACL data: handle 12 flags 0x02 dlen 16

    L2CAP(s): Connect rsp: dcid 0x0054 scid 0x0040 result 0 status 0 Connection successful

Quoted 6 lines
Quoted 1 line

Now it looks good to me.

Thanks, so ready for push? ;)

Quoted 23 lines
Quoted 14 lines

---
 net/bluetooth/l2cap.c |    1 +

 1 files changed, 1 insertions(+), 0 deletions(-)
net/bluetooth/l2cap.c +0 -0
index fadf26b..364197d 100644
@@ -848,6 +848,7 @@ static void __l2cap_sock_close(struct sock *sk, int reason)
                               result = L2CAP_CR_SEC_BLOCK;

                      else
                              result = L2CAP_CR_BAD_PSM;
+                     sk->sk_state = BT_DISCONN;

Quoted 5 lines

                      rsp.scid   = cpu_to_le16(l2cap_pi(sk)->dcid); rsp.dcid   = cpu_to_le16(l2cap_pi(sk)->scid); --
1.7.1

--
Ville

#3 lore raw
In reply to Liang Bao

Hi Liang,

Quoted 18 lines · Liang Bao

From: Bao Liang <[email protected]>

This patch fixes a minor issue that two connection responses will be sent for one L2CAP connection request. If the L2CAP connection request is first blocked due to security reason and responded with reason "security block", the state of the connection remains BT_CONNECT2. If a pairing procedure completes successfully before the ACL connection is down, local host will send another connection complete response. See the following packets captured by hcidump.

2010-12-07 22:21:24.928096 < ACL data: handle 12 flags 0x00 dlen 16
    0000: 0c 00 01 00 03 19 08 00  41 00 53 00 03 00 00 00  ........A.S.....

... ...

2010-12-07 22:21:35.791747 > HCI Event: Auth Complete (0x06) plen 3
    status 0x00 handle 12

... ...

Quoted 8 lines
2010-12-07 22:21:35.872372 > ACL data: handle 12 flags 0x02 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0054 scid 0x0040 result 0 status 0
      Connection successful
---
 net/bluetooth/l2cap.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Patch has been applied. Thanks.

Signature · 2 lines
Gustavo F. Padovan
http://profusion.mobi