diff options
| author | vivek <vivek@cumulusnetworks.com> | 2018-03-10 04:03:41 +0000 |
|---|---|---|
| committer | vivek <vivek@cumulusnetworks.com> | 2018-03-10 04:03:41 +0000 |
| commit | 4e262455a252c700f81df75fb8107d112062bba8 (patch) | |
| tree | fbd55c66eebe78ccb60424e560548d1613aa403a /lib/netns_linux.c | |
| parent | bfd498f0dab9a1937c6036cd35ed020b64a69e8f (diff) | |
| parent | 58e7db106d5907cb129fcc316f02ce0bf34e3885 (diff) | |
Merge branch 'master' of https://github.com/frrouting/frr into evpn-ipv6-tenant-routing
Conflicts:
bgpd/bgp_evpn.c
Diffstat (limited to 'lib/netns_linux.c')
| -rw-r--r-- | lib/netns_linux.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/lib/netns_linux.c b/lib/netns_linux.c index 0e955bade9..01616be711 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); @@ -173,7 +176,7 @@ static struct ns *ns_get_created_internal(struct ns *ns, char *name, zlog_info("NS %s is created.", ns->name); } if (ns_master.ns_new_hook) - (*ns_master.ns_new_hook) (ns); + (*ns_master.ns_new_hook)(ns); return ns; } @@ -247,8 +250,7 @@ static void ns_disable_internal(struct ns *ns) { if (ns_is_enabled(ns)) { if (ns_debug) - zlog_info("NS %u is to be disabled.", - ns->ns_id); + zlog_info("NS %u is to be disabled.", ns->ns_id); if (ns_master.ns_disable_hook) (*ns_master.ns_disable_hook)(ns); @@ -295,8 +297,7 @@ void ns_delete(struct ns *ns) } /* Look up the data pointer of the specified VRF. */ -void * -ns_info_lookup(ns_id_t ns_id) +void *ns_info_lookup(ns_id_t ns_id) { struct ns *ns = ns_lookup_internal(ns_id); @@ -385,18 +386,17 @@ char *ns_netns_pathname(struct vty *vty, const char *name) vty_out(vty, "Invalid pathname: %s\n", safe_strerror(errno)); else - zlog_warn("Invalid pathname: %s", - safe_strerror(errno)); + zlog_warn("Invalid pathname: %s", safe_strerror(errno)); return NULL; } check_base = basename(pathname); if (check_base != NULL && strlen(check_base) + 1 > NS_NAMSIZ) { if (vty) vty_out(vty, "NS name (%s) invalid: too long (>%d)\n", - check_base, NS_NAMSIZ-1); + check_base, NS_NAMSIZ - 1); else zlog_warn("NS name (%s) invalid: too long (>%d)", - check_base, NS_NAMSIZ-1); + check_base, NS_NAMSIZ - 1); return NULL; } return pathname; @@ -414,8 +414,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; @@ -435,8 +437,7 @@ void ns_init_management(ns_id_t default_ns_id) ns_init(); default_ns = ns_get_created_internal(NULL, NULL, default_ns_id); if (!default_ns) { - zlog_err("%s: failed to create the default NS!", - __func__); + zlog_err("%s: failed to create the default NS!", __func__); exit(1); } if (have_netns()) { @@ -446,13 +447,12 @@ void ns_init_management(ns_id_t default_ns_id) /* Set the default NS name. */ default_ns->name = XSTRDUP(MTYPE_NS_NAME, NS_DEFAULT_NAME); if (ns_debug) - zlog_info("%s: default NSID is %u", - __func__, default_ns->ns_id); + zlog_info("%s: default NSID is %u", __func__, + default_ns->ns_id); /* Enable the default NS. */ if (!ns_enable(default_ns, NULL)) { - zlog_err("%s: failed to enable the default NS!", - __func__); + zlog_err("%s: failed to enable the default NS!", __func__); exit(1); } } @@ -534,6 +534,5 @@ ns_id_t ns_get_default_id(void) { if (default_ns) return default_ns->ns_id; - return NS_UNKNOWN; + return NS_DEFAULT_INTERNAL; } - |
