]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: NS_DEFAULT wrong value 1840/head
authorPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 6 Mar 2018 17:12:57 +0000 (18:12 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 6 Mar 2018 17:18:32 +0000 (18:18 +0100)
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 <philippe.guibert@6wind.com>
lib/netns_linux.c

index 0e955bade927137edafbfda3ee2c31e3b9d178d6..a92431d1ae2c2e54551148ac96d00ae7cc192882 100644 (file)
@@ -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;
 }