From patchwork Mon Jul 13 06:22:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11658821 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 5734B618 for ; Mon, 13 Jul 2020 06:18:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3CF612075F for ; Mon, 13 Jul 2020 06:18:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PYtuEI24" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728950AbgGMGSa (ORCPT ); Mon, 13 Jul 2020 02:18:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgGMGSa (ORCPT ); Mon, 13 Jul 2020 02:18:30 -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 8EA8CC061794 for ; Sun, 12 Jul 2020 23:18:30 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id j20so5563790pfe.5 for ; Sun, 12 Jul 2020 23:18:30 -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=xSub10RztAkAVkR7dQ1tuib+ohmh4r9LyvxXZPcSzms=; b=PYtuEI24SUiceyjMGvP8DZ9fcw4kzUoqVdCJIl22dOi89C/ex/cniSYZpVA7KQixZG fY7OKc2Gr67Ho/vjnGI1+z3O+Vbsu/H8Etl81ziYf4MTFSqNCeml4SM20StY0T0vUO7h 63Bk5qiYquUOi69iuqbI/CChpvpXDscIFmOQCHX2EjJVq1e0eUfJbjcXLVs6T6EHAhiB Io2LtaNgBGF3ZuEjo9QbSeyuxJoR2txATJbgzZt+smMZ03DR+Y2emcwP/pt6ctl8gA62 nt02/TdUg3XDcSSpa/hsDJYOtVvbguU8AuLW3b8xBWF1eyWAmAAKgLqTFjIUjwhIuj6u JlLA== 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=xSub10RztAkAVkR7dQ1tuib+ohmh4r9LyvxXZPcSzms=; b=iBVQ24+U2kgNLnWcCwx+XrYyHhkNbGwuWSIBB+MqGHLgue0og36s6qqtOvExzUqkrN /65Dio2T/5ATHEDCHsxzg1FAckBLdtjSc+lLmIj8G06PFDIwkFOH+5sGgh9W+NzzNxzp alQ62XQRmUVrYNUgOcrbbjwjuwyAGHdL5UTqgRzlcGkWyus/9JrxrsyfOnYm+EtWDHzB WLufa4xz7DVLTZa4gvKWRd7hcN3iGxM6VlAL4eo3rz3Ts67BtgYuXcCZZ1p2ECc0uiQk wdh6aGIccCJmRStvVB6AxCQK6JMLc3WmirW3SuvaVxK5+AR6wsVQ22gx6wn5/rHa7ULG hMWw== X-Gm-Message-State: AOAM532GeoWXNtAI+hMp8mpH72z7jmtYnG44yVUb/avNtvj2Mo9tUb2S 5D/nKEPKpoGfJGgZ5Bpm94iv8Je6r693TQ== X-Google-Smtp-Source: ABdhPJxGd+UgMH68xXk6MSqy1axeE3LMMVxel5LtDzJ8mfBZs3SCMKaLVq4ysnZ8zH3kNagDdKxggQ== X-Received: by 2002:a63:6744:: with SMTP id b65mr48189679pgc.42.1594621109882; Sun, 12 Jul 2020 23:18:29 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id 204sm13096371pfx.3.2020.07.12.23.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:18:29 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v4 1/8] Bluetooth: Translate additional address type correctly Date: Mon, 13 Jul 2020 11:52:06 +0530 Message-Id: <20200713062213.3692-2-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713062213.3692-1-sathish.narasimman@intel.com> References: <20200713062213.3692-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 1f18f71363e9..abab8b5981a7 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 6509f785dd14..4af208b82138 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3290,6 +3290,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 Mon Jul 13 06:22: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: 11658823 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 4C23913B1 for ; Mon, 13 Jul 2020 06:18:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 345AF2075F for ; Mon, 13 Jul 2020 06:18:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hUtjcKtg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729013AbgGMGSj (ORCPT ); Mon, 13 Jul 2020 02:18:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgGMGSj (ORCPT ); Mon, 13 Jul 2020 02:18:39 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96AB1C061794 for ; Sun, 12 Jul 2020 23:18:39 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id f16so5729875pjt.0 for ; Sun, 12 Jul 2020 23:18: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:in-reply-to:references; bh=0uDYaKG7efI3+NfcjCvxS1+KgIa76fmhv33RI9RFLbw=; b=hUtjcKtgoBapahxkdmERTduk04+ofTqj2xNcTSMk5qW2ivR/AIl59W9/v5Co1Yxh9O Dhd0WSJnUc7opL0EeEDVgG3XO+r4LwLM08bDTuFhChIElShcLVinBFAUDXGybgGg7+ER agSrHrS/xhHJrkV0YWT/p270AcUUQDH9EaSoorbaTDIcO6RBTGva5PUtVuZOAlWUPfsU AVtNNTryoNn7GcvJJHa/BaanIOCqaWKSQW0TowMYDQfebYfSB92bLy4FCXY1RvYx4pGo kHu6ClK4zfqQ0pT1BrECmGtINU0vkyMqN01YJ74TQP1HN8isfzwIYRsSUnNdgPHN8NrO Rjug== 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=0uDYaKG7efI3+NfcjCvxS1+KgIa76fmhv33RI9RFLbw=; b=sJb8SkzzNkPjwzs21AlGXx64LwcowYLsc2hRdJ3CfCJFfgkoouoLWWcfYn1JFDSAu5 1VNYuRd52dykLZcEBVuqKNksQ56ZyJJ/9HXQ58hDtPTY26yBu3v9EgYAXEJItVl3zcv1 x9RwFGDA1TDLcFqy4dbiEewXfml91oO+EhyDAyWzN0d3twC5IdTP+Gxj31VtMh0glfEv Q+ge9gl9D9SglEJQQ9RsmYYH61nC2sbnnhuMmZ/3oKRjvD7rcoRjZrUfc/X93aSeP6Yb itXtotqBHx4Zi0sbbF6PYOWvr3j5Pl0V4ZggjTqb3eEm1YibDO+TjOcKbMry8mUpybGV lpVQ== X-Gm-Message-State: AOAM530hL/VhSNLB3vZnteelHK2ZqHqtj8/+RfaLbmQGtZfQ+weBvGyn lz9dFdpHl6QzQJnz+kKed/Ebb5131OcpmA== X-Google-Smtp-Source: ABdhPJx8P3oxwtEo0ns2ScQu4IKDUTrgpWu/hD6SWZtM7YMg2zCU3ZDHaH8MJybO016/eVhWiFIZ3Q== X-Received: by 2002:a17:902:654e:: with SMTP id d14mr26325038pln.60.1594621118885; Sun, 12 Jul 2020 23:18:38 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id 204sm13096371pfx.3.2020.07.12.23.18.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:18:38 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v4 2/8] Bluetooth: Configure controller address resolution if available Date: Mon, 13 Jul 2020 11:52:07 +0530 Message-Id: <20200713062213.3692-3-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713062213.3692-1-sathish.narasimman@intel.com> References: <20200713062213.3692-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 34ad5b207598..065250242a1b 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1359,6 +1359,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 770b93758112..d3c7ddbcff33 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -675,6 +675,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, @@ -816,7 +822,8 @@ 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; @@ -825,6 +832,11 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, return; } + 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 */ @@ -898,12 +910,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"); @@ -949,7 +967,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) @@ -2748,6 +2766,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); @@ -2770,7 +2790,7 @@ static int active_scan(struct hci_request *req, unsigned long opt) hci_req_start_scan(req, LE_SCAN_ACTIVE, interval, hdev->le_scan_window_discovery, own_addr_type, - filter_policy); + filter_policy, addr_resolv); return 0; } From patchwork Mon Jul 13 06:22: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: 11658825 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 EB87A13B1 for ; Mon, 13 Jul 2020 06:18:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D35D92075F for ; Mon, 13 Jul 2020 06:18:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l7r1+2ib" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729196AbgGMGSn (ORCPT ); Mon, 13 Jul 2020 02:18:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgGMGSm (ORCPT ); Mon, 13 Jul 2020 02:18:42 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7634FC061794 for ; Sun, 12 Jul 2020 23:18:42 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id k5so5050557plk.13 for ; Sun, 12 Jul 2020 23:18:42 -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=3K8YriwZsyJ0Zz+v0ZMtNGnBg6m3R1aaPPOtC++AWHM=; b=l7r1+2ibixy8apzMhAuVaOsq8w1ErNaDrFgvnQWRdtBPq6k2i9t41yo1oOtUz2ROHu OYNHQ02kojU884wfCU4H1ijFOYTIpXxrmFUD5wpFbE06ILkj8pNzrpd1iM34MDFiPQxw LtVAyGl2eIYC3uYdsIqeBZJ1wZtyjt10aRCQZoTdKt/HxqOEoP2Qtj74d9MJ2PuyWCpx xVK684TDkCCbC1I6pYVCS0fzI94eZpVzYWmLq5zX5aQKmPV8EwQrzQ9b8kSb6NsIS3sz XITkco4F1vKA3T6+OayCP4qg1C8gmALJHpbuRvUP3zhhUkU8welCJa2hbAM/5oY6I4jq L0cA== 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=3K8YriwZsyJ0Zz+v0ZMtNGnBg6m3R1aaPPOtC++AWHM=; b=dBDJl8jVE07omojxl2EegmDaxtFG/YwcLPaXzAjKn1bxLzv2CKX3RS6Zu+sGDfApx0 j3ytRaEUwL0VuquWCxScIevcwCy0/m5CbpEkCTooMH+8Zl9U1tD7nzUCHrghYRnTgCqn +Z8pkDbPZUc1N6yeV8DjWBmpFcKu7JZRk3aVoPtIFeW+zJwlvUBnkTSG0I80X+G0Sn3e Kdt+tPIUb80ioJezTwXvT3JkijoYrxOnmB7zYATQ+OI2JKtv1oJ6zzabN7Rf9tR7uCod ofpUDZ1y8jAuLbid85smU7zX+lFl5h9j6ILXQ2QHZTnxzN+AncYo28mgx4C9dZ2Qk6XZ dLzA== X-Gm-Message-State: AOAM530fBqHJGMG23N0cXe0h3R40Qc4wTVYa67w7Nm4su03hcI3sYX6m 59G4IGdy06Ob2IEn7JRL6iYtAnOvIAxHWw== X-Google-Smtp-Source: ABdhPJyLJ7HNm2uwWsfCO2XXgDAfyFxkE51/JUsXzkLqYj5npPSEIpp1cWTMx+UtuKQ37Dpev0oydA== X-Received: by 2002:a17:90a:764c:: with SMTP id s12mr18481758pjl.201.1594621121796; Sun, 12 Jul 2020 23:18:41 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id 204sm13096371pfx.3.2020.07.12.23.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:18:41 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v4 3/8] Bluetooth: Update resolving list when updating whitelist Date: Mon, 13 Jul 2020 11:52:08 +0530 Message-Id: <20200713062213.3692-4-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713062213.3692-1-sathish.narasimman@intel.com> References: <20200713062213.3692-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 d3c7ddbcff33..2dc00604412c 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -694,6 +694,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. */ @@ -714,7 +729,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 Mon Jul 13 06:22: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: 11658827 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 7AF1F618 for ; Mon, 13 Jul 2020 06:18:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 636D72075F for ; Mon, 13 Jul 2020 06:18:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="j6HuWtKX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729198AbgGMGSp (ORCPT ); Mon, 13 Jul 2020 02:18:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgGMGSp (ORCPT ); Mon, 13 Jul 2020 02:18:45 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A5AFC061794 for ; Sun, 12 Jul 2020 23:18:45 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id m16so3866848pls.5 for ; Sun, 12 Jul 2020 23:18:45 -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=s2IcTEAY6E8gqIiH1UvcKWcRD7F04eaPXNmCRRgH/EI=; b=j6HuWtKXJA0LJN3It5/huBCCyvIsHDa95qy/PrtPY0SHVarddS5eFhjMMqvUr4b+tV 8op+y5evL7Ai0OdNrqE6iKaPeBgO5uEtIyX5YC0whmpQvgIgeCV7Z1Dp5Jwmr6DmexUQ BfVUXfMTrzwTHvoNEGDIJEetl2T1Ps2RMrxWRClU7psHNsYbXnZtg4Yg6YFz4a/1p6V1 kQIcJN9pkyXPaUI5Tpz7rAshwzulXlfAdOyJRTL2Ok5xJswtLtf6mdKL9N9qyLKbaGQC nCsoaTYmKMvQCdMWzwhXIIclBJYLn/td3cxCkF9me1ACxIMayTj9gYip7js9DgxZjOdL wZEQ== 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=s2IcTEAY6E8gqIiH1UvcKWcRD7F04eaPXNmCRRgH/EI=; b=KlXUnqSdYe1ATUvPBqv/W3SqlPqtKLNHHWdi4YzzwS6uU8XPHUOoKaLE/FQXoNhEsd oyLuTnusQaQ6QPGlfLSsBJ8Q+ZlxKWWeqcFTfiXEpPUjI2KRdg+Qkob66Kx3syx+6u3d ODCptGPpNXghCE1+uIzauTgTZY/ZeNBIKCwHHbCTB6duSwin3r6dOCzafs/csdfIx785 SFatGzZBGj5/0iN3xoJya1s0YDN1ppu6nrqQVJsw4VaCAEShM6Rj1RHtR5jSI8Eao6Na bldd6Q7chhD4p2Pw25teEmeHjPR8p1g8vIzmPq0GwVeOtliLx5gFQAmArNhA9TzB1WOB XO4g== X-Gm-Message-State: AOAM53202gMV53YHxRm+CH+JYu1jYd9I+k6ZcDV2bbBW6V1JissUhUUe Ap7oWYy5XOWjgf/q2kheI0l5ek3v9+Y/yQ== X-Google-Smtp-Source: ABdhPJyn8nljlXT68UpGRDusEmqYlIgFDYMFEfPtiFKpaBpclIpd+Vw8jj8HKc5t47FbUbVeC7TvwA== X-Received: by 2002:a17:90a:8a8b:: with SMTP id x11mr19062807pjn.127.1594621124489; Sun, 12 Jul 2020 23:18:44 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id 204sm13096371pfx.3.2020.07.12.23.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:18:44 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v4 4/8] Bluetooth: Translate additional address type during le_conn Date: Mon, 13 Jul 2020 11:52:09 +0530 Message-Id: <20200713062213.3692-5-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713062213.3692-1-sathish.narasimman@intel.com> References: <20200713062213.3692-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 927bde511170..eae5bd4a53ac 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 Mon Jul 13 06:22: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: 11658829 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 C8730618 for ; Mon, 13 Jul 2020 06:18:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEFDF2075F for ; Mon, 13 Jul 2020 06:18:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JgQsTLPh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729199AbgGMGSs (ORCPT ); Mon, 13 Jul 2020 02:18:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgGMGSs (ORCPT ); Mon, 13 Jul 2020 02:18:48 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC915C061794 for ; Sun, 12 Jul 2020 23:18:47 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id f2so5062069plr.8 for ; Sun, 12 Jul 2020 23:18:47 -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=nCVTz/TW1C8kDWW89hWnxqM0hLVoG7bmfidmPtnLD50=; b=JgQsTLPhaOkj5WpKoQTBdC0hd15AEi3eR+BAxFwUa4FmUr1K13f7vAo8cR24V3CVxj UDjufzkeTE4vvM3swvHZvaTQsl+RL6xv0wfxkEX7+SNWlwqVBImvISzRrJ1Gscr92Rl+ VF40S6A8c054Ys2CTDO92263itje5gqOq4gq+RLiM8RtWbkenJuk5Of27Q2jsDxblaE7 McxjtkYnb7AO+rFmlxaPAkzed2Drba4KdGI0FBOFMaLTWpxZbRjXN0NCou3BXMI+60uR PKo7CdzwnMTo1WXwtM82ak+pMzYTTnL5chGciLPTbzGtxL8AaLaabMa1AU4BS/Fq4jYe SA4w== 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=nCVTz/TW1C8kDWW89hWnxqM0hLVoG7bmfidmPtnLD50=; b=WN4a+rIoRzs8GLtbsvxn9oJXGDnkXpb2WH8iC4iVmshctDegG/7p8wRsYd1unyjAYl rDjVbJD/zdihy31ZcAsiuZ6Ir6yF1OKWufDpDgmsXohB2LaMxxwzvhoXo7XxEfML2/Ux OzelOW/sNpPCpPrSMPtpOaDdMlPvR77lbDmzqfFt+piMkdTE5lOdRYu5T5QBC8akjP09 5sRPujto/tGsR2cfgR3XGvnIhqcwE8PWANPLmTFDpaNaK/vfBEBfDsJEXg0eVrZSF0OL KCIKEOM0Yt5KdgMWIvS5EILeU9Nc0AJND/PCnZTVOHUi5fmdOFGkT8R64BaOt2th8w4X 6PjA== X-Gm-Message-State: AOAM532DYR6jLJXhPn/2pjs+gmXi1/d0NisPWuQD7eikomfk01+h/Vu3 Yeq5HPyByHonrZODGZ1+2dfayhJOre29AA== X-Google-Smtp-Source: ABdhPJz2kM9OG9o0jmvaS+BzXUTQcpngBKNaoIG2RfbaTjGsVy3WXY4bHWEIewCHLVYcD30xRVDWYA== X-Received: by 2002:a17:90a:1d06:: with SMTP id c6mr19291143pjd.194.1594621127375; Sun, 12 Jul 2020 23:18:47 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id 204sm13096371pfx.3.2020.07.12.23.18.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:18:46 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v4 5/8] Bluetooth: Let controller creates RPA during le create conn Date: Mon, 13 Jul 2020 11:52:10 +0530 Message-Id: <20200713062213.3692-6-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713062213.3692-1-sathish.narasimman@intel.com> References: <20200713062213.3692-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 2dc00604412c..e16d5154b2cf 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -2201,7 +2201,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 Mon Jul 13 06:22: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: 11658831 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 AF483618 for ; Mon, 13 Jul 2020 06:18:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E9D820791 for ; Mon, 13 Jul 2020 06:18:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lCwdJeFO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729143AbgGMGSv (ORCPT ); Mon, 13 Jul 2020 02:18:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgGMGSu (ORCPT ); Mon, 13 Jul 2020 02:18:50 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D679EC061794 for ; Sun, 12 Jul 2020 23:18:50 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id t15so5723971pjq.5 for ; Sun, 12 Jul 2020 23:18:50 -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=gqesOFNLs3tg0XsWgFXS5D1nTeu/tqmZApdWPI1nKEU=; b=lCwdJeFOT+uC+zUVyZkAeAZ2Zo65yBgVERNGPrmBib9Fu1ugNCOmzpv4uKQ9kPz9BH 9EFd2MBuMzCnv3Sm/J8/uVHvyZpOQ8Rhtm1MBXJ0QWjjen/75r2nCHli2jsslABeRBHI 3EiFfr2pSfRhevZjmHd0Jooa5/bHIRU8BKKf8eZcjczrp0qOy9yiogcyw+vy5UAQOsuj sXXcB9/gz1EKwJQa/tHY/1dGnT8r7W9xWdDc0TQqDZH92V8CekJW2HFqsy7L6qL6SXFs 9WpZq0H2/K1BO80nkBYUKJ3IVHT6BJtdo5NM5wl/RO/3RUmRm3LaMsaDi+LzNjWd1E6R fMHw== 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=gqesOFNLs3tg0XsWgFXS5D1nTeu/tqmZApdWPI1nKEU=; b=Wy7HPEW4Qb3oIvQ8rg6jIJaEokRFlEbSWw6hVT/fK8c6uM5gTbsb43yOIkYQRSFREq 8agQdxoDVhcRXZ9q4BuzsxwN6JIvP+Zo9gD6NxRIWSS3tB0zhVvJGzQWO0mexlCl67XU osuctGWqi94MLuTuSKCtWKFNByP2Pw4Tab08305Uf5OlV65X7Wv/oaSFiF5Azs/ESZ8T VQ487nnEIGOmysM9dAap9clwBGkGjt1K4D3296hedFU/lrMmaA/i4T6hXh2zzCz2+QJg n8K0Y4XpvZCFwEoe5EgK97qyzp0xbdPEMJfQPvBcM4EgxJwexuw+DrmqVZABpxzh/gkP Sm0Q== X-Gm-Message-State: AOAM531AVDaxSgApRRQiaPyTzbMwe1OtY0lTX4AIyYXEg8Ys0vZw5Qjj hGRS6KiaTqNHWspJ33hg9Pjl6wYQ3zj7IQ== X-Google-Smtp-Source: ABdhPJyapFmIKfe7aiayLpP33iR52qoGqLpIPyu3zAlAIwW6aB1PpWbC8QTH2Yhs1iMgnt4S1yf8Bw== X-Received: by 2002:a17:90b:1650:: with SMTP id il16mr17833277pjb.79.1594621130040; Sun, 12 Jul 2020 23:18:50 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id 204sm13096371pfx.3.2020.07.12.23.18.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:18:49 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v4 6/8] Bluetooth: Enable/Disable address resolution during le create conn Date: Mon, 13 Jul 2020 11:52:11 +0530 Message-Id: <20200713062213.3692-7-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713062213.3692-1-sathish.narasimman@intel.com> References: <20200713062213.3692-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 | 7 +++++- net/bluetooth/hci_event.c | 4 ++++ net/bluetooth/hci_request.c | 45 ++++++++++++++++++++++++++++--------- 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 8805d68e65f2..caf1598758bf 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -1003,6 +1003,11 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, 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)) { if (lmp_le_capable(hdev)) @@ -1103,7 +1108,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 eae5bd4a53ac..684c68cb5c76 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5221,6 +5221,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 e16d5154b2cf..c3193f7f9ff0 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -428,7 +428,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 { @@ -447,7 +447,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); @@ -652,7 +652,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; @@ -676,8 +676,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); } @@ -1072,7 +1073,7 @@ static void hci_req_config_le_suspend_scan(struct hci_request *req) { /* Before changing params disable scan if enabled */ if (hci_dev_test_flag(req->hdev, HCI_LE_SCAN)) - 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); @@ -1140,7 +1141,7 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next) /* Disable LE passive scan if enabled */ if (hci_dev_test_flag(hdev, HCI_LE_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); @@ -1701,6 +1702,28 @@ 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); @@ -2626,7 +2649,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; } @@ -2729,7 +2752,7 @@ static int le_scan_restart(struct hci_request *req, unsigned long opt) 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; @@ -2820,7 +2843,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 @@ -2935,14 +2958,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 686ef4792831..c292d5de4dc3 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -5226,7 +5226,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 Mon Jul 13 06:22: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: 11658833 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 31F0E13B1 for ; Mon, 13 Jul 2020 06:18:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 19720207BC for ; Mon, 13 Jul 2020 06:18:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NhQbI2ei" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729144AbgGMGSx (ORCPT ); Mon, 13 Jul 2020 02:18:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729119AbgGMGSx (ORCPT ); Mon, 13 Jul 2020 02:18:53 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ECF4C061794 for ; Sun, 12 Jul 2020 23:18:53 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id ch3so5707935pjb.5 for ; Sun, 12 Jul 2020 23:18:53 -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=PK9IFrqGA8tYf+eWNXSfj5UIMsffCcBtO2fOhU2TTN4=; b=NhQbI2ei67hufJgVSdS8zpkQQXKWe+xpErfVRbSXURKMOQ7eHBVc331c3BD0Dyp3yH bLzc/KC7PRop3VlBwJRmqGP549GoPyLTdxJKepJx1qXGXT86+8oTbGYcUGzVESe09sOL 49ZH58GotMOGsiEUGuZWzNgP5TEsF+DWuEbqCtn+gxhOiIkVJyZm7erULcWSy+OpLTEa X9ijT7M47YPO+meb/naSGX6yCaJtQXKSamXZ5wv+BODYs4nV8M9XFLuZRGPjem1fPLTP Pjwk/aGQ4IqJk3LmDfXbND8CaI0k51mAncGYtex+9PTXX7247sv/FrW5qL7rEcIKAg4c enBw== 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=PK9IFrqGA8tYf+eWNXSfj5UIMsffCcBtO2fOhU2TTN4=; b=oQiJrIYJaM81WWNFeCr3oOf57cMZl2/Qa7ks3xTuTQ3w6o73olnH3ysr2dV7mCaqV6 LENQUQVQEL8XiP+EP0N/uCPJwKjtbKciMsCbLVLr/bjvtM9XF1i+lJSzZ+oLN9YHC0+d tNjdSHvyaRDJtM+GRYl3wX0q8gu0PkIe+jOyslgMpm4qWk2bV6U2dwlstHfRvL3C0FNu i/14eSm80nRcnrsLqxTFv6HtjPFSF+ro3pH0hBDnE0icvpB4kvj8y4X8YpozGwM1aegg l9VVKXw+KbKwMVZGI0MTQfxxOs43jCecVDdL+8SKuGLWy8oOnqzJTzCal2JkBSthv8zO IdmA== X-Gm-Message-State: AOAM533ARJ+7Oa0SwKlMo9GBSUf6rkaHuBTwNlq3B3qxmLdrj4s+v34U L53LGagyI9yHApLIzCasqi5uWFO64KMZDA== X-Google-Smtp-Source: ABdhPJxfWUUJkvx7LaKkaub5iMWPPZChuj/DK9iVV92p4uvA7jUKRB8GAizrlWzKrg9qNpSBZt+mxA== X-Received: by 2002:a17:90a:71c4:: with SMTP id m4mr19130787pjs.178.1594621132889; Sun, 12 Jul 2020 23:18:52 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id 204sm13096371pfx.3.2020.07.12.23.18.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:18:52 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v4 7/8] Bluetooth: Enable RPA Timeout Date: Mon, 13 Jul 2020 11:52:12 +0530 Message-Id: <20200713062213.3692-8-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713062213.3692-1-sathish.narasimman@intel.com> References: <20200713062213.3692-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Enable RPA timeout during bluetooth initialization. The RPA timeout value is used from hdev, which initialized from debug_fs 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 abab8b5981a7..4ff2fc4498f3 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 4af208b82138..2030536cc5d8 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -762,6 +762,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); From patchwork Mon Jul 13 06:22: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: 11658835 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 3804113B1 for ; Mon, 13 Jul 2020 06:18:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 208DB20791 for ; Mon, 13 Jul 2020 06:18:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kIhed68W" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729211AbgGMGS4 (ORCPT ); Mon, 13 Jul 2020 02:18:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729119AbgGMGS4 (ORCPT ); Mon, 13 Jul 2020 02:18:56 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7051DC061794 for ; Sun, 12 Jul 2020 23:18:56 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id m16so3867084pls.5 for ; Sun, 12 Jul 2020 23:18:56 -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=f1oHIKp+Xl1MtDR3jCF7Dp+Qm8VEDoGCEovuZWBlKwk=; b=kIhed68WGVNC99IJGz/zYURc14jeots+sVpKjP9Wzfb3Hjrkj/d0txeaOuiD7a7sEM 8zutwg/JuQuYiL/ExxO5zghiFonoiy9FxdeLtKUi46/slPx2WZGDd83daqAr8a3SALH2 SKpJczv9d1UFjaQ3/4hpi3uT0MnBsz8f7ub1nOmYwT2bul1NVk9xloV0xVsZX0sXZfWx /YLrL7faNLjG49VV2I9QkNB5aGy6J5NZ9mTqj5eMQUFfwBO+onZEtFUX2+Mrp5+dnqZ1 pKcygtPni9R1mXHz6v71de48owQWRogvrRJerEIpLY/4T7WQt5f5iGBSveuVFnqdCyWV 66hQ== 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=f1oHIKp+Xl1MtDR3jCF7Dp+Qm8VEDoGCEovuZWBlKwk=; b=DLyqPgO5KlUFGfj9Lc8+tDNwWIn+PrhmtsZAvETlHVgPKTh9+BepXDTUBzfXb1YEHp gw3ZK1wTl4gxz7oc/OFASgr3SC6BsqbOOdb2bXRN3MN+6pLcmLBTc7GWc8cdm8DC8acT aRmVhALNb2fL+N7Odmob4HZw8QI28uC4uwM1sJ9xGvpf5gEYnAjgjb3pUFW54Ehu3fqE +UX0/s8a5pQ40Odj4tSR+og85ld35VmZOSbOUFtyPUnT937lOEhq77g7iU+XnOEzCbZ6 oPggdcoq9/BnHPu65MMimzOwARN10xwE666ADLmsWXleZuoJQfEGMyFuvhyzZkg5ED6C RfSg== X-Gm-Message-State: AOAM531ozeW2DREafnv12nuotlOlD8uXVsOflc9sU9+aApE9Eb6s3Ojb TXXwfA84zKBHLG4CmK/yX2tWeEhRJ7TuYA== X-Google-Smtp-Source: ABdhPJwEOJ7OadWiiCZv5/lLsdk4wDT/US4qI/Jr7EnWPHLjrPEYmgM/ezRfSh6YVl9UWGHpdG0Kkg== X-Received: by 2002:a17:90a:db8a:: with SMTP id h10mr18903824pjv.58.1594621135806; Sun, 12 Jul 2020 23:18:55 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id 204sm13096371pfx.3.2020.07.12.23.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:18:55 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v4 8/8] Bluetooth: Enable controller RPA resolution using Experimental feature Date: Mon, 13 Jul 2020 11:52:13 +0530 Message-Id: <20200713062213.3692-9-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200713062213.3692-1-sathish.narasimman@intel.com> References: <20200713062213.3692-1-sathish.narasimman@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch adds support to enable the use of RPA Address resolution using expermental feature mgmt command. Signed-off-by: Sathish Narasimman --- include/net/bluetooth/hci.h | 1 + net/bluetooth/hci_event.c | 3 ++- net/bluetooth/hci_request.c | 6 +++-- net/bluetooth/mgmt.c | 52 +++++++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 3 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 4ff2fc4498f3..cb284365b4c1 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -307,6 +307,7 @@ enum { HCI_FORCE_BREDR_SMP, HCI_FORCE_STATIC_ADDR, HCI_LL_RPA_RESOLUTION, + HCI_ENABLE_RPA_RESOLUTION, HCI_CMD_PENDING, HCI_FORCE_NO_MITM, diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 684c68cb5c76..c8a5e1e4dba2 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5222,7 +5222,8 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, le16_to_cpu(ev->latency), le16_to_cpu(ev->supervision_timeout)); - if (use_ll_privacy(hdev) && + if (hci_dev_test_flag(hdev, HCI_ENABLE_RPA_RESOLUTION) && + use_ll_privacy(hdev) && hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) hci_req_disable_address_resolution(hdev); } diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index c3193f7f9ff0..cb44b83539e6 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -677,7 +677,8 @@ void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn) } /* Disable address resolution */ - if (use_ll_privacy(hdev) && + if (hci_dev_test_flag(hdev, HCI_ENABLE_RPA_RESOLUTION) && + use_ll_privacy(hdev) && 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); @@ -870,7 +871,8 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, return; } - if (use_ll_privacy(hdev) && addr_resolv) { + if (hci_dev_test_flag(hdev, HCI_ENABLE_RPA_RESOLUTION) && + use_ll_privacy(hdev) && addr_resolv) { u8 enable = 0x01; hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index c292d5de4dc3..fbe02ab5fa05 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -3759,6 +3759,12 @@ static const u8 simult_central_periph_uuid[16] = { 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, }; +/* 15c0a148-c273-11ea-b3de-0242ac130004 */ +static const u8 rpa_resolution_uuid[16] = { + 0x04, 0x00, 0x13, 0xac, 0x42, 0x02, 0xde, 0xb3, + 0xea, 0x11, 0x73, 0xc2, 0x48, 0xa1, 0xc0, 0x15, +}; + static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, void *data, u16 data_len) { @@ -3795,6 +3801,17 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, idx++; } + if (hdev) { + if (hci_dev_test_flag(hdev, HCI_ENABLE_RPA_RESOLUTION)) + flags = BIT(0); + else + flags = 0; + + memcpy(rp->features[idx].uuid, rpa_resolution_uuid, 16); + rp->features[idx].flags = cpu_to_le32(flags); + idx++; + } + rp->feature_count = cpu_to_le16(idx); /* After reading the experimental features information, enable @@ -3895,6 +3912,41 @@ static int set_exp_feature(struct sock *sk, struct hci_dev *hdev, } #endif + if (!memcmp(cp->uuid, rpa_resolution_uuid, 16)) { + bool val; + int err; + + /* Parameters are limited to a single octet */ + if (data_len != MGMT_SET_EXP_FEATURE_SIZE + 1) + return mgmt_cmd_status(sk, MGMT_INDEX_NONE, + MGMT_OP_SET_EXP_FEATURE, + MGMT_STATUS_INVALID_PARAMS); + + /* Only boolean on/off is supported */ + if (cp->param[0] != 0x00 && cp->param[0] != 0x01) + return mgmt_cmd_status(sk, MGMT_INDEX_NONE, + MGMT_OP_SET_EXP_FEATURE, + MGMT_STATUS_INVALID_PARAMS); + + val = !!cp->param[0]; + + if (val) + hci_dev_set_flag(hdev, HCI_ENABLE_RPA_RESOLUTION); + else + hci_dev_clear_flag(hdev, HCI_ENABLE_RPA_RESOLUTION); + + memcpy(rp.uuid, rpa_resolution_uuid, 16); + rp.flags = cpu_to_le32(val ? BIT(0) : 0); + + hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS); + + err = mgmt_cmd_complete(sk, MGMT_INDEX_NONE, + MGMT_OP_SET_EXP_FEATURE, 0, + &rp, sizeof(rp)); + + return err; + } + return mgmt_cmd_status(sk, hdev ? hdev->id : MGMT_INDEX_NONE, MGMT_OP_SET_EXP_FEATURE, MGMT_STATUS_NOT_SUPPORTED);