diff options
| author | Igor Ryzhov <iryzhov@nfware.com> | 2021-12-04 01:22:55 +0300 |
|---|---|---|
| committer | Igor Ryzhov <iryzhov@nfware.com> | 2021-12-21 22:09:29 +0300 |
| commit | ac2cb9bf9467ada08014b045c52512c625d6c55b (patch) | |
| tree | 19983a5108d70d705c0810c6f270332712c0d207 /lib/libfrr.c | |
| parent | a64829d3c55b9c83e275d78698eab0899ebfcaae (diff) | |
*: 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 'lib/libfrr.c')
| -rw-r--r-- | lib/libfrr.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/libfrr.c b/lib/libfrr.c index 9b05bb4fbf..361af49c27 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -116,6 +116,7 @@ static const struct option lo_always[] = { {"module", no_argument, NULL, 'M'}, {"profile", required_argument, NULL, 'F'}, {"pathspace", required_argument, NULL, 'N'}, + {"vrfdefaultname", required_argument, NULL, 'o'}, {"vty_socket", required_argument, NULL, OPTION_VTYSOCK}, {"moduledir", required_argument, NULL, OPTION_MODULEDIR}, {"scriptdir", required_argument, NULL, OPTION_SCRIPTDIR}, @@ -126,13 +127,14 @@ static const struct option lo_always[] = { {"limit-fds", required_argument, NULL, OPTION_LIMIT_FDS}, {NULL}}; static const struct optspec os_always = { - "hvdM:F:N:", + "hvdM:F:N:o:", " -h, --help Display this help and exit\n" " -v, --version Print program version\n" " -d, --daemon Runs in daemon mode\n" " -M, --module Load specified module\n" " -F, --profile Use specified configuration profile\n" " -N, --pathspace Insert prefix into config & socket paths\n" + " -o, --vrfdefaultname Set default VRF name.\n" " --vty_socket Override vty socket path\n" " --moduledir Override modules directory\n" " --scriptdir Override scripts directory\n" @@ -495,6 +497,9 @@ static int frr_opt(int opt) snprintf(pidfile_default, sizeof(pidfile_default), "%s/%s.pid", frr_vtydir, di->name); break; + case 'o': + vrf_set_default_name(optarg); + break; #ifdef HAVE_SQLITE3 case OPTION_DB_FILE: if (di->flags & FRR_NO_CFG_PID_DRY) |
