summaryrefslogtreecommitdiffstats
path: root/lib/northbound.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2019-09-17 03:57:10 +0200
committerRenato Westphal <renato@opensourcerouting.org>2019-09-18 19:35:10 +0200
commit6cd301e048cfeb5c57fbbaa005f9fc62aeac563e (patch)
tree7b471ccfbf9c1781de751842ae129c35fb5bb8cc /lib/northbound.c
parentRevert "lib: introduce a read-write lock for northbound configurations" (diff)
downloadfrr-6cd301e048cfeb5c57fbbaa005f9fc62aeac563e.tar.xz
frr-6cd301e048cfeb5c57fbbaa005f9fc62aeac563e.zip
lib: fix corner case when iterating over YANG-modeled operational data
When updating the XPath during the iteration of operational data, include the namespace of the augmenting module when necessary. Reported-by: Quentin Young <qlyoung@cumulusnetworks.com> Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib/northbound.c')
-rw-r--r--lib/northbound.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/northbound.c b/lib/northbound.c
index bffe62f60..75f1e07b7 100644
--- a/lib/northbound.c
+++ b/lib/northbound.c
@@ -1302,9 +1302,27 @@ static int nb_oper_data_iter_node(const struct lys_node *snode,
/* Update XPath. */
strlcpy(xpath, xpath_parent, sizeof(xpath));
- if (!first && snode->nodetype != LYS_USES)
- snprintf(xpath + strlen(xpath), sizeof(xpath) - strlen(xpath),
- "/%s", snode->name);
+ if (!first && snode->nodetype != LYS_USES) {
+ struct lys_node *parent;
+
+ /* Get the real parent. */
+ parent = snode->parent;
+ while (parent && parent->nodetype == LYS_USES)
+ parent = parent->parent;
+
+ /*
+ * When necessary, include the namespace of the augmenting
+ * module.
+ */
+ if (parent && parent->nodetype == LYS_AUGMENT)
+ snprintf(xpath + strlen(xpath),
+ sizeof(xpath) - strlen(xpath), "/%s:%s",
+ snode->module->name, snode->name);
+ else
+ snprintf(xpath + strlen(xpath),
+ sizeof(xpath) - strlen(xpath), "/%s",
+ snode->name);
+ }
nb_node = snode->priv;
switch (snode->nodetype) {