Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1755350rwb; Fri, 7 Oct 2022 18:31:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6QjvM+xk1KtcKrkYOVdyzeb+iYxiLJa7hRhpFlPZwSe0yYwy/zgq217JnLswWPQcbSqHPz X-Received: by 2002:a17:906:4fcc:b0:782:e248:c8a8 with SMTP id i12-20020a1709064fcc00b00782e248c8a8mr6144445ejw.717.1665192666799; Fri, 07 Oct 2022 18:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665192666; cv=none; d=google.com; s=arc-20160816; b=eV3UNwzwE1X8hcDbs23s2k0FZ/66MCF4l7gu3pbgh022be8FJXTb2ja7lrcohaAlmn p9LMJfluBb7DgEev55Y+jZt7KjlnYW+sd8aPa24j8qkepYXuO7MQEf1tBOHRBImCHWJ1 y+KskpM++o7YByYn3uUVsvwSx4KrLQvUXGviuq/yeCUqdvbiKKUUtxP5Z0BIxS294Koh S0j9aXLA+reGDLZ1CP50idR1BsbhLCJ74ICtglHwJ6YBP3MLd/JqGVB9dqvLiR9nQ6Pe M1V1CJKg24ax5theOkXUsrDI7fj/DLRfSNtPByXT81E4ykhqPy1twbj9w0mh3VOGZrPa TlJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=9LouFIjt6eyVIB3skK9CrYX6MidIDEaMX8AY8SOHiN0=; b=qVxlx7z80rTT7Rx+Sq1nHjRSv92sIoE3k2H4PjaSE9+VYw2mX8FRNcPGji8BAAEem3 LIFFUS44esywuTl3OB3YdYiwLOy2Rl5EYES2TOj1Z/HKznPa4cNu1A2cwNu7A7PUn6fD EOSdN8MexPkA3TDMNDCHDJ4JgmS/754/Mwiup9UvSrZV0nbO9Pk7b4aOm3VeE6Eny+nD G0dv1v66C8SxhHn8gUMZzFETqjBe5ZDQbDAZbjGilgHRSOOmjqZiEIDG8+zZyYM9oA/f CzljIhirk3WhIbAhCyQ958y0Ujp3BkSymxzkzZmsOHT+Jk9dhvkyFgZCfbs0L3E82hn8 FYfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BYSpjKcM; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d21-20020a056402079500b00457e9f88b90si714720edy.246.2022.10.07.18.30.40; Fri, 07 Oct 2022 18:31:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BYSpjKcM; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229544AbiJHBLi (ORCPT + 99 others); Fri, 7 Oct 2022 21:11:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbiJHBLg (ORCPT ); Fri, 7 Oct 2022 21:11:36 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B069EB48A6 for ; Fri, 7 Oct 2022 18:11:32 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id r18so5970420pgr.12 for ; Fri, 07 Oct 2022 18:11:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=9LouFIjt6eyVIB3skK9CrYX6MidIDEaMX8AY8SOHiN0=; b=BYSpjKcMP6d9MzGuur2Jp5wFfSOSVVgIc0gUo9aPvKE714GLvblQFrRYa/WFEwhivK Y5luaDydH6zZIx3TFslUKrFcL4eLF0YxQDcU+Bt4CoeXPaVhMU/Tmz/T3433e4s4niGe pGaduNv64yW2vZDW9pmuVbIymXcwpgQ6mg2PPXKGjlRLtVUkssWgVdMKgnMi46NisfbN /+osWE3d/7hlDevq0EsXfaupDVAFHNzsuY81msp1lDxzzqRsQRPCJlkTjVVpvSu7/uZi Doa7LIQ6DjseIqN9reeNDZlK4bIik/7D38RUjdV1TsEddhrXV7R+6c53xCQB4/VwrY+7 Pz1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9LouFIjt6eyVIB3skK9CrYX6MidIDEaMX8AY8SOHiN0=; b=5g86Xft/SjCsWh5wTjF4Py1vuROZLWNuyDlKSH+yUOMQBrt6aFTeQjDNzps7Deh0Kx bQdtjsyXJVRWCtlhGoCT1qixZGpyap7+btzmhgZZqhnRoZZk+2rJ6Rsmtb+Ud3cdfg/s XkYyAT+6CC5X1DNtHduOAiQQVphs08EIqjREPaW/DzeHtI1WodR4kcBZCoSGAaOiWWg0 yx9BjLGm6eyWHjWYPeBnl3WnU32IQvniVDA/3inI8pwXjh6GWdgeDlf9PVeVtJVySWq0 mo78jtz/0VpmllGyiThadOutqECsg471EmN26pFj040TbO2VHPkfmgALbFfypuyFYQY1 N65g== X-Gm-Message-State: ACrzQf1Uh20d5i+2zaCgu1lEXPQEv4LRLd2Jxl3DTNSmd/hYWL6KYDRI Nyu3GrDbJX/t1xLORXqUsKXLkThyVCMMGw== X-Received: by 2002:a05:6a00:a96:b0:558:8915:2f0e with SMTP id b22-20020a056a000a9600b0055889152f0emr7776414pfl.38.1665191491673; Fri, 07 Oct 2022 18:11:31 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id h187-20020a62dec4000000b0056158a41d74sm2234123pfg.58.2022.10.07.18.11.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Oct 2022 18:11:30 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH 1/2] Bluetooth: hci_sync: Fix not setting static address Date: Fri, 7 Oct 2022 18:11:28 -0700 Message-Id: <20221008011129.1906898-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This attempts to program the address stored in hdev->static_addr after the init sequence has been complete: @ MGMT Command: Set Static A.. (0x002b) plen 6 Address: C0:55:44:33:22:11 (Static) @ MGMT Event: Command Complete (0x0001) plen 7 Set Static Address (0x002b) plen 4 Status: Success (0x00) Current settings: 0x00008200 Low Energy Static Address @ MGMT Event: New Settings (0x0006) plen 4 Current settings: 0x00008200 Low Energy Static Address < HCI Command: LE Set Random.. (0x08|0x0005) plen 6 Address: C0:55:44:33:22:11 (Static) > HCI Event: Command Complete (0x0e) plen 4 LE Set Random Address (0x08|0x0005) ncmd 1 Status: Success (0x00) @ MGMT Event: Command Complete (0x0001) plen 7 Set Powered (0x0005) plen 4 Status: Success (0x00) Current settings: 0x00008201 Powered Low Energy Static Address @ MGMT Event: New Settings (0x0006) plen 4 Current settings: 0x00008201 Powered Low Energy Static Address Signed-off-by: Luiz Augusto von Dentz --- net/bluetooth/hci_sync.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index 76c3107c9f91..b53bb0ee9d39 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -3054,6 +3054,7 @@ int hci_update_name_sync(struct hci_dev *hdev) * Enable Authentication * lmp_bredr_capable(Set Fast Connectable -> Set Scan Type -> Set Class -> * Set Name -> Set EIR) + * HCI_FORCE_STATIC_ADDR | BDADDR_ANY && !HCI_BREDR_ENABLED (Set Static Address) */ int hci_powered_update_sync(struct hci_dev *hdev) { @@ -3093,6 +3094,23 @@ int hci_powered_update_sync(struct hci_dev *hdev) hci_update_eir_sync(hdev); } + /* If forcing static address is in use or there is no public + * address use the static address as random address (but skip + * the HCI command if the current random address is already the + * static one. + * + * In case BR/EDR has been disabled on a dual-mode controller + * and a static address has been configured, then use that + * address instead of the public BR/EDR address. + */ + if (hci_dev_test_flag(hdev, HCI_FORCE_STATIC_ADDR) || + (!bacmp(&hdev->bdaddr, BDADDR_ANY) && + !hci_dev_test_flag(hdev, HCI_BREDR_ENABLED))) { + if (bacmp(&hdev->static_addr, BDADDR_ANY)) + return hci_set_random_addr_sync(hdev, + &hdev->static_addr); + } + return 0; } -- 2.37.3