Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp664086ybg; Wed, 3 Jun 2020 10:17:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5bzuaL2Ri4UdDehCm2pEGOSVz3AYSQ+pafcOfxN1jiiaxze14VoQsMzCUwaaJZSf5NjYx X-Received: by 2002:a17:906:3013:: with SMTP id 19mr276921ejz.303.1591204676538; Wed, 03 Jun 2020 10:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591204676; cv=none; d=google.com; s=arc-20160816; b=hjgchCM+5EDwr/16S4aP3w3mThbD86Jz+P49vf5zErafDjLUmi5vCylwL2eJp0X9d5 9iJcK45jfG3PO5xg4nxNWA4ag1ffhrth+/u1LTjCCluF6T40k6jM74sfjEWyUhgYeFKB Wswme1rl22ZWk2uqnJtjr9ExwSbB4G7DjhVHBqywsRjomMXeAhBhFNJi0KCFKitu/63A jxRPMQRpX//cPZb+/huLBva/xU2adGJFnGq02gnhq7p2TBhDquHKzX5NQ7IB7XkSvfVZ 9Vsoo1F/HhaabFCR+8Ht9nXmsLIJnqXQh6fYm6nS47vqQGP/5ZHnzNXhVCDycPQgM9hR 8x7Q== 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=bpSheGMCVgME0idzklrJ0le5PrZYkTpunntgt2JqXb8=; b=Zv81OjvzTTcrQ4yWyVD7B0FDfR8XcZvKzp912iWJ2Ne33BtDjwFNyaGICcbOkub5Wx 8Vcd1iRhoT6Wqk4LAiadEaxNzwp3wExwTshihHrNVSTnjkaiOwF3w8hTmM+PC6oqbBdL RL/saVpifp8r97A114i4JGilzrz65/ZXNW6JCK9MtkSoRD/dPfCvice3MQGbMF7ONVYS XsFZiKwOhyzTROxAQCaCAbx/+AreptHmEnXUFo/ZaDElZ1PDSNj04vN0tbFnXE3LIzkD bCj/AGgqYdD80XDX9tX4mo3YKoOUhoRY9TxBe4pO0xoKzKHZQKEwJ2ZJzeJwAkKv04Ll 0CMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Cxq6Vw7m; 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 o11si91179ejc.714.2020.06.03.10.17.32; Wed, 03 Jun 2020 10:17:56 -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=Cxq6Vw7m; 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 S1726219AbgFCROb (ORCPT + 99 others); Wed, 3 Jun 2020 13:14:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725961AbgFCROb (ORCPT ); Wed, 3 Jun 2020 13:14:31 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10E27C08C5C0 for ; Wed, 3 Jun 2020 10:14:31 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id 64so2016552pfg.8 for ; Wed, 03 Jun 2020 10:14:31 -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=bpSheGMCVgME0idzklrJ0le5PrZYkTpunntgt2JqXb8=; b=Cxq6Vw7mx18O6nNaFVmMnAxUq4MlVQtx/fS6enoGId8/Rs0rjM4G4Gvv2AJS9KHxwm 9A6theXZl0V9hHLoHxkEKczZaSGRuv6vrXajdU6/YMvKAaC6NU2qRNtroF2u8FG/1H3R oIoay75lce/T5cFcoGAy9SrinbuqQnCytXavWDdxjzNCxe/KRtchecfkdVLl/bUypyOm 6Z2pEUN3QszFGoTYVSWJ3nR1QE4SN3AuyejIKYDHYHAX4nVBhKbWq+m+d2Yb7Ewe1x72 DJS5S+cqLOxfMnslPB+aYn4tqxMiWyeDNw8LQJ5oN/RePfkg12CGWBywnVIc835R2fRE TBBw== 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=bpSheGMCVgME0idzklrJ0le5PrZYkTpunntgt2JqXb8=; b=IeYaMhgV7qPfEt/q7nK6n6zDJufaykbFwb2u8ROFM4Y5dSfB5lXQEmvjeF3LaKZ+Nh P3Kf5giWuw3tm6pvPkTJUxH1Ifu+yhx7DtUXwcUBrZl/f68P/tbc/nYh3TDUy7U7ymqn Ln1X5VPZWO6OPbaXBNjHKqsZ7E1dF7ZPws+mg/1HAnvaeyXZqDZEckmGXOHfi4Z0u1/a 55scflrHZVKNmyszL/2yqD5lW18MVbGAWNkksKD248Q/126OinEi3eDKskpRyIHYkrC9 T1o8/BI/LibK0DL6vHPzlSIFDM3VTkvOUyBO2TU7RD94ncE3lSy/PfHwTgAdWlWjh0XA KKVA== X-Gm-Message-State: AOAM531AEXb6C08crWTvkl/lZJWoznJCN2W9Dsay2nJrfAIGsuj2f0EH vjJpIZAD0/OhJcMfAAt2boaHzwfLlkk= X-Received: by 2002:a17:90b:792:: with SMTP id l18mr914031pjz.24.1591204470274; Wed, 03 Jun 2020 10:14:30 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.45]) by smtp.gmail.com with ESMTPSA id x190sm2016770pgb.79.2020.06.03.10.14.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 10:14:29 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH 6/7] Bluetooth: Enable/Disable address resolution during le create conn Date: Wed, 3 Jun 2020 22:47:12 +0530 Message-Id: <20200603171713.9882-7-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200603171713.9882-1-sathish.narasimman@intel.com> References: <20200603171713.9882-1-sathish.narasimman@intel.com> 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