Skip to content

Commit 08fbd11

Browse files
lylezhu2012rlubos
authored andcommitted
[nrf fromtree] Bluetooth: Host: SSP: Correct BR bonding type
Currently, the bonding type of Authentication _Requirements parameter is always `Dedicated Bonding` if the device is pairing initiator. But if the bonding is performed during connection setup or channel establishment as a precursor to accessing a service, the bonding type should be `General bonding`. Add a flag BT_CONN_BR_GENERAL_BONDING. Set the flag if the bonding is performed in the L2CAP_BR/RFCOMM channel establishment. Set bonding type depends on the flag when receiving IO cap request. Signed-off-by: Lyle Zhu <[email protected]> (cherry picked from commit 08ceb14)
1 parent 4bec79b commit 08fbd11

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

subsys/bluetooth/host/classic/l2cap_br.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,13 @@ l2cap_br_conn_security(struct bt_l2cap_chan *chan, const uint16_t psm)
786786
* since service/profile requires that.
787787
*/
788788
if (check == 0) {
789+
/*
790+
* General Bonding refers to the process of performing bonding
791+
* during connection setup or channel establishment procedures
792+
* as a precursor to accessing a service.
793+
* For current case, it is dedicated bonding.
794+
*/
795+
atomic_set_bit(chan->conn->flags, BT_CONN_BR_GENERAL_BONDING);
789796
return L2CAP_CONN_SECURITY_PENDING;
790797
}
791798

subsys/bluetooth/host/classic/rfcomm.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,13 @@ static enum security_result rfcomm_dlc_security(struct bt_rfcomm_dlc *dlc)
829829
}
830830

831831
if (!bt_conn_set_security(conn, dlc->required_sec_level)) {
832+
/*
833+
* General Bonding refers to the process of performing bonding
834+
* during connection setup or channel establishment procedures
835+
* as a precursor to accessing a service.
836+
* For current case, it is dedicated bonding.
837+
*/
838+
atomic_set_bit(conn->flags, BT_CONN_BR_GENERAL_BONDING);
832839
/* If Security elevation is initiated or in progress */
833840
return RFCOMM_SECURITY_PENDING;
834841
}

subsys/bluetooth/host/classic/ssp.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,9 +666,17 @@ void bt_hci_io_capa_req(struct net_buf *buf)
666666
*/
667667
if (atomic_test_bit(conn->flags, BT_CONN_BR_PAIRING_INITIATOR)) {
668668
if (get_io_capa() != BT_IO_NO_INPUT_OUTPUT) {
669-
auth = BT_HCI_DEDICATED_BONDING_MITM;
669+
if (atomic_test_bit(conn->flags, BT_CONN_BR_GENERAL_BONDING)) {
670+
auth = BT_HCI_GENERAL_BONDING_MITM;
671+
} else {
672+
auth = BT_HCI_DEDICATED_BONDING_MITM;
673+
}
670674
} else {
671-
auth = BT_HCI_DEDICATED_BONDING;
675+
if (atomic_test_bit(conn->flags, BT_CONN_BR_GENERAL_BONDING)) {
676+
auth = BT_HCI_GENERAL_BONDING;
677+
} else {
678+
auth = BT_HCI_DEDICATED_BONDING;
679+
}
672680
}
673681
} else {
674682
auth = ssp_get_auth(conn);

subsys/bluetooth/host/conn.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,6 +2633,7 @@ static void reset_pairing(struct bt_conn *conn)
26332633
atomic_clear_bit(conn->flags, BT_CONN_BR_PAIRING);
26342634
atomic_clear_bit(conn->flags, BT_CONN_BR_PAIRING_INITIATOR);
26352635
atomic_clear_bit(conn->flags, BT_CONN_BR_LEGACY_SECURE);
2636+
atomic_clear_bit(conn->flags, BT_CONN_BR_GENERAL_BONDING);
26362637
}
26372638
#endif /* CONFIG_BT_CLASSIC */
26382639

subsys/bluetooth/host/conn_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ enum {
6060
BT_CONN_USER, /* user I/O when pairing */
6161
BT_CONN_BR_PAIRING, /* BR connection in pairing context */
6262
BT_CONN_BR_NOBOND, /* SSP no bond pairing tracker */
63+
BT_CONN_BR_GENERAL_BONDING, /* BR general bonding */
6364
BT_CONN_BR_PAIRING_INITIATOR, /* local host starts authentication */
6465
BT_CONN_CLEANUP, /* Disconnected, pending cleanup */
6566
BT_CONN_AUTO_INIT_PROCEDURES_DONE, /* Auto-initiated procedures have run */

0 commit comments

Comments
 (0)