From 6548050a858b4d9bad54b96068c6966e491e8cf4 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Thu, 6 Dec 2018 09:03:12 +0100 Subject: [PATCH] zebra: avoid initialising more than one the l3vni hash structure the l3vni structure is allocated only once, since that structure is only used for default netns. For that, move the initialisation part is moved to a proper place, where there is no risk of attempting to initialise it more than once, even when vrf backend is netns. Signed-off-by: Philippe Guibert --- zebra/zebra_ns.c | 3 --- zebra/zebra_router.c | 5 +++-- zebra/zebra_vxlan.c | 4 ++-- zebra/zebra_vxlan.h | 4 ++-- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/zebra/zebra_ns.c b/zebra/zebra_ns.c index 965c8c206c..9b86657f1b 100644 --- a/zebra/zebra_ns.c +++ b/zebra/zebra_ns.c @@ -76,7 +76,6 @@ static int zebra_ns_new(struct ns *ns) /* Do any needed per-NS data structure allocation. */ zns->if_table = route_table_init(); - zebra_vxlan_ns_init(zns); return 0; } @@ -142,7 +141,6 @@ int zebra_ns_enable(ns_id_t ns_id, void **info) static int zebra_ns_disable_internal(struct zebra_ns *zns, bool complete) { route_table_finish(zns->if_table); - zebra_vxlan_ns_disable(zns); #if defined(HAVE_RTADV) rtadv_terminate(zns); #endif @@ -201,7 +199,6 @@ int zebra_ns_init(void) /* Do any needed per-NS data structure allocation. */ dzns->if_table = route_table_init(); - zebra_vxlan_ns_init(dzns); /* Register zebra VRF callbacks, create and activate default VRF. */ zebra_vrf_init(); diff --git a/zebra/zebra_router.c b/zebra/zebra_router.c index afe3c708a0..2e1c69fb92 100644 --- a/zebra/zebra_router.c +++ b/zebra/zebra_router.c @@ -24,6 +24,7 @@ #include "zebra_router.h" #include "zebra_memory.h" #include "zebra_pbr.h" +#include "zebra_vxlan.h" struct zebra_router zrouter; @@ -157,6 +158,7 @@ void zebra_router_terminate(void) zebra_router_free_table(zrt); } + zebra_vxlan_disable(); hash_clean(zrouter.rules_hash, zebra_pbr_rules_free); hash_free(zrouter.rules_hash); @@ -170,8 +172,7 @@ void zebra_router_terminate(void) void zebra_router_init(void) { - zrouter.l3vni_table = NULL; - + zebra_vxlan_init(); zrouter.rules_hash = hash_create_size(8, zebra_pbr_rules_hash_key, zebra_pbr_rules_hash_equal, "Rules Hash"); diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index ed1c185f1a..abc1f85c05 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -8864,14 +8864,14 @@ void zebra_vxlan_close_tables(struct zebra_vrf *zvrf) } /* init the l3vni table */ -void zebra_vxlan_ns_init(struct zebra_ns *zns) +void zebra_vxlan_init(void) { zrouter.l3vni_table = hash_create(l3vni_hash_keymake, l3vni_hash_cmp, "Zebra VRF L3 VNI table"); } /* free l3vni table */ -void zebra_vxlan_ns_disable(struct zebra_ns *zns) +void zebra_vxlan_disable(void) { hash_free(zrouter.l3vni_table); } diff --git a/zebra/zebra_vxlan.h b/zebra/zebra_vxlan.h index eafc481200..c50664a28b 100644 --- a/zebra/zebra_vxlan.h +++ b/zebra/zebra_vxlan.h @@ -183,8 +183,8 @@ extern int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf, vni_t vni, extern void zebra_vxlan_init_tables(struct zebra_vrf *zvrf); extern void zebra_vxlan_close_tables(struct zebra_vrf *); extern void zebra_vxlan_cleanup_tables(struct zebra_vrf *); -extern void zebra_vxlan_ns_init(struct zebra_ns *zns); -extern void zebra_vxlan_ns_disable(struct zebra_ns *zns); +extern void zebra_vxlan_init(void); +extern void zebra_vxlan_disable(void); extern void zebra_vxlan_evpn_vrf_route_add(vrf_id_t vrf_id, struct ethaddr *rmac, struct ipaddr *ip,