diff options
author | David Lamparter <equinox@diac24.net> | 2018-08-16 16:39:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-16 16:39:40 +0200 |
commit | 55d3dad27cad9e38c9bb9f70248661a06052c83a (patch) | |
tree | e8e0fbac5155e5e50eee628f2c75f4ed074acb62 /bgpd | |
parent | Merge pull request #2845 from donaldsharp/cmsg_foolishness (diff) | |
parent | *: frr_elevate_privs whitespace fixes (diff) | |
download | frr-55d3dad27cad9e38c9bb9f70248661a06052c83a.tar.xz frr-55d3dad27cad9e38c9bb9f70248661a06052c83a.zip |
Merge pull request #2448 from qlyoung/error-reference-cards
Error Reference Cards
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/Makefile.am | 4 | ||||
-rw-r--r-- | bgpd/bgp_attr.c | 128 | ||||
-rw-r--r-- | bgpd/bgp_errors.c | 306 | ||||
-rw-r--r-- | bgpd/bgp_errors.h | 79 | ||||
-rw-r--r-- | bgpd/bgp_evpn.c | 184 | ||||
-rw-r--r-- | bgpd/bgp_evpn_vty.c | 4 | ||||
-rw-r--r-- | bgpd/bgp_flowspec.c | 23 | ||||
-rw-r--r-- | bgpd/bgp_flowspec_util.c | 25 | ||||
-rw-r--r-- | bgpd/bgp_fsm.c | 54 | ||||
-rw-r--r-- | bgpd/bgp_io.c | 6 | ||||
-rw-r--r-- | bgpd/bgp_label.c | 24 | ||||
-rw-r--r-- | bgpd/bgp_labelpool.c | 14 | ||||
-rw-r--r-- | bgpd/bgp_main.c | 6 | ||||
-rw-r--r-- | bgpd/bgp_mplsvpn.c | 25 | ||||
-rw-r--r-- | bgpd/bgp_network.c | 170 | ||||
-rw-r--r-- | bgpd/bgp_nht.c | 4 | ||||
-rw-r--r-- | bgpd/bgp_open.c | 14 | ||||
-rw-r--r-- | bgpd/bgp_packet.c | 87 | ||||
-rw-r--r-- | bgpd/bgp_pbr.c | 16 | ||||
-rw-r--r-- | bgpd/bgp_route.c | 24 | ||||
-rw-r--r-- | bgpd/bgp_updgrp.c | 6 | ||||
-rw-r--r-- | bgpd/bgp_updgrp_packet.c | 4 | ||||
-rw-r--r-- | bgpd/bgp_vty.c | 4 | ||||
-rw-r--r-- | bgpd/bgp_zebra.c | 21 | ||||
-rw-r--r-- | bgpd/bgpd.c | 25 | ||||
-rw-r--r-- | bgpd/rfapi/rfapi.c | 7 | ||||
-rw-r--r-- | bgpd/rfapi/rfapi_import.c | 8 | ||||
-rw-r--r-- | bgpd/rfapi/vnc_export_bgp.c | 32 | ||||
-rw-r--r-- | bgpd/rfapi/vnc_import_bgp.c | 13 | ||||
-rw-r--r-- | bgpd/rfapi/vnc_zebra.c | 12 |
30 files changed, 953 insertions, 376 deletions
diff --git a/bgpd/Makefile.am b/bgpd/Makefile.am index 2f19bbbd7..b6b125f75 100644 --- a/bgpd/Makefile.am +++ b/bgpd/Makefile.am @@ -85,7 +85,7 @@ libbgp_a_SOURCES = \ bgp_encap_tlv.c $(BGP_VNC_RFAPI_SRC) bgp_attr_evpn.c \ bgp_evpn.c bgp_evpn_vty.c bgp_vpn.c bgp_label.c bgp_rd.c \ bgp_keepalives.c bgp_io.c bgp_flowspec.c bgp_flowspec_util.c \ - bgp_flowspec_vty.c bgp_labelpool.c bgp_pbr.c + bgp_flowspec_vty.c bgp_labelpool.c bgp_pbr.c bgp_errors.c noinst_HEADERS = \ bgp_memory.h \ @@ -99,7 +99,7 @@ noinst_HEADERS = \ $(BGP_VNC_RFAPI_HD) bgp_attr_evpn.h bgp_evpn.h bgp_evpn_vty.h \ bgp_vpn.h bgp_label.h bgp_rd.h bgp_evpn_private.h bgp_keepalives.h \ bgp_io.h bgp_flowspec.h bgp_flowspec_private.h bgp_flowspec_util.h \ - bgp_labelpool.h bgp_pbr.h + bgp_labelpool.h bgp_pbr.h bgp_errors.h bgpd_SOURCES = bgp_main.c bgpd_LDADD = libbgp.a $(BGP_VNC_RFP_LIB) ../lib/libfrr.la @LIBCAP@ @LIBM@ diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index e5ad5e233..6acd4c8cf 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -39,6 +39,7 @@ #include "bgpd/bgp_aspath.h" #include "bgpd/bgp_community.h" #include "bgpd/bgp_debug.h" +#include "bgpd/bgp_errors.h" #include "bgpd/bgp_label.h" #include "bgpd/bgp_packet.h" #include "bgpd/bgp_ecommunity.h" @@ -996,12 +997,14 @@ 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)) { - zlog_err("%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( + 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); seen = 1; } if (!seen) { @@ -1059,7 +1062,8 @@ 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)) { - zlog_err( + flog_err( + BGP_ERR_ATTR_FLAG, "%s well-known attributes must have transitive flag set (%x)", lookup_msg(attr_str, attr_code, NULL), flags); return 1; @@ -1071,18 +1075,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)) { - zlog_err( - "%s well-known attribute " - "must NOT have the partial flag set (%x)", - lookup_msg(attr_str, attr_code, NULL), flags); + 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); return 1; } if (CHECK_FLAG(flags, BGP_ATTR_FLAG_OPTIONAL) && !CHECK_FLAG(flags, BGP_ATTR_FLAG_TRANS)) { - zlog_err( - "%s optional + transitive attribute " - "must NOT have the partial flag set (%x)", - lookup_msg(attr_str, attr_code, NULL), flags); + 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); return 1; } } @@ -1114,7 +1118,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) { - zlog_err("Origin attribute length is not one %d", length); + flog_err(BGP_ERR_ATTR_LEN, + "Origin attribute length is not one %d", length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); } @@ -1127,7 +1132,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)) { - zlog_err("Origin attribute value is invalid %d", attr->origin); + flog_err(BGP_ERR_ATTR_ORIGIN, + "Origin attribute value is invalid %d", attr->origin); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_INVAL_ORIGIN, args->total); } @@ -1155,8 +1161,9 @@ static int bgp_attr_aspath(struct bgp_attr_parser_args *args) /* In case of IBGP, length will be zero. */ if (!attr->aspath) { - zlog_err("Malformed AS path from %s, length is %d", peer->host, - length); + flog_err(BGP_ERR_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); } @@ -1184,7 +1191,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))) { - zlog_err("Malformed AS path from %s", peer->host); + flog_err(BGP_ERR_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; @@ -1194,8 +1202,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)) { - zlog_err("%s incorrect first AS (must be %u)", - peer->host, peer->as); + flog_err(BGP_ERR_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; @@ -1227,8 +1236,9 @@ static int bgp_attr_as4_path(struct bgp_attr_parser_args *args, /* In case of IBGP, length will be zero. */ if (!*as4_path) { - zlog_err("Malformed AS4 path from %s, length is %d", peer->host, - length); + flog_err(BGP_ERR_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); } @@ -1250,7 +1260,8 @@ static bgp_attr_parse_ret_t bgp_attr_nexthop(struct bgp_attr_parser_args *args) /* Check nexthop attribute length. */ if (length != 4) { - zlog_err("Nexthop attribute length isn't four [%d]", length); + flog_err(BGP_ERR_ATTR_LEN, + "Nexthop attribute length isn't four [%d]", length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); @@ -1274,7 +1285,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); - zlog_err("Martian nexthop %s", buf); + flog_err(BGP_ERR_ATTR_MARTIAN_NH, "Martian nexthop %s", buf); return bgp_attr_malformed( args, BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP, args->total); } @@ -1294,7 +1305,8 @@ static bgp_attr_parse_ret_t bgp_attr_med(struct bgp_attr_parser_args *args) /* Length check. */ if (length != 4) { - zlog_err("MED attribute length isn't four [%d]", length); + flog_err(BGP_ERR_ATTR_LEN, + "MED attribute length isn't four [%d]", length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); @@ -1317,7 +1329,8 @@ bgp_attr_local_pref(struct bgp_attr_parser_args *args) /* Length check. */ if (length != 4) { - zlog_err("LOCAL_PREF attribute length isn't 4 [%u]", length); + flog_err(BGP_ERR_ATTR_LEN, + "LOCAL_PREF attribute length isn't 4 [%u]", length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); } @@ -1346,8 +1359,9 @@ static int bgp_attr_atomic(struct bgp_attr_parser_args *args) /* Length check. */ if (length != 0) { - zlog_err("ATOMIC_AGGREGATE attribute length isn't 0 [%u]", - length); + flog_err(BGP_ERR_ATTR_LEN, + "ATOMIC_AGGREGATE attribute length isn't 0 [%u]", + length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); } @@ -1372,8 +1386,9 @@ static int bgp_attr_aggregator(struct bgp_attr_parser_args *args) wantedlen = 8; if (length != wantedlen) { - zlog_err("AGGREGATOR attribute length isn't %u [%u]", wantedlen, - length); + flog_err(BGP_ERR_ATTR_LEN, + "AGGREGATOR attribute length isn't %u [%u]", + wantedlen, length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); } @@ -1401,7 +1416,8 @@ bgp_attr_as4_aggregator(struct bgp_attr_parser_args *args, const bgp_size_t length = args->length; if (length != 8) { - zlog_err("New Aggregator length is not 8 [%d]", length); + flog_err(BGP_ERR_ATTR_LEN, + "New Aggregator length is not 8 [%d]", length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, 0); } @@ -1560,7 +1576,8 @@ bgp_attr_originator_id(struct bgp_attr_parser_args *args) /* Length check. */ if (length != 4) { - zlog_err("Bad originator ID length %d", length); + flog_err(BGP_ERR_ATTR_LEN, "Bad originator ID length %d", + length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); @@ -1583,7 +1600,8 @@ bgp_attr_cluster_list(struct bgp_attr_parser_args *args) /* Check length. */ if (length % 4) { - zlog_err("Bad cluster list length %d", length); + flog_err(BGP_ERR_ATTR_LEN, "Bad cluster list length %d", + length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); @@ -2052,10 +2070,10 @@ 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) { - zlog_err( - "Prefix SID label index length is %d instead of %d", - length, - BGP_PREFIX_SID_LABEL_INDEX_LENGTH); + flog_err( + BGP_ERR_ATTR_LEN, + "Prefix SID label index length is %d instead of %d", + length, BGP_PREFIX_SID_LABEL_INDEX_LENGTH); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); @@ -2088,8 +2106,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) { - zlog_err("Prefix SID IPv6 length is %d instead of %d", - 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); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); @@ -2110,7 +2129,8 @@ static bgp_attr_parse_ret_t bgp_attr_psid_sub(int32_t type, length -= 2; if (length % BGP_PREFIX_SID_ORIGINATOR_SRGB_LENGTH) { - zlog_err( + flog_err( + BGP_ERR_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( @@ -2159,8 +2179,10 @@ bgp_attr_prefix_sid(int32_t tlength, struct bgp_attr_parser_args *args, tlength -= length + 3; if (tlength < 0) { - zlog_err("Prefix SID internal length %d causes us to read beyond the total Prefix SID length", - length); + flog_err( + BGP_ERR_ATTR_LEN, + "Prefix SID internal length %d causes us to read beyond the total Prefix SID length", + length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); @@ -2185,21 +2207,24 @@ bgp_attr_pmsi_tunnel(struct bgp_attr_parser_args *args) * can only support that. */ if (length < 2) { - zlog_err("Bad PMSI tunnel attribute length %d", length); + flog_err(BGP_ERR_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) { - zlog_err("Invalid PMSI tunnel attribute type %d", tnl_type); + flog_err(BGP_ERR_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) { - zlog_err("Bad PMSI tunnel attribute length %d for IR", - length); + flog_err(BGP_ERR_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); @@ -2799,9 +2824,10 @@ size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer, afi_t afi, break; default: if (safi != SAFI_FLOWSPEC) - zlog_err( - "Bad nexthop when sending to %s, AFI %u SAFI %u nhlen %d", - peer->host, afi, safi, attr->mp_nexthop_len); + flog_err( + BGP_ERR_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_errors.c b/bgpd/bgp_errors.c new file mode 100644 index 000000000..50dd001b8 --- /dev/null +++ b/bgpd/bgp_errors.c @@ -0,0 +1,306 @@ +/* + * BGP-specific error messages. + * Copyright (C) 2018 Cumulus Networks, Inc. + * Don Slice + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; see the file COPYING; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <zebra.h> + +#include "lib/ferr.h" +#include "bgp_errors.h" + +/* clang-format off */ +static struct log_ref ferr_bgp_err[] = { + { + .code = BGP_ERR_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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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, + .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" + }, + { + .code = END_FERR, + } +}; +/* clang-format on */ + +void bgp_error_init(void) +{ + log_ref_add(ferr_bgp_err); +} diff --git a/bgpd/bgp_errors.h b/bgpd/bgp_errors.h new file mode 100644 index 000000000..be718d99e --- /dev/null +++ b/bgpd/bgp_errors.h @@ -0,0 +1,79 @@ +/* + * BGP-specific error messages. + * Copyright (C) 2018 Cumulus Networks, Inc. + * Don Slice + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; see the file COPYING; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __BGP_ERRORS_H__ +#define __BGP_ERRORS_H__ + +#include "lib/ferr.h" + +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, +}; + +extern void bgp_error_init(void); + +#endif diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 73f225784..b190e0923 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -43,6 +43,7 @@ #include "bgpd/bgp_ecommunity.h" #include "bgpd/bgp_encap_types.h" #include "bgpd/bgp_debug.h" +#include "bgpd/bgp_errors.h" #include "bgpd/bgp_aspath.h" #include "bgpd/bgp_zebra.h" #include "bgpd/bgp_nexthop.h" @@ -172,7 +173,8 @@ static struct vrf_irt_node *vrf_import_rt_new(struct ecommunity_val *rt) bgp_def = bgp_get_default(); if (!bgp_def) { - zlog_err("vrf import rt new - def instance not created yet"); + flog_err(BGP_ERR_NO_DFLT, + "vrf import rt new - def instance not created yet"); return NULL; } @@ -202,7 +204,8 @@ static void vrf_import_rt_free(struct vrf_irt_node *irt) bgp_def = bgp_get_default(); if (!bgp_def) { - zlog_err("vrf import rt free - def instance not created yet"); + flog_err(BGP_ERR_NO_DFLT, + "vrf import rt free - def instance not created yet"); return; } @@ -223,7 +226,9 @@ static struct vrf_irt_node *lookup_vrf_import_rt(struct ecommunity_val *rt) bgp_def = bgp_get_default(); if (!bgp_def) { - zlog_err("vrf import rt lookup - def instance not created yet"); + flog_err( + BGP_ERR_NO_DFLT, + "vrf import rt lookup - def instance not created yet"); return NULL; } @@ -619,7 +624,8 @@ static int bgp_zebra_send_remote_vtep(struct bgp *bgp, struct bgpevpn *vpn, if (is_evpn_prefix_ipaddr_v4(p)) stream_put_in_addr(s, &p->prefix.imet_addr.ip.ipaddr_v4); else if (is_evpn_prefix_ipaddr_v6(p)) { - zlog_err( + flog_err( + BGP_ERR_VTEP_INVALID, "Bad remote IP when trying to %s remote VTEP for VNI %u", add ? "ADD" : "DEL", vpn->vni); return -1; @@ -1289,11 +1295,12 @@ static int update_evpn_type4_route_entry(struct bgp *bgp, * We shouldn't see the same route from any other vtep. */ if (remote_ri) { - zlog_err( - "%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)), - ipaddr2str(&es->originator_ip, buf1, sizeof(buf1))); + flog_err( + BGP_ERR_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)), + ipaddr2str(&es->originator_ip, buf1, sizeof(buf1))); return -1; } @@ -1376,10 +1383,12 @@ static int update_evpn_type4_route(struct bgp *bgp, &attr, 1, &ri, &route_changed); if (ret != 0) { - zlog_err("%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( + 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))); } assert(ri); @@ -2216,10 +2225,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) { - zlog_err( - "%u failed to delete type-4 route for ESI %s", - bgp->vrf_id, - esi_to_str(&es->esi, buf, sizeof(buf))); + 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))); } /* Delete all routes from per ES table */ @@ -2876,7 +2884,8 @@ static int install_uninstall_routes_for_es(struct bgp *bgp, bgp, es, evp, ri); if (ret) { - zlog_err( + flog_err( + BGP_ERR_EVPN_FAIL, "Failed to %s EVPN %s route in ESI %s", install ? "install" : "uninstall", @@ -2955,7 +2964,8 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf, int install) bgp_vrf, evp, ri); if (ret) { - zlog_err( + flog_err( + BGP_ERR_EVPN_FAIL, "Failed to %s EVPN %s route in VRF %s", install ? "install" : "uninstall", @@ -3028,7 +3038,8 @@ static int install_uninstall_routes_for_vni(struct bgp *bgp, bgp, vpn, evp, ri); if (ret) { - zlog_err( + flog_err( + BGP_ERR_EVPN_FAIL, "%u: Failed to %s EVPN %s route in VNI %u", bgp->vrf_id, install ? "install" @@ -3130,11 +3141,11 @@ static int install_uninstall_route_in_es(struct bgp *bgp, struct evpnes *es, ret = uninstall_evpn_route_entry_in_es(bgp, es, evp, ri); if (ret) { - zlog_err("%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))); + flog_err( + BGP_ERR_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))); return ret; } return 0; @@ -3173,11 +3184,12 @@ static int install_uninstall_route_in_vrfs(struct bgp *bgp_def, afi_t afi, ri); if (ret) { - zlog_err("%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(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)); return ret; } } @@ -3208,12 +3220,14 @@ static int install_uninstall_route_in_vnis(struct bgp *bgp, afi_t afi, ret = uninstall_evpn_route_entry(bgp, vpn, evp, ri); if (ret) { - zlog_err("%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( + 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); return ret; } } @@ -3592,8 +3606,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) { - zlog_err("%u:%s - Rx EVPN Type-2 NLRI with invalid length %d", - peer->bgp->vrf_id, peer->host, psize); + 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); return -1; } @@ -3628,7 +3643,8 @@ static int process_type2_route(struct peer *peer, afi_t afi, safi_t safi, memcpy(&p.prefix.macip_addr.mac.octet, pfx, ETH_ALEN); pfx += ETH_ALEN; } else { - zlog_err( + flog_err( + BGP_ERR_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; @@ -3639,7 +3655,8 @@ static int process_type2_route(struct peer *peer, afi_t afi, safi_t safi, ipaddr_len = *pfx++; if (ipaddr_len != 0 && ipaddr_len != IPV4_MAX_BITLEN && ipaddr_len != IPV6_MAX_BITLEN) { - zlog_err( + flog_err( + BGP_ERR_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; @@ -3700,8 +3717,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) { - zlog_err("%u:%s - Rx EVPN Type-3 NLRI with invalid length %d", - peer->bgp->vrf_id, peer->host, psize); + 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); return -1; } @@ -3741,7 +3759,8 @@ static int process_type3_route(struct peer *peer, afi_t afi, safi_t safi, p.prefix.imet_addr.ip.ipa_type = IPADDR_V4; memcpy(&p.prefix.imet_addr.ip.ip.addr, pfx, IPV4_MAX_BYTELEN); } else { - zlog_err( + flog_err( + BGP_ERR_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; @@ -3777,8 +3796,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) { - zlog_err("%u:%s - Rx EVPN Type-4 NLRI with invalid length %d", - peer->bgp->vrf_id, peer->host, psize); + 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); return -1; } @@ -3798,7 +3818,8 @@ static int process_type4_route(struct peer *peer, afi_t afi, safi_t safi, if (ipaddr_len == IPV4_MAX_BITLEN) { memcpy(&vtep_ip, pfx, IPV4_MAX_BYTELEN); } else { - zlog_err( + flog_err( + BGP_ERR_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; @@ -3840,8 +3861,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) { - zlog_err("%u:%s - Rx EVPN Type-5 NLRI with invalid length %d", - peer->bgp->vrf_id, peer->host, psize); + 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); return -1; } @@ -3872,7 +3894,8 @@ static int process_type5_route(struct peer *peer, afi_t afi, safi_t safi, /* Fetch IP prefix length. */ ippfx_len = *pfx++; if (ippfx_len > IPV6_MAX_BITLEN) { - zlog_err( + flog_err( + BGP_ERR_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; @@ -4104,7 +4127,8 @@ void bgp_evpn_withdraw_type5_route(struct bgp *bgp_vrf, struct prefix *p, build_type5_prefix_from_ip_prefix(&evp, p); ret = delete_evpn_type5_route(bgp_vrf, &evp); if (ret) { - zlog_err( + flog_err( + BGP_ERR_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)); @@ -4150,8 +4174,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) - zlog_err("%u: Failed to create type-5 route for prefix %s", - bgp_vrf->vrf_id, prefix2str(p, buf, sizeof(buf))); + 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))); } /* Inject all prefixes of a particular address-family (currently, IPv4 or @@ -4709,7 +4734,8 @@ int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr, if (process_type2_route(peer, afi, safi, withdraw ? NULL : attr, pnt, psize, addpath_id)) { - zlog_err( + flog_err( + BGP_ERR_EVPN_FAIL, "%u:%s - Error in processing EVPN type-2 NLRI size %d", peer->bgp->vrf_id, peer->host, psize); return -1; @@ -4720,7 +4746,8 @@ int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr, if (process_type3_route(peer, afi, safi, withdraw ? NULL : attr, pnt, psize, addpath_id)) { - zlog_err( + flog_err( + BGP_ERR_PKT_PROCESS, "%u:%s - Error in processing EVPN type-3 NLRI size %d", peer->bgp->vrf_id, peer->host, psize); return -1; @@ -4731,7 +4758,8 @@ int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr, if (process_type4_route(peer, afi, safi, withdraw ? NULL : attr, pnt, psize, addpath_id)) { - zlog_err( + flog_err( + BGP_ERR_PKT_PROCESS, "%u:%s - Error in processing EVPN type-4 NLRI size %d", peer->bgp->vrf_id, peer->host, psize); return -1; @@ -4741,7 +4769,8 @@ int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr, case BGP_EVPN_IP_PREFIX_ROUTE: if (process_type5_route(peer, afi, safi, attr, pnt, psize, addpath_id, withdraw)) { - zlog_err( + flog_err( + BGP_ERR_PKT_PROCESS, "%u:%s - Error in processing EVPN type-5 NLRI size %d", peer->bgp->vrf_id, peer->host, psize); return -1; @@ -5204,7 +5233,8 @@ int bgp_evpn_local_macip_add(struct bgp *bgp, vni_t vni, struct ethaddr *mac, char buf[ETHER_ADDR_STRLEN]; char buf2[INET6_ADDRSTRLEN]; - zlog_err( + flog_err( + BGP_ERR_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) @@ -5246,7 +5276,8 @@ 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) { - zlog_err( + flog_err( + BGP_ERR_NO_DFLT, "Cannot process L3VNI %u ADD - default BGP instance not yet created", l3vni); return -1; @@ -5263,13 +5294,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: - zlog_err("'bgp multiple-instance' not present\n"); + flog_err(BGP_ERR_MULTI_INSTANCE, + "'bgp multiple-instance' not present\n"); return -1; case BGP_ERR_AS_MISMATCH: - zlog_err("BGP is already running; AS is %u\n", as); + flog_err(BGP_ERR_EVPN_AS_MISMATCH, + "BGP is already running; AS is %u\n", as); return -1; case BGP_ERR_INSTANCE_MISMATCH: - zlog_err("BGP instance name and AS number mismatch\n"); + flog_err(BGP_ERR_EVPN_INSTANCE_MISMATCH, + "BGP instance name and AS number mismatch\n"); return -1; } @@ -5330,7 +5364,8 @@ 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) { - zlog_err( + flog_err( + BGP_ERR_NO_DFLT, "Cannot process L3VNI %u Del - Could not find BGP instance", l3vni); return -1; @@ -5338,7 +5373,8 @@ int bgp_evpn_local_l3vni_del(vni_t l3vni, vrf_id_t vrf_id) bgp_def = bgp_get_default(); if (!bgp_def) { - zlog_err( + flog_err( + BGP_ERR_NO_DFLT, "Cannot process L3VNI %u Del - Could not find default BGP instance", l3vni); return -1; @@ -5468,7 +5504,8 @@ int bgp_evpn_local_vni_add(struct bgp *bgp, vni_t vni, if (!vpn) { vpn = bgp_evpn_new(bgp, vni, originator_ip, tenant_vrf_id); if (!vpn) { - zlog_err( + flog_err( + BGP_ERR_VNI, "%u: Failed to allocate VNI entry for VNI %u - at Add", bgp->vrf_id, vni); return -1; @@ -5491,8 +5528,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)) { - zlog_err("%u: Type3 route creation failure for VNI %u", - bgp->vrf_id, vni); + flog_err(BGP_ERR_EVPN_ROUTE_CREATE, + "%u: Type3 route creation failure for VNI %u", + bgp->vrf_id, vni); return -1; } @@ -5520,7 +5558,8 @@ int bgp_evpn_local_es_del(struct bgp *bgp, struct evpnes *es = NULL; if (!bgp->esihash) { - zlog_err("%u: ESI hash not yet created", bgp->vrf_id); + flog_err(BGP_ERR_ES_CREATE, "%u: ESI hash not yet created", + bgp->vrf_id); return -1; } @@ -5556,7 +5595,8 @@ int bgp_evpn_local_es_add(struct bgp *bgp, struct prefix_evpn p; if (!bgp->esihash) { - zlog_err("%u: ESI hash not yet created", bgp->vrf_id); + flog_err(BGP_ERR_ES_CREATE, "%u: ESI hash not yet created", + bgp->vrf_id); return -1; } @@ -5565,7 +5605,8 @@ int bgp_evpn_local_es_add(struct bgp *bgp, if (!es) { es = bgp_evpn_es_new(bgp, esi, originator_ip); if (!es) { - zlog_err( + flog_err( + BGP_ERR_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; @@ -5576,8 +5617,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)) { - zlog_err("%u: Type4 route creation failure for ESI %s", - bgp->vrf_id, esi_to_str(esi, buf, sizeof(buf))); + 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))); return -1; } diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index b45c1a99d..3828ce216 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -35,6 +35,7 @@ #include "bgpd/bgp_evpn_private.h" #include "bgpd/bgp_zebra.h" #include "bgpd/bgp_vty.h" +#include "bgpd/bgp_errors.h" #include "bgpd/bgp_ecommunity.h" #define SHOW_DISPLAY_STANDARD 0 @@ -1892,7 +1893,8 @@ 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) { - zlog_err( + flog_err( + BGP_ERR_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 2d336fa6d..6695596c6 100644 --- a/bgpd/bgp_flowspec.c +++ b/bgpd/bgp_flowspec.c @@ -22,6 +22,7 @@ #include <zebra.h> #include "prefix.h" +#include "lib_errors.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_route.h" @@ -30,6 +31,7 @@ #include "bgpd/bgp_flowspec_private.h" #include "bgpd/bgp_ecommunity.h" #include "bgpd/bgp_debug.h" +#include "bgpd/bgp_errors.h" static int bgp_fs_nlri_validate(uint8_t *nlri_content, uint32_t len) { @@ -102,13 +104,15 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr, safi = packet->safi; if (afi == AFI_IP6) { - zlog_err("BGP flowspec IPv6 not supported"); + flog_err(LIB_ERR_DEVELOPMENT, + "BGP flowspec IPv6 not supported"); return -1; } if (packet->length >= FLOWSPEC_NLRI_SIZELIMIT) { - zlog_err("BGP flowspec nlri length maximum reached (%u)", - packet->length); + flog_err(BGP_ERR_FLOWSPEC_PACKET, + "BGP flowspec nlri length maximum reached (%u)", + packet->length); return -1; } @@ -124,12 +128,14 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr, /* When packet overflow occur return immediately. */ if (pnt + psize > lim) { - zlog_err("Flowspec NLRI length inconsistent ( size %u seen)", - psize); + flog_err(BGP_ERR_FLOWSPEC_PACKET, + "Flowspec NLRI length inconsistent ( size %u seen)", + psize); return -1; } if (bgp_fs_nlri_validate(pnt, psize) < 0) { - zlog_err("Bad flowspec format or NLRI options not supported"); + flog_err(BGP_ERR_FLOWSPEC_PACKET, + "Bad flowspec format or NLRI options not supported"); return -1; } p.family = AF_FLOWSPEC; @@ -182,8 +188,9 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0, NULL); if (ret) { - zlog_err("Flowspec NLRI failed to be %s.", - attr ? "added" : "withdrawn"); + flog_err(BGP_ERR_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 6408337a5..9f92a3c3a 100644 --- a/bgpd/bgp_flowspec_util.c +++ b/bgpd/bgp_flowspec_util.c @@ -21,11 +21,13 @@ #include "zebra.h" #include "prefix.h" +#include "lib_errors.h" #include "bgp_table.h" #include "bgp_flowspec_util.h" #include "bgp_flowspec_private.h" #include "bgp_pbr.h" +#include "bgp_errors.h" static void hex2bin(uint8_t *hex, int *bin) { @@ -66,8 +68,9 @@ static int bgp_flowspec_call_non_opaque_decode(uint8_t *nlri_content, int len, len, mval, error); if (*error < 0) - zlog_err("%s: flowspec_op_decode error %d", - __func__, *error); + flog_err(BGP_ERR_FLOWSPEC_PACKET, + "%s: flowspec_op_decode error %d", + __func__, *error); else *match_num = *error; return ret; @@ -444,8 +447,9 @@ int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len, len - offset, prefix, &error); if (error < 0) - zlog_err("%s: flowspec_ip_address error %d", - __func__, error); + flog_err(BGP_ERR_FLOWSPEC_PACKET, + "%s: flowspec_ip_address error %d", + __func__, error); else bpem->match_bitmask |= bitmask; offset += ret; @@ -538,8 +542,9 @@ int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len, len - offset, &bpem->tcpflags, &error); if (error < 0) - zlog_err("%s: flowspec_tcpflags_decode error %d", - __func__, error); + flog_err(BGP_ERR_FLOWSPEC_PACKET, + "%s: flowspec_tcpflags_decode error %d", + __func__, error); else bpem->match_tcpflags_num = error; /* contains the number of slots used */ @@ -552,14 +557,16 @@ int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len, len - offset, &bpem->fragment, &error); if (error < 0) - zlog_err("%s: flowspec_fragment_type_decode error %d", - __func__, error); + flog_err(BGP_ERR_FLOWSPEC_PACKET, + "%s: flowspec_fragment_type_decode error %d", + __func__, error); else bpem->match_fragment_num = error; offset += ret; break; default: - zlog_err("%s: unknown type %d\n", __func__, type); + flog_err(LIB_ERR_DEVELOPMENT, "%s: unknown type %d\n", + __func__, type); } } return error; diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index 2fd63531d..14d692ebf 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -34,11 +34,13 @@ #include "queue.h" #include "filter.h" #include "command.h" +#include "lib_errors.h" #include "lib/json.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_attr.h" #include "bgpd/bgp_debug.h" +#include "bgpd/bgp_errors.h" #include "bgpd/bgp_fsm.h" #include "bgpd/bgp_packet.h" #include "bgpd/bgp_network.h" @@ -164,7 +166,8 @@ static struct peer *peer_xfer_conn(struct peer *from_peer) * runs in our pthread. */ if (peer->curr) { - zlog_err( + flog_err( + BGP_ERR_PKT_PROCESS, "[%s] Dropping pending packet on connection transfer:", peer->host); uint16_t type = stream_getc_from(peer->curr, @@ -242,7 +245,8 @@ static struct peer *peer_xfer_conn(struct peer *from_peer) } if (bgp_getsockname(peer) < 0) { - zlog_err( + flog_err( + LIB_ERR_SOCKET, "%%bgp_getsockname() failed for %s peer %s fd %d (from_peer fd %d)", (CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER) ? "accept" @@ -254,8 +258,10 @@ static struct peer *peer_xfer_conn(struct peer *from_peer) } if (from_peer->status > Active) { if (bgp_getsockname(from_peer) < 0) { - zlog_err( + flog_err( + LIB_ERR_SOCKET, "%%bgp_getsockname() failed for %s from_peer %s fd %d (peer fd %d)", + (CHECK_FLAG(from_peer->sflags, PEER_STATUS_ACCEPT_PEER) ? "accept" @@ -1280,15 +1286,17 @@ static int bgp_connect_check(struct thread *thread) static int bgp_connect_success(struct peer *peer) { if (peer->fd < 0) { - zlog_err("bgp_connect_success peer's fd is negative value %d", - peer->fd); + flog_err(BGP_ERR_CONNECT, + "bgp_connect_success peer's fd is negative value %d", + peer->fd); bgp_stop(peer); return -1; } if (bgp_getsockname(peer) < 0) { - zlog_err("%s: bgp_getsockname(): failed for peer %s, fd %d", - __FUNCTION__, peer->host, peer->fd); + flog_err_sys(LIB_ERR_SOCKET, + "%s: bgp_getsockname(): failed for peer %s, fd %d", + __FUNCTION__, peer->host, peer->fd); bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR, 0); /* internal error */ bgp_writes_on(peer); @@ -1346,10 +1354,10 @@ int bgp_start(struct peer *peer) if (BGP_PEER_START_SUPPRESSED(peer)) { if (bgp_debug_neighbor_events(peer)) - zlog_err( - "%s [FSM] Trying to start suppressed peer" - " - this is never supposed to happen!", - peer->host); + flog_err(BGP_ERR_FSM, + "%s [FSM] Trying to start suppressed peer" + " - this is never supposed to happen!", + peer->host); return -1; } @@ -1381,7 +1389,8 @@ int bgp_start(struct peer *peer) if (peer->bgp->vrf_id == VRF_UNKNOWN) { if (bgp_debug_neighbor_events(peer)) - zlog_err( + flog_err( + BGP_ERR_FSM, "%s [FSM] In a VRF that is not initialised yet", peer->host); return -1; @@ -1435,8 +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) { - zlog_err("bgp_start peer's fd is negative value %d", - peer->fd); + flog_err(BGP_ERR_FSM, + "bgp_start peer's fd is negative value %d", + peer->fd); return -1; } /* @@ -1482,8 +1492,9 @@ static int bgp_fsm_open(struct peer *peer) peer and change to Idle status. */ static int bgp_fsm_event_error(struct peer *peer) { - zlog_err("%s [FSM] unexpected packet received in state %s", peer->host, - lookup_msg(bgp_status_msg, peer->status, NULL)); + flog_err(BGP_ERR_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); } @@ -1515,7 +1526,7 @@ static int bgp_establish(struct peer *peer) other = peer->doppelganger; peer = peer_xfer_conn(peer); if (!peer) { - zlog_err("%%Neighbor failed in xfer_conn"); + flog_err(BGP_ERR_CONNECT, "%%Neighbor failed in xfer_conn"); return -1; } @@ -1674,7 +1685,8 @@ static int bgp_fsm_update(struct peer *peer) /* This is empty event. */ static int bgp_ignore(struct peer *peer) { - zlog_err( + flog_err( + BGP_ERR_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), @@ -1686,7 +1698,8 @@ static int bgp_ignore(struct peer *peer) /* This is to handle unexpected events.. */ static int bgp_fsm_exeption(struct peer *peer) { - zlog_err( + flog_err( + BGP_ERR_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), @@ -1960,7 +1973,8 @@ int bgp_event_update(struct peer *peer, int event) * code. */ if (!dyn_nbr && !passive_conn && peer->bgp) { - zlog_err( + flog_err( + BGP_ERR_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 c8d5b1daa..311f98001 100644 --- a/bgpd/bgp_io.c +++ b/bgpd/bgp_io.c @@ -35,6 +35,7 @@ #include "bgpd/bgp_io.h" #include "bgpd/bgp_debug.h" // for bgp_debug_neighbor_events, bgp_type_str +#include "bgpd/bgp_errors.h" // for expanded error reference information #include "bgpd/bgp_fsm.h" // for BGP_EVENT_ADD, bgp_event #include "bgpd/bgp_packet.h" // for bgp_notify_send_with_data, bgp_notify... #include "bgpd/bgpd.h" // for peer, BGP_MARKER_SIZE, bgp_master, bm @@ -401,8 +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) { - zlog_err("%s [Error] bgp_read_packet error: %s", peer->host, - safe_strerror(errno)); + flog_err(BGP_ERR_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 8a051b7ff..633e58933 100644 --- a/bgpd/bgp_label.c +++ b/bgpd/bgp_label.c @@ -38,6 +38,7 @@ #include "bgpd/bgp_label.h" #include "bgpd/bgp_packet.h" #include "bgpd/bgp_debug.h" +#include "bgpd/bgp_errors.h" extern struct zclient *zclient; @@ -244,7 +245,8 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr, /* sanity check against packet data */ if ((pnt + psize) > lim) { - zlog_err( + flog_err( + BGP_ERR_UPDATE_RCV, "%s [Error] Update packet error / L-U (prefix length %d exceeds packet size %u)", peer->host, prefixlen, (uint)(lim - pnt)); return -1; @@ -256,10 +258,10 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr, /* There needs to be at least one label */ if (prefixlen < 24) { - zlog_err( - "%s [Error] Update packet error" - " (wrong label length %d)", - peer->host, prefixlen); + flog_err(BGP_ERR_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; @@ -284,7 +286,8 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr, * be logged locally, and the prefix SHOULD be * ignored. */ - zlog_err( + flog_err( + BGP_ERR_UPDATE_RCV, "%s: IPv4 labeled-unicast NLRI is multicast address %s, ignoring", peer->host, inet_ntoa(p.u.prefix4)); continue; @@ -296,7 +299,8 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr, if (IN6_IS_ADDR_LINKLOCAL(&p.u.prefix6)) { char buf[BUFSIZ]; - zlog_err( + flog_err( + BGP_ERR_UPDATE_RCV, "%s: IPv6 labeled-unicast NLRI is link-local address %s, ignoring", peer->host, inet_ntop(AF_INET6, &p.u.prefix6, buf, @@ -308,7 +312,8 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr, if (IN6_IS_ADDR_MULTICAST(&p.u.prefix6)) { char buf[BUFSIZ]; - zlog_err( + flog_err( + BGP_ERR_UPDATE_RCV, "%s: IPv6 unicast NLRI is multicast address %s, ignoring", peer->host, inet_ntop(AF_INET6, &p.u.prefix6, buf, @@ -331,7 +336,8 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr, /* Packet length consistency check. */ if (pnt != lim) { - zlog_err( + flog_err( + BGP_ERR_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 e052d6061..8d15649ea 100644 --- a/bgpd/bgp_labelpool.c +++ b/bgpd/bgp_labelpool.c @@ -34,6 +34,7 @@ #include "bgpd/bgpd.h" #include "bgpd/bgp_labelpool.h" #include "bgpd/bgp_debug.h" +#include "bgpd/bgp_errors.h" /* * Definitions and external declarations. @@ -126,7 +127,8 @@ static wq_item_status lp_cbq_docallback(struct work_queue *wq, void *data) if (lcbq->label == MPLS_LABEL_NONE) { /* shouldn't happen */ - zlog_err("%s: error: label==MPLS_LABEL_NONE", __func__); + flog_err(BGP_ERR_LABEL, "%s: error: label==MPLS_LABEL_NONE", + __func__); return WQ_SUCCESS; } @@ -336,8 +338,9 @@ void bgp_lp_get( if (rc) { /* shouldn't happen */ - zlog_err("%s: can't insert new LCB into ledger list", - __func__); + flog_err(BGP_ERR_LABEL, + "%s: can't insert new LCB into ledger list", + __func__); XFREE(MTYPE_BGP_LABEL_CB, lcb); return; } @@ -424,8 +427,9 @@ void bgp_lp_event_chunk(uint8_t keep, uint32_t first, uint32_t last) struct lp_fifo *lf; if (last < first) { - zlog_err("%s: zebra label chunk invalid: first=%u, last=%u", - __func__, first, last); + flog_err(BGP_ERR_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 2327e262a..8eb1c9e25 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -54,11 +54,13 @@ #include "bgpd/bgp_regex.h" #include "bgpd/bgp_clist.h" #include "bgpd/bgp_debug.h" +#include "bgpd/bgp_errors.h" #include "bgpd/bgp_filter.h" #include "bgpd/bgp_zebra.h" #include "bgpd/bgp_packet.h" #include "bgpd/bgp_keepalives.h" #include "bgpd/bgp_network.h" +#include "bgpd/bgp_errors.h" #ifdef ENABLE_BGP_VNC #include "bgpd/rfapi/rfapi_backend.h" @@ -384,7 +386,8 @@ int main(int argc, char **argv) multipath_num = atoi(optarg); if (multipath_num > MULTIPATH_NUM || multipath_num <= 0) { - zlog_err( + flog_err( + BGP_ERR_MULTIPATH, "Multipath Number specified must be less than %d and greater than 0", MULTIPATH_NUM); return 1; @@ -417,6 +420,7 @@ int main(int argc, char **argv) if (no_fib_flag) bgp_option_set(BGP_OPT_NO_FIB); + bgp_error_init(); /* Initializations. */ bgp_vrf_init(); diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index f72104dd3..c2cb20b06 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -33,6 +33,7 @@ #include "bgpd/bgpd.h" #include "bgpd/bgp_debug.h" +#include "bgpd/bgp_errors.h" #include "bgpd/bgp_table.h" #include "bgpd/bgp_route.h" #include "bgpd/bgp_attr.h" @@ -150,7 +151,8 @@ int bgp_nlri_parse_vpn(struct peer *peer, struct attr *attr, psize = PSIZE(prefixlen); if (prefixlen < VPN_PREFIXLEN_MIN_BYTES * 8) { - zlog_err( + flog_err( + BGP_ERR_UPDATE_RCV, "%s [Error] Update packet error / VPN (prefix length %d less than VPN min length)", peer->host, prefixlen); return -1; @@ -158,7 +160,8 @@ int bgp_nlri_parse_vpn(struct peer *peer, struct attr *attr, /* sanity check against packet data */ if ((pnt + psize) > lim) { - zlog_err( + flog_err( + BGP_ERR_UPDATE_RCV, "%s [Error] Update packet error / VPN (prefix length %d exceeds packet size %u)", peer->host, prefixlen, (uint)(lim - pnt)); return -1; @@ -166,7 +169,8 @@ 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)) { - zlog_err( + flog_err( + BGP_ERR_UPDATE_RCV, "%s [Error] Update packet error / VPN (psize %d exceeds storage size %zu)", peer->host, prefixlen - VPN_PREFIXLEN_MIN_BYTES * 8, @@ -176,7 +180,8 @@ 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)) { - zlog_err( + flog_err( + BGP_ERR_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, @@ -213,7 +218,8 @@ int bgp_nlri_parse_vpn(struct peer *peer, struct attr *attr, #endif default: - zlog_err("Unknown RD type %d", type); + flog_err(BGP_ERR_UPDATE_RCV, "Unknown RD type %d", + type); break; /* just report */ } @@ -235,7 +241,8 @@ int bgp_nlri_parse_vpn(struct peer *peer, struct attr *attr, } /* Packet length consistency check. */ if (pnt != lim) { - zlog_err( + flog_err( + BGP_ERR_UPDATE_RCV, "%s [Error] Update packet error / VPN (%zu data remaining after parsing)", peer->host, lim - pnt); return -1; @@ -359,8 +366,10 @@ int vpn_leak_label_callback( return 0; } /* Shouldn't happen: different label allocation */ - zlog_err("%s: %s had label %u but got new assignment %u", - __func__, vp->bgp->name_pretty, vp->tovpn_label, label); + flog_err(BGP_ERR_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 476b64e75..0664fdfd1 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -35,12 +35,14 @@ #include "hash.h" #include "filter.h" #include "ns.h" +#include "lib_errors.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_open.h" #include "bgpd/bgp_fsm.h" #include "bgpd/bgp_attr.h" #include "bgpd/bgp_debug.h" +#include "bgpd/bgp_errors.h" #include "bgpd/bgp_network.h" extern struct zebra_privs_t bgpd_privs; @@ -95,15 +97,9 @@ static int bgp_md5_set_connect(int socket, union sockunion *su, int ret = -1; #if HAVE_DECL_TCP_MD5SIG - if (bgpd_privs.change(ZPRIVS_RAISE)) { - zlog_err("%s: could not raise privs", __func__); - return ret; + frr_elevate_privs(&bgpd_privs) { + ret = bgp_md5_set_socket(socket, su, password); } - - ret = bgp_md5_set_socket(socket, su, password); - - if (bgpd_privs.change(ZPRIVS_LOWER)) - zlog_err("%s: could not lower privs", __func__); #endif /* HAVE_TCP_MD5SIG */ return ret; @@ -115,25 +111,18 @@ static int bgp_md5_set_password(struct peer *peer, const char *password) int ret = 0; struct bgp_listener *listener; - if (bgpd_privs.change(ZPRIVS_RAISE)) { - zlog_err("%s: could not raise privs", __func__); - return -1; - } - + frr_elevate_privs(&bgpd_privs) { /* Set or unset the password on the listen socket(s). Outbound - * connections - * are taken care of in bgp_connect() below. + * connections are taken care of in bgp_connect() below. */ - for (ALL_LIST_ELEMENTS_RO(bm->listen_sockets, node, listener)) - if (listener->su.sa.sa_family == peer->su.sa.sa_family) { - ret = bgp_md5_set_socket(listener->fd, &peer->su, - password); - break; - } - - if (bgpd_privs.change(ZPRIVS_LOWER)) - zlog_err("%s: could not lower privs", __func__); - + for (ALL_LIST_ELEMENTS_RO(bm->listen_sockets, node, listener)) + if (listener->su.sa.sa_family + == peer->su.sa.sa_family) { + ret = bgp_md5_set_socket(listener->fd, + &peer->su, password); + break; + } + } return ret; } @@ -158,10 +147,12 @@ int bgp_set_socket_ttl(struct peer *peer, int bgp_sock) if (!peer->gtsm_hops && (peer_sort(peer) == BGP_PEER_EBGP)) { ret = sockopt_ttl(peer->su.sa.sa_family, bgp_sock, peer->ttl); if (ret) { - zlog_err( + flog_err( + LIB_ERR_SOCKET, "%s: Can't set TxTTL on peer (rtrid %s) socket, err = %d", - __func__, inet_ntop(AF_INET, &peer->remote_id, - buf, sizeof(buf)), + __func__, + inet_ntop(AF_INET, &peer->remote_id, buf, + sizeof(buf)), errno); return ret; } @@ -172,20 +163,24 @@ int bgp_set_socket_ttl(struct peer *peer, int bgp_sock) */ ret = sockopt_ttl(peer->su.sa.sa_family, bgp_sock, MAXTTL); if (ret) { - zlog_err( + flog_err( + LIB_ERR_SOCKET, "%s: Can't set TxTTL on peer (rtrid %s) socket, err = %d", - __func__, inet_ntop(AF_INET, &peer->remote_id, - buf, sizeof(buf)), + __func__, + inet_ntop(AF_INET, &peer->remote_id, buf, + sizeof(buf)), errno); return ret; } ret = sockopt_minttl(peer->su.sa.sa_family, bgp_sock, MAXTTL + 1 - peer->gtsm_hops); if (ret) { - zlog_err( + flog_err( + LIB_ERR_SOCKET, "%s: Can't set MinTTL on peer (rtrid %s) socket, err = %d", - __func__, inet_ntop(AF_INET, &peer->remote_id, - buf, sizeof(buf)), + __func__, + inet_ntop(AF_INET, &peer->remote_id, buf, + sizeof(buf)), errno); return ret; } @@ -226,8 +221,10 @@ 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) - zlog_err("[Error] BGP SO_BINDTODEVICE get failed (%s), sock %d", - safe_strerror(errno), sock); + flog_err( + LIB_ERR_SOCKET, + "[Error] BGP SO_BINDTODEVICE get failed (%s), sock %d", + safe_strerror(errno), sock); return -1; #endif } @@ -282,7 +279,8 @@ static int bgp_accept(struct thread *thread) /* Register accept thread. */ accept_sock = THREAD_FD(thread); if (accept_sock < 0) { - zlog_err("accept_sock is nevative value %d", accept_sock); + flog_err_sys(LIB_ERR_SOCKET, "accept_sock is nevative value %d", + accept_sock); return -1; } listener->thread = NULL; @@ -293,8 +291,9 @@ static int bgp_accept(struct thread *thread) /* Accept client connection. */ bgp_sock = sockunion_accept(accept_sock, &su); if (bgp_sock < 0) { - zlog_err("[Error] BGP socket accept failed (%s)", - safe_strerror(errno)); + flog_err_sys(LIB_ERR_SOCKET, + "[Error] BGP socket accept failed (%s)", + safe_strerror(errno)); return -1; } set_nonblocking(bgp_sock); @@ -543,13 +542,11 @@ int bgp_connect(struct peer *peer) zlog_debug("Peer address not learnt: Returning from connect"); return 0; } - if (bgpd_privs.change(ZPRIVS_RAISE)) - zlog_err("Can't raise privileges"); + frr_elevate_privs(&bgpd_privs) { /* Make socket for the peer. */ - peer->fd = vrf_sockunion_socket(&peer->su, peer->bgp->vrf_id, - bgp_get_bound_name(peer)); - if (bgpd_privs.change(ZPRIVS_LOWER)) - zlog_err("Can't lower privileges"); + peer->fd = vrf_sockunion_socket(&peer->su, peer->bgp->vrf_id, + bgp_get_bound_name(peer)); + } if (peer->fd < 0) return -1; @@ -568,14 +565,14 @@ int bgp_connect(struct peer *peer) peer->host, safe_strerror(errno)); #ifdef IPTOS_PREC_INTERNETCONTROL - if (bgpd_privs.change(ZPRIVS_RAISE)) - zlog_err("%s: could not raise privs", __func__); - if (sockunion_family(&peer->su) == AF_INET) - setsockopt_ipv4_tos(peer->fd, IPTOS_PREC_INTERNETCONTROL); - else if (sockunion_family(&peer->su) == AF_INET6) - setsockopt_ipv6_tclass(peer->fd, IPTOS_PREC_INTERNETCONTROL); - if (bgpd_privs.change(ZPRIVS_LOWER)) - zlog_err("%s: could not lower privs", __func__); + frr_elevate_privs(&bgpd_privs) { + if (sockunion_family(&peer->su) == AF_INET) + setsockopt_ipv4_tos(peer->fd, + IPTOS_PREC_INTERNETCONTROL); + else if (sockunion_family(&peer->su) == AF_INET6) + setsockopt_ipv6_tclass(peer->fd, + IPTOS_PREC_INTERNETCONTROL); + } #endif if (peer->password) @@ -623,7 +620,8 @@ int bgp_getsockname(struct peer *peer) if (bgp_nexthop_set(peer->su_local, peer->su_remote, &peer->nexthop, peer)) { #if defined(HAVE_CUMULUS) - zlog_err( + flog_err( + BGP_ERR_NH_UPD, "%s: nexthop_set failed, resetting connection - intf %p", peer->host, peer->nexthop.ifp); return -1; @@ -642,31 +640,31 @@ static int bgp_listener(int sock, struct sockaddr *sa, socklen_t salen, sockopt_reuseaddr(sock); sockopt_reuseport(sock); - if (bgpd_privs.change(ZPRIVS_RAISE)) - zlog_err("%s: could not raise privs", __func__); + frr_elevate_privs(&bgpd_privs) { #ifdef IPTOS_PREC_INTERNETCONTROL - if (sa->sa_family == AF_INET) - setsockopt_ipv4_tos(sock, IPTOS_PREC_INTERNETCONTROL); - else if (sa->sa_family == AF_INET6) - setsockopt_ipv6_tclass(sock, IPTOS_PREC_INTERNETCONTROL); + if (sa->sa_family == AF_INET) + setsockopt_ipv4_tos(sock, IPTOS_PREC_INTERNETCONTROL); + else if (sa->sa_family == AF_INET6) + setsockopt_ipv6_tclass(sock, + IPTOS_PREC_INTERNETCONTROL); #endif - sockopt_v6only(sa->sa_family, sock); + sockopt_v6only(sa->sa_family, sock); - ret = bind(sock, sa, salen); - en = errno; - if (bgpd_privs.change(ZPRIVS_LOWER)) - zlog_err("%s: could not lower privs", __func__); + ret = bind(sock, sa, salen); + en = errno; + } if (ret < 0) { - zlog_err("bind: %s", safe_strerror(en)); + flog_err_sys(LIB_ERR_SOCKET, "bind: %s", safe_strerror(en)); return ret; } ret = listen(sock, SOMAXCONN); if (ret < 0) { - zlog_err("listen: %s", safe_strerror(errno)); + flog_err_sys(LIB_ERR_SOCKET, "listen: %s", + safe_strerror(errno)); return ret; } @@ -702,14 +700,13 @@ int bgp_socket(struct bgp *bgp, unsigned short port, const char *address) snprintf(port_str, sizeof(port_str), "%d", port); port_str[sizeof(port_str) - 1] = '\0'; - if (bgpd_privs.change(ZPRIVS_RAISE)) - zlog_err("Can't raise privileges"); - ret = vrf_getaddrinfo(address, port_str, &req, &ainfo_save, - bgp->vrf_id); - if (bgpd_privs.change(ZPRIVS_LOWER)) - zlog_err("Can't lower privileges"); + frr_elevate_privs(&bgpd_privs) { + ret = vrf_getaddrinfo(address, port_str, &req, &ainfo_save, + bgp->vrf_id); + } if (ret != 0) { - zlog_err("getaddrinfo: %s", gai_strerror(ret)); + flog_err_sys(LIB_ERR_SOCKET, "getaddrinfo: %s", + gai_strerror(ret)); return -1; } @@ -720,16 +717,17 @@ int bgp_socket(struct bgp *bgp, unsigned short port, const char *address) if (ainfo->ai_family != AF_INET && ainfo->ai_family != AF_INET6) continue; - if (bgpd_privs.change(ZPRIVS_RAISE)) - zlog_err("Can't raise privileges"); - sock = vrf_socket(ainfo->ai_family, ainfo->ai_socktype, - ainfo->ai_protocol, bgp->vrf_id, - (bgp->inst_type == BGP_INSTANCE_TYPE_VRF ? - bgp->name : NULL)); - if (bgpd_privs.change(ZPRIVS_LOWER)) - zlog_err("Can't lower privileges"); + frr_elevate_privs(&bgpd_privs) { + sock = vrf_socket(ainfo->ai_family, + ainfo->ai_socktype, + ainfo->ai_protocol, bgp->vrf_id, + (bgp->inst_type + == BGP_INSTANCE_TYPE_VRF + ? bgp->name : NULL)); + } if (sock < 0) { - zlog_err("socket: %s", safe_strerror(errno)); + flog_err_sys(LIB_ERR_SOCKET, "socket: %s", + safe_strerror(errno)); continue; } @@ -746,10 +744,12 @@ 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) { - zlog_err( + flog_err( + LIB_ERR_SOCKET, "%s: no usable addresses please check other programs usage of specified port %d", __func__, port); - zlog_err("%s: Program cannot continue", __func__); + flog_err_sys(LIB_ERR_SOCKET, "%s: Program cannot continue", + __func__); exit(-1); } diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index 8b6ff3fa2..0c0c07995 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -38,6 +38,7 @@ #include "bgpd/bgp_attr.h" #include "bgpd/bgp_nexthop.h" #include "bgpd/bgp_debug.h" +#include "bgpd/bgp_errors.h" #include "bgpd/bgp_nht.h" #include "bgpd/bgp_fsm.h" #include "bgpd/bgp_zebra.h" @@ -343,7 +344,8 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id) bgp = bgp_lookup_by_vrf_id(vrf_id); if (!bgp) { - zlog_err( + flog_err( + BGP_ERR_NH_UPD, "parse nexthop update: instance not found for vrf_id %u", vrf_id); return; diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c index da90bbd67..7fbc03024 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -34,6 +34,7 @@ #include "bgpd/bgpd.h" #include "bgpd/bgp_attr.h" #include "bgpd/bgp_debug.h" +#include "bgpd/bgp_errors.h" #include "bgpd/bgp_fsm.h" #include "bgpd/bgp_packet.h" #include "bgpd/bgp_open.h" @@ -520,8 +521,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) { - zlog_err("%s AS4 capability has incorrect data length %d", - peer->host, hdr->length); + flog_err(BGP_ERR_PKT_OPEN, + "%s AS4 capability has incorrect data length %d", + peer->host, hdr->length); return 0; } @@ -1184,10 +1186,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]) { - zlog_err( - "%s [Error] Configured AFI/SAFIs do not " - "overlap with received MP capabilities", - peer->host); + flog_err(BGP_ERR_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 446dc5ac1..bb474b9e2 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -36,12 +36,14 @@ #include "plist.h" #include "queue.h" #include "filter.h" +#include "lib_errors.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_table.h" #include "bgpd/bgp_dump.h" #include "bgpd/bgp_attr.h" #include "bgpd/bgp_debug.h" +#include "bgpd/bgp_errors.h" #include "bgpd/bgp_fsm.h" #include "bgpd/bgp_route.h" #include "bgpd/bgp_packet.h" @@ -1089,8 +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) { - zlog_err("%s bad OPEN, got AS4 capability, but AS4 set to 0", - peer->host); + flog_err(BGP_ERR_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); @@ -1103,7 +1106,8 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size) * BGP_AS_TRANS, for some unknown reason. */ if (as4 == BGP_AS_TRANS) { - zlog_err( + flog_err( + BGP_ERR_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, @@ -1132,7 +1136,8 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size) if (CHECK_FLAG(peer->cap, PEER_CAP_AS4_RCV) && as4 != remote_as) { /* raise error, log this, close session */ - zlog_err( + flog_err( + BGP_ERR_PKT_OPEN, "%s bad OPEN, got AS4 capability, but remote_as %u" " mismatch with 16bit 'myasn' %u in open", peer->host, as4, remote_as); @@ -1299,8 +1304,9 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size) /* Get sockname. */ if ((ret = bgp_getsockname(peer)) < 0) { - zlog_err("%s: bgp_getsockname() failed for peer: %s", - __FUNCTION__, peer->host); + flog_err_sys(LIB_ERR_SOCKET, + "%s: bgp_getsockname() failed for peer: %s", + __FUNCTION__, peer->host); return BGP_Stop; } @@ -1313,7 +1319,8 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size) || peer->afc_nego[AFI_IP][SAFI_ENCAP]) { if (!peer->nexthop.v4.s_addr) { #if defined(HAVE_CUMULUS) - zlog_err( + flog_err( + BGP_ERR_SND_FAIL, "%s: No local IPv4 addr resetting connection, fd %d", peer->host, peer->fd); bgp_notify_send(peer, BGP_NOTIFY_CEASE, @@ -1329,7 +1336,8 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size) || peer->afc_nego[AFI_IP6][SAFI_ENCAP]) { if (IN6_IS_ADDR_UNSPECIFIED(&peer->nexthop.v6_global)) { #if defined(HAVE_CUMULUS) - zlog_err( + flog_err( + BGP_ERR_SND_FAIL, "%s: No local IPv6 addr resetting connection, fd %d", peer->host, peer->fd); bgp_notify_send(peer, BGP_NOTIFY_CEASE, @@ -1391,9 +1399,10 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size) /* Status must be Established. */ if (peer->status != Established) { - zlog_err("%s [FSM] Update packet received under status %s", - peer->host, - lookup_msg(bgp_status_msg, peer->status, NULL)); + flog_err(BGP_ERR_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; } @@ -1414,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) { - zlog_err( - "%s [Error] Update packet error" - " (packet length is short for unfeasible length)", - peer->host); + flog_err(BGP_ERR_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; @@ -1428,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) { - zlog_err( - "%s [Error] Update packet error" - " (packet unfeasible length overflow %d)", - peer->host, withdraw_len); + flog_err(BGP_ERR_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; @@ -1502,7 +1511,8 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size) ret = bgp_dump_attr(&attr, peer->rcvd_attr_str, BUFSIZ); if (attr_parse_ret == BGP_ATTR_PARSE_WITHDRAW) - zlog_err( + flog_err( + BGP_ERR_UPDATE_RCV, "%s rcvd UPDATE with errors in attr(s)!! Withdrawing route.", peer->host); @@ -1562,7 +1572,8 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size) } if (nlri_ret < 0) { - zlog_err("%s [Error] Error parsing NLRI", peer->host); + flog_err(BGP_ERR_UPDATE_RCV, + "%s [Error] Error parsing NLRI", peer->host); if (peer->status == Established) bgp_notify_send( peer, BGP_NOTIFY_UPDATE_ERR, @@ -1733,8 +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)) { - zlog_err("%s [Error] BGP route refresh is not enabled", - peer->host); + flog_err(BGP_ERR_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; @@ -1742,7 +1754,8 @@ static int bgp_route_refresh_receive(struct peer *peer, bgp_size_t size) /* Status must be Established. */ if (peer->status != Established) { - zlog_err( + flog_err( + BGP_ERR_INVALID_STATUS, "%s [Error] Route refresh packet received under status %s", peer->host, lookup_msg(bgp_status_msg, peer->status, NULL)); @@ -2122,8 +2135,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)) { - zlog_err("%s [Error] BGP dynamic capability is not enabled", - peer->host); + flog_err(BGP_ERR_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; @@ -2131,7 +2145,8 @@ int bgp_capability_receive(struct peer *peer, bgp_size_t size) /* Status must be Established. */ if (peer->status != Established) { - zlog_err( + flog_err( + BGP_ERR_NO_CAP, "%s [Error] Dynamic capability packet received under status %s", peer->host, lookup_msg(bgp_status_msg, peer->status, NULL)); @@ -2212,7 +2227,8 @@ int bgp_process_packet(struct thread *thread) memory_order_relaxed); mprc = bgp_open_receive(peer, size); if (mprc == BGP_Stop) - zlog_err( + flog_err( + BGP_ERR_PKT_OPEN, "%s: BGP OPEN receipt failed for peer: %s", __FUNCTION__, peer->host); break; @@ -2222,7 +2238,8 @@ int bgp_process_packet(struct thread *thread) peer->readtime = monotime(NULL); mprc = bgp_update_receive(peer, size); if (mprc == BGP_Stop) - zlog_err( + flog_err( + BGP_ERR_UPDATE_RCV, "%s: BGP UPDATE receipt failed for peer: %s", __FUNCTION__, peer->host); break; @@ -2231,7 +2248,8 @@ int bgp_process_packet(struct thread *thread) memory_order_relaxed); mprc = bgp_notify_receive(peer, size); if (mprc == BGP_Stop) - zlog_err( + flog_err( + BGP_ERR_NOTIFY_RCV, "%s: BGP NOTIFY receipt failed for peer: %s", __FUNCTION__, peer->host); break; @@ -2241,7 +2259,8 @@ int bgp_process_packet(struct thread *thread) memory_order_relaxed); mprc = bgp_keepalive_receive(peer, size); if (mprc == BGP_Stop) - zlog_err( + flog_err( + BGP_ERR_KEEP_RCV, "%s: BGP KEEPALIVE receipt failed for peer: %s", __FUNCTION__, peer->host); break; @@ -2251,7 +2270,8 @@ int bgp_process_packet(struct thread *thread) memory_order_relaxed); mprc = bgp_route_refresh_receive(peer, size); if (mprc == BGP_Stop) - zlog_err( + flog_err( + BGP_ERR_RFSH_RCV, "%s: BGP ROUTEREFRESH receipt failed for peer: %s", __FUNCTION__, peer->host); break; @@ -2260,7 +2280,8 @@ int bgp_process_packet(struct thread *thread) memory_order_relaxed); mprc = bgp_capability_receive(peer, size); if (mprc == BGP_Stop) - zlog_err( + flog_err( + BGP_ERR_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 de475d2dc..129c143a6 100644 --- a/bgpd/bgp_pbr.c +++ b/bgpd/bgp_pbr.c @@ -33,6 +33,7 @@ #include "bgpd/bgp_zebra.h" #include "bgpd/bgp_mplsvpn.h" #include "bgpd/bgp_flowspec_private.h" +#include "bgpd/bgp_errors.h" DEFINE_MTYPE_STATIC(BGPD, PBR_MATCH_ENTRY, "PBR match entry") DEFINE_MTYPE_STATIC(BGPD, PBR_MATCH, "PBR match") @@ -652,8 +653,9 @@ 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)) - zlog_err("%s: flowspec actions exceeds limit (max %u)", - __func__, action_count); + flog_err(BGP_ERR_FLOWSPEC_PACKET, + "%s: flowspec actions exceeds limit (max %u)", + __func__, action_count); break; } api_action = &api->actions[action_count - 1]; @@ -2250,15 +2252,17 @@ void bgp_pbr_update_entry(struct bgp *bgp, struct prefix *p, if (!bgp_zebra_tm_chunk_obtained()) { if (BGP_DEBUG(pbr, PBR_ERROR)) - zlog_err("%s: table chunk not obtained yet", - __func__); + flog_err(BGP_ERR_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)) - zlog_err("%s: cancel updating entry %p in bgp pbr", - __func__, info); + flog_err(BGP_ERR_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 1ded492a2..b39554379 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -44,6 +44,7 @@ #include "bgpd/bgp_route.h" #include "bgpd/bgp_attr.h" #include "bgpd/bgp_debug.h" +#include "bgpd/bgp_errors.h" #include "bgpd/bgp_aspath.h" #include "bgpd/bgp_regex.h" #include "bgpd/bgp_community.h" @@ -4202,8 +4203,9 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr, /* Prefix length check. */ if (p.prefixlen > prefix_blen(&p) * 8) { - zlog_err( - "%s [Error] Update packet error (wrong perfix length %d for afi %u)", + flog_err( + BGP_ERR_UPDATE_RCV, + "%s [Error] Update packet error (wrong prefix length %d for afi %u)", peer->host, p.prefixlen, packet->afi); return -1; } @@ -4213,7 +4215,8 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr, /* When packet overflow occur return immediately. */ if (pnt + psize > lim) { - zlog_err( + flog_err( + BGP_ERR_UPDATE_RCV, "%s [Error] Update packet error (prefix length %d overflows packet)", peer->host, p.prefixlen); return -1; @@ -4222,7 +4225,8 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr, /* Defensive coding, double-check the psize fits in a struct * prefix */ if (psize > (ssize_t)sizeof(p.u)) { - zlog_err( + flog_err( + BGP_ERR_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; @@ -4243,7 +4247,8 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr, * be logged locally, and the prefix SHOULD be * ignored. */ - zlog_err( + flog_err( + BGP_ERR_UPDATE_RCV, "%s: IPv4 unicast NLRI is multicast address %s, ignoring", peer->host, inet_ntoa(p.u.prefix4)); continue; @@ -4255,7 +4260,8 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr, if (IN6_IS_ADDR_LINKLOCAL(&p.u.prefix6)) { char buf[BUFSIZ]; - zlog_err( + flog_err( + BGP_ERR_UPDATE_RCV, "%s: IPv6 unicast NLRI is link-local address %s, ignoring", peer->host, inet_ntop(AF_INET6, &p.u.prefix6, buf, @@ -4266,7 +4272,8 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr, if (IN6_IS_ADDR_MULTICAST(&p.u.prefix6)) { char buf[BUFSIZ]; - zlog_err( + flog_err( + BGP_ERR_UPDATE_RCV, "%s: IPv6 unicast NLRI is multicast address %s, ignoring", peer->host, inet_ntop(AF_INET6, &p.u.prefix6, buf, @@ -4295,7 +4302,8 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr, /* Packet length consistency check. */ if (pnt != lim) { - zlog_err( + flog_err( + BGP_ERR_UPDATE_RCV, "%s [Error] Update packet error (prefix length mismatch with total length)", peer->host); return -1; diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c index 6a65f982e..37740671c 100644 --- a/bgpd/bgp_updgrp.c +++ b/bgpd/bgp_updgrp.c @@ -47,6 +47,7 @@ #include "bgpd/bgpd.h" #include "bgpd/bgp_table.h" #include "bgpd/bgp_debug.h" +#include "bgpd/bgp_errors.h" #include "bgpd/bgp_fsm.h" #include "bgpd/bgp_advertise.h" #include "bgpd/bgp_packet.h" @@ -1630,8 +1631,9 @@ void update_group_adjust_peer(struct peer_af *paf) if (!updgrp) { updgrp = update_group_create(paf); if (!updgrp) { - zlog_err("couldn't create update group for peer %s", - paf->peer->host); + flog_err(BGP_ERR_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 34ddbfcd1..c0761503f 100644 --- a/bgpd/bgp_updgrp_packet.c +++ b/bgpd/bgp_updgrp_packet.c @@ -46,6 +46,7 @@ #include "bgpd/bgpd.h" #include "bgpd/bgp_debug.h" +#include "bgpd/bgp_errors.h" #include "bgpd/bgp_fsm.h" #include "bgpd/bgp_route.h" #include "bgpd/bgp_packet.h" @@ -786,7 +787,8 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp) * NLRI then * return */ if (space_remaining < space_needed) { - zlog_err( + flog_err( + BGP_ERR_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 e3efbbf25..e12d9ec34 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -45,6 +45,7 @@ #include "bgpd/bgp_lcommunity.h" #include "bgpd/bgp_damp.h" #include "bgpd/bgp_debug.h" +#include "bgpd/bgp_errors.h" #include "bgpd/bgp_fsm.h" #include "bgpd/bgp_nexthop.h" #include "bgpd/bgp_open.h" @@ -10754,7 +10755,8 @@ static void bgp_show_all_instances_neighbors_vty(struct vty *vty, for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { if (use_json) { if (!(json = json_object_new_object())) { - zlog_err( + flog_err( + BGP_ERR_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 9591fe673..59659c918 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -44,6 +44,7 @@ #include "bgpd/bgp_zebra.h" #include "bgpd/bgp_fsm.h" #include "bgpd/bgp_debug.h" +#include "bgpd/bgp_errors.h" #include "bgpd/bgp_mpath.h" #include "bgpd/bgp_nexthop.h" #include "bgpd/bgp_nht.h" @@ -1077,7 +1078,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) { - zlog_err("BGP: Error getting table chunk %u", chunk_size); + flog_err(BGP_ERR_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]", @@ -2381,9 +2383,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) { - zlog_err("%u:Recv MACIP %s with invalid IP addr length %d", - vrf_id, (command == ZEBRA_MACIP_ADD) ? "Add" : "Del", - ipa_len); + 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); return -1; } @@ -2473,11 +2476,13 @@ static void bgp_zebra_process_label_chunk( STREAM_GETL(s, last); if (zclient->redist_default != proto) { - zlog_err("Got LM msg with wrong proto %u", proto); + flog_err(BGP_ERR_LM_ERROR, "Got LM msg with wrong proto %u", + proto); return; } if (zclient->instance != instance) { - zlog_err("Got LM msg with wrong instance %u", proto); + flog_err(BGP_ERR_LM_ERROR, "Got LM msg with wrong instance %u", + proto); return; } @@ -2485,8 +2490,8 @@ static void bgp_zebra_process_label_chunk( first < MPLS_LABEL_UNRESERVED_MIN || last > MPLS_LABEL_UNRESERVED_MAX) { - zlog_err("%s: Invalid Label chunk: %u - %u", - __func__, first, last); + flog_err(BGP_ERR_LM_ERROR, "%s: Invalid Label chunk: %u - %u", + __func__, first, last); return; } if (BGP_DEBUG(zebra, ZEBRA)) { diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 82da0245b..555dd2a49 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -52,6 +52,7 @@ #include "bgpd/bgp_route.h" #include "bgpd/bgp_dump.h" #include "bgpd/bgp_debug.h" +#include "bgpd/bgp_errors.h" #include "bgpd/bgp_community.h" #include "bgpd/bgp_attr.h" #include "bgpd/bgp_regex.h" @@ -683,12 +684,6 @@ struct peer_af *peer_af_create(struct peer *peer, afi_t afi, safi_t safi) /* Allocate new peer af */ af = XCALLOC(MTYPE_BGP_PEER_AF, sizeof(struct peer_af)); - if (af == NULL) { - zlog_err("Could not create af structure for peer %s", - peer->host); - return NULL; - } - peer->peer_af_array[afid] = af; af->afi = afi; af->safi = safi; @@ -1809,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)) { - zlog_err("%s was called for peer-group %s", __func__, - peer->host); + flog_err(BGP_ERR_PEER_GROUP, "%s was called for peer-group %s", + __func__, peer->host); return 1; } @@ -1923,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)) { - zlog_err("%s was called for peer-group %s", __func__, - peer->host); + flog_err(BGP_ERR_PEER_GROUP, "%s was called for peer-group %s", + __func__, peer->host); return 1; } @@ -1936,8 +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) { - zlog_err("couldn't delete af structure for peer %s", - peer->host); + flog_err(BGP_ERR_PEER_DELETE, + "couldn't delete af structure for peer %s", + peer->host); return 1; } @@ -1986,8 +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) { - zlog_err("couldn't delete af structure for peer %s", - peer->host); + flog_err(BGP_ERR_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/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index a1f1169a7..355cf9205 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -32,6 +32,7 @@ #include "lib/command.h" #include "lib/stream.h" #include "lib/ringbuf.h" +#include "lib/lib_errors.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_ecommunity.h" @@ -3933,7 +3934,8 @@ void *rfapi_rfp_init_group_config_ptr_vty(void *rfp_start_val, size); break; default: - zlog_err("%s: Unknown group type=%d", __func__, type); + flog_err(LIB_ERR_DEVELOPMENT, "%s: Unknown group type=%d", + __func__, type); /* should never happen */ assert("Unknown type" == NULL); break; @@ -4047,7 +4049,8 @@ void *rfapi_rfp_get_group_config_ptr_name( criteria, search_cb); break; default: - zlog_err("%s: Unknown group type=%d", __func__, type); + flog_err(LIB_ERR_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 c1af269d3..ac3b6da23 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -34,6 +34,7 @@ #include "lib/skiplist.h" #include "lib/thread.h" #include "lib/stream.h" +#include "lib/lib_errors.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_ecommunity.h" @@ -3028,7 +3029,7 @@ static void rfapiBgpInfoFilteredImportEncap( break; default: - zlog_err("%s: bad afi %d", __func__, afi); + flog_err(LIB_ERR_DEVELOPMENT, "%s: bad afi %d", __func__, afi); return; } @@ -3485,7 +3486,7 @@ void rfapiBgpInfoFilteredImportVPN( break; default: - zlog_err("%s: bad afi %d", __func__, afi); + flog_err(LIB_ERR_DEVELOPMENT, "%s: bad afi %d", __func__, afi); return; } @@ -3890,7 +3891,8 @@ rfapiBgpInfoFilteredImportFunction(safi_t safi) default: /* not expected */ - zlog_err("%s: bad safi %d", __func__, safi); + flog_err(LIB_ERR_DEVELOPMENT, "%s: bad safi %d", __func__, + safi); return rfapiBgpInfoFilteredImportBadSafi; } } diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c index d4dd34d1d..69426670a 100644 --- a/bgpd/rfapi/vnc_export_bgp.c +++ b/bgpd/rfapi/vnc_export_bgp.c @@ -33,6 +33,7 @@ #include "lib/linklist.h" #include "lib/plist.h" #include "lib/routemap.h" +#include "lib/lib_errors.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_ecommunity.h" @@ -187,7 +188,8 @@ void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct route_node *rn, if (!afi) { - zlog_err("%s: can't get afi of route node", __func__); + flog_err(LIB_ERR_DEVELOPMENT, + "%s: can't get afi of route node", __func__); return; } @@ -333,7 +335,7 @@ void vnc_direct_bgp_del_route_ce(struct bgp *bgp, struct route_node *rn, struct prefix ce_nexthop; if (!afi) { - zlog_err("%s: bad afi", __func__); + flog_err(LIB_ERR_DEVELOPMENT, "%s: bad afi", __func__); return; } @@ -698,7 +700,8 @@ void vnc_direct_bgp_add_prefix(struct bgp *bgp, afi_t afi = family2afi(rn->p.family); if (!afi) { - zlog_err("%s: can't get afi of route node", __func__); + flog_err(LIB_ERR_DEVELOPMENT, + "%s: can't get afi of route node", __func__); return; } @@ -807,7 +810,8 @@ void vnc_direct_bgp_del_prefix(struct bgp *bgp, afi_t afi = family2afi(rn->p.family); if (!afi) { - zlog_err("%s: can't get afi route node", __func__); + flog_err(LIB_ERR_DEVELOPMENT, "%s: can't get afi route node", + __func__); return; } @@ -922,7 +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) { - zlog_err("%s: can't get afi of nve vn addr", __func__); + flog_err(LIB_ERR_DEVELOPMENT, + "%s: can't get afi of nve vn addr", __func__); return; } @@ -974,7 +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 { - zlog_err("%s: bad afi %d", __func__, afi); + flog_err(LIB_ERR_DEVELOPMENT, "%s: bad afi %d", + __func__, afi); return; } @@ -1066,7 +1072,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) { - zlog_err("%s: can't get afi of nve vn addr", __func__); + flog_err(LIB_ERR_DEVELOPMENT, + "%s: can't get afi of nve vn addr", __func__); return; } @@ -1113,7 +1120,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 { - zlog_err("%s: bad afi %d", __func__, afi); + flog_err(LIB_ERR_DEVELOPMENT, "%s: bad afi %d", + __func__, afi); return; } @@ -1288,7 +1296,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 { - zlog_err("%s: bad afi %d", __func__, afi); + flog_err(LIB_ERR_DEVELOPMENT, "%s: bad afi %d", __func__, afi); return; } @@ -1632,7 +1640,8 @@ void vnc_direct_bgp_rh_add_route(struct bgp *bgp, afi_t afi, struct attr *iattr; if (!afi) { - zlog_err("%s: can't get afi of route node", __func__); + flog_err(LIB_ERR_DEVELOPMENT, + "%s: can't get afi of route node", __func__); return; } @@ -1751,7 +1760,8 @@ void vnc_direct_bgp_rh_del_route(struct bgp *bgp, afi_t afi, struct vnc_export_info *eti; if (!afi) { - zlog_err("%s: can't get afi route node", __func__); + flog_err(LIB_ERR_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 156572b57..72363f7cf 100644 --- a/bgpd/rfapi/vnc_import_bgp.c +++ b/bgpd/rfapi/vnc_import_bgp.c @@ -32,6 +32,7 @@ #include "lib/linklist.h" #include "lib/plist.h" #include "lib/routemap.h" +#include "lib/lib_errors.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_ecommunity.h" @@ -602,7 +603,8 @@ static void vnc_import_bgp_add_route_mode_resolve_nve( */ if (!afi) { - zlog_err("%s: can't get afi of prefix", __func__); + flog_err(LIB_ERR_DEVELOPMENT, "%s: can't get afi of prefix", + __func__); return; } @@ -718,7 +720,8 @@ static void vnc_import_bgp_add_route_mode_plain(struct bgp *bgp, } if (!afi) { - zlog_err("%s: can't get afi of prefix", __func__); + flog_err(LIB_ERR_DEVELOPMENT, "%s: can't get afi of prefix", + __func__); return; } @@ -905,7 +908,8 @@ vnc_import_bgp_add_route_mode_nvegroup(struct bgp *bgp, struct prefix *prefix, assert(rfg); if (!afi) { - zlog_err("%s: can't get afi of prefix", __func__); + flog_err(LIB_ERR_DEVELOPMENT, "%s: can't get afi of prefix", + __func__); return; } @@ -2628,7 +2632,8 @@ void vnc_import_bgp_add_route(struct bgp *bgp, struct prefix *prefix, VNC_RHNCK(enter); if (!afi) { - zlog_err("%s: can't get afi of prefix", __func__); + flog_err(LIB_ERR_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 7d564ef11..a2871188e 100644 --- a/bgpd/rfapi/vnc_zebra.c +++ b/bgpd/rfapi/vnc_zebra.c @@ -32,6 +32,7 @@ #include "lib/stream.h" #include "lib/ringbuf.h" #include "lib/memory.h" +#include "lib/lib_errors.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_ecommunity.h" @@ -570,7 +571,8 @@ static void vnc_zebra_add_del_prefix(struct bgp *bgp, return; if (rn->p.family != AF_INET && rn->p.family != AF_INET6) { - zlog_err("%s: invalid route node addr family", __func__); + flog_err(LIB_ERR_DEVELOPMENT, + "%s: invalid route node addr family", __func__); return; } @@ -642,7 +644,8 @@ static void vnc_zebra_add_del_nve(struct bgp *bgp, struct rfapi_descriptor *rfd, return; if (afi != AFI_IP && afi != AFI_IP6) { - zlog_err("%s: invalid vn addr family", __func__); + flog_err(LIB_ERR_DEVELOPMENT, "%s: invalid vn addr family", + __func__); return; } @@ -739,12 +742,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 { - zlog_err("%s: bad afi %d", __func__, afi); + flog_err(LIB_ERR_DEVELOPMENT, "%s: bad afi %d", __func__, afi); return; } if (!family) { - zlog_err("%s: computed bad family: %d", __func__, family); + flog_err(LIB_ERR_DEVELOPMENT, "%s: computed bad family: %d", + __func__, family); return; } |