Merge pull request #6916 from ton31337/feature/dump_attributes_for_debugging_if_malformed_7.4

bgpd: [7.4] Dump attributes before returning from bgp_attr_malformed()
This commit is contained in:
Rafael Zalamena 2020-08-20 11:23:04 +00:00 committed by GitHub
commit d752b00409
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 5 deletions

View File

@ -1148,6 +1148,7 @@ bgp_attr_malformed(struct bgp_attr_parser_args *args, uint8_t subcode,
bgp_size_t length) bgp_size_t length)
{ {
struct peer *const peer = args->peer; struct peer *const peer = args->peer;
struct attr *const attr = args->attr;
const uint8_t flags = args->flags; const uint8_t flags = args->flags;
/* startp and length must be special-cased, as whether or not to /* startp and length must be special-cased, as whether or not to
* send the attribute data with the NOTIFY depends on the error, * send the attribute data with the NOTIFY depends on the error,
@ -1155,6 +1156,14 @@ bgp_attr_malformed(struct bgp_attr_parser_args *args, uint8_t subcode,
*/ */
uint8_t *notify_datap = (length > 0 ? args->startp : NULL); uint8_t *notify_datap = (length > 0 ? args->startp : NULL);
if (bgp_debug_update(peer, NULL, NULL, 1)) {
char attr_str[BUFSIZ] = {0};
bgp_dump_attr(attr, attr_str, sizeof(attr_str));
zlog_debug("%s: attributes: %s", __func__, attr_str);
}
/* Only relax error handling for eBGP peers */ /* Only relax error handling for eBGP peers */
if (peer->sort != BGP_PEER_EBGP) { if (peer->sort != BGP_PEER_EBGP) {
bgp_notify_send_with_data(peer, BGP_NOTIFY_UPDATE_ERR, subcode, bgp_notify_send_with_data(peer, BGP_NOTIFY_UPDATE_ERR, subcode,

View File

@ -3174,7 +3174,7 @@ static int bgp_evpn_route_rmac_self_check(struct bgp *bgp_vrf,
char buf1[PREFIX_STRLEN]; char buf1[PREFIX_STRLEN];
char attr_str[BUFSIZ] = {0}; char attr_str[BUFSIZ] = {0};
bgp_dump_attr(pi->attr, attr_str, BUFSIZ); bgp_dump_attr(pi->attr, attr_str, sizeof(attr_str));
zlog_debug("%s: bgp %u prefix %s with attr %s - DENIED due to self mac", zlog_debug("%s: bgp %u prefix %s with attr %s - DENIED due to self mac",
__func__, bgp_vrf->vrf_id, __func__, bgp_vrf->vrf_id,
@ -5625,7 +5625,8 @@ int bgp_filter_evpn_routes_upon_martian_nh_change(struct bgp *bgp)
char attr_str[BUFSIZ] = {0}; char attr_str[BUFSIZ] = {0};
bgp_dump_attr(pi->attr, bgp_dump_attr(pi->attr,
attr_str, BUFSIZ); attr_str,
sizeof(attr_str));
zlog_debug( zlog_debug(
"%u: prefix %pRN with attr %s - DENIED due to martian or self nexthop", "%u: prefix %pRN with attr %s - DENIED due to martian or self nexthop",

View File

@ -1580,7 +1580,8 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size)
if (attr_parse_ret == BGP_ATTR_PARSE_WITHDRAW if (attr_parse_ret == BGP_ATTR_PARSE_WITHDRAW
|| BGP_DEBUG(update, UPDATE_IN) || BGP_DEBUG(update, UPDATE_IN)
|| BGP_DEBUG(update, UPDATE_PREFIX)) { || BGP_DEBUG(update, UPDATE_PREFIX)) {
ret = bgp_dump_attr(&attr, peer->rcvd_attr_str, BUFSIZ); ret = bgp_dump_attr(&attr, peer->rcvd_attr_str,
sizeof(peer->rcvd_attr_str));
peer->stat_upd_7606++; peer->stat_upd_7606++;

View File

@ -824,7 +824,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
memset(send_attr_str, 0, BUFSIZ); memset(send_attr_str, 0, BUFSIZ);
send_attr_printed = 0; send_attr_printed = 0;
bgp_dump_attr(adv->baa->attr, send_attr_str, bgp_dump_attr(adv->baa->attr, send_attr_str,
BUFSIZ); sizeof(send_attr_str));
} }
} }
@ -1140,7 +1140,7 @@ void subgroup_default_update_packet(struct update_subgroup *subgrp,
attrstr[0] = '\0'; attrstr[0] = '\0';
bgp_dump_attr(attr, attrstr, BUFSIZ); bgp_dump_attr(attr, attrstr, sizeof(attrstr));
if (addpath_encode) if (addpath_encode)
snprintf(tx_id_buf, sizeof(tx_id_buf), snprintf(tx_id_buf, sizeof(tx_id_buf),