From: Philippe Guibert Date: Tue, 6 Mar 2018 17:12:57 +0000 (+0100) Subject: lib: NS_DEFAULT wrong value X-Git-Tag: frr-5.0-dev~188^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=c214a6e9282315e20494ab681a5036e386aa7fd1;p=mirror%2Ffrr.git lib: NS_DEFAULT wrong value The NS_DEFAULT value returns UNKNOWN in the case the vrf lite backend is used, whereas this is wrong. This commit fixes the default value. Also, it fixes the default value in the case NETNS support from system is not ok, or some error can occur when reading default NS at startup. Signed-off-by: Philippe Guibert --- diff --git a/lib/netns_linux.c b/lib/netns_linux.c index 0e955bade9..a92431d1ae 100644 --- a/lib/netns_linux.c +++ b/lib/netns_linux.c @@ -43,6 +43,9 @@ DEFINE_MTYPE_STATIC(LIB, NS, "NetNS Context") DEFINE_MTYPE_STATIC(LIB, NS_NAME, "NetNS Name") +/* default NS ID value used when VRF backend is not NETNS */ +#define NS_DEFAULT_INTERNAL 0 + static inline int ns_compare(const struct ns *ns, const struct ns *ns2); static struct ns *ns_lookup_name_internal(const char *name); @@ -414,8 +417,10 @@ void ns_init(void) #ifdef HAVE_NETNS if (have_netns_enabled < 0) ns_default_ns_fd = open(NS_DEFAULT_NAME, O_RDONLY); - else + else { ns_default_ns_fd = -1; + default_ns = NULL; + } #else ns_default_ns_fd = -1; default_ns = NULL; @@ -534,6 +539,6 @@ ns_id_t ns_get_default_id(void) { if (default_ns) return default_ns->ns_id; - return NS_UNKNOWN; + return NS_DEFAULT_INTERNAL; }