BGP bestpath debugs need to display the addpath RX ID

Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-8459

Output with fix

2015/12/07 09:47:41.342932 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 3) and path 10.0.0.7 (addpath rxid 2) are equal via matching aspaths
2015/12/07 09:47:41.342966 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 3) wins over path 10.0.0.7 (addpath rxid 2) due to Router-ID comparison
2015/12/07 09:47:41.342978 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 4) and path 10.0.0.7 (addpath rxid 3) are equal via matching aspaths
2015/12/07 09:47:41.342988 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 4) loses to path 10.0.0.7 (addpath rxid 3) due to Router-ID comparison
2015/12/07 09:47:41.342999 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 5) and path 10.0.0.7 (addpath rxid 3) are equal via matching aspaths
2015/12/07 09:47:41.343008 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 5) loses to path 10.0.0.7 (addpath rxid 3) due to Router-ID comparison
2015/12/07 09:47:41.343019 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 6) and path 10.0.0.7 (addpath rxid 3) are equal via matching aspaths
2015/12/07 09:47:41.343029 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 6) loses to path 10.0.0.7 (addpath rxid 3) due to Router-ID comparison
2015/12/07 09:47:41.343039 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 7) and path 10.0.0.7 (addpath rxid 3) are equal via matching aspaths
2015/12/07 09:47:41.343048 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 7) loses to path 10.0.0.7 (addpath rxid 3) due to Router-ID comparison
2015/12/07 09:47:41.343058 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 3) is the bestpath from AS 0
2015/12/07 09:47:41.343068 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 3) is the initial bestpath
2015/12/07 09:47:41.343077 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 3) is the bestpath, now find multipaths
2015/12/07 09:47:41.343088 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 2) has the same nexthop as the bestpath, skip it
2015/12/07 09:47:41.343097 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 3) is the bestpath, add to the multipath list
2015/12/07 09:47:41.343109 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 4) and path 10.0.0.7 (addpath rxid 3) are equal via matching aspaths
2015/12/07 09:47:41.343119 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 4) loses to path 10.0.0.7 (addpath rxid 3) due to Router-ID comparison
2015/12/07 09:47:41.343127 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 4) is equivalent to the bestpath, add to the multipath list
2015/12/07 09:47:41.343139 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 5) and path 10.0.0.7 (addpath rxid 3) are equal via matching aspaths
2015/12/07 09:47:41.343164 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 5) loses to path 10.0.0.7 (addpath rxid 3) due to Router-ID comparison
2015/12/07 09:47:41.343173 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 5) is equivalent to the bestpath, add to the multipath list
2015/12/07 09:47:41.343186 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 6) and path 10.0.0.7 (addpath rxid 3) are equal via matching aspaths
2015/12/07 09:47:41.343196 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 6) loses to path 10.0.0.7 (addpath rxid 3) due to Router-ID comparison
2015/12/07 09:47:41.343205 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 6) is equivalent to the bestpath, add to the multipath list
2015/12/07 09:47:41.343217 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 7) and path 10.0.0.7 (addpath rxid 3) are equal via matching aspaths
2015/12/07 09:47:41.343227 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 7) loses to path 10.0.0.7 (addpath rxid 3) due to Router-ID comparison
2015/12/07 09:47:41.343236 BGP: 1.1.1.1/32: path 10.0.0.7 (addpath rxid 7) is equivalent to the bestpath, add to the multipath list
2015/12/07 09:47:41.343254 BGP: 1.1.1.1/32 add mpath nexthop 34.34.34.34 path 10.0.0.7 (addpath rxid 4)
2015/12/07 09:47:41.343268 BGP: 1.1.1.1/32 add mpath nexthop 56.56.56.56 path 10.0.0.7 (addpath rxid 6)
This commit is contained in:
Daniel Walton 2015-12-07 11:56:02 -08:00
parent f1db66bfc2
commit 2ec1e66ff1
3 changed files with 147 additions and 122 deletions

View file

