summaryrefslogtreecommitdiff
path: root/lib/if.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-06-16 14:07:30 +0300
committerIgor Ryzhov <iryzhov@nfware.com>2021-06-18 03:27:46 +0300
commit763725cd5e431cb4f4ec385e35b312cc7807163a (patch)
tree30a3627d078d50fba5a32a96556f504b061a18d0 /lib/if.c
parent161b567451593a7a176bc91b5aaafc53a578be75 (diff)
lib: fix interface configuration after vrf change
This commit fixes the following problem: - enter the interface node - move the interface to another VRF - try to continue configuring the interface It is not possible to continue configuration because the XPath stored in the vty doesn't correspond with the actual state of the system anymore. For example: ``` nfware# conf nfware(config)# interface enp2s0 <-- move the enp2s0 to a different VRF --> nfware(config-if)# ip router isis 1 % Failed to get iface dnode in candidate DB ``` To fix the issue, go through all connected vty shells and update the stored XPath. Suggested-by: Renato Westphal <renato@opensourcerouting.org> Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'lib/if.c')
-rw-r--r--lib/if.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/if.c b/lib/if.c
index b3803141df..e37b4f55b0 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -266,20 +266,23 @@ void if_update_to_new_vrf(struct interface *ifp, vrf_id_t vrf_id)
char oldpath[XPATH_MAXLEN];
char newpath[XPATH_MAXLEN];
- if_dnode = yang_dnode_getf(
- running_config->dnode,
- "/frr-interface:lib/interface[name='%s'][vrf='%s']/vrf",
- ifp->name, old_vrf->name);
+ snprintf(oldpath, sizeof(oldpath),
+ "/frr-interface:lib/interface[name='%s'][vrf='%s']",
+ ifp->name, old_vrf->name);
+ snprintf(newpath, sizeof(newpath),
+ "/frr-interface:lib/interface[name='%s'][vrf='%s']",
+ ifp->name, vrf->name);
+
+ if_dnode = yang_dnode_getf(running_config->dnode, "%s/vrf",
+ oldpath);
if (if_dnode) {
- yang_dnode_get_path(lyd_parent(if_dnode), oldpath,
- sizeof(oldpath));
yang_dnode_change_leaf(if_dnode, vrf->name);
- yang_dnode_get_path(lyd_parent(if_dnode), newpath,
- sizeof(newpath));
nb_running_move_tree(oldpath, newpath);
running_config->version++;
}
+
+ vty_update_xpath(oldpath, newpath);
}
}