return (RB_FIND(ns_head, &ns_tree, &ns));
}
+/* Look up the data pointer of the specified VRF. */
+void *
+ns_info_lookup(ns_id_t ns_id)
+{
+ struct ns *ns = ns_lookup(ns_id);
+
+ return ns ? ns->info : NULL;
+}
+
+void ns_walk_func(int (*func)(struct ns *))
+{
+ struct ns *ns = NULL;
+
+ RB_FOREACH(ns, ns_head, &ns_tree)
+ func(ns);
+}
+
/* Look up a NS by name */
static struct ns *ns_lookup_name(const char *name)
{
extern int ns_handler_create(struct vty *vty, struct vrf *vrf,
char *pathname, ns_id_t ns_id);
extern char *ns_netns_pathname(struct vty *vty, const char *name);
+extern void *ns_info_lookup(ns_id_t ns_id);
+extern void ns_walk_func(int (*func)(struct ns *));
#endif /*_ZEBRA_NS_H*/
{
struct vrf *vrf;
struct zebra_vrf *zvrf;
- struct zebra_ns *zns;
zlog_notice("Terminating on signal");
}
vrf_terminate();
- zns = zebra_ns_lookup(NS_DEFAULT);
- zebra_ns_disable(0, (void **)&zns);
+ ns_walk_func(zebra_ns_disabled);
access_list_reset();
prefix_list_reset();
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)
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;
}
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;
{
struct zebra_ns *zns = (struct zebra_ns *)(*info);
+ zns->ns_id = ns_id;
+
#if defined(HAVE_RTADV)
rtadv_init(zns);
#endif
kernel_terminate(zns);
+ zns->ns_id = NS_DEFAULT;
+
return 0;
}
int zebra_ns_init(void);
int zebra_ns_enable(ns_id_t ns_id, void **info);
+int zebra_ns_disabled(struct ns *ns);
int zebra_ns_disable(ns_id_t ns_id, void **info);
extern struct route_table *zebra_ns_find_table(struct zebra_ns *zns,