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>
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);
#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;
{
if (default_ns)
return default_ns->ns_id;
- return NS_UNKNOWN;
+ return NS_DEFAULT_INTERNAL;
}