Add and delete devices in the resolving list
Subsystems (2)
RFC v2 2/3 Add and delete devices in the resolving list
Devices are added to the resolving list when IRKs are loaded through mgmt API or when a peer IRK is received through the SMP pairing procedure.A device is deleted from the resolving list when it is upaired through mgmt API.
Copy of resolving list maintained by kernel is a sorted list. When a connection or pairing is done for a device it is pushed to the tail of the list. When a device is to to be deleted to make space for new one, the LRU entry at the head is removed.
Signed-off-by Shermin Joy <[email protected]>
--- include/net/bluetooth/hci_core.h | 3 + net/bluetooth/hci_event.c | 5 ++ net/bluetooth/hci_request.c | 166 +++++++++++++++++++++++++++++++++++++++ net/bluetooth/hci_request.h | 4 + net/bluetooth/mgmt.c | 10 +++ net/bluetooth/smp.c | 4 + 6 files changed, 192 insertions(+)
include/net/bluetooth/hci_core.h +3 -0
@@ -1547,6 +1547,9 @@ void hci_copy_identity_address(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *bdaddr_type);void hci_clear_resolving_list (struct hci_dev *hdev); +int hci_req_update_resolving_list (struct hci_dev *hdev,u8 addr_type, +bdaddr_t *bdaddr,u8 irk[16 ]); +void hci_load_resolving_list (struct hci_dev *hdev);#define SCO_AIRMODE_MASK 0x0003#define SCO_AIRMODE_CVSD 0x0000
net/bluetooth/hci_event.c +5 -0
@@ -2281,6 +2281,11 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) }else if (ev->link_type !=ACL_LINK )hci_connect_cfm (conn, ev->status); +/* If the device IRK is known, it has to be added +* to the resolving list. +*/ +hci_req_check_and_update_resolving_list (hdev, conn->type, &conn->dst); + unlock:hci_dev_unlock (hdev);
net/bluetooth/hci_request.c +166 -0
172 lines not on this page · raw message
net/bluetooth/hci_request.h +4 -0
@@ -73,6 +73,10 @@ int hci_update_resolving_list(struct hci_dev *hdev, u8 addr_type,int hci_delete_from_resolving_list (struct hci_dev *hdev,u8 addr_type,bdaddr_t *bdaddr);void hci_clear_resolving_list (struct hci_dev *hdev); +void hci_req_del_from_resolving_list (struct hci_dev *hdev,u8 addr_type, +bdaddr_t *bdaddr); +void hci_req_check_and_update_resolving_list (struct hci_dev *hdev, +u8 addr_type,bdaddr_t *bdaddr);void hci_req_reenable_advertising (struct hci_dev *hdev);void __hci_req_enable_advertising (struct hci_request *req);
net/bluetooth/mgmt.c +10 -0
@@ -2300,6 +2300,8 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data,hci_remove_irk (hdev, &cp->addr.bdaddr, addr_type); +hci_req_del_from_resolving_list (hdev, addr_type, &cp->addr.bdaddr); + err =hci_remove_ltk (hdev, &cp->addr.bdaddr, addr_type);if (err <0 ) { err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_UNPAIR_DEVICE,
@@ -4700,6 +4702,9 @@ static int load_irks(struct sock *sk, struct hci_dev *hdev, void *cp_data, BDADDR_ANY); } +/* Load the resolving list with entries from IRK list.*/ +hci_load_resolving_list (hdev); +hci_dev_set_flag (hdev,HCI_RPA_RESOLVING ); err =mgmt_cmd_complete (sk, hdev->id,MGMT_OP_LOAD_IRKS ,0 ,NULL ,0 );
@@ -6652,6 +6657,11 @@ void mgmt_power_on(struct hci_dev *hdev, int err)if (match.sk)sock_put (match.sk); +/* If load _irk was called when controller was powered down, +* then the resolving list has to be updated now. +*/ +hci_load_resolving_list (hdev); +hci_dev_unlock (hdev); }
net/bluetooth/smp.c +4 -0
@@ -2563,6 +2563,10 @@ static int smp_cmd_ident_addr_info(struct l2cap_conn *conn, smp->remote_irk =hci_add_irk (conn->hcon->hdev, &smp->id_addr, smp->id_addr_type, smp->irk, &rpa); +/* Add the device to the resolving list.*/ +hci_req_update_resolving_list (conn->hcon->hdev, smp->id_addr_type, + &smp->id_addr, smp->irk); + distribute:if (!(smp->remote_key_dist &KEY_DIST_MASK ))smp_distribute_keys (smp);
Signature · 1 line
1.9.1