@ -427,6 +427,7 @@ bgp_info_mpath_update (struct bgp_node *rn, struct bgp_info *new_best,
struct bgp_info *cur_mpath, *new_mpath, *next_mpath, *prev_mpath; struct bgp_info *cur_mpath, *new_mpath, *next_mpath, *prev_mpath;
int mpath_changed, debug; int mpath_changed, debug;
char pfx_buf[PREFIX2STR_BUFFER], nh_buf[2][INET6_ADDRSTRLEN]; char pfx_buf[PREFIX2STR_BUFFER], nh_buf[2][INET6_ADDRSTRLEN];
char path_buf[PATH_ADDPATH_STR_BUFFER];
mpath_changed = 0; mpath_changed = 0;
maxpaths = BGP_DEFAULT_MAXPATHS; maxpaths = BGP_DEFAULT_MAXPATHS;
@ -500,11 +501,13 @@ bgp_info_mpath_update (struct bgp_node *rn, struct bgp_info *new_best,
{ {
mpath_changed = 1; mpath_changed = 1;
if (debug) if (debug)
zlog_debug ("%s remove mpath nexthop %s peer %s", pfx_buf, {
bgp_info_path_with_addpath_rx_str(cur_mpath, path_buf);
zlog_debug ("%s remove mpath nexthop %s %s", pfx_buf,
inet_ntop (AF_INET, &cur_mpath->attr->nexthop, inet_ntop (AF_INET, &cur_mpath->attr->nexthop,
nh_buf[0], sizeof (nh_buf[0])), nh_buf[0], sizeof (nh_buf[0])),
sockunion2str (cur_mpath->peer->su_remote, path_buf);
nh_buf[1], sizeof (nh_buf[1]))); }
} }
mp_node = mp_next_node; mp_node = mp_next_node;
cur_mpath = next_mpath; cur_mpath = next_mpath;
@ -524,11 +527,13 @@ bgp_info_mpath_update (struct bgp_node *rn, struct bgp_info *new_best,
bgp_info_mpath_dequeue (cur_mpath); bgp_info_mpath_dequeue (cur_mpath);
mpath_changed = 1; mpath_changed = 1;
if (debug) if (debug)
zlog_debug ("%s remove mpath nexthop %s peer %s", pfx_buf, {
bgp_info_path_with_addpath_rx_str(cur_mpath, path_buf);
zlog_debug ("%s remove mpath nexthop %s %s", pfx_buf,
inet_ntop (AF_INET, &cur_mpath->attr->nexthop, inet_ntop (AF_INET, &cur_mpath->attr->nexthop,
nh_buf[0], sizeof (nh_buf[0])), nh_buf[0], sizeof (nh_buf[0])),
sockunion2str (cur_mpath->peer->su_remote, path_buf);
nh_buf[1], sizeof (nh_buf[1]))); }
cur_mpath = next_mpath; cur_mpath = next_mpath;
} }
else else
@ -558,11 +563,13 @@ bgp_info_mpath_update (struct bgp_node *rn, struct bgp_info *new_best,
mpath_changed = 1; mpath_changed = 1;
mpath_count++; mpath_count++;
if (debug) if (debug)
zlog_debug ("%s add mpath nexthop %s peer %s", pfx_buf, {
bgp_info_path_with_addpath_rx_str(new_mpath, path_buf);
zlog_debug ("%s add mpath nexthop %s %s", pfx_buf,
inet_ntop (AF_INET, &new_mpath->attr->nexthop, inet_ntop (AF_INET, &new_mpath->attr->nexthop,
nh_buf[0], sizeof (nh_buf[0])), nh_buf[0], sizeof (nh_buf[0])),
sockunion2str (new_mpath->peer->su_remote, path_buf);
nh_buf[1], sizeof (nh_buf[1]))); }
} }
mp_node = mp_next_node; mp_node = mp_next_node;
} }

View file

