Skip to content

Commit

Permalink
mesh: Fix node when loading from storage
Browse files Browse the repository at this point in the history
This fixes adding mandatory models (config server, remote provisioner)
to a node whose configuration is being loaded from storage:
mesh_model_add() was called with a wrong argument.

Was:     mesh_model_add(..., PRIMARY_ELE_IDX, ...);
Correct: mesh_model_add(..., ele->models, ...);
  • Loading branch information
inga-s authored and bgix committed Mar 12, 2023
1 parent 815f779 commit 40576ac
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions mesh/node.c
Expand Up @@ -347,21 +347,27 @@ static bool add_elements_from_storage(struct mesh_node *node,
struct mesh_config_node *db_node)
{
const struct l_queue_entry *entry;
struct node_element *ele;

entry = l_queue_get_entries(db_node->elements);

for (; entry; entry = entry->next)
if (!add_element_from_storage(node, entry->data))
return false;

ele = l_queue_find(node->elements, match_element_idx,
L_UINT_TO_PTR(PRIMARY_ELE_IDX));
if (!ele)
return false;

/* Add configuration server model on the primary element */
mesh_model_add(node, PRIMARY_ELE_IDX, CONFIG_SRV_MODEL, NULL);
mesh_model_add(node, ele->models, CONFIG_SRV_MODEL, NULL);

/* Add remote provisioning models on the primary element */
mesh_model_add(node, PRIMARY_ELE_IDX, REM_PROV_SRV_MODEL, NULL);
mesh_model_add(node, ele->models, REM_PROV_SRV_MODEL, NULL);

if (node->provisioner)
mesh_model_add(node, PRIMARY_ELE_IDX, REM_PROV_CLI_MODEL, NULL);
mesh_model_add(node, ele->models, REM_PROV_CLI_MODEL, NULL);

return true;
}
Expand Down

0 comments on commit 40576ac

Please sign in to comment.