Skip to content

Commit 8bb67c5

Browse files
lylezhu2012kartben
authored andcommitted
Bluetooth: Classic: SMP: Derived LE keys are not handled correctly
The derived LE keys are not saved to NVM. And the IRK is not added to controller resolving list. It causes two issues, Issue 1, the LE connection connection cannot be established if the adv address of peer is RPA. Issue 2, the LE keys are missing after the power reset. For issue 1, add a function `smp_br_id_add_replace` to add LE keys. For issue 2, check the BR bondable flag `BT_CONN_BR_NOBOND` instead of `SMP_FLAG_BOND`. Signed-off-by: Lyle Zhu <[email protected]>
1 parent a7ba802 commit 8bb67c5

File tree

1 file changed

+23
-1
lines changed
  • subsys/bluetooth/host

1 file changed

+23
-1
lines changed

subsys/bluetooth/host/smp.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,24 @@ static void smp_br_reset(struct bt_smp_br *smp)
822822
atomic_set_bit(smp->allowed_cmds, BT_SMP_CMD_PAIRING_REQ);
823823
}
824824

825+
static void smp_br_id_add_replace(struct bt_keys *keys)
826+
{
827+
struct bt_keys *conflict;
828+
829+
conflict = bt_id_find_conflict(keys);
830+
if (conflict != NULL) {
831+
int err;
832+
833+
LOG_DBG("Un-pairing old conflicting bond and finalizing new.");
834+
835+
err = bt_unpair(conflict->id, &conflict->addr);
836+
__ASSERT_NO_MSG(!err);
837+
}
838+
839+
__ASSERT_NO_MSG(!bt_id_find_conflict(keys));
840+
bt_id_add(keys);
841+
}
842+
825843
static void smp_pairing_br_complete(struct bt_smp_br *smp, uint8_t status)
826844
{
827845
struct bt_conn *conn = smp->chan.chan.conn;
@@ -852,9 +870,13 @@ static void smp_pairing_br_complete(struct bt_smp_br *smp, uint8_t status)
852870
}
853871
}
854872
} else {
855-
bool bond_flag = atomic_test_bit(smp->flags, SMP_FLAG_BOND);
873+
bool bond_flag = !atomic_test_bit(conn->flags, BT_CONN_BR_NOBOND);
856874
struct bt_conn_auth_info_cb *listener, *next;
857875

876+
if (keys) {
877+
smp_br_id_add_replace(keys);
878+
}
879+
858880
if (bond_flag && keys) {
859881
bt_keys_store(keys);
860882
}

0 commit comments

Comments
 (0)