summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2018-03-06 18:12:57 +0100
committerPhilippe Guibert <philippe.guibert@6wind.com>2018-03-06 18:18:32 +0100
commitc214a6e9282315e20494ab681a5036e386aa7fd1 (patch)
tree97480b8b15131075b78bec341995ea3a5e241ea7 /lib
parentbgpd: permit bgp vrf socket creation on some cases (diff)
downloadfrr-c214a6e9282315e20494ab681a5036e386aa7fd1.tar.xz
frr-c214a6e9282315e20494ab681a5036e386aa7fd1.zip
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 <philippe.guibert@6wind.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/netns_linux.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/netns_linux.c b/lib/netns_linux.c
index 0e955bade..a92431d1a 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;
}