diff options
author | Igor Ryzhov <iryzhov@nfware.com> | 2021-12-03 23:22:55 +0100 |
---|---|---|
committer | Igor Ryzhov <iryzhov@nfware.com> | 2021-12-21 20:09:29 +0100 |
commit | ac2cb9bf9467ada08014b045c52512c625d6c55b (patch) | |
tree | 19983a5108d70d705c0810c6f270332712c0d207 /ripd | |
parent | Merge pull request #9472 from rampxxxx/pathd_doc_augmented (diff) | |
download | frr-ac2cb9bf9467ada08014b045c52512c625d6c55b.tar.xz frr-ac2cb9bf9467ada08014b045c52512c625d6c55b.zip |
*: rework renaming the default VRF
Currently, it is possible to rename the default VRF either by passing
`-o` option to zebra or by creating a file in `/var/run/netns` and
binding it to `/proc/self/ns/net`.
In both cases, only zebra knows about the rename and other daemons learn
about it only after they connect to zebra. This is a problem, because
daemons may read their config before they connect to zebra. To handle
this rename after the config is read, we have some special code in every
single daemon, which is not very bad but not desirable in my opinion.
But things are getting worse when we need to handle this in northbound
layer as we have to manually rewrite the config nodes. This approach is
already hacky, but still works as every daemon handles its own NB
structures. But it is completely incompatible with the central
management daemon architecture we are aiming for, as mgmtd doesn't even
have a connection with zebra to learn from it. And it shouldn't have it,
because operational state changes should never affect configuration.
To solve the problem and simplify the code, I propose to expand the `-o`
option to all daemons. By using the startup option, we let daemons know
about the rename before they read their configs so we don't need any
special code to deal with it. There's an easy way to pass the option to
all daemons by using `frr_global_options` variable.
Unfortunately, the second way of renaming by creating a file in
`/var/run/netns` is incompatible with the new mgmtd architecture.
Theoretically, we could force daemons to read their configs only after
they connect to zebra, but it means adding even more code to handle a
very specific use-case. And anyway this won't work for mgmtd as it
doesn't have a connection with zebra. So I had to remove this option.
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'ripd')
-rw-r--r-- | ripd/ripd.c | 40 |
1 files changed, 1 insertions, 39 deletions
diff --git a/ripd/ripd.c b/ripd/ripd.c index 145b4de0a..346c11ad3 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -3606,43 +3606,6 @@ static int rip_vrf_enable(struct vrf *vrf) int socket; rip = rip_lookup_by_vrf_name(vrf->name); - if (!rip) { - char *old_vrf_name = NULL; - - rip = (struct rip *)vrf->info; - if (!rip) - return 0; - /* update vrf name */ - if (rip->vrf_name) - old_vrf_name = rip->vrf_name; - rip->vrf_name = XSTRDUP(MTYPE_RIP_VRF_NAME, vrf->name); - /* - * HACK: Change the RIP VRF in the running configuration directly, - * bypassing the northbound layer. This is necessary to avoid deleting - * the RIP and readding it in the new VRF, which would have - * several implications. - */ - if (yang_module_find("frr-ripd") && old_vrf_name) { - struct lyd_node *rip_dnode; - char oldpath[XPATH_MAXLEN]; - char newpath[XPATH_MAXLEN]; - - rip_dnode = yang_dnode_getf( - running_config->dnode, - "/frr-ripd:ripd/instance[vrf='%s']/vrf", - old_vrf_name); - if (rip_dnode) { - yang_dnode_get_path(lyd_parent(rip_dnode), - oldpath, sizeof(oldpath)); - yang_dnode_change_leaf(rip_dnode, vrf->name); - yang_dnode_get_path(lyd_parent(rip_dnode), - newpath, sizeof(newpath)); - nb_running_move_tree(oldpath, newpath); - running_config->version++; - } - } - XFREE(MTYPE_RIP_VRF_NAME, old_vrf_name); - } if (!rip || rip->enabled) return 0; @@ -3683,8 +3646,7 @@ static int rip_vrf_disable(struct vrf *vrf) void rip_vrf_init(void) { - vrf_init(rip_vrf_new, rip_vrf_enable, rip_vrf_disable, rip_vrf_delete, - rip_vrf_enable); + vrf_init(rip_vrf_new, rip_vrf_enable, rip_vrf_disable, rip_vrf_delete); vrf_cmd_init(NULL); } |