diff options
Diffstat (limited to 'bgpd')
37 files changed, 655 insertions, 631 deletions
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c index b156cda86d..1f8a910f2f 100644 --- a/bgpd/bgp_aspath.c +++ b/bgpd/bgp_aspath.c @@ -1640,7 +1640,7 @@ struct aspath *aspath_reconcile_as4(struct aspath *aspath, if (hops < 0) { if (BGP_DEBUG(as4, AS4)) flog_warn( - BGP_WARN_ASPATH_FEWER_HOPS, + EC_BGP_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, diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index a603bbcd8b..c7d7c56a12 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -260,11 +260,11 @@ void bgp_attr_flush_encap(struct attr *attr) * * This algorithm could be made faster if needed */ -static int encap_same(struct bgp_attr_encap_subtlv *h1, - struct bgp_attr_encap_subtlv *h2) +static int encap_same(const struct bgp_attr_encap_subtlv *h1, + const struct bgp_attr_encap_subtlv *h2) { - struct bgp_attr_encap_subtlv *p; - struct bgp_attr_encap_subtlv *q; + const struct bgp_attr_encap_subtlv *p; + const struct bgp_attr_encap_subtlv *q; if (h1 == h2) return 1; @@ -357,8 +357,8 @@ static unsigned int encap_hash_key_make(void *p) static int encap_hash_cmp(const void *p1, const void *p2) { - return encap_same((struct bgp_attr_encap_subtlv *)p1, - (struct bgp_attr_encap_subtlv *)p2); + return encap_same((const struct bgp_attr_encap_subtlv *)p1, + (const struct bgp_attr_encap_subtlv *)p2); } static void encap_init(void) @@ -997,14 +997,13 @@ bgp_attr_flags_diagnose(struct bgp_attr_parser_args *args, for (i = 0; i <= 2; i++) /* O,T,P, but not E */ if (CHECK_FLAG(desired_flags, attr_flag_str[i].key) != CHECK_FLAG(real_flags, attr_flag_str[i].key)) { - flog_err( - BGP_ERR_ATTR_FLAG, - "%s attribute must%s be flagged as \"%s\"", - lookup_msg(attr_str, attr_code, NULL), - CHECK_FLAG(desired_flags, attr_flag_str[i].key) - ? "" - : " not", - attr_flag_str[i].str); + flog_err(EC_BGP_ATTR_FLAG, + "%s attribute must%s be flagged as \"%s\"", + lookup_msg(attr_str, attr_code, NULL), + CHECK_FLAG(desired_flags, attr_flag_str[i].key) + ? "" + : " not", + attr_flag_str[i].str); seen = 1; } if (!seen) { @@ -1063,7 +1062,7 @@ static int bgp_attr_flag_invalid(struct bgp_attr_parser_args *args) if (!CHECK_FLAG(BGP_ATTR_FLAG_OPTIONAL, flags) && !CHECK_FLAG(BGP_ATTR_FLAG_TRANS, flags)) { flog_err( - BGP_ERR_ATTR_FLAG, + EC_BGP_ATTR_FLAG, "%s well-known attributes must have transitive flag set (%x)", lookup_msg(attr_str, attr_code, NULL), flags); return 1; @@ -1075,18 +1074,18 @@ static int bgp_attr_flag_invalid(struct bgp_attr_parser_args *args) */ if (CHECK_FLAG(flags, BGP_ATTR_FLAG_PARTIAL)) { if (!CHECK_FLAG(flags, BGP_ATTR_FLAG_OPTIONAL)) { - flog_err(BGP_ERR_ATTR_FLAG, - "%s well-known attribute " - "must NOT have the partial flag set (%x)", - lookup_msg(attr_str, attr_code, NULL), flags); + flog_err(EC_BGP_ATTR_FLAG, + "%s well-known attribute " + "must NOT have the partial flag set (%x)", + lookup_msg(attr_str, attr_code, NULL), flags); return 1; } if (CHECK_FLAG(flags, BGP_ATTR_FLAG_OPTIONAL) && !CHECK_FLAG(flags, BGP_ATTR_FLAG_TRANS)) { - flog_err(BGP_ERR_ATTR_FLAG, - "%s optional + transitive attribute " - "must NOT have the partial flag set (%x)", - lookup_msg(attr_str, attr_code, NULL), flags); + flog_err(EC_BGP_ATTR_FLAG, + "%s optional + transitive attribute " + "must NOT have the partial flag set (%x)", + lookup_msg(attr_str, attr_code, NULL), flags); return 1; } } @@ -1118,8 +1117,8 @@ static bgp_attr_parse_ret_t bgp_attr_origin(struct bgp_attr_parser_args *args) field contains the erroneous attribute (type, length and value). */ if (length != 1) { - flog_err(BGP_ERR_ATTR_LEN, - "Origin attribute length is not one %d", length); + flog_err(EC_BGP_ATTR_LEN, + "Origin attribute length is not one %d", length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); } @@ -1132,8 +1131,8 @@ static bgp_attr_parse_ret_t bgp_attr_origin(struct bgp_attr_parser_args *args) contains the unrecognized attribute (type, length and value). */ if ((attr->origin != BGP_ORIGIN_IGP) && (attr->origin != BGP_ORIGIN_EGP) && (attr->origin != BGP_ORIGIN_INCOMPLETE)) { - flog_err(BGP_ERR_ATTR_ORIGIN, - "Origin attribute value is invalid %d", attr->origin); + flog_err(EC_BGP_ATTR_ORIGIN, + "Origin attribute value is invalid %d", attr->origin); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_INVAL_ORIGIN, args->total); } @@ -1161,9 +1160,9 @@ static int bgp_attr_aspath(struct bgp_attr_parser_args *args) /* In case of IBGP, length will be zero. */ if (!attr->aspath) { - flog_err(BGP_ERR_ATTR_MAL_AS_PATH, - "Malformed AS path from %s, length is %d", peer->host, - length); + flog_err(EC_BGP_ATTR_MAL_AS_PATH, + "Malformed AS path from %s, length is %d", peer->host, + length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_MAL_AS_PATH, 0); } @@ -1191,8 +1190,8 @@ static bgp_attr_parse_ret_t bgp_attr_aspath_check(struct peer *const peer, && !aspath_left_confed_check(attr->aspath)) || (peer->sort == BGP_PEER_EBGP && aspath_confed_check(attr->aspath))) { - flog_err(BGP_ERR_ATTR_MAL_AS_PATH, "Malformed AS path from %s", - peer->host); + flog_err(EC_BGP_ATTR_MAL_AS_PATH, "Malformed AS path from %s", + peer->host); bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, BGP_NOTIFY_UPDATE_MAL_AS_PATH); return BGP_ATTR_PARSE_ERROR; @@ -1202,9 +1201,9 @@ static bgp_attr_parse_ret_t bgp_attr_aspath_check(struct peer *const peer, if (CHECK_FLAG(peer->flags, PEER_FLAG_ENFORCE_FIRST_AS)) { if (peer->sort == BGP_PEER_EBGP && !aspath_firstas_check(attr->aspath, peer->as)) { - flog_err(BGP_ERR_ATTR_FIRST_AS, - "%s incorrect first AS (must be %u)", - peer->host, peer->as); + flog_err(EC_BGP_ATTR_FIRST_AS, + "%s incorrect first AS (must be %u)", + peer->host, peer->as); bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, BGP_NOTIFY_UPDATE_MAL_AS_PATH); return BGP_ATTR_PARSE_ERROR; @@ -1236,9 +1235,9 @@ static int bgp_attr_as4_path(struct bgp_attr_parser_args *args, /* In case of IBGP, length will be zero. */ if (!*as4_path) { - flog_err(BGP_ERR_ATTR_MAL_AS_PATH, - "Malformed AS4 path from %s, length is %d", - peer->host, length); + flog_err(EC_BGP_ATTR_MAL_AS_PATH, + "Malformed AS4 path from %s, length is %d", peer->host, + length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_MAL_AS_PATH, 0); } @@ -1260,8 +1259,8 @@ static bgp_attr_parse_ret_t bgp_attr_nexthop(struct bgp_attr_parser_args *args) /* Check nexthop attribute length. */ if (length != 4) { - flog_err(BGP_ERR_ATTR_LEN, - "Nexthop attribute length isn't four [%d]", length); + flog_err(EC_BGP_ATTR_LEN, + "Nexthop attribute length isn't four [%d]", length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); @@ -1285,7 +1284,7 @@ static bgp_attr_parse_ret_t bgp_attr_nexthop(struct bgp_attr_parser_args *args) { char buf[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &nexthop_n, buf, INET_ADDRSTRLEN); - flog_err(BGP_ERR_ATTR_MARTIAN_NH, "Martian nexthop %s", buf); + flog_err(EC_BGP_ATTR_MARTIAN_NH, "Martian nexthop %s", buf); return bgp_attr_malformed( args, BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP, args->total); } @@ -1305,8 +1304,8 @@ static bgp_attr_parse_ret_t bgp_attr_med(struct bgp_attr_parser_args *args) /* Length check. */ if (length != 4) { - flog_err(BGP_ERR_ATTR_LEN, - "MED attribute length isn't four [%d]", length); + flog_err(EC_BGP_ATTR_LEN, + "MED attribute length isn't four [%d]", length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); @@ -1329,8 +1328,8 @@ bgp_attr_local_pref(struct bgp_attr_parser_args *args) /* Length check. */ if (length != 4) { - flog_err(BGP_ERR_ATTR_LEN, - "LOCAL_PREF attribute length isn't 4 [%u]", length); + flog_err(EC_BGP_ATTR_LEN, + "LOCAL_PREF attribute length isn't 4 [%u]", length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); } @@ -1359,9 +1358,9 @@ static int bgp_attr_atomic(struct bgp_attr_parser_args *args) /* Length check. */ if (length != 0) { - flog_err(BGP_ERR_ATTR_LEN, - "ATOMIC_AGGREGATE attribute length isn't 0 [%u]", - length); + flog_err(EC_BGP_ATTR_LEN, + "ATOMIC_AGGREGATE attribute length isn't 0 [%u]", + length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); } @@ -1386,9 +1385,9 @@ static int bgp_attr_aggregator(struct bgp_attr_parser_args *args) wantedlen = 8; if (length != wantedlen) { - flog_err(BGP_ERR_ATTR_LEN, - "AGGREGATOR attribute length isn't %u [%u]", - wantedlen, length); + flog_err(EC_BGP_ATTR_LEN, + "AGGREGATOR attribute length isn't %u [%u]", wantedlen, + length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); } @@ -1416,8 +1415,8 @@ bgp_attr_as4_aggregator(struct bgp_attr_parser_args *args, const bgp_size_t length = args->length; if (length != 8) { - flog_err(BGP_ERR_ATTR_LEN, - "New Aggregator length is not 8 [%d]", length); + flog_err(EC_BGP_ATTR_LEN, "New Aggregator length is not 8 [%d]", + length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, 0); } @@ -1576,8 +1575,8 @@ bgp_attr_originator_id(struct bgp_attr_parser_args *args) /* Length check. */ if (length != 4) { - flog_err(BGP_ERR_ATTR_LEN, "Bad originator ID length %d", - length); + flog_err(EC_BGP_ATTR_LEN, "Bad originator ID length %d", + length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); @@ -1600,8 +1599,7 @@ bgp_attr_cluster_list(struct bgp_attr_parser_args *args) /* Check length. */ if (length % 4) { - flog_err(BGP_ERR_ATTR_LEN, "Bad cluster list length %d", - length); + flog_err(EC_BGP_ATTR_LEN, "Bad cluster list length %d", length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); @@ -1707,8 +1705,14 @@ int bgp_mp_reach_parse(struct bgp_attr_parser_args *args, stream_getl(s); /* RD low */ } stream_get(&attr->mp_nexthop_global, s, IPV6_MAX_BYTELEN); - if (IN6_IS_ADDR_LINKLOCAL(&attr->mp_nexthop_global)) + if (IN6_IS_ADDR_LINKLOCAL(&attr->mp_nexthop_global)) { + if (!peer->nexthop.ifp) { + zlog_warn("%s: interface not set appropriately to handle some attributes", + peer->host); + return BGP_ATTR_PARSE_WITHDRAW; + } attr->nh_ifindex = peer->nexthop.ifp->ifindex; + } break; case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL: case BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL: @@ -1718,8 +1722,14 @@ int bgp_mp_reach_parse(struct bgp_attr_parser_args *args, stream_getl(s); /* RD low */ } stream_get(&attr->mp_nexthop_global, s, IPV6_MAX_BYTELEN); - if (IN6_IS_ADDR_LINKLOCAL(&attr->mp_nexthop_global)) + if (IN6_IS_ADDR_LINKLOCAL(&attr->mp_nexthop_global)) { + if (!peer->nexthop.ifp) { + zlog_warn("%s: interface not set appropriately to handle some attributes", + peer->host); + return BGP_ATTR_PARSE_WITHDRAW; + } attr->nh_ifindex = peer->nexthop.ifp->ifindex; + } if (attr->mp_nexthop_len == BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL) { stream_getl(s); /* RD high */ @@ -1743,6 +1753,11 @@ int bgp_mp_reach_parse(struct bgp_attr_parser_args *args, attr->mp_nexthop_len = IPV6_MAX_BYTELEN; } + if (!peer->nexthop.ifp) { + zlog_warn("%s: Interface not set appropriately to handle this some attributes", + peer->host); + return BGP_ATTR_PARSE_WITHDRAW; + } attr->nh_lla_ifindex = peer->nexthop.ifp->ifindex; break; default: @@ -1761,7 +1776,7 @@ int bgp_mp_reach_parse(struct bgp_attr_parser_args *args, uint8_t val; if ((val = stream_getc(s))) flog_warn( - BGP_WARN_DEFUNCT_SNPA_LEN, + EC_BGP_DEFUNCT_SNPA_LEN, "%s sent non-zero value, %u, for defunct SNPA-length field", peer->host, val); } @@ -2072,7 +2087,7 @@ static bgp_attr_parse_ret_t bgp_attr_psid_sub(int32_t type, if (type == BGP_PREFIX_SID_LABEL_INDEX) { if (length != BGP_PREFIX_SID_LABEL_INDEX_LENGTH) { flog_err( - BGP_ERR_ATTR_LEN, + EC_BGP_ATTR_LEN, "Prefix SID label index length is %d instead of %d", length, BGP_PREFIX_SID_LABEL_INDEX_LENGTH); return bgp_attr_malformed(args, @@ -2107,9 +2122,9 @@ static bgp_attr_parse_ret_t bgp_attr_psid_sub(int32_t type, /* Placeholder code for the IPv6 SID type */ else if (type == BGP_PREFIX_SID_IPV6) { if (length != BGP_PREFIX_SID_IPV6_LENGTH) { - flog_err(BGP_ERR_ATTR_LEN, - "Prefix SID IPv6 length is %d instead of %d", - length, BGP_PREFIX_SID_IPV6_LENGTH); + flog_err(EC_BGP_ATTR_LEN, + "Prefix SID IPv6 length is %d instead of %d", + length, BGP_PREFIX_SID_IPV6_LENGTH); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); @@ -2131,7 +2146,7 @@ static bgp_attr_parse_ret_t bgp_attr_psid_sub(int32_t type, if (length % BGP_PREFIX_SID_ORIGINATOR_SRGB_LENGTH) { flog_err( - BGP_ERR_ATTR_LEN, + EC_BGP_ATTR_LEN, "Prefix SID Originator SRGB length is %d, it must be a multiple of %d ", length, BGP_PREFIX_SID_ORIGINATOR_SRGB_LENGTH); return bgp_attr_malformed( @@ -2181,7 +2196,7 @@ bgp_attr_prefix_sid(int32_t tlength, struct bgp_attr_parser_args *args, if (tlength < 0) { flog_err( - BGP_ERR_ATTR_LEN, + EC_BGP_ATTR_LEN, "Prefix SID internal length %d causes us to read beyond the total Prefix SID length", length); return bgp_attr_malformed(args, @@ -2208,24 +2223,24 @@ bgp_attr_pmsi_tunnel(struct bgp_attr_parser_args *args) * can only support that. */ if (length < 2) { - flog_err(BGP_ERR_ATTR_LEN, - "Bad PMSI tunnel attribute length %d", length); + flog_err(EC_BGP_ATTR_LEN, "Bad PMSI tunnel attribute length %d", + length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); } stream_getc(peer->curr); /* Flags */ tnl_type = stream_getc(peer->curr); if (tnl_type > PMSI_TNLTYPE_MAX) { - flog_err(BGP_ERR_ATTR_PMSI_TYPE, - "Invalid PMSI tunnel attribute type %d", tnl_type); + flog_err(EC_BGP_ATTR_PMSI_TYPE, + "Invalid PMSI tunnel attribute type %d", tnl_type); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_OPT_ATTR_ERR, args->total); } if (tnl_type == PMSI_TNLTYPE_INGR_REPL) { if (length != 9) { - flog_err(BGP_ERR_ATTR_PMSI_LEN, - "Bad PMSI tunnel attribute length %d for IR", - length); + flog_err(EC_BGP_ATTR_PMSI_LEN, + "Bad PMSI tunnel attribute length %d for IR", + length); return bgp_attr_malformed( args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); @@ -2337,7 +2352,7 @@ static int bgp_attr_check(struct peer *peer, struct attr *attr) type = BGP_ATTR_LOCAL_PREF; if (type) { - flog_warn(BGP_WARN_MISSING_ATTRIBUTE, + flog_warn(EC_BGP_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, @@ -2380,7 +2395,7 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr, if (endp - BGP_INPUT_PNT(peer) < BGP_ATTR_MIN_LEN) { /* XXX warning: long int format, int arg (arg 5) */ flog_warn( - BGP_WARN_ATTRIBUTE_TOO_SMALL, + EC_BGP_ATTRIBUTE_TOO_SMALL, "%s: error BGP attribute length %lu is smaller than min len", peer->host, (unsigned long)(endp @@ -2403,7 +2418,7 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr, if (CHECK_FLAG(flag, BGP_ATTR_FLAG_EXTLEN) && ((endp - startp) < (BGP_ATTR_MIN_LEN + 1))) { flog_warn( - BGP_WARN_EXT_ATTRIBUTE_TOO_SMALL, + EC_BGP_EXT_ATTRIBUTE_TOO_SMALL, "%s: Extended length set, but just %lu bytes of attr header", peer->host, (unsigned long)(endp @@ -2426,7 +2441,7 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr, if (CHECK_BITMAP(seen, type)) { flog_warn( - BGP_WARN_ATTRIBUTE_REPEATED, + EC_BGP_ATTRIBUTE_REPEATED, "%s: error BGP attribute type %d appears twice in a message", peer->host, type); @@ -2445,7 +2460,7 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr, if (attr_endp > endp) { flog_warn( - BGP_WARN_ATTRIBUTE_TOO_LARGE, + EC_BGP_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); @@ -2602,7 +2617,7 @@ 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) { - flog_warn(BGP_WARN_ATTRIBUTE_PARSE_ERROR, + flog_warn(EC_BGP_ATTRIBUTE_PARSE_ERROR, "%s: Attribute %s, parse error", peer->host, lookup_msg(attr_str, type, NULL)); if (as4_path) @@ -2612,7 +2627,7 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr, if (ret == BGP_ATTR_PARSE_WITHDRAW) { flog_warn( - BGP_WARN_ATTRIBUTE_PARSE_WITHDRAW, + EC_BGP_ATTRIBUTE_PARSE_WITHDRAW, "%s: Attribute %s, parse error - treating as withdrawal", peer->host, lookup_msg(attr_str, type, NULL)); if (as4_path) @@ -2622,7 +2637,7 @@ 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) { - flog_warn(BGP_WARN_ATTRIBUTE_FETCH_ERROR, + flog_warn(EC_BGP_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, @@ -2635,7 +2650,7 @@ 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) { - flog_warn(BGP_WARN_ATTRIBUTES_MISMATCH, + flog_warn(EC_BGP_ATTRIBUTES_MISMATCH, "%s: BGP attribute %s, length mismatch", peer->host, lookup_msg(attr_str, type, NULL)); bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, @@ -2831,7 +2846,7 @@ size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer, afi_t afi, default: if (safi != SAFI_FLOWSPEC) flog_err( - BGP_ERR_ATTR_NH_SEND_LEN, + EC_BGP_ATTR_NH_SEND_LEN, "Bad nexthop when sending to %s, AFI %u SAFI %u nhlen %d", peer->host, afi, safi, attr->mp_nexthop_len); break; diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c index 071ee6b9c6..5ffab0bf4f 100644 --- a/bgpd/bgp_damp.c +++ b/bgpd/bgp_damp.c @@ -177,7 +177,7 @@ int bgp_damp_withdraw(struct bgp_info *binfo, struct bgp_node *rn, afi_t afi, { time_t t_now; struct bgp_damp_info *bdi = NULL; - double last_penalty = 0; + unsigned int last_penalty = 0; t_now = bgp_clock(); diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index 49f27d298b..ef746597a4 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -120,7 +120,7 @@ static FILE *bgp_dump_open_file(struct bgp_dump *bgp_dump) ret = strftime(realpath, MAXPATHLEN, bgp_dump->filename, tm); if (ret == 0) { - flog_warn(BGP_WARN_DUMP, "bgp_dump_open_file: strftime error"); + flog_warn(EC_BGP_DUMP, "bgp_dump_open_file: strftime error"); return NULL; } @@ -132,7 +132,7 @@ static FILE *bgp_dump_open_file(struct bgp_dump *bgp_dump) bgp_dump->fp = fopen(realpath, "w"); if (bgp_dump->fp == NULL) { - flog_warn(BGP_WARN_DUMP, "bgp_dump_open_file: %s: %s", realpath, + flog_warn(EC_BGP_DUMP, "bgp_dump_open_file: %s: %s", realpath, strerror(errno)); umask(oldumask); return NULL; diff --git a/bgpd/bgp_errors.c b/bgpd/bgp_errors.c index 827927f1b9..bd42901c2d 100644 --- a/bgpd/bgp_errors.c +++ b/bgpd/bgp_errors.c @@ -26,163 +26,163 @@ /* clang-format off */ static struct log_ref ferr_bgp_warn[] = { { - .code = BGP_WARN_ASPATH_FEWER_HOPS, + .code = EC_BGP_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, + .code = EC_BGP_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, + .code = EC_BGP_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, + .code = EC_BGP_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, + .code = EC_BGP_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, + .code = EC_BGP_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, + .code = EC_BGP_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, + .code = EC_BGP_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, + .code = EC_BGP_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, + .code = EC_BGP_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, + .code = EC_BGP_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 = BGP_WARN_DUMP, + .code = EC_BGP_DUMP, .title = "BGP MRT dump subsystem has encountered an issue", .description = "BGP has found that the attempted write of MRT data to a dump file has failed", .suggestion = "Ensure BGP has permissions to write the specified file", }, { - .code = BGP_WARN_UPDATE_PACKET_SHORT, + .code = EC_BGP_UPDATE_PACKET_SHORT, .title = "BGP Update Packet is to Small", .description = "The update packet received from a peer is to small", .suggestion = "Determine the source of the update packet and examine that peer for what has gone wrong", }, { - .code = BGP_WARN_UPDATE_PACKET_LONG, + .code = EC_BGP_UPDATE_PACKET_LONG, .title = "BGP Update Packet is to large", .description = "The update packet received from a peer is to large", .suggestion = "Determine the source of the update packet and examine that peer for what has gone wrong", }, { - .code = BGP_WARN_UNRECOGNIZED_CAPABILITY, + .code = EC_BGP_UNRECOGNIZED_CAPABILITY, .title = "Unknown BGP Capability Received", .description = "The negotiation of capabilities has received a capability that we do not know what to do with", .suggestion = "Determine the source of the capability and remove the capability from what is sent", }, { - .code = BGP_WARN_NO_TCP_MD5, + .code = EC_BGP_NO_TCP_MD5, .title = "Unable to set TCP MD5 option on socket", .description = "BGP attempted to setup TCP MD5 configuration on the socket as per configuration but was unable to", .suggestion = "Please collect log files and open Issue", }, { - .code = BGP_WARN_NO_SOCKOPT_MARK, + .code = EC_BGP_NO_SOCKOPT_MARK, .title = "Unable to set socket MARK option", .description = "BGP attempted to set the SO_MARK option for a socket and was unable to do so", .suggestion = "Please collect log files and open Issue", }, { - .code = BGP_WARN_EVPN_PMSI_PRESENT, + .code = EC_BGP_EVPN_PMSI_PRESENT, .title = "BGP Received a EVPN NLRI with PMSI included", .description = "BGP has received a type-3 NLRI with PMSI information. At this time FRR is not capable of properly handling this NLRI type", .suggestion = "Setup peer to not send this type of data to FRR" }, { - .code = BGP_WARN_EVPN_VPN_VNI, + .code = EC_BGP_EVPN_VPN_VNI, .title = "BGP has received a local macip and cannot properly handle it", .description = "BGP has received a local macip from zebra and has no way to properly handle the macip because the vni is not setup properly", .suggestion = "Ensure proper setup of BGP EVPN", }, { - .code = BGP_WARN_EVPN_ESI, + .code = EC_BGP_EVPN_ESI, .title = "BGP has received a local ESI for deletion", .description = "BGP has received a local ESI for deletion but when attempting to find the stored data internally was unable to find the information for deletion", .suggestion = "Gather logging and open an Issue", }, { - .code = BGP_WARN_INVALID_LABEL_STACK, + .code = EC_BGP_INVALID_LABEL_STACK, .title = "BGP has received a label stack in a NLRI that does not have the BOS marked", .description = "BGP when it receives a NLRI with a label stack should have the BOS marked, this received packet does not have this", .suggestion = "Gather log information from here and remote peer and open an Issue", }, { - .code = BGP_WARN_ZEBRA_SEND, + .code = EC_BGP_ZEBRA_SEND, .title = "BGP has attempted to send data to zebra and has failed to do so", .description = "BGP has attempted to send data to zebra but has been unable to do so", .suggestion = "Gather log data, open an Issue and restart FRR" }, { - .code = BGP_WARN_CAPABILITY_INVALID_LENGTH, + .code = EC_BGP_CAPABILITY_INVALID_LENGTH, .title = "BGP has received a capability with an invalid length", .description = "BGP has received a capability from it's peer who's size is wrong", .suggestion = "Gather log files from here and from peer and open an Issue", }, { - .code = BGP_WARN_CAPABILITY_INVALID_DATA, + .code = EC_BGP_CAPABILITY_INVALID_DATA, .title = "BGP has received capability data with invalid information", .description = "BGP has noticed that during processing of capability information that data was wrong", .suggestion = "Gather log files from here and from peer and open an Issue", }, { - .code = BGP_WARN_CAPABILITY_VENDOR, + .code = EC_BGP_CAPABILITY_VENDOR, .title = "BGP has recieved capability data specific to a particular vendor", .description = "BGP has received a capability that is vendor specific and as such we have no knowledge of how to use this capability in FRR", .suggestion = "On peer turn off this feature" }, { - .code = BGP_WARN_CAPABILITY_UNKNOWN, + .code = EC_BGP_CAPABILITY_UNKNOWN, .title = "BGP has received capability data for a unknown capability", .description = "BGP has received a capability that it does not know how to decode. This may be due to a new feature that has not been coded into FRR or it may be a bug in the remote peer", .suggestion = "Gather log files from here and from peer and open an Issue", }, { - .code = BGP_WARN_INVALID_NEXTHOP_LENGTH, + .code = EC_BGP_INVALID_NEXTHOP_LENGTH, .title = "BGP is attempting to write an invalid nexthop length value", .description = "BGP is in the process of building NLRI information for a peer and has discovered an inconsistent internal state", .suggestion = "Gather log files and open an Issue, restart FRR", @@ -194,270 +194,270 @@ static struct log_ref ferr_bgp_warn[] = { static struct log_ref ferr_bgp_err[] = { { - .code = BGP_ERR_ATTR_FLAG, + .code = EC_BGP_ATTR_FLAG, .title = "BGP attribute flag is incorrect", .description = "BGP attribute flag is set to the wrong value (Optional/Transitive/Partial)", .suggestion = "Determine the soure of the attribute and determine why the attribute flag has been set incorrectly" }, { - .code = BGP_ERR_ATTR_LEN, + .code = EC_BGP_ATTR_LEN, .title = "BGP attribute length is incorrect", .description = "BGP attribute length is incorrect", .suggestion = "Determine the soure of the attribute and determine why the attribute length has been set incorrectly" }, { - .code = BGP_ERR_ATTR_ORIGIN, + .code = EC_BGP_ATTR_ORIGIN, .title = "BGP attribute origin value invalid", .description = "BGP attribute origin value is invalid", .suggestion = "Determine the soure of the attribute and determine why the origin attribute has been set incorrectly" }, { - .code = BGP_ERR_ATTR_MAL_AS_PATH, + .code = EC_BGP_ATTR_MAL_AS_PATH, .title = "BGP as path is invalid", .description = "BGP as path has been malformed", .suggestion = "Determine the soure of the update and determine why the as path has been set incorrectly" }, { - .code = BGP_ERR_ATTR_FIRST_AS, + .code = EC_BGP_ATTR_FIRST_AS, .title = "BGP as path first as is invalid", .description = "BGP update has invalid first as in as path", .suggestion = "Determine the soure of the update and determine why the as path first as value has been set incorrectly" }, { - .code = BGP_ERR_ATTR_PMSI_TYPE, + .code = EC_BGP_ATTR_PMSI_TYPE, .title = "BGP PMSI tunnel attribute type is invalid", .description = "BGP update has invalid type for PMSI tunnel", .suggestion = "Determine the soure of the update and determine why the PMSI tunnel attribute type has been set incorrectly" }, { - .code = BGP_ERR_ATTR_PMSI_LEN, + .code = EC_BGP_ATTR_PMSI_LEN, .title = "BGP PMSI tunnel attribute length is invalid", .description = "BGP update has invalid length for PMSI tunnel", .suggestion = "Determine the soure of the update and determine why the PMSI tunnel attribute length has been set incorrectly" }, { - .code = BGP_ERR_PEER_GROUP, + .code = EC_BGP_PEER_GROUP, .title = "BGP peergroup operated on in error", .description = "BGP operating on peer-group instead of peers included", .suggestion = "Ensure the config doesn't contain peergroups contained within peergroups" }, { - .code = BGP_ERR_PEER_DELETE, + .code = EC_BGP_PEER_DELETE, .title = "BGP failed to delete peer structure", .description = "BGP was unable to delete peer structure when address-family removed", .suggestion = "Determine if all expected peers are removed and restart FRR if not. Most likely a bug" }, { - .code = BGP_ERR_TABLE_CHUNK, + .code = EC_BGP_TABLE_CHUNK, .title = "BGP failed to get table chunk memory", .description = "BGP unable to get chunk memory for table manager", .suggestion = "Ensure there is adequate memory on the device to support the table requirements" }, { - .code = BGP_ERR_MACIP_LEN, + .code = EC_BGP_MACIP_LEN, .title = "BGP received MACIP with invalid IP addr len", .description = "BGP received MACIP with invalid IP addr len from Zebra", .suggestion = "Verify MACIP entries inserted in Zebra are correct. Most likely a bug" }, { - .code = BGP_ERR_LM_ERROR, + .code = EC_BGP_LM_ERROR, .title = "BGP received invalid label manager message", .description = "BGP received invalid label manager message from label manager", .suggestion = "Label manager sent invalid essage to BGP for wrong protocol, instance, etc. Most likely a bug" }, { - .code = BGP_ERR_JSON_MEM_ERROR, + .code = EC_BGP_JSON_MEM_ERROR, .title = "BGP unable to allocate memory for JSON output", .description = "BGP attempted to generate JSON output and was unable to allocate the memory required", .suggestion = "Ensure that the device has adequate memory to suport the required functions" }, { - .code = BGP_ERR_UPDGRP_ATTR_LEN, + .code = EC_BGP_UPDGRP_ATTR_LEN, .title = "BGP update had attributes too long to send", .description = "BGP attempted to send an update but the attributes were too long to fit", .suggestion = "Most likely a bug. If the problem persists, report the problem for troubleshooting" }, { - .code = BGP_ERR_UPDGRP_CREATE, + .code = EC_BGP_UPDGRP_CREATE, .title = "BGP update group creation failed", .description = "BGP attempted to create an update group but was unable to", .suggestion = "Most likely a bug. If the problem persists, report the problem for troubleshooting" }, { - .code = BGP_ERR_UPDATE_SND, + .code = EC_BGP_UPDATE_SND, .title = "BGP error creating update packet", .description = "BGP attempted to create an update packet but was unable to", .suggestion = "Most likely a bug. If the problem persists, report the problem for troubleshooting" }, { - .code = BGP_ERR_PKT_OPEN, + .code = EC_BGP_PKT_OPEN, .title = "BGP error receiving open packet", .description = "BGP received an open from a peer that was invalid", .suggestion = "Determine the sending peer and correct his invalid open packet" }, { - .code = BGP_ERR_SND_FAIL, + .code = EC_BGP_SND_FAIL, .title = "BGP error sending to peer", .description = "BGP attempted to respond to open from a peer and failed", .suggestion = "BGP attempted to respond to an open and could not sene the packet. Check local IP address for source" }, { - .code = BGP_ERR_INVALID_STATUS, + .code = EC_BGP_INVALID_STATUS, .title = "BGP error receiving from peer", .description = "BGP received an update from a peer but status was incorrect", .suggestion = "Most likely a bug. If the problem persists, report the problem for troubleshooting" }, { - .code = BGP_ERR_UPDATE_RCV, + .code = EC_BGP_UPDATE_RCV, .title = "BGP error receiving update packet", .description = "BGP received an invalid update packet", .suggestion = "Determine the source of the update and resolve the invalid update being sent" }, { - .code = BGP_ERR_NO_CAP, + .code = EC_BGP_NO_CAP, .title = "BGP error due to capability not enabled", .description = "BGP attempted a function that did not have the capability enabled", .suggestion = "Enable the capability if this functionality is desired" }, { - .code = BGP_ERR_NOTIFY_RCV, + .code = EC_BGP_NOTIFY_RCV, .title = "BGP error receiving notify message", .description = "BGP unable to process notification message", .suggestion = "BGP notify received while in stopped state. If the problem persists, report for troubleshooting" }, { - .code = BGP_ERR_KEEP_RCV, + .code = EC_BGP_KEEP_RCV, .title = "BGP error receiving keepalive packet", .description = "BGP unable to process keepalive packet", .suggestion = "BGP keepalive received while in stopped state. If the problem persists, report for troubleshooting" }, { - .code = BGP_ERR_RFSH_RCV, + .code = EC_BGP_RFSH_RCV, .title = "BGP error receiving route refresh message", .description = "BGP unable to process route refresh message", .suggestion = "BGP route refresh received while in stopped state. If the problem persists, report for troubleshooting"}, { - .code = BGP_ERR_CAP_RCV, + .code = EC_BGP_CAP_RCV, .title = "BGP error capability message", .description = "BGP unable to process received capability", .suggestion = "BGP capability message received while in stopped state. If the problem persists, report for troubleshooting" }, { - .code = BGP_ERR_NH_UPD, + .code = EC_BGP_NH_UPD, .title = "BGP error with nexthopo update", .description = "BGP unable to process nexthop update", .suggestion = "BGP received nexthop update but nexthop is not reachable in this bgp instance. Report for troubleshooting" }, { - .code = BGP_ERR_LABEL, + .code = EC_BGP_LABEL, .title = "Failure to apply label", .description = "BGP attempted to attempted to apply a label but could not", .suggestion = "Most likely a bug. If the problem persists, report the problem for troubleshooting" }, { - .code = BGP_ERR_MULTIPATH, + .code = EC_BGP_MULTIPATH, .title = "Multipath specified is invalid", .description = "BGP was started with an invalid ecmp/multipath value", .suggestion = "Correct the ecmp/multipath value supplied when starting the BGP daemon" }, { - .code = BGP_ERR_PKT_PROCESS, + .code = EC_BGP_PKT_PROCESS, .title = "Failure to process a packet", .description = "BGP attempted to process a received packet but could not", .suggestion = "Most likely a bug. If the problem persists, report the problem for troubleshooting" }, { - .code = BGP_ERR_CONNECT, + .code = EC_BGP_CONNECT, .title = "Failure to connect to peer", .description = "BGP attempted to send open to peer but couldn't connect", .suggestion = "Most likely a bug. If the problem persists, report the problem for troubleshooting" }, { - .code = BGP_ERR_FSM, + .code = EC_BGP_FSM, .title = "BGP FSM issue", .description = "BGP neighbor transition problem", .suggestion = "Most likely a bug. If the problem persists, report the problem for troubleshooting" }, { - .code = BGP_ERR_VNI, + .code = EC_BGP_VNI, .title = "BGP VNI creation issue", .description = "BGP could not create a new VNI", .suggestion = "Most likely a bug. If the problem persists, report the problem for troubleshooting" }, { - .code = BGP_ERR_NO_DFLT, + .code = EC_BGP_NO_DFLT, .title = "BGP default instance missing", .description = "BGP could not find default instance", .suggestion = "Define a default instance of BGP since some feature requires it's existence" }, { - .code = BGP_ERR_VTEP_INVALID, + .code = EC_BGP_VTEP_INVALID, .title = "BGP remote VTEP invalid", .description = "BGP remote VTEP is invalid and cannot be used", .suggestion = "Correct remote VTEP configuration or resolve the source of the problem" }, { - .code = BGP_ERR_ES_INVALID, + .code = EC_BGP_ES_INVALID, .title = "BGP ES route error", .description = "BGP ES route incorrect, learned both local and remote", .suggestion = "Correct configuration or addressing so that same not learned both local and remote" }, { - .code = BGP_ERR_EVPN_ROUTE_DELETE, + .code = EC_BGP_EVPN_ROUTE_DELETE, .title = "BGP EVPN route delete error", .description = "BGP attempted to delete an EVPN route and failed", .suggestion = "Most likely a bug. If the problem persists, report the problem for troubleshooting" }, { - .code = BGP_ERR_EVPN_FAIL, + .code = EC_BGP_EVPN_FAIL, .title = "BGP EVPN install/uninstall error", .description = "BGP attempted to install or uninstall an EVPN prefix and failed", .suggestion = "Most likely a bug. If the problem persists, report the problem for troubleshooting" }, { - .code = BGP_ERR_EVPN_ROUTE_INVALID, + .code = EC_BGP_EVPN_ROUTE_INVALID, .title = "BGP EVPN route received with invalid contents", .description = "BGP received an EVPN route with invalid contents", .suggestion = "Determine the source of the EVPN route and resolve whatever is causing invalid contents" }, { - .code = BGP_ERR_EVPN_ROUTE_CREATE, + .code = EC_BGP_EVPN_ROUTE_CREATE, .title = "BGP EVPN route create error", .description = "BGP attempted to create an EVPN route and failed", .suggestion = "Most likely a bug. If the problem persists, report the problem for troubleshooting" }, { - .code = BGP_ERR_ES_CREATE, + .code = EC_BGP_ES_CREATE, .title = "BGP EVPN ES entry create error", .description = "BGP attempted to create an EVPN ES entry and failed", .suggestion = "Most likely a bug. If the problem persists, report the problem for troubleshooting" }, { - .code = BGP_ERR_MULTI_INSTANCE, + .code = EC_BGP_MULTI_INSTANCE, .title = "BGP config multi-instance issue", .description = "BGP configuration attempting multiple instances without enabling the feature", .suggestion = "Correct the configuration so that bgp multiple-instance is enabled if desired" }, { - .code = BGP_ERR_EVPN_AS_MISMATCH, + .code = EC_BGP_EVPN_AS_MISMATCH, .title = "BGP AS configuration issue", .description = "BGP configuration attempted for a different AS than currently configured", .suggestion = "Correct the configuration so that the correct BGP AS number is used" }, { - .code = BGP_ERR_EVPN_INSTANCE_MISMATCH, + .code = EC_BGP_EVPN_INSTANCE_MISMATCH, .title = "BGP EVPN AS and process name mismatch", .description = "BGP configuration has AS and process name mismatch", .suggestion = "Correct the configuration so that the BGP AS number and instance name are consistent" }, { - .code = BGP_ERR_FLOWSPEC_PACKET, + .code = EC_BGP_FLOWSPEC_PACKET, .title = "BGP Flowspec packet processing error", .description = "The BGP flowspec subsystem has detected a error in the send or receive of a packet", .suggestion = "Gather log files from both sides of the peering relationship and open an issue" }, { - .code = BGP_ERR_FLOWSPEC_INSTALLATION, + .code = EC_BGP_FLOWSPEC_INSTALLATION, .title = "BGP Flowspec Installation/removal Error", .description = "The BGP flowspec subsystem has detected that there was a failure for installation/removal/modification of Flowspec from the dataplane", .suggestion = "Gather log files from the router and open an issue, Restart FRR" diff --git a/bgpd/bgp_errors.h b/bgpd/bgp_errors.h index f7db77ac38..853f2da222 100644 --- a/bgpd/bgp_errors.h +++ b/bgpd/bgp_errors.h @@ -25,80 +25,80 @@ enum bgp_log_refs { - BGP_ERR_ATTR_FLAG = BGP_FERR_START, - BGP_ERR_ATTR_LEN, - BGP_ERR_ATTR_ORIGIN, - BGP_ERR_ATTR_MAL_AS_PATH, - BGP_ERR_ATTR_FIRST_AS, - BGP_ERR_ATTR_MARTIAN_NH, - BGP_ERR_ATTR_PMSI_TYPE, - BGP_ERR_ATTR_PMSI_LEN, - BGP_ERR_ATTR_NH_SEND_LEN, - BGP_ERR_PEER_GROUP, - BGP_ERR_PEER_DELETE, - BGP_ERR_TABLE_CHUNK, - BGP_ERR_MACIP_LEN, - BGP_ERR_LM_ERROR, - BGP_ERR_JSON_MEM_ERROR, - BGP_ERR_UPDGRP_ATTR_LEN, - BGP_ERR_UPDGRP_CREATE, - BGP_ERR_UPDATE_SND, - BGP_ERR_PKT_OPEN, - BGP_ERR_SND_FAIL, - BGP_ERR_INVALID_STATUS, - BGP_ERR_UPDATE_RCV, - BGP_ERR_NO_CAP, - BGP_ERR_NOTIFY_RCV, - BGP_ERR_KEEP_RCV, - BGP_ERR_RFSH_RCV, - BGP_ERR_CAP_RCV, - BGP_ERR_NH_UPD, - BGP_ERR_LABEL, - BGP_ERR_MULTIPATH, - BGP_ERR_PKT_PROCESS, - BGP_ERR_CONNECT, - BGP_ERR_FSM, - BGP_ERR_VNI, - BGP_ERR_NO_DFLT, - BGP_ERR_VTEP_INVALID, - BGP_ERR_ES_INVALID, - BGP_ERR_EVPN_ROUTE_DELETE, - BGP_ERR_EVPN_FAIL, - BGP_ERR_EVPN_ROUTE_INVALID, - BGP_ERR_EVPN_ROUTE_CREATE, - BGP_ERR_ES_CREATE, - BGP_ERR_MULTI_INSTANCE, - BGP_ERR_EVPN_AS_MISMATCH, - 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, - BGP_WARN_DUMP, - BGP_WARN_UPDATE_PACKET_SHORT, - BGP_WARN_UPDATE_PACKET_LONG, - BGP_WARN_UNRECOGNIZED_CAPABILITY, - BGP_WARN_NO_TCP_MD5, - BGP_WARN_NO_SOCKOPT_MARK, - BGP_WARN_EVPN_PMSI_PRESENT, - BGP_WARN_EVPN_VPN_VNI, - BGP_WARN_EVPN_ESI, - BGP_WARN_INVALID_LABEL_STACK, - BGP_WARN_ZEBRA_SEND, - BGP_WARN_CAPABILITY_INVALID_LENGTH, - BGP_WARN_CAPABILITY_INVALID_DATA, - BGP_WARN_CAPABILITY_VENDOR, - BGP_WARN_CAPABILITY_UNKNOWN, - BGP_WARN_INVALID_NEXTHOP_LENGTH, + EC_BGP_ATTR_FLAG = BGP_FERR_START, + EC_BGP_ATTR_LEN, + EC_BGP_ATTR_ORIGIN, + EC_BGP_ATTR_MAL_AS_PATH, + EC_BGP_ATTR_FIRST_AS, + EC_BGP_ATTR_MARTIAN_NH, + EC_BGP_ATTR_PMSI_TYPE, + EC_BGP_ATTR_PMSI_LEN, + EC_BGP_ATTR_NH_SEND_LEN, + EC_BGP_PEER_GROUP, + EC_BGP_PEER_DELETE, + EC_BGP_TABLE_CHUNK, + EC_BGP_MACIP_LEN, + EC_BGP_LM_ERROR, + EC_BGP_JSON_MEM_ERROR, + EC_BGP_UPDGRP_ATTR_LEN, + EC_BGP_UPDGRP_CREATE, + EC_BGP_UPDATE_SND, + EC_BGP_PKT_OPEN, + EC_BGP_SND_FAIL, + EC_BGP_INVALID_STATUS, + EC_BGP_UPDATE_RCV, + EC_BGP_NO_CAP, + EC_BGP_NOTIFY_RCV, + EC_BGP_KEEP_RCV, + EC_BGP_RFSH_RCV, + EC_BGP_CAP_RCV, + EC_BGP_NH_UPD, + EC_BGP_LABEL, + EC_BGP_MULTIPATH, + EC_BGP_PKT_PROCESS, + EC_BGP_CONNECT, + EC_BGP_FSM, + EC_BGP_VNI, + EC_BGP_NO_DFLT, + EC_BGP_VTEP_INVALID, + EC_BGP_ES_INVALID, + EC_BGP_EVPN_ROUTE_DELETE, + EC_BGP_EVPN_FAIL, + EC_BGP_EVPN_ROUTE_INVALID, + EC_BGP_EVPN_ROUTE_CREATE, + EC_BGP_ES_CREATE, + EC_BGP_MULTI_INSTANCE, + EC_BGP_EVPN_AS_MISMATCH, + EC_BGP_EVPN_INSTANCE_MISMATCH, + EC_BGP_FLOWSPEC_PACKET, + EC_BGP_FLOWSPEC_INSTALLATION, + EC_BGP_ASPATH_FEWER_HOPS, + EC_BGP_DEFUNCT_SNPA_LEN, + EC_BGP_MISSING_ATTRIBUTE, + EC_BGP_ATTRIBUTE_TOO_SMALL, + EC_BGP_EXT_ATTRIBUTE_TOO_SMALL, + EC_BGP_ATTRIBUTE_REPEATED, + EC_BGP_ATTRIBUTE_TOO_LARGE, + EC_BGP_ATTRIBUTE_PARSE_ERROR, + EC_BGP_ATTRIBUTE_PARSE_WITHDRAW, + EC_BGP_ATTRIBUTE_FETCH_ERROR, + EC_BGP_ATTRIBUTES_MISMATCH, + EC_BGP_DUMP, + EC_BGP_UPDATE_PACKET_SHORT, + EC_BGP_UPDATE_PACKET_LONG, + EC_BGP_UNRECOGNIZED_CAPABILITY, + EC_BGP_NO_TCP_MD5, + EC_BGP_NO_SOCKOPT_MARK, + EC_BGP_EVPN_PMSI_PRESENT, + EC_BGP_EVPN_VPN_VNI, + EC_BGP_EVPN_ESI, + EC_BGP_INVALID_LABEL_STACK, + EC_BGP_ZEBRA_SEND, + EC_BGP_CAPABILITY_INVALID_LENGTH, + EC_BGP_CAPABILITY_INVALID_DATA, + EC_BGP_CAPABILITY_VENDOR, + EC_BGP_CAPABILITY_UNKNOWN, + EC_BGP_INVALID_NEXTHOP_LENGTH, }; extern void bgp_error_init(void); diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 3bd566e072..41aceae9f7 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -173,8 +173,8 @@ static struct vrf_irt_node *vrf_import_rt_new(struct ecommunity_val *rt) bgp_def = bgp_get_default(); if (!bgp_def) { - flog_err(BGP_ERR_NO_DFLT, - "vrf import rt new - def instance not created yet"); + flog_err(EC_BGP_NO_DFLT, + "vrf import rt new - def instance not created yet"); return NULL; } @@ -204,8 +204,8 @@ static void vrf_import_rt_free(struct vrf_irt_node *irt) bgp_def = bgp_get_default(); if (!bgp_def) { - flog_err(BGP_ERR_NO_DFLT, - "vrf import rt free - def instance not created yet"); + flog_err(EC_BGP_NO_DFLT, + "vrf import rt free - def instance not created yet"); return; } @@ -226,9 +226,8 @@ static struct vrf_irt_node *lookup_vrf_import_rt(struct ecommunity_val *rt) bgp_def = bgp_get_default(); if (!bgp_def) { - flog_err( - BGP_ERR_NO_DFLT, - "vrf import rt lookup - def instance not created yet"); + flog_err(EC_BGP_NO_DFLT, + "vrf import rt lookup - def instance not created yet"); return NULL; } @@ -628,7 +627,7 @@ static int bgp_zebra_send_remote_vtep(struct bgp *bgp, struct bgpevpn *vpn, stream_put_in_addr(s, &p->prefix.imet_addr.ip.ipaddr_v4); else if (is_evpn_prefix_ipaddr_v6(p)) { flog_err( - BGP_ERR_VTEP_INVALID, + EC_BGP_VTEP_INVALID, "Bad remote IP when trying to %s remote VTEP for VNI %u", add ? "ADD" : "DEL", vpn->vni); return -1; @@ -1302,7 +1301,7 @@ static int update_evpn_type4_route_entry(struct bgp *bgp, */ if (remote_ri) { flog_err( - BGP_ERR_ES_INVALID, + EC_BGP_ES_INVALID, "%u ERROR: local es route for ESI: %s Vtep %s also learnt from remote", bgp->vrf_id, esi_to_str(&evp->prefix.es_addr.esi, buf, sizeof(buf)), @@ -1389,12 +1388,11 @@ static int update_evpn_type4_route(struct bgp *bgp, &attr, 1, &ri, &route_changed); if (ret != 0) { - flog_err( - BGP_ERR_ES_INVALID, - "%u ERROR: Failed to updated ES route ESI: %s VTEP %s", - bgp->vrf_id, - esi_to_str(&p->prefix.es_addr.esi, buf, sizeof(buf)), - ipaddr2str(&es->originator_ip, buf1, sizeof(buf1))); + flog_err(EC_BGP_ES_INVALID, + "%u ERROR: Failed to updated ES route ESI: %s VTEP %s", + bgp->vrf_id, + esi_to_str(&p->prefix.es_addr.esi, buf, sizeof(buf)), + ipaddr2str(&es->originator_ip, buf1, sizeof(buf1))); } assert(ri); @@ -2191,9 +2189,9 @@ static int delete_routes_for_es(struct bgp *bgp, struct evpnes *es) build_evpn_type4_prefix(&p, &es->esi, es->originator_ip.ipaddr_v4); ret = delete_evpn_type4_route(bgp, es, &p); if (ret) { - flog_err(BGP_ERR_EVPN_ROUTE_DELETE, - "%u failed to delete type-4 route for ESI %s", - bgp->vrf_id, esi_to_str(&es->esi, buf, sizeof(buf))); + flog_err(EC_BGP_EVPN_ROUTE_DELETE, + "%u failed to delete type-4 route for ESI %s", + bgp->vrf_id, esi_to_str(&es->esi, buf, sizeof(buf))); } /* Delete all routes from per ES table */ @@ -2851,7 +2849,7 @@ static int install_uninstall_routes_for_es(struct bgp *bgp, if (ret) { flog_err( - BGP_ERR_EVPN_FAIL, + EC_BGP_EVPN_FAIL, "Failed to %s EVPN %s route in ESI %s", install ? "install" : "uninstall", @@ -2931,7 +2929,7 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf, int install) if (ret) { flog_err( - BGP_ERR_EVPN_FAIL, + EC_BGP_EVPN_FAIL, "Failed to %s EVPN %s route in VRF %s", install ? "install" : "uninstall", @@ -3005,7 +3003,7 @@ static int install_uninstall_routes_for_vni(struct bgp *bgp, if (ret) { flog_err( - BGP_ERR_EVPN_FAIL, + EC_BGP_EVPN_FAIL, "%u: Failed to %s EVPN %s route in VNI %u", bgp->vrf_id, install ? "install" @@ -3108,7 +3106,7 @@ static int install_uninstall_route_in_es(struct bgp *bgp, struct evpnes *es, if (ret) { flog_err( - BGP_ERR_EVPN_FAIL, + EC_BGP_EVPN_FAIL, "%u: Failed to %s EVPN %s route in ESI %s", bgp->vrf_id, install ? "install" : "uninstall", "ES", esi_to_str(&evp->prefix.es_addr.esi, buf, sizeof(buf))); @@ -3150,12 +3148,12 @@ static int install_uninstall_route_in_vrfs(struct bgp *bgp_def, afi_t afi, ri); if (ret) { - flog_err(BGP_ERR_EVPN_FAIL, - "%u: Failed to %s prefix %s in VRF %s", - bgp_def->vrf_id, - install ? "install" : "uninstall", - prefix2str(evp, buf, sizeof(buf)), - vrf_id_to_name(bgp_vrf->vrf_id)); + flog_err(EC_BGP_EVPN_FAIL, + "%u: Failed to %s prefix %s in VRF %s", + bgp_def->vrf_id, + install ? "install" : "uninstall", + prefix2str(evp, buf, sizeof(buf)), + vrf_id_to_name(bgp_vrf->vrf_id)); return ret; } } @@ -3186,14 +3184,13 @@ static int install_uninstall_route_in_vnis(struct bgp *bgp, afi_t afi, ret = uninstall_evpn_route_entry(bgp, vpn, evp, ri); if (ret) { - flog_err( - BGP_ERR_EVPN_FAIL, - "%u: Failed to %s EVPN %s route in VNI %u", - bgp->vrf_id, install ? "install" : "uninstall", - evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE - ? "MACIP" - : "IMET", - vpn->vni); + flog_err(EC_BGP_EVPN_FAIL, + "%u: Failed to %s EVPN %s route in VNI %u", + bgp->vrf_id, install ? "install" : "uninstall", + evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE + ? "MACIP" + : "IMET", + vpn->vni); return ret; } } @@ -3559,9 +3556,9 @@ static int process_type2_route(struct peer *peer, afi_t afi, safi_t safi, */ if (psize != 33 && psize != 37 && psize != 49 && psize != 36 && psize != 40 && psize != 52) { - flog_err(BGP_ERR_EVPN_ROUTE_INVALID, - "%u:%s - Rx EVPN Type-2 NLRI with invalid length %d", - peer->bgp->vrf_id, peer->host, psize); + flog_err(EC_BGP_EVPN_ROUTE_INVALID, + "%u:%s - Rx EVPN Type-2 NLRI with invalid length %d", + peer->bgp->vrf_id, peer->host, psize); return -1; } @@ -3597,7 +3594,7 @@ static int process_type2_route(struct peer *peer, afi_t afi, safi_t safi, pfx += ETH_ALEN; } else { flog_err( - BGP_ERR_EVPN_ROUTE_INVALID, + EC_BGP_EVPN_ROUTE_INVALID, "%u:%s - Rx EVPN Type-2 NLRI with unsupported MAC address length %d", peer->bgp->vrf_id, peer->host, macaddr_len); return -1; @@ -3609,7 +3606,7 @@ static int process_type2_route(struct peer *peer, afi_t afi, safi_t safi, if (ipaddr_len != 0 && ipaddr_len != IPV4_MAX_BITLEN && ipaddr_len != IPV6_MAX_BITLEN) { flog_err( - BGP_ERR_EVPN_ROUTE_INVALID, + EC_BGP_EVPN_ROUTE_INVALID, "%u:%s - Rx EVPN Type-2 NLRI with unsupported IP address length %d", peer->bgp->vrf_id, peer->host, ipaddr_len); return -1; @@ -3670,9 +3667,9 @@ static int process_type3_route(struct peer *peer, afi_t afi, safi_t safi, * IP len (1) and IP (4 or 16). */ if (psize != 17 && psize != 29) { - flog_err(BGP_ERR_EVPN_ROUTE_INVALID, - "%u:%s - Rx EVPN Type-3 NLRI with invalid length %d", - peer->bgp->vrf_id, peer->host, psize); + flog_err(EC_BGP_EVPN_ROUTE_INVALID, + "%u:%s - Rx EVPN Type-3 NLRI with invalid length %d", + peer->bgp->vrf_id, peer->host, psize); return -1; } @@ -3684,7 +3681,7 @@ static int process_type3_route(struct peer *peer, afi_t afi, safi_t safi, (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL))) { if (attr->pmsi_tnl_type != PMSI_TNLTYPE_INGR_REPL) { flog_warn( - BGP_WARN_EVPN_PMSI_PRESENT, + EC_BGP_EVPN_PMSI_PRESENT, "%u:%s - Rx EVPN Type-3 NLRI with unsupported PTA %d", peer->bgp->vrf_id, peer->host, attr->pmsi_tnl_type); @@ -3715,7 +3712,7 @@ static int process_type3_route(struct peer *peer, afi_t afi, safi_t safi, memcpy(&p.prefix.imet_addr.ip.ip.addr, pfx, IPV4_MAX_BYTELEN); } else { flog_err( - BGP_ERR_EVPN_ROUTE_INVALID, + EC_BGP_EVPN_ROUTE_INVALID, "%u:%s - Rx EVPN Type-3 NLRI with unsupported IP address length %d", peer->bgp->vrf_id, peer->host, ipaddr_len); return -1; @@ -3751,9 +3748,9 @@ static int process_type4_route(struct peer *peer, afi_t afi, safi_t safi, * RD (8), ESI (10), ip-len (1), ip (4 or 16) */ if (psize != 23 && psize != 35) { - flog_err(BGP_ERR_EVPN_ROUTE_INVALID, - "%u:%s - Rx EVPN Type-4 NLRI with invalid length %d", - peer->bgp->vrf_id, peer->host, psize); + flog_err(EC_BGP_EVPN_ROUTE_INVALID, + "%u:%s - Rx EVPN Type-4 NLRI with invalid length %d", + peer->bgp->vrf_id, peer->host, psize); return -1; } @@ -3774,7 +3771,7 @@ static int process_type4_route(struct peer *peer, afi_t afi, safi_t safi, memcpy(&vtep_ip, pfx, IPV4_MAX_BYTELEN); } else { flog_err( - BGP_ERR_EVPN_ROUTE_INVALID, + EC_BGP_EVPN_ROUTE_INVALID, "%u:%s - Rx EVPN Type-4 NLRI with unsupported IP address length %d", peer->bgp->vrf_id, peer->host, ipaddr_len); return -1; @@ -3816,9 +3813,9 @@ static int process_type5_route(struct peer *peer, afi_t afi, safi_t safi, * Note that the IP and GW should both be IPv4 or both IPv6. */ if (psize != 34 && psize != 58) { - flog_err(BGP_ERR_EVPN_ROUTE_INVALID, - "%u:%s - Rx EVPN Type-5 NLRI with invalid length %d", - peer->bgp->vrf_id, peer->host, psize); + flog_err(EC_BGP_EVPN_ROUTE_INVALID, + "%u:%s - Rx EVPN Type-5 NLRI with invalid length %d", + peer->bgp->vrf_id, peer->host, psize); return -1; } @@ -3850,7 +3847,7 @@ static int process_type5_route(struct peer *peer, afi_t afi, safi_t safi, ippfx_len = *pfx++; if (ippfx_len > IPV6_MAX_BITLEN) { flog_err( - BGP_ERR_EVPN_ROUTE_INVALID, + EC_BGP_EVPN_ROUTE_INVALID, "%u:%s - Rx EVPN Type-5 NLRI with invalid IP Prefix length %d", peer->bgp->vrf_id, peer->host, ippfx_len); return -1; @@ -4077,7 +4074,7 @@ void bgp_evpn_withdraw_type5_route(struct bgp *bgp_vrf, struct prefix *p, ret = delete_evpn_type5_route(bgp_vrf, &evp); if (ret) { flog_err( - BGP_ERR_EVPN_ROUTE_DELETE, + EC_BGP_EVPN_ROUTE_DELETE, "%u failed to delete type-5 route for prefix %s in vrf %s", bgp_vrf->vrf_id, prefix2str(p, buf, sizeof(buf)), vrf_id_to_name(bgp_vrf->vrf_id)); @@ -4123,9 +4120,9 @@ void bgp_evpn_advertise_type5_route(struct bgp *bgp_vrf, struct prefix *p, build_type5_prefix_from_ip_prefix(&evp, p); ret = update_evpn_type5_route(bgp_vrf, &evp, src_attr); if (ret) - flog_err(BGP_ERR_EVPN_ROUTE_CREATE, - "%u: Failed to create type-5 route for prefix %s", - bgp_vrf->vrf_id, prefix2str(p, buf, sizeof(buf))); + flog_err(EC_BGP_EVPN_ROUTE_CREATE, + "%u: Failed to create type-5 route for prefix %s", + bgp_vrf->vrf_id, prefix2str(p, buf, sizeof(buf))); } /* Inject all prefixes of a particular address-family (currently, IPv4 or @@ -4684,7 +4681,7 @@ int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr, withdraw ? NULL : attr, pnt, psize, addpath_id)) { flog_err( - BGP_ERR_EVPN_FAIL, + EC_BGP_EVPN_FAIL, "%u:%s - Error in processing EVPN type-2 NLRI size %d", peer->bgp->vrf_id, peer->host, psize); return -1; @@ -4696,7 +4693,7 @@ int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr, withdraw ? NULL : attr, pnt, psize, addpath_id)) { flog_err( - BGP_ERR_PKT_PROCESS, + EC_BGP_PKT_PROCESS, "%u:%s - Error in processing EVPN type-3 NLRI size %d", peer->bgp->vrf_id, peer->host, psize); return -1; @@ -4708,7 +4705,7 @@ int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr, withdraw ? NULL : attr, pnt, psize, addpath_id)) { flog_err( - BGP_ERR_PKT_PROCESS, + EC_BGP_PKT_PROCESS, "%u:%s - Error in processing EVPN type-4 NLRI size %d", peer->bgp->vrf_id, peer->host, psize); return -1; @@ -4719,7 +4716,7 @@ int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr, if (process_type5_route(peer, afi, safi, attr, pnt, psize, addpath_id, withdraw)) { flog_err( - BGP_ERR_PKT_PROCESS, + EC_BGP_PKT_PROCESS, "%u:%s - Error in processing EVPN type-5 NLRI size %d", peer->bgp->vrf_id, peer->host, psize); return -1; @@ -5164,7 +5161,7 @@ int bgp_evpn_local_macip_del(struct bgp *bgp, vni_t vni, struct ethaddr *mac, /* Lookup VNI hash - should exist. */ vpn = bgp_evpn_lookup_vni(bgp, vni); if (!vpn || !is_vni_live(vpn)) { - flog_warn(BGP_WARN_EVPN_VPN_VNI, + flog_warn(EC_BGP_EVPN_VPN_VNI, "%u: VNI hash entry for VNI %u %s at MACIP DEL", bgp->vrf_id, vni, vpn ? "not live" : "not found"); return -1; @@ -5189,7 +5186,7 @@ int bgp_evpn_local_macip_add(struct bgp *bgp, vni_t vni, struct ethaddr *mac, /* Lookup VNI hash - should exist. */ vpn = bgp_evpn_lookup_vni(bgp, vni); if (!vpn || !is_vni_live(vpn)) { - flog_warn(BGP_WARN_EVPN_VPN_VNI, + flog_warn(EC_BGP_EVPN_VPN_VNI, "%u: VNI hash entry for VNI %u %s at MACIP ADD", bgp->vrf_id, vni, vpn ? "not live" : "not found"); return -1; @@ -5202,7 +5199,7 @@ int bgp_evpn_local_macip_add(struct bgp *bgp, vni_t vni, struct ethaddr *mac, char buf2[INET6_ADDRSTRLEN]; flog_err( - BGP_ERR_EVPN_ROUTE_CREATE, + EC_BGP_EVPN_ROUTE_CREATE, "%u:Failed to create Type-2 route, VNI %u %s MAC %s IP %s (flags: 0x%x)", bgp->vrf_id, vpn->vni, CHECK_FLAG(flags, ZEBRA_MACIP_TYPE_STICKY) @@ -5244,7 +5241,7 @@ int bgp_evpn_local_l3vni_add(vni_t l3vni, vrf_id_t vrf_id, struct ethaddr *rmac, bgp_def = bgp_get_default(); if (!bgp_def) { flog_err( - BGP_ERR_NO_DFLT, + EC_BGP_NO_DFLT, "Cannot process L3VNI %u ADD - default BGP instance not yet created", l3vni); return -1; @@ -5261,16 +5258,16 @@ int bgp_evpn_local_l3vni_add(vni_t l3vni, vrf_id_t vrf_id, struct ethaddr *rmac, BGP_INSTANCE_TYPE_VRF); switch (ret) { case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: - flog_err(BGP_ERR_MULTI_INSTANCE, - "'bgp multiple-instance' not present\n"); + flog_err(EC_BGP_MULTI_INSTANCE, + "'bgp multiple-instance' not present\n"); return -1; case BGP_ERR_AS_MISMATCH: - flog_err(BGP_ERR_EVPN_AS_MISMATCH, - "BGP is already running; AS is %u\n", as); + flog_err(EC_BGP_EVPN_AS_MISMATCH, + "BGP is already running; AS is %u\n", as); return -1; case BGP_ERR_INSTANCE_MISMATCH: - flog_err(BGP_ERR_EVPN_INSTANCE_MISMATCH, - "BGP instance name and AS number mismatch\n"); + flog_err(EC_BGP_EVPN_INSTANCE_MISMATCH, + "BGP instance name and AS number mismatch\n"); return -1; } @@ -5332,7 +5329,7 @@ int bgp_evpn_local_l3vni_del(vni_t l3vni, vrf_id_t vrf_id) bgp_vrf = bgp_lookup_by_vrf_id(vrf_id); if (!bgp_vrf) { flog_err( - BGP_ERR_NO_DFLT, + EC_BGP_NO_DFLT, "Cannot process L3VNI %u Del - Could not find BGP instance", l3vni); return -1; @@ -5341,7 +5338,7 @@ int bgp_evpn_local_l3vni_del(vni_t l3vni, vrf_id_t vrf_id) bgp_def = bgp_get_default(); if (!bgp_def) { flog_err( - BGP_ERR_NO_DFLT, + EC_BGP_NO_DFLT, "Cannot process L3VNI %u Del - Could not find default BGP instance", l3vni); return -1; @@ -5403,7 +5400,7 @@ int bgp_evpn_local_vni_del(struct bgp *bgp, vni_t vni) if (!vpn) { if (bgp_debug_zebra(NULL)) flog_warn( - BGP_WARN_EVPN_VPN_VNI, + EC_BGP_EVPN_VPN_VNI, "%u: VNI hash entry for VNI %u not found at DEL", bgp->vrf_id, vni); return 0; @@ -5473,7 +5470,7 @@ int bgp_evpn_local_vni_add(struct bgp *bgp, vni_t vni, vpn = bgp_evpn_new(bgp, vni, originator_ip, tenant_vrf_id); if (!vpn) { flog_err( - BGP_ERR_VNI, + EC_BGP_VNI, "%u: Failed to allocate VNI entry for VNI %u - at Add", bgp->vrf_id, vni); return -1; @@ -5496,9 +5493,9 @@ int bgp_evpn_local_vni_add(struct bgp *bgp, vni_t vni, /* Create EVPN type-3 route and schedule for processing. */ build_evpn_type3_prefix(&p, vpn->originator_ip); if (update_evpn_route(bgp, vpn, &p, 0, 0)) { - flog_err(BGP_ERR_EVPN_ROUTE_CREATE, - "%u: Type3 route creation failure for VNI %u", - bgp->vrf_id, vni); + flog_err(EC_BGP_EVPN_ROUTE_CREATE, + "%u: Type3 route creation failure for VNI %u", + bgp->vrf_id, vni); return -1; } @@ -5526,15 +5523,15 @@ int bgp_evpn_local_es_del(struct bgp *bgp, struct evpnes *es = NULL; if (!bgp->esihash) { - flog_err(BGP_ERR_ES_CREATE, "%u: ESI hash not yet created", - bgp->vrf_id); + flog_err(EC_BGP_ES_CREATE, "%u: ESI hash not yet created", + bgp->vrf_id); return -1; } /* Lookup ESI hash - should exist. */ es = bgp_evpn_lookup_es(bgp, esi); if (!es) { - flog_warn(BGP_WARN_EVPN_ESI, + flog_warn(EC_BGP_EVPN_ESI, "%u: ESI hash entry for ESI %s at Local ES DEL", bgp->vrf_id, esi_to_str(esi, buf, sizeof(buf))); return -1; @@ -5563,8 +5560,8 @@ int bgp_evpn_local_es_add(struct bgp *bgp, struct prefix_evpn p; if (!bgp->esihash) { - flog_err(BGP_ERR_ES_CREATE, "%u: ESI hash not yet created", - bgp->vrf_id); + flog_err(EC_BGP_ES_CREATE, "%u: ESI hash not yet created", + bgp->vrf_id); return -1; } @@ -5574,7 +5571,7 @@ int bgp_evpn_local_es_add(struct bgp *bgp, es = bgp_evpn_es_new(bgp, esi, originator_ip); if (!es) { flog_err( - BGP_ERR_ES_CREATE, + EC_BGP_ES_CREATE, "%u: Failed to allocate ES entry for ESI %s - at Local ES Add", bgp->vrf_id, esi_to_str(esi, buf, sizeof(buf))); return -1; @@ -5585,9 +5582,9 @@ int bgp_evpn_local_es_add(struct bgp *bgp, build_evpn_type4_prefix(&p, esi, originator_ip->ipaddr_v4); if (update_evpn_type4_route(bgp, es, &p)) { - flog_err(BGP_ERR_EVPN_ROUTE_CREATE, - "%u: Type4 route creation failure for ESI %s", - bgp->vrf_id, esi_to_str(esi, buf, sizeof(buf))); + flog_err(EC_BGP_EVPN_ROUTE_CREATE, + "%u: Type4 route creation failure for ESI %s", + bgp->vrf_id, esi_to_str(esi, buf, sizeof(buf))); return -1; } diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index a6cc2d9b53..6f907c3ab5 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -1890,9 +1890,10 @@ static struct bgpevpn *evpn_create_update_vni(struct bgp *bgp, vni_t vni) if (!vpn) { /* Check if this L2VNI is already configured as L3VNI */ if (bgp_evpn_lookup_l3vni_l2vni_table(vni)) { - flog_err(BGP_ERR_VNI, - "%u: Failed to create L2VNI %u, it is configured as L3VNI", - bgp->vrf_id, vni); + flog_err( + EC_BGP_VNI, + "%u: Failed to create L2VNI %u, it is configured as L3VNI", + bgp->vrf_id, vni); return NULL; } @@ -1902,7 +1903,7 @@ static struct bgpevpn *evpn_create_update_vni(struct bgp *bgp, vni_t vni) vpn = bgp_evpn_new(bgp, vni, bgp->router_id, 0); if (!vpn) { flog_err( - BGP_ERR_VNI, + EC_BGP_VNI, "%u: Failed to allocate VNI entry for VNI %u - at Config", bgp->vrf_id, vni); return NULL; diff --git a/bgpd/bgp_flowspec.c b/bgpd/bgp_flowspec.c index c604135bfd..ab8bfcb770 100644 --- a/bgpd/bgp_flowspec.c +++ b/bgpd/bgp_flowspec.c @@ -104,15 +104,14 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr, safi = packet->safi; if (afi == AFI_IP6) { - flog_err(LIB_ERR_DEVELOPMENT, - "BGP flowspec IPv6 not supported"); + flog_err(EC_LIB_DEVELOPMENT, "BGP flowspec IPv6 not supported"); return -1; } if (packet->length >= FLOWSPEC_NLRI_SIZELIMIT) { - flog_err(BGP_ERR_FLOWSPEC_PACKET, - "BGP flowspec nlri length maximum reached (%u)", - packet->length); + flog_err(EC_BGP_FLOWSPEC_PACKET, + "BGP flowspec nlri length maximum reached (%u)", + packet->length); return -1; } @@ -128,14 +127,16 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr, /* When packet overflow occur return immediately. */ if (pnt + psize > lim) { - flog_err(BGP_ERR_FLOWSPEC_PACKET, - "Flowspec NLRI length inconsistent ( size %u seen)", - psize); + flog_err( + EC_BGP_FLOWSPEC_PACKET, + "Flowspec NLRI length inconsistent ( size %u seen)", + psize); return -1; } if (bgp_fs_nlri_validate(pnt, psize) < 0) { - flog_err(BGP_ERR_FLOWSPEC_PACKET, - "Bad flowspec format or NLRI options not supported"); + flog_err( + EC_BGP_FLOWSPEC_PACKET, + "Bad flowspec format or NLRI options not supported"); return -1; } p.family = AF_FLOWSPEC; @@ -188,9 +189,9 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0, NULL); if (ret) { - flog_err(BGP_ERR_FLOWSPEC_INSTALLATION, - "Flowspec NLRI failed to be %s.", - attr ? "added" : "withdrawn"); + flog_err(EC_BGP_FLOWSPEC_INSTALLATION, + "Flowspec NLRI failed to be %s.", + attr ? "added" : "withdrawn"); return -1; } } diff --git a/bgpd/bgp_flowspec_util.c b/bgpd/bgp_flowspec_util.c index 9f92a3c3a6..cb71a64a85 100644 --- a/bgpd/bgp_flowspec_util.c +++ b/bgpd/bgp_flowspec_util.c @@ -68,9 +68,8 @@ static int bgp_flowspec_call_non_opaque_decode(uint8_t *nlri_content, int len, len, mval, error); if (*error < 0) - flog_err(BGP_ERR_FLOWSPEC_PACKET, - "%s: flowspec_op_decode error %d", - __func__, *error); + flog_err(EC_BGP_FLOWSPEC_PACKET, + "%s: flowspec_op_decode error %d", __func__, *error); else *match_num = *error; return ret; @@ -447,9 +446,9 @@ int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len, len - offset, prefix, &error); if (error < 0) - flog_err(BGP_ERR_FLOWSPEC_PACKET, - "%s: flowspec_ip_address error %d", - __func__, error); + flog_err(EC_BGP_FLOWSPEC_PACKET, + "%s: flowspec_ip_address error %d", + __func__, error); else bpem->match_bitmask |= bitmask; offset += ret; @@ -542,9 +541,10 @@ int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len, len - offset, &bpem->tcpflags, &error); if (error < 0) - flog_err(BGP_ERR_FLOWSPEC_PACKET, - "%s: flowspec_tcpflags_decode error %d", - __func__, error); + flog_err( + EC_BGP_FLOWSPEC_PACKET, + "%s: flowspec_tcpflags_decode error %d", + __func__, error); else bpem->match_tcpflags_num = error; /* contains the number of slots used */ @@ -557,16 +557,17 @@ int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len, len - offset, &bpem->fragment, &error); if (error < 0) - flog_err(BGP_ERR_FLOWSPEC_PACKET, - "%s: flowspec_fragment_type_decode error %d", - __func__, error); + flog_err( + EC_BGP_FLOWSPEC_PACKET, + "%s: flowspec_fragment_type_decode error %d", + __func__, error); else bpem->match_fragment_num = error; offset += ret; break; default: - flog_err(LIB_ERR_DEVELOPMENT, "%s: unknown type %d\n", - __func__, type); + flog_err(EC_LIB_DEVELOPMENT, "%s: unknown type %d\n", + __func__, type); } } return error; diff --git a/bgpd/bgp_flowspec_vty.c b/bgpd/bgp_flowspec_vty.c index 978ce6bf4e..faa88f9850 100644 --- a/bgpd/bgp_flowspec_vty.c +++ b/bgpd/bgp_flowspec_vty.c @@ -519,7 +519,7 @@ DEFUN (bgp_fs_local_install_ifname, { struct bgp *bgp = VTY_GET_CONTEXT(bgp); int idx = 0; - const char *no = strmatch(argv[0]->text, (char *)"no") ? "no" : NULL; + const char *no = strmatch(argv[0]->text, "no") ? "no" : NULL; char *ifname = argv_find(argv, argc, "INTERFACE", &idx) ? argv[idx]->arg : NULL; diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index 14d692ebf0..384d2bca82 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -167,7 +167,7 @@ static struct peer *peer_xfer_conn(struct peer *from_peer) */ if (peer->curr) { flog_err( - BGP_ERR_PKT_PROCESS, + EC_BGP_PKT_PROCESS, "[%s] Dropping pending packet on connection transfer:", peer->host); uint16_t type = stream_getc_from(peer->curr, @@ -246,7 +246,7 @@ static struct peer *peer_xfer_conn(struct peer *from_peer) if (bgp_getsockname(peer) < 0) { flog_err( - LIB_ERR_SOCKET, + EC_LIB_SOCKET, "%%bgp_getsockname() failed for %s peer %s fd %d (from_peer fd %d)", (CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER) ? "accept" @@ -259,7 +259,7 @@ static struct peer *peer_xfer_conn(struct peer *from_peer) if (from_peer->status > Active) { if (bgp_getsockname(from_peer) < 0) { flog_err( - LIB_ERR_SOCKET, + EC_LIB_SOCKET, "%%bgp_getsockname() failed for %s from_peer %s fd %d (peer fd %d)", (CHECK_FLAG(from_peer->sflags, @@ -1286,15 +1286,15 @@ static int bgp_connect_check(struct thread *thread) static int bgp_connect_success(struct peer *peer) { if (peer->fd < 0) { - flog_err(BGP_ERR_CONNECT, - "bgp_connect_success peer's fd is negative value %d", - peer->fd); + flog_err(EC_BGP_CONNECT, + "bgp_connect_success peer's fd is negative value %d", + peer->fd); bgp_stop(peer); return -1; } if (bgp_getsockname(peer) < 0) { - flog_err_sys(LIB_ERR_SOCKET, + flog_err_sys(EC_LIB_SOCKET, "%s: bgp_getsockname(): failed for peer %s, fd %d", __FUNCTION__, peer->host, peer->fd); bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR, @@ -1354,10 +1354,10 @@ int bgp_start(struct peer *peer) if (BGP_PEER_START_SUPPRESSED(peer)) { if (bgp_debug_neighbor_events(peer)) - flog_err(BGP_ERR_FSM, - "%s [FSM] Trying to start suppressed peer" - " - this is never supposed to happen!", - peer->host); + flog_err(EC_BGP_FSM, + "%s [FSM] Trying to start suppressed peer" + " - this is never supposed to happen!", + peer->host); return -1; } @@ -1390,7 +1390,7 @@ int bgp_start(struct peer *peer) if (peer->bgp->vrf_id == VRF_UNKNOWN) { if (bgp_debug_neighbor_events(peer)) flog_err( - BGP_ERR_FSM, + EC_BGP_FSM, "%s [FSM] In a VRF that is not initialised yet", peer->host); return -1; @@ -1444,9 +1444,9 @@ int bgp_start(struct peer *peer) "%s [FSM] Non blocking connect waiting result, fd %d", peer->host, peer->fd); if (peer->fd < 0) { - flog_err(BGP_ERR_FSM, - "bgp_start peer's fd is negative value %d", - peer->fd); + flog_err(EC_BGP_FSM, + "bgp_start peer's fd is negative value %d", + peer->fd); return -1; } /* @@ -1492,9 +1492,8 @@ static int bgp_fsm_open(struct peer *peer) peer and change to Idle status. */ static int bgp_fsm_event_error(struct peer *peer) { - flog_err(BGP_ERR_FSM, - "%s [FSM] unexpected packet received in state %s", peer->host, - lookup_msg(bgp_status_msg, peer->status, NULL)); + flog_err(EC_BGP_FSM, "%s [FSM] unexpected packet received in state %s", + peer->host, lookup_msg(bgp_status_msg, peer->status, NULL)); return bgp_stop_with_notify(peer, BGP_NOTIFY_FSM_ERR, 0); } @@ -1526,7 +1525,7 @@ static int bgp_establish(struct peer *peer) other = peer->doppelganger; peer = peer_xfer_conn(peer); if (!peer) { - flog_err(BGP_ERR_CONNECT, "%%Neighbor failed in xfer_conn"); + flog_err(EC_BGP_CONNECT, "%%Neighbor failed in xfer_conn"); return -1; } @@ -1686,7 +1685,7 @@ static int bgp_fsm_update(struct peer *peer) static int bgp_ignore(struct peer *peer) { flog_err( - BGP_ERR_FSM, + EC_BGP_FSM, "%s [FSM] Ignoring event %s in state %s, prior events %s, %s, fd %d", peer->host, bgp_event_str[peer->cur_event], lookup_msg(bgp_status_msg, peer->status, NULL), @@ -1699,7 +1698,7 @@ static int bgp_ignore(struct peer *peer) static int bgp_fsm_exeption(struct peer *peer) { flog_err( - BGP_ERR_FSM, + EC_BGP_FSM, "%s [FSM] Unexpected event %s in state %s, prior events %s, %s, fd %d", peer->host, bgp_event_str[peer->cur_event], lookup_msg(bgp_status_msg, peer->status, NULL), @@ -1974,7 +1973,7 @@ int bgp_event_update(struct peer *peer, int event) */ if (!dyn_nbr && !passive_conn && peer->bgp) { flog_err( - BGP_ERR_FSM, + EC_BGP_FSM, "%s [FSM] Failure handling event %s in state %s, " "prior events %s, %s, fd %d", peer->host, bgp_event_str[peer->cur_event], diff --git a/bgpd/bgp_io.c b/bgpd/bgp_io.c index 311f98001d..c3bfbe4a90 100644 --- a/bgpd/bgp_io.c +++ b/bgpd/bgp_io.c @@ -402,9 +402,9 @@ static uint16_t bgp_read(struct peer *peer) SET_FLAG(status, BGP_IO_TRANS_ERR); /* Fatal error; tear down session */ } else if (nbytes < 0) { - flog_err(BGP_ERR_UPDATE_RCV, - "%s [Error] bgp_read_packet error: %s", peer->host, - safe_strerror(errno)); + flog_err(EC_BGP_UPDATE_RCV, + "%s [Error] bgp_read_packet error: %s", peer->host, + safe_strerror(errno)); if (peer->status == Established) { if (CHECK_FLAG(peer->sflags, PEER_STATUS_NSF_MODE)) { diff --git a/bgpd/bgp_label.c b/bgpd/bgp_label.c index c32df275a3..ba059d66e6 100644 --- a/bgpd/bgp_label.c +++ b/bgpd/bgp_label.c @@ -192,7 +192,7 @@ static int bgp_nlri_get_labels(struct peer *peer, uint8_t *pnt, uint8_t plen, if (!(bgp_is_withdraw_label(label) || label_bos(label))) flog_warn( - BGP_WARN_INVALID_LABEL_STACK, + EC_BGP_INVALID_LABEL_STACK, "%s rcvd UPDATE with invalid label stack - no bottom of stack", peer->host); @@ -247,7 +247,7 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr, /* sanity check against packet data */ if ((pnt + psize) > lim) { flog_err( - BGP_ERR_UPDATE_RCV, + EC_BGP_UPDATE_RCV, "%s [Error] Update packet error / L-U (prefix length %d exceeds packet size %u)", peer->host, prefixlen, (uint)(lim - pnt)); return -1; @@ -259,10 +259,10 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr, /* There needs to be at least one label */ if (prefixlen < 24) { - flog_err(BGP_ERR_UPDATE_RCV, - "%s [Error] Update packet error" - " (wrong label length %d)", - peer->host, prefixlen); + flog_err(EC_BGP_UPDATE_RCV, + "%s [Error] Update packet error" + " (wrong label length %d)", + peer->host, prefixlen); bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, BGP_NOTIFY_UPDATE_INVAL_NETWORK); return -1; @@ -288,7 +288,7 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr, * ignored. */ flog_err( - BGP_ERR_UPDATE_RCV, + EC_BGP_UPDATE_RCV, "%s: IPv4 labeled-unicast NLRI is multicast address %s, ignoring", peer->host, inet_ntoa(p.u.prefix4)); continue; @@ -301,7 +301,7 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr, char buf[BUFSIZ]; flog_err( - BGP_ERR_UPDATE_RCV, + EC_BGP_UPDATE_RCV, "%s: IPv6 labeled-unicast NLRI is link-local address %s, ignoring", peer->host, inet_ntop(AF_INET6, &p.u.prefix6, buf, @@ -314,7 +314,7 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr, char buf[BUFSIZ]; flog_err( - BGP_ERR_UPDATE_RCV, + EC_BGP_UPDATE_RCV, "%s: IPv6 unicast NLRI is multicast address %s, ignoring", peer->host, inet_ntop(AF_INET6, &p.u.prefix6, buf, @@ -338,7 +338,7 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr, /* Packet length consistency check. */ if (pnt != lim) { flog_err( - BGP_ERR_UPDATE_RCV, + EC_BGP_UPDATE_RCV, "%s [Error] Update packet error / L-U (%zu data remaining after parsing)", peer->host, lim - pnt); return -1; diff --git a/bgpd/bgp_labelpool.c b/bgpd/bgp_labelpool.c index 8d15649ea5..7a7a400278 100644 --- a/bgpd/bgp_labelpool.c +++ b/bgpd/bgp_labelpool.c @@ -127,8 +127,8 @@ static wq_item_status lp_cbq_docallback(struct work_queue *wq, void *data) if (lcbq->label == MPLS_LABEL_NONE) { /* shouldn't happen */ - flog_err(BGP_ERR_LABEL, "%s: error: label==MPLS_LABEL_NONE", - __func__); + flog_err(EC_BGP_LABEL, "%s: error: label==MPLS_LABEL_NONE", + __func__); return WQ_SUCCESS; } @@ -338,9 +338,9 @@ void bgp_lp_get( if (rc) { /* shouldn't happen */ - flog_err(BGP_ERR_LABEL, - "%s: can't insert new LCB into ledger list", - __func__); + flog_err(EC_BGP_LABEL, + "%s: can't insert new LCB into ledger list", + __func__); XFREE(MTYPE_BGP_LABEL_CB, lcb); return; } @@ -427,9 +427,9 @@ void bgp_lp_event_chunk(uint8_t keep, uint32_t first, uint32_t last) struct lp_fifo *lf; if (last < first) { - flog_err(BGP_ERR_LABEL, - "%s: zebra label chunk invalid: first=%u, last=%u", - __func__, first, last); + flog_err(EC_BGP_LABEL, + "%s: zebra label chunk invalid: first=%u, last=%u", + __func__, first, last); return; } diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index e0834604b2..d888090e60 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -410,7 +410,7 @@ int main(int argc, char **argv) if (multipath_num > MULTIPATH_NUM || multipath_num <= 0) { flog_err( - BGP_ERR_MULTIPATH, + EC_BGP_MULTIPATH, "Multipath Number specified must be less than %d and greater than 0", MULTIPATH_NUM); return 1; diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 459775c8ec..276945cbf6 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -152,7 +152,7 @@ int bgp_nlri_parse_vpn(struct peer *peer, struct attr *attr, if (prefixlen < VPN_PREFIXLEN_MIN_BYTES * 8) { flog_err( - BGP_ERR_UPDATE_RCV, + EC_BGP_UPDATE_RCV, "%s [Error] Update packet error / VPN (prefix length %d less than VPN min length)", peer->host, prefixlen); return -1; @@ -161,7 +161,7 @@ int bgp_nlri_parse_vpn(struct peer *peer, struct attr *attr, /* sanity check against packet data */ if ((pnt + psize) > lim) { flog_err( - BGP_ERR_UPDATE_RCV, + EC_BGP_UPDATE_RCV, "%s [Error] Update packet error / VPN (prefix length %d exceeds packet size %u)", peer->host, prefixlen, (uint)(lim - pnt)); return -1; @@ -170,7 +170,7 @@ int bgp_nlri_parse_vpn(struct peer *peer, struct attr *attr, /* sanity check against storage for the IP address portion */ if ((psize - VPN_PREFIXLEN_MIN_BYTES) > (ssize_t)sizeof(p.u)) { flog_err( - BGP_ERR_UPDATE_RCV, + EC_BGP_UPDATE_RCV, "%s [Error] Update packet error / VPN (psize %d exceeds storage size %zu)", peer->host, prefixlen - VPN_PREFIXLEN_MIN_BYTES * 8, @@ -181,7 +181,7 @@ int bgp_nlri_parse_vpn(struct peer *peer, struct attr *attr, /* Sanity check against max bitlen of the address family */ if ((psize - VPN_PREFIXLEN_MIN_BYTES) > prefix_blen(&p)) { flog_err( - BGP_ERR_UPDATE_RCV, + EC_BGP_UPDATE_RCV, "%s [Error] Update packet error / VPN (psize %d exceeds family (%u) max byte len %u)", peer->host, prefixlen - VPN_PREFIXLEN_MIN_BYTES * 8, @@ -218,8 +218,7 @@ int bgp_nlri_parse_vpn(struct peer *peer, struct attr *attr, #endif default: - flog_err(BGP_ERR_UPDATE_RCV, "Unknown RD type %d", - type); + flog_err(EC_BGP_UPDATE_RCV, "Unknown RD type %d", type); break; /* just report */ } @@ -242,7 +241,7 @@ int bgp_nlri_parse_vpn(struct peer *peer, struct attr *attr, /* Packet length consistency check. */ if (pnt != lim) { flog_err( - BGP_ERR_UPDATE_RCV, + EC_BGP_UPDATE_RCV, "%s [Error] Update packet error / VPN (%zu data remaining after parsing)", peer->host, lim - pnt); return -1; @@ -366,10 +365,10 @@ int vpn_leak_label_callback( return 0; } /* Shouldn't happen: different label allocation */ - flog_err(BGP_ERR_LABEL, - "%s: %s had label %u but got new assignment %u", - __func__, vp->bgp->name_pretty, vp->tovpn_label, - label); + flog_err(EC_BGP_LABEL, + "%s: %s had label %u but got new assignment %u", + __func__, vp->bgp->name_pretty, vp->tovpn_label, + label); /* use new one */ } diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index 96d2e2f2ab..d56fdd75ce 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -36,6 +36,7 @@ #include "filter.h" #include "ns.h" #include "lib_errors.h" +#include "nexthop.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_open.h" @@ -44,6 +45,7 @@ #include "bgpd/bgp_debug.h" #include "bgpd/bgp_errors.h" #include "bgpd/bgp_network.h" +#include "bgpd/bgp_zebra.h" extern struct zebra_privs_t bgpd_privs; @@ -84,7 +86,7 @@ static int bgp_md5_set_socket(int socket, union sockunion *su, #endif /* HAVE_TCP_MD5SIG */ if (ret < 0) - flog_warn(BGP_WARN_NO_TCP_MD5, + flog_warn(EC_BGP_NO_TCP_MD5, "can't set TCP_MD5SIG option on socket %d: %s", socket, safe_strerror(en)); @@ -149,7 +151,7 @@ int bgp_set_socket_ttl(struct peer *peer, int bgp_sock) ret = sockopt_ttl(peer->su.sa.sa_family, bgp_sock, peer->ttl); if (ret) { flog_err( - LIB_ERR_SOCKET, + EC_LIB_SOCKET, "%s: Can't set TxTTL on peer (rtrid %s) socket, err = %d", __func__, inet_ntop(AF_INET, &peer->remote_id, buf, @@ -165,7 +167,7 @@ int bgp_set_socket_ttl(struct peer *peer, int bgp_sock) ret = sockopt_ttl(peer->su.sa.sa_family, bgp_sock, MAXTTL); if (ret) { flog_err( - LIB_ERR_SOCKET, + EC_LIB_SOCKET, "%s: Can't set TxTTL on peer (rtrid %s) socket, err = %d", __func__, inet_ntop(AF_INET, &peer->remote_id, buf, @@ -177,7 +179,7 @@ int bgp_set_socket_ttl(struct peer *peer, int bgp_sock) MAXTTL + 1 - peer->gtsm_hops); if (ret) { flog_err( - LIB_ERR_SOCKET, + EC_LIB_SOCKET, "%s: Can't set MinTTL on peer (rtrid %s) socket, err = %d", __func__, inet_ntop(AF_INET, &peer->remote_id, buf, @@ -222,10 +224,9 @@ static int bgp_get_instance_for_inc_conn(int sock, struct bgp **bgp_inst) rc = getsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, name, &name_len); if (rc != 0) { #if defined(HAVE_CUMULUS) - flog_err( - LIB_ERR_SOCKET, - "[Error] BGP SO_BINDTODEVICE get failed (%s), sock %d", - safe_strerror(errno), sock); + flog_err(EC_LIB_SOCKET, + "[Error] BGP SO_BINDTODEVICE get failed (%s), sock %d", + safe_strerror(errno), sock); return -1; #endif } @@ -280,7 +281,7 @@ static int bgp_accept(struct thread *thread) /* Register accept thread. */ accept_sock = THREAD_FD(thread); if (accept_sock < 0) { - flog_err_sys(LIB_ERR_SOCKET, "accept_sock is nevative value %d", + flog_err_sys(EC_LIB_SOCKET, "accept_sock is nevative value %d", accept_sock); return -1; } @@ -292,7 +293,7 @@ static int bgp_accept(struct thread *thread) /* Accept client connection. */ bgp_sock = sockunion_accept(accept_sock, &su); if (bgp_sock < 0) { - flog_err_sys(LIB_ERR_SOCKET, + flog_err_sys(EC_LIB_SOCKET, "[Error] BGP socket accept failed (%s)", safe_strerror(errno)); return -1; @@ -562,7 +563,7 @@ int bgp_connect(struct peer *peer) sockopt_reuseaddr(peer->fd); sockopt_reuseport(peer->fd); if (sockopt_mark_default(peer->fd, DATAPLANE_MARK, &bgpd_privs) < 0) - flog_warn(BGP_WARN_NO_SOCKOPT_MARK, + flog_warn(EC_BGP_NO_SOCKOPT_MARK, "Unable to set mark on FD for peer %s, err=%s", peer->host, safe_strerror(errno)); @@ -619,15 +620,12 @@ int bgp_getsockname(struct peer *peer) if (!peer->su_remote) return -1; - if (bgp_nexthop_set(peer->su_local, peer->su_remote, &peer->nexthop, - peer)) { -#if defined(HAVE_CUMULUS) - flog_err( - BGP_ERR_NH_UPD, - "%s: nexthop_set failed, resetting connection - intf %p", - peer->host, peer->nexthop.ifp); + if (!bgp_zebra_nexthop_set(peer->su_local, peer->su_remote, + &peer->nexthop, peer)) { + flog_err(EC_BGP_NH_UPD, + "%s: nexthop_set failed, resetting connection - intf %p", + peer->host, peer->nexthop.ifp); return -1; -#endif } return 0; } @@ -659,14 +657,13 @@ static int bgp_listener(int sock, struct sockaddr *sa, socklen_t salen, } if (ret < 0) { - flog_err_sys(LIB_ERR_SOCKET, "bind: %s", safe_strerror(en)); + flog_err_sys(EC_LIB_SOCKET, "bind: %s", safe_strerror(en)); return ret; } ret = listen(sock, SOMAXCONN); if (ret < 0) { - flog_err_sys(LIB_ERR_SOCKET, "listen: %s", - safe_strerror(errno)); + flog_err_sys(EC_LIB_SOCKET, "listen: %s", safe_strerror(errno)); return ret; } @@ -708,7 +705,7 @@ int bgp_socket(struct bgp *bgp, unsigned short port, const char *address) bgp->vrf_id); } if (ret != 0) { - flog_err_sys(LIB_ERR_SOCKET, "getaddrinfo: %s", + flog_err_sys(EC_LIB_SOCKET, "getaddrinfo: %s", gai_strerror(ret)); return -1; } @@ -729,7 +726,7 @@ int bgp_socket(struct bgp *bgp, unsigned short port, const char *address) ? bgp->name : NULL)); } if (sock < 0) { - flog_err_sys(LIB_ERR_SOCKET, "socket: %s", + flog_err_sys(EC_LIB_SOCKET, "socket: %s", safe_strerror(errno)); continue; } @@ -748,10 +745,10 @@ int bgp_socket(struct bgp *bgp, unsigned short port, const char *address) freeaddrinfo(ainfo_save); if (count == 0 && bgp->inst_type != BGP_INSTANCE_TYPE_VRF) { flog_err( - LIB_ERR_SOCKET, + EC_LIB_SOCKET, "%s: no usable addresses please check other programs usage of specified port %d", __func__, port); - flog_err_sys(LIB_ERR_SOCKET, "%s: Program cannot continue", + flog_err_sys(EC_LIB_SOCKET, "%s: Program cannot continue", __func__); exit(-1); } diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index cf055fd438..3d2a4ee0dd 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -345,7 +345,7 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id) bgp = bgp_lookup_by_vrf_id(vrf_id); if (!bgp) { flog_err( - BGP_ERR_NH_UPD, + EC_BGP_NH_UPD, "parse nexthop update: instance not found for vrf_id %u", vrf_id); return; @@ -592,7 +592,7 @@ static void sendmsg_zebra_rnh(struct bgp_nexthop_cache *bnc, int command) bnc->bgp->vrf_id); /* TBD: handle the failure */ if (ret < 0) - flog_warn(BGP_WARN_ZEBRA_SEND, + flog_warn(EC_BGP_ZEBRA_SEND, "sendmsg_nexthop: zclient_send_message() failed"); if ((command == ZEBRA_NEXTHOP_REGISTER) diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c index 2a32f02f42..62b412af0c 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -255,7 +255,7 @@ static int bgp_capability_mp(struct peer *peer, struct capability_header *hdr) /* Verify length is 4 */ if (hdr->length != 4) { flog_warn( - BGP_WARN_CAPABILITY_INVALID_LENGTH, + EC_BGP_CAPABILITY_INVALID_LENGTH, "MP Cap: Received invalid length %d, non-multiple of 4", hdr->length); return -1; @@ -451,7 +451,7 @@ static int bgp_capability_restart(struct peer *peer, /* Verify length is a multiple of 4 */ if ((caphdr->length - 2) % 4) { flog_warn( - BGP_WARN_CAPABILITY_INVALID_LENGTH, + EC_BGP_CAPABILITY_INVALID_LENGTH, "Restart Cap: Received invalid length %d, non-multiple of 4", caphdr->length); return -1; @@ -523,9 +523,9 @@ static as_t bgp_capability_as4(struct peer *peer, struct capability_header *hdr) SET_FLAG(peer->cap, PEER_CAP_AS4_RCV); if (hdr->length != CAPABILITY_CODE_AS4_LEN) { - flog_err(BGP_ERR_PKT_OPEN, - "%s AS4 capability has incorrect data length %d", - peer->host, hdr->length); + flog_err(EC_BGP_PKT_OPEN, + "%s AS4 capability has incorrect data length %d", + peer->host, hdr->length); return 0; } @@ -549,7 +549,7 @@ static int bgp_capability_addpath(struct peer *peer, /* Verify length is a multiple of 4 */ if (hdr->length % 4) { flog_warn( - BGP_WARN_CAPABILITY_INVALID_LENGTH, + EC_BGP_CAPABILITY_INVALID_LENGTH, "Add Path: Received invalid length %d, non-multiple of 4", hdr->length); return -1; @@ -608,7 +608,7 @@ static int bgp_capability_enhe(struct peer *peer, struct capability_header *hdr) /* Verify length is a multiple of 4 */ if (hdr->length % 6) { flog_warn( - BGP_WARN_CAPABILITY_INVALID_LENGTH, + EC_BGP_CAPABILITY_INVALID_LENGTH, "Extended NH: Received invalid length %d, non-multiple of 6", hdr->length); return -1; @@ -651,7 +651,7 @@ static int bgp_capability_enhe(struct peer *peer, struct capability_header *hdr) || !(safi == SAFI_UNICAST || safi == SAFI_LABELED_UNICAST)) { flog_warn( - BGP_WARN_CAPABILITY_INVALID_DATA, + EC_BGP_CAPABILITY_INVALID_DATA, "%s Unexpected afi/safi/next-hop afi: %u/%u/%u " "in Extended Next-hop capability, ignoring", peer->host, pkt_afi, pkt_safi, pkt_nh_afi); @@ -683,7 +683,7 @@ static int bgp_capability_hostname(struct peer *peer, len = stream_getc(s); if (stream_get_getp(s) + len > end) { flog_warn( - BGP_WARN_CAPABILITY_INVALID_DATA, + EC_BGP_CAPABILITY_INVALID_DATA, "%s: Received malformed hostname capability from peer %s", __FUNCTION__, peer->host); return -1; @@ -714,7 +714,7 @@ static int bgp_capability_hostname(struct peer *peer, if (stream_get_getp(s) + 1 > end) { flog_warn( - BGP_WARN_CAPABILITY_INVALID_DATA, + EC_BGP_CAPABILITY_INVALID_DATA, "%s: Received invalid domain name len (hostname capability) from peer %s", __FUNCTION__, peer->host); return -1; @@ -723,7 +723,7 @@ static int bgp_capability_hostname(struct peer *peer, len = stream_getc(s); if (stream_get_getp(s) + len > end) { flog_warn( - BGP_WARN_CAPABILITY_INVALID_DATA, + EC_BGP_CAPABILITY_INVALID_DATA, "%s: Received runt domain name (hostname capability) from peer %s", __FUNCTION__, peer->host); return -1; @@ -960,12 +960,12 @@ static int bgp_capability_parse(struct peer *peer, size_t length, specific capabilities. It seems reasonable for now... */ - flog_warn(BGP_WARN_CAPABILITY_VENDOR, + flog_warn(EC_BGP_CAPABILITY_VENDOR, "%s Vendor specific capability %d", peer->host, caphdr.code); } else { flog_warn( - BGP_WARN_CAPABILITY_UNKNOWN, + EC_BGP_CAPABILITY_UNKNOWN, "%s unrecognized capability code: %d - ignored", peer->host, caphdr.code); memcpy(*error, sp, caphdr.length + 2); @@ -981,7 +981,7 @@ static int bgp_capability_parse(struct peer *peer, size_t length, if (stream_get_getp(s) != (start + caphdr.length)) { if (stream_get_getp(s) > (start + caphdr.length)) flog_warn( - BGP_WARN_CAPABILITY_INVALID_LENGTH, + EC_BGP_CAPABILITY_INVALID_LENGTH, "%s Cap-parser for %s read past cap-length, %u!", peer->host, lookup_msg(capcode_str, caphdr.code, @@ -1197,10 +1197,10 @@ int bgp_open_option_parse(struct peer *peer, uint8_t length, int *mp_capability) && !peer->afc_nego[AFI_IP6][SAFI_ENCAP] && !peer->afc_nego[AFI_IP6][SAFI_FLOWSPEC] && !peer->afc_nego[AFI_L2VPN][SAFI_EVPN]) { - flog_err(BGP_ERR_PKT_OPEN, - "%s [Error] Configured AFI/SAFIs do not " - "overlap with received MP capabilities", - peer->host); + flog_err(EC_BGP_PKT_OPEN, + "%s [Error] Configured AFI/SAFIs do not " + "overlap with received MP capabilities", + peer->host); if (error != error_data) bgp_notify_send_with_data( diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index d8bab60414..96f3c8324f 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -1091,9 +1091,9 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size) /* Just in case we have a silly peer who sends AS4 capability set to 0 */ if (CHECK_FLAG(peer->cap, PEER_CAP_AS4_RCV) && !as4) { - flog_err(BGP_ERR_PKT_OPEN, - "%s bad OPEN, got AS4 capability, but AS4 set to 0", - peer->host); + flog_err(EC_BGP_PKT_OPEN, + "%s bad OPEN, got AS4 capability, but AS4 set to 0", + peer->host); bgp_notify_send_with_data(peer, BGP_NOTIFY_OPEN_ERR, BGP_NOTIFY_OPEN_BAD_PEER_AS, notify_data_remote_as4, 4); @@ -1107,7 +1107,7 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size) */ if (as4 == BGP_AS_TRANS) { flog_err( - BGP_ERR_PKT_OPEN, + EC_BGP_PKT_OPEN, "%s [AS4] NEW speaker using AS_TRANS for AS4, not allowed", peer->host); bgp_notify_send_with_data(peer, BGP_NOTIFY_OPEN_ERR, @@ -1137,7 +1137,7 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size) && as4 != remote_as) { /* raise error, log this, close session */ flog_err( - BGP_ERR_PKT_OPEN, + EC_BGP_PKT_OPEN, "%s bad OPEN, got AS4 capability, but remote_as %u" " mismatch with 16bit 'myasn' %u in open", peer->host, as4, remote_as); @@ -1304,7 +1304,7 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size) /* Get sockname. */ if ((ret = bgp_getsockname(peer)) < 0) { - flog_err_sys(LIB_ERR_SOCKET, + flog_err_sys(EC_LIB_SOCKET, "%s: bgp_getsockname() failed for peer: %s", __FUNCTION__, peer->host); return BGP_Stop; @@ -1320,7 +1320,7 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size) if (!peer->nexthop.v4.s_addr) { #if defined(HAVE_CUMULUS) flog_err( - BGP_ERR_SND_FAIL, + EC_BGP_SND_FAIL, "%s: No local IPv4 addr resetting connection, fd %d", peer->host, peer->fd); bgp_notify_send(peer, BGP_NOTIFY_CEASE, @@ -1337,7 +1337,7 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size) if (IN6_IS_ADDR_UNSPECIFIED(&peer->nexthop.v6_global)) { #if defined(HAVE_CUMULUS) flog_err( - BGP_ERR_SND_FAIL, + EC_BGP_SND_FAIL, "%s: No local IPv6 addr resetting connection, fd %d", peer->host, peer->fd); bgp_notify_send(peer, BGP_NOTIFY_CEASE, @@ -1399,10 +1399,10 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size) /* Status must be Established. */ if (peer->status != Established) { - flog_err(BGP_ERR_INVALID_STATUS, - "%s [FSM] Update packet received under status %s", - peer->host, - lookup_msg(bgp_status_msg, peer->status, NULL)); + flog_err(EC_BGP_INVALID_STATUS, + "%s [FSM] Update packet received under status %s", + peer->host, + lookup_msg(bgp_status_msg, peer->status, NULL)); bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR, 0); return BGP_Stop; } @@ -1423,10 +1423,10 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size) Attribute Length + 23 exceeds the message Length), then the Error Subcode is set to Malformed Attribute List. */ if (stream_pnt(s) + 2 > end) { - flog_err(BGP_ERR_UPDATE_RCV, - "%s [Error] Update packet error" - " (packet length is short for unfeasible length)", - peer->host); + flog_err(EC_BGP_UPDATE_RCV, + "%s [Error] Update packet error" + " (packet length is short for unfeasible length)", + peer->host); bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, BGP_NOTIFY_UPDATE_MAL_ATTR); return BGP_Stop; @@ -1437,10 +1437,10 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size) /* Unfeasible Route Length check. */ if (stream_pnt(s) + withdraw_len > end) { - flog_err(BGP_ERR_UPDATE_RCV, - "%s [Error] Update packet error" - " (packet unfeasible length overflow %d)", - peer->host, withdraw_len); + flog_err(EC_BGP_UPDATE_RCV, + "%s [Error] Update packet error" + " (packet unfeasible length overflow %d)", + peer->host, withdraw_len); bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, BGP_NOTIFY_UPDATE_MAL_ATTR); return BGP_Stop; @@ -1458,7 +1458,7 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size) /* Attribute total length check. */ if (stream_pnt(s) + 2 > end) { flog_warn( - BGP_WARN_UPDATE_PACKET_SHORT, + EC_BGP_UPDATE_PACKET_SHORT, "%s [Error] Packet Error (update packet is short for attribute length)", peer->host); bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, @@ -1472,7 +1472,7 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size) /* Attribute length check. */ if (stream_pnt(s) + attribute_len > end) { flog_warn( - BGP_WARN_UPDATE_PACKET_LONG, + EC_BGP_UPDATE_PACKET_LONG, "%s [Error] Packet Error (update packet attribute length overflow %d)", peer->host, attribute_len); bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR, @@ -1512,7 +1512,7 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size) if (attr_parse_ret == BGP_ATTR_PARSE_WITHDRAW) flog_err( - BGP_ERR_UPDATE_RCV, + EC_BGP_UPDATE_RCV, "%s rcvd UPDATE with errors in attr(s)!! Withdrawing route.", peer->host); @@ -1572,8 +1572,8 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size) } if (nlri_ret < 0) { - flog_err(BGP_ERR_UPDATE_RCV, - "%s [Error] Error parsing NLRI", peer->host); + flog_err(EC_BGP_UPDATE_RCV, + "%s [Error] Error parsing NLRI", peer->host); if (peer->status == Established) bgp_notify_send( peer, BGP_NOTIFY_UPDATE_ERR, @@ -1744,9 +1744,9 @@ static int bgp_route_refresh_receive(struct peer *peer, bgp_size_t size) /* If peer does not have the capability, send notification. */ if (!CHECK_FLAG(peer->cap, PEER_CAP_REFRESH_ADV)) { - flog_err(BGP_ERR_NO_CAP, - "%s [Error] BGP route refresh is not enabled", - peer->host); + flog_err(EC_BGP_NO_CAP, + "%s [Error] BGP route refresh is not enabled", + peer->host); bgp_notify_send(peer, BGP_NOTIFY_HEADER_ERR, BGP_NOTIFY_HEADER_BAD_MESTYPE); return BGP_Stop; @@ -1755,7 +1755,7 @@ static int bgp_route_refresh_receive(struct peer *peer, bgp_size_t size) /* Status must be Established. */ if (peer->status != Established) { flog_err( - BGP_ERR_INVALID_STATUS, + EC_BGP_INVALID_STATUS, "%s [Error] Route refresh packet received under status %s", peer->host, lookup_msg(bgp_status_msg, peer->status, NULL)); @@ -2105,7 +2105,7 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt, } } else { flog_warn( - BGP_WARN_UNRECOGNIZED_CAPABILITY, + EC_BGP_UNRECOGNIZED_CAPABILITY, "%s unrecognized capability code: %d - ignored", peer->host, hdr->code); } @@ -2136,9 +2136,9 @@ int bgp_capability_receive(struct peer *peer, bgp_size_t size) /* If peer does not have the capability, send notification. */ if (!CHECK_FLAG(peer->cap, PEER_CAP_DYNAMIC_ADV)) { - flog_err(BGP_ERR_NO_CAP, - "%s [Error] BGP dynamic capability is not enabled", - peer->host); + flog_err(EC_BGP_NO_CAP, + "%s [Error] BGP dynamic capability is not enabled", + peer->host); bgp_notify_send(peer, BGP_NOTIFY_HEADER_ERR, BGP_NOTIFY_HEADER_BAD_MESTYPE); return BGP_Stop; @@ -2147,7 +2147,7 @@ int bgp_capability_receive(struct peer *peer, bgp_size_t size) /* Status must be Established. */ if (peer->status != Established) { flog_err( - BGP_ERR_NO_CAP, + EC_BGP_NO_CAP, "%s [Error] Dynamic capability packet received under status %s", peer->host, lookup_msg(bgp_status_msg, peer->status, NULL)); @@ -2229,7 +2229,7 @@ int bgp_process_packet(struct thread *thread) mprc = bgp_open_receive(peer, size); if (mprc == BGP_Stop) flog_err( - BGP_ERR_PKT_OPEN, + EC_BGP_PKT_OPEN, "%s: BGP OPEN receipt failed for peer: %s", __FUNCTION__, peer->host); break; @@ -2240,7 +2240,7 @@ int bgp_process_packet(struct thread *thread) mprc = bgp_update_receive(peer, size); if (mprc == BGP_Stop) flog_err( - BGP_ERR_UPDATE_RCV, + EC_BGP_UPDATE_RCV, "%s: BGP UPDATE receipt failed for peer: %s", __FUNCTION__, peer->host); break; @@ -2250,7 +2250,7 @@ int bgp_process_packet(struct thread *thread) mprc = bgp_notify_receive(peer, size); if (mprc == BGP_Stop) flog_err( - BGP_ERR_NOTIFY_RCV, + EC_BGP_NOTIFY_RCV, "%s: BGP NOTIFY receipt failed for peer: %s", __FUNCTION__, peer->host); break; @@ -2261,7 +2261,7 @@ int bgp_process_packet(struct thread *thread) mprc = bgp_keepalive_receive(peer, size); if (mprc == BGP_Stop) flog_err( - BGP_ERR_KEEP_RCV, + EC_BGP_KEEP_RCV, "%s: BGP KEEPALIVE receipt failed for peer: %s", __FUNCTION__, peer->host); break; @@ -2272,7 +2272,7 @@ int bgp_process_packet(struct thread *thread) mprc = bgp_route_refresh_receive(peer, size); if (mprc == BGP_Stop) flog_err( - BGP_ERR_RFSH_RCV, + EC_BGP_RFSH_RCV, "%s: BGP ROUTEREFRESH receipt failed for peer: %s", __FUNCTION__, peer->host); break; @@ -2282,7 +2282,7 @@ int bgp_process_packet(struct thread *thread) mprc = bgp_capability_receive(peer, size); if (mprc == BGP_Stop) flog_err( - BGP_ERR_CAP_RCV, + EC_BGP_CAP_RCV, "%s: BGP CAPABILITY receipt failed for peer: %s", __FUNCTION__, peer->host); break; diff --git a/bgpd/bgp_pbr.c b/bgpd/bgp_pbr.c index b182fde1e2..552eb253ea 100644 --- a/bgpd/bgp_pbr.c +++ b/bgpd/bgp_pbr.c @@ -653,9 +653,10 @@ static int bgp_pbr_build_and_validate_entry(struct prefix *p, action_count++; if (action_count > ACTIONS_MAX_NUM) { if (BGP_DEBUG(pbr, PBR_ERROR)) - flog_err(BGP_ERR_FLOWSPEC_PACKET, - "%s: flowspec actions exceeds limit (max %u)", - __func__, action_count); + flog_err( + EC_BGP_FLOWSPEC_PACKET, + "%s: flowspec actions exceeds limit (max %u)", + __func__, action_count); break; } api_action = &api->actions[action_count - 1]; @@ -2251,17 +2252,16 @@ void bgp_pbr_update_entry(struct bgp *bgp, struct prefix *p, if (!bgp_zebra_tm_chunk_obtained()) { if (BGP_DEBUG(pbr, PBR_ERROR)) - flog_err(BGP_ERR_TABLE_CHUNK, - "%s: table chunk not obtained yet", - __func__); + flog_err(EC_BGP_TABLE_CHUNK, + "%s: table chunk not obtained yet", __func__); return; } if (bgp_pbr_build_and_validate_entry(p, info, &api) < 0) { if (BGP_DEBUG(pbr, PBR_ERROR)) - flog_err(BGP_ERR_FLOWSPEC_INSTALLATION, - "%s: cancel updating entry %p in bgp pbr", - __func__, info); + flog_err(EC_BGP_FLOWSPEC_INSTALLATION, + "%s: cancel updating entry %p in bgp pbr", + __func__, info); return; } bgp_pbr_handle_entry(bgp, info, &api, nlri_update); diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 4c2df0dd0a..5c65d5e615 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -355,7 +355,7 @@ static void bgp_pcount_adjust(struct bgp_node *rn, struct bgp_info *ri) if (ri->peer->pcount[table->afi][table->safi]) ri->peer->pcount[table->afi][table->safi]--; else - flog_err(LIB_ERR_DEVELOPMENT, + flog_err(EC_LIB_DEVELOPMENT, "Asked to decrement 0 prefix count for peer"); } else if (BGP_INFO_COUNTABLE(ri) && !CHECK_FLAG(ri->flags, BGP_INFO_COUNTED)) { @@ -4216,7 +4216,7 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr, /* Prefix length check. */ if (p.prefixlen > prefix_blen(&p) * 8) { flog_err( - BGP_ERR_UPDATE_RCV, + EC_BGP_UPDATE_RCV, "%s [Error] Update packet error (wrong prefix length %d for afi %u)", peer->host, p.prefixlen, packet->afi); return -1; @@ -4228,7 +4228,7 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr, /* When packet overflow occur return immediately. */ if (pnt + psize > lim) { flog_err( - BGP_ERR_UPDATE_RCV, + EC_BGP_UPDATE_RCV, "%s [Error] Update packet error (prefix length %d overflows packet)", peer->host, p.prefixlen); return -1; @@ -4238,7 +4238,7 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr, * prefix */ if (psize > (ssize_t)sizeof(p.u)) { flog_err( - BGP_ERR_UPDATE_RCV, + EC_BGP_UPDATE_RCV, "%s [Error] Update packet error (prefix length %d too large for prefix storage %zu)", peer->host, p.prefixlen, sizeof(p.u)); return -1; @@ -4260,7 +4260,7 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr, * ignored. */ flog_err( - BGP_ERR_UPDATE_RCV, + EC_BGP_UPDATE_RCV, "%s: IPv4 unicast NLRI is multicast address %s, ignoring", peer->host, inet_ntoa(p.u.prefix4)); continue; @@ -4273,7 +4273,7 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr, char buf[BUFSIZ]; flog_err( - BGP_ERR_UPDATE_RCV, + EC_BGP_UPDATE_RCV, "%s: IPv6 unicast NLRI is link-local address %s, ignoring", peer->host, inet_ntop(AF_INET6, &p.u.prefix6, buf, @@ -4285,7 +4285,7 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr, char buf[BUFSIZ]; flog_err( - BGP_ERR_UPDATE_RCV, + EC_BGP_UPDATE_RCV, "%s: IPv6 unicast NLRI is multicast address %s, ignoring", peer->host, inet_ntop(AF_INET6, &p.u.prefix6, buf, @@ -4315,7 +4315,7 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr, /* Packet length consistency check. */ if (pnt != lim) { flog_err( - BGP_ERR_UPDATE_RCV, + EC_BGP_UPDATE_RCV, "%s [Error] Update packet error (prefix length mismatch with total length)", peer->host); return -1; @@ -9890,12 +9890,14 @@ static int bgp_peer_count_walker(struct thread *t) if (CHECK_FLAG(ri->flags, BGP_INFO_COUNTED)) { pc->count[PCOUNT_COUNTED]++; if (CHECK_FLAG(ri->flags, BGP_INFO_UNUSEABLE)) - flog_err(LIB_ERR_DEVELOPMENT, - "Attempting to count but flags say it is unusable"); + flog_err( + EC_LIB_DEVELOPMENT, + "Attempting to count but flags say it is unusable"); } else { if (!CHECK_FLAG(ri->flags, BGP_INFO_UNUSEABLE)) - flog_err(LIB_ERR_DEVELOPMENT, - "Not counted but flags say we should"); + flog_err( + EC_LIB_DEVELOPMENT, + "Not counted but flags say we should"); } } } diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c index 37740671ca..7f7b4a893f 100644 --- a/bgpd/bgp_updgrp.c +++ b/bgpd/bgp_updgrp.c @@ -1631,9 +1631,9 @@ void update_group_adjust_peer(struct peer_af *paf) if (!updgrp) { updgrp = update_group_create(paf); if (!updgrp) { - flog_err(BGP_ERR_UPDGRP_CREATE, - "couldn't create update group for peer %s", - paf->peer->host); + flog_err(EC_BGP_UPDGRP_CREATE, + "couldn't create update group for peer %s", + paf->peer->host); return; } } diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c index f3047369bc..56a82c801c 100644 --- a/bgpd/bgp_updgrp_packet.c +++ b/bgpd/bgp_updgrp_packet.c @@ -428,7 +428,7 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt, default: /* TODO: handle IPv6 nexthops */ flog_warn( - BGP_WARN_INVALID_NEXTHOP_LENGTH, + EC_BGP_INVALID_NEXTHOP_LENGTH, "%s: %s: invalid MP nexthop length (AFI IP): %u", __func__, peer->host, nhlen); stream_free(s); @@ -534,7 +534,7 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt, default: /* TODO: handle IPv4 nexthops */ flog_warn( - BGP_WARN_INVALID_NEXTHOP_LENGTH, + EC_BGP_INVALID_NEXTHOP_LENGTH, "%s: %s: invalid MP nexthop length (AFI IP6): %u", __func__, peer->host, nhlen); stream_free(s); @@ -790,7 +790,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp) * return */ if (space_remaining < space_needed) { flog_err( - BGP_ERR_UPDGRP_ATTR_LEN, + EC_BGP_UPDGRP_ATTR_LEN, "u%" PRIu64 ":s%" PRIu64 " attributes too long, cannot send UPDATE", subgrp->update_group->id, subgrp->id); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 3669ea7736..e6d44c1a2c 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -7367,7 +7367,7 @@ DEFUN (show_bgp_vrfs, for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { const char *name, *type; struct peer *peer; - struct listnode *node, *nnode; + struct listnode *node2, *nnode2; int peers_cfg, peers_estb; json_object *json_vrf = NULL; @@ -7387,7 +7387,7 @@ DEFUN (show_bgp_vrfs, json_vrf = json_object_new_object(); - for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { + for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) continue; peers_cfg++; @@ -10822,7 +10822,7 @@ static void bgp_show_all_instances_neighbors_vty(struct vty *vty, if (use_json) { if (!(json = json_object_new_object())) { flog_err( - BGP_ERR_JSON_MEM_ERROR, + EC_BGP_JSON_MEM_ERROR, "Unable to allocate memory for JSON object"); vty_out(vty, "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 43afc317e9..deed8788e6 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -287,6 +287,7 @@ static int bgp_interface_down(int command, struct zclient *zclient, struct nbr_connected *nc; struct listnode *node, *nnode; struct bgp *bgp; + struct peer *peer; bgp = bgp_lookup_by_vrf_id(vrf_id); if (!bgp) @@ -307,11 +308,7 @@ static int bgp_interface_down(int command, struct zclient *zclient, bgp_nbr_connected_delete(bgp, nc, 1); /* Fast external-failover */ - { - struct peer *peer; - - if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) - return 0; + if (!CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) { for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { #if defined(HAVE_CUMULUS) @@ -474,6 +471,7 @@ static int bgp_interface_vrf_update(int command, struct zclient *zclient, struct nbr_connected *nc; struct listnode *node, *nnode; struct bgp *bgp; + struct peer *peer; ifp = zebra_interface_vrf_update_read(zclient->ibuf, vrf_id, &new_vrf_id); @@ -495,12 +493,7 @@ static int bgp_interface_vrf_update(int command, struct zclient *zclient, bgp_nbr_connected_delete(bgp, nc, 1); /* Fast external-failover */ - { - struct peer *peer; - - if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) - return 0; - + if (!CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) { for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { if ((peer->ttl != 1) && (peer->gtsm_hops != 1)) continue; @@ -777,8 +770,9 @@ static int if_get_ipv4_address(struct interface *ifp, struct in_addr *addr) return 0; } -int bgp_nexthop_set(union sockunion *local, union sockunion *remote, - struct bgp_nexthop *nexthop, struct peer *peer) + +bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote, + struct bgp_nexthop *nexthop, struct peer *peer) { int ret = 0; struct interface *ifp = NULL; @@ -786,9 +780,9 @@ int bgp_nexthop_set(union sockunion *local, union sockunion *remote, memset(nexthop, 0, sizeof(struct bgp_nexthop)); if (!local) - return -1; + return false; if (!remote) - return -1; + return false; if (local->sa.sa_family == AF_INET) { nexthop->v4 = local->sin.sin_addr; @@ -815,8 +809,24 @@ int bgp_nexthop_set(union sockunion *local, union sockunion *remote, peer->bgp->vrf_id); } - if (!ifp) - return -1; + if (!ifp) { + /* + * BGP views do not currently get proper data + * from zebra( when attached ) to be able to + * properly resolve nexthops, so give this + * instance type a pass. + */ + if (peer->bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) + return true; + /* + * If we have no interface data but we have established + * some connection w/ zebra than something has gone + * terribly terribly wrong here, so say this failed + * If we do not any zebra connection then not + * having a ifp pointer is ok. + */ + return zclient_num_connects ? false : true; + } nexthop->ifp = ifp; @@ -912,7 +922,7 @@ int bgp_nexthop_set(union sockunion *local, union sockunion *remote, /* If we have identified the local interface, there is no error for now. */ - return 0; + return true; } static struct in6_addr *bgp_info_to_ipv6_nexthop(struct bgp_info *info, @@ -1078,8 +1088,8 @@ int bgp_zebra_get_table_range(uint32_t chunk_size, return -1; ret = tm_get_table_chunk(zclient, chunk_size, start, end); if (ret < 0) { - flog_err(BGP_ERR_TABLE_CHUNK, - "BGP: Error getting table chunk %u", chunk_size); + flog_err(EC_BGP_TABLE_CHUNK, + "BGP: Error getting table chunk %u", chunk_size); return -1; } zlog_info("BGP: Table Manager returns range from chunk %u is [%u %u]", @@ -2390,10 +2400,10 @@ static int bgp_zebra_process_local_macip(int command, struct zclient *zclient, ipa_len = stream_getl(s); if (ipa_len != 0 && ipa_len != IPV4_MAX_BYTELEN && ipa_len != IPV6_MAX_BYTELEN) { - flog_err(BGP_ERR_MACIP_LEN, - "%u:Recv MACIP %s with invalid IP addr length %d", - vrf_id, (command == ZEBRA_MACIP_ADD) ? "Add" : "Del", - ipa_len); + flog_err(EC_BGP_MACIP_LEN, + "%u:Recv MACIP %s with invalid IP addr length %d", + vrf_id, (command == ZEBRA_MACIP_ADD) ? "Add" : "Del", + ipa_len); return -1; } @@ -2487,13 +2497,13 @@ static void bgp_zebra_process_label_chunk( STREAM_GETL(s, last); if (zclient->redist_default != proto) { - flog_err(BGP_ERR_LM_ERROR, "Got LM msg with wrong proto %u", - proto); + flog_err(EC_BGP_LM_ERROR, "Got LM msg with wrong proto %u", + proto); return; } if (zclient->instance != instance) { - flog_err(BGP_ERR_LM_ERROR, "Got LM msg with wrong instance %u", - proto); + flog_err(EC_BGP_LM_ERROR, "Got LM msg with wrong instance %u", + proto); return; } @@ -2501,8 +2511,8 @@ static void bgp_zebra_process_label_chunk( first < MPLS_LABEL_UNRESERVED_MIN || last > MPLS_LABEL_UNRESERVED_MAX) { - flog_err(BGP_ERR_LM_ERROR, "%s: Invalid Label chunk: %u - %u", - __func__, first, last); + flog_err(EC_BGP_LM_ERROR, "%s: Invalid Label chunk: %u - %u", + __func__, first, last); return; } if (BGP_DEBUG(zebra, ZEBRA)) { diff --git a/bgpd/bgp_zebra.h b/bgpd/bgp_zebra.h index 546d72402a..c00d9925ee 100644 --- a/bgpd/bgp_zebra.h +++ b/bgpd/bgp_zebra.h @@ -73,6 +73,9 @@ extern int bgp_zebra_advertise_all_vni(struct bgp *, int); extern int bgp_zebra_num_connects(void); +extern bool bgp_zebra_nexthop_set(union sockunion *, union sockunion *, + struct bgp_nexthop *, struct peer *); + struct bgp_pbr_action; struct bgp_pbr_match; struct bgp_pbr_match_entry; diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 066db1c774..7df8de55f0 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -1804,8 +1804,8 @@ static int peer_activate_af(struct peer *peer, afi_t afi, safi_t safi) int active; if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { - flog_err(BGP_ERR_PEER_GROUP, "%s was called for peer-group %s", - __func__, peer->host); + flog_err(EC_BGP_PEER_GROUP, "%s was called for peer-group %s", + __func__, peer->host); return 1; } @@ -1918,8 +1918,8 @@ static int non_peergroup_deactivate_af(struct peer *peer, afi_t afi, safi_t safi) { if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { - flog_err(BGP_ERR_PEER_GROUP, "%s was called for peer-group %s", - __func__, peer->host); + flog_err(EC_BGP_PEER_GROUP, "%s was called for peer-group %s", + __func__, peer->host); return 1; } @@ -1931,9 +1931,9 @@ static int non_peergroup_deactivate_af(struct peer *peer, afi_t afi, peer->afc[afi][safi] = 0; if (peer_af_delete(peer, afi, safi) != 0) { - flog_err(BGP_ERR_PEER_DELETE, - "couldn't delete af structure for peer %s", - peer->host); + flog_err(EC_BGP_PEER_DELETE, + "couldn't delete af structure for peer %s", + peer->host); return 1; } @@ -1982,9 +1982,9 @@ int peer_deactivate(struct peer *peer, afi_t afi, safi_t safi) group = peer->group; if (peer_af_delete(peer, afi, safi) != 0) { - flog_err(BGP_ERR_PEER_DELETE, - "couldn't delete af structure for peer %s", - peer->host); + flog_err(EC_BGP_PEER_DELETE, + "couldn't delete af structure for peer %s", + peer->host); } for (ALL_LIST_ELEMENTS(group->peer, node, nnode, tmp_peer)) { diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 8a99741390..0a8962b4c7 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -1470,8 +1470,6 @@ extern void bgp_terminate(void); extern void bgp_reset(void); extern time_t bgp_clock(void); extern void bgp_zclient_reset(void); -extern int bgp_nexthop_set(union sockunion *, union sockunion *, - struct bgp_nexthop *, struct peer *); extern struct bgp *bgp_get_default(void); extern struct bgp *bgp_lookup(as_t, const char *); extern struct bgp *bgp_lookup_by_name(const char *); diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c index f1dd08fda0..15e3974248 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.c +++ b/bgpd/rfapi/bgp_rfapi_cfg.c @@ -4015,21 +4015,21 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp) vty_out(vty, "!\n"); if (hc->l2_groups) { - struct rfapi_l2_group_cfg *rfg = NULL; + struct rfapi_l2_group_cfg *rfgc = NULL; struct listnode *gnode; - for (ALL_LIST_ELEMENTS_RO(hc->l2_groups, gnode, rfg)) { + for (ALL_LIST_ELEMENTS_RO(hc->l2_groups, gnode, rfgc)) { struct listnode *lnode; void *data; ++write; - vty_out(vty, " vnc l2-group %s\n", rfg->name); - if (rfg->logical_net_id != 0) + vty_out(vty, " vnc l2-group %s\n", rfgc->name); + if (rfgc->logical_net_id != 0) vty_out(vty, " logical-network-id %u\n", - rfg->logical_net_id); - if (rfg->labels != NULL - && listhead(rfg->labels) != NULL) { + rfgc->logical_net_id); + if (rfgc->labels != NULL + && listhead(rfgc->labels) != NULL) { vty_out(vty, " labels "); - for (ALL_LIST_ELEMENTS_RO(rfg->labels, + for (ALL_LIST_ELEMENTS_RO(rfgc->labels, lnode, data)) { vty_out(vty, "%hu ", @@ -4040,28 +4040,28 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp) vty_out(vty, "\n"); } - if (rfg->rt_import_list && rfg->rt_export_list - && ecommunity_cmp(rfg->rt_import_list, - rfg->rt_export_list)) { + if (rfgc->rt_import_list && rfgc->rt_export_list + && ecommunity_cmp(rfgc->rt_import_list, + rfgc->rt_export_list)) { char *b = ecommunity_ecom2str( - rfg->rt_import_list, + rfgc->rt_import_list, ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); vty_out(vty, " rt both %s\n", b); XFREE(MTYPE_ECOMMUNITY_STR, b); } else { - if (rfg->rt_import_list) { + if (rfgc->rt_import_list) { char *b = ecommunity_ecom2str( - rfg->rt_import_list, + rfgc->rt_import_list, ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); vty_out(vty, " rt import %s\n", b); XFREE(MTYPE_ECOMMUNITY_STR, b); } - if (rfg->rt_export_list) { + if (rfgc->rt_export_list) { char *b = ecommunity_ecom2str( - rfg->rt_export_list, + rfgc->rt_export_list, ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); vty_out(vty, " rt export %s\n", @@ -4074,7 +4074,7 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp) .cfg_group_cb)( vty, bgp->rfapi->rfp, RFAPI_RFP_CFG_GROUP_L2, - rfg->name, rfg->rfp_cfg); + rfgc->name, rfgc->rfp_cfg); vty_out(vty, " exit-vnc\n"); vty_out(vty, "!\n"); } diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index 18c3c63855..16dcbd4ee7 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -3942,8 +3942,8 @@ void *rfapi_rfp_init_group_config_ptr_vty(void *rfp_start_val, size); break; default: - flog_err(LIB_ERR_DEVELOPMENT, "%s: Unknown group type=%d", - __func__, type); + flog_err(EC_LIB_DEVELOPMENT, "%s: Unknown group type=%d", + __func__, type); /* should never happen */ assert("Unknown type" == NULL); break; @@ -4057,8 +4057,8 @@ void *rfapi_rfp_get_group_config_ptr_name( criteria, search_cb); break; default: - flog_err(LIB_ERR_DEVELOPMENT, "%s: Unknown group type=%d", - __func__, type); + flog_err(EC_LIB_DEVELOPMENT, "%s: Unknown group type=%d", + __func__, type); /* should never happen */ assert("Unknown type" == NULL); break; diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index f014f16fc2..398de6b3a1 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -3033,7 +3033,7 @@ static void rfapiBgpInfoFilteredImportEncap( break; default: - flog_err(LIB_ERR_DEVELOPMENT, "%s: bad afi %d", __func__, afi); + flog_err(EC_LIB_DEVELOPMENT, "%s: bad afi %d", __func__, afi); return; } @@ -3492,7 +3492,7 @@ void rfapiBgpInfoFilteredImportVPN( break; default: - flog_err(LIB_ERR_DEVELOPMENT, "%s: bad afi %d", __func__, afi); + flog_err(EC_LIB_DEVELOPMENT, "%s: bad afi %d", __func__, afi); return; } @@ -3897,8 +3897,7 @@ rfapiBgpInfoFilteredImportFunction(safi_t safi) default: /* not expected */ - flog_err(LIB_ERR_DEVELOPMENT, "%s: bad safi %d", __func__, - safi); + flog_err(EC_LIB_DEVELOPMENT, "%s: bad safi %d", __func__, safi); return rfapiBgpInfoFilteredImportBadSafi; } } diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index 9f8270097a..1dc2d02f15 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -2004,7 +2004,8 @@ register_add(struct vty *vty, struct cmd_token *carg_prefix, "Missing parameter for local-next-hop\n"); return CMD_WARNING_CONFIG_FAILED; } - ++argv, --argc; + ++argv; + --argc; arg_lnh = argv[0]->arg; } if (strmatch(argv[0]->text, "local-cost")) { @@ -2018,7 +2019,8 @@ register_add(struct vty *vty, struct cmd_token *carg_prefix, "Missing parameter for local-cost\n"); return CMD_WARNING_CONFIG_FAILED; } - ++argv, --argc; + ++argv; + --argc; arg_lnh_cost = argv[0]->arg; } } diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c index 6289175645..f830c3ed52 100644 --- a/bgpd/rfapi/vnc_export_bgp.c +++ b/bgpd/rfapi/vnc_export_bgp.c @@ -188,8 +188,8 @@ void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct agg_node *rn, if (!afi) { - flog_err(LIB_ERR_DEVELOPMENT, - "%s: can't get afi of route node", __func__); + flog_err(EC_LIB_DEVELOPMENT, "%s: can't get afi of route node", + __func__); return; } @@ -335,7 +335,7 @@ void vnc_direct_bgp_del_route_ce(struct bgp *bgp, struct agg_node *rn, struct prefix ce_nexthop; if (!afi) { - flog_err(LIB_ERR_DEVELOPMENT, "%s: bad afi", __func__); + flog_err(EC_LIB_DEVELOPMENT, "%s: bad afi", __func__); return; } @@ -700,8 +700,8 @@ void vnc_direct_bgp_add_prefix(struct bgp *bgp, afi_t afi = family2afi(rn->p.family); if (!afi) { - flog_err(LIB_ERR_DEVELOPMENT, - "%s: can't get afi of route node", __func__); + flog_err(EC_LIB_DEVELOPMENT, "%s: can't get afi of route node", + __func__); return; } @@ -810,8 +810,8 @@ void vnc_direct_bgp_del_prefix(struct bgp *bgp, afi_t afi = family2afi(rn->p.family); if (!afi) { - flog_err(LIB_ERR_DEVELOPMENT, "%s: can't get afi route node", - __func__); + flog_err(EC_LIB_DEVELOPMENT, "%s: can't get afi route node", + __func__); return; } @@ -926,8 +926,8 @@ void vnc_direct_bgp_add_nve(struct bgp *bgp, struct rfapi_descriptor *rfd) afi_t afi = family2afi(rfd->vn_addr.addr_family); if (!afi) { - flog_err(LIB_ERR_DEVELOPMENT, - "%s: can't get afi of nve vn addr", __func__); + flog_err(EC_LIB_DEVELOPMENT, "%s: can't get afi of nve vn addr", + __func__); return; } @@ -979,8 +979,8 @@ void vnc_direct_bgp_add_nve(struct bgp *bgp, struct rfapi_descriptor *rfd) if (afi == AFI_IP || afi == AFI_IP6) { rt = import_table->imported_vpn[afi]; } else { - flog_err(LIB_ERR_DEVELOPMENT, "%s: bad afi %d", - __func__, afi); + flog_err(EC_LIB_DEVELOPMENT, "%s: bad afi %d", + __func__, afi); return; } @@ -1073,8 +1073,8 @@ void vnc_direct_bgp_del_nve(struct bgp *bgp, struct rfapi_descriptor *rfd) afi_t afi = family2afi(rfd->vn_addr.addr_family); if (!afi) { - flog_err(LIB_ERR_DEVELOPMENT, - "%s: can't get afi of nve vn addr", __func__); + flog_err(EC_LIB_DEVELOPMENT, "%s: can't get afi of nve vn addr", + __func__); return; } @@ -1121,8 +1121,8 @@ void vnc_direct_bgp_del_nve(struct bgp *bgp, struct rfapi_descriptor *rfd) if (afi == AFI_IP || afi == AFI_IP6) { rt = import_table->imported_vpn[afi]; } else { - flog_err(LIB_ERR_DEVELOPMENT, "%s: bad afi %d", - __func__, afi); + flog_err(EC_LIB_DEVELOPMENT, "%s: bad afi %d", + __func__, afi); return; } @@ -1298,7 +1298,7 @@ static void vnc_direct_bgp_add_group_afi(struct bgp *bgp, if (afi == AFI_IP || afi == AFI_IP6) { rt = import_table->imported_vpn[afi]; } else { - flog_err(LIB_ERR_DEVELOPMENT, "%s: bad afi %d", __func__, afi); + flog_err(EC_LIB_DEVELOPMENT, "%s: bad afi %d", __func__, afi); return; } @@ -1642,8 +1642,8 @@ void vnc_direct_bgp_rh_add_route(struct bgp *bgp, afi_t afi, struct attr *iattr; if (!afi) { - flog_err(LIB_ERR_DEVELOPMENT, - "%s: can't get afi of route node", __func__); + flog_err(EC_LIB_DEVELOPMENT, "%s: can't get afi of route node", + __func__); return; } @@ -1762,8 +1762,8 @@ void vnc_direct_bgp_rh_del_route(struct bgp *bgp, afi_t afi, struct vnc_export_info *eti; if (!afi) { - flog_err(LIB_ERR_DEVELOPMENT, "%s: can't get afi route node", - __func__); + flog_err(EC_LIB_DEVELOPMENT, "%s: can't get afi route node", + __func__); return; } diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c index dc37ff89b5..71a4485d39 100644 --- a/bgpd/rfapi/vnc_import_bgp.c +++ b/bgpd/rfapi/vnc_import_bgp.c @@ -603,8 +603,8 @@ static void vnc_import_bgp_add_route_mode_resolve_nve( */ if (!afi) { - flog_err(LIB_ERR_DEVELOPMENT, "%s: can't get afi of prefix", - __func__); + flog_err(EC_LIB_DEVELOPMENT, "%s: can't get afi of prefix", + __func__); return; } @@ -720,8 +720,8 @@ static void vnc_import_bgp_add_route_mode_plain(struct bgp *bgp, } if (!afi) { - flog_err(LIB_ERR_DEVELOPMENT, "%s: can't get afi of prefix", - __func__); + flog_err(EC_LIB_DEVELOPMENT, "%s: can't get afi of prefix", + __func__); return; } @@ -908,8 +908,8 @@ vnc_import_bgp_add_route_mode_nvegroup(struct bgp *bgp, struct prefix *prefix, assert(rfg); if (!afi) { - flog_err(LIB_ERR_DEVELOPMENT, "%s: can't get afi of prefix", - __func__); + flog_err(EC_LIB_DEVELOPMENT, "%s: can't get afi of prefix", + __func__); return; } @@ -2398,11 +2398,11 @@ void vnc_import_bgp_exterior_add_route_interior( } if (list_adopted) { struct listnode *node; - struct agg_node *bi_exterior; + struct agg_node *an_bi_exterior; - for (ALL_LIST_ELEMENTS_RO(list_adopted, node, bi_exterior)) { + for (ALL_LIST_ELEMENTS_RO(list_adopted, node, an_bi_exterior)) { skiplist_delete(it->monitor_exterior_orphans, - bi_exterior, NULL); + an_bi_exterior, NULL); } list_delete_and_null(&list_adopted); } @@ -2634,8 +2634,8 @@ void vnc_import_bgp_add_route(struct bgp *bgp, struct prefix *prefix, VNC_RHNCK(enter); if (!afi) { - flog_err(LIB_ERR_DEVELOPMENT, "%s: can't get afi of prefix", - __func__); + flog_err(EC_LIB_DEVELOPMENT, "%s: can't get afi of prefix", + __func__); return; } diff --git a/bgpd/rfapi/vnc_zebra.c b/bgpd/rfapi/vnc_zebra.c index a93fb60735..1db1755368 100644 --- a/bgpd/rfapi/vnc_zebra.c +++ b/bgpd/rfapi/vnc_zebra.c @@ -571,8 +571,8 @@ static void vnc_zebra_add_del_prefix(struct bgp *bgp, return; if (rn->p.family != AF_INET && rn->p.family != AF_INET6) { - flog_err(LIB_ERR_DEVELOPMENT, - "%s: invalid route node addr family", __func__); + flog_err(EC_LIB_DEVELOPMENT, + "%s: invalid route node addr family", __func__); return; } @@ -644,8 +644,8 @@ static void vnc_zebra_add_del_nve(struct bgp *bgp, struct rfapi_descriptor *rfd, return; if (afi != AFI_IP && afi != AFI_IP6) { - flog_err(LIB_ERR_DEVELOPMENT, "%s: invalid vn addr family", - __func__); + flog_err(EC_LIB_DEVELOPMENT, "%s: invalid vn addr family", + __func__); return; } @@ -743,13 +743,13 @@ static void vnc_zebra_add_del_group_afi(struct bgp *bgp, if (afi == AFI_IP || afi == AFI_IP6) { rt = import_table->imported_vpn[afi]; } else { - flog_err(LIB_ERR_DEVELOPMENT, "%s: bad afi %d", __func__, afi); + flog_err(EC_LIB_DEVELOPMENT, "%s: bad afi %d", __func__, afi); return; } if (!family) { - flog_err(LIB_ERR_DEVELOPMENT, "%s: computed bad family: %d", - __func__, family); + flog_err(EC_LIB_DEVELOPMENT, "%s: computed bad family: %d", + __func__, family); return; } |
