From: Donald Sharp Date: Mon, 20 Nov 2023 18:57:59 +0000 (-0500) Subject: zebra: Cleanup svd_nh_table on shutdown X-Git-Tag: base_10.0~241^2~2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=a7628b1b2d88282d981991b7afb16e7e290602d5;p=matthieu%2Ffrr.git zebra: Cleanup svd_nh_table on shutdown Signed-off-by: Donald Sharp --- diff --git a/zebra/zebra_router.c b/zebra/zebra_router.c index 5299716091..d75f57f16f 100644 --- a/zebra/zebra_router.c +++ b/zebra/zebra_router.c @@ -246,6 +246,7 @@ void zebra_router_terminate(void) zebra_script_destroy(); #endif + zebra_vxlan_terminate(); /* OS-specific deinit */ kernel_router_terminate(); } diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 5480a94d27..91a5bc4d42 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -82,7 +82,7 @@ static int zl3vni_nh_uninstall(struct zebra_l3vni *zl3vni, struct zebra_neigh *n); static struct zebra_neigh *svd_nh_add(const struct ipaddr *vtep_ip, const struct ethaddr *rmac); -static int svd_nh_del(struct zebra_neigh *n); +static void svd_nh_del(struct zebra_neigh *n); static int svd_nh_install(struct zebra_l3vni *zl3vni, struct zebra_neigh *n); static int svd_nh_uninstall(struct zebra_l3vni *zl3vni, struct zebra_neigh *n); @@ -1590,17 +1590,24 @@ static struct zebra_neigh *svd_nh_add(const struct ipaddr *ip, /* * Del Single VXlan Device neighbor entry. */ -static int svd_nh_del(struct zebra_neigh *n) +static void svd_nh_del(struct zebra_neigh *n) { if (n->refcnt > 0) - return -1; + return; hash_release(svd_nh_table, n); XFREE(MTYPE_L3NEIGH, n); +} - return 0; +static void svd_nh_del_terminate(void *ptr) +{ + struct zebra_neigh *n = ptr; + + n->refcnt = 0; + svd_nh_del(n); } + /* * Common code to install remote nh as neigh into the kernel. */ @@ -5813,6 +5820,11 @@ void zebra_vxlan_init(void) zebra_evpn_mh_init(); } +void zebra_vxlan_terminate(void) +{ + hash_clean_and_free(&svd_nh_table, svd_nh_del_terminate); +} + /* free l3vni table */ void zebra_vxlan_disable(void) { diff --git a/zebra/zebra_vxlan.h b/zebra/zebra_vxlan.h index 98c2767eb2..5785e0b3c3 100644 --- a/zebra/zebra_vxlan.h +++ b/zebra/zebra_vxlan.h @@ -185,6 +185,7 @@ 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_init(void); +extern void zebra_vxlan_terminate(void); extern void zebra_vxlan_disable(void); extern void zebra_vxlan_evpn_vrf_route_add(vrf_id_t vrf_id, const struct ethaddr *rmac,