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 <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-10930
Reviewed By: CCR-4717
Testing Done: Manual, bgp-smoke
This commit is contained in:
vivek 2016-05-14 14:48:18 -07:00
parent 3ff8613314
commit d3f5a0d3f5

View File

@ -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);
}