All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alfonso Acosta <fons@spotify.com>
To: Alfonso Acosta <fons@spotify.com>,
	Marcel Holtmann <marcel@holtmann.org>,
	linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH v3] Bluetooth: Add HCI_AUTO_CONN_DIRECT_REPORT_IND
Date: Mon, 29 Sep 2014 17:25:24 +0200	[thread overview]
Message-ID: <CAHF=Y4qFrSNBgAMz+VRHXYnLFij3A_a5qoQmHkCtS3BnextZdQ@mail.gmail.com> (raw)
In-Reply-To: <20140929143531.GA20265@t440s.P-661HNU-F1>

I was informally describing the HCI exchange between the device , not
the userspace calls. Sorry I didn't make that clear.

On Mon, Sep 29, 2014 at 4:35 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Alfonso,
>
> On Mon, Sep 29, 2014, Alfonso Acosta wrote:
>> * With 0x02, (HCI_AUTO_CONN_ALWAYS) there is auto-connection upon
>> ADV_DIRECT_IND but replacing the device's batteries  (power-on
>> ADV_IND) causes an infinite connection loop: connect->encryption
>> on->disconnect(due to "encryption on" failing)->connect .... Getting
>> the report data inside the  Device Connected event won't help because
>> it will never get to that point.
>
> Are you sure that you've mapped out the order of events correctly for
> this case? The way things should be going (based on going through the
> code - I haven't verified this in practice) on the user space side is:
>
> 1. mgmt_ev_device_connected (connected_callback() in adapter.c)
> 2. Connection indication on ATT server socket (src/attrib-server.c)
> 3. device_attach_attrib() called (due to step 2)
> 4. bt_io_set(io, ..., BT_IO_SEC_MEDIUM, ...);
>
> The last step above is what instructs the kernel to initiate encryption.
> If the mgmt_ev_device_connected would contain hints telling us to call
> mgmt_unpair + mgmt_pair instead of trying to elevate security your use
> case should be solvable.
>
> If the above order is not what's happening we might be having a race
> condition between the mgmt and ATT sockets. This race *should* be
> fixable by ensuring that the mgmt socket has higher priority in the
> mainloop than the ATT socket.  We used to have it like that in the past,
> but we might have lost it along the way because shared/mgmt.c that uses
> shared/io.h.
>
> As a quick hack to check if these sockets are indeed racing against each
> other during the same mainloop iteration you could try changing
> G_PRIORITY_DEFAULT to G_PRIORITY_HIGH in the io_set_read_handler()
> function in src/shared/io-glib.c (the ATT socket shouldn't be using that
> but shared/mgmt.c is).
>
> Johan



-- 
Alfonso Acosta

Embedded Systems Engineer at Spotify
Birger Jarlsgatan 61, Stockholm, Sweden
http://www.spotify.com

      reply	other threads:[~2014-09-29 15:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-26 15:54 [PATCH v3] Bluetooth: Add HCI_AUTO_CONN_DIRECT_REPORT_IND Alfonso Acosta
2014-09-29  8:37 ` Marcel Holtmann
2014-09-29 10:59   ` Alfonso Acosta
2014-09-29 11:34     ` Marcel Holtmann
2014-09-29 13:33       ` Alfonso Acosta
2014-09-29 14:29         ` Marcel Holtmann
2014-09-29 14:49           ` Alfonso Acosta
2014-09-29 14:54             ` Marcel Holtmann
2014-10-03  8:37             ` Alfonso Acosta
2014-10-03  9:55               ` Marcel Holtmann
2014-10-09  1:01                 ` Alfonso Acosta
2014-09-29 14:35         ` Johan Hedberg
2014-09-29 15:25           ` Alfonso Acosta [this message]

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='CAHF=Y4qFrSNBgAMz+VRHXYnLFij3A_a5qoQmHkCtS3BnextZdQ@mail.gmail.com' \
    --to=fons@spotify.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 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.