2019-06-26 15:49:41

by Rafał Gajda

[permalink] [raw]
Subject: [PATCH BlueZ] mesh: Fix to duplicated model Ids saved to storage

BlueZ internally implements a SIG model for Config Server.

When generating node, if the Mesh Element in mesh application returns modelId 0
among its supported models, it should be skipped, otherwise it will be
duplicated and saved in the storage file.

This patch fixes correctly skipping Config Server model during node creation.
---
mesh/node.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/mesh/node.c b/mesh/node.c
index e99858623..4e35bb3ff 100644
--- a/mesh/node.c
+++ b/mesh/node.c
@@ -1061,10 +1061,9 @@ static bool validate_model_property(struct node_element *ele,
/* Bluetooth SIG defined models */
while (l_dbus_message_iter_next_entry(&ids, &mod_id)) {
struct mesh_model *mod;
- uint32_t m = mod_id;

/* Skip internally implemented models */
- if (m == CONFIG_SRV_MODEL)
+ if ((VENDOR_ID_MASK | mod_id) == CONFIG_SRV_MODEL)
continue;

mod = l_queue_find(ele->models, match_model_id,
@@ -1078,6 +1077,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 = l_queue_find(ele->models, match_model_id,
L_UINT_TO_PTR((vendor_id << 16) | mod_id));
if (!mod)
@@ -1108,10 +1108,9 @@ static void get_models_from_properties(struct node_element *ele,
if (!vendor) {
while (l_dbus_message_iter_next_entry(&ids, &mod_id)) {
struct mesh_model *mod;
- uint32_t m = mod_id;

/* Skip internally implemented models */
- if (m == CONFIG_SRV_MODEL)
+ if ((VENDOR_ID_MASK | mod_id) == CONFIG_SRV_MODEL)
continue;

mod = mesh_model_new(ele->idx, mod_id);
--
2.22.0


2019-06-26 17:34:24

by Gix, Brian

[permalink] [raw]
Subject: Re: [PATCH BlueZ] mesh: Fix to duplicated model Ids saved to storage

Applied with minor commit message change, Thanks

On Wed, 2019-06-26 at 17:49 +0200, Rafał Gajda wrote:
> BlueZ internally implements a SIG model for Config Server.
>
> When generating node, if the Mesh Element in mesh application returns modelId 0
> among its supported models, it should be skipped, otherwise it will be
> duplicated and saved in the storage file.
>
> This patch fixes correctly skipping Config Server model during node creation.
> ---
> mesh/node.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/mesh/node.c b/mesh/node.c
> index e99858623..4e35bb3ff 100644
> --- a/mesh/node.c
> +++ b/mesh/node.c
> @@ -1061,10 +1061,9 @@ static bool validate_model_property(struct node_element *ele,
> /* Bluetooth SIG defined models */
> while (l_dbus_message_iter_next_entry(&ids, &mod_id)) {
> struct mesh_model *mod;
> - uint32_t m = mod_id;
>
> /* Skip internally implemented models */
> - if (m == CONFIG_SRV_MODEL)
> + if ((VENDOR_ID_MASK | mod_id) == CONFIG_SRV_MODEL)
> continue;
>
> mod = l_queue_find(ele->models, match_model_id,
> @@ -1078,6 +1077,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 = l_queue_find(ele->models, match_model_id,
> L_UINT_TO_PTR((vendor_id << 16) | mod_id));
> if (!mod)
> @@ -1108,10 +1108,9 @@ static void get_models_from_properties(struct node_element *ele,
> if (!vendor) {
> while (l_dbus_message_iter_next_entry(&ids, &mod_id)) {
> struct mesh_model *mod;
> - uint32_t m = mod_id;
>
> /* Skip internally implemented models */
> - if (m == CONFIG_SRV_MODEL)
> + if ((VENDOR_ID_MASK | mod_id) == CONFIG_SRV_MODEL)
> continue;
>
> mod = mesh_model_new(ele->idx, mod_id);