summaryrefslogtreecommitdiff
path: root/zebra/zebra_ns.c
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2019-12-26 17:46:08 +0100
committerGitHub <noreply@github.com>2019-12-26 17:46:08 +0100
commitd7cce42cc78cfbe25e3cc19a612b1caee3c26809 (patch)
tree2eefe24860f639fd7646596538a93951ab6ca83d /zebra/zebra_ns.c
parent7655aa34c9d81c72e4d523d1c8bd959d8e6c43d9 (diff)
parentfd4c24f5e38bb686d86f0f7b3d8f48bcde7c67f7 (diff)
Merge pull request #5350 from sworleys/Fix-NS-Defualt-Info
zebra: Fix default ns->info should point to default zebra_ns
Diffstat (limited to 'zebra/zebra_ns.c')
-rw-r--r--zebra/zebra_ns.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/zebra/zebra_ns.c b/zebra/zebra_ns.c
index 37f53bf911..3287176ef5 100644
--- a/zebra/zebra_ns.c
+++ b/zebra/zebra_ns.c
@@ -37,6 +37,7 @@
#include "zebra_pbr.h"
#include "rib.h"
#include "table_manager.h"
+#include "zebra_errors.h"
extern struct zebra_privs_t zserv_privs;
@@ -64,6 +65,9 @@ static int zebra_ns_new(struct ns *ns)
{
struct zebra_ns *zns;
+ if (!ns)
+ return -1;
+
if (IS_ZEBRA_DEBUG_EVENT)
zlog_info("ZNS %s with id %u (created)", ns->name, ns->ns_id);
@@ -86,7 +90,7 @@ static int zebra_ns_delete(struct ns *ns)
zlog_info("ZNS %s with id %u (deleted)", ns->name, ns->ns_id);
if (!zns)
return 0;
- XFREE(MTYPE_ZEBRA_NS, zns);
+ XFREE(MTYPE_ZEBRA_NS, ns->info);
return 0;
}
@@ -175,19 +179,26 @@ int zebra_ns_final_shutdown(struct ns *ns)
int zebra_ns_init(const char *optional_default_name)
{
+ struct ns *default_ns;
ns_id_t ns_id;
ns_id_t ns_id_external;
- dzns = zebra_ns_alloc();
-
frr_with_privs(&zserv_privs) {
ns_id = zebra_ns_id_get_default();
}
ns_id_external = ns_map_nsid_with_external(ns_id, true);
ns_init_management(ns_id_external, ns_id);
+ default_ns = ns_lookup(ns_get_default_id());
+ if (!default_ns) {
+ flog_err(EC_ZEBRA_NS_NO_DEFAULT,
+ "%s: failed to find default ns", __func__);
+ exit(EXIT_FAILURE); /* This is non-recoverable */
+ }
+
/* Do any needed per-NS data structure allocation. */
- dzns->if_table = route_table_init();
+ zebra_ns_new(default_ns);
+ dzns = default_ns->info;
/* Register zebra VRF callbacks, create and activate default VRF. */
zebra_vrf_init();