From patchwork Wed Jun 3 17:17:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11586035 X-Patchwork-Delegate: marcel@holtmann.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 328D81392 for ; Wed, 3 Jun 2020 17:14:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1AC4420772 for ; Wed, 3 Jun 2020 17:14:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AqIZdmER" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726182AbgFCRON (ORCPT ); Wed, 3 Jun 2020 13:14:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726046AbgFCRON (ORCPT ); Wed, 3 Jun 2020 13:14:13 -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 7B8B0C08C5C0 for ; Wed, 3 Jun 2020 10:14:13 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id s10so2220814pgm.0 for ; Wed, 03 Jun 2020 10:14:13 -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=CuTW1YSo6SbIPQ+NugG8xNnabM9kKD5flh82Xdj9G2g=; b=AqIZdmERFi5Y3RTNmnlfaTFzw+mHC3sV9IZZQmeVtkfc7JAOWEyqTcnvfqTZskloHH ZFQ2B9p9hBZMQpah5RhFoOhMVv5JuWjsM//UUoYfEpW6SrOfMZgddyAtauSctTiAxK9W y5zT3y7hi97tMiS04YCJNXhAREml1hsWx0euIi7jAG2HWO33i30d/Ouy1TtSctrHHjkn ZwasvGy8ubqD+KFNusBjQPdTQxjBidoQWJzHL57ZuJmY1N6jdVW9YjGpy1jbtk8EsrjS RH3L47w9b56NjOlTY5bTUioQfBETcFjX6GFHlwlio1215m+Y2KJ1JL4dzc4TTvVvmclC 2gmQ== 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=CuTW1YSo6SbIPQ+NugG8xNnabM9kKD5flh82Xdj9G2g=; b=eRAdYvJEbcixQGIgxHP40UvBd9JFxAeAUQBJRVaSC2pHGtzdpiZZWNiZV7+j1hSiCx dncgqmVdNxPoR8mR4/YdU6MIJbLwmly9t00urWZ8q2a88U9t7PhYn66PbGB+J72pMA52 3eE893cVBWGuyeoQaKNWGNWBgkiNwMd74ga/e7dVUTXf0kl8eh55eCqKCXlc5h5Q/bJ9 L8YDBAtz/boPLHGtNPGcsRFHFpoAHdQnXbzGv7uwCMFpCwQvY1YEPoy3Y2xMia08iQMM nWLIYgPbKqOL9frxyFparxExg+MW0nNWLA+++4SAjzL6h6cfFbJ2qhjf/qqlw7CE086+ HPtg== X-Gm-Message-State: AOAM533Oz7W8zOX8lIDXgmU9ssLAPkmQODwZEFN69y/4x7acVdcXt6Wj OZvzE7BqF/iEFlZlEIKbJy3b0RsbzoQ= X-Google-Smtp-Source: ABdhPJwjJ10+cQMD+6dnq0Dknw1/gJZYKR1on9zzSONDk5w34DQFAdpbYlxP4k6fMHiIgh2WhbFP4g== X-Received: by 2002:a17:90b:252:: with SMTP id fz18mr866840pjb.96.1591204452769; Wed, 03 Jun 2020 10:14:12 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 10:14:12 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v2 1/7] Bluetooth: Translate additional address type correctly Date: Wed, 3 Jun 2020 22:47:07 +0530 Message-Id: <20200603171713.9882-2-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 From: Marcel Holtmann When using controller based address resolution, then the new address types 0x02 and 0x03 are used. These types need to be converted back into either public address or random address types. Signed-off-by: Marcel Holtmann Signed-off-by: Sathish Narsimman --- include/net/bluetooth/hci.h | 6 ++++-- net/bluetooth/hci_core.c | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 16ab6ce87883..1165dfea56a9 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -2268,8 +2268,10 @@ struct hci_ev_le_conn_complete { #define LE_EXT_ADV_SCAN_RSP 0x0008 #define LE_EXT_ADV_LEGACY_PDU 0x0010 -#define ADDR_LE_DEV_PUBLIC 0x00 -#define ADDR_LE_DEV_RANDOM 0x01 +#define ADDR_LE_DEV_PUBLIC 0x00 +#define ADDR_LE_DEV_RANDOM 0x01 +#define ADDR_LE_DEV_PUBLIC_RESOLVED 0x02 +#define ADDR_LE_DEV_RANDOM_RESOLVED 0x03 #define HCI_EV_LE_ADVERTISING_REPORT 0x02 struct hci_ev_le_advertising_info { diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index dbe2d79f233f..f4ceda1f1454 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3145,6 +3145,15 @@ struct hci_conn_params *hci_pend_le_action_lookup(struct list_head *list, { struct hci_conn_params *param; + switch (addr_type) { + case ADDR_LE_DEV_PUBLIC_RESOLVED: + addr_type = ADDR_LE_DEV_PUBLIC; + break; + case ADDR_LE_DEV_RANDOM_RESOLVED: + addr_type = ADDR_LE_DEV_RANDOM; + break; + } + list_for_each_entry(param, list, action) { if (bacmp(¶m->addr, addr) == 0 && param->addr_type == addr_type) From patchwork Wed Jun 3 17:17:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11586037 X-Patchwork-Delegate: marcel@holtmann.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D0BE1392 for ; Wed, 3 Jun 2020 17:14:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 15BC020772 for ; Wed, 3 Jun 2020 17:14:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V7px6/FN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726183AbgFCROT (ORCPT ); Wed, 3 Jun 2020 13:14:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725961AbgFCROT (ORCPT ); Wed, 3 Jun 2020 13:14:19 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16686C08C5C0 for ; Wed, 3 Jun 2020 10:14:18 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id f3so2005003pfd.11 for ; Wed, 03 Jun 2020 10:14:18 -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=agt0nawk/JvvEuRuffYxBaaD0CzjiES3RArXV+8d3mU=; b=V7px6/FNhO00cLPUOgAdw5UXg+zCciP/pV6q4yoDz1qr1m21NrrMD6Xhdp0fn/FZm0 LPl7yqCaRG/9ulr5j6exR06g4gzaaWL9b5IKPKWj2roqU4lXKn9oqsxmwBEWqDFPsDyU TqhTtktaDLorvKNxtHwNhuXi+uMv6zcfC3eST9NHcuC4RsWS6QgkpVmAM9AzjznMm+IN wwNYVYdfIrbBvQksDwFa80lNkuPKr9kW2WSUb2+7tGELFvy2QaYXaN5yq1/qbsJQhi55 vljIj7a9NhdRmNKnJOIlXoeyg8njN6C2/jt8e9aReq5Hitasjic8qcUD+dcB4UqRIrT6 gGzQ== 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=agt0nawk/JvvEuRuffYxBaaD0CzjiES3RArXV+8d3mU=; b=R4hbmS1YvfP0cJeS1gaHZ1jX1Qg422PxX0r6nQ13s8ueYhpIXIUk3PtUqtHfiveNk9 YQc2Fpi0EiDeIxWG9zysxb+wZNnB7qTaVRnz1tnuI3+nMbWVIKHSkH7wtJWVwPjtXAvy buHdRpkzQftJcQgmVIiT+oKemq/J4VliyPUFOTOTsrlnby4dCVOcXtidfOxKs45nenMR jOZIgeTKDtiMON6o0CV3/8oHO5yGW5qDKWQyATz6eJYPTEhIh5C7tbyUyvauNt7KU+TF fOxm2Dm9gklGyiW+eHfzJc/S3GoWCLRUYG5vvouDYyim6zx+XGdvepQHIJ+3CMCKY6Z4 5xYQ== X-Gm-Message-State: AOAM531WPIB7PhO0QznybwvU2nHYKVNnKQMh1aNaC7M+S4cuNWsLUPwZ Bh1muSt74QgekeJ7budrfoYHNFtDA0c= X-Google-Smtp-Source: ABdhPJw3wbt5UAEkgDBbZdvYegMlNWEbocRkDO1JYZZcIUp/ghAb2QaCY6BEdD2hb4DKhdEfzKs5RQ== X-Received: by 2002:a63:7d58:: with SMTP id m24mr371315pgn.81.1591204457319; Wed, 03 Jun 2020 10:14:17 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 10:14:16 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v2 2/7] Bluetooth: Configure controller address resolution if available Date: Wed, 3 Jun 2020 22:47:08 +0530 Message-Id: <20200603171713.9882-3-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 From: Marcel Holtmann When the LL Privacy support is available, then as part of enabling or disabling passive background scanning, it is required to set up the controller based address resolution as well. Since only passive background scanning is utilizing the whitelist, the address resolution is now bound to the whitelist and passive background scanning. All other resolution can be easily done by the host stack. Signed-off-by: Marcel Holtmann Signed-off-by: Sathish Narsimman --- include/net/bluetooth/hci_core.h | 3 +++ net/bluetooth/hci_request.c | 26 +++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index cdd4f1db8670..c17c8d820493 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1279,6 +1279,9 @@ void hci_conn_del_sysfs(struct hci_conn *conn); #define scan_coded(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_CODED) || \ ((dev)->le_rx_def_phys & HCI_LE_SET_PHY_CODED)) +/* Use LL Privacy based address resolution if supported */ +#define use_ll_privacy(dev) ((dev)->le_features[0] & HCI_LE_LL_PRIVACY) + /* Use ext scanning if set ext scan param and ext scan enable is supported */ #define use_ext_scan(dev) (((dev)->commands[37] & 0x20) && \ ((dev)->commands[37] & 0x40)) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 1fc55685da62..1d885ccd5419 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -676,6 +676,12 @@ void hci_req_add_le_scan_disable(struct hci_request *req) cp.enable = LE_SCAN_DISABLE; hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); } + + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + __u8 enable = 0x00; + hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + } } static void del_from_white_list(struct hci_request *req, bdaddr_t *bdaddr, @@ -808,10 +814,16 @@ static bool scan_use_rpa(struct hci_dev *hdev) } static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, - u16 window, u8 own_addr_type, u8 filter_policy) + u16 window, u8 own_addr_type, u8 filter_policy, + bool addr_resolv) { struct hci_dev *hdev = req->hdev; + if (use_ll_privacy(hdev) && addr_resolv) { + u8 enable = 0x01; + hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); + } + /* Use ext scanning if set ext scan param and ext scan enable is * supported */ @@ -885,12 +897,18 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, } } +/* Ensure to call hci_req_add_le_scan_disable() first to disable the + * controller based address resolution to be able to reconfigure + * resolving list. + */ void hci_req_add_le_passive_scan(struct hci_request *req) { struct hci_dev *hdev = req->hdev; u8 own_addr_type; u8 filter_policy; u16 window, interval; + /* Background scanning should run with address resolution */ + bool addr_resolv = true; if (hdev->scanning_paused) { bt_dev_dbg(hdev, "Scanning is paused for suspend"); @@ -936,7 +954,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req) bt_dev_dbg(hdev, "LE passive scan with whitelist = %d", filter_policy); hci_req_start_scan(req, LE_SCAN_PASSIVE, interval, window, - own_addr_type, filter_policy); + own_addr_type, filter_policy, addr_resolv); } static u8 get_adv_instance_scan_rsp_len(struct hci_dev *hdev, u8 instance) @@ -2725,6 +2743,8 @@ static int active_scan(struct hci_request *req, unsigned long opt) u8 own_addr_type; /* White list is not used for discovery */ u8 filter_policy = 0x00; + /* Discovery doesn't require controller address resolution */ + bool addr_resolv = false; int err; BT_DBG("%s", hdev->name); @@ -2746,7 +2766,7 @@ static int active_scan(struct hci_request *req, unsigned long opt) own_addr_type = ADDR_LE_DEV_PUBLIC; hci_req_start_scan(req, LE_SCAN_ACTIVE, interval, DISCOV_LE_SCAN_WIN, - own_addr_type, filter_policy); + own_addr_type, filter_policy, addr_resolv); return 0; } From patchwork Wed Jun 3 17:17:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11586039 X-Patchwork-Delegate: marcel@holtmann.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 75DB914E3 for ; Wed, 3 Jun 2020 17:14:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E36520772 for ; Wed, 3 Jun 2020 17:14:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="at5OV/Ap" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726187AbgFCROW (ORCPT ); Wed, 3 Jun 2020 13:14:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725961AbgFCROV (ORCPT ); Wed, 3 Jun 2020 13:14:21 -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 A2358C08C5C0 for ; Wed, 3 Jun 2020 10:14:21 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id p21so2146419pgm.13 for ; Wed, 03 Jun 2020 10:14:21 -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=KNTecTNnvShK+jbDcWYwGt/NrIa6D+tmpxROB3vM6M8=; b=at5OV/Aphg1X15SJ6Eudv7cdLkdv7OEmmo396zQMsxOfwC/sWeS+XPG4o1UD0SzG6f o6Ukg+ZtxUln86oN8/N40G6gnwv0xDqRSHAn+kRg2JHsiL5dDDBFuDiEDMV2XJGgsCfu mYGTvXQBbgLWAlqgS2rSH8rmvtKjWoLjGVh9Yj6uKQQmz/IyQFUtyFfLeMd1FRfFV3mc iWdhW7r3GSeVXcaKl8wpsavS8HjBmJj5jsrdfsPqUxf7SWZl3Kl2ruS9Cwv4ZHK8kcWa 7RnFZLGn0Hn7iorgCT8l4sPvH6YgTQjsjW73IE2j7iJF3X+nsx3b2A0Zf6VdDSqOZMu5 5E2g== 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=KNTecTNnvShK+jbDcWYwGt/NrIa6D+tmpxROB3vM6M8=; b=F2Y72uy7ZSbUHkELxCnWqJuO2yyJxr8T/alTwy8oQ+tJToYiVm/Vo9kc7EXdip6zli GNarDLAPIWy/XEJnFazTd4ckujrZosFodYbnl+QlK7j8C+1U1Qc8MiUQJNVqGVr3mYur nIqpDQ8CIgTVYIhQizdNbBfiCIb1+3/RrjcEXXlw2bXQdphokUcIqmkvpS71ThvV49PN 81tWIcP9RqyLobIlY/cJBb+in+LhUwThCbiT1vThu3/hsFQNGicXMck+DhTJhIDX6AP6 UwOGtFocAorZkAqnPt8m7pwdNJexdg0Skdbq0fDU+UeGZ5kss1AWOBcM5TFA4OKCrOYH 0TTg== X-Gm-Message-State: AOAM530YwzG1DRhytowvGEAL0ESroe2P+DS2nzXkOzvhuJtUOrCaYKJh 6Dpp/rKzC/Ypy38Siaq2cD0/0NKBhbA= X-Google-Smtp-Source: ABdhPJzPrAn/CfCdGQdubXhoEHCkt0WT4eBfzj6FiObTSH+o1CLa/41tC0gU1QARYqsZ3WqDXKDR8w== X-Received: by 2002:a17:90a:aa83:: with SMTP id l3mr883420pjq.73.1591204460934; Wed, 03 Jun 2020 10:14:20 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 10:14:20 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v2 3/7] Bluetooth: Update resolving list when updating whitelist Date: Wed, 3 Jun 2020 22:47:09 +0530 Message-Id: <20200603171713.9882-4-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 From: Marcel Holtmann When the whitelist is updated, then also update the entries of the resolving list for devices where IRKs are available. Signed-off-by: Marcel Holtmann Signed-off-by: Sathish Narsimman --- net/bluetooth/hci_request.c | 41 +++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 1d885ccd5419..bcd64dec9989 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -695,6 +695,21 @@ static void del_from_white_list(struct hci_request *req, bdaddr_t *bdaddr, bt_dev_dbg(req->hdev, "Remove %pMR (0x%x) from whitelist", &cp.bdaddr, cp.bdaddr_type); hci_req_add(req, HCI_OP_LE_DEL_FROM_WHITE_LIST, sizeof(cp), &cp); + + if (use_ll_privacy(req->hdev)) { + struct smp_irk *irk; + + irk = hci_find_irk_by_addr(req->hdev, bdaddr, bdaddr_type); + if (irk) { + struct hci_cp_le_del_from_resolv_list cp; + + cp.bdaddr_type = bdaddr_type; + bacpy(&cp.bdaddr, bdaddr); + + hci_req_add(req, HCI_OP_LE_DEL_FROM_RESOLV_LIST, + sizeof(cp), &cp); + } + } } /* Adds connection to white list if needed. On error, returns -1. */ @@ -715,7 +730,7 @@ static int add_to_white_list(struct hci_request *req, return -1; /* White list can not be used with RPAs */ - if (!allow_rpa && + if (!allow_rpa && !use_ll_privacy(hdev) && hci_find_irk_by_addr(hdev, ¶ms->addr, params->addr_type)) { return -1; } @@ -732,6 +747,28 @@ static int add_to_white_list(struct hci_request *req, cp.bdaddr_type); hci_req_add(req, HCI_OP_LE_ADD_TO_WHITE_LIST, sizeof(cp), &cp); + if (use_ll_privacy(hdev)) { + struct smp_irk *irk; + + irk = hci_find_irk_by_addr(hdev, ¶ms->addr, + params->addr_type); + if (irk) { + struct hci_cp_le_add_to_resolv_list cp; + + cp.bdaddr_type = params->addr_type; + bacpy(&cp.bdaddr, ¶ms->addr); + memcpy(cp.peer_irk, irk->val, 16); + + if (hci_dev_test_flag(hdev, HCI_PRIVACY)) + memcpy(cp.local_irk, hdev->irk, 16); + else + memset(cp.local_irk, 0, 16); + + hci_req_add(req, HCI_OP_LE_ADD_TO_RESOLV_LIST, + sizeof(cp), &cp); + } + } + return 0; } @@ -772,7 +809,7 @@ static u8 update_white_list(struct hci_request *req) } /* White list can not be used with RPAs */ - if (!allow_rpa && + if (!allow_rpa && !use_ll_privacy(hdev) && hci_find_irk_by_addr(hdev, &b->bdaddr, b->bdaddr_type)) { return 0x00; } From patchwork Wed Jun 3 17:17:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11586041 X-Patchwork-Delegate: marcel@holtmann.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3290E14E3 for ; Wed, 3 Jun 2020 17:14:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A08520674 for ; Wed, 3 Jun 2020 17:14:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MI6QDVR0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726225AbgFCRO0 (ORCPT ); Wed, 3 Jun 2020 13:14:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725961AbgFCROZ (ORCPT ); Wed, 3 Jun 2020 13:14:25 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8624C08C5C0 for ; Wed, 3 Jun 2020 10:14:24 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id s23so698084pfh.7 for ; Wed, 03 Jun 2020 10:14:24 -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=RqbNZdfUYH4SzFn+I4Y/bQsxB/0Uon3AtvdfFK17OOE=; b=MI6QDVR0Dwcb1j/3WKvcigtl7WV1KSXclWfwvQGkjUUEHQUcWXRJcFCs8RzTtfnnYp Zwqhwfu0tdVq8NqsyMfB0tPOVQRam+awoDXi6lLUtkBlhnVJTXRvgjWIOz7dbnCo2Q1d ifpWtMLuSdcduOYHubxvixtIB7L53gJWLj8WEGhV6axEFfFDraBwKg9lO37mfOxW8voj wergH32sZHY2B3fviSybiiWFZNKtn6zElSccKMq3ziRcVPz5n2TLP5F5Ne9is428y4hs TITYIcxd+tz/qucRd8zqGCepaW8dtSWTMlezu81QKbHNliCWM1ZCFAqR/G+LQ38DwB6a N06g== 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=RqbNZdfUYH4SzFn+I4Y/bQsxB/0Uon3AtvdfFK17OOE=; b=MBQq8fJe67XH4b8MJDuSplYBEABHGWr0cpOO0cyUNO4SnglgiDjGrPXZ2Wzt2rVciO dQLTTLHafPQP4+ZdfmqXv4hSL5LVCkDsJ4NfqFn0gjYU/f+9/rdjQMPivcGCd9fzL3bT sDMwZruQKAbJ3QG8oSYt63EFSIXQeYbh1MzlPFSbF5XXKdWWddy+FVJSAkd2E/X+OnNF 0PCD8T2KzQ6lMC4ICRheG81cKwLMo7dourZqAgmXr7G2nQmp5JDg0KEyhQ5/3KYq1bbV jfG0E6y0pUoZ+/T3WcfSlYuAjanloup4HwQfCZJBWJLRy49tlTDZB+PU317LuMpeAi1F DrXg== X-Gm-Message-State: AOAM533Qrr63SHZnTlvpHbqf/osh100jHueRqaPZMj+YWOPB9xXWtxUL n4fYOeDEIOrCSXtQy6IsuIjFGzaeVfU= X-Google-Smtp-Source: ABdhPJzEeePFIofDvFU8l1ZUa3xqvI7J6YTJ9CPxualxTNJBo84AxshxB6huOepSrJXaUSqOkYYwQw== X-Received: by 2002:a62:e703:: with SMTP id s3mr133450pfh.43.1591204464098; Wed, 03 Jun 2020 10:14:24 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 10:14:23 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH 4/7] Bluetooth: Translate additional address type during le_conn Date: Wed, 3 Jun 2020 22:47:10 +0530 Message-Id: <20200603171713.9882-5-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 When using controller based address resolution, then the new address types 0x02 and 0x03 are used. These types need to be converted back into either public address or random address types. This patch is specially during LE_CREATE_CONN if using own_add_type as 0x02 or 0x03. Signed-off-by: Sathish Narasimman --- net/bluetooth/hci_event.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index cfeaee347db3..9c9c434844f2 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2296,6 +2296,22 @@ static void cs_le_create_conn(struct hci_dev *hdev, bdaddr_t *peer_addr, if (!conn) return; + /* When using controller based address resolution, then the new + * address types 0x02 and 0x03 are used. These types need to be + * converted back into either public address or random address type + */ + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + switch (own_address_type) { + case ADDR_LE_DEV_PUBLIC_RESOLVED: + own_address_type = ADDR_LE_DEV_PUBLIC; + break; + case ADDR_LE_DEV_RANDOM_RESOLVED: + own_address_type = ADDR_LE_DEV_RANDOM; + break; + } + } + /* Store the initiator and responder address information which * is needed for SMP. These values will not change during the * lifetime of the connection. From patchwork Wed Jun 3 17:17:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11586043 X-Patchwork-Delegate: marcel@holtmann.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7689C14E3 for ; Wed, 3 Jun 2020 17:14:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5EB0820674 for ; Wed, 3 Jun 2020 17:14:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kNnwPTbk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726229AbgFCRO3 (ORCPT ); Wed, 3 Jun 2020 13:14:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726226AbgFCRO2 (ORCPT ); Wed, 3 Jun 2020 13:14:28 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1D36C08C5C0 for ; Wed, 3 Jun 2020 10:14:27 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id y18so1034192plr.4 for ; Wed, 03 Jun 2020 10:14:27 -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=6CBbZ9r4eSiZUUGFyvEEYED4UFptLRNF6sdTCpICb7Q=; b=kNnwPTbkTH46n95zn6hqziBPVM9wJFJVDrlvB+FxTPIyAc9TOVwb+UNRfGqNMV2QIU CncI3fX2YD6bTDnXllyfK6l1io5jNo3NppNCdphijC8YuzAbFNyfDzYfylygKasCa/Pb zYnFH2aTwlfIQUD24EmQJkRm1I0JvXYrpgUt1KKlZqi4eFdZF4HUtAfJlVdWX8xHRjSh zkcrnsfTWw/w2wYDlVmBGi8aXdtaLpNLh0ExGot+5Rzlm8Mwwafcl2j8+9PIdpnWc+sN DhVOZYKINf1K1NDpXkfTZeTNEf0P+oqaq6qgrhdNhOOgi8CwmEJ+ltTTZGAIfDZpDZvN OXOQ== 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=6CBbZ9r4eSiZUUGFyvEEYED4UFptLRNF6sdTCpICb7Q=; b=VCipTPZgMzQbHw7dVSYLLVwevfXXC+Rh7Za6PidvnONORVVaYYa1w88k+js5+BcMDt TbW+V7eV9OoT1chZUBpOCnOzb29JpY90vo/5SPTNmP++poH9g4qtpgwkrNCOytlGWf/2 7kH5FOxKZ7dzSH97VC6ymK6nkv/w7jldJLwcXQUg5C5vNruVhUT4OHWOq1Vmz3Q/xnEt oQNIvT4CnckiGP0utPi3F69BUyBSs0f1bWWRWNDe/Vd5I6SBGxj2vs3ngrtxulcdWCgP ckWchN8E6Ze0xn0XXCsxei1lxhBnG7pLJdm4BMlO0sTL7775SpqW5HG2wU80HeF46l0c j8kQ== X-Gm-Message-State: AOAM53383vNsM/Dy6iI+blPaVF2mMF1xjMn1cP/tEhoKASm21IRFmVV0 DMgU8jAyIodbbPpPmRnqOIvNPNabNYs= X-Google-Smtp-Source: ABdhPJzEoahzou9bcXCE8PRgshFSFajcc0GSz9qsT5E2PhEjJHvjcFK9WPTQNEo+srKK/gKmRzGP/Q== X-Received: by 2002:a17:902:7682:: with SMTP id m2mr819735pll.281.1591204467230; Wed, 03 Jun 2020 10:14:27 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 10:14:26 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH 5/7] Bluetooth: Let controller creates RPA during le create conn Date: Wed, 3 Jun 2020 22:47:11 +0530 Message-Id: <20200603171713.9882-6-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 When address resolution is enabled and set_privacy is enabled let's use own address type as 0x03 Signed-off-by: Sathish Narasimman --- net/bluetooth/hci_request.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index bcd64dec9989..6e1036cc8b1e 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -2183,7 +2183,13 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy, if (use_rpa) { int to; - *own_addr_type = ADDR_LE_DEV_RANDOM; + /* If Controller supports LL Privacy use own address type is + * 0x03 + */ + if (use_ll_privacy(hdev)) + *own_addr_type = ADDR_LE_DEV_RANDOM_RESOLVED; + else + *own_addr_type = ADDR_LE_DEV_RANDOM; if (!hci_dev_test_and_clear_flag(hdev, HCI_RPA_EXPIRED) && !bacmp(&hdev->random_addr, &hdev->rpa)) From patchwork Wed Jun 3 17:17:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11586045 X-Patchwork-Delegate: marcel@holtmann.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 295331392 for ; Wed, 3 Jun 2020 17:14:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0A8BA207D5 for ; Wed, 3 Jun 2020 17:14:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Cxq6Vw7m" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726226AbgFCROb (ORCPT ); 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-Google-Smtp-Source: ABdhPJwA+wtH6no0KEQUxfKDXEHbsmEBf/sJNtPt6z+Th8d59dt4DEGHQwtE77oZMWKBC6U70PwoTg== 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); From patchwork Wed Jun 3 17:17:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11586047 X-Patchwork-Delegate: marcel@holtmann.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E91581392 for ; Wed, 3 Jun 2020 17:14:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD3EE20738 for ; Wed, 3 Jun 2020 17:14:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fiFDCuvx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726238AbgFCROe (ORCPT ); Wed, 3 Jun 2020 13:14:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726236AbgFCROe (ORCPT ); Wed, 3 Jun 2020 13:14:34 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ACFBC08C5C0 for ; Wed, 3 Jun 2020 10:14:34 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id o6so2206058pgh.2 for ; Wed, 03 Jun 2020 10:14:34 -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=C5aGJDCTVUf27Q5D9JDTfavbwDNrp4VfqXTMY6QGNOA=; b=fiFDCuvxKqGHpKKO+MMyLyDL5EKslBQuoC5iZdAkp0GX3he7E5Xi6+6MlM6Uzikhvv DFaFPljD77rPgL29PUjFOj/rIk/hAnvCl1bVjWONpMzbNJpcmc+ZnonfnKLhTilZD/e0 TUnzS32K0CaclBAq8eurabFa7Yy6PpWSwGdITZfUcaN25bi0BCWbjHIK9df0/EscmBEp oSEtpl5qaGaGEDNllirEhLt90QzBaj1/fJP5NpOnG3ju+DUUplFx/ofUEnN8oU81MuS3 fRv2+s3WHPbD9st1rzKxJ054ngXLDGAzeEIGzzCxqx/yifaXDaxzQgQIAYHPw3NvKRMS 2ndQ== 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=C5aGJDCTVUf27Q5D9JDTfavbwDNrp4VfqXTMY6QGNOA=; b=i1A0JrS1n30eQyqxfoHD6CSFozTuSClqYhYxClVPUqFg1tW2flcRU4dlJ8atqFbl61 1zuePI6TcdmFJnZr3RzVSb1qI007F448WerpZpFxLV7gZ4T7ex5Bv/bXv97FujW0C0Rz belruLKxYfQliRDMVG+fZ5/l70pu+lB58/OA9/XYeSb9d6xtGA8cMi82W2G1v2Dcpw/C 4MIDYQoORc0Icw7na2LzI0KM/Z20r6jiTYUK0fgkdDTHxwB0K/LtxgM3hPRRqzt/V6Ww PXJUvq/axFmu2wqUq++OyebyHrRTKpDhKu2SDj6u6JuPBOs2bjJq4BU/+3S7wyVwkPYo hFYA== X-Gm-Message-State: AOAM532h7WPRSfgpttdX/m0tA3vEMHWGfIOsS+XA3mJJTFvV3ZyKKjrM tGpg/S/rHJmZlfqhe/6E+UurWQdGbyI= X-Google-Smtp-Source: ABdhPJwFisMy2dylIof5pK6pv7bFWp3eV4AqsrdmCEQXfbwb5rs+INtIRYwZLPVx/zFMR+cBheUx3A== X-Received: by 2002:a17:90b:23c8:: with SMTP id md8mr1002099pjb.72.1591204473343; Wed, 03 Jun 2020 10:14:33 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 10:14:32 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH 7/7] Bluetooth: Enable RPA Timeout Date: Wed, 3 Jun 2020 22:47:13 +0530 Message-Id: <20200603171713.9882-8-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 Signed-off-by: Sathish Narasimman --- include/net/bluetooth/hci.h | 2 ++ net/bluetooth/hci_core.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 1165dfea56a9..12005fbe6e09 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -1637,6 +1637,8 @@ struct hci_rp_le_read_resolv_list_size { #define HCI_OP_LE_SET_ADDR_RESOLV_ENABLE 0x202d +#define HCI_OP_LE_SET_RPA_TIMEOUT 0x202e + #define HCI_OP_LE_READ_MAX_DATA_LEN 0x202f struct hci_rp_le_read_max_data_len { __u8 status; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index f4ceda1f1454..67e1434c3f31 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -763,6 +763,14 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt) hci_req_add(req, HCI_OP_LE_CLEAR_RESOLV_LIST, 0, NULL); } + if (hdev->commands[35] & 0x40) { + __le16 rpa_timeout = cpu_to_le16(hdev->rpa_timeout); + + /* Set RPA timeout */ + hci_req_add(req, HCI_OP_LE_SET_RPA_TIMEOUT, 2, + &rpa_timeout); + } + if (hdev->le_features[0] & HCI_LE_DATA_LEN_EXT) { /* Read LE Maximum Data Length */ hci_req_add(req, HCI_OP_LE_READ_MAX_DATA_LEN, 0, NULL);