Re: [PATCH 3/7] Bluetooth: Update the Resolving list when Local IRK changed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Sathish,

> Whenever the Local IRK changes. i.e privacy mode is toggled
> this patch helps to change the IRK list in the bluetooth
> controller
> 
> Signed-off-by: Sathish Narsimman <sathish.narasimman@xxxxxxxxx>
> Signed-off-by: Joy Shermin <shermin.joy@xxxxxxxxx>
> ---
> include/net/bluetooth/hci_core.h |  2 ++
> net/bluetooth/hci_request.c      | 50 ++++++++++++++++++++++++++++++++
> 2 files changed, 52 insertions(+)
> 
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index e5e09d530ce7..43d31a9339a6 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -1659,6 +1659,8 @@ void hci_copy_identity_address(struct hci_dev *hdev, bdaddr_t *bdaddr,
> 			       u8 *bdaddr_type);
> int hci_req_update_resolving_list(struct hci_dev *hdev,  u8 addr_type,
> 				  bdaddr_t *bdaddr, u8 irk[16]);
> +void hci_req_update_resolving_list_local_irk(struct hci_dev *hdev);
> +
> void hci_req_del_from_resolving_list(struct hci_dev *hdev, u8 addr_type,
> 				     bdaddr_t *bdaddr);
> 
> diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
> index 88225a9ca1f8..9ffb62178d24 100644
> --- a/net/bluetooth/hci_request.c
> +++ b/net/bluetooth/hci_request.c
> @@ -965,6 +965,56 @@ int hci_req_update_resolving_list(struct hci_dev *hdev, u8 type, bdaddr_t *bdadd
> 	return 0;
> }
> 
> +void hci_req_update_resolving_list_local_irk(struct hci_dev *hdev)
> +{
> +	struct bdaddr_list_with_irk *irk;
> +	struct hci_request req;
> +
> +	BT_DBG("");
> +
> +	/* Nothing to be done if LL privacy is not supported. */
> +	if (!(hdev->le_features[0] & HCI_LE_LL_PRIVACY))
> +		return;
> +
> +	/* If resolving list is empty, nothing is to be done.*/
> +	if (list_empty(&hdev->le_resolv_list))
> +		return;

actually the le_resolv_list represents the current list programmed into the controller.

> +
> +	/* Resolving List cannot be updated if address resolution
> +	 * in the controller is enabled and advertisement or scanning
> +	 * or create connection command is ongoing.
> +	 */
> +	if ( !hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) &&
> +	    ( hci_dev_test_flag(hdev, HCI_LE_ADV) ||
> +	      hci_dev_test_flag(hdev, HCI_LE_SCAN) ||
> +	      hci_lookup_le_connect(hdev) ) )
> +		return;

Coding style needs to be correct.

> +
> +	/* If resolving list is not empty, then clear the resolving list
> +	 * and add back each entry with updated local IRK.
> +	 */
> +	hci_req_init(&req, hdev);
> +
> +	list_for_each_entry(irk, &hdev->le_resolv_list, list) {
> +		struct hci_cp_le_add_to_resolv_list cp;
> +		struct hci_cp_le_del_from_resolv_list cp1;
> +
> +		cp1.bdaddr_type = irk->bdaddr_type;
> +		bacpy(&cp1.bdaddr, &irk->bdaddr);
> +		hci_req_add(&req, HCI_OP_LE_DEL_FROM_RESOLV_LIST,
> +			    sizeof(cp1), &cp1);
> +
> +		cp.bdaddr_type = irk->bdaddr_type;
> +		bacpy(&cp.bdaddr, &irk->bdaddr);
> +		memcpy(cp.peer_irk, irk->peer_irk, 16);
> +		memcpy(cp.local_irk, hdev->irk, 16);
> +		hci_req_add(&req, HCI_OP_LE_ADD_TO_RESOLV_LIST,
> +			    sizeof(cp), &cp);
> +	}

Can we please do this the smart way, no need to remove and entry to just add it back later.

Regards

Marcel




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux