From 18abc1ebfd83718a867206154b414edaa14583e4 Mon Sep 17 00:00:00 2001 From: vivek Date: Fri, 30 Mar 2018 00:13:58 +0000 Subject: [PATCH] bgpd: Cleanup linkage between L2 VNIs and L3 VNI When an L3 VNI is deleted, cleanup linkage to it from associated L2 VNIs. Updates: bgpd: keep a backpointer to vrf instance in struct bgpevpn [Mitesh Kanjariya] Signed-off-by: Vivek Venkatraman Reviewed-by: Mitesh Kanjariya --- bgpd/bgp_evpn.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index d9f99bc089..ec526a3129 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -4336,6 +4336,7 @@ int bgp_evpn_local_l3vni_del(vni_t l3vni, vrf_id_t vrf_id) struct bgp *bgp_vrf = NULL; /* bgp vrf instance */ struct bgp *bgp_def = NULL; /* default bgp instance */ struct listnode *node = NULL; + struct listnode *next = NULL; struct bgpevpn *vpn = NULL; bgp_vrf = bgp_lookup_by_vrf_id(vrf_id); @@ -4386,6 +4387,10 @@ int bgp_evpn_local_l3vni_del(vni_t l3vni, vrf_id_t vrf_id) } } + /* If any L2VNIs point to this instance, unlink them. */ + for (ALL_LIST_ELEMENTS(bgp_vrf->l2vnis, node, next, vpn)) + bgpevpn_unlink_from_l3vni(vpn); + /* Delete the instance if it was autocreated */ if (CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_AUTO)) bgp_delete(bgp_vrf); -- 2.39.5