From patchwork Wed Jul 1 10:04:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11635979 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 42A4A912 for ; Wed, 1 Jul 2020 10:01:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2B00D2074D for ; Wed, 1 Jul 2020 10:01:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qPIyk2MQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729486AbgGAKBF (ORCPT ); Wed, 1 Jul 2020 06:01:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbgGAKBF (ORCPT ); Wed, 1 Jul 2020 06:01:05 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E820C061755 for ; Wed, 1 Jul 2020 03:01:05 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id k71so7264505pje.0 for ; Wed, 01 Jul 2020 03:01:05 -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=XQsMIxXrDju3xAGiOt+lQ1c1a9XOuAjcFVyUXi9Jbzc=; b=qPIyk2MQ7xE5iit4ig06C+IlJAqBoFofUEB3fixTef2LJinF5BBVdOSZ32dvyDYGjA /cLvq91XC6c+wLfj+9998vpSRxamJ8YiDXeL8eVjTjhrlnVPcGDIs4zJ48oAWseaY1iG 6ANcNHxfgxoNW8oZe3Zozw821niCI/k/8b9TeGcj4FtzVneby7XuBiVfQk0eVSc5jZDB gjZ8KTzKxUFngKo7JmLtSutFfYT8gT4WgOKj7+qS51SGebMHSkhM7kiw1cmC+CHWRUfr +icEev1RiKhQwGqY4H1259hOL+lNaEluPwh8W64WGOWgV4b7c3vkuHhLG24R0zhvS9V1 ivSg== 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=XQsMIxXrDju3xAGiOt+lQ1c1a9XOuAjcFVyUXi9Jbzc=; b=o2+uMZYzSfzz/vIa80pbySq2BVtM+2elkVo88N/LoCeFIkiCM2FUQg+yGeLxPCOLId ycS4JaOVxJMURTBIlVx9cN8mQeh5JcpVAb7dOTgIYcsNS+d0ODbIRg3fNWz5M2pAE0IW UGnP5ABfnH2OVGMxiLBsXhoOl95KskyPkRh5nfqKNFdh+rML0103mXqLF9iy7vKEcYV4 oOyjKmYFQ/0esbRe/c12GhtQP1Aza9e1YHcTETUzKg5QbRuGWH2Am/ovWYqxVgVPwwxv ECE+1EwVLrVSBKy1d8lAzNaGKwjsinzJMPbWc9eUVrvWt4WksFy6BNKMtMI7xZodRlSK qD6w== X-Gm-Message-State: AOAM5316USq6PZocLzHVdwfeLHMTLvjAsKYEWl0Q+VBNqMltw/zAgtza /cvDSvfeXo7TYvnFw10yuXGyHXAooP6Cmw== X-Google-Smtp-Source: ABdhPJxeXuLH4fet/q2DK7GV3yM5Don8vOyea4yvctMPCuNcv4RaTPfj8DROHZBCfcNxxi5IR23YTA== X-Received: by 2002:a17:902:9309:: with SMTP id bc9mr22102673plb.232.1593597664642; Wed, 01 Jul 2020 03:01:04 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.43]) by smtp.gmail.com with ESMTPSA id d37sm5381961pgd.18.2020.07.01.03.01.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 03:01:04 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v3 1/8] Bluetooth: Translate additional address type correctly Date: Wed, 1 Jul 2020 15:34:25 +0530 Message-Id: <20200701100432.28038-2-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200701100432.28038-1-sathish.narasimman@intel.com> References: <20200701100432.28038-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 5577cf9e2c7c..604a411a9b8f 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3292,6 +3292,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 Jul 1 10:04:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11635981 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 A8CB4739 for ; Wed, 1 Jul 2020 10:01:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E92020747 for ; Wed, 1 Jul 2020 10:01:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hdiqcRc6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729671AbgGAKBL (ORCPT ); Wed, 1 Jul 2020 06:01:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbgGAKBK (ORCPT ); Wed, 1 Jul 2020 06:01:10 -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 77D7AC061755 for ; Wed, 1 Jul 2020 03:01:10 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id bf7so395861plb.2 for ; Wed, 01 Jul 2020 03:01:10 -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=yhFm8iVS8rF216LAKKaefGhuvOqn0g+HGfEb++sXEKQ=; b=hdiqcRc63sJZg87JBlBrYqCN/EuvRLRr0Q4xTHYcPEY9fft8NYzC2mYjSkPb0Qckuo Y0JTvEVd8gCB/G5u2kjcb2UuGtX1RIt6wKbw4JsPlFUig1okeouA/Xeo21DMwZrqg48C dh104Na4SW6oTFpa+TbntOVTraqSRcpvtGQ8TF/ffnA9qYg2wN+gpHo9U6D0UV4KnWk9 USuRhIWhUewFnDewVPLfnjEOe5s+tWWl1kjel0RDZrViNkR0ib6toF/9/qCZGUNWdSAX akfIJcyu4KqDEgRA4kYBuEmpXXGrUPL6YrIZ8NfPvkbQWNc0rk08bgqrXM+JcWq5Jy8G dg6Q== 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=yhFm8iVS8rF216LAKKaefGhuvOqn0g+HGfEb++sXEKQ=; b=pC++NKP8GJ+iDGTLawS5aq4t3Ze7NW+/mOqX9qJK5zqk4cbi2w82UZnIlJIW7pmJ3g gJGezxI50bYIMiqEGGqy+W0gqWvl45zbf4dRDwi1MxYNTR/DX/4PF3inMeL0BfUkXNTl 6MiBJw8csA91zObaU0VQXpvRcnLQjlQNbtvUqJ0FNOFhGXkd6vmTSYQjfFgAw76DDK60 wS0kwKuIte5+OsTQDtkcqxv7Z+q4aIMqI635ZIwLzPusFdshKsGdhNpwln4CKCjaf3yT WO1POidvXh/GCEqgfwjnn85o9i0so7d35kiPxft0g5XLkRnhwVZt6A7enSkib91vp677 fRfg== X-Gm-Message-State: AOAM53027R8/PEELBJj/UJiBK9ujHlpW+l8TV2Atl7cN6U2/59PCjjbs +d0OuHczDsCs/cTgDiO6s5OLSm2zHQYvCw== X-Google-Smtp-Source: ABdhPJz7pjDPMPwQk2aqCNZQcc80MO49nb4IBfUbOY0va6SS7YJlExR/vVF6IWntveQ/hYHOadll0w== X-Received: by 2002:a17:902:7204:: with SMTP id ba4mr20563799plb.250.1593597669730; Wed, 01 Jul 2020 03:01:09 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.43]) by smtp.gmail.com with ESMTPSA id d37sm5381961pgd.18.2020.07.01.03.01.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 03:01:09 -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/8] Bluetooth: Configure controller address resolution if available Date: Wed, 1 Jul 2020 15:34:26 +0530 Message-Id: <20200701100432.28038-3-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200701100432.28038-1-sathish.narasimman@intel.com> References: <20200701100432.28038-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 836dc997ff94..915f7a48bfaa 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1358,6 +1358,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 116207009dde..5978f9177b3d 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, @@ -815,7 +821,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; @@ -824,6 +831,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 */ @@ -897,12 +909,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"); @@ -948,7 +966,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) @@ -2747,6 +2765,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); @@ -2768,7 +2788,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 Jul 1 10:04:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11635983 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 3074B912 for ; Wed, 1 Jul 2020 10:01:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 19E0E2074D for ; Wed, 1 Jul 2020 10:01:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="J/GL13uO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729683AbgGAKBO (ORCPT ); Wed, 1 Jul 2020 06:01:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbgGAKBO (ORCPT ); Wed, 1 Jul 2020 06:01:14 -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 1C0B7C061755 for ; Wed, 1 Jul 2020 03:01:14 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id gc9so4272750pjb.2 for ; Wed, 01 Jul 2020 03:01:14 -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=AmvPW4v1t8mYI78mS127zBVBOMVhLn3jVVhr+y7gx+4=; b=J/GL13uO37fsfo/YLPOhh6CluFhyg3ONCqjCal+Y127YZd95FXn/NnfZk6goc8iczP iZeaM1PlJQaHxhhHqcdouA9hOPPIqt1jQQT/SB2pUAY2El8obZYHelzhQ1L1YBm0k8UE 5Fe1iD/jMx8qwxttwd8YU6ll37AzWaTNcUgn5Am/0oZqB2HIwbWnwQ+2mpVZOJ8+Z8h/ sgSpvn30RGQtFK/6Rtc7WAdsBlVqLK1zMFwFk0N03C35nMZGxoqOqxRAe7wawGf2DRmk O771KfW5wKekafGYw7IJ6H5IHcgfytCh2w8bYDM9OViuRTeUTi+mF+uljpIJQdcCP2Jb 8Hww== 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=AmvPW4v1t8mYI78mS127zBVBOMVhLn3jVVhr+y7gx+4=; b=hjEEyj5i1lvGQR6Vs8GMvsYMgdA3fJ+XyYeUjzwF4Xx7FsGBkEaNZUEMm+S/TfjEc1 G0RkYGxuc/PqAdx6i++N96CyT4cEtZH3RKva2UcqolG3amxPQw17bJ7LSu9RDpIQ/cva QuBxDoXq8qMGJk68vMhZsIj3mHMBCCTOzp85NrGkcYrtyAssMPuLgOSXmoTel7/M9xOK Tqf3Wkzm5cY5C+MnDbhNXBDXoXovCdtWxhjZ1nAVnj8W+UA3j/0azCYb//q/XU/f8XVH 1HE+tLAsoohQd3vAaZiyLj6HQDvE0L9hbwWqWGryos79oS3R8lqKbU66qUgcrV9Kpues Ip5g== X-Gm-Message-State: AOAM532qJS9QKo7q3UVm6L0OwfNz0hjNFF/p+5XYAqBNaYsntu6VbNdc KMhSJdOwrMlhnHcyPQZaL9TaTEqzM62Cqg== X-Google-Smtp-Source: ABdhPJxuYu3xiadLfkFpoOWQ+teaogD4zTLxCsfxU++1RMK3odcmqoIrm32A7ONexAhHcjHYyDVODA== X-Received: by 2002:a17:902:b18b:: with SMTP id s11mr5705538plr.152.1593597673438; Wed, 01 Jul 2020 03:01:13 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.43]) by smtp.gmail.com with ESMTPSA id d37sm5381961pgd.18.2020.07.01.03.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 03:01:13 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Sathish Narsimman Subject: [PATCH v3 3/8] Bluetooth: Update resolving list when updating whitelist Date: Wed, 1 Jul 2020 15:34:27 +0530 Message-Id: <20200701100432.28038-4-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200701100432.28038-1-sathish.narasimman@intel.com> References: <20200701100432.28038-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 5978f9177b3d..622016287628 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 Wed Jul 1 10:04:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11635985 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 266BC739 for ; Wed, 1 Jul 2020 10:01:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0DB192073E for ; Wed, 1 Jul 2020 10:01:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f7uURM5y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729689AbgGAKBT (ORCPT ); Wed, 1 Jul 2020 06:01:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbgGAKBS (ORCPT ); Wed, 1 Jul 2020 06:01:18 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33437C061755 for ; Wed, 1 Jul 2020 03:01:17 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id x8so8822491plm.10 for ; Wed, 01 Jul 2020 03:01:17 -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=SiGWJykKRUEpwFqa25J4j/wcmszxEYFYY2Kihm0MUu8=; b=f7uURM5yqevpDA2KH5B6wkuUNNejZsTKOoudMOcwSrTbp9uqtfea0vtdtaJ4XCihwE YnRCaZrjE+Tff5LJn8M/EfcgFXvLjgF8MLSsaJ1PjT25z5iCaCXLACKFmYEjefyuXKWm 70RTNFZaJ7BFGjub2ivy6vRFIJadDWFV8ndaU3+0eNtMSHsUG136lBJTjocx0SsLOu0I GhXzpfv3vArKUE8AoCwUf7yv/crxahkF6ogmqOhNKNAdNeTvzhM1cGUDh+Syn8npHwd+ y9dk6iN1wAW7/6Jf/rl5nexwz7XjFtL7/iO0I6CY9C8j9iKVuPLOp5m7UNuqFFT/9WIg 6eZQ== 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=SiGWJykKRUEpwFqa25J4j/wcmszxEYFYY2Kihm0MUu8=; b=q+/4uFQauWxhyk6QSAMSakGSnGFDS25siFtlBZ1wXmsJXgqNz4dam8CERRUIos0dkO mIP92ctjkMmQWtFwWBhZXxh++x1/dDzPQbacGdF4IaXU3+zTibBhvhstemwl/LeM7gjA ecJtyp+yYfRK7qbSRf6lJHFp9RSCLn5f8j3UB5CEBN3d5FF3fAONFBLZBO92SMJUoD2w UEjeLw+MX20/uGSkyYp99MxkWeNoPVUnSrhcNe1ejAdIgiyynsLyjugO5QHVJcUlrC37 +xSBbTFKcLPp+8waH8gUb7uD9F1MPL6uuieZjBD8YH4wD0qDL5OquTWxitdFZ1fO1AD+ g2xg== X-Gm-Message-State: AOAM533Q+Q8SjA8hcZq0dV9BMxalA+GWH8gc55tEhdr198GH03ajoppH GQf+WX+cwaetStQAFJGjj/UFd0hDknmZMQ== X-Google-Smtp-Source: ABdhPJyUvdacwJjPCU1dUiJqroxQse9Zkqz+wDNuAnasVH5jODG1XQSYH3iFrE646ihnscEq/gU6Mw== X-Received: by 2002:a17:90a:26a4:: with SMTP id m33mr6814342pje.124.1593597676371; Wed, 01 Jul 2020 03:01:16 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.43]) by smtp.gmail.com with ESMTPSA id d37sm5381961pgd.18.2020.07.01.03.01.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 03:01:15 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v3 4/8] Bluetooth: Translate additional address type during le_conn Date: Wed, 1 Jul 2020 15:34:28 +0530 Message-Id: <20200701100432.28038-5-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200701100432.28038-1-sathish.narasimman@intel.com> References: <20200701100432.28038-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 e060fc9ebb18..592ef5dda3ab 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 Jul 1 10:04:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11635987 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 78964739 for ; Wed, 1 Jul 2020 10:01:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5FD612074D for ; Wed, 1 Jul 2020 10:01:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PG4tVNAm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729716AbgGAKBV (ORCPT ); Wed, 1 Jul 2020 06:01:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbgGAKBU (ORCPT ); Wed, 1 Jul 2020 06:01:20 -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 5D199C061755 for ; Wed, 1 Jul 2020 03:01:20 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id x11so9711636plo.7 for ; Wed, 01 Jul 2020 03:01:20 -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=ZfCBwWzszt0wp19IOQjQbWYB7ZUb16MS4aRNucJyhyI=; b=PG4tVNAmrYY6eQRIYWaffh3ohZNEpAr/1AHTsZTtAefCoamTRGLx1MM7XVIQcOBLfr vQdLmfN6Dyre2fXtb9+SuCWxUY+uDNPoZxhtdGKNVkkujDlZNSyLgsul6k6sC7nVcImV dIBtGFBw/ebHd7klghTjkGudMbAPIJilsLqnlA7UxhdMBsD4dI4cyfBDqb5H/LYpqQEW y3fCZWQZ8o67UqdKjEW3hjshjFaC4Gklxu3OnVpWC4JAQkZ0FqrRsj3o2LC/fM5F1tD8 H0IBApfv8hzPef4jUvZwnkRKwBvqUXWLS4vFaX6AaUrwa4Ap0y/ODO7neL7sRgg2hlEE oNBg== 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=ZfCBwWzszt0wp19IOQjQbWYB7ZUb16MS4aRNucJyhyI=; b=DsnjCnu7cg0a/MUTkBsmwFdM89PYRu2MEuEXhcGlN27a+hTNjcwjKUZ14puNCq6zbr ThQ9G79JxMH7yLa8MYDbmv1z0ZY1tSExwpr7eA0xc29BUY7Myj1ysHNP8i4w7Ly8vcRm /ndfXj2abgChkYfihLV6qYjbAQ5JkQ3Uh7oiyUcIn8XVsHcUpsxFpmUHbt1OjHjgSc7n k72W2L2kujbOVOtAbN19ieM2Jgc9BEyYQ16hGfG9vC86d7y1P0brUUEfTNF+2elE03JP 1shb8QqkMejWg0tYegXHoSxb1m/7G0FFsCkouDFosPBraKOwNFECsh8LfIijvcU+dG2T yUBQ== X-Gm-Message-State: AOAM532FJTfwV8m+uBmM1Q2fTxNRbqu+wF27k39UIlpIrlq6FDecPiNP gXfTMNuwBp40LPzIAHGoyjThJZFyoI5CSg== X-Google-Smtp-Source: ABdhPJzKEsybwvFlzN+HoJvW9b9lD5678LZfi6sECRNqybPbiruESbcTxfId5jWVksMvWjmjh0Ggiw== X-Received: by 2002:a17:90a:ce96:: with SMTP id g22mr6851044pju.9.1593597679527; Wed, 01 Jul 2020 03:01:19 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.43]) by smtp.gmail.com with ESMTPSA id d37sm5381961pgd.18.2020.07.01.03.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 03:01:19 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v3 5/8] Bluetooth: Let controller creates RPA during le create conn Date: Wed, 1 Jul 2020 15:34:29 +0530 Message-Id: <20200701100432.28038-6-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200701100432.28038-1-sathish.narasimman@intel.com> References: <20200701100432.28038-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 622016287628..906721759c2f 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -2200,7 +2200,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 Jul 1 10:04:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11635989 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 6AD48739 for ; Wed, 1 Jul 2020 10:01:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B1D12073E for ; Wed, 1 Jul 2020 10:01:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UbYLHpQG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729769AbgGAKBY (ORCPT ); Wed, 1 Jul 2020 06:01:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbgGAKBY (ORCPT ); Wed, 1 Jul 2020 06:01:24 -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 4CE90C061755 for ; Wed, 1 Jul 2020 03:01:24 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id o1so3147050plk.1 for ; Wed, 01 Jul 2020 03:01: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=zJ2QpfO712U6ML1rl/3l7HQWUfo4RwY2Ra3Gjw2SIQM=; b=UbYLHpQGvfzsHOhj+sqEBJEbV4AEfMdA4TwWbBSk5G6f0mm5nOizgFIVG35TTlAyfq sQeXIku/xq+pKltA59QBbMqxWXWS1zwymqbZCjCYheHEgTD+dv632g7wy5zK6t6UsaVt vEy4rE1hcpPooQ5ORc8X0ALXfJhhYOTaYQ9m+xDFf5Tx0x9y0Oyb7OB+7sG2j1r3CO1B /MHwYkup9EZL3fAbqRFWUu1Uwehoc/5sa+DPfqqq21jyWruwYO+osdANblmI3qyVIiRc Jlr2kstV16LlC1VWpa1tNMZimoqjCIeaa9IDyrf3Sq4t60dTwE2WnB25OoCJJAzD6WLB WcxA== 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=zJ2QpfO712U6ML1rl/3l7HQWUfo4RwY2Ra3Gjw2SIQM=; b=kHEej3PKPBPCDpEz3Bc41ectxugF4B2OJ9rQaVpowXf3JgE2jx+L0YoMnWPqPzB3Uw Fn68q3he3JDRFCVGrvt316FgNSpu7zR1uqvV4t/gKNCTRx23uGpo3gkJNpyw4Mv/VYn0 MINtXxGMr6+djaGInUMLW0sLgbV3N7hlC5vRHAV1je2H53fMHljFeW+Zkxvv1hHkIGaq bSgyAwMKaapkfRKcpIzUbP+d+Rsv3XicwGRZXvls/sOycdAbAqroIZ3/DnfcmJWBYJBa uCLGMTbFeZzngUOusmFCCu9ilZNaJvck7BcMrtcyNwd8JK6QNGZXZpycdSj6RhMRFTCB Y0pw== X-Gm-Message-State: AOAM533xopQlzuQx37O+QN6mFYw0Jlc6Kptt9HUuJ0jiRMTwXa3LR/9f iCX6adWxpk2yCMMQ+j6DKzD+jWV/KuT1rA== X-Google-Smtp-Source: ABdhPJzVYm5C1xkGzoWc/dD359XYRJgvAXQ7ihhg9fERom3YSneeWtglAgZsr80eGiSM9o2mQMbLWg== X-Received: by 2002:a17:902:9a4b:: with SMTP id x11mr14305418plv.150.1593597682865; Wed, 01 Jul 2020 03:01:22 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.43]) by smtp.gmail.com with ESMTPSA id d37sm5381961pgd.18.2020.07.01.03.01.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 03:01:22 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v3 6/8] Bluetooth: Enable/Disable address resolution during le create conn Date: Wed, 1 Jul 2020 15:34:30 +0530 Message-Id: <20200701100432.28038-7-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200701100432.28038-1-sathish.narasimman@intel.com> References: <20200701100432.28038-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..8d762567ea16 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 592ef5dda3ab..47a4050462ed 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 906721759c2f..0dc587026753 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); } @@ -1071,7 +1072,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); @@ -1139,7 +1140,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); @@ -1700,6 +1701,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); @@ -2625,7 +2648,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; } @@ -2728,7 +2751,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; @@ -2819,7 +2842,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 @@ -2933,14 +2956,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 5e9b9728eeac..65d93a38e5b3 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -5205,7 +5205,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 Jul 1 10:04:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11635991 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 00089739 for ; Wed, 1 Jul 2020 10:01:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA79220747 for ; Wed, 1 Jul 2020 10:01:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IQpaKIjk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729721AbgGAKBd (ORCPT ); Wed, 1 Jul 2020 06:01:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbgGAKBc (ORCPT ); Wed, 1 Jul 2020 06:01:32 -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 C1E50C061755 for ; Wed, 1 Jul 2020 03:01:32 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id f16so433651pjt.0 for ; Wed, 01 Jul 2020 03:01:32 -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=vkjx5T9Sq5IYIs+S7efhCR5KF66qOJdP9PWteN5i6Lo=; b=IQpaKIjkCKXiUJiPwiiS/vQiL0VViTB8EJ4zSEitaRCCIv1GmJZO0TvqeIiwjZSxA+ aUEHwJXYWc+TvF0abTyLbPr/HrdA0yMVgzfabd4nZqJizQnLd3GMAJSk9k55gJ324pQV lskhYX3IP58lwLaQOyryQluWrCk5hMbDO4reJzhlgUeEjke5Ia0dR5mceMDUYjS4jRkI h5QqsUVFyTmRmbW4wtF9+LVmWO6J1YjqhCaBLsLRrA+RwXZDtJ7tDWKWBCfI4D3nFbOo GwufLsMnn1nYOofrnuF2TeFo+iEHvopeqVst+QCZfICd0pSbU/IVmbYE5QVoRG81DNou /E7g== 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=vkjx5T9Sq5IYIs+S7efhCR5KF66qOJdP9PWteN5i6Lo=; b=lLNEYaZDl8Qlv3Pr3kVz2vG4HO+n7iX49BBcq2CBWrSuqAijeAgVXvJdJwN4sUKyuv Oy1FRuCTYZUJPI71yZxT+VRqil1kkxuC7xO/J6LnEBZQeVybFvbJQ5rLoUWheJV3GZbV X+yY1B+NpVX6WjgxwqgzONAkmmpGQex/atkdREvF2l2NL35TUSM5/oONJobL8c3GOFCK NKmAGDjE+bMfYN4wC65DrxxJYfwy8OSdUJ173ZQiFG1iaO65g7jHGd6Hl2DdO7T1Quda VqTPHWLZRKvA/CisMCYQG4rL6AhpBEMnUOAw4v7yrJfGPIrE8KAoGPvUAtRyIVtbiVHY WBlQ== X-Gm-Message-State: AOAM5314HzO2Tc5JaOAA3LgSBr9+WDZOd2ZRhBFyoDZL5xlWhA+S4dnA n0kzyANRx2ijgFz2huJ5Gk/5s9Blg6AJDA== X-Google-Smtp-Source: ABdhPJyFe2XHAKYJmO8+Lc4E1rTPDNDtHKOjbaEjlnvDZpcVm7aDpeMsMuHCKY/CG50ryTaCyfEY5g== X-Received: by 2002:a17:90a:e602:: with SMTP id j2mr23767397pjy.200.1593597692090; Wed, 01 Jul 2020 03:01:32 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.43]) by smtp.gmail.com with ESMTPSA id d37sm5381961pgd.18.2020.07.01.03.01.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 03:01:31 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v3 7/8] Bluetooth: Enable RPA Timeout Date: Wed, 1 Jul 2020 15:34:31 +0530 Message-Id: <20200701100432.28038-8-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200701100432.28038-1-sathish.narasimman@intel.com> References: <20200701100432.28038-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 604a411a9b8f..b496d5395bd3 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 Wed Jul 1 10:04:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathish Narasimman X-Patchwork-Id: 11635993 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 81302912 for ; Wed, 1 Jul 2020 10:01:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 60AF72073E for ; Wed, 1 Jul 2020 10:01:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Twp2rHZ5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729772AbgGAKBh (ORCPT ); Wed, 1 Jul 2020 06:01:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725440AbgGAKBg (ORCPT ); Wed, 1 Jul 2020 06:01:36 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 749FFC061755 for ; Wed, 1 Jul 2020 03:01:36 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id e8so11479848pgc.5 for ; Wed, 01 Jul 2020 03:01:36 -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=Tofe5K0oXmYz1C+QMUjX7aijC98yv1W6QBb5sW/j1KE=; b=Twp2rHZ5iwjWizLno7mIZY8KPEPwttjiFcf2vnx4Nj4Gw6UH6yHG4vKuOIPwQ6dde4 ll2dzkEDsW3Vl3KpcP8FK6R/WvOPgkmA5nx8JLNiGtxv8evU/PD35u2qNEvM9H8thNdj nvdy5YXyReu32zkZO0Iva4/SbWvvRkk90IDd2heOd0dZkJUa4IE82BeXjwqk+PVpOwmv rlrse0CHYldXXW3Vf4Lv5iGgYUQ6EWpW9lPTReAX60ErpuxwI4dgI5E17ZdpIk0+LR3C f7ZvxXXbpiOdwgTJoMwDSUytFwwGNMZEctoPFq/YlXqLMyc/ObDHrCw8JQLtUKWlp5UR u6mA== 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=Tofe5K0oXmYz1C+QMUjX7aijC98yv1W6QBb5sW/j1KE=; b=NN2ABA3cL6SBwVcBoeNh/c/CkjZ8ddf2WyZg8AcjPM2FWDkPGuX9xGshc37wE+FLLA OEZ8aPKODWF/FHwnhKyRqB8C9vpUEDMSs13sObw3xKiPB6SYluMdf2QANxoFqX70EZNi ok/aOSGKhMLcjI2cYOY9GkEQSuTHGCoxeU10LI5pzxWVZ7vKyPlMDqML9gcm7sGkS3RO Utq6kXR8xSLrJn7uyQA2OtCi137VZrG+KovMdddIj5nM681vkRHWYaCUb+StN5XdJdeb dvy+QWxkP39niARl93tuOs8jira+OP6aIcTRni4T2e7Ti1/C1VXgJuh6wPaZXVkBNiF5 bopw== X-Gm-Message-State: AOAM5302LFOOfY3StHLlbEkjU7uQrmuX9qe58tKT0f+EHRKlSudKDxKC Ba9q+3O4cLbyKM7QZdiRXtCAOIkjG1MGeA== X-Google-Smtp-Source: ABdhPJxmBmgJhpRJEGupfI4CgEleUolgb6zw7Q2qQncK/TwtxLFicyJWMAFJszLrQ6EmmeGT1+y9cQ== X-Received: by 2002:a62:195:: with SMTP id 143mr16252194pfb.226.1593597695503; Wed, 01 Jul 2020 03:01:35 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([192.55.55.43]) by smtp.gmail.com with ESMTPSA id d37sm5381961pgd.18.2020.07.01.03.01.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 03:01:35 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: Sathish Narasimman Subject: [PATCH v3 8/8] Bluetooth: Add support to enable LL PRIVACY using set_privacy Date: Wed, 1 Jul 2020 15:34:32 +0530 Message-Id: <20200701100432.28038-9-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200701100432.28038-1-sathish.narasimman@intel.com> References: <20200701100432.28038-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 LL Privacy using mgmt set_privacy command. The privacy value 0x03 is used here to enable LL Privacy. Still to use LL Privacy controller support is must. Signed-off-by: Sathish Narasimman --- include/net/bluetooth/hci.h | 1 + net/bluetooth/hci_event.c | 6 ++++-- net/bluetooth/hci_request.c | 15 ++++++++++----- net/bluetooth/mgmt.c | 6 +++++- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 4ff2fc4498f3..2a42c7ceabb2 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -286,6 +286,7 @@ enum { HCI_SC_ONLY, HCI_PRIVACY, HCI_LIMITED_PRIVACY, + HCI_ENABLE_LL_PRIVACY, HCI_RPA_EXPIRED, HCI_RPA_RESOLVING, HCI_HS_ENABLED, diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 47a4050462ed..589bac9859ce 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -2301,7 +2301,8 @@ static void cs_le_create_conn(struct hci_dev *hdev, bdaddr_t *peer_addr, * converted back into either public address or random address type */ if (use_ll_privacy(hdev) && - hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) { + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) { switch (own_address_type) { case ADDR_LE_DEV_PUBLIC_RESOLVED: own_address_type = ADDR_LE_DEV_PUBLIC; @@ -5223,7 +5224,8 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev, le16_to_cpu(ev->supervision_timeout)); if (use_ll_privacy(hdev) && - hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) hci_req_disable_address_resolution(hdev); } diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 0dc587026753..e1c2e2c13456 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -678,7 +678,8 @@ void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn) /* Disable address resolution */ if (use_ll_privacy(hdev) && - hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn) { + hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) && !rpa_le_conn && + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) { __u8 enable = 0x00; hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); } @@ -696,7 +697,8 @@ static void del_from_white_list(struct hci_request *req, bdaddr_t *bdaddr, cp.bdaddr_type); hci_req_add(req, HCI_OP_LE_DEL_FROM_WHITE_LIST, sizeof(cp), &cp); - if (use_ll_privacy(req->hdev)) { + if (use_ll_privacy(req->hdev) && + hci_dev_test_flag(req->hdev, HCI_ENABLE_LL_PRIVACY)) { struct smp_irk *irk; irk = hci_find_irk_by_addr(req->hdev, bdaddr, bdaddr_type); @@ -748,7 +750,8 @@ 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)) { + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) { struct smp_irk *irk; irk = hci_find_irk_by_addr(hdev, ¶ms->addr, @@ -869,7 +872,8 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, return; } - if (use_ll_privacy(hdev) && addr_resolv) { + if (use_ll_privacy(hdev) && addr_resolv && + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) { u8 enable = 0x01; hci_req_add(req, HCI_OP_LE_SET_ADDR_RESOLV_ENABLE, 1, &enable); } @@ -2226,7 +2230,8 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy, /* If Controller supports LL Privacy use own address type is * 0x03 */ - if (use_ll_privacy(hdev)) + if (use_ll_privacy(hdev) && + hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) *own_addr_type = ADDR_LE_DEV_RANDOM_RESOLVED; else *own_addr_type = ADDR_LE_DEV_RANDOM; diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 65d93a38e5b3..c1106d97e3a9 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -5652,7 +5652,8 @@ static int set_privacy(struct sock *sk, struct hci_dev *hdev, void *cp_data, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_PRIVACY, MGMT_STATUS_NOT_SUPPORTED); - if (cp->privacy != 0x00 && cp->privacy != 0x01 && cp->privacy != 0x02) + if (cp->privacy != 0x00 && cp->privacy != 0x01 && cp->privacy != 0x02 + && cp->privacy != 0x03) return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_PRIVACY, MGMT_STATUS_INVALID_PARAMS); @@ -5674,6 +5675,8 @@ static int set_privacy(struct sock *sk, struct hci_dev *hdev, void *cp_data, hci_adv_instances_set_rpa_expired(hdev, true); if (cp->privacy == 0x02) hci_dev_set_flag(hdev, HCI_LIMITED_PRIVACY); + else if (cp->privacy == 0x03) + hci_dev_set_flag(hdev, HCI_ENABLE_LL_PRIVACY); else hci_dev_clear_flag(hdev, HCI_LIMITED_PRIVACY); } else { @@ -5682,6 +5685,7 @@ static int set_privacy(struct sock *sk, struct hci_dev *hdev, void *cp_data, hci_dev_clear_flag(hdev, HCI_RPA_EXPIRED); hci_adv_instances_set_rpa_expired(hdev, false); hci_dev_clear_flag(hdev, HCI_LIMITED_PRIVACY); + hci_dev_clear_flag(hdev, HCI_ENABLE_LL_PRIVACY); } err = send_settings_rsp(sk, MGMT_OP_SET_PRIVACY, hdev);