]> git.puffer.fish Git - mirror/frr.git/commitdiff
BGP: Fix linkage between BGP instance and VRF structure
authorvivek <vivek@cumulusnetworks.com>
Wed, 16 Mar 2016 20:38:31 +0000 (20:38 +0000)
committervivek <vivek@cumulusnetworks.com>
Wed, 16 Mar 2016 20:38:31 +0000 (20:38 +0000)
The issue here has to do with the fact that VRFs (like interfaces) are not
actually getting deleted when they are removed - they remain present. This
leads to situations in which BGP may try to unlink more than once, which
messes up the reference count (lock) in the BGP instance.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Ticket: CM-9419
Reviewed By: CCR-4302
Testing Done: Manual, also verified by Atul

<DETAILED DESCRIPTION (REPLACE)>

bgpd/bgpd.h

index 3a0a679d6fd5b19106c93d2db84b9e4882e2663b..240694bb6d6a90365828c5dc666fe76b1f37a810 100644 (file)
@@ -1458,17 +1458,22 @@ static inline void
 bgp_vrf_link (struct bgp *bgp, struct vrf *vrf)
 {
   bgp->vrf_id = vrf->vrf_id;
-  bgp_lock (bgp);
-  vrf->info = (void *)bgp;
-
+  if (vrf->info != (void *)bgp)
+    {
+      bgp_lock (bgp);
+      vrf->info = (void *)bgp;
+    }
 }
 
 /* Unlink BGP instance from VRF. */
 static inline void
 bgp_vrf_unlink (struct bgp *bgp, struct vrf *vrf)
 {
-  vrf->info = NULL;
-  bgp_unlock (bgp);
+  if (vrf->info == (void *)bgp)
+    {
+      vrf->info = NULL;
+      bgp_unlock (bgp);
+    }
   bgp->vrf_id = VRF_DEFAULT;
 }