diff options
Diffstat (limited to 'bgpd/bgp_debug.c')
| -rw-r--r-- | bgpd/bgp_debug.c | 82 |
1 files changed, 51 insertions, 31 deletions
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index e45b5ab4e3..f9e67d96ca 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -39,6 +39,9 @@ #include "bgpd/bgp_community.h" #include "bgpd/bgp_updgrp.h" #include "bgpd/bgp_mplsvpn.h" +#include "bgpd/bgp_ecommunity.h" +#include "bgpd/bgp_label.h" +#include "bgpd/bgp_evpn.h" unsigned long conf_bgp_debug_as4; unsigned long conf_bgp_debug_neighbor_events; @@ -384,6 +387,8 @@ bgp_debug_peer_updout_enabled(char *host) int bgp_dump_attr (struct attr *attr, char *buf, size_t size) { + char addrbuf[BUFSIZ]; + if (! attr) return 0; @@ -394,66 +399,68 @@ bgp_dump_attr (struct attr *attr, char *buf, size_t size) snprintf (buf + strlen (buf), size - strlen (buf), ", origin %s", bgp_origin_str[attr->origin]); - if (attr->extra) - { - char addrbuf[BUFSIZ]; + /* Add MP case. */ + if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL + || attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) + snprintf (buf + strlen (buf), size - strlen (buf), ", mp_nexthop %s", + inet_ntop (AF_INET6, &attr->mp_nexthop_global, + addrbuf, BUFSIZ)); - /* Add MP case. */ - if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL - || attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) - snprintf (buf + strlen (buf), size - strlen (buf), ", mp_nexthop %s", - inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, - addrbuf, BUFSIZ)); + if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) + snprintf (buf + strlen (buf), size - strlen (buf), "(%s)", + inet_ntop (AF_INET6, &attr->mp_nexthop_local, + addrbuf, BUFSIZ)); - if (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) - snprintf (buf + strlen (buf), size - strlen (buf), "(%s)", - inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, - addrbuf, BUFSIZ)); - } + if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV4) + snprintf (buf, size, "nexthop %s", inet_ntoa (attr->nexthop)); if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))) snprintf (buf + strlen (buf), size - strlen (buf), ", localpref %u", attr->local_pref); - if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))) + if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))) snprintf (buf + strlen (buf), size - strlen (buf), ", metric %u", attr->med); - if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES))) + if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES))) snprintf (buf + strlen (buf), size - strlen (buf), ", community %s", community_str (attr->community)); + if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES))) + snprintf (buf + strlen (buf), size - strlen (buf), ", extcommunity %s", + ecommunity_str (attr->ecommunity)); + if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE))) snprintf (buf + strlen (buf), size - strlen (buf), ", atomic-aggregate"); if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))) snprintf (buf + strlen (buf), size - strlen (buf), ", aggregated by %u %s", - attr->extra->aggregator_as, - inet_ntoa (attr->extra->aggregator_addr)); + attr->aggregator_as, + inet_ntoa (attr->aggregator_addr)); if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))) snprintf (buf + strlen (buf), size - strlen (buf), ", originator %s", - inet_ntoa (attr->extra->originator_id)); + inet_ntoa (attr->originator_id)); if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST))) { int i; snprintf (buf + strlen (buf), size - strlen (buf), ", clusterlist"); - for (i = 0; i < attr->extra->cluster->length / 4; i++) + for (i = 0; i < attr->cluster->length / 4; i++) snprintf (buf + strlen (buf), size - strlen (buf), " %s", - inet_ntoa (attr->extra->cluster->list[i])); + inet_ntoa (attr->cluster->list[i])); } - if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH))) + if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH))) snprintf (buf + strlen (buf), size - strlen (buf), ", path %s", aspath_print (attr->aspath)); if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_PREFIX_SID))) { - if (attr->extra->label_index != BGP_INVALID_LABEL_INDEX) + if (attr->label_index != BGP_INVALID_LABEL_INDEX) snprintf (buf + strlen (buf), size - strlen (buf), ", label-index %u", - attr->extra->label_index); + attr->label_index); } if (strlen (buf) > 1) @@ -2142,12 +2149,14 @@ bgp_debug_zebra (struct prefix *p) } const char * -bgp_debug_rdpfxpath2str (struct prefix_rd *prd, union prefixconstptr pu, - int addpath_valid, u_int32_t addpath_id, - char *str, int size) +bgp_debug_rdpfxpath2str (afi_t afi, safi_t safi, + struct prefix_rd *prd, union prefixconstptr pu, + mpls_label_t *label, int addpath_valid, + u_int32_t addpath_id, char *str, int size) { char rd_buf[RD_ADDRSTRLEN]; char pfx_buf[PREFIX_STRLEN]; + char tag_buf[30]; /* ' with addpath ID ' 17 * max strlen of uint32 + 10 * +/- (just in case) + 1 @@ -2163,13 +2172,24 @@ bgp_debug_rdpfxpath2str (struct prefix_rd *prd, union prefixconstptr pu, if (addpath_valid) snprintf(pathid_buf, sizeof(pathid_buf), " with addpath ID %u", addpath_id); + tag_buf[0] = '\0'; + if (bgp_labeled_safi (safi) && label) + { + u_int32_t label_value; + + label_value = decode_label (label); + sprintf (tag_buf, " label %u", label_value); + } + if (prd) - snprintf (str, size, "RD %s %s%s", + snprintf (str, size, "RD %s %s%s%s", prefix_rd2str(prd, rd_buf, sizeof (rd_buf)), - prefix2str (pu, pfx_buf, sizeof (pfx_buf)), pathid_buf); + prefix2str (pu, pfx_buf, sizeof (pfx_buf)), + tag_buf, pathid_buf); else - snprintf (str, size, "%s%s", - prefix2str (pu, pfx_buf, sizeof (pfx_buf)), pathid_buf); + snprintf (str, size, "%s%s%s", + prefix2str (pu, pfx_buf, sizeof (pfx_buf)), + tag_buf, pathid_buf); return str; } |
