Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp346256ybh; Thu, 12 Mar 2020 03:09:47 -0700 (PDT) X-Google-Smtp-Source: ADFU+vviab3IV5uLGcRRYHYZcUZ8IoVyRDDn5wmgQmCzzBDL8Nx7myQwJWtwwtj5IWRZrCqTDWQs X-Received: by 2002:aca:4b95:: with SMTP id y143mr1931697oia.36.1584007787409; Thu, 12 Mar 2020 03:09:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584007787; cv=none; d=google.com; s=arc-20160816; b=s8QAglmCcQvAMZMyXDLu9xnCilK7fUs76rSEN0KdpmusxTsIgZw79P2JQ9YAbDtF3M y8+YSKCrCh6umWuKQHUU/BQXjxkO8XX9j9htLywjtOh1PLNB7e4HfBmB5KoIW/w/jJ8Q O6mgr1j+OHxvGuWVRe0PcnqLkppz1VHxKxdBRqivu9q+2GHg0mpvPRrsxNu0jt0yFnKg uMjxOji52WVlJ3gOgAaYp/+gZmpuvVjUYdXdM9X3nq6Wx7jCgVbnydnlZ9jDxOIO/xRk Xv2FofiQQWtgJdJWkgbUmI0L0f0z93g09cfTa38TkQF2GlBqO0GwgIABCYNkeA2ET/cu hyIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=y8MluMm6f37XTe3y61evZ3K/RFwbeZ1K+tfhSmXkmKU=; b=fyvWNss/JLPPUCGGb90DAKeatt9xDWsNM24qiXrZhl5SWWJMt7RcwlxI1l2S6oxAop LvglAarFNw54Xzkv4qr3px9L93yWd0D3AlCniMQsxV3Dv+HjlOIzgabZKXu878mz6MpJ I9rVbBBrIod1wL9vHBqU8Ze0DWiNnpQruG8LmePT97KZzemxgojK8HWZHSjO1RNqswny IXDnTNQOoeoC9FAt2tvgst2LCkn0bXh5+D73d1nRt7ybW7ndO++kOSyfL2a95NyEhZMp zSATU15VX9oiD71tiwt12UzhFCplVH1p1AdVwHLOnCkl2PPVtYRYmTXz1HJW1Tq4rrIM Y9gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rm0JKmK3; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s15si2266301oie.175.2020.03.12.03.09.34; Thu, 12 Mar 2020 03:09:47 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rm0JKmK3; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726720AbgCLKHC (ORCPT + 99 others); Thu, 12 Mar 2020 06:07:02 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:37957 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726028AbgCLKHC (ORCPT ); Thu, 12 Mar 2020 06:07:02 -0400 Received: by mail-pf1-f194.google.com with SMTP id z5so3029445pfn.5 for ; Thu, 12 Mar 2020 03:07:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=y8MluMm6f37XTe3y61evZ3K/RFwbeZ1K+tfhSmXkmKU=; b=rm0JKmK3M9l2ShN5Rm8hIF7crWT2uzhqAbDpxufwiAgbh1CYUcivvSY/Nceab+uNgK qGWeDnK4GF2/aySFt4k+uJz3BeNhcC9kaMaL4XHUWGlrxwSZc9oF4lk0oPPBD+OMfMeO iFZbZJGPnosn7TiUdSNzabAt9sdCAAME/8NtzlxIiyZJXImW6nap7omgnQWlob0A9XTC qIiPxIr2kImMYbc5OSed3ldtMMiJWiU31DVNGR0canN9M8WiiuFBGbPA/LfVRjaHT0Rm VNIMOTDtNG7692PFC544J4JZpUO++CpYf8MPha7zkt9nuezRYUEbYrPYUp/xOcQUDKiu AJvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=y8MluMm6f37XTe3y61evZ3K/RFwbeZ1K+tfhSmXkmKU=; b=buBzRKicmAYpUz+HE78frQXN9HxxK8houDbSRCv+x8s1A9xK+luW+sMdx/PG3wNNY1 cRSDrW1uRE3OiiiPUq2o/6/SQneYzgURPYZizD2RpHoa4ew1i8VgXxbOukF5O2E0vxna F2aAYp0MfMa36/tNyRo2PUF2ycd6ug48rYi/k7W6iy5+S16NzwjGFhP6+USGW6lAmzne TKXJeRSJXZzkrz/o6v6BgFAH/3q+xwExTdER6UlmFv1Q352F+o58xZJG6xPaobHcfv2G QQfj7m/xKsEswr076apW8v825R800Qj+UOZd5QS7i7z7D6D8lbreC1NWFChikFnxctII dRRg== X-Gm-Message-State: ANhLgQ2UNCTPT0gR5vWSQ9wW9lzx0uQdkwUg6pmLEhHTUhz9ndStKTFX GUVCwuJPyKavgXeUI3Eg/yWDiNi3gDpupQ== X-Received: by 2002:aa7:9888:: with SMTP id r8mr5294374pfl.293.1584007620683; Thu, 12 Mar 2020 03:07:00 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.45]) by smtp.gmail.com with ESMTPSA id e9sm10578295pfl.179.2020.03.12.03.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2020 03:07:00 -0700 (PDT) From: Sathish Narsimman X-Google-Original-From: Sathish Narsimman To: linux-bluetooth@vger.kernel.org, nsathish41@gmail.com Cc: chethan.tumkur.narayan@intel.com, Sathish Narsimman , Joy Shermin Subject: [PATCH 3/7] Bluetooth: Update the Resolving list when Local IRK changed Date: Thu, 12 Mar 2020 15:37:50 +0530 Message-Id: <20200312100754.3445-4-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200312100754.3445-1-sathish.narasimman@intel.com> References: <20200312100754.3445-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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 Signed-off-by: Joy Shermin --- 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; + + /* 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; + + /* 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); + } + + hci_req_run(&req, NULL); +} + void hci_req_del_from_resolving_list(struct hci_dev *hdev, u8 addr_type, bdaddr_t *bdaddr) { struct hci_cp_le_del_from_resolv_list cp; -- 2.17.1