From: Donald Sharp Date: Wed, 20 May 2015 01:04:01 +0000 (-0700) Subject: The path ordering has an impact on whether paths are flagged as multipath, this shoul... X-Git-Tag: frr-2.0-rc1~1430 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=f4eeff72d5be6c1065f11face168a4bcd832de78;p=mirror%2Ffrr.git The path ordering has an impact on whether paths are flagged as multipath, this should not be the case. --- diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 2e572fe757..ef26656aff 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -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);