summaryrefslogtreecommitdiffstats
path: root/lib/northbound_confd.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2020-10-20 04:56:54 +0200
committerRenato Westphal <renato@opensourcerouting.org>2020-10-23 23:18:22 +0200
commit9bde0b256919ff3987ea60101229fec195324102 (patch)
tree03d5a635efaf775dca58f389073b58c5fa2833d9 /lib/northbound_confd.c
parentMerge pull request #7361 from wesleycoakley/alpine-build-fix (diff)
downloadfrr-9bde0b256919ff3987ea60101229fec195324102.tar.xz
frr-9bde0b256919ff3987ea60101229fec195324102.zip
lib: fix iteration over schema nodes of a single YANG module
The only safe way to iterate over all schema nodes of a given YANG module is by iterating over all schema nodes of all YANG modules and filter out the nodes that belong to other modules. The original yang_snodes_iterate_module() code did the following: 1 - Iterate over all top-level schema nodes of the given module; 2 - Iterate over all augmentations of the given module. While that iteration strategy is more efficient, it does't handle well more complex YANG hierarchies containing nested augmentations or self-augmenting modules. Any iteration that isn't done on the resolved YANG data hierarchy is fragile and prone to errors. Fixes regression introduced by commit 8a923b48513316b where the gen_northbound_callbacks tool was generating duplicate callbacks for certain modules. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib/northbound_confd.c')
-rw-r--r--lib/northbound_confd.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/northbound_confd.c b/lib/northbound_confd.c
index c1cb0fc11..a53e90d55 100644
--- a/lib/northbound_confd.c
+++ b/lib/northbound_confd.c
@@ -550,6 +550,9 @@ static int frr_confd_init_cdb(void)
continue;
nb_node = snode->priv;
+ if (!nb_node)
+ continue;
+
DEBUGD(&nb_dbg_client_confd, "%s: subscribing to '%s'",
__func__, nb_node->xpath);
@@ -1189,7 +1192,7 @@ static int frr_confd_subscribe_state(const struct lys_node *snode, void *arg)
struct nb_node *nb_node = snode->priv;
struct confd_data_cbs *data_cbs = arg;
- if (!CHECK_FLAG(snode->flags, LYS_CONFIG_R))
+ if (!nb_node || !CHECK_FLAG(snode->flags, LYS_CONFIG_R))
return YANG_ITER_CONTINUE;
/* We only need to subscribe to the root of the state subtrees. */
if (snode->parent && CHECK_FLAG(snode->parent->flags, LYS_CONFIG_R))
@@ -1393,7 +1396,8 @@ static int frr_confd_calculate_snode_hash(const struct lys_node *snode,
{
struct nb_node *nb_node = snode->priv;
- nb_node->confd_hash = confd_str2hash(snode->name);
+ if (nb_node)
+ nb_node->confd_hash = confd_str2hash(snode->name);
return YANG_ITER_CONTINUE;
}