]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: fix corner case when iterating over YANG-modeled operational data
authorRenato Westphal <renato@opensourcerouting.org>
Tue, 17 Sep 2019 01:57:10 +0000 (22:57 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Wed, 18 Sep 2019 17:35:10 +0000 (14:35 -0300)
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>
lib/northbound.c

index bffe62f60e29d9162998a7f9157439ce0428ff0b..75f1e07b7fc11d12d9221864fe94e7eef29dd7c7 100644 (file)
@@ -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) {