From: Donald Sharp Date: Wed, 15 Aug 2018 18:46:27 +0000 (-0400) Subject: bgpd: Convert zlog_warn to flog_warn for bgp_aspath.c and bgp_attr.c X-Git-Tag: frr-7.1-dev~371^2~49 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=559aaa3066f2c2aa93298f3dcecdee904ffa645d;p=mirror%2Ffrr.git bgpd: Convert zlog_warn to flog_warn for bgp_aspath.c and bgp_attr.c Signed-off-by: Donald Sharp --- diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c index d6ad52b3a6..55e5b03b15 100644 --- a/bgpd/bgp_aspath.c +++ b/bgpd/bgp_aspath.c @@ -35,9 +35,10 @@ #include "bgpd/bgp_aspath.h" #include "bgpd/bgp_debug.h" #include "bgpd/bgp_attr.h" +#include "bgpd/bgp_errors.h" /* Attr. Flags and Attr. Type Code. */ -#define AS_HEADER_SIZE 2 +#define AS_HEADER_SIZE 2 /* Now FOUR octets are used for AS value. */ #define AS_VALUE_SIZE sizeof (as_t) @@ -1638,8 +1639,8 @@ struct aspath *aspath_reconcile_as4(struct aspath *aspath, if (hops < 0) { if (BGP_DEBUG(as4, AS4)) - zlog_warn( - "[AS4] Fewer hops in AS_PATH than NEW_AS_PATH"); + flog_warn(BGP_WARN_ASPATH_FEWER_HOPS, + "[AS4] Fewer hops in AS_PATH than NEW_AS_PATH"); /* Something's gone wrong. The RFC says we should now ignore * AS4_PATH, * which is daft behaviour - it contains vital loop-detection diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 6acd4c8cf1..a993cc71c5 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -1760,9 +1760,9 @@ int bgp_mp_reach_parse(struct bgp_attr_parser_args *args, { uint8_t val; if ((val = stream_getc(s))) - zlog_warn( - "%s sent non-zero value, %u, for defunct SNPA-length field", - peer->host, val); + flog_warn(BGP_WARN_DEFUNCT_SNPA_LEN, + "%s sent non-zero value, %u, for defunct SNPA-length field", + peer->host, val); } /* must have nrli_len, what is left of the attribute */ @@ -2336,7 +2336,8 @@ static int bgp_attr_check(struct peer *peer, struct attr *attr) type = BGP_ATTR_LOCAL_PREF; if (type) { - zlog_warn("%s Missing well-known attribute %s.", peer->host, + flog_warn(BGP_WARN_MISSING_ATTRIBUTE, + "%s Missing well-known attribute %s.", peer->host, lookup_msg(attr_str, type, NULL)); bgp_notify_send_with_data(peer, BGP_NOTIFY_UPDATE_ERR, BGP_NOTIFY_UPDATE_MISS_ATTR, &type, @@ -2377,11 +2378,11 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr, /* Check remaining length check.*/ if (endp - BGP_INPUT_PNT(peer) < BGP_ATTR_MIN_LEN) { /* XXX warning: long int format, int arg (arg 5) */ - zlog_warn( - "%s: error BGP attribute length %lu is smaller than min len", - peer->host, - (unsigned long)(endp - - stream_pnt(BGP_INPUT(peer)))); + flog_warn(BGP_WARN_ATTRIBUTE_TOO_SMALL, + "%s: error BGP attribute length %lu is smaller than min len", + peer->host, + (unsigned long)(endp + - stream_pnt(BGP_INPUT(peer)))); bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR); @@ -2399,11 +2400,11 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr, /* Check whether Extended-Length applies and is in bounds */ if (CHECK_FLAG(flag, BGP_ATTR_FLAG_EXTLEN) && ((endp - startp) < (BGP_ATTR_MIN_LEN + 1))) { - zlog_warn( - "%s: Extended length set, but just %lu bytes of attr header", - peer->host, - (unsigned long)(endp - - stream_pnt(BGP_INPUT(peer)))); + flog_warn(BGP_WARN_EXT_ATTRIBUTE_TOO_SMALL, + "%s: Extended length set, but just %lu bytes of attr header", + peer->host, + (unsigned long)(endp + - stream_pnt(BGP_INPUT(peer)))); bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR); @@ -2421,9 +2422,9 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr, List. */ if (CHECK_BITMAP(seen, type)) { - zlog_warn( - "%s: error BGP attribute type %d appears twice in a message", - peer->host, type); + flog_warn(BGP_WARN_ATTRIBUTE_REPEATED, + "%s: error BGP attribute type %d appears twice in a message", + peer->host, type); bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, BGP_NOTIFY_UPDATE_MAL_ATTR); @@ -2439,10 +2440,10 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr, attr_endp = BGP_INPUT_PNT(peer) + length; if (attr_endp > endp) { - zlog_warn( - "%s: BGP type %d length %d is too large, attribute total length is %d. attr_endp is %p. endp is %p", - peer->host, type, length, size, attr_endp, - endp); + flog_warn(BGP_WARN_ATTRIBUTE_TOO_LARGE, + "%s: BGP type %d length %d is too large, attribute total length is %d. attr_endp is %p. endp is %p", + peer->host, type, length, size, attr_endp, + endp); /* * RFC 4271 6.3 * If any recognized attribute has an Attribute @@ -2597,7 +2598,8 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr, /* If hard error occured immediately return to the caller. */ if (ret == BGP_ATTR_PARSE_ERROR) { - zlog_warn("%s: Attribute %s, parse error", peer->host, + flog_warn(BGP_WARN_ATTRIBUTE_PARSE_ERROR, + "%s: Attribute %s, parse error", peer->host, lookup_msg(attr_str, type, NULL)); if (as4_path) aspath_unintern(&as4_path); @@ -2605,7 +2607,7 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr, } if (ret == BGP_ATTR_PARSE_WITHDRAW) { - zlog_warn( + flog_warn(BGP_WARN_ATTRIBUTE_PARSE_WITHDRAW, "%s: Attribute %s, parse error - treating as withdrawal", peer->host, lookup_msg(attr_str, type, NULL)); if (as4_path) @@ -2615,7 +2617,8 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr, /* Check the fetched length. */ if (BGP_INPUT_PNT(peer) != attr_endp) { - zlog_warn("%s: BGP attribute %s, fetch error", + flog_warn(BGP_WARN_ATTRIBUTE_FETCH_ERROR, + "%s: BGP attribute %s, fetch error", peer->host, lookup_msg(attr_str, type, NULL)); bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR); @@ -2627,7 +2630,8 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr, /* Check final read pointer is same as end pointer. */ if (BGP_INPUT_PNT(peer) != endp) { - zlog_warn("%s: BGP attribute %s, length mismatch", peer->host, + flog_warn(BGP_WARN_ATTRIBUTES_MISMATCH, + "%s: BGP attribute %s, length mismatch", peer->host, lookup_msg(attr_str, type, NULL)); bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR); diff --git a/bgpd/bgp_errors.c b/bgpd/bgp_errors.c index 50dd001b8b..5b0c4b0da5 100644 --- a/bgpd/bgp_errors.c +++ b/bgpd/bgp_errors.c @@ -24,6 +24,78 @@ #include "bgp_errors.h" /* clang-format off */ +static struct log_ref ferr_bgp_warn[] = { + { + .code = BGP_WARN_ASPATH_FEWER_HOPS, + .title = "BGP AS-path conversion has failed", + .description = "BGP has attempted to convert a AS2 to AS4 path and has failed", + .suggestion = "Open an Issue with all relevant log files and restart FRR" + }, + { + .code = BGP_WARN_DEFUNCT_SNPA_LEN, + .title = "BGP has received a value in a reserved field", + .description = "BGP has received a non-zero value in a reserved field that was used for SNPA-length at one point in time", + .suggestion = "BGP has peered with either a router that is attempting to send SNPA data or it has received a corrupted packet. If we are peering with a SNPA aware router(unlikely) upgrade that router, else open an Issue after gathering relevant log files", + }, + { + .code = BGP_WARN_MISSING_ATTRIBUTE, + .title = "BGP has received an update with missing a missing attribute", + .description = "BGP received update packets must have some minimum attribute information within them", + .suggestion = "Gather log data from this and remote peer and open an Issue with this data", + }, + { + .code = BGP_WARN_ATTRIBUTE_TOO_SMALL, + .title = "BGP udate packet with attribute data that is too small", + .description = "BGP has received an update packet that is too small to parse a given attribute. This typically means that something has gone wrong between us and the remote peer", + .suggestion = "Gather log data from this and remote peer and open an Issue with this data", + }, + { + .code = BGP_WARN_EXT_ATTRIBUTE_TOO_SMALL, + .title = "BGP udate packet with extended attribute data that is too small", + .description = "BGP has received an update packet that is too small to parse a given extended attribute. This typically means that something has gone wrong between us and the remote peer", + .suggestion = "Gather log data from this and remote peer and open an Issue with this data", + }, + { + .code = BGP_WARN_ATTRIBUTE_REPEATED, + .title = "BGP update packet received with a repeated attribute", + .description = "BGP has received an update packet with a attribute that is repeated more than one time for a particular route. This typically means that something has gone wrong between us and the remote peer", + .suggestion = "Gather log data from this and remote peer and open an Issue with this data", + }, + { + .code = BGP_WARN_ATTRIBUTE_TOO_LARGE, + .title = "BGP udate packet with attribute data that is too large", + .description = "BGP has received an update packet that has too much data in a particular attribute. This typically means that something has gone wrong between us and the remote peer", + .suggestion = "Gather log data from this and remote peer and open an Issue with this data", + }, + { + .code = BGP_WARN_ATTRIBUTE_PARSE_ERROR, + .title = "BGP update packet with attribute data has a parse error, specific to the attribute", + .description = "BGP has received an update packet with an attribute that when parsed does not make sense in some manner", + .suggestion = "Gather log data from this and remote peer and open an Issue with this data", + }, + { + .code = BGP_WARN_ATTRIBUTE_PARSE_WITHDRAW, + .title = "BGP update packet with a broken optional attribute has caused a withdraw of associated routes", + .description = "BGP has received a update packet with optional attributes that did not parse correctly, instead of resetting the peer, withdraw associated routes and note that this has happened", + .suggestion = "Gather log data from this and remote peer and open an Issue with this data", + }, + { + .code = BGP_WARN_ATTRIBUTE_FETCH_ERROR, + .title = "BGP update packet with a broken length", + .description = "BGP has received a update packet with an attribute that has an incorrect length", + .suggestion = "Gather log data from this and remote peer and open an Issue with this data", + }, + { + .code = BGP_WARN_ATTRIBUTES_MISMATCH, + .title = "BGP update packet with a length different than attribute data length", + .description = "BGP has received a update packet with attributes that when parsed do not correctly add up to packet data length", + .suggestion = "Gather log data from this and remote peer and open an Issue with this data", + }, + { + .code = END_FERR, + } +}; + static struct log_ref ferr_bgp_err[] = { { .code = BGP_ERR_ATTR_FLAG, @@ -302,5 +374,6 @@ static struct log_ref ferr_bgp_err[] = { void bgp_error_init(void) { + log_ref_add(ferr_bgp_warn); log_ref_add(ferr_bgp_err); } diff --git a/bgpd/bgp_errors.h b/bgpd/bgp_errors.h index be718d99e7..f9291b19f4 100644 --- a/bgpd/bgp_errors.h +++ b/bgpd/bgp_errors.h @@ -72,6 +72,17 @@ enum bgp_log_refs { BGP_ERR_EVPN_INSTANCE_MISMATCH, BGP_ERR_FLOWSPEC_PACKET, BGP_ERR_FLOWSPEC_INSTALLATION, + BGP_WARN_ASPATH_FEWER_HOPS, + BGP_WARN_DEFUNCT_SNPA_LEN, + BGP_WARN_MISSING_ATTRIBUTE, + BGP_WARN_ATTRIBUTE_TOO_SMALL, + BGP_WARN_EXT_ATTRIBUTE_TOO_SMALL, + BGP_WARN_ATTRIBUTE_REPEATED, + BGP_WARN_ATTRIBUTE_TOO_LARGE, + BGP_WARN_ATTRIBUTE_PARSE_ERROR, + BGP_WARN_ATTRIBUTE_PARSE_WITHDRAW, + BGP_WARN_ATTRIBUTE_FETCH_ERROR, + BGP_WARN_ATTRIBUTES_MISMATCH, }; extern void bgp_error_init(void);