diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c index 30eefdb5f..c0e1a6163 100644 --- a/bgpd/bgp_mpath.c +++ b/bgpd/bgp_mpath.c @@ -103,7 +103,7 @@ bgp_maximum_paths_unset (struct bgp *bgp, afi_t afi, safi_t safi, * or greater than zero if bi1 is respectively less than, equal to, * or greater than bi2. */ -static int +int bgp_info_nexthop_cmp (struct bgp_info *bi1, struct bgp_info *bi2) { struct attr_extra *ae1, *ae2; diff --git a/bgpd/bgp_mpath.h b/bgpd/bgp_mpath.h index 0c8137041..729b2c8ca 100644 --- a/bgpd/bgp_mpath.h +++ b/bgpd/bgp_mpath.h @@ -59,6 +59,7 @@ extern int bgp_maximum_paths_unset (struct bgp *, afi_t, safi_t, int); /* Functions used by bgp_best_selection to record current * multipath selections */ +extern int bgp_info_nexthop_cmp (struct bgp_info *bi1, struct bgp_info *bi2); extern void bgp_mp_list_init (struct list *); extern void bgp_mp_list_clear (struct list *); extern void bgp_mp_list_add (struct list *, struct bgp_info *); diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index eae8f6164..4d5d6ad69 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -1637,12 +1637,20 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, if (ri->peer->status != Established) continue; + if (!bgp_info_nexthop_cmp (ri, new_select)) + { + if (debug) + zlog_debug("%s: path %s has the same nexthop as the bestpath, skip it", + pfx_buf, ri->peer->host); + continue; + } + bgp_info_cmp (bgp, ri, new_select, &paths_eq, mpath_cfg, debug, pfx_buf); if (paths_eq) { if (debug) - zlog_debug("%s: %s path is equivalent to the bestpath, add to the multipath list", + zlog_debug("%s: path %s is equivalent to the bestpath, add to the multipath list", pfx_buf, ri->peer->host); bgp_mp_list_add (&mp_list, ri); } diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index db9781001..3ad59ff0c 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -6899,10 +6899,10 @@ bgp_config_write (struct vty *vty) { vty_out (vty, " bgp bestpath as-path multipath-relax as-set%s", VTY_NEWLINE); } - } - else - { - vty_out (vty, " no bgp bestpath as-path multipath-relax%s", VTY_NEWLINE); + else + { + vty_out (vty, " bgp bestpath as-path multipath-relax%s", VTY_NEWLINE); + } } if (bgp_flag_check (bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) {