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 /lib/ns.h | |
| parent | e27dec3cf15d627cc26c07f40ded138b0bcc6a0a (diff) | |
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 'lib/ns.h')
| -rw-r--r-- | lib/ns.h | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -30,12 +30,17 @@ typedef u_int32_t ns_id_t; /* the default NS ID */ -#define NS_DEFAULT 0 #define NS_UNKNOWN UINT32_MAX /* Default netns directory (Linux) */ #define NS_RUN_DIR "/var/run/netns" +#ifdef HAVE_NETNS +#define NS_DEFAULT_NAME "/proc/self/ns/net" +#else /* !HAVE_NETNS */ +#define NS_DEFAULT_NAME "Default-logical-router" +#endif /* HAVE_NETNS */ + struct ns { RB_ENTRY(ns) entry; @@ -85,7 +90,7 @@ extern void ns_add_hook(int type, int (*)(struct ns *)); * NS initializer/destructor */ extern void ns_init(void); -extern void ns_init_zebra(void); +extern void ns_init_zebra(ns_id_t ns_id); extern void ns_terminate(void); /* @@ -101,10 +106,15 @@ extern char *ns_netns_pathname(struct vty *vty, const char *name); extern void *ns_info_lookup(ns_id_t ns_id); extern void ns_walk_func(int (*func)(struct ns *)); extern const char *ns_get_name(struct ns *ns); +extern ns_id_t ns_get_default_id(void); /* API that can be used by all daemons */ extern int ns_switchback_to_initial(void); extern int ns_switch_to_netns(const char *netns_name); extern void ns_init(void); + +/* The default NS ID */ +#define NS_DEFAULT ns_get_default_id() + #endif /*_ZEBRA_NS_H*/ |
