Skip to content

Commit

Permalink
cmgd: Check if to be set or deleted is a leaf node
Browse files Browse the repository at this point in the history
Signed-off-by: Yash Ranjan <ranjany@vmware.com>
  • Loading branch information
YashRanjanVMWare committed Aug 18, 2021
1 parent b2369cd commit b423a4c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/northbound.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,16 @@ int nb_candidate_edit(struct nb_config *candidate,
return NB_OK;
}

static bool nb_is_operation_allowed(struct nb_node *nb_node, struct nb_cfg_change *change)
{
enum nb_operation oper = change->operation;
if(lysc_is_key(nb_node->snode)) {
if (oper == NB_OP_MODIFY || oper == NB_OP_DESTROY)
return false;
}
return true;
}

void nb_candidate_edit_config_changes(struct nb_config *candidate_config,
struct nb_cfg_change cfg_changes[],
size_t num_cfg_changes,
Expand Down Expand Up @@ -787,6 +797,13 @@ void nb_candidate_edit_config_changes(struct nb_config *candidate_config,
*error = true;
continue;
}
/* Find if the node to be edited is not a key node */
if (!nb_is_operation_allowed(nb_node, change))
{
zlog_err(" Xpath %s points to key node", xpath);
*error = true;
break;
}

/* If the value is not set, get the default if it exists. */
if (change->value == NULL)
Expand Down

0 comments on commit b423a4c

Please sign in to comment.