Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1004771ybg; Wed, 3 Jun 2020 21:07:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRO2j285KOnGlZWHJUXhEWRhKEj1/F1vsbOY83HT8DRSXhtxAhLdqrmomVlRPgnuSBcL33 X-Received: by 2002:a50:fd04:: with SMTP id i4mr2576774eds.43.1591243627095; Wed, 03 Jun 2020 21:07:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591243627; cv=none; d=google.com; s=arc-20160816; b=elDYTf2qwQiKHbJOgNBmECLxGzRXb/B0SvhZvMZBBT/GKOAbf+Tzzw4BcOX2SRBlDl i653/pFEbWmvlkEORG8uQQFCv4FQAW3puU0NxLcjfrXlhZmT6vt8cj14VsQ8KJ2YXVpT TZza9vbjhbk3/Os/FuQ2wbhkThCSZ+16mvmfVU5LVPMtrWmMIeW5l9+RnR5jEe2+J7/x LfsLnniCETN4QDjkD+60RVw6CQWUJxcTfQoXqYUysguuCp84QHMPRrJPrBmbi3ygJV7w 1CStmdWkEgfZozcuAOOR4DSjnZGgfpFhvKECBNUtUdARfL7hOzLXxtljRduwKa6jL3Kd Y5MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=lEpu+mPwhcgszfPdr3BI0hBtv81HWV0SrnyrSIu5zdA=; b=hFTxffIEzSdoaVL+zb1hnXHjjfTo5ssN5U1W0M9TWVugQXrI3CAwGJmHy5jB3730SM z45865CcGxwl0gbJFwvsq75CmX6qwl6x881hQmWCAfjB4tPCROq5BXeLtbnkHruTqJnr xs5Xa/6ogrZ3NcLxNj0I4p3EKD6M0ZYqAfAyYNKIe/Fk0SOl6bwG1uwlKHU2UglTxEmz 1plGDdukg/oGyK4IsKVcH7g/Oxj2tGn5TMg/nijyak1T39hlqDIs6XgJfLXybr9Ea/OC x5HuU9Ra92s9xuQPrz2TdQZ+13Oko0uj1dltWrrcoO2HL7uhBo4q3jjznGFuPlItmRb3 2hXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="b/gevncW"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id c9si897559edx.597.2020.06.03.21.06.42; Wed, 03 Jun 2020 21:07:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="b/gevncW"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 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 S1725936AbgFDEFl (ORCPT + 99 others); Thu, 4 Jun 2020 00:05:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725767AbgFDEFk (ORCPT ); Thu, 4 Jun 2020 00:05:40 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD9AFC03E96D for ; Wed, 3 Jun 2020 21:05:39 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id s10so2989128pgm.0 for ; Wed, 03 Jun 2020 21:05:39 -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; bh=lEpu+mPwhcgszfPdr3BI0hBtv81HWV0SrnyrSIu5zdA=; b=b/gevncWZ8d9XHeBwJ+q25V/F8s0bhdNZ6h9iyEdxG9J1dlFa2HCrim69A1lt9OGFp GiiBnRrJR2x/WqMW//Z/gMGZh0Z/QyNLMfdgYcuhueIR2kx8DNEuJ/JvGTU4wDJqqww1 2var/k0g/gObPgH0lk0qSCKbciHgELAXXWlyKahWMMgKUKsU5bxCh4ra4dHsQcMXocvW UQS1Pax+1qyL3+2BcciozopGVErGRIYyajxAOPi0CjIGMGO+ZOMLKSAeXwiokIJj5A6t TIfK1HM4oqG5SrmZAlPPCYZsd4YDXz95E03gNcWis6/gf3FT117laVXimUQFMZ9/lzuv 21Og== 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; bh=lEpu+mPwhcgszfPdr3BI0hBtv81HWV0SrnyrSIu5zdA=; b=jcW7eNVYtQWzLC+Qbk27xTqGdv9lQOk2TWNEwwKLWzq55i5TQvYC68MMR/ZoUnZCWQ sGoSM9bdBbvosLCwdcHFpQQFniUD6DGo947koYNsH2EyxOHHiiauXHTu+NhpgI7wQOAp 3jGCI9j1NGa+OVB/SeY0SUBNO3SIisNWH4NXUPuyzTazpHZ27eVotEz9nqOl/mOXgQmx RYR6SHKTNYPLjBK00spB3l6AL1r574r51cREugTyyMCWbJ5zMduw0+XYADA54IzUUbW1 0UU1ZzzUdHQ5ApVehFf+bFonGkr4kZOf9+rEMPwSnknl5XM+aFx5kxhy4j5memctZzCu mohQ== X-Gm-Message-State: AOAM530SPoOndKRS1MNBOIEIuwyWOPi1gyrV1KIg50/nLosJeTvXxUJ2 pt96z2bwGlDlWoklJQs48ZOhvrg+J1M= X-Received: by 2002:a63:78b:: with SMTP id 133mr2702944pgh.161.1591243538991; Wed, 03 Jun 2020 21:05:38 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([134.134.137.77]) by smtp.gmail.com with ESMTPSA id o18sm3265230pfu.138.2020.06.03.21.05.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 21:05:38 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v2 6/7] Bluetooth: Enable/Disable address resolution during le create conn Date: Thu, 4 Jun 2020 09:39:00 +0530 Message-Id: <20200604040900.13436-1-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org In this patch if le_create_conn process is started restrict to disable address resolution and same is disabled during le_enh_connection_complete Signed-off-by: Sathish Narasimman --- net/bluetooth/hci_conn.c | 6 ++++- net/bluetooth/hci_event.c | 4 ++++ net/bluetooth/hci_request.c | 46 ++++++++++++++++++++++++++++--------- net/bluetooth/hci_request.h | 3 ++- net/bluetooth/mgmt.c | 2 +- 5 files changed, 47 insertions(+), 14 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 307800fd18e6..bbd6d06bc900 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -1008,6 +1008,10 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, struct smp_irk *irk; struct hci_request req; int err; + /* This ensures that during disable le_scan address resolution + * will not be disabled if it is followed by le_create_conn + */ + bool rpa_le_conn = true; /* Let's make sure that le is enabled.*/ if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) { @@ -1109,7 +1113,7 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, * state. */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, rpa_le_conn); hci_dev_set_flag(hdev, HCI_LE_SCAN_INTERRUPTED); } diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 9c9c434844f2..1866de712bb2 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5225,6 +5225,10 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, le16_to_cpu(ev->interval), le16_to_cpu(ev->latency), le16_to_cpu(ev->supervision_timeout)); + + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) + hci_req_disable_address_resolution(hdev); } static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, struct sk_buff *skb) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 6e1036cc8b1e..8552a37976ec 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -429,7 +429,7 @@ static void __hci_update_background_scan(struct hci_request *req) if (!hci_dev_test_flag(hdev, HCI_LE_SCAN)) return; - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); BT_DBG("%s stopping background scanning", hdev->name); } else { @@ -448,7 +448,7 @@ static void __hci_update_background_scan(struct hci_request *req) * don't miss any advertising (due to duplicates filter). */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); hci_req_add_le_passive_scan(req); @@ -653,7 +653,7 @@ void __hci_req_update_eir(struct hci_request *req) hci_req_add(req, HCI_OP_WRITE_EIR, sizeof(cp), &cp); } -void hci_req_add_le_scan_disable(struct hci_request *req) +void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn) { struct hci_dev *hdev = req->hdev; @@ -677,8 +677,9 @@ void hci_req_add_le_scan_disable(struct hci_request *req) hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); } + /* Disable address resolution */ if (use_ll_privacy(hdev) && - hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn) { __u8 enable = 0x00; hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); } @@ -1054,7 +1055,7 @@ static void hci_req_set_event_filter(struct hci_request *req) static void hci_req_config_le_suspend_scan(struct hci_request *req) { /* Can't change params without disabling first */ - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); /* Configure params and enable scanning */ hci_req_add_le_passive_scan(req); @@ -1121,7 +1122,7 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next) hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &page_scan); /* Disable LE passive scan */ - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, false); /* Mark task needing completion */ set_bit(SUSPEND_SCAN_DISABLE, hdev->suspend_tasks); @@ -1682,6 +1683,29 @@ int hci_req_update_adv_data(struct hci_dev *hdev, u8 instance) return hci_req_run(&req, NULL); } +static void enable_addr_resolution_complete(struct hci_dev *hdev, u8 status, + u16 opcode) +{ + BT_DBG("%s status %u", hdev->name, status); +} + +void hci_req_disable_address_resolution(struct hci_dev *hdev) +{ + struct hci_request req; + __u8 enable = 0x00; + + if (!use_ll_privacy(hdev) && + !hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) + return; + + hci_req_init(&req, hdev); + + hci_req_add(&req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + + hci_req_run(&req, enable_addr_resolution_complete); +} + static void adv_enable_complete(struct hci_dev *hdev, u8 status, u16 opcode) { BT_DBG("%s status %u", hdev->name, status); @@ -2608,7 +2632,7 @@ static void bg_scan_update(struct work_struct *work) static int le_scan_disable(struct hci_request *req, unsigned long opt) { - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); return 0; } @@ -2706,7 +2730,7 @@ static int le_scan_restart(struct hci_request *req, unsigned long opt) if (!hci_dev_test_flag(hdev, HCI_LE_SCAN)) return 0; - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); if (use_ext_scan(hdev)) { struct hci_cp_le_set_ext_scan_enable ext_enable_cp; @@ -2797,7 +2821,7 @@ static int active_scan(struct hci_request *req, unsigned long opt) * discovery scanning parameters. */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); /* All active scans will be done with either a resolvable private * address (when privacy feature has been enabled) or non-resolvable @@ -2911,14 +2935,14 @@ bool hci_req_stop_discovery(struct hci_request *req) if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { cancel_delayed_work(&hdev->le_scan_disable); - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); } ret = true; } else { /* Passive scanning */ if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { - hci_req_add_le_scan_disable(req); + hci_req_add_le_scan_disable(req, false); ret = true; } } diff --git a/net/bluetooth/hci_request.h b/net/bluetooth/hci_request.h index 0e81614d235e..12bea10e7d70 100644 --- a/net/bluetooth/hci_request.h +++ b/net/bluetooth/hci_request.h @@ -65,11 +65,12 @@ void __hci_req_write_fast_connectable(struct hci_request *req, bool enable); void __hci_req_update_name(struct hci_request *req); void __hci_req_update_eir(struct hci_request *req); -void hci_req_add_le_scan_disable(struct hci_request *req); +void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn); void hci_req_add_le_passive_scan(struct hci_request *req); void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next); +void hci_req_disable_address_resolution(struct hci_dev *hdev); void hci_req_reenable_advertising(struct hci_dev *hdev); void __hci_req_enable_advertising(struct hci_request *req); void __hci_req_disable_advertising(struct hci_request *req); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 9e8a3cccc6ca..97eb4f3a160b 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -4848,7 +4848,7 @@ static int set_scan_params(struct sock *sk, struct hci_dev *hdev, hci_req_init(&req, hdev); - hci_req_add_le_scan_disable(&req); + hci_req_add_le_scan_disable(&req, false); hci_req_add_le_passive_scan(&req); hci_req_run(&req, NULL); -- 2.17.1