--- embedaddon/quagga/bgpd/bgp_mpath.c 2013/07/21 23:54:37 1.1.1.2 +++ embedaddon/quagga/bgpd/bgp_mpath.c 2016/11/02 10:09:10 1.1.1.3 @@ -28,6 +28,7 @@ #include "linklist.h" #include "sockunion.h" #include "memory.h" +#include "filter.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_table.h" @@ -39,6 +40,33 @@ #include "bgpd/bgp_ecommunity.h" #include "bgpd/bgp_mpath.h" +bool +bgp_mpath_is_configured_sort (struct bgp *bgp, bgp_peer_sort_t sort, + afi_t afi, safi_t safi) +{ + struct bgp_maxpaths_cfg *cfg = &bgp->maxpaths[afi][safi]; + + /* XXX: BGP_DEFAULT_MAXPATHS is 1, and this test only seems to make sense + * if if it stays 1, so not sure the DEFAULT define is that useful. + */ + switch (sort) + { + case BGP_PEER_IBGP: + return cfg->maxpaths_ibgp != BGP_DEFAULT_MAXPATHS; + case BGP_PEER_EBGP: + return cfg->maxpaths_ebgp != BGP_DEFAULT_MAXPATHS; + default: + return false; + } +} + +bool +bgp_mpath_is_configured (struct bgp *bgp, afi_t afi, safi_t safi) +{ + return bgp_mpath_is_configured_sort (bgp, BGP_PEER_IBGP, afi, safi) + || bgp_mpath_is_configured_sort (bgp, BGP_PEER_EBGP, afi, safi); +} + /* * bgp_maximum_paths_set * @@ -120,7 +148,6 @@ bgp_info_nexthop_cmp (struct bgp_info *bi1, struct bgp compare = IPV4_ADDR_CMP (&ae1->mp_nexthop_global_in, &ae2->mp_nexthop_global_in); break; -#ifdef HAVE_IPV6 case 16: compare = IPV6_ADDR_CMP (&ae1->mp_nexthop_global, &ae2->mp_nexthop_global); @@ -132,7 +159,6 @@ bgp_info_nexthop_cmp (struct bgp_info *bi1, struct bgp compare = IPV6_ADDR_CMP (&ae1->mp_nexthop_local, &ae2->mp_nexthop_local); break; -#endif /* HAVE_IPV6 */ } } @@ -395,13 +421,14 @@ bgp_info_mpath_attr_set (struct bgp_info *binfo, struc void bgp_info_mpath_update (struct bgp_node *rn, struct bgp_info *new_best, struct bgp_info *old_best, struct list *mp_list, - struct bgp_maxpaths_cfg *mpath_cfg) + afi_t afi, safi_t safi) { u_int16_t maxpaths, mpath_count, old_mpath_count; struct listnode *mp_node, *mp_next_node; struct bgp_info *cur_mpath, *new_mpath, *next_mpath, *prev_mpath; int mpath_changed, debug; char pfx_buf[INET_ADDRSTRLEN], nh_buf[2][INET_ADDRSTRLEN]; + struct bgp_maxpaths_cfg *mpath_cfg = NULL; mpath_changed = 0; maxpaths = BGP_DEFAULT_MAXPATHS; @@ -410,6 +437,7 @@ bgp_info_mpath_update (struct bgp_node *rn, struct bgp old_mpath_count = 0; prev_mpath = new_best; mp_node = listhead (mp_list); + debug = BGP_DEBUG (events, EVENTS); if (debug) @@ -417,6 +445,7 @@ bgp_info_mpath_update (struct bgp_node *rn, struct bgp if (new_best) { + mpath_cfg = &new_best->peer->bgp->maxpaths[afi][safi]; mpath_count++; if (new_best != old_best) bgp_info_mpath_dequeue (new_best); @@ -715,10 +744,8 @@ bgp_info_mpath_aggregate_update (struct bgp_info *new_ /* Zap multipath attr nexthop so we set nexthop to self */ attr.nexthop.s_addr = 0; -#ifdef HAVE_IPV6 if (attr.extra) memset (&attr.extra->mp_nexthop_global, 0, sizeof (struct in6_addr)); -#endif /* HAVE_IPV6 */ /* TODO: should we set ATOMIC_AGGREGATE and AGGREGATOR? */