From b21e0c937528765db57e6d9b10bf6429fa5787e3 Mon Sep 17 00:00:00 2001 From: Anuradha Karuppiah Date: Tue, 16 Apr 2019 18:49:28 -0700 Subject: [PATCH] pim: fix order of vxlan mroutes cleanup when pimd is shutdown 1. vxlan instance cleanup needs to be done before the upstream entries are force-flushed. 2. also vxlan callbacks need to be ignored post instance-cleanup. Signed-off-by: Anuradha Karuppiah --- pimd/pim_instance.c | 3 ++- pimd/pim_vxlan.c | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/pimd/pim_instance.c b/pimd/pim_instance.c index 1416d8de55..a2bf3d2783 100644 --- a/pimd/pim_instance.c +++ b/pimd/pim_instance.c @@ -36,6 +36,8 @@ static void pim_instance_terminate(struct pim_instance *pim) { + pim_vxlan_exit(pim); + if (pim->ssm_info) { pim_ssm_terminate(pim->ssm_info); pim->ssm_info = NULL; @@ -60,7 +62,6 @@ static void pim_instance_terminate(struct pim_instance *pim) pim_oil_terminate(pim); pim_msdp_exit(pim); - pim_vxlan_exit(pim); XFREE(MTYPE_PIM_PIM_INSTANCE, pim); } diff --git a/pimd/pim_vxlan.c b/pimd/pim_vxlan.c index e973c8c045..af76c6d732 100644 --- a/pimd/pim_vxlan.c +++ b/pimd/pim_vxlan.c @@ -858,7 +858,9 @@ static void pim_vxlan_set_default_iif(struct pim_instance *pim, /* add/del upstream entries for the existing vxlan SG when the * interface becomes available */ - hash_iterate(pim->vxlan.sg_hash, pim_vxlan_orig_mr_iif_update, ifp); + if (pim->vxlan.sg_hash) + hash_iterate(pim->vxlan.sg_hash, + pim_vxlan_orig_mr_iif_update, ifp); } static void pim_vxlan_set_peerlink_rif(struct pim_instance *pim, @@ -889,7 +891,9 @@ static void pim_vxlan_set_peerlink_rif(struct pim_instance *pim, /* add/del upstream entries for the existing vxlan SG when the * interface becomes available */ - hash_iterate(pim->vxlan.sg_hash, pim_vxlan_orig_mr_iif_update, ifp); + if (pim->vxlan.sg_hash) + hash_iterate(pim->vxlan.sg_hash, + pim_vxlan_orig_mr_iif_update, ifp); } void pim_vxlan_add_vif(struct interface *ifp) @@ -972,8 +976,10 @@ void pim_vxlan_add_term_dev(struct pim_instance *pim, } pim->vxlan.term_if = ifp; - hash_iterate(pim_ifp->pim->vxlan.sg_hash, - pim_vxlan_term_mr_oif_update, ifp); + + if (pim->vxlan.sg_hash) + hash_iterate(pim_ifp->pim->vxlan.sg_hash, + pim_vxlan_term_mr_oif_update, ifp); } void pim_vxlan_del_term_dev(struct pim_instance *pim) @@ -985,8 +991,10 @@ void pim_vxlan_del_term_dev(struct pim_instance *pim) zlog_debug("vxlan term oif changed from %s to -", ifp->name); pim->vxlan.term_if = NULL; - hash_iterate(pim->vxlan.sg_hash, - pim_vxlan_term_mr_oif_update, NULL); + + if (pim->vxlan.sg_hash) + hash_iterate(pim->vxlan.sg_hash, + pim_vxlan_term_mr_oif_update, NULL); pim_ifp = (struct pim_interface *)ifp->info; if (pim_ifp) { -- 2.39.5