Re: [PATCH v4 2/4] Bluetooth: connect to an RPA as to the identity behind it
From: Radek Podgorny
Date: Wed Nov 25 2026 - 18:35:12 EST
Hi Luiz,
On Tue, Nov 24, 2026 at 5:35 PM Luiz Augusto von Dentz wrote:
> Any reason why le_conn_lookup_irk is not incorporated into
> hci_conn_hash_lookup_le? That would mean other plcares that want to
> resolve a hci_conn to a peer always lookup by both address or irk not
> just by address.
No reason beyond keeping the change small. I went through the other
callers and none of them is hurt by it, so v5, which follows, does
that.
A connection is kept under an RPA whose IRK we hold mostly while
hci_connect_le() is still creating it, since le_conn_complete_evt() and
smp_notify_keys() both move it to the identity. The other cases are the
time between SMP adding the IRK and smp_notify_keys(), a connection
that was up before Load IRKs, which nothing moves, and an explicit
connect made to the RPA before the IRK was known (more on that below).
The unpair paths remove the IRK before they look up, so they don't
change. Given the identity, the other callers now also find a
connection kept under an RPA: Load Connection Parameters queues an
update that applies once it completes, a pairing reply goes to it, and
Disconnect cancels an explicit connect that was never started. One
whose LE Create Connection is already queued is over by the time the
Disconnect work runs, as both go through the same queue.
Four things change with it:
- hci_conn_hash_lookup_le() moves out of line into hci_conn.c, since
smp_irk_matches() is private to net/bluetooth.
- hci_connect_le() reused a scanning connection found by address.
One found by IRK it must still refuse, as v4's 3/4 does, so it now
returns -EBUSY when the connection's dst is not the address it was
given. With that, the separate IRK lookup in hci_connect_le() goes
away, and so does v4's 3/4: the combined lookup and that check are
now 2/4, and the old 2/4 shrinks to resolving the RPA in
hci_connect_le_scan().
- hci_connect_le_scan() reuses what the lookup returns, except a
connection still scanning under an RPA that has params of its own
there. That is an explicit connect made to the RPA before the IRK was
known, which is never started. Both connect paths refuse it with
-EBUSY: a connection of their own would be dialled to the same RPA,
and le_conn_complete_evt() matches a completion by address, so it
would complete the older one and leave the new one blocking every LE
connect after it.
- The fallback works from the identity only. Resolving an RPA given
by the caller to the identity's connection as well would change
what Disconnect and Unpair Device do given an RPA, so I left it out;
I can do it as a follow-up if you want the lookup to work both ways.
Thanks,
Radek