diff options
Diffstat (limited to 'zebra/zebra_ns.c')
| -rw-r--r-- | zebra/zebra_ns.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/zebra/zebra_ns.c b/zebra/zebra_ns.c index cb302985c8..192e8ad413 100644 --- a/zebra/zebra_ns.c +++ b/zebra/zebra_ns.c @@ -36,23 +36,22 @@ #include "debug.h" #include "zebra_netns_notify.h" #include "zebra_netns_id.h" +#include "zebra_pbr.h" extern struct zebra_privs_t zserv_privs; DEFINE_MTYPE(ZEBRA, ZEBRA_NS, "Zebra Name Space") -static inline int -zebra_ns_table_entry_compare(const struct zebra_ns_table *e1, - const struct zebra_ns_table *e2); +static inline int zebra_ns_table_entry_compare(const struct zebra_ns_table *e1, + const struct zebra_ns_table *e2); RB_GENERATE(zebra_ns_table_head, zebra_ns_table, zebra_ns_table_entry, zebra_ns_table_entry_compare); static struct zebra_ns *dzns; -static inline int -zebra_ns_table_entry_compare(const struct zebra_ns_table *e1, - const struct zebra_ns_table *e2) +static inline int zebra_ns_table_entry_compare(const struct zebra_ns_table *e1, + const struct zebra_ns_table *e2) { if (e1->tableid == e2->tableid) return (e1->afi - e2->afi); @@ -96,7 +95,7 @@ static int zebra_ns_new(struct ns *ns) static int zebra_ns_delete(struct ns *ns) { - struct zebra_ns *zns = (struct zebra_ns *) ns->info; + struct zebra_ns *zns = (struct zebra_ns *)ns->info; if (IS_ZEBRA_DEBUG_EVENT) zlog_info("ZNS %s with id %u (deleted)", ns->name, ns->ns_id); @@ -146,8 +145,8 @@ int zebra_ns_enable(ns_id_t ns_id, void **info) return 0; } -struct route_table *zebra_ns_find_table(struct zebra_ns *zns, - uint32_t tableid, afi_t afi) +struct route_table *zebra_ns_find_table(struct zebra_ns *zns, uint32_t tableid, + afi_t afi) { struct zebra_ns_table finder; struct zebra_ns_table *znst; @@ -213,12 +212,15 @@ int zebra_ns_disable(ns_id_t ns_id, void **info) struct zebra_ns_table *znst; struct zebra_ns *zns = (struct zebra_ns *)(*info); + hash_clean(zns->rules_hash, zebra_pbr_rules_free); + hash_free(zns->rules_hash); while (!RB_EMPTY(zebra_ns_table_head, &zns->ns_tables)) { znst = RB_ROOT(zebra_ns_table_head, &zns->ns_tables); RB_REMOVE(zebra_ns_table_head, &zns->ns_tables, znst); zebra_ns_free_table(znst); } + route_table_finish(zns->if_table); zebra_vxlan_ns_disable(zns); #if defined(HAVE_RTADV) @@ -259,6 +261,9 @@ int zebra_ns_init(void) /* Default NS is activated */ zebra_ns_enable(ns_id, (void **)&dzns); + dzns->rules_hash = + hash_create_size(8, zebra_pbr_rules_hash_key, + zebra_pbr_rules_hash_equal, "Rules Hash"); if (vrf_is_backend_netns()) { ns_add_hook(NS_NEW_HOOK, zebra_ns_new); ns_add_hook(NS_ENABLE_HOOK, zebra_ns_enabled); @@ -275,7 +280,7 @@ static int logicalrouter_config_write(struct vty *vty) struct ns *ns; int write = 0; - RB_FOREACH(ns, ns_head, &ns_tree) { + RB_FOREACH (ns, ns_head, &ns_tree) { if (ns->ns_id == NS_DEFAULT || ns->name == NULL) continue; vty_out(vty, "logical-router %u netns %s\n", ns->ns_id, |
