]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: avoid initialising more than one the l3vni hash structure 3428/head
authorPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 6 Dec 2018 08:03:12 +0000 (09:03 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 17 Dec 2018 11:09:52 +0000 (12:09 +0100)
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 <philippe.guibert@6wind.com>
zebra/zebra_ns.c
zebra/zebra_router.c
zebra/zebra_vxlan.c
zebra/zebra_vxlan.h

index 965c8c206c7ffeb62ad0abefc938dafb6f8683d4..9b86657f1b092d3a36ad97ec3b2d1c06c95f9325 100644 (file)
@@ -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();
index afe3c708a012fa3ce20399c9cf008465908e2886..2e1c69fb9269af3cc29252e2b9577bd6a0b1c2e7 100644 (file)
@@ -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");
index ed1c185f1a8280041a5276342802773778e4c120..abc1f85c05ac2ec9417f696ab52012f218c11b87 100644 (file)
@@ -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);
 }
index eafc4812000888d6703dfeed58e5613cb88dc746..c50664a28ba45c346d420cde7b6fddcd78a2a376 100644 (file)
@@ -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,