]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Fix route handling for 2-level routing tables
authorvivek <vivek@cumulusnetworks.com>
Wed, 24 May 2017 06:08:09 +0000 (23:08 -0700)
committervivek <vivek@cumulusnetworks.com>
Thu, 25 May 2017 17:20:04 +0000 (10:20 -0700)
For certain (sub) address families such as EVPN or L3VPN, the routing
table is organized as a 2-level tree. Ensure that code walking the
routing table does the correct handling in such cases.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
bgpd/bgpd.c

index 92a0cd6acc145c3a2e86ba3393df50a9777cb9f3..9d404b16dc011616cfd3a3225cfa70eb262100f2 100644 (file)
@@ -1477,17 +1477,28 @@ bgp_recalculate_all_bestpaths (struct bgp *bgp)
 {
   afi_t afi;
   safi_t safi;
-  struct bgp_node *rn;
+  struct bgp_node *rn, *nrn;
 
   for (afi = AFI_IP; afi < AFI_MAX; afi++)
     {
       for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
         {
-          for (rn = bgp_table_top (bgp->rib[afi][safi]); rn; rn = bgp_route_next (rn))
+          for (rn = bgp_table_top (bgp->rib[afi][safi]); rn;
+               rn = bgp_route_next (rn))
             {
               if (rn->info != NULL)
                 {
-                  bgp_process (bgp, rn, afi, safi);
+                  /* Special handling for 2-level routing tables. */
+                  if (safi == SAFI_MPLS_VPN ||
+                      safi == SAFI_ENCAP ||
+                      safi == SAFI_EVPN)
+                    {
+                      for (nrn = bgp_table_top((struct bgp_table *)(rn->info));
+                           nrn; nrn = bgp_route_next (nrn))
+                        bgp_process (bgp, nrn, afi, safi);
+                    }
+                  else
+                    bgp_process (bgp, rn, afi, safi);
                 }
             }
         }
@@ -3289,6 +3300,8 @@ bgp_free (struct bgp *bgp)
 {
   afi_t afi;
   safi_t safi;
+  struct bgp_table *table;
+  struct bgp_node *rn;
 
   QOBJ_UNREG (bgp);
 
@@ -3304,6 +3317,18 @@ bgp_free (struct bgp *bgp)
   for (afi = AFI_IP; afi < AFI_MAX; afi++)
     for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
       {
+        /* Special handling for 2-level routing tables. */
+        if (safi == SAFI_MPLS_VPN ||
+            safi == SAFI_ENCAP ||
+            safi == SAFI_EVPN)
+          {
+            for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
+                 rn = bgp_route_next (rn))
+              {
+                table = (struct bgp_table *) rn->info;
+                bgp_table_finish(&table);
+              }
+          }
        if (bgp->route[afi][safi])
           bgp_table_finish (&bgp->route[afi][safi]);
        if (bgp->aggregate[afi][safi])