Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3042702ybi; Mon, 17 Jun 2019 15:20:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0/yT6J2dE5rHwuwmq/Tl8YBCBHPN7n5/0vo95Wfxp0ccliLmXdhkrVhzrtMFhWjv2ix3R X-Received: by 2002:aa7:8f2c:: with SMTP id y12mr32716966pfr.38.1560810012746; Mon, 17 Jun 2019 15:20:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560810012; cv=none; d=google.com; s=arc-20160816; b=yHhIUKa4Jin790Mm3LiLdUqUiKuVy6Dn66AbZhBLLgFAKTJArglokL5i/ToPdHg1OG 6uowSY0y5I0TgzetvW8ife2mYZVtEHbH18pG2jZQF8URYB55xgkhc8fM/oXMKBaTr/Vi vK3rC8FRDCnyPxprLV9jC8mdNaM5cfnYwHgdq1tmouLrtkTTRhkNy4wgBYiREowN4rEf YaIOg/UFUDKre5CNqZxkhRA8hDapmH3mEbMBBsIADE9WO7eCFShxFzayN0yIOA3IyiAl m1spYo4sa+YK9PsrvhlDikEIrlHn8wQui6DS4d9FaQ3v+opMMUBOMiwnDSgU0JJYTxDt egAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=5pzpSmJPA5+HFACx/oyNmbOnYXxAl1RW2fj5BiYlVOg=; b=HV6I0qJd2vncEvVktwcCa389dExZvpAnAT5lP1pGGzK4/MAYXbaSjWMBO0fMyz+ySl HGcTOgAWHd5JfqtT16hIfpw22U9Jnorp6+ciHf2oWs3wwehLhV/bDRXotTtea2YRAQ2u M5OgsxLvpVhCSTNryeXYx69YPYw/I14JsJGgRs4ttyXuaj3uNBAPQ3l/qGZ4fxF/yHhR l6+vZNbD92kXCfov2XCpVTD/9roE8GH60l12oymCex4W/5M6k6dwxgQUzepEDrATCcLa icOVzkbV3AKRKGZZreC44mSFp21FuVTP32EwqQDlyE4fXjIO3yXFs0W9kVXKY2XOJJVv xtRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d37si11562230plb.351.2019.06.17.15.19.43; Mon, 17 Jun 2019 15:20:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728764AbfFQWTY (ORCPT + 99 others); Mon, 17 Jun 2019 18:19:24 -0400 Received: from mga09.intel.com ([134.134.136.24]:57565 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726116AbfFQWTY (ORCPT ); Mon, 17 Jun 2019 18:19:24 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jun 2019 15:19:23 -0700 X-ExtLoop1: 1 Received: from orsmsx106.amr.corp.intel.com ([10.22.225.133]) by orsmga005.jf.intel.com with ESMTP; 17 Jun 2019 15:19:23 -0700 Received: from orsmsx126.amr.corp.intel.com (10.22.240.126) by ORSMSX106.amr.corp.intel.com (10.22.225.133) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 17 Jun 2019 15:19:23 -0700 Received: from orsmsx103.amr.corp.intel.com ([169.254.5.135]) by ORSMSX126.amr.corp.intel.com ([169.254.4.136]) with mapi id 14.03.0439.000; Mon, 17 Jun 2019 15:19:23 -0700 From: "Stotland, Inga" To: "jakub.witowski@silvair.com" , "linux-bluetooth@vger.kernel.org" CC: "Gix, Brian" Subject: Re: [PATCH] mesh: Return dbus error code on Leave() with invalit token given Thread-Topic: [PATCH] mesh: Return dbus error code on Leave() with invalit token given Thread-Index: AQHVJRJrlD83R3pSxEWh/SZGMOaHeaag4I+A Date: Mon, 17 Jun 2019 22:19:22 +0000 Message-ID: <5a3a7c681e92d613a35f5c9b3abe5c27df867b4a.camel@intel.com> References: <20190617134141.575-1-jakub.witowski@silvair.com> In-Reply-To: <20190617134141.575-1-jakub.witowski@silvair.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-originating-ip: [10.254.55.111] Content-Type: multipart/signed; micalg=sha-1; protocol="application/x-pkcs7-signature"; boundary="=-nvvrVnzzuTlBkQD1Eo7R" MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org --=-nvvrVnzzuTlBkQD1Eo7R Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Jakub, On Mon, 2019-06-17 at 15:41 +0200, Jakub Witowski wrote: > This implements MESH_ERROR_NOT_FOUND error when we try to call > Leave() > from dbus api with incorrect token value (ex. Leave(0)) > --- > mesh/mesh.c | 10 +++++----- > mesh/node.c | 7 +++++-- > mesh/node.h | 2 +- > mesh/storage.c | 4 ++-- > 4 files changed, 13 insertions(+), 10 deletions(-) >=20 > diff --git a/mesh/mesh.c b/mesh/mesh.c > index 231a6bca4..f10b73331 100644 > --- a/mesh/mesh.c > +++ b/mesh/mesh.c > @@ -65,7 +65,7 @@ struct bt_mesh { > uint8_t max_filters; > }; > =20 > -struct join_data{ > +struct join_data { > struct l_dbus_message *msg; > struct mesh_agent *agent; > const char *sender; > @@ -355,7 +355,7 @@ static void free_pending_join_call(bool failed) > mesh_agent_remove(join_pending->agent); > =20 > if (failed) > - node_remove(join_pending->node); > + (void)node_remove(join_pending->node); > =20 > l_free(join_pending); > join_pending =3D NULL; > @@ -530,8 +530,7 @@ static void node_init_cb(struct mesh_node *node, > struct mesh_agent *agent) > =20 > if (!acceptor_start(num_ele, join_pending->uuid, > mesh.algorithms, > mesh.prov_timeout, agent, > prov_complete_cb, > - &mesh)) > - { > + &mesh)) { > reply =3D dbus_error(join_pending->msg, > MESH_ERROR_FAILED, > "Failed to start provisioning > acceptor"); > goto fail; > @@ -696,7 +695,8 @@ static struct l_dbus_message *leave_call(struct > l_dbus *dbus, > if (!l_dbus_message_get_arguments(msg, "t", &token)) > return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL); > =20 > - node_remove(node_find_by_token(token)); > + if (!node_remove(node_find_by_token(token))) > + return dbus_error(msg, MESH_ERROR_NOT_FOUND, NULL); > =20 > return l_dbus_message_new_method_return(msg); > } > diff --git a/mesh/node.c b/mesh/node.c > index e99858623..2b9978908 100644 > --- a/mesh/node.c > +++ b/mesh/node.c > @@ -256,11 +256,12 @@ static void free_node_resources(void *data) > /* > * This function is called to free resources and remove the > * configuration files for the specified node. > + * The false is returned when there is no node to be removed > */ > -void node_remove(struct mesh_node *node) > +bool node_remove(struct mesh_node *node) > { > if (!node) > - return; > + return false; > =20 > l_queue_remove(nodes, node); > =20 > @@ -268,6 +269,7 @@ void node_remove(struct mesh_node *node) > storage_remove_node_config(node); > =20 > free_node_resources(node); > + return true; > } > =20 > static bool add_models(struct mesh_node *node, struct node_element > *ele, > @@ -1078,6 +1080,7 @@ static bool validate_model_property(struct > node_element *ele, > while (l_dbus_message_iter_next_entry(&ids, &vendor_id, > &mod_id > )) { > struct mesh_model *mod; > + > mod =3D l_queue_find(ele->models, match_model_id, > L_UINT_TO_PTR((vendor_id << 16) | > mod_id)); > if (!mod) > diff --git a/mesh/node.h b/mesh/node.h > index 142527b30..5f045ee2d 100644 > --- a/mesh/node.h > +++ b/mesh/node.h > @@ -34,7 +34,7 @@ typedef void (*node_join_ready_func_t) (struct > mesh_node *node, > struct mesh_agent > *agent); > =20 > struct mesh_node *node_new(const uint8_t uuid[16]); > -void node_remove(struct mesh_node *node); > +bool node_remove(struct mesh_node *node); > void node_join(const char *app_path, const char *sender, const > uint8_t *uuid, > node_join_ready_func_t > cb); > uint8_t *node_uuid_get(struct mesh_node *node); > diff --git a/mesh/storage.c b/mesh/storage.c > index 1a9945aa8..7ae0ac5b1 100644 > --- a/mesh/storage.c > +++ b/mesh/storage.c > @@ -77,7 +77,7 @@ static bool read_node_cb(struct mesh_db_node > *db_node, void *user_data) > uint8_t *uuid; > =20 > if (!node_init_from_storage(node, db_node)) { > - node_remove(node); > + (void)node_remove(node); > return false; > } > =20 > @@ -220,7 +220,7 @@ static bool parse_config(char *in_file, char > *out_dir, const uint8_t uuid[16]) > =20 > if (!result) { > json_object_put(jnode); > - node_remove(node); > + (void)node_remove(node); > } > =20 > node_jconfig_set(node, jnode); A better fix would be to remove the "NotFound" error from doc/mesh- api.txt altogether: effectively, if the node wasn't found, it's been successfully removed. Best regards, Inga --=-nvvrVnzzuTlBkQD1Eo7R Content-Type: application/x-pkcs7-signature; name="smime.p7s" Content-Disposition: attachment; filename="smime.p7s" Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIKbDCCBOsw ggPToAMCAQICEDabxALowUBS+21KC0JI8fcwDQYJKoZIhvcNAQEFBQAwbzELMAkGA1UEBhMCU0Ux FDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRUcnVzdCBFeHRlcm5hbCBUVFAgTmV0 d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0EgUm9vdDAeFw0xMzE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