Bluetooth: Fix LE SMP channel source address and source address type
Subsystems (2)
Marcel Holtmann
maintainerPATCH 1/3 Bluetooth: Fix LE SMP channel source address and source address type
The source address and source address type of the LE SMP channel can either be the public address of the controller or the static random address configured by the host.
Right now the public address is used for the LE SMP channel and obviously that is not correct if the controller operates with the configured static random address.
--- net/bluetooth/smp.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)
net/bluetooth/smp.c +23 -4
@@ -2950,11 +2950,30 @@ create_chan:l2cap_chan_set_defaults (chan); -bacpy (&chan->src, &hdev->bdaddr); -if (cid ==L2CAP_CID_SMP ) - chan->src_type =BDADDR_LE_PUBLIC ; -else +if (cid ==L2CAP_CID_SMP ) { +/* If usage of static address is forced or if the devices +* does not have a public address, then listen on the static +* address. +* +* In case BR/EDR has been disabled on a dual-mode controller +* and a static address has been configued, then listen on +* the static address instead. +*/ +if (test_bit (HCI_FORCE_STATIC_ADDR , &hdev->dbg_flags) || + !bacmp (&hdev->bdaddr,BDADDR_ANY ) || + (!test_bit (HCI_BREDR_ENABLED , &hdev->dev_flags) && +bacmp (&hdev->static_addr,BDADDR_ANY ))) { +bacpy (&chan->src, &hdev->static_addr); + chan->src_type =BDADDR_LE_RANDOM ; + }else { +bacpy (&chan->src, &hdev->bdaddr); + chan->src_type =BDADDR_LE_PUBLIC ; + } + }else { +bacpy (&chan->src, &hdev->bdaddr); chan->src_type =BDADDR_BREDR ; + } + chan->state =BT_LISTEN ; chan->mode =L2CAP_MODE_BASIC ; chan->imtu =L2CAP_DEFAULT_MTU ;
Signature · 1 line
2.1.0
Hi Marcel,
Quoted 9 lines · Marcel Holtmann
net/bluetooth/smp.c +9
-0+if (cid ==L2CAP_CID_SMP ) { +/* If usage of static address is forced or if the devices +* does not have a public address, then listen on the static +* address. +* +* In case BR/EDR has been disabled on a dual-mode controller +* and a static address has been configued, then listen on +* the static address instead. +*/
net/bluetooth/smp.c create_chan: · line 2971
Quoted 10 lines
net/bluetooth/smp.c +10
-0+if (test_bit (HCI_FORCE_STATIC_ADDR , &hdev->dbg_flags) || + !bacmp (&hdev->bdaddr,BDADDR_ANY ) || + (!test_bit (HCI_BREDR_ENABLED , &hdev->dev_flags) && +bacmp (&hdev->static_addr,BDADDR_ANY ))) { +bacpy (&chan->src, &hdev->static_addr); + chan->src_type =BDADDR_LE_RANDOM ; + }else { +bacpy (&chan->src, &hdev->bdaddr); + chan->src_type =BDADDR_LE_PUBLIC ; + }
I think this can be simply substituted with:
hci_copy_identity_address(hdev, &chan->src, &chan->src_type);
Johan
Hi,
Quoted 23 lines · Johan Hedberg
Quoted 9 lines · Marcel Holtmann
net/bluetooth/smp.c +9
-0+if (cid ==L2CAP_CID_SMP ) { +/* If usage of static address is forced or if the devices +* does not have a public address, then listen on the static +* address. +* +* In case BR/EDR has been disabled on a dual-mode controller +* and a static address has been configued, then listen on +* the static address instead. +*/ net/bluetooth/smp.c create_chan: · line 2971
Quoted 10 lines
net/bluetooth/smp.c +10
-0+if (test_bit (HCI_FORCE_STATIC_ADDR , &hdev->dbg_flags) || + !bacmp (&hdev->bdaddr,BDADDR_ANY ) || + (!test_bit (HCI_BREDR_ENABLED , &hdev->dev_flags) && +bacmp (&hdev->static_addr,BDADDR_ANY ))) { +bacpy (&chan->src, &hdev->static_addr); + chan->src_type =BDADDR_LE_RANDOM ; + }else { +bacpy (&chan->src, &hdev->bdaddr); + chan->src_type =BDADDR_LE_PUBLIC ; + }I think this can be simply substituted with:
Quoted 1 line
hci_copy_identity_address(hdev, &chan->src, &chan->src_type);
Actually I got this wrong. The l2cap_chan uses a different address types than the hci_dev uses (e.g. BDADDR_LE_RANDOM vs ADDR_LE_DEV_RANDOM), so the patch is correct. However, we might still want to later simplify this using a helper function or macro.
Johan
Hi Marcel,
Quoted 4 lines · Marcel Holtmann
The source address and source address type of the LE SMP channel can either be the public address of the controller or the static random address configured by the host.
Quoted 8 lines
Right now the public address is used for the LE SMP channel and obviously that is not correct if the controller operates with the configured static random address.
Signed-off-by Marcel Holtmann <[email protected]>--- net/bluetooth/smp.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)
All three patches in this set have been applied to bluetooth-next. Thanks.
Johan