From: vivek Date: Sat, 14 May 2016 21:48:18 +0000 (-0700) Subject: BGP: Unlink BGP instance from VRF only at the end of deletion X-Git-Tag: frr-2.0-rc1~913 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=d3f5a0d3f51a8a7f3f02c38bd4c1c6870b4b2a5b;p=mirror%2Ffrr.git BGP: Unlink BGP instance from VRF only at the end of deletion When a BGP instance including the default instance is deleted, it needs to be unlinked from the corresponding VRF structure. However, instance deletion does not happen in one shot but needs a lot of threads to run - peer event handling, route processing etc. - before it can complete. Premature unlinking of the instance from underlying VRF would result in BGP routes not being deleted from the zebra RIB. Signed-off-by: Vivek Venkatraman Reviewed-by: Donald Sharp Ticket: CM-10930 Reviewed By: CCR-4717 Testing Done: Manual, bgp-smoke --- diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 1a2c874c24..7dd88be952 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -3038,7 +3038,6 @@ bgp_delete (struct bgp *bgp) struct peer *peer; struct peer_group *group; struct listnode *node, *next; - struct vrf *vrf; afi_t afi; int i; @@ -3107,11 +3106,6 @@ bgp_delete (struct bgp *bgp) /* Free interfaces in this instance. */ bgp_if_finish (bgp); - /* If Default instance or VRF, unlink from the VRF structure. */ - vrf = bgp_vrf_lookup_by_instance_type (bgp); - if (vrf) - bgp_vrf_unlink (bgp, vrf); - thread_master_free_unused(bm->master); bgp_unlock(bgp); /* initial reference */ @@ -3139,6 +3133,7 @@ bgp_free (struct bgp *bgp) { afi_t afi; safi_t safi; + struct vrf *vrf; list_delete (bgp->group); list_delete (bgp->peer); @@ -3162,6 +3157,12 @@ bgp_free (struct bgp *bgp) if (bgp->rib[afi][safi]) bgp_table_finish (&bgp->rib[afi][safi]); } + + /* If Default instance or VRF, unlink from the VRF structure. */ + vrf = bgp_vrf_lookup_by_instance_type (bgp); + if (vrf) + bgp_vrf_unlink (bgp, vrf); + XFREE (MTYPE_BGP, bgp); }