Received: by 2002:a05:7412:8d06:b0:f9:332d:97f1 with SMTP id bj6csp78804rdb; Mon, 18 Dec 2023 09:21:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IFgLOm8taz0jezpdSamJgZLglXMrKfmZoes3mrDlN7lQ+ymDLqzpozuOO+uJt1nKxuMBZdV X-Received: by 2002:a17:906:4113:b0:a23:690e:48b9 with SMTP id j19-20020a170906411300b00a23690e48b9mr557292ejk.54.1702920062138; Mon, 18 Dec 2023 09:21:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702920062; cv=none; d=google.com; s=arc-20160816; b=YHAs1KWfonPXbW0o2QrcYY3A1OhgYHz6s7SZ8ZBMGsvd0CHz+vtAaTf6toxQwWmIuD 9u7zKlc0gyhh4S9neo/riak+yQvsP4aqoNcVZiJ+oAkahS8ZNQmL2xKL1pUONrAfSijv gQSif1CigCnnHnPhwux/L3l9DG+pRjuXhs0FqSOpezGcSqfphtlfbVTVvnv7poi57fFZ +PmqYnN5VXCz9lOHiG6IemElvbwSe3gxEjmkoqWybXU7XRiEncgieg6fKjL/k27k9RM3 lkfEXvZxRdJMAk2WbNDIcgKQdnVHeWIW8c34LroNzDtoAD21gqHE/YRKtbDB9llFW+7R XI0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=CWGHhBD0WYd/cyCepEQ4R1KKPnNd5l8ZQ4xdlTL5+uA=; fh=D9exZMgC/jO6LogKZqGQTnGTULBpuh+GYZEyDZNL+3s=; b=oyetw2rs6XgHitGXJzutH8yetd6MJASk/t1iQHP93TnW9okNoBuyCaw0YC54fBF7Ci lWvTCnZUXhV2ruHyANAoNfAy0Q8s6kHFchwrOsyNXKJlT73ufg0qJsVpLJyM4HmqKVBY O63YtWXrMed+rzKcwzVEC/5l/bPcqZ7jb8BIa8nqhcBE3i+xGfgBQ5gvYXvyAPEfTi9f 4Pwmz7gPvWJntmZfIdMskUF7uPATTCHYE3nPoac9ajxwATHMPEu9rcme4KHbXMD+mxXa KRfkj/NC+LGFe1hW8zVf505+cOG6ktSuFRdIGaonzS/vo/2g8C9BIIpuK9FJ5d2nSRUD wvTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GTg5KNjp; spf=pass (google.com: domain of linux-bluetooth+bounces-646-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-646-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id k23-20020a17090646d700b00a23631d192dsi535003ejs.895.2023.12.18.09.21.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 09:21:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-646-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GTg5KNjp; spf=pass (google.com: domain of linux-bluetooth+bounces-646-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-646-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3C7331F23E7C for ; Mon, 18 Dec 2023 17:19:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 83BC75A852; Mon, 18 Dec 2023 17:19:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GTg5KNjp" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 635B94237E for ; Mon, 18 Dec 2023 17:18:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2cc7b9281d1so2512191fa.1 for ; Mon, 18 Dec 2023 09:18:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702919936; x=1703524736; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=CWGHhBD0WYd/cyCepEQ4R1KKPnNd5l8ZQ4xdlTL5+uA=; b=GTg5KNjpTy5fiooRROZQI133hjV5BfcNfMojMXpz/n767RqFv1OFy1HC2JKkw3evfm HHJasa/kO17Z73MlF9qr00sPAPzY4+583PATjc6OQT4GElIz7LE1G1BgNJGyGTKzTc5Z YULB+fc445ZJGe2ZHIbzGr++vHjpRfcs/SaQzuETuwcQKIA0YKK1CrLLr5+EAHlhoULy Vtv2OXaZEh28HR0ngJs3nXh4Ws8U2Wdj1dYbBPGUNgfSXjdVAONl1OiagvlDgXg+nFWR 3JsC0VX32K8ifQdZCAUAuqXPXJBSl05TzHllr3WVhUoZdu1ykgL3HZBC01mwNc9vOaLF Va4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702919936; x=1703524736; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CWGHhBD0WYd/cyCepEQ4R1KKPnNd5l8ZQ4xdlTL5+uA=; b=o0EKLHO5HchBRBGlu8+TJkQCjumH4DUP6cY5GKBP9blOcTBYA9OL0kJAx6UKp3QF3V kZaRBs5S50ueQ2gao44vPYx9x/lEHd5yl4dclf+wcbTznkxoUFr5CjnkPXpDmiP61XSH c/Jk5ikG6zhEi26v+JTiEEsYCyQDyIEoshP+q9PMNipk55Z9YM+pyGbQXCP7pLOwqJEG ZV25epyWjwPEJx9AYgTMszSJtVZKrjLDgP8o3gi8/xCeyqFk5yvOvPjNpTBAzPNqNkZT qjzwStcZxJEfSNVXa3nJD1FNz+Tyi0UGQZblRVrvbHcJIe9J2wRhxIoWgmtKObkGdn4T Jxlg== X-Gm-Message-State: AOJu0Ywj+38+5Ue8ZnlKLa3vbDuU6bx49jfACqGDRM1hw1HsrwewVp8D fih3Nxx8XNg9GkkDp7EGUq+PGGe4sphDUjviDZo= X-Received: by 2002:a2e:bcc9:0:b0:2cc:2b1a:57e3 with SMTP id z9-20020a2ebcc9000000b002cc2b1a57e3mr8646309ljp.88.1702919936163; Mon, 18 Dec 2023 09:18:56 -0800 (PST) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231217135012.1476534-1-xiaokeqinhealth@126.com> In-Reply-To: <20231217135012.1476534-1-xiaokeqinhealth@126.com> From: Luiz Augusto von Dentz Date: Mon, 18 Dec 2023 12:18:44 -0500 Message-ID: Subject: Re: [PATCH BlueZ] adapter: Fix link key address type for old kernels To: Xiao Yao Cc: linux-bluetooth@vger.kernel.org, antiz@archlinux.org, Xiao Yao Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Xiao, On Sun, Dec 17, 2023 at 11:21=E2=80=AFAM Xiao Yao = wrote: > > From: Xiao Yao > > Fixes: https://github.com/bluez/bluez/issues/686 > > Signed-off-by: Xiao Yao > --- > src/adapter.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/src/adapter.c b/src/adapter.c > index ee70b00d2..b4628a411 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -4347,7 +4347,17 @@ static void load_link_keys(struct btd_adapter *ada= pter, GSList *keys, > struct link_key_info *info =3D l->data; > > bacpy(&key->addr.bdaddr, &info->bdaddr); > - key->addr.type =3D info->bdaddr_type; > + > + /* > + * According to the Bluetooth specification, the address > + * type of the link key is not fixed. However, the > + * load_link_keys function in the old kernel code require= s > + * that the address type must be BREDR. Since the address > + * type is not actually used by the link key, to maintain > + * compatibility with older kernel versions, the addr.typ= e > + * of the link key is set to BDADDR_BREDR. > + */ > + key->addr.type =3D BDADDR_BREDR; We probably want to find a way to detect if the kernel is capable of handling the addr type or not, maybe attempt to load with it set and in case it doesn't work then use BREDR. > key->type =3D info->type; > memcpy(key->val, info->key, 16); > key->pin_len =3D info->pin_len; > -- > 2.34.1 > > --=20 Luiz Augusto von Dentz