]> git.puffer.fish Git - mirror/frr.git/commitdiff
BGP: Unlink BGP instance from VRF only at the end of deletion
authorvivek <vivek@cumulusnetworks.com>
Sat, 14 May 2016 21:48:18 +0000 (14:48 -0700)
committervivek <vivek@cumulusnetworks.com>
Sat, 14 May 2016 22:57:43 +0000 (15:57 -0700)
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

bgpd/bgpd.c

index 1a2c874c245dc19fcde04922e605d7de91c3f466..7dd88be952c303d77abc85429d9ad6ece6a2f987 100644 (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);
 }