]> git.puffer.fish Git - mirror/frr.git/commitdiff
The path ordering has an impact on whether paths are flagged as multipath, this shoul...
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 20 May 2015 01:04:01 +0000 (18:04 -0700)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 20 May 2015 01:04:01 +0000 (18:04 -0700)
bgpd/bgp_route.c

index 2e572fe757837d1c675aea166d11a673f2f0694e..ef26656affba0eb3abd86f6fcdf54d4227b63ff1 100644 (file)
@@ -1996,8 +1996,6 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
             continue;
 
        new_select = ri1;
-       if (do_mpath)
-         bgp_mp_list_add (&mp_list, ri1);
        old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL;
        if (ri1->next)
          for (ri2 = ri1->next; ri2; ri2 = ri2->next)
@@ -2023,24 +2021,13 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
                    {
                      bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
                      new_select = ri2;
-                     if (do_mpath && !paths_eq)
-                       {
-                         bgp_mp_list_clear (&mp_list);
-                         bgp_mp_list_add (&mp_list, ri2);
-                       }
                    }
 
-                 if (do_mpath && paths_eq)
-                   bgp_mp_list_add (&mp_list, ri2);
-
                  bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK);
                }
            }
        bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK);
        bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
-
-       bgp_info_mpath_update (rn, new_select, old_select, &mp_list, mpath_cfg);
-       bgp_mp_list_clear (&mp_list);
       }
 
   /* Check old selected route and new selected route. */
@@ -2080,24 +2067,44 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
 
       if (bgp_info_cmp (bgp, ri, new_select, &paths_eq, mpath_cfg))
        {
-         if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
-           bgp_mp_dmed_deselect (new_select);
-
          new_select = ri;
-
-         if (do_mpath && !paths_eq)
-           {
-             bgp_mp_list_clear (&mp_list);
-             bgp_mp_list_add (&mp_list, ri);
-           }
        }
-      else if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
-       bgp_mp_dmed_deselect (ri);
-
-      if (do_mpath && paths_eq)
-       bgp_mp_list_add (&mp_list, ri);
     }
     
+  /* Now that we know which path is the bestpath see if any of the other paths
+   * qualify as multipaths
+   */
+  if (do_mpath && new_select)
+    {
+      for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri)
+        {
+          if (ri == new_select)
+            {
+             bgp_mp_list_add (&mp_list, ri);
+              continue;
+            }
+
+          if (BGP_INFO_HOLDDOWN (ri))
+            continue;
+
+          if (ri->peer &&
+              ri->peer != bgp->peer_self &&
+              !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT))
+            if (ri->peer->status != Established)
+              continue;
+
+          if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)
+              && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED)))
+             continue;
+
+          bgp_info_cmp (bgp, ri, new_select, &paths_eq, mpath_cfg);
+
+          if (paths_eq)
+            {
+             bgp_mp_list_add (&mp_list, ri);
+            }
+        }
+    }
 
   if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
     bgp_info_mpath_update (rn, new_select, old_select, &mp_list, mpath_cfg);