Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2401551pxb; Fri, 17 Sep 2021 08:59:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBEgrbQFbtk3DCCftjojE5NWf8FIBoWOQb9HJWMs89IlUABIJRSFPlvf+aH78eVzk/6G2t X-Received: by 2002:a05:6402:358f:: with SMTP id y15mr12857648edc.67.1631894385727; Fri, 17 Sep 2021 08:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631894385; cv=none; d=google.com; s=arc-20160816; b=jT6JGHhuGg6S9L+6lZLmuTbKjokU4+cWPRk//+qU0T3qJ/1ifAHApzZ+zMN+IYSzie HcF7GjHxIzpafKGCbJk5ujGOC9+ZB8odgkSjDSRR5YmW08h1UyDLwUMkIp4jxWeFrh5F 98T+3xBrNR19Xh/t36De2m8q+P0Pj5k+55eqOr4Fe9EXB97b52bkmCTQcoSs1ih1SWSc nJILFkx3sgEA6K8PjoFVruajoS+staxPxFEAIRgLAvt8yfct4u210i2GdFGKxLr68iML 1pRCLNkOTXULqnxF3Z7/5/2Nk2QJELCaOzhI685ki+GW+i9i3IyWJoBmAoOWAajtQ37m Kakw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=1msLgxMuoUYRkSqjSYW1EJkXemcrpwMnFdbysKXTnYA=; b=FE3j4Gq6jDwlT5dc+qVH2K+44XWVchJx/bkHsuaUrHtUzMtklZ3Wa/SdSgkX6gPQUD 2afFBpFfCsHDW8lDM8O7Wfv4gvuNFqE1ZuyGUvkeTb/wqZiGNNpe2DzoMzDuRFZWCRqL 53v/Ak1GuBiSSfR9nFQuQDYh810c6EOM/K4MCOkdJ4A/2yuigpLPG9Q+fC6agkgC69+2 cFbWPhrJ6/ZBKhpLzrhFtzVUZ6zn6WrZ6P0uFJ9t9y+BdNyLuLVjN4/U3lrBzkbJBs6G TAVHdMpj1BLLWwUllZs5vUcbGnhtRx2OYzbSkDlErgQRSaWPIp6BXEVqtqKkGuh7yCoa sfuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=n4L+ojhz; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x2si8871606ejy.385.2021.09.17.08.59.02; Fri, 17 Sep 2021 08:59:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=n4L+ojhz; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244078AbhIQDo4 (ORCPT + 99 others); Thu, 16 Sep 2021 23:44:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242037AbhIQDo4 (ORCPT ); Thu, 16 Sep 2021 23:44:56 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D13DDC061574 for ; Thu, 16 Sep 2021 20:43:34 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id eg28so1697749edb.1 for ; Thu, 16 Sep 2021 20:43:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1msLgxMuoUYRkSqjSYW1EJkXemcrpwMnFdbysKXTnYA=; b=n4L+ojhzAz44SHcGI1LZP48TzVZ6Z0QfTzW1wuRRIzSpZ5bPY+62rT6msy8cmiF5YX iAc7DFdTZgQrM5xR/EhhLLAqp/2IMSl1jaBsC8Nzov/0Yc1NSC+5kb7f1JVOHHTYwY73 tCJEKbbYJ9KHr1HKItioGCK1WIk/5rkfuebnoKN4H3cDn6uM7olwPcnU5NC4ANgq9ORJ 0oUa09VL89f3UOQCM3haFSACsLa1tBASZJq2B8zOqy2ZFPxTKSIEPi2RkDEHg/NaLNSh LrF+u+QVj4/lX0UdyX++TJYJETS0fIcZBUsuaP34mH75Z0Lu9C7g+KeDQ17qEC+tNJIb 7p+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1msLgxMuoUYRkSqjSYW1EJkXemcrpwMnFdbysKXTnYA=; b=0J9IWTE/cTeRBWX2LbZaG77pGCbni77Q54neqpCPVxZMjVFF99f7BzzUVPQQq1LEmu z94xlWAIHbTHJuajK5yranF53Mec/G8Qr2jvlupLlUtn9uSeWIIlIFbzPdSMWAxCSmVc soXxCfSuLa5/GTbofWL+1xIxL8kK4oR/fDVcji9Fk4glIjmXtaMXQkRyE6g4DoAOG7cK 4LBjNiCfJ0KrimMfXDpz84LrOfud7rMn/IySKJXJGXo0+jRZo4up4wLY8yYf7Mn4oXi/ GbzxOE576B4HE+jOQdoApyQxaGe2wgO8dmdy4XXeRyQejNA1CBYTIFvguVHBoLgp+mNj CWnA== X-Gm-Message-State: AOAM531jN5JKSRihfcxRkajf3XbXhFPXSDPfrHqR9N+z81+EWDhj6OkI G+r8H5+wAT4rOxa8UxTeaZJ9Xb/h54uQ1jY5qrJzr6kBqao= X-Received: by 2002:a50:9fcf:: with SMTP id c73mr9927336edf.308.1631850212932; Thu, 16 Sep 2021 20:43:32 -0700 (PDT) MIME-Version: 1.0 References: <20210906140250.Bluez.v2.1.Id597e5ae87e680e6a744a8ed08d5000aacfce867@changeid> In-Reply-To: From: Yun-hao Chung Date: Fri, 17 Sep 2021 11:43:21 +0800 Message-ID: Subject: Re: [Bluez PATCH v2 1/2] plugins/admin: add adapter_remove handler To: Luiz Augusto von Dentz Cc: Bluez mailing list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Thanks for catching and delivering the fixes. I didn't consider the multiple adapters case, and I will send out another patch to fix it. On Fri, Sep 17, 2021 at 7:50 AM Luiz Augusto von Dentz wrote: > > Hi Howard, > > On Wed, Sep 15, 2021 at 4:40 PM Luiz Augusto von Dentz > wrote: > > > > Hi Howard, > > > > On Wed, Sep 15, 2021 at 5:32 AM Yun-hao Chung wrote: > > > > > > Gentle ping. Thanks. > > > > > > > > > On Mon, Sep 6, 2021 at 2:03 PM Howard Chung wrote: > > > > > > > > From: Yun-Hao Chung > > > > > > > > Currently admin doesn't handle adapter removed callbacks, which causes > > > > interfaces AdminPolicySet1 and AdminPolicyStatus1 not being > > > > unregistered, which in turns causes these interfaces can not be > > > > re-registered once adapter is back. > > > > > > > > This adds handler for adapter_remove. > > > > > > > > Reviewed-by: Shyh-In Hwang > > > > Reviewed-by: Miao-chen Chou > > > > --- > > > > tested with following steps > > > > 1. rmmod btusb > > > > 2. modprobe btusb > > > > 3. read allowlist via bluetoothctl > > > > > > > > Changes in v2: > > > > 1. Fix make errors > > > > > > > > plugins/admin.c | 35 ++++++++++++++++++++++++++++------- > > > > 1 file changed, 28 insertions(+), 7 deletions(-) > > > > > > > > diff --git a/plugins/admin.c b/plugins/admin.c > > > > index 02fec04568ba..82c00cabdb6b 100644 > > > > --- a/plugins/admin.c > > > > +++ b/plugins/admin.c > > > > @@ -85,6 +85,17 @@ static void admin_policy_free(void *data) > > > > g_free(admin_policy); > > > > } > > > > > > > > +static void admin_policy_destroy(struct btd_admin_policy *admin_policy) > > > > +{ > > > > + const char *path = adapter_get_path(admin_policy->adapter); > > > > + > > > > + g_dbus_unregister_interface(dbus_conn, path, > > > > + ADMIN_POLICY_SET_INTERFACE); > > > > + g_dbus_unregister_interface(dbus_conn, path, > > > > + ADMIN_POLICY_STATUS_INTERFACE); > > > > + admin_policy_free(admin_policy); > > > > +} > > > > + > > > > static bool uuid_match(const void *data, const void *match_data) > > > > { > > > > const bt_uuid_t *uuid = data; > > > > @@ -492,7 +503,7 @@ static int admin_policy_adapter_probe(struct btd_adapter *adapter) > > > > if (!g_dbus_register_interface(dbus_conn, adapter_path, > > > > ADMIN_POLICY_SET_INTERFACE, > > > > admin_policy_adapter_methods, NULL, > > > > - NULL, policy_data, admin_policy_free)) { > > > > + NULL, policy_data, NULL)) { > > > > btd_error(policy_data->adapter_id, > > > > "Admin Policy Set interface init failed on path %s", > > > > adapter_path); > > > > @@ -506,7 +517,7 @@ static int admin_policy_adapter_probe(struct btd_adapter *adapter) > > > > ADMIN_POLICY_STATUS_INTERFACE, > > > > NULL, NULL, > > > > admin_policy_adapter_properties, > > > > - policy_data, admin_policy_free)) { > > > > + policy_data, NULL)) { > > > > btd_error(policy_data->adapter_id, > > > > "Admin Policy Status interface init failed on path %s", > > > > adapter_path); > > > > @@ -574,10 +585,24 @@ static void admin_policy_device_removed(struct btd_adapter *adapter, > > > > unregister_device_data(data, NULL); > > > > } > > > > > > > > +static void admin_policy_remove(struct btd_adapter *adapter) > > > > +{ > > > > + DBG(""); > > > > + > > > > + queue_foreach(devices, unregister_device_data, NULL); > > > > + queue_destroy(devices, g_free); > > > > + > > > > + if (policy_data) { > > > > + admin_policy_destroy(policy_data); > > > > + policy_data = NULL; > > > > + } > > > > +} > > > > + > > > > static struct btd_adapter_driver admin_policy_driver = { > > > > .name = "admin_policy", > > > > .probe = admin_policy_adapter_probe, > > > > .resume = NULL, > > > > + .remove = admin_policy_remove, > > > > .device_resolved = admin_policy_device_added, > > > > .device_removed = admin_policy_device_removed > > > > }; > > > > @@ -597,11 +622,7 @@ static void admin_exit(void) > > > > DBG(""); > > > > > > > > btd_unregister_adapter_driver(&admin_policy_driver); > > > > - queue_foreach(devices, unregister_device_data, NULL); > > > > - queue_destroy(devices, g_free); > > > > - > > > > - if (policy_data) > > > > - admin_policy_free(policy_data); > > > > + admin_policy_remove(NULL); > > > > } > > > > > > > > BLUETOOTH_PLUGIN_DEFINE(admin, VERSION, > > > > -- > > > > 2.33.0.153.gba50c8fa24-goog > > > > > > > > Applied, thanks. > > > > > > -- > > There are actually some problems with these admin plugin: > > https://patchwork.kernel.org/project/bluetooth/patch/20210916223825.276530-1-luiz.dentz@gmail.com/ > https://patchwork.kernel.org/project/bluetooth/patch/20210916223825.276530-2-luiz.dentz@gmail.com/ > > There is also some assumption that there could be only one > policy_data, when in fact there could be multiple btd_adapter in the > system so having admin plugin in a system with multiple adapters might > lead to various problems. > > > -- > Luiz Augusto von Dentz