@ -318,6 +318,15 @@ bgp_med_value (struct attr *attr, struct bgp *bgp)
} }
} }
void
bgp_info_path_with_addpath_rx_str (struct bgp_info *ri, char *buf)
{
if (ri->addpath_rx_id)
sprintf(buf, "path %s (addpath rxid %d)", ri->peer->host, ri->addpath_rx_id);
else
sprintf(buf, "path %s", ri->peer->host);
}
/* Compare two bgp route entity. If 'new' is preferable over 'exist' return 1. */ /* Compare two bgp route entity. If 'new' is preferable over 'exist' return 1. */
static int static int
bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
@ -342,6 +351,8 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
int internal_as_route; int internal_as_route;
int confed_as_route; int confed_as_route;
int ret; int ret;
char new_buf[PATH_ADDPATH_STR_BUFFER];
char exist_buf[PATH_ADDPATH_STR_BUFFER];
*paths_eq = 0; *paths_eq = 0;
@ -353,14 +364,19 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
return 0; return 0;
} }
if (debug)
bgp_info_path_with_addpath_rx_str (new, new_buf);
if (exist == NULL) if (exist == NULL)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s is the initial bestpath", zlog_debug("%s: %s is the initial bestpath", pfx_buf, new_buf);
pfx_buf, new->peer->host);
return 1; return 1;
} }
if (debug)
bgp_info_path_with_addpath_rx_str (exist, exist_buf);
newattr = new->attr; newattr = new->attr;
existattr = exist->attr; existattr = exist->attr;
newattre = newattr->extra; newattre = newattr->extra;
@ -377,18 +393,16 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
if (new_weight > exist_weight) if (new_weight > exist_weight)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s wins over path %s due to weight %d > %d", zlog_debug("%s: %s wins over %s due to weight %d > %d",
pfx_buf, new->peer->host, exist->peer->host, new_weight, pfx_buf, new_buf, exist_buf, new_weight, exist_weight);
exist_weight);
return 1; return 1;
} }
if (new_weight < exist_weight) if (new_weight < exist_weight)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s loses to path %s due to weight %d < %d", zlog_debug("%s: %s loses to %s due to weight %d < %d",
pfx_buf, new->peer->host, exist->peer->host, new_weight, pfx_buf, new_buf, exist_buf, new_weight, exist_weight);
exist_weight);
return 0; return 0;
} }
@ -403,18 +417,16 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
if (new_pref > exist_pref) if (new_pref > exist_pref)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s wins over path %s due to localpref %d > %d", zlog_debug("%s: %s wins over %s due to localpref %d > %d",
pfx_buf, new->peer->host, exist->peer->host, new_pref, pfx_buf, new_buf, exist_buf, new_pref, exist_pref);
exist_pref);
return 1; return 1;
} }
if (new_pref < exist_pref) if (new_pref < exist_pref)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s loses to path %s due to localpref %d < %d", zlog_debug("%s: %s loses to %s due to localpref %d < %d",
pfx_buf, new->peer->host, exist->peer->host, new_pref, pfx_buf, new_buf, exist_buf, new_pref, exist_pref);
exist_pref);
return 0; return 0;
} }
@ -426,16 +438,16 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
if (! (new->sub_type == BGP_ROUTE_NORMAL)) if (! (new->sub_type == BGP_ROUTE_NORMAL))
{ {
if (debug) if (debug)
zlog_debug("%s: path %s wins over path %s due to preferred BGP_ROUTE type", zlog_debug("%s: %s wins over %s due to preferred BGP_ROUTE type",
pfx_buf, new->peer->host, exist->peer->host); pfx_buf, new_buf, exist_buf);
return 1; return 1;
} }
if (! (exist->sub_type == BGP_ROUTE_NORMAL)) if (! (exist->sub_type == BGP_ROUTE_NORMAL))
{ {
if (debug) if (debug)
zlog_debug("%s: path %s loses to path %s due to preferred BGP_ROUTE type", zlog_debug("%s: %s loses to %s due to preferred BGP_ROUTE type",
pfx_buf, new->peer->host, exist->peer->host); pfx_buf, new_buf, exist_buf);
return 0; return 0;
} }
@ -455,8 +467,8 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
if ( aspath_hops < (exist_hops + exist_confeds)) if ( aspath_hops < (exist_hops + exist_confeds))
{ {
if (debug) if (debug)
zlog_debug("%s: path %s wins over path %s due to aspath (with confeds) hopcount %d < %d", zlog_debug("%s: %s wins over %s due to aspath (with confeds) hopcount %d < %d",
pfx_buf, new->peer->host, exist->peer->host, pfx_buf, new_buf, exist_buf,
aspath_hops, (exist_hops + exist_confeds)); aspath_hops, (exist_hops + exist_confeds));
return 1; return 1;
} }
@ -464,8 +476,8 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
if ( aspath_hops > (exist_hops + exist_confeds)) if ( aspath_hops > (exist_hops + exist_confeds))
{ {
if (debug) if (debug)
zlog_debug("%s: path %s loses to path %s due to aspath (with confeds) hopcount %d > %d", zlog_debug("%s: %s loses to %s due to aspath (with confeds) hopcount %d > %d",
pfx_buf, new->peer->host, exist->peer->host, pfx_buf, new_buf, exist_buf,
aspath_hops, (exist_hops + exist_confeds)); aspath_hops, (exist_hops + exist_confeds));
return 0; return 0;
} }
@ -477,18 +489,16 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
if (newhops < exist_hops) if (newhops < exist_hops)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s wins over path %s due to aspath hopcount %d < %d", zlog_debug("%s: %s wins over %s due to aspath hopcount %d < %d",
pfx_buf, new->peer->host, exist->peer->host, pfx_buf, new_buf, exist_buf, newhops, exist_hops);
newhops, exist_hops);
return 1; return 1;
} }
if (newhops > exist_hops) if (newhops > exist_hops)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s loses to path %s due to aspath hopcount %d > %d", zlog_debug("%s: %s loses to %s due to aspath hopcount %d > %d",
pfx_buf, new->peer->host, exist->peer->host, pfx_buf, new_buf, exist_buf, newhops, exist_hops);
newhops, exist_hops);
return 0; return 0;
} }
} }
@ -498,8 +508,8 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
if (newattr->origin < existattr->origin) if (newattr->origin < existattr->origin)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s wins over path %s due to ORIGIN %s < %s", zlog_debug("%s: %s wins over %s due to ORIGIN %s < %s",
pfx_buf, new->peer->host, exist->peer->host, pfx_buf, new_buf, exist_buf,
bgp_origin_long_str[newattr->origin], bgp_origin_long_str[newattr->origin],
bgp_origin_long_str[existattr->origin]); bgp_origin_long_str[existattr->origin]);
return 1; return 1;
@ -508,8 +518,8 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
if (newattr->origin > existattr->origin) if (newattr->origin > existattr->origin)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s loses to path %s due to ORIGIN %s > %s", zlog_debug("%s: %s loses to %s due to ORIGIN %s > %s",
pfx_buf, new->peer->host, exist->peer->host, pfx_buf, new_buf, exist_buf,
bgp_origin_long_str[newattr->origin], bgp_origin_long_str[newattr->origin],
bgp_origin_long_str[existattr->origin]); bgp_origin_long_str[existattr->origin]);
return 0; return 0;
@ -536,18 +546,16 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
if (new_med < exist_med) if (new_med < exist_med)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s wins over path %s due to MED %d < %d", zlog_debug("%s: %s wins over %s due to MED %d < %d",
pfx_buf, new->peer->host, exist->peer->host, new_med, pfx_buf, new_buf, exist_buf, new_med, exist_med);
exist_med);
return 1; return 1;
} }
if (new_med > exist_med) if (new_med > exist_med)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s loses to path %s due to MED %d > %d", zlog_debug("%s: %s loses to %s due to MED %d > %d",
pfx_buf, new->peer->host, exist->peer->host, new_med, pfx_buf, new_buf, exist_buf, new_med, exist_med);
exist_med);
return 0; return 0;
} }
} }
@ -560,8 +568,8 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
&& (exist_sort == BGP_PEER_IBGP || exist_sort == BGP_PEER_CONFED)) && (exist_sort == BGP_PEER_IBGP || exist_sort == BGP_PEER_CONFED))
{ {
if (debug) if (debug)
zlog_debug("%s: path %s wins over path %s due to eBGP peer > iBGP peer", zlog_debug("%s: %s wins over %s due to eBGP peer > iBGP peer",
pfx_buf, new->peer->host, exist->peer->host); pfx_buf, new_buf, exist_buf);
return 1; return 1;
} }
@ -569,8 +577,8 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
&& (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED)) && (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED))
{ {
if (debug) if (debug)
zlog_debug("%s: path %s loses to path %s due to iBGP peer < eBGP peer", zlog_debug("%s: %s loses to %s due to iBGP peer < eBGP peer",
pfx_buf, new->peer->host, exist->peer->host); pfx_buf, new_buf, exist_buf);
return 0; return 0;
} }
@ -585,16 +593,16 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
if (newm < existm) if (newm < existm)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s wins over path %s due to IGP metric %d < %d", zlog_debug("%s: %s wins over %s due to IGP metric %d < %d",
pfx_buf, new->peer->host, exist->peer->host, newm, existm); pfx_buf, new_buf, exist_buf, newm, existm);
ret = 1; ret = 1;
} }
if (newm > existm) if (newm > existm)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s loses to path %s due to IGP metric %d > %d", zlog_debug("%s: %s loses to %s due to IGP metric %d > %d",
pfx_buf, new->peer->host, exist->peer->host, newm, existm); pfx_buf, new_buf, exist_buf, newm, existm);
ret = 0; ret = 0;
} }
@ -615,18 +623,16 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
if (newm < existm) if (newm < existm)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s wins over path %s due to CLUSTER_LIST length %d < %d", zlog_debug("%s: %s wins over %s due to CLUSTER_LIST length %d < %d",
pfx_buf, new->peer->host, exist->peer->host, newm, pfx_buf, new_buf, exist_buf, newm, existm);
existm);
ret = 1; ret = 1;
} }
if (newm > existm) if (newm > existm)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s loses to path %s due to CLUSTER_LIST length %d > %d", zlog_debug("%s: %s loses to %s due to CLUSTER_LIST length %d > %d",
pfx_buf, new->peer->host, exist->peer->host, newm, pfx_buf, new_buf, exist_buf, newm, existm);
existm);
ret = 0; ret = 0;
} }
} }
@ -638,16 +644,16 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
if (new_sort == BGP_PEER_CONFED && exist_sort == BGP_PEER_IBGP) if (new_sort == BGP_PEER_CONFED && exist_sort == BGP_PEER_IBGP)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s wins over path %s due to confed-external peer > confed-internal peer", zlog_debug("%s: %s wins over %s due to confed-external peer > confed-internal peer",
pfx_buf, new->peer->host, exist->peer->host); pfx_buf, new_buf, exist_buf);
return 1; return 1;
} }
if (exist_sort == BGP_PEER_CONFED && new_sort == BGP_PEER_IBGP) if (exist_sort == BGP_PEER_CONFED && new_sort == BGP_PEER_IBGP)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s loses to path %s due to confed-internal peer < confed-external peer", zlog_debug("%s: %s loses to %s due to confed-internal peer < confed-external peer",
pfx_buf, new->peer->host, exist->peer->host); pfx_buf, new_buf, exist_buf);
return 0; return 0;
} }
} }
@ -669,8 +675,8 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
*paths_eq = 1; *paths_eq = 1;
if (debug) if (debug)
zlog_debug("%s: path %s and path %s are equal via multipath-relax", zlog_debug("%s: %s and %s are equal via multipath-relax",
pfx_buf, new->peer->host, exist->peer->host); pfx_buf, new_buf, exist_buf);
} }
else if (new->peer->sort == BGP_PEER_IBGP) else if (new->peer->sort == BGP_PEER_IBGP)
{ {
@ -679,8 +685,8 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
*paths_eq = 1; *paths_eq = 1;
if (debug) if (debug)
zlog_debug("%s: path %s and path %s are equal via matching aspaths", zlog_debug("%s: %s and %s are equal via matching aspaths",
pfx_buf, new->peer->host, exist->peer->host); pfx_buf, new_buf, exist_buf);
} }
} }
else if (new->peer->as == exist->peer->as) else if (new->peer->as == exist->peer->as)
@ -688,8 +694,8 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
*paths_eq = 1; *paths_eq = 1;
if (debug) if (debug)
zlog_debug("%s: path %s and path %s are equal via same remote-as", zlog_debug("%s: %s and %s are equal via same remote-as",
pfx_buf, new->peer->host, exist->peer->host); pfx_buf, new_buf, exist_buf);
} }
} }
else else
@ -712,16 +718,16 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED)) if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED))
{ {
if (debug) if (debug)
zlog_debug("%s: path %s wins over path %s due to oldest external", zlog_debug("%s: %s wins over %s due to oldest external",
pfx_buf, new->peer->host, exist->peer->host); pfx_buf, new_buf, exist_buf);
return 1; return 1;
} }
if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED)) if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED))
{ {
if (debug) if (debug)
zlog_debug("%s: path %s loses to path %s due to oldest external", zlog_debug("%s: %s loses to %s due to oldest external",
pfx_buf, new->peer->host, exist->peer->host); pfx_buf, new_buf, exist_buf);
return 0; return 0;
} }
} }
@ -743,16 +749,16 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr)) if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr))
{ {
if (debug) if (debug)
zlog_debug("%s: path %s wins over path %s due to Router-ID comparison", zlog_debug("%s: %s wins over %s due to Router-ID comparison",
pfx_buf, new->peer->host, exist->peer->host); pfx_buf, new_buf, exist_buf);
return 1; return 1;
} }
if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr)) if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr))
{ {
if (debug) if (debug)
zlog_debug("%s: path %s loses to path %s due to Router-ID comparison", zlog_debug("%s: %s loses to %s due to Router-ID comparison",
pfx_buf, new->peer->host, exist->peer->host); pfx_buf, new_buf, exist_buf);
return 0; return 0;
} }
@ -763,18 +769,16 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
if (new_cluster < exist_cluster) if (new_cluster < exist_cluster)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s wins over path %s due to CLUSTER_LIST length %d < %d", zlog_debug("%s: %s wins over %s due to CLUSTER_LIST length %d < %d",
pfx_buf, new->peer->host, exist->peer->host, new_cluster, pfx_buf, new_buf, exist_buf, new_cluster, exist_cluster);
exist_cluster);
return 1; return 1;
} }
if (new_cluster > exist_cluster) if (new_cluster > exist_cluster)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s loses to path %s due to CLUSTER_LIST length %d > %d", zlog_debug("%s: %s loses to %s due to CLUSTER_LIST length %d > %d",
pfx_buf, new->peer->host, exist->peer->host, new_cluster, pfx_buf, new_buf, exist_buf, new_cluster, exist_cluster);
exist_cluster);
return 0; return 0;
} }
@ -785,16 +789,16 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
if (CHECK_FLAG (exist->flags, BGP_INFO_STALE)) if (CHECK_FLAG (exist->flags, BGP_INFO_STALE))
{ {
if (debug) if (debug)
zlog_debug("%s: path %s wins over path %s due to latter path being STALE", zlog_debug("%s: %s wins over %s due to latter path being STALE",
pfx_buf, new->peer->host, exist->peer->host); pfx_buf, new_buf, exist_buf);
return 1; return 1;
} }
if (CHECK_FLAG (new->flags, BGP_INFO_STALE)) if (CHECK_FLAG (new->flags, BGP_INFO_STALE))
{ {
if (debug) if (debug)
zlog_debug("%s: path %s loses to path %s due to former path being STALE", zlog_debug("%s: %s loses to %s due to former path being STALE",
pfx_buf, new->peer->host, exist->peer->host); pfx_buf, new_buf, exist_buf);
return 0; return 0;
} }
@ -803,22 +807,22 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
if (ret == 1) if (ret == 1)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s loses to path %s due to Neighor IP comparison", zlog_debug("%s: %s loses to %s due to Neighor IP comparison",
pfx_buf, new->peer->host, exist->peer->host); pfx_buf, new_buf, exist_buf);
return 0; return 0;
} }
if (ret == -1) if (ret == -1)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s wins over path %s due to Neighor IP comparison", zlog_debug("%s: %s wins over %s due to Neighor IP comparison",
pfx_buf, new->peer->host, exist->peer->host); pfx_buf, new_buf, exist_buf);
return 1; return 1;
} }
if (debug) if (debug)
zlog_debug("%s: path %s wins over path %s due to nothing left to compare", zlog_debug("%s: %s wins over %s due to nothing left to compare",
pfx_buf, new->peer->host, exist->peer->host); pfx_buf, new_buf, exist_buf);
return 1; return 1;
} }
@ -1507,6 +1511,7 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
int paths_eq, do_mpath, debug; int paths_eq, do_mpath, debug;
struct list mp_list; struct list mp_list;
char pfx_buf[PREFIX2STR_BUFFER]; char pfx_buf[PREFIX2STR_BUFFER];
char path_buf[PATH_ADDPATH_STR_BUFFER];
bgp_mp_list_init (&mp_list); bgp_mp_list_init (&mp_list);
do_mpath = (mpath_cfg->maxpaths_ebgp > 1 || mpath_cfg->maxpaths_ibgp > 1); do_mpath = (mpath_cfg->maxpaths_ebgp > 1 || mpath_cfg->maxpaths_ibgp > 1);
@ -1572,9 +1577,11 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED); bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
if (debug) if (debug)
zlog_debug("%s: path %s is the bestpath from AS %d", {
pfx_buf, new_select->peer->host, bgp_info_path_with_addpath_rx_str (new_select, path_buf);
aspath_get_firstas(new_select->attr->aspath)); zlog_debug("%s: %s is the bestpath from AS %d",
pfx_buf, path_buf, aspath_get_firstas(new_select->attr->aspath));
}
} }
} }
@ -1625,16 +1632,22 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
if (do_mpath && new_select) if (do_mpath && new_select)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s is the bestpath, now find multipaths", {
pfx_buf, new_select->peer->host); bgp_info_path_with_addpath_rx_str (new_select, path_buf);
zlog_debug("%s: %s is the bestpath, now find multipaths", pfx_buf, path_buf);
}
for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri) for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri)
{ {
if (debug)
bgp_info_path_with_addpath_rx_str (ri, path_buf);
if (ri == new_select) if (ri == new_select)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s is the bestpath, add to the multipath list", zlog_debug("%s: %s is the bestpath, add to the multipath list",
pfx_buf, ri->peer->host); pfx_buf, path_buf);
bgp_mp_list_add (&mp_list, ri); bgp_mp_list_add (&mp_list, ri);
continue; continue;
} }
@ -1651,8 +1664,8 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
if (!bgp_info_nexthop_cmp (ri, new_select)) if (!bgp_info_nexthop_cmp (ri, new_select))
{ {
if (debug) if (debug)
zlog_debug("%s: path %s has the same nexthop as the bestpath, skip it", zlog_debug("%s: %s has the same nexthop as the bestpath, skip it",
pfx_buf, ri->peer->host); pfx_buf, path_buf);
continue; continue;
} }
@ -1661,8 +1674,8 @@ bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
if (paths_eq) if (paths_eq)
{ {
if (debug) if (debug)
zlog_debug("%s: path %s is equivalent to the bestpath, add to the multipath list", zlog_debug("%s: %s is equivalent to the bestpath, add to the multipath list",
pfx_buf, ri->peer->host); pfx_buf, path_buf);
bgp_mp_list_add (&mp_list, ri); bgp_mp_list_add (&mp_list, ri);
} }
} }
@ -2080,12 +2093,13 @@ info_make (int type, int sub_type, u_short instance, struct peer *peer, struct a
} }
static void static void
bgp_info_addpath_rx_str(struct bgp_info *ri, char *buf) bgp_info_addpath_rx_str(u_int32_t addpath_id, char *buf)
{ {
if (ri && ri->addpath_rx_id) if (addpath_id)
sprintf(buf, " with addpath ID %d", ri->addpath_rx_id); sprintf(buf, " with addpath ID %d", addpath_id);
} }
/* Check if received nexthop is valid or not. */ /* Check if received nexthop is valid or not. */
static int static int
bgp_update_martian_nexthop (afi_t afi, safi_t safi, struct attr *attr) bgp_update_martian_nexthop (afi_t afi, safi_t safi, struct attr *attr)
@ -2258,7 +2272,7 @@ bgp_update_main (struct peer *peer, struct prefix *p, u_int32_t addpath_id,
{ {
if (bgp_debug_update(peer, p, NULL, 1)) if (bgp_debug_update(peer, p, NULL, 1))
{ {
bgp_info_addpath_rx_str(ri, buf2); bgp_info_addpath_rx_str(addpath_id, buf2);
zlog_debug ("%s rcvd %s/%d%s", zlog_debug ("%s rcvd %s/%d%s",
peer->host, peer->host,
inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
@ -2281,7 +2295,7 @@ bgp_update_main (struct peer *peer, struct prefix *p, u_int32_t addpath_id,
peer->rcvd_attr_printed = 1; peer->rcvd_attr_printed = 1;
} }
bgp_info_addpath_rx_str(ri, buf2); bgp_info_addpath_rx_str(addpath_id, buf2);
zlog_debug ("%s rcvd %s/%d%s...duplicate ignored", zlog_debug ("%s rcvd %s/%d%s...duplicate ignored",
peer->host, peer->host,
inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
@ -2307,7 +2321,7 @@ bgp_update_main (struct peer *peer, struct prefix *p, u_int32_t addpath_id,
{ {
if (bgp_debug_update(peer, p, NULL, 1)) if (bgp_debug_update(peer, p, NULL, 1))
{ {
bgp_info_addpath_rx_str(ri, buf2); bgp_info_addpath_rx_str(addpath_id, buf2);
zlog_debug ("%s rcvd %s/%d%s, flapped quicker than processing", zlog_debug ("%s rcvd %s/%d%s, flapped quicker than processing",
peer->host, peer->host,
inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
@ -2319,7 +2333,7 @@ bgp_update_main (struct peer *peer, struct prefix *p, u_int32_t addpath_id,
/* Received Logging. */ /* Received Logging. */
if (bgp_debug_update(peer, p, NULL, 1)) if (bgp_debug_update(peer, p, NULL, 1))
{ {
bgp_info_addpath_rx_str(ri, buf2); bgp_info_addpath_rx_str(addpath_id, buf2);
zlog_debug ("%s rcvd %s/%d%s", zlog_debug ("%s rcvd %s/%d%s",
peer->host, peer->host,
inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
@ -2413,7 +2427,7 @@ bgp_update_main (struct peer *peer, struct prefix *p, u_int32_t addpath_id,
peer->rcvd_attr_printed = 1; peer->rcvd_attr_printed = 1;
} }
bgp_info_addpath_rx_str(ri, buf2); bgp_info_addpath_rx_str(addpath_id, buf2);
zlog_debug ("%s rcvd %s/%d%s", zlog_debug ("%s rcvd %s/%d%s",
peer->host, peer->host,
inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
@ -2486,7 +2500,7 @@ bgp_update_main (struct peer *peer, struct prefix *p, u_int32_t addpath_id,
peer->rcvd_attr_printed = 1; peer->rcvd_attr_printed = 1;
} }
bgp_info_addpath_rx_str(ri, buf2); bgp_info_addpath_rx_str(addpath_id, buf2);
zlog_debug ("%s rcvd UPDATE about %s/%d%s -- DENIED due to: %s", zlog_debug ("%s rcvd UPDATE about %s/%d%s -- DENIED due to: %s",
peer->host, peer->host,
inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
@ -2541,7 +2555,7 @@ bgp_withdraw (struct peer *peer, struct prefix *p, u_int32_t addpath_id,
/* Logging. */ /* Logging. */
if (bgp_debug_update(peer, p, NULL, 1)) if (bgp_debug_update(peer, p, NULL, 1))
{ {
bgp_info_addpath_rx_str(ri, buf2); bgp_info_addpath_rx_str(addpath_id, buf2);
zlog_debug ("%s rcvd UPDATE about %s/%d%s -- withdrawn", zlog_debug ("%s rcvd UPDATE about %s/%d%s -- withdrawn",
peer->host, peer->host,
inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN), inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),

View file

@ -191,6 +191,9 @@ struct bgp_static
#define UNSUPPRESS_MAP_NAME(F) ((F)->usmap.name) #define UNSUPPRESS_MAP_NAME(F) ((F)->usmap.name)
#define UNSUPPRESS_MAP(F) ((F)->usmap.map) #define UNSUPPRESS_MAP(F) ((F)->usmap.map)
/* path PREFIX (addpath rxid NUMBER) */
#define PATH_ADDPATH_STR_BUFFER PREFIX2STR_BUFFER + 32
enum bgp_path_type enum bgp_path_type
{ {
BGP_PATH_ALL, BGP_PATH_ALL,
@ -229,6 +232,7 @@ extern void bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri);
extern struct bgp_info_extra *bgp_info_extra_get (struct bgp_info *); extern struct bgp_info_extra *bgp_info_extra_get (struct bgp_info *);
extern void bgp_info_set_flag (struct bgp_node *, struct bgp_info *, u_int32_t); extern void bgp_info_set_flag (struct bgp_node *, struct bgp_info *, u_int32_t);
extern void bgp_info_unset_flag (struct bgp_node *, struct bgp_info *, u_int32_t); extern void bgp_info_unset_flag (struct bgp_node *, struct bgp_info *, u_int32_t);
extern void bgp_info_path_with_addpath_rx_str (struct bgp_info *ri, char *buf);
extern int bgp_nlri_sanity_check (struct peer *, int, safi_t, u_char *, bgp_size_t, int *); extern int bgp_nlri_sanity_check (struct peer *, int, safi_t, u_char *, bgp_size_t, int *);
extern int bgp_nlri_parse (struct peer *, struct attr *, struct bgp_nlri *); extern int bgp_nlri_parse (struct peer *, struct attr *, struct bgp_nlri *);