All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: Wrong timeout when connecting to device with removed pairing
Date: Fri, 15 Apr 2011 16:28:58 -0300	[thread overview]
Message-ID: <20110415192858.GD2359@joana> (raw)
In-Reply-To: <20110415192258.GC2359@joana>

* Gustavo F. Padovan <padovan@profusion.mobi> [2011-04-15 16:22:58 -0300]:

> Hi Luiz,
> 
> * Luiz Augusto von Dentz <luiz.dentz@gmail.com> [2011-04-12 14:36:01 +0300]:
> 
> > Apparently this is a regression caused by commit
> > 769be974d0c7b4fe1a52f9cdaad22259b60953f7 - [Bluetooth] Use ACL config
> > stage to retrieve remote features, when receiving pincode request in a
> > new connection the state will be BT_CONFIG so HCI_PAIRING_TIMEOUT is
> > never set to the connection, this could be reproduced by removing a
> > link key in the remote side and trying to connect:
> > 
> > 2011-04-05 12:11:37.070953 < HCI Command: Authentication Requested
> > (0x01|0x0011) plen 2
> >     handle 1
> > 2011-04-05 12:11:37.071686 > HCI Event: Command Status (0x0f) plen 4
> >     Authentication Requested (0x01|0x0011) status 0x00 ncmd 1
> > 2011-04-05 12:11:37.071838 > HCI Event: Link Key Request (0x17) plen 6
> >     bdaddr 00:1F:E1:EB:B9:CB
> > 2011-04-05 12:11:37.075073 < HCI Command: Link Key Request Reply
> > (0x01|0x000b) plen 22
> >     bdaddr 00:1F:E1:EB:B9:CB key 92BA9EAD06542B0600457C609B8F5395
> > 2011-04-05 12:11:37.075775 > HCI Event: Command Complete (0x0e) plen 10
> >     Link Key Request Reply (0x01|0x000b) ncmd 1
> >     status 0x00 bdaddr 00:1F:E1:EB:B9:CB
> > 2011-04-05 12:11:37.087005 > HCI Event: PIN Code Request (0x16) plen 6
> >     bdaddr 00:1F:E1:EB:B9:CB
> > 2011-04-05 12:11:39.038849 < ACL data: handle 1 flags 0x00 dlen 12
> >     L2CAP(s): Disconn req: dcid 0x00a9 scid 0x0040
> > 2011-04-05 12:11:39.100647 > HCI Event: Number of Completed Packets
> > (0x13) plen 5
> >     handle 1 packets 1
> > 2011-04-05 12:11:39.100830 > ACL data: handle 1 flags 0x02 dlen 12
> >     L2CAP(s): Disconn rsp: dcid 0x00a9 scid 0x0040
> > 2011-04-05 12:11:40.433624 > HCI Event: Auth Complete (0x06) plen 3
> >     status 0x13 handle 1
> >     Error: Remote User Terminated Connection
> > 2011-04-05 12:11:40.437774 > HCI Event: Disconn Complete (0x05) plen 4
> >     status 0x00 handle 1 reason 0x13
> >     Reason: Remote User Terminated Connection
> > 
> > I think the following patch might fix it:
> > 
> > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> > index 3fbfa50..abdc4de 100644
> > --- a/net/bluetooth/hci_event.c
> > +++ b/net/bluetooth/hci_event.c
> > @@ -1973,10 +1973,14 @@ static inline void hci_pin_code_request_evt(struct
> > hci_dev *hdev, struct sk_buff
> >         hci_dev_lock(hdev);
> > 
> >         conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
> > -       if (conn && conn->state == BT_CONNECTED) {
> > -               hci_conn_hold(conn);
> > +       if (conn) {
> >                 conn->disc_timeout = HCI_PAIRING_TIMEOUT;
> > -               hci_conn_put(conn);
> > +
> > +               /* Update disconnect timer */
> > +               if (conn->state == BT_CONNECTED) {
> > +                       hci_conn_hold(conn);
> > +                       hci_conn_put(conn);
> 
> I think these two line can be:
> 
> 		mod_timer(&conn->disc_timer, jiffies + HCI_PAIRING_TIMEOUT);
> 
> 
> The two main difference are that here we don't delete the idle_timer, but it
> isn't used anywhere, so I think we can delete it. 

My mistake, idle_timer is actually used, I forgot to look hci_conn.c

> Also we don't double the
> timeout value when !conn->out
> 
> from hci_conn_put():
> 
>                 timeo = msecs_to_jiffies(conn->disc_timeout);
> 		if (!conn->out)
> 			timeo *= 2; 
> 
> I still don't know why we double it.
> 
> -- 
> Gustavo F. Padovan
> http://profusion.mobi

-- 
Gustavo F. Padovan
http://profusion.mobi

  reply	other threads:[~2011-04-15 19:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-12 11:36 Wrong timeout when connecting to device with removed pairing Luiz Augusto von Dentz
2011-04-15 19:22 ` Gustavo F. Padovan
2011-04-15 19:28   ` Gustavo F. Padovan [this message]
2011-04-17 17:32     ` Luiz Augusto von Dentz

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=20110415192858.GD2359@joana \
    --to=padovan@profusion.mobi \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.