summaryrefslogtreecommitdiff
path: root/zebra/zebra_ns.c
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2017-12-08 14:32:38 +0100
committerPhilippe Guibert <philippe.guibert@6wind.com>2018-02-27 11:11:24 +0100
commitff705b15dd5e191e727662412a8433d718887a08 (patch)
treec24cded67abdfb4af873cc13303c2274d13feb53 /zebra/zebra_ns.c
parent3347430b12ecccc4f03fb29111e9621a6e123b3c (diff)
zebra: handle the zns init/destroy
The zebra netnamespace contexts are initialised, based on the callback coming from the NS. Reversely, the list of ns is parsed to disable the ns contexts. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'zebra/zebra_ns.c')
-rw-r--r--zebra/zebra_ns.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/zebra/zebra_ns.c b/zebra/zebra_ns.c
index 6ce64b3a33..02fc2b1844 100644
--- a/zebra/zebra_ns.c
+++ b/zebra/zebra_ns.c
@@ -57,7 +57,11 @@ zebra_ns_table_entry_compare(const struct zebra_ns_table *e1,
struct zebra_ns *zebra_ns_lookup(ns_id_t ns_id)
{
- return dzns;
+ if (ns_id == NS_DEFAULT)
+ return dzns;
+ struct zebra_ns *info = (struct zebra_ns *)ns_info_lookup(ns_id);
+
+ return (info == NULL) ? dzns : info;
}
static struct zebra_ns *zebra_ns_alloc(void)
@@ -75,6 +79,11 @@ static int zebra_ns_new(struct ns *ns)
zns = zebra_ns_alloc();
ns->info = zns;
zns->ns = ns;
+
+ /* Do any needed per-NS data structure allocation. */
+ zns->if_table = route_table_init();
+ zebra_vxlan_ns_init(zns);
+
return 0;
}
@@ -101,7 +110,7 @@ static int zebra_ns_enabled(struct ns *ns)
return zebra_ns_enable(ns->ns_id, (void **)&zns);
}
-static int zebra_ns_disabled(struct ns *ns)
+int zebra_ns_disabled(struct ns *ns)
{
struct zebra_ns *zns = ns->info;
@@ -117,6 +126,8 @@ int zebra_ns_enable(ns_id_t ns_id, void **info)
{
struct zebra_ns *zns = (struct zebra_ns *)(*info);
+ zns->ns_id = ns_id;
+
#if defined(HAVE_RTADV)
rtadv_init(zns);
#endif
@@ -209,6 +220,8 @@ int zebra_ns_disable(ns_id_t ns_id, void **info)
kernel_terminate(zns);
+ zns->ns_id = NS_DEFAULT;
+
return 0;
}