diff options
author | Philippe Guibert <philippe.guibert@6wind.com> | 2018-01-16 13:59:58 +0100 |
---|---|---|
committer | Philippe Guibert <philippe.guibert@6wind.com> | 2018-02-27 11:11:24 +0100 |
commit | ec31f30d28b65a4820a44ac658e677840ed6f88b (patch) | |
tree | 12d7828e18031db13e71f2fa0d5f8070246fb966 /zebra/zebra_ns.c | |
parent | zebra: collect and get netnamespaces information (diff) | |
download | frr-ec31f30d28b65a4820a44ac658e677840ed6f88b.tar.xz frr-ec31f30d28b65a4820a44ac658e677840ed6f88b.zip |
zebra: upon startup, a NSID is assigned to default netns
when the netns backend is selected for VRF, the default VRF is being
assigned a NSID. This avoids the need to handle the case where if the
incoming NSID was 0 for a non default VRF, then a specific handling had
to be done to keep 0 value for default VRF.
In most cases, as the first NETNS to get a NSID will be the default VRF,
most probably the default VRF will be assigned to 0, while the other
ones will have their value incremented. On some cases, where the NSID is
already assigned for NETNS, including default VRF, then the default VRF
value will be the one derived from the NSID of default VRF, thus keeping
consistency between VRF IDs and NETNS IDs.
Default NS is attempted to be created. Actually, some VMs may have the
netns feature, but the NS initialisation fails because that folder is
not present.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'zebra/zebra_ns.c')
-rw-r--r-- | zebra/zebra_ns.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/zebra/zebra_ns.c b/zebra/zebra_ns.c index 50551c9b3..da5b22def 100644 --- a/zebra/zebra_ns.c +++ b/zebra/zebra_ns.c @@ -34,6 +34,9 @@ #include "zebra_vxlan.h" #include "debug.h" #include "zebra_netns_notify.h" +#include "zebra_netns_id.h" + +extern struct zebra_privs_t zserv_privs; DEFINE_MTYPE(ZEBRA, ZEBRA_NS, "Zebra Name Space") @@ -229,9 +232,16 @@ int zebra_ns_disable(ns_id_t ns_id, void **info) int zebra_ns_init(void) { + ns_id_t ns_id; + dzns = zebra_ns_alloc(); - ns_init_zebra(); + if (zserv_privs.change(ZPRIVS_RAISE)) + zlog_err("Can't raise privileges"); + ns_id = zebra_ns_id_get_default(); + if (zserv_privs.change(ZPRIVS_LOWER)) + zlog_err("Can't lower privileges"); + ns_init_zebra(ns_id); ns_init(); |