diff options
author | Igor Ryzhov <iryzhov@nfware.com> | 2021-06-16 13:07:30 +0200 |
---|---|---|
committer | Igor Ryzhov <iryzhov@nfware.com> | 2021-06-18 02:27:46 +0200 |
commit | 763725cd5e431cb4f4ec385e35b312cc7807163a (patch) | |
tree | 30a3627d078d50fba5a32a96556f504b061a18d0 /lib/if.c | |
parent | Merge pull request #8874 from idryzhov/ospf-routemap-fix (diff) | |
download | frr-763725cd5e431cb4f4ec385e35b312cc7807163a.tar.xz frr-763725cd5e431cb4f4ec385e35b312cc7807163a.zip |
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.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -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); } } |