diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-06-06 13:20:38 -0400 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-07-12 15:23:18 -0400 |
| commit | aadc0905054edac0fe88b35ae29236875d586cd8 (patch) | |
| tree | 71c405efd33d784450ef4d8010c0aafbe5b63751 /bgpd/bgp_debug.c | |
| parent | d5424e5356955e543cb31243f69e38cf68e05a33 (diff) | |
bgpd: Refactor 'struct attr_extra' into 'struct attr'
Most of the attributes in 'struct attr_extra' allow for
the more interesting cases of using bgp. The extra
overhead of managing it will induce errors as we add
more attributes and the extra memory overhead is
negligible on anything but full bgp feeds.
Additionally this greatly simplifies the code for
the handling of data.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd: Fix missing label set
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'bgpd/bgp_debug.c')
| -rw-r--r-- | bgpd/bgp_debug.c | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index a48df5c0c8..e4495c488c 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -387,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; @@ -397,73 +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->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)); + /* 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)); - 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_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_IPV4) - snprintf (buf, size, "nexthop %s", inet_ntoa (attr->nexthop)); - } + 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->extra->ecommunity)); + 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) |
