Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp505530ybh; Wed, 18 Mar 2020 04:07:07 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtjmMYjCCAnIkOZeJyb8hGUNI6U2mtnoATIdwlkO/oulPnX3/zbrCvNJNfJejDlX2fvwmcF X-Received: by 2002:a05:6830:13c7:: with SMTP id e7mr3284400otq.5.1584529626933; Wed, 18 Mar 2020 04:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584529626; cv=none; d=google.com; s=arc-20160816; b=HQugY7Q4QoYo4dPBcVYrkjsilvAbIGlTDwyCD3q3pyrtuEjho9+rtN8ueyKUe/kYXH KHk1fmP3jNqffIXef8+EPS2OY+rSvAfovhkXOfccIGlEIJRzkWmzEBDSZvO5BXu7oEBM z1H7G99C0USVRZkLtzhS2wIJWbExj286CWIIjmdiCPDvlrHF2HBbzEoUqesgvA1mtmN0 TIKdk/13XDmCjLoMrP5dnX6R/yPj/7dM4nu6KSB620zFMpQbrB3/ZtRX3H/a5I7alTrc vAat5s0MW+bfGpgNPTLa7ol8SvkclbZvEbcygo3IvCekoA57ZlX+iHJnqf/qEx1rgx3M uqrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=oV4Al9nDTovHe2WEWd6pkH4hEBjLAPzDvkuN5aZr+nY=; b=uX0Ngxpuvj4ehyqhbB3TTRwhvAIJevWaAWoh+twg9bv2FRMPZ67WRpRFe5exw+ygkf y/IH27AIEVC3THhT9pla42KOtjRMnhG7hHhZvpp4alVJXMesNUKFZii9zaiRJqKAS3wa her4nYi3CT67BR/PJTVFF+fr0UQ30vO62FlY/7Cz6CWwFqkQQipbO1W+Lw0hEsTDBlRL 7lNmEBK0Xel0R9kBIZFcK5AbzMy8It5LRtmZYQ9lMOqtYbtFkSePm1Ja1Qh3f7+2o/HE 6SBfNfFQpz2DvGkfOG6kwg7mGmXvYL1v8j1bS5uF7g+41OD6P2kraPMRx3blgP+Ru1wD LCFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c21si3187273oto.137.2020.03.18.04.06.54; Wed, 18 Mar 2020 04:07:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726713AbgCRLGu convert rfc822-to-8bit (ORCPT + 99 others); Wed, 18 Mar 2020 07:06:50 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:42883 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbgCRLGu (ORCPT ); Wed, 18 Mar 2020 07:06:50 -0400 Received: from marcel-macbook.fritz.box (p4FEFC5A7.dip0.t-ipconnect.de [79.239.197.167]) by mail.holtmann.org (Postfix) with ESMTPSA id 651DBCECF2; Wed, 18 Mar 2020 12:16:19 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.60.0.2.5\)) Subject: Re: [PATCH 4/7] Bluetooth: LL_PRIVACY re-load resolving list From: Marcel Holtmann In-Reply-To: <20200312100754.3445-5-sathish.narasimman@intel.com> Date: Wed, 18 Mar 2020 12:06:48 +0100 Cc: linux-bluetooth , chethan.tumkur.narayan@intel.com, Sathish Narsimman , Joy Shermin Content-Transfer-Encoding: 8BIT Message-Id: <7F7F5693-AF9F-423C-9439-FD394CC4A8B1@holtmann.org> References: <20200312100754.3445-1-sathish.narasimman@intel.com> <20200312100754.3445-5-sathish.narasimman@intel.com> To: Sathish Narsimman X-Mailer: Apple Mail (2.3608.60.0.2.5) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Sathish, > The patch is used to load the entries in the local IRK to the > Bluetooth LE controller resolving list. > > Signed-off-by: Sathish Narsimman > Signed-off-by: Joy Shermin > --- > include/net/bluetooth/hci_core.h | 1 + > net/bluetooth/hci_request.c | 29 +++++++++++++++++++++++++++++ > 2 files changed, 30 insertions(+) > > diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h > index 43d31a9339a6..46d2d3e10c97 100644 > --- a/include/net/bluetooth/hci_core.h > +++ b/include/net/bluetooth/hci_core.h > @@ -1659,6 +1659,7 @@ 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_load_resolving_list(struct hci_dev *hdev); > 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, > diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c > index 9ffb62178d24..e17db3103a3d 100644 > --- a/net/bluetooth/hci_request.c > +++ b/net/bluetooth/hci_request.c > @@ -1015,6 +1015,35 @@ void hci_req_update_resolving_list_local_irk(struct hci_dev *hdev) > hci_req_run(&req, NULL); > } > > +void hci_load_resolving_list (struct hci_dev *hdev) > +{ > + struct smp_irk *irk; > + u8 num = 0; > + > + /* Nothing to be done if LL privacy is not supported */ > + if ( !(hdev->le_features[0] & HCI_LE_LL_PRIVACY) ) > + return; > + > + 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; > + > + /* Load the first le_resolving_list_size entries from IRK > + * list in to resolving list. > + */ > + rcu_read_lock(); > + list_for_each_entry_rcu(irk, &hdev->identity_resolving_keys, list) { > + if (num++ >= hdev->le_resolv_list_size) > + return; > + > + hci_req_update_resolving_list(hdev, irk->addr_type, &irk->bdaddr, irk->val); > + } I comparison to the le_whitelist, the le_resolv_list_size does not have to match the actual available memory of the controller. It is just some guesstimate. I think we have to design this in a way that we add the IRK anyway and handle the error case gracefully. I am also confused why we are not actually checking here if an entry is already present and just loading the whole list. I have seen code being duplicated in at least 3 places now. Regards Marcel