summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_aspath.c6
-rw-r--r--bgpd/bgp_attr.c44
-rw-r--r--bgpd/bgp_dump.c5
-rw-r--r--bgpd/bgp_errors.c169
-rw-r--r--bgpd/bgp_errors.h27
-rw-r--r--bgpd/bgp_evpn.c23
-rw-r--r--bgpd/bgp_label.c5
-rw-r--r--bgpd/bgp_network.c6
-rw-r--r--bgpd/bgp_nht.c3
-rw-r--r--bgpd/bgp_open.c33
-rw-r--r--bgpd/bgp_packet.c15
-rw-r--r--bgpd/bgp_route.c5
-rw-r--r--bgpd/bgp_routemap.c1
-rw-r--r--bgpd/bgp_updgrp_packet.c6
-rw-r--r--bgpd/bgpd.c1
-rw-r--r--bgpd/rfapi/rfapi.c2
-rw-r--r--bgpd/rfapi/rfapi_import.c6
-rw-r--r--bgpd/rfapi/rfapi_vty.c3
-rw-r--r--bgpd/rfapi/vnc_import_bgp.c10
-rw-r--r--isisd/isis_pdu.c3
-rw-r--r--isisd/isis_tlvs.c6
-rw-r--r--lib/agentx.c3
-rw-r--r--lib/buffer.c17
-rw-r--r--lib/lib_errors.c53
-rw-r--r--lib/lib_errors.h7
-rw-r--r--lib/libfrr.c6
-rw-r--r--lib/log.h2
-rw-r--r--lib/netns_linux.c7
-rw-r--r--lib/network.c11
-rw-r--r--lib/plist.c5
-rw-r--r--lib/privs.c4
-rw-r--r--lib/routemap.c4
-rw-r--r--lib/sigevent.c3
-rw-r--r--lib/sockopt.c61
-rw-r--r--lib/sockunion.c53
-rw-r--r--lib/stream.c22
-rw-r--r--lib/thread.c7
-rw-r--r--lib/vrf.c11
-rw-r--r--lib/vty.c55
-rw-r--r--lib/zclient.c107
-rw-r--r--nhrpd/nhrp_peer.c5
-rw-r--r--ospf6d/ospf6_abr.c3
-rw-r--r--ospfd/ospf_abr.c10
-rw-r--r--ospfd/ospf_apiserver.c13
-rw-r--r--ospfd/ospf_asbr.c11
-rw-r--r--ospfd/ospf_errors.c102
-rw-r--r--ospfd/ospf_errors.h17
-rw-r--r--ospfd/ospf_ext.c119
-rw-r--r--ospfd/ospf_flood.c1
-rw-r--r--ospfd/ospf_ia.c8
-rw-r--r--ospfd/ospf_interface.c2
-rw-r--r--ospfd/ospf_lsa.c80
-rw-r--r--ospfd/ospf_lsdb.c13
-rw-r--r--ospfd/ospf_neighbor.c7
-rw-r--r--ospfd/ospf_network.c67
-rw-r--r--ospfd/ospf_nsm.c6
-rw-r--r--ospfd/ospf_opaque.c198
-rw-r--r--ospfd/ospf_packet.c206
-rw-r--r--ospfd/ospf_ri.c53
-rw-r--r--ospfd/ospf_routemap.c4
-rw-r--r--ospfd/ospf_spf.c4
-rw-r--r--ospfd/ospf_sr.c64
-rw-r--r--ospfd/ospf_te.c87
-rw-r--r--ospfd/ospf_zebra.c6
-rw-r--r--ospfd/ospfd.c14
-rw-r--r--pimd/mtracebis_netlink.c8
-rw-r--r--pimd/pim_cmd.c12
-rw-r--r--pimd/pim_ifchannel.c3
-rw-r--r--pimd/pim_pim.c2
-rw-r--r--ripd/rip_interface.c10
-rw-r--r--ripd/ripd.c2
-rw-r--r--ripngd/ripngd.c7
-rw-r--r--zebra/connected.c19
-rw-r--r--zebra/if_ioctl.c9
-rw-r--r--zebra/if_ioctl_solaris.c30
-rw-r--r--zebra/if_netlink.c31
-rw-r--r--zebra/if_sysctl.c17
-rw-r--r--zebra/interface.c19
-rw-r--r--zebra/ioctl.c1
-rw-r--r--zebra/ioctl_solaris.c5
-rw-r--r--zebra/ipforward_proc.c1
-rw-r--r--zebra/ipforward_solaris.c14
-rw-r--r--zebra/ipforward_sysctl.c18
-rw-r--r--zebra/irdp_interface.c37
-rw-r--r--zebra/irdp_main.c14
-rw-r--r--zebra/irdp_packet.c38
-rw-r--r--zebra/kernel_netlink.c15
-rw-r--r--zebra/kernel_socket.c37
-rw-r--r--zebra/label_manager.c7
-rw-r--r--zebra/redistribute.c24
-rw-r--r--zebra/rt_netlink.c63
-rw-r--r--zebra/rt_socket.c12
-rw-r--r--zebra/rtadv.c66
-rw-r--r--zebra/rtread_getmsg.c33
-rw-r--r--zebra/rtread_sysctl.c7
-rw-r--r--zebra/rule_netlink.c4
-rw-r--r--zebra/rule_socket.c1
-rw-r--r--zebra/zapi_msg.c46
-rw-r--r--zebra/zebra_errors.c429
-rw-r--r--zebra/zebra_errors.h51
-rw-r--r--zebra/zebra_fpm.c3
-rw-r--r--zebra/zebra_mpls.c9
-rw-r--r--zebra/zebra_mpls_openbsd.c26
-rw-r--r--zebra/zebra_netns_id.c5
-rw-r--r--zebra/zebra_netns_notify.c49
-rw-r--r--zebra/zebra_ns.c1
-rw-r--r--zebra/zebra_pbr.c17
-rw-r--r--zebra/zebra_ptm.c39
-rw-r--r--zebra/zebra_pw.c8
-rw-r--r--zebra/zebra_rib.c10
-rw-r--r--zebra/zebra_rnh.c5
-rw-r--r--zebra/zebra_vxlan.c105
-rw-r--r--zebra/zserv.c31
113 files changed, 2219 insertions, 1098 deletions
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c
index d6ad52b3a..b156cda86 100644
--- a/bgpd/bgp_aspath.c
+++ b/bgpd/bgp_aspath.c
@@ -35,9 +35,10 @@
#include "bgpd/bgp_aspath.h"
#include "bgpd/bgp_debug.h"
#include "bgpd/bgp_attr.h"
+#include "bgpd/bgp_errors.h"
/* Attr. Flags and Attr. Type Code. */
-#define AS_HEADER_SIZE 2
+#define AS_HEADER_SIZE 2
/* Now FOUR octets are used for AS value. */
#define AS_VALUE_SIZE sizeof (as_t)
@@ -1638,7 +1639,8 @@ struct aspath *aspath_reconcile_as4(struct aspath *aspath,
if (hops < 0) {
if (BGP_DEBUG(as4, AS4))
- zlog_warn(
+ flog_warn(
+ BGP_WARN_ASPATH_FEWER_HOPS,
"[AS4] Fewer hops in AS_PATH than NEW_AS_PATH");
/* Something's gone wrong. The RFC says we should now ignore
* AS4_PATH,
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index 6acd4c8cf..a603bbcd8 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -1760,7 +1760,8 @@ int bgp_mp_reach_parse(struct bgp_attr_parser_args *args,
{
uint8_t val;
if ((val = stream_getc(s)))
- zlog_warn(
+ flog_warn(
+ BGP_WARN_DEFUNCT_SNPA_LEN,
"%s sent non-zero value, %u, for defunct SNPA-length field",
peer->host, val);
}
@@ -2336,7 +2337,8 @@ static int bgp_attr_check(struct peer *peer, struct attr *attr)
type = BGP_ATTR_LOCAL_PREF;
if (type) {
- zlog_warn("%s Missing well-known attribute %s.", peer->host,
+ flog_warn(BGP_WARN_MISSING_ATTRIBUTE,
+ "%s Missing well-known attribute %s.", peer->host,
lookup_msg(attr_str, type, NULL));
bgp_notify_send_with_data(peer, BGP_NOTIFY_UPDATE_ERR,
BGP_NOTIFY_UPDATE_MISS_ATTR, &type,
@@ -2352,7 +2354,7 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr,
bgp_size_t size, struct bgp_nlri *mp_update,
struct bgp_nlri *mp_withdraw)
{
- int ret;
+ bgp_attr_parse_ret_t ret;
uint8_t flag = 0;
uint8_t type = 0;
bgp_size_t length;
@@ -2377,7 +2379,8 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr,
/* Check remaining length check.*/
if (endp - BGP_INPUT_PNT(peer) < BGP_ATTR_MIN_LEN) {
/* XXX warning: long int format, int arg (arg 5) */
- zlog_warn(
+ flog_warn(
+ BGP_WARN_ATTRIBUTE_TOO_SMALL,
"%s: error BGP attribute length %lu is smaller than min len",
peer->host,
(unsigned long)(endp
@@ -2399,7 +2402,8 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr,
/* Check whether Extended-Length applies and is in bounds */
if (CHECK_FLAG(flag, BGP_ATTR_FLAG_EXTLEN)
&& ((endp - startp) < (BGP_ATTR_MIN_LEN + 1))) {
- zlog_warn(
+ flog_warn(
+ BGP_WARN_EXT_ATTRIBUTE_TOO_SMALL,
"%s: Extended length set, but just %lu bytes of attr header",
peer->host,
(unsigned long)(endp
@@ -2421,7 +2425,8 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr,
List. */
if (CHECK_BITMAP(seen, type)) {
- zlog_warn(
+ flog_warn(
+ BGP_WARN_ATTRIBUTE_REPEATED,
"%s: error BGP attribute type %d appears twice in a message",
peer->host, type);
@@ -2439,7 +2444,8 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr,
attr_endp = BGP_INPUT_PNT(peer) + length;
if (attr_endp > endp) {
- zlog_warn(
+ flog_warn(
+ BGP_WARN_ATTRIBUTE_TOO_LARGE,
"%s: BGP type %d length %d is too large, attribute total length is %d. attr_endp is %p. endp is %p",
peer->host, type, length, size, attr_endp,
endp);
@@ -2503,7 +2509,6 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr,
Attribute Flags Error. The Data field contains the erroneous
attribute (type, length and value). */
if (bgp_attr_flag_invalid(&attr_args)) {
- bgp_attr_parse_ret_t ret;
ret = bgp_attr_malformed(
&attr_args, BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR,
attr_args.total);
@@ -2597,7 +2602,8 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr,
/* If hard error occured immediately return to the caller. */
if (ret == BGP_ATTR_PARSE_ERROR) {
- zlog_warn("%s: Attribute %s, parse error", peer->host,
+ flog_warn(BGP_WARN_ATTRIBUTE_PARSE_ERROR,
+ "%s: Attribute %s, parse error", peer->host,
lookup_msg(attr_str, type, NULL));
if (as4_path)
aspath_unintern(&as4_path);
@@ -2605,7 +2611,8 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr,
}
if (ret == BGP_ATTR_PARSE_WITHDRAW) {
- zlog_warn(
+ flog_warn(
+ BGP_WARN_ATTRIBUTE_PARSE_WITHDRAW,
"%s: Attribute %s, parse error - treating as withdrawal",
peer->host, lookup_msg(attr_str, type, NULL));
if (as4_path)
@@ -2615,7 +2622,8 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr,
/* Check the fetched length. */
if (BGP_INPUT_PNT(peer) != attr_endp) {
- zlog_warn("%s: BGP attribute %s, fetch error",
+ flog_warn(BGP_WARN_ATTRIBUTE_FETCH_ERROR,
+ "%s: BGP attribute %s, fetch error",
peer->host, lookup_msg(attr_str, type, NULL));
bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR,
BGP_NOTIFY_UPDATE_ATTR_LENG_ERR);
@@ -2627,7 +2635,8 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr,
/* Check final read pointer is same as end pointer. */
if (BGP_INPUT_PNT(peer) != endp) {
- zlog_warn("%s: BGP attribute %s, length mismatch", peer->host,
+ flog_warn(BGP_WARN_ATTRIBUTES_MISMATCH,
+ "%s: BGP attribute %s, length mismatch", peer->host,
lookup_msg(attr_str, type, NULL));
bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR,
BGP_NOTIFY_UPDATE_ATTR_LENG_ERR);
@@ -2637,13 +2646,10 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr,
}
/* Check all mandatory well-known attributes are present */
- {
- bgp_attr_parse_ret_t ret;
- if ((ret = bgp_attr_check(peer, attr)) < 0) {
- if (as4_path)
- aspath_unintern(&as4_path);
- return ret;
- }
+ if ((ret = bgp_attr_check(peer, attr)) < 0) {
+ if (as4_path)
+ aspath_unintern(&as4_path);
+ return ret;
}
/*
diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c
index d69b1c46f..49f27d298 100644
--- a/bgpd/bgp_dump.c
+++ b/bgpd/bgp_dump.c
@@ -36,6 +36,7 @@
#include "bgpd/bgp_route.h"
#include "bgpd/bgp_attr.h"
#include "bgpd/bgp_dump.h"
+#include "bgpd/bgp_errors.h"
enum bgp_dump_type {
BGP_DUMP_ALL,
@@ -119,7 +120,7 @@ static FILE *bgp_dump_open_file(struct bgp_dump *bgp_dump)
ret = strftime(realpath, MAXPATHLEN, bgp_dump->filename, tm);
if (ret == 0) {
- zlog_warn("bgp_dump_open_file: strftime error");
+ flog_warn(BGP_WARN_DUMP, "bgp_dump_open_file: strftime error");
return NULL;
}
@@ -131,7 +132,7 @@ static FILE *bgp_dump_open_file(struct bgp_dump *bgp_dump)
bgp_dump->fp = fopen(realpath, "w");
if (bgp_dump->fp == NULL) {
- zlog_warn("bgp_dump_open_file: %s: %s", realpath,
+ flog_warn(BGP_WARN_DUMP, "bgp_dump_open_file: %s: %s", realpath,
strerror(errno));
umask(oldumask);
return NULL;
diff --git a/bgpd/bgp_errors.c b/bgpd/bgp_errors.c
index 50dd001b8..827927f1b 100644
--- a/bgpd/bgp_errors.c
+++ b/bgpd/bgp_errors.c
@@ -24,6 +24,174 @@
#include "bgp_errors.h"
/* clang-format off */
+static struct log_ref ferr_bgp_warn[] = {
+ {
+ .code = BGP_WARN_ASPATH_FEWER_HOPS,
+ .title = "BGP AS-path conversion has failed",
+ .description = "BGP has attempted to convert a AS2 to AS4 path and has failed",
+ .suggestion = "Open an Issue with all relevant log files and restart FRR"
+ },
+ {
+ .code = BGP_WARN_DEFUNCT_SNPA_LEN,
+ .title = "BGP has received a value in a reserved field",
+ .description = "BGP has received a non-zero value in a reserved field that was used for SNPA-length at one point in time",
+ .suggestion = "BGP has peered with either a router that is attempting to send SNPA data or it has received a corrupted packet. If we are peering with a SNPA aware router(unlikely) upgrade that router, else open an Issue after gathering relevant log files",
+ },
+ {
+ .code = BGP_WARN_MISSING_ATTRIBUTE,
+ .title = "BGP has received an update with missing a missing attribute",
+ .description = "BGP received update packets must have some minimum attribute information within them",
+ .suggestion = "Gather log data from this and remote peer and open an Issue with this data",
+ },
+ {
+ .code = BGP_WARN_ATTRIBUTE_TOO_SMALL,
+ .title = "BGP udate packet with attribute data that is too small",
+ .description = "BGP has received an update packet that is too small to parse a given attribute. This typically means that something has gone wrong between us and the remote peer",
+ .suggestion = "Gather log data from this and remote peer and open an Issue with this data",
+ },
+ {
+ .code = BGP_WARN_EXT_ATTRIBUTE_TOO_SMALL,
+ .title = "BGP udate packet with extended attribute data that is too small",
+ .description = "BGP has received an update packet that is too small to parse a given extended attribute. This typically means that something has gone wrong between us and the remote peer",
+ .suggestion = "Gather log data from this and remote peer and open an Issue with this data",
+ },
+ {
+ .code = BGP_WARN_ATTRIBUTE_REPEATED,
+ .title = "BGP update packet received with a repeated attribute",
+ .description = "BGP has received an update packet with a attribute that is repeated more than one time for a particular route. This typically means that something has gone wrong between us and the remote peer",
+ .suggestion = "Gather log data from this and remote peer and open an Issue with this data",
+ },
+ {
+ .code = BGP_WARN_ATTRIBUTE_TOO_LARGE,
+ .title = "BGP udate packet with attribute data that is too large",
+ .description = "BGP has received an update packet that has too much data in a particular attribute. This typically means that something has gone wrong between us and the remote peer",
+ .suggestion = "Gather log data from this and remote peer and open an Issue with this data",
+ },
+ {
+ .code = BGP_WARN_ATTRIBUTE_PARSE_ERROR,
+ .title = "BGP update packet with attribute data has a parse error, specific to the attribute",
+ .description = "BGP has received an update packet with an attribute that when parsed does not make sense in some manner",
+ .suggestion = "Gather log data from this and remote peer and open an Issue with this data",
+ },
+ {
+ .code = BGP_WARN_ATTRIBUTE_PARSE_WITHDRAW,
+ .title = "BGP update packet with a broken optional attribute has caused a withdraw of associated routes",
+ .description = "BGP has received a update packet with optional attributes that did not parse correctly, instead of resetting the peer, withdraw associated routes and note that this has happened",
+ .suggestion = "Gather log data from this and remote peer and open an Issue with this data",
+ },
+ {
+ .code = BGP_WARN_ATTRIBUTE_FETCH_ERROR,
+ .title = "BGP update packet with a broken length",
+ .description = "BGP has received a update packet with an attribute that has an incorrect length",
+ .suggestion = "Gather log data from this and remote peer and open an Issue with this data",
+ },
+ {
+ .code = BGP_WARN_ATTRIBUTES_MISMATCH,
+ .title = "BGP update packet with a length different than attribute data length",
+ .description = "BGP has received a update packet with attributes that when parsed do not correctly add up to packet data length",
+ .suggestion = "Gather log data from this and remote peer and open an Issue with this data",
+ },
+ {
+ .code = BGP_WARN_DUMP,
+ .title = "BGP MRT dump subsystem has encountered an issue",
+ .description = "BGP has found that the attempted write of MRT data to a dump file has failed",
+ .suggestion = "Ensure BGP has permissions to write the specified file",
+ },
+ {
+ .code = BGP_WARN_UPDATE_PACKET_SHORT,
+ .title = "BGP Update Packet is to Small",
+ .description = "The update packet received from a peer is to small",
+ .suggestion = "Determine the source of the update packet and examine that peer for what has gone wrong",
+ },
+ {
+ .code = BGP_WARN_UPDATE_PACKET_LONG,
+ .title = "BGP Update Packet is to large",
+ .description = "The update packet received from a peer is to large",
+ .suggestion = "Determine the source of the update packet and examine that peer for what has gone wrong",
+ },
+ {
+ .code = BGP_WARN_UNRECOGNIZED_CAPABILITY,
+ .title = "Unknown BGP Capability Received",
+ .description = "The negotiation of capabilities has received a capability that we do not know what to do with",
+ .suggestion = "Determine the source of the capability and remove the capability from what is sent",
+ },
+ {
+ .code = BGP_WARN_NO_TCP_MD5,
+ .title = "Unable to set TCP MD5 option on socket",
+ .description = "BGP attempted to setup TCP MD5 configuration on the socket as per configuration but was unable to",
+ .suggestion = "Please collect log files and open Issue",
+ },
+ {
+ .code = BGP_WARN_NO_SOCKOPT_MARK,
+ .title = "Unable to set socket MARK option",
+ .description = "BGP attempted to set the SO_MARK option for a socket and was unable to do so",
+ .suggestion = "Please collect log files and open Issue",
+ },
+ {
+ .code = BGP_WARN_EVPN_PMSI_PRESENT,
+ .title = "BGP Received a EVPN NLRI with PMSI included",
+ .description = "BGP has received a type-3 NLRI with PMSI information. At this time FRR is not capable of properly handling this NLRI type",
+ .suggestion = "Setup peer to not send this type of data to FRR"
+ },
+ {
+ .code = BGP_WARN_EVPN_VPN_VNI,
+ .title = "BGP has received a local macip and cannot properly handle it",
+ .description = "BGP has received a local macip from zebra and has no way to properly handle the macip because the vni is not setup properly",
+ .suggestion = "Ensure proper setup of BGP EVPN",
+ },
+ {
+ .code = BGP_WARN_EVPN_ESI,
+ .title = "BGP has received a local ESI for deletion",
+ .description = "BGP has received a local ESI for deletion but when attempting to find the stored data internally was unable to find the information for deletion",
+ .suggestion = "Gather logging and open an Issue",
+ },
+ {
+ .code = BGP_WARN_INVALID_LABEL_STACK,
+ .title = "BGP has received a label stack in a NLRI that does not have the BOS marked",
+ .description = "BGP when it receives a NLRI with a label stack should have the BOS marked, this received packet does not have this",
+ .suggestion = "Gather log information from here and remote peer and open an Issue",
+ },
+ {
+ .code = BGP_WARN_ZEBRA_SEND,
+ .title = "BGP has attempted to send data to zebra and has failed to do so",
+ .description = "BGP has attempted to send data to zebra but has been unable to do so",
+ .suggestion = "Gather log data, open an Issue and restart FRR"
+ },
+ {
+ .code = BGP_WARN_CAPABILITY_INVALID_LENGTH,
+ .title = "BGP has received a capability with an invalid length",
+ .description = "BGP has received a capability from it's peer who's size is wrong",
+ .suggestion = "Gather log files from here and from peer and open an Issue",
+ },
+ {
+ .code = BGP_WARN_CAPABILITY_INVALID_DATA,
+ .title = "BGP has received capability data with invalid information",
+ .description = "BGP has noticed that during processing of capability information that data was wrong",
+ .suggestion = "Gather log files from here and from peer and open an Issue",
+ },
+ {
+ .code = BGP_WARN_CAPABILITY_VENDOR,
+ .title = "BGP has recieved capability data specific to a particular vendor",
+ .description = "BGP has received a capability that is vendor specific and as such we have no knowledge of how to use this capability in FRR",
+ .suggestion = "On peer turn off this feature"
+ },
+ {
+ .code = BGP_WARN_CAPABILITY_UNKNOWN,
+ .title = "BGP has received capability data for a unknown capability",
+ .description = "BGP has received a capability that it does not know how to decode. This may be due to a new feature that has not been coded into FRR or it may be a bug in the remote peer",
+ .suggestion = "Gather log files from here and from peer and open an Issue",
+ },
+ {
+ .code = BGP_WARN_INVALID_NEXTHOP_LENGTH,
+ .title = "BGP is attempting to write an invalid nexthop length value",
+ .description = "BGP is in the process of building NLRI information for a peer and has discovered an inconsistent internal state",
+ .suggestion = "Gather log files and open an Issue, restart FRR",
+ },
+ {
+ .code = END_FERR,
+ }
+};
+
static struct log_ref ferr_bgp_err[] = {
{
.code = BGP_ERR_ATTR_FLAG,
@@ -303,4 +471,5 @@ static struct log_ref ferr_bgp_err[] = {
void bgp_error_init(void)
{
log_ref_add(ferr_bgp_err);
+ log_ref_add(ferr_bgp_warn);
}
diff --git a/bgpd/bgp_errors.h b/bgpd/bgp_errors.h
index be718d99e..f7db77ac3 100644
--- a/bgpd/bgp_errors.h
+++ b/bgpd/bgp_errors.h
@@ -72,6 +72,33 @@ enum bgp_log_refs {
BGP_ERR_EVPN_INSTANCE_MISMATCH,
BGP_ERR_FLOWSPEC_PACKET,
BGP_ERR_FLOWSPEC_INSTALLATION,
+ BGP_WARN_ASPATH_FEWER_HOPS,
+ BGP_WARN_DEFUNCT_SNPA_LEN,
+ BGP_WARN_MISSING_ATTRIBUTE,
+ BGP_WARN_ATTRIBUTE_TOO_SMALL,
+ BGP_WARN_EXT_ATTRIBUTE_TOO_SMALL,
+ BGP_WARN_ATTRIBUTE_REPEATED,
+ BGP_WARN_ATTRIBUTE_TOO_LARGE,
+ BGP_WARN_ATTRIBUTE_PARSE_ERROR,
+ BGP_WARN_ATTRIBUTE_PARSE_WITHDRAW,
+ BGP_WARN_ATTRIBUTE_FETCH_ERROR,
+ BGP_WARN_ATTRIBUTES_MISMATCH,
+ BGP_WARN_DUMP,
+ BGP_WARN_UPDATE_PACKET_SHORT,
+ BGP_WARN_UPDATE_PACKET_LONG,
+ BGP_WARN_UNRECOGNIZED_CAPABILITY,
+ BGP_WARN_NO_TCP_MD5,
+ BGP_WARN_NO_SOCKOPT_MARK,
+ BGP_WARN_EVPN_PMSI_PRESENT,
+ BGP_WARN_EVPN_VPN_VNI,
+ BGP_WARN_EVPN_ESI,
+ BGP_WARN_INVALID_LABEL_STACK,
+ BGP_WARN_ZEBRA_SEND,
+ BGP_WARN_CAPABILITY_INVALID_LENGTH,
+ BGP_WARN_CAPABILITY_INVALID_DATA,
+ BGP_WARN_CAPABILITY_VENDOR,
+ BGP_WARN_CAPABILITY_UNKNOWN,
+ BGP_WARN_INVALID_NEXTHOP_LENGTH,
};
extern void bgp_error_init(void);
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c
index a104a2e16..3bd566e07 100644
--- a/bgpd/bgp_evpn.c
+++ b/bgpd/bgp_evpn.c
@@ -3683,9 +3683,11 @@ static int process_type3_route(struct peer *peer, afi_t afi, safi_t safi,
if (attr &&
(attr->flag & ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL))) {
if (attr->pmsi_tnl_type != PMSI_TNLTYPE_INGR_REPL) {
- zlog_warn("%u:%s - Rx EVPN Type-3 NLRI with unsupported PTA %d",
- peer->bgp->vrf_id, peer->host,
- attr->pmsi_tnl_type);
+ flog_warn(
+ BGP_WARN_EVPN_PMSI_PRESENT,
+ "%u:%s - Rx EVPN Type-3 NLRI with unsupported PTA %d",
+ peer->bgp->vrf_id, peer->host,
+ attr->pmsi_tnl_type);
}
}
@@ -5162,7 +5164,8 @@ int bgp_evpn_local_macip_del(struct bgp *bgp, vni_t vni, struct ethaddr *mac,
/* Lookup VNI hash - should exist. */
vpn = bgp_evpn_lookup_vni(bgp, vni);
if (!vpn || !is_vni_live(vpn)) {
- zlog_warn("%u: VNI hash entry for VNI %u %s at MACIP DEL",
+ flog_warn(BGP_WARN_EVPN_VPN_VNI,
+ "%u: VNI hash entry for VNI %u %s at MACIP DEL",
bgp->vrf_id, vni, vpn ? "not live" : "not found");
return -1;
}
@@ -5186,7 +5189,8 @@ int bgp_evpn_local_macip_add(struct bgp *bgp, vni_t vni, struct ethaddr *mac,
/* Lookup VNI hash - should exist. */
vpn = bgp_evpn_lookup_vni(bgp, vni);
if (!vpn || !is_vni_live(vpn)) {
- zlog_warn("%u: VNI hash entry for VNI %u %s at MACIP ADD",
+ flog_warn(BGP_WARN_EVPN_VPN_VNI,
+ "%u: VNI hash entry for VNI %u %s at MACIP ADD",
bgp->vrf_id, vni, vpn ? "not live" : "not found");
return -1;
}
@@ -5398,7 +5402,8 @@ int bgp_evpn_local_vni_del(struct bgp *bgp, vni_t vni)
vpn = bgp_evpn_lookup_vni(bgp, vni);
if (!vpn) {
if (bgp_debug_zebra(NULL))
- zlog_warn(
+ flog_warn(
+ BGP_WARN_EVPN_VPN_VNI,
"%u: VNI hash entry for VNI %u not found at DEL",
bgp->vrf_id, vni);
return 0;
@@ -5529,9 +5534,9 @@ int bgp_evpn_local_es_del(struct bgp *bgp,
/* Lookup ESI hash - should exist. */
es = bgp_evpn_lookup_es(bgp, esi);
if (!es) {
- zlog_warn("%u: ESI hash entry for ESI %s at Local ES DEL",
- bgp->vrf_id,
- esi_to_str(esi, buf, sizeof(buf)));
+ flog_warn(BGP_WARN_EVPN_ESI,
+ "%u: ESI hash entry for ESI %s at Local ES DEL",
+ bgp->vrf_id, esi_to_str(esi, buf, sizeof(buf)));
return -1;
}
diff --git a/bgpd/bgp_label.c b/bgpd/bgp_label.c
index 633e58933..c32df275a 100644
--- a/bgpd/bgp_label.c
+++ b/bgpd/bgp_label.c
@@ -187,11 +187,12 @@ static int bgp_nlri_get_labels(struct peer *peer, uint8_t *pnt, uint8_t plen,
/* If we RX multiple labels we will end up keeping only the last
* one. We do not yet support a label stack greater than 1. */
if (label_depth > 1)
- zlog_warn("%s rcvd UPDATE with label stack %d deep", peer->host,
+ zlog_info("%s rcvd UPDATE with label stack %d deep", peer->host,
label_depth);
if (!(bgp_is_withdraw_label(label) || label_bos(label)))
- zlog_warn(
+ flog_warn(
+ BGP_WARN_INVALID_LABEL_STACK,
"%s rcvd UPDATE with invalid label stack - no bottom of stack",
peer->host);
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index 22d5d35c8..96d2e2f2a 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -84,7 +84,8 @@ static int bgp_md5_set_socket(int socket, union sockunion *su,
#endif /* HAVE_TCP_MD5SIG */
if (ret < 0)
- zlog_warn("can't set TCP_MD5SIG option on socket %d: %s",
+ flog_warn(BGP_WARN_NO_TCP_MD5,
+ "can't set TCP_MD5SIG option on socket %d: %s",
socket, safe_strerror(en));
return ret;
@@ -561,7 +562,8 @@ int bgp_connect(struct peer *peer)
sockopt_reuseaddr(peer->fd);
sockopt_reuseport(peer->fd);
if (sockopt_mark_default(peer->fd, DATAPLANE_MARK, &bgpd_privs) < 0)
- zlog_warn("Unable to set mark on FD for peer %s, err=%s",
+ flog_warn(BGP_WARN_NO_SOCKOPT_MARK,
+ "Unable to set mark on FD for peer %s, err=%s",
peer->host, safe_strerror(errno));
#ifdef IPTOS_PREC_INTERNETCONTROL
diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c
index 0c0c07995..cf055fd43 100644
--- a/bgpd/bgp_nht.c
+++ b/bgpd/bgp_nht.c
@@ -592,7 +592,8 @@ static void sendmsg_zebra_rnh(struct bgp_nexthop_cache *bnc, int command)
bnc->bgp->vrf_id);
/* TBD: handle the failure */
if (ret < 0)
- zlog_warn("sendmsg_nexthop: zclient_send_message() failed");
+ flog_warn(BGP_WARN_ZEBRA_SEND,
+ "sendmsg_nexthop: zclient_send_message() failed");
if ((command == ZEBRA_NEXTHOP_REGISTER)
|| (command == ZEBRA_IMPORT_ROUTE_REGISTER))
diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c
index 5bdee5f51..2a32f02f4 100644
--- a/bgpd/bgp_open.c
+++ b/bgpd/bgp_open.c
@@ -254,7 +254,8 @@ static int bgp_capability_mp(struct peer *peer, struct capability_header *hdr)
/* Verify length is 4 */
if (hdr->length != 4) {
- zlog_warn(
+ flog_warn(
+ BGP_WARN_CAPABILITY_INVALID_LENGTH,
"MP Cap: Received invalid length %d, non-multiple of 4",
hdr->length);
return -1;
@@ -449,7 +450,8 @@ static int bgp_capability_restart(struct peer *peer,
/* Verify length is a multiple of 4 */
if ((caphdr->length - 2) % 4) {
- zlog_warn(
+ flog_warn(
+ BGP_WARN_CAPABILITY_INVALID_LENGTH,
"Restart Cap: Received invalid length %d, non-multiple of 4",
caphdr->length);
return -1;
@@ -546,7 +548,8 @@ static int bgp_capability_addpath(struct peer *peer,
/* Verify length is a multiple of 4 */
if (hdr->length % 4) {
- zlog_warn(
+ flog_warn(
+ BGP_WARN_CAPABILITY_INVALID_LENGTH,
"Add Path: Received invalid length %d, non-multiple of 4",
hdr->length);
return -1;
@@ -604,7 +607,8 @@ static int bgp_capability_enhe(struct peer *peer, struct capability_header *hdr)
/* Verify length is a multiple of 4 */
if (hdr->length % 6) {
- zlog_warn(
+ flog_warn(
+ BGP_WARN_CAPABILITY_INVALID_LENGTH,
"Extended NH: Received invalid length %d, non-multiple of 6",
hdr->length);
return -1;
@@ -646,7 +650,8 @@ static int bgp_capability_enhe(struct peer *peer, struct capability_header *hdr)
if (afi != AFI_IP || nh_afi != AFI_IP6
|| !(safi == SAFI_UNICAST
|| safi == SAFI_LABELED_UNICAST)) {
- zlog_warn(
+ flog_warn(
+ BGP_WARN_CAPABILITY_INVALID_DATA,
"%s Unexpected afi/safi/next-hop afi: %u/%u/%u "
"in Extended Next-hop capability, ignoring",
peer->host, pkt_afi, pkt_safi, pkt_nh_afi);
@@ -677,7 +682,8 @@ static int bgp_capability_hostname(struct peer *peer,
len = stream_getc(s);
if (stream_get_getp(s) + len > end) {
- zlog_warn(
+ flog_warn(
+ BGP_WARN_CAPABILITY_INVALID_DATA,
"%s: Received malformed hostname capability from peer %s",
__FUNCTION__, peer->host);
return -1;
@@ -707,7 +713,8 @@ static int bgp_capability_hostname(struct peer *peer,
}
if (stream_get_getp(s) + 1 > end) {
- zlog_warn(
+ flog_warn(
+ BGP_WARN_CAPABILITY_INVALID_DATA,
"%s: Received invalid domain name len (hostname capability) from peer %s",
__FUNCTION__, peer->host);
return -1;
@@ -715,7 +722,8 @@ static int bgp_capability_hostname(struct peer *peer,
len = stream_getc(s);
if (stream_get_getp(s) + len > end) {
- zlog_warn(
+ flog_warn(
+ BGP_WARN_CAPABILITY_INVALID_DATA,
"%s: Received runt domain name (hostname capability) from peer %s",
__FUNCTION__, peer->host);
return -1;
@@ -952,10 +960,12 @@ static int bgp_capability_parse(struct peer *peer, size_t length,
specific
capabilities. It seems reasonable for now...
*/
- zlog_warn("%s Vendor specific capability %d",
+ flog_warn(BGP_WARN_CAPABILITY_VENDOR,
+ "%s Vendor specific capability %d",
peer->host, caphdr.code);
} else {
- zlog_warn(
+ flog_warn(
+ BGP_WARN_CAPABILITY_UNKNOWN,
"%s unrecognized capability code: %d - ignored",
peer->host, caphdr.code);
memcpy(*error, sp, caphdr.length + 2);
@@ -970,7 +980,8 @@ static int bgp_capability_parse(struct peer *peer, size_t length,
}
if (stream_get_getp(s) != (start + caphdr.length)) {
if (stream_get_getp(s) > (start + caphdr.length))
- zlog_warn(
+ flog_warn(
+ BGP_WARN_CAPABILITY_INVALID_LENGTH,
"%s Cap-parser for %s read past cap-length, %u!",
peer->host,
lookup_msg(capcode_str, caphdr.code,
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index bb474b9e2..d8bab6041 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -1457,9 +1457,9 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size)
/* Attribute total length check. */
if (stream_pnt(s) + 2 > end) {
- zlog_warn(
- "%s [Error] Packet Error"
- " (update packet is short for attribute length)",
+ flog_warn(
+ BGP_WARN_UPDATE_PACKET_SHORT,
+ "%s [Error] Packet Error (update packet is short for attribute length)",
peer->host);
bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR,
BGP_NOTIFY_UPDATE_MAL_ATTR);
@@ -1471,9 +1471,9 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size)
/* Attribute length check. */
if (stream_pnt(s) + attribute_len > end) {
- zlog_warn(
- "%s [Error] Packet Error"
- " (update packet attribute length overflow %d)",
+ flog_warn(
+ BGP_WARN_UPDATE_PACKET_LONG,
+ "%s [Error] Packet Error (update packet attribute length overflow %d)",
peer->host, attribute_len);
bgp_notify_send(peer, BGP_NOTIFY_UPDATE_ERR,
BGP_NOTIFY_UPDATE_MAL_ATTR);
@@ -2104,7 +2104,8 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
return BGP_Stop;
}
} else {
- zlog_warn(
+ flog_warn(
+ BGP_WARN_UNRECOGNIZED_CAPABILITY,
"%s unrecognized capability code: %d - ignored",
peer->host, hdr->code);
}
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 2107d1f9f..4c2df0dd0 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -4040,7 +4040,6 @@ void bgp_clear_stale_route(struct peer *peer, afi_t afi, safi_t safi)
for (rn = bgp_table_top(peer->bgp->rib[afi][safi]); rn;
rn = bgp_route_next(rn)) {
struct bgp_node *rm;
- struct bgp_info *ri;
/* look for neighbor in tables */
if ((table = rn->info) == NULL)
@@ -4728,7 +4727,6 @@ static void bgp_static_update_safi(struct bgp *bgp, struct prefix *p,
break;
if (ri) {
- union gw_addr add;
memset(&add, 0, sizeof(union gw_addr));
if (attrhash_cmp(ri->attr, attr_new)
&& overlay_index_equal(afi, ri, bgp_static->eth_s_id, &add)
@@ -8291,8 +8289,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
continue;
}
if (type == bgp_show_type_prefix_longer) {
- struct prefix *p = output_arg;
-
+ p = output_arg;
if (!prefix_match(p, &rn->p))
continue;
}
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index bee4fca70..0b4355805 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -3086,7 +3086,6 @@ static void bgp_route_map_process_update(struct bgp *bgp, const char *rmap_name,
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
struct list *red_list;
- struct listnode *node;
struct bgp_redist *red;
red_list = bgp->redist[afi][i];
diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c
index c0761503f..f3047369b 100644
--- a/bgpd/bgp_updgrp_packet.c
+++ b/bgpd/bgp_updgrp_packet.c
@@ -427,7 +427,8 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
break;
default:
/* TODO: handle IPv6 nexthops */
- zlog_warn(
+ flog_warn(
+ BGP_WARN_INVALID_NEXTHOP_LENGTH,
"%s: %s: invalid MP nexthop length (AFI IP): %u",
__func__, peer->host, nhlen);
stream_free(s);
@@ -532,7 +533,8 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
break;
default:
/* TODO: handle IPv4 nexthops */
- zlog_warn(
+ flog_warn(
+ BGP_WARN_INVALID_NEXTHOP_LENGTH,
"%s: %s: invalid MP nexthop length (AFI IP6): %u",
__func__, peer->host, nhlen);
stream_free(s);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index a9707a7fc..066db1c77 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -7332,7 +7332,6 @@ static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi,
}
if (CHECK_FLAG(bgp->af_flags[afi][safi],
BGP_CONFIG_VRF_TO_VRF_IMPORT)) {
- struct listnode *node;
char *name;
for (ALL_LIST_ELEMENTS_RO(
diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c
index 51504bb0a..18c3c6385 100644
--- a/bgpd/rfapi/rfapi.c
+++ b/bgpd/rfapi/rfapi.c
@@ -459,8 +459,6 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
rfapiProcessWithdraw(peer, rfd, p, prd, NULL, afi, safi, type, kill);
if (bi) {
- char buf[PREFIX_STRLEN];
-
prefix2str(p, buf, sizeof(buf));
vnc_zlog_debug_verbose(
"%s: Found route (safi=%d) to delete at prefix %s",
diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c
index 4601718f1..f014f16fc 100644
--- a/bgpd/rfapi/rfapi_import.c
+++ b/bgpd/rfapi/rfapi_import.c
@@ -3678,12 +3678,12 @@ void rfapiBgpInfoFilteredImportVPN(
rfapiCopyUnEncap2VPN(ern->info, info_new);
agg_unlock_node(ern); /* undo lock in route_note_match */
} else {
- char buf[PREFIX_STRLEN];
+ char bpf[PREFIX_STRLEN];
- prefix2str(&vn_prefix, buf, sizeof(buf));
+ prefix2str(&vn_prefix, bpf, sizeof(bpf));
/* Not a big deal, just means VPN route got here first */
vnc_zlog_debug_verbose("%s: no encap route for vn addr %s",
- __func__, buf);
+ __func__, bpf);
info_new->extra->vnc.import.un_family = 0;
}
diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c
index cd751319e..9f8270097 100644
--- a/bgpd/rfapi/rfapi_vty.c
+++ b/bgpd/rfapi/rfapi_vty.c
@@ -666,7 +666,6 @@ void rfapiPrintBi(void *stream, struct bgp_info *bi)
HVTYNL);
}
if (bi->extra && bi->extra->vnc.import.aux_prefix.family) {
- char buf[BUFSIZ];
const char *sp;
sp = rfapi_ntop(bi->extra->vnc.import.aux_prefix.family,
@@ -3179,8 +3178,6 @@ static int rfapiDeleteLocalPrefixesByRFD(struct rfapi_local_reg_delete_arg *cda,
list_delete_all_node(adb_delete_list);
if (!(pPrefix && !RFAPI_0_PREFIX(pPrefix))) {
- void *cursor;
-
/*
* Caller didn't specify a prefix, or specified
* (0/32 or 0/128)
diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c
index 6022e4cc2..dc37ff89b 100644
--- a/bgpd/rfapi/vnc_import_bgp.c
+++ b/bgpd/rfapi/vnc_import_bgp.c
@@ -1010,13 +1010,13 @@ vnc_import_bgp_add_route_mode_nvegroup(struct bgp *bgp, struct prefix *prefix,
bgp_attr_dup(&hattr, attr); /* hattr becomes a ghost attr */
if (rmap) {
- struct bgp_info info;
+ struct bgp_info binfo;
route_map_result_t ret;
- memset(&info, 0, sizeof(info));
- info.peer = peer;
- info.attr = &hattr;
- ret = route_map_apply(rmap, prefix, RMAP_BGP, &info);
+ memset(&binfo, 0, sizeof(binfo));
+ binfo.peer = peer;
+ binfo.attr = &hattr;
+ ret = route_map_apply(rmap, prefix, RMAP_BGP, &binfo);
if (ret == RMAP_DENYMATCH) {
bgp_attr_flush(&hattr);
vnc_zlog_debug_verbose(
diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c
index 88575f531..a335a96cd 100644
--- a/isisd/isis_pdu.c
+++ b/isisd/isis_pdu.c
@@ -1311,8 +1311,7 @@ static int process_snp(uint8_t pdu_type, struct isis_circuit *circuit,
continue;
}
}
- struct isis_lsp *lsp =
- lsp_new(circuit->area, entry->id,
+ lsp = lsp_new(circuit->area, entry->id,
entry->rem_lifetime, 0, 0,
entry->checksum, lsp0, level);
lsp_insert(lsp,
diff --git a/isisd/isis_tlvs.c b/isisd/isis_tlvs.c
index b22460a0b..782462766 100644
--- a/isisd/isis_tlvs.c
+++ b/isisd/isis_tlvs.c
@@ -1904,9 +1904,9 @@ static void format_item_auth(uint16_t mtid, struct isis_item *i,
sbuf_push(buf, indent, " Password: %s\n", obuf);
break;
case ISIS_PASSWD_TYPE_HMAC_MD5:
- for (unsigned int i = 0; i < 16; i++) {
- snprintf(obuf + 2 * i, sizeof(obuf) - 2 * i,
- "%02" PRIx8, auth->value[i]);
+ for (unsigned int j = 0; j < 16; j++) {
+ snprintf(obuf + 2 * j, sizeof(obuf) - 2 * j,
+ "%02" PRIx8, auth->value[j]);
}
sbuf_push(buf, indent, " HMAC-MD5: %s\n", obuf);
break;
diff --git a/lib/agentx.c b/lib/agentx.c
index 8e6493d4d..c319649e3 100644
--- a/lib/agentx.c
+++ b/lib/agentx.c
@@ -158,7 +158,8 @@ static int agentx_log_callback(int major, int minor, void *serverarg,
"snmp[err]: %s", msg ? msg : slm->msg);
break;
case LOG_WARNING:
- zlog_warn("snmp[warning]: %s", msg ? msg : slm->msg);
+ flog_warn(LIB_WARN_SNMP, "snmp[warning]: %s",
+ msg ? msg : slm->msg);
break;
case LOG_NOTICE:
zlog_notice("snmp[notice]: %s", msg ? msg : slm->msg);
diff --git a/lib/buffer.c b/lib/buffer.c
index 446bad85e..11bacf83b 100644
--- a/lib/buffer.c
+++ b/lib/buffer.c
@@ -365,8 +365,9 @@ buffer_status_t buffer_flush_window(struct buffer *b, int fd, int width,
iov_size =
((iov_index > IOV_MAX) ? IOV_MAX : iov_index);
if ((nbytes = writev(fd, c_iov, iov_size)) < 0) {
- zlog_warn("%s: writev to fd %d failed: %s",
- __func__, fd, safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "%s: writev to fd %d failed: %s",
+ __func__, fd, safe_strerror(errno));
break;
}
@@ -377,8 +378,8 @@ buffer_status_t buffer_flush_window(struct buffer *b, int fd, int width,
}
#else /* IOV_MAX */
if ((nbytes = writev(fd, iov, iov_index)) < 0)
- zlog_warn("%s: writev to fd %d failed: %s", __func__, fd,
- safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET, "%s: writev to fd %d failed: %s",
+ __func__, fd, safe_strerror(errno));
#endif /* IOV_MAX */
/* Free printed buffer data. */
@@ -438,8 +439,8 @@ in one shot. */
if (ERRNO_IO_RETRY(errno))
/* Calling code should try again later. */
return BUFFER_PENDING;
- zlog_warn("%s: write error on fd %d: %s", __func__, fd,
- safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET, "%s: write error on fd %d: %s",
+ __func__, fd, safe_strerror(errno));
return BUFFER_ERROR;
}
@@ -492,8 +493,8 @@ buffer_status_t buffer_write(struct buffer *b, int fd, const void *p,
if (ERRNO_IO_RETRY(errno))
nbytes = 0;
else {
- zlog_warn("%s: write error on fd %d: %s", __func__, fd,
- safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET, "%s: write error on fd %d: %s",
+ __func__, fd, safe_strerror(errno));
return BUFFER_ERROR;
}
}
diff --git a/lib/lib_errors.c b/lib/lib_errors.c
index 2ddc571e6..a608aa9e6 100644
--- a/lib/lib_errors.c
+++ b/lib/lib_errors.c
@@ -25,6 +25,54 @@
#include "lib_errors.h"
/* clang-format off */
+static struct log_ref ferr_lib_warn[] = {
+ {
+ .code = LIB_WARN_SNMP,
+ .title = "SNMP has discovered a warning",
+ .description = "The SNMP AgentX library has returned a warning that we should report to the end user",
+ .suggestion = "Gather Log data and open an Issue.",
+ },
+ {
+ .code = LIB_WARN_STREAM,
+ .title = "The stream subsystem has encountered an error",
+ .description = "During sanity checking stream.c has detected an error in the data associated with a particular stream",
+ .suggestion = "Gather log data and open an Issue, restart FRR",
+ },
+ {
+ .code = LIB_WARN_LINUX_NS,
+ .title = "The Linux namespace subsystem has encountered a parsing error",
+ .description = "During system startup an invalid parameter for the namesapce was give to FRR",
+ .suggestion = "Gather log data and open an Issue. restart FRR",
+ },
+ {
+ .code = LIB_WARN_SLOW_THREAD,
+ .title = "The Event subsystem has detected a slow process",
+ .description = "The Event subsystem has detected a slow process, this typically indicates that FRR is having trouble completing work in a timely manner. This can be either a misconfiguration, bug, or some combination therof.",
+ .suggestion = "Gather log data and open an Issue",
+ },
+ {
+ .code = LIB_WARN_RMAP_RECURSION_LIMIT,
+ .title = "Reached the Route-Map Recursion Limit",
+ .description = "The Route-Map subsystem has detected a route-map depth of RMAP_RECURSION_LIMIT and has stopped processing",
+ .suggestion = "Re-work the Route-Map in question to not have so many route-map statements, or recompile FRR with a higher limit",
+ },
+ {
+ .code = LIB_WARN_BACKUP_CONFIG,
+ .title = "Unable to open configuration file",
+ .description = "The config subsystem attempted to read in it's configuration file which failed, so we are falling back to the backup config file to see if it is available",
+ .suggestion = "Create configuration file",
+ },
+ {
+ .code = LIB_WARN_VRF_LENGTH,
+ .title = "The VRF subsystem has encountered a parsing error",
+ .description = "The VRF subsystem, during initialization, has found a parsing error with input it has received",
+ .suggestion = "Check the length of the vrf name and adjust accordingly",
+ },
+ {
+ .code = END_FERR,
+ },
+};
+
static struct log_ref ferr_lib_err[] = {
{
.code = LIB_ERR_PRIVILEGES,
@@ -42,7 +90,7 @@ static struct log_ref ferr_lib_err[] = {
.code = LIB_ERR_SOCKET,
.title = "Socket Error",
.description = "When attempting to access a socket a system error has occured and we were unable to properly complete the request",
- .suggestion = "Ensure that there are sufficient system resources available and ensure that the frr user has sufficient permisions to work",
+ .suggestion = "Ensure that there are sufficient system resources available and ensure that the frr user has sufficient permisions to work. If necessary open an Issue",
},
{
.code = LIB_ERR_ZAPI_MISSMATCH,
@@ -54,7 +102,7 @@ static struct log_ref ferr_lib_err[] = {
.code = LIB_ERR_ZAPI_ENCODE,
.title = "ZAPI Error",
.description = "The ZAPI subsystem has detected an encoding issue, between zebra and a client protocol",
- .suggestion = "Restart FRR"
+ .suggestion = "Gather data and open an Issue, also Restart FRR"
},
{
.code = LIB_ERR_ZAPI_SOCKET,
@@ -118,5 +166,6 @@ static struct log_ref ferr_lib_err[] = {
void lib_error_init(void)
{
+ log_ref_add(ferr_lib_warn);
log_ref_add(ferr_lib_err);
}
diff --git a/lib/lib_errors.h b/lib/lib_errors.h
index 84f5b8dc1..dcaf888e1 100644
--- a/lib/lib_errors.h
+++ b/lib/lib_errors.h
@@ -38,6 +38,13 @@ enum lib_log_refs {
LIB_ERR_DEVELOPMENT,
LIB_ERR_ZMQ,
LIB_ERR_UNAVAILABLE,
+ LIB_WARN_SNMP,
+ LIB_WARN_STREAM,
+ LIB_WARN_LINUX_NS,
+ LIB_WARN_SLOW_THREAD,
+ LIB_WARN_RMAP_RECURSION_LIMIT,
+ LIB_WARN_BACKUP_CONFIG,
+ LIB_WARN_VRF_LENGTH,
};
extern void lib_error_init(void);
diff --git a/lib/libfrr.c b/lib/libfrr.c
index 61f5fa708..ecdc27757 100644
--- a/lib/libfrr.c
+++ b/lib/libfrr.c
@@ -543,13 +543,15 @@ static void frr_mkdir(const char *path, bool strip)
if (errno == EEXIST)
return;
- zlog_warn("failed to mkdir \"%s\": %s", path, strerror(errno));
+ flog_err(LIB_ERR_SYSTEM_CALL, "failed to mkdir \"%s\": %s",
+ path, strerror(errno));
return;
}
zprivs_get_ids(&ids);
if (chown(path, ids.uid_normal, ids.gid_normal))
- zlog_warn("failed to chown \"%s\": %s", path, strerror(errno));
+ flog_err(LIB_ERR_SYSTEM_CALL, "failed to chown \"%s\": %s",
+ path, strerror(errno));
}
static struct thread_master *master;
diff --git a/lib/log.h b/lib/log.h
index 7d05b8464..be1d9fb59 100644
--- a/lib/log.h
+++ b/lib/log.h
@@ -90,6 +90,8 @@ extern void zlog_debug(const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
zlog_err("[EC %"PRIu32"] " format, ferr_id, ##__VA_ARGS__)
#define flog_err_sys(ferr_id, format, ...) \
flog_err(ferr_id, format, ##__VA_ARGS__)
+#define flog_warn(ferr_id, format, ...) \
+ zlog_warn("[EC %"PRIu32"] " format, ferr_id, ##__VA_ARGS__)
extern void zlog_thread_info(int log_level);
diff --git a/lib/netns_linux.c b/lib/netns_linux.c
index 33338ac89..e3170fee1 100644
--- a/lib/netns_linux.c
+++ b/lib/netns_linux.c
@@ -441,8 +441,8 @@ char *ns_netns_pathname(struct vty *vty, const char *name)
pathname,
safe_strerror(errno));
else
- zlog_warn("Invalid pathname for %s: %s",
- pathname,
+ flog_warn(LIB_WARN_LINUX_NS,
+ "Invalid pathname for %s: %s", pathname,
safe_strerror(errno));
return NULL;
}
@@ -452,7 +452,8 @@ char *ns_netns_pathname(struct vty *vty, const char *name)
vty_out(vty, "NS name (%s) invalid: too long (>%d)\n",
check_base, NS_NAMSIZ - 1);
else
- zlog_warn("NS name (%s) invalid: too long (>%d)",
+ flog_warn(LIB_WARN_LINUX_NS,
+ "NS name (%s) invalid: too long (>%d)",
check_base, NS_NAMSIZ - 1);
return NULL;
}
diff --git a/lib/network.c b/lib/network.c
index 6d3350ad4..41bd321bc 100644
--- a/lib/network.c
+++ b/lib/network.c
@@ -22,6 +22,7 @@
#include <zebra.h>
#include "log.h"
#include "network.h"
+#include "lib_errors.h"
/* Read nbytes from fd and store into ptr. */
int readn(int fd, uint8_t *ptr, int nbytes)
@@ -78,13 +79,15 @@ int set_nonblocking(int fd)
should
never be negative. */
if ((flags = fcntl(fd, F_GETFL)) < 0) {
- zlog_warn("fcntl(F_GETFL) failed for fd %d: %s", fd,
- safe_strerror(errno));
+ flog_err(LIB_ERR_SYSTEM_CALL,
+ "fcntl(F_GETFL) failed for fd %d: %s", fd,
+ safe_strerror(errno));
return -1;
}
if (fcntl(fd, F_SETFL, (flags | O_NONBLOCK)) < 0) {
- zlog_warn("fcntl failed setting fd %d non-blocking: %s", fd,
- safe_strerror(errno));
+ flog_err(LIB_ERR_SYSTEM_CALL,
+ "fcntl failed setting fd %d non-blocking: %s", fd,
+ safe_strerror(errno));
return -1;
}
return 0;
diff --git a/lib/plist.c b/lib/plist.c
index 574608012..f8dd7df0b 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -930,7 +930,10 @@ static int vty_prefix_list_install(struct vty *vty, afi_t afi, const char *name,
char buf_tmp[PREFIX2STR_BUFFER];
prefix2str(&p, buf, sizeof(buf));
prefix2str(&p_tmp, buf_tmp, sizeof(buf_tmp));
- zlog_warn(
+ vty_out(vty,
+ "%% Prefix-list %s prefix changed from %s to %s to match length\n",
+ name, buf, buf_tmp);
+ zlog_info(
"Prefix-list %s prefix changed from %s to %s to match length",
name, buf, buf_tmp);
p = p_tmp;
diff --git a/lib/privs.c b/lib/privs.c
index 34905ca48..d77a63a2d 100644
--- a/lib/privs.c
+++ b/lib/privs.c
@@ -24,6 +24,7 @@
#include "log.h"
#include "privs.h"
#include "memory.h"
+#include "lib_errors.h"
#ifdef HAVE_CAPABILITIES
@@ -288,7 +289,8 @@ zebra_privs_current_t zprivs_state_caps(void)
if (cap_get_flag(zprivs_state.caps,
zprivs_state.syscaps_p->caps[i], CAP_EFFECTIVE,
&val)) {
- zlog_warn(
+ flog_err(
+ LIB_ERR_SYSTEM_CALL,
"zprivs_state_caps: could not cap_get_flag, %s",
safe_strerror(errno));
return ZPRIVS_UNKNOWN;
diff --git a/lib/routemap.c b/lib/routemap.c
index e5613c208..9e3dd3c0a 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -30,6 +30,7 @@
#include "log.h"
#include "hash.h"
#include "libfrr.h"
+#include "lib_errors.h"
DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP, "Route map")
DEFINE_MTYPE(LIB, ROUTE_MAP_NAME, "Route map name")
@@ -1445,7 +1446,8 @@ route_map_result_t route_map_apply(struct route_map *map,
struct route_map_rule *set;
if (recursion > RMAP_RECURSION_LIMIT) {
- zlog_warn(
+ flog_warn(
+ LIB_WARN_RMAP_RECURSION_LIMIT,
"route-map recursion limit (%d) reached, discarding route",
RMAP_RECURSION_LIMIT);
recursion = 0;
diff --git a/lib/sigevent.c b/lib/sigevent.c
index 034602793..115781af5 100644
--- a/lib/sigevent.c
+++ b/lib/sigevent.c
@@ -329,7 +329,8 @@ static void trap_default_signals(void)
}
if (sigaction(sigmap[i].sigs[j], &act, NULL)
< 0)
- zlog_warn(
+ flog_err(
+ LIB_ERR_SYSTEM_CALL,
"Unable to set signal handler for signal %d: %s",
sigmap[i].sigs[j],
safe_strerror(errno));
diff --git a/lib/sockopt.c b/lib/sockopt.c
index 3febcb714..25e9973e5 100644
--- a/lib/sockopt.c
+++ b/lib/sockopt.c
@@ -38,8 +38,9 @@ void setsockopt_so_recvbuf(int sock, int size)
size /= 2;
if (size != orig_req)
- zlog_warn("%s: fd %d: SO_RCVBUF set to %d (requested %d)",
- __func__, sock, size, orig_req);
+ flog_err(LIB_ERR_SOCKET,
+ "%s: fd %d: SO_RCVBUF set to %d (requested %d)",
+ __func__, sock, size, orig_req);
}
void setsockopt_so_sendbuf(const int sock, int size)
@@ -51,8 +52,9 @@ void setsockopt_so_sendbuf(const int sock, int size)
size /= 2;
if (size != orig_req)
- zlog_warn("%s: fd %d: SO_SNDBUF set to %d (requested %d)",
- __func__, sock, size, orig_req);
+ flog_err(LIB_ERR_SOCKET,
+ "%s: fd %d: SO_SNDBUF set to %d (requested %d)",
+ __func__, sock, size, orig_req);
}
int getsockopt_so_sendbuf(const int sock)
@@ -92,13 +94,14 @@ int setsockopt_ipv6_pktinfo(int sock, int val)
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &val,
sizeof(val));
if (ret < 0)
- zlog_warn("can't setsockopt IPV6_RECVPKTINFO : %s",
- safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "can't setsockopt IPV6_RECVPKTINFO : %s",
+ safe_strerror(errno));
#else /*RFC2292*/
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_PKTINFO, &val, sizeof(val));
if (ret < 0)
- zlog_warn("can't setsockopt IPV6_PKTINFO : %s",
- safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET, "can't setsockopt IPV6_PKTINFO : %s",
+ safe_strerror(errno));
#endif /* INIA_IPV6 */
return ret;
}
@@ -114,7 +117,7 @@ int setsockopt_ipv6_checksum(int sock, int val)
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_CHECKSUM, &val, sizeof(val));
#endif /* GNU_LINUX */
if (ret < 0)
- zlog_warn("can't setsockopt IPV6_CHECKSUM");
+ flog_err(LIB_ERR_SOCKET, "can't setsockopt IPV6_CHECKSUM");
return ret;
}
@@ -126,7 +129,8 @@ int setsockopt_ipv6_multicast_hops(int sock, int val)
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &val,
sizeof(val));
if (ret < 0)
- zlog_warn("can't setsockopt IPV6_MULTICAST_HOPS");
+ flog_err(LIB_ERR_SOCKET,
+ "can't setsockopt IPV6_MULTICAST_HOPS");
return ret;
}
@@ -138,7 +142,7 @@ int setsockopt_ipv6_unicast_hops(int sock, int val)
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &val,
sizeof(val));
if (ret < 0)
- zlog_warn("can't setsockopt IPV6_UNICAST_HOPS");
+ flog_err(LIB_ERR_SOCKET, "can't setsockopt IPV6_UNICAST_HOPS");
return ret;
}
@@ -150,11 +154,11 @@ int setsockopt_ipv6_hoplimit(int sock, int val)
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &val,
sizeof(val));
if (ret < 0)
- zlog_warn("can't setsockopt IPV6_RECVHOPLIMIT");
+ flog_err(LIB_ERR_SOCKET, "can't setsockopt IPV6_RECVHOPLIMIT");
#else /*RFC2292*/
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_HOPLIMIT, &val, sizeof(val));
if (ret < 0)
- zlog_warn("can't setsockopt IPV6_HOPLIMIT");
+ flog_err(LIB_ERR_SOCKET, "can't setsockopt IPV6_HOPLIMIT");
#endif
return ret;
}
@@ -167,7 +171,8 @@ int setsockopt_ipv6_multicast_loop(int sock, int val)
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &val,
sizeof(val));
if (ret < 0)
- zlog_warn("can't setsockopt IPV6_MULTICAST_LOOP");
+ flog_err(LIB_ERR_SOCKET,
+ "can't setsockopt IPV6_MULTICAST_LOOP");
return ret;
}
@@ -188,8 +193,9 @@ int setsockopt_ipv6_tclass(int sock, int tclass)
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_TCLASS, &tclass,
sizeof(tclass));
if (ret < 0)
- zlog_warn("Can't set IPV6_TCLASS option for fd %d to %#x: %s",
- sock, tclass, safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "Can't set IPV6_TCLASS option for fd %d to %#x: %s",
+ sock, tclass, safe_strerror(errno));
#endif
return ret;
}
@@ -391,7 +397,7 @@ int setsockopt_ipv4_multicast_loop(int sock, uint8_t val)
ret = setsockopt(sock, IPPROTO_IP, IP_MULTICAST_LOOP, (void *)&val,
sizeof(val));
if (ret < 0)
- zlog_warn("can't setsockopt IP_MULTICAST_LOOP");
+ flog_err(LIB_ERR_SOCKET, "can't setsockopt IP_MULTICAST_LOOP");
return ret;
}
@@ -403,13 +409,15 @@ static int setsockopt_ipv4_ifindex(int sock, ifindex_t val)
#if defined(IP_PKTINFO)
if ((ret = setsockopt(sock, IPPROTO_IP, IP_PKTINFO, &val, sizeof(val)))
< 0)
- zlog_warn("Can't set IP_PKTINFO option for fd %d to %d: %s",
- sock, val, safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "Can't set IP_PKTINFO option for fd %d to %d: %s",
+ sock, val, safe_strerror(errno));
#elif defined(IP_RECVIF)
if ((ret = setsockopt(sock, IPPROTO_IP, IP_RECVIF, &val, sizeof(val)))
< 0)
- zlog_warn("Can't set IP_RECVIF option for fd %d to %d: %s",
- sock, val, safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "Can't set IP_RECVIF option for fd %d to %d: %s", sock,
+ val, safe_strerror(errno));
#else
#warning "Neither IP_PKTINFO nor IP_RECVIF is available."
#warning "Will not be able to receive link info."
@@ -427,8 +435,9 @@ int setsockopt_ipv4_tos(int sock, int tos)
ret = setsockopt(sock, IPPROTO_IP, IP_TOS, &tos, sizeof(tos));
if (ret < 0)
- zlog_warn("Can't set IP_TOS option for fd %d to %#x: %s", sock,
- tos, safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "Can't set IP_TOS option for fd %d to %#x: %s", sock,
+ tos, safe_strerror(errno));
return ret;
}
@@ -445,7 +454,8 @@ int setsockopt_ifindex(int af, int sock, ifindex_t val)
ret = setsockopt_ipv6_pktinfo(sock, val);
break;
default:
- zlog_warn("setsockopt_ifindex: unknown address family %d", af);
+ flog_err(LIB_ERR_DEVELOPMENT,
+ "setsockopt_ifindex: unknown address family %d", af);
}
return ret;
}
@@ -534,7 +544,8 @@ ifindex_t getsockopt_ifindex(int af, struct msghdr *msgh)
return (getsockopt_ipv6_ifindex(msgh));
break;
default:
- zlog_warn("getsockopt_ifindex: unknown address family %d", af);
+ flog_err(LIB_ERR_DEVELOPMENT,
+ "getsockopt_ifindex: unknown address family %d", af);
return 0;
}
}
diff --git a/lib/sockunion.c b/lib/sockunion.c
index bbbfbfc42..f4e806e92 100644
--- a/lib/sockunion.c
+++ b/lib/sockunion.c
@@ -140,9 +140,9 @@ int sockunion_socket(const union sockunion *su)
sock = socket(su->sa.sa_family, SOCK_STREAM, 0);
if (sock < 0) {
char buf[SU_ADDRSTRLEN];
- zlog_warn("Can't make socket for %s : %s",
- sockunion_log(su, buf, SU_ADDRSTRLEN),
- safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET, "Can't make socket for %s : %s",
+ sockunion_log(su, buf, SU_ADDRSTRLEN),
+ safe_strerror(errno));
return -1;
}
@@ -235,7 +235,8 @@ int sockunion_stream_socket(union sockunion *su)
sock = socket(su->sa.sa_family, SOCK_STREAM, 0);
if (sock < 0)
- zlog_warn("can't make socket sockunion_stream_socket");
+ flog_err(LIB_ERR_SOCKET,
+ "can't make socket sockunion_stream_socket");
return sock;
}
@@ -273,9 +274,9 @@ int sockunion_bind(int sock, union sockunion *su, unsigned short port,
ret = bind(sock, (struct sockaddr *)su, size);
if (ret < 0) {
char buf[SU_ADDRSTRLEN];
- zlog_warn("can't bind socket for %s : %s",
- sockunion_log(su, buf, SU_ADDRSTRLEN),
- safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET, "can't bind socket for %s : %s",
+ sockunion_log(su, buf, SU_ADDRSTRLEN),
+ safe_strerror(errno));
}
return ret;
@@ -289,7 +290,8 @@ int sockopt_reuseaddr(int sock)
ret = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&on,
sizeof(on));
if (ret < 0) {
- zlog_warn("can't set sockopt SO_REUSEADDR to socket %d", sock);
+ flog_err(LIB_ERR_SOCKET,
+ "can't set sockopt SO_REUSEADDR to socket %d", sock);
return -1;
}
return 0;
@@ -304,7 +306,8 @@ int sockopt_reuseport(int sock)
ret = setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (void *)&on,
sizeof(on));
if (ret < 0) {
- zlog_warn("can't set sockopt SO_REUSEPORT to socket %d", sock);
+ flog_err(LIB_ERR_SOCKET,
+ "can't set sockopt SO_REUSEPORT to socket %d", sock);
return -1;
}
return 0;
@@ -325,8 +328,9 @@ int sockopt_ttl(int family, int sock, int ttl)
ret = setsockopt(sock, IPPROTO_IP, IP_TTL, (void *)&ttl,
sizeof(int));
if (ret < 0) {
- zlog_warn("can't set sockopt IP_TTL %d to socket %d",
- ttl, sock);
+ flog_err(LIB_ERR_SOCKET,
+ "can't set sockopt IP_TTL %d to socket %d",
+ ttl, sock);
return -1;
}
return 0;
@@ -336,7 +340,8 @@ int sockopt_ttl(int family, int sock, int ttl)
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_UNICAST_HOPS,
(void *)&ttl, sizeof(int));
if (ret < 0) {
- zlog_warn(
+ flog_err(
+ LIB_ERR_SOCKET,
"can't set sockopt IPV6_UNICAST_HOPS %d to socket %d",
ttl, sock);
return -1;
@@ -383,7 +388,8 @@ int sockopt_minttl(int family, int sock, int minttl)
int ret = setsockopt(sock, IPPROTO_IP, IP_MINTTL, &minttl,
sizeof(minttl));
if (ret < 0)
- zlog_warn(
+ flog_err(
+ LIB_ERR_SOCKET,
"can't set sockopt IP_MINTTL to %d on socket %d: %s",
minttl, sock, safe_strerror(errno));
return ret;
@@ -394,7 +400,8 @@ int sockopt_minttl(int family, int sock, int minttl)
int ret = setsockopt(sock, IPPROTO_IPV6, IPV6_MINHOPCOUNT,
&minttl, sizeof(minttl));
if (ret < 0)
- zlog_warn(
+ flog_err(
+ LIB_ERR_SOCKET,
"can't set sockopt IPV6_MINHOPCOUNT to %d on socket %d: %s",
minttl, sock, safe_strerror(errno));
return ret;
@@ -414,10 +421,10 @@ int sockopt_v6only(int family, int sock)
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&on,
sizeof(int));
if (ret < 0) {
- zlog_warn(
- "can't set sockopt IPV6_V6ONLY "
- "to socket %d",
- sock);
+ flog_err(LIB_ERR_SOCKET,
+ "can't set sockopt IPV6_V6ONLY "
+ "to socket %d",
+ sock);
return -1;
}
return 0;
@@ -532,8 +539,9 @@ union sockunion *sockunion_getsockname(int fd)
ret = getsockname(fd, (struct sockaddr *)&name, &len);
if (ret < 0) {
- zlog_warn("Can't get local address and port by getsockname: %s",
- safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "Can't get local address and port by getsockname: %s",
+ safe_strerror(errno));
return NULL;
}
@@ -568,8 +576,9 @@ union sockunion *sockunion_getpeername(int fd)
len = sizeof name;
ret = getpeername(fd, (struct sockaddr *)&name, &len);
if (ret < 0) {
- zlog_warn("Can't get remote address and port: %s",
- safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "Can't get remote address and port: %s",
+ safe_strerror(errno));
return NULL;
}
diff --git a/lib/stream.c b/lib/stream.c
index 589a22925..8424a941d 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -54,7 +54,8 @@ DEFINE_MTYPE_STATIC(LIB, STREAM_FIFO, "Stream FIFO")
* using stream_put..._at() functions.
*/
#define STREAM_WARN_OFFSETS(S) \
- zlog_warn("&(struct stream): %p, size: %lu, getp: %lu, endp: %lu\n", \
+ flog_warn(LIB_WARN_STREAM, \
+ "&(struct stream): %p, size: %lu, getp: %lu, endp: %lu\n", \
(void *)(S), (unsigned long)(S)->size, \
(unsigned long)(S)->getp, (unsigned long)(S)->endp)
@@ -68,16 +69,16 @@ DEFINE_MTYPE_STATIC(LIB, STREAM_FIFO, "Stream FIFO")
#define STREAM_BOUND_WARN(S, WHAT) \
do { \
- zlog_warn("%s: Attempt to %s out of bounds", __func__, \
- (WHAT)); \
+ flog_warn(LIB_WARN_STREAM, "%s: Attempt to %s out of bounds", \
+ __func__, (WHAT)); \
STREAM_WARN_OFFSETS(S); \
assert(0); \
} while (0)
#define STREAM_BOUND_WARN2(S, WHAT) \
do { \
- zlog_warn("%s: Attempt to %s out of bounds", __func__, \
- (WHAT)); \
+ flog_warn(LIB_WARN_STREAM, "%s: Attempt to %s out of bounds", \
+ __func__, (WHAT)); \
STREAM_WARN_OFFSETS(S); \
} while (0)
@@ -85,7 +86,8 @@ DEFINE_MTYPE_STATIC(LIB, STREAM_FIFO, "Stream FIFO")
#define CHECK_SIZE(S, Z) \
do { \
if (((S)->endp + (Z)) > (S)->size) { \
- zlog_warn( \
+ flog_warn( \
+ LIB_WARN_STREAM, \
"CHECK_SIZE: truncating requested size %lu\n", \
(unsigned long)(Z)); \
STREAM_WARN_OFFSETS(S); \
@@ -966,8 +968,8 @@ ssize_t stream_read_try(struct stream *s, int fd, size_t size)
/* Error: was it transient (return -2) or fatal (return -1)? */
if (ERRNO_IO_RETRY(errno))
return -2;
- zlog_warn("%s: read failed on fd %d: %s", __func__, fd,
- safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET, "%s: read failed on fd %d: %s", __func__, fd,
+ safe_strerror(errno));
return -1;
}
@@ -997,8 +999,8 @@ ssize_t stream_recvfrom(struct stream *s, int fd, size_t size, int flags,
/* Error: was it transient (return -2) or fatal (return -1)? */
if (ERRNO_IO_RETRY(errno))
return -2;
- zlog_warn("%s: read failed on fd %d: %s", __func__, fd,
- safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET, "%s: read failed on fd %d: %s", __func__, fd,
+ safe_strerror(errno));
return -1;
}
diff --git a/lib/thread.c b/lib/thread.c
index 52bc79ffe..b2740baf5 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -33,6 +33,7 @@
#include "network.h"
#include "jhash.h"
#include "frratomic.h"
+#include "lib_errors.h"
DEFINE_MTYPE_STATIC(LIB, THREAD, "Thread")
DEFINE_MTYPE_STATIC(LIB, THREAD_MASTER, "Thread master")
@@ -1480,7 +1481,8 @@ struct thread *thread_fetch(struct thread_master *m, struct thread *fetch)
}
/* else die */
- zlog_warn("poll() error: %s", safe_strerror(errno));
+ flog_err(LIB_ERR_SYSTEM_CALL, "poll() error: %s",
+ safe_strerror(errno));
pthread_mutex_unlock(&m->mtx);
fetch = NULL;
break;
@@ -1617,7 +1619,8 @@ void thread_call(struct thread *thread)
* Whinge about it now, so we're aware this is yet another task
* to fix.
*/
- zlog_warn(
+ flog_warn(
+ LIB_WARN_SLOW_THREAD,
"SLOW THREAD: task %s (%lx) ran for %lums (cpu time %lums)",
thread->funcname, (unsigned long)thread->func,
realtime / 1000, cputime / 1000);
diff --git a/lib/vrf.c b/lib/vrf.c
index 3ab830c55..4b7e84275 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -630,7 +630,8 @@ int vrf_handler_create(struct vty *vty, const char *vrfname,
"%% VRF name %s invalid: length exceeds %d bytes\n",
vrfname, VRF_NAMSIZ);
else
- zlog_warn(
+ flog_warn(
+ LIB_WARN_VRF_LENGTH,
"%% VRF name %s invalid: length exceeds %d bytes\n",
vrfname, VRF_NAMSIZ);
return CMD_WARNING_CONFIG_FAILED;
@@ -659,7 +660,7 @@ int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf, char *pathname,
"VRF %u is already configured with VRF %s\n",
vrf->vrf_id, vrf->name);
else
- zlog_warn("VRF %u is already configured with VRF %s\n",
+ zlog_info("VRF %u is already configured with VRF %s\n",
vrf->vrf_id, vrf->name);
return CMD_WARNING_CONFIG_FAILED;
}
@@ -671,7 +672,7 @@ int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf, char *pathname,
"VRF %u already configured with NETNS %s\n",
vrf->vrf_id, ns->name);
else
- zlog_warn(
+ zlog_info(
"VRF %u already configured with NETNS %s",
vrf->vrf_id, ns->name);
return CMD_WARNING_CONFIG_FAILED;
@@ -689,7 +690,7 @@ int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf, char *pathname,
" with VRF %u(%s)\n",
ns->name, vrf2->vrf_id, vrf2->name);
else
- zlog_warn("NS %s is already configured with VRF %u(%s)",
+ zlog_info("NS %s is already configured with VRF %u(%s)",
ns->name, vrf2->vrf_id, vrf2->name);
return CMD_WARNING_CONFIG_FAILED;
}
@@ -705,7 +706,7 @@ int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf, char *pathname,
vty_out(vty, "Can not associate NS %u with NETNS %s\n",
ns->ns_id, ns->name);
else
- zlog_warn("Can not associate NS %u with NETNS %s",
+ zlog_info("Can not associate NS %u with NETNS %s",
ns->ns_id, ns->name);
return CMD_WARNING_CONFIG_FAILED;
}
diff --git a/lib/vty.c b/lib/vty.c
index 480137a7a..921f92df1 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -314,8 +314,9 @@ static int vty_log_out(struct vty *vty, const char *level,
/* Fatal I/O error. */
vty->monitor =
0; /* disable monitoring to avoid infinite recursion */
- zlog_warn("%s: write failed to vty client fd %d, closing: %s",
- __func__, vty->fd, safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "%s: write failed to vty client fd %d, closing: %s",
+ __func__, vty->fd, safe_strerror(errno));
buffer_reset(vty->obuf);
buffer_reset(vty->lbuf);
/* cannot call vty_close, because a parent routine may still try
@@ -534,7 +535,8 @@ static int vty_command(struct vty *vty, char *buf)
if ((realtime = thread_consumed_time(&after, &before, &cputime))
> CONSUMED_TIME_CHECK)
/* Warn about CPU hog that must be fixed. */
- zlog_warn(
+ flog_warn(
+ LIB_WARN_SLOW_THREAD,
"SLOW COMMAND: command took %lums (cpu time %lums): %s",
realtime / 1000, cputime / 1000, buf);
}
@@ -1326,7 +1328,8 @@ static int vty_telnet_option(struct vty *vty, unsigned char *buf, int nbytes)
switch (vty->sb_buf[0]) {
case TELOPT_NAWS:
if (vty->sb_len != TELNET_NAWS_SB_LEN)
- zlog_warn(
+ flog_err(
+ LIB_ERR_SYSTEM_CALL,
"RFC 1073 violation detected: telnet NAWS option "
"should send %d characters, but we received %lu",
TELNET_NAWS_SB_LEN,
@@ -1448,7 +1451,8 @@ static int vty_read(struct thread *thread)
}
vty->monitor = 0; /* disable monitoring to avoid
infinite recursion */
- zlog_warn(
+ flog_err(
+ LIB_ERR_SOCKET,
"%s: read error on vty client fd %d, closing: %s",
__func__, vty->fd, safe_strerror(errno));
buffer_reset(vty->obuf);
@@ -1655,7 +1659,7 @@ static int vty_flush(struct thread *thread)
case BUFFER_ERROR:
vty->monitor =
0; /* disable monitoring to avoid infinite recursion */
- zlog_warn("buffer_flush failed on vty client fd %d, closing",
+ zlog_info("buffer_flush failed on vty client fd %d, closing",
vty->fd);
buffer_reset(vty->lbuf);
buffer_reset(vty->obuf);
@@ -1902,7 +1906,8 @@ static int vty_accept(struct thread *thread)
/* We can handle IPv4 or IPv6 socket. */
vty_sock = sockunion_accept(accept_sock, &su);
if (vty_sock < 0) {
- zlog_warn("can't accept vty socket : %s", safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET, "can't accept vty socket : %s",
+ safe_strerror(errno));
return -1;
}
set_nonblocking(vty_sock);
@@ -2110,14 +2115,15 @@ static int vtysh_accept(struct thread *thread)
(socklen_t *)&client_len);
if (sock < 0) {
- zlog_warn("can't accept vty socket : %s", safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET, "can't accept vty socket : %s",
+ safe_strerror(errno));
return -1;
}
if (set_nonblocking(sock) < 0) {
- zlog_warn(
- "vtysh_accept: could not set vty socket %d to non-blocking,"
- " %s, closing",
+ flog_err(
+ LIB_ERR_SOCKET,
+ "vtysh_accept: could not set vty socket %d to non-blocking, %s, closing",
sock, safe_strerror(errno));
close(sock);
return -1;
@@ -2148,8 +2154,8 @@ static int vtysh_flush(struct vty *vty)
case BUFFER_ERROR:
vty->monitor =
0; /* disable monitoring to avoid infinite recursion */
- zlog_warn("%s: write error to fd %d, closing", __func__,
- vty->fd);
+ flog_err(LIB_ERR_SOCKET, "%s: write error to fd %d, closing",
+ __func__, vty->fd);
buffer_reset(vty->lbuf);
buffer_reset(vty->obuf);
vty_close(vty);
@@ -2183,7 +2189,8 @@ static int vtysh_read(struct thread *thread)
}
vty->monitor = 0; /* disable monitoring to avoid
infinite recursion */
- zlog_warn(
+ flog_err(
+ LIB_ERR_SOCKET,
"%s: read failed on vtysh client fd %d, closing: %s",
__func__, sock, safe_strerror(errno));
}
@@ -2504,12 +2511,15 @@ bool vty_read_config(const char *config_file, char *config_default_dir)
confp = fopen(fullpath, "r");
if (confp == NULL) {
- zlog_warn("%s: failed to open configuration file %s: %s, checking backup",
- __func__, fullpath, safe_strerror(errno));
+ flog_warn(
+ LIB_WARN_BACKUP_CONFIG,
+ "%s: failed to open configuration file %s: %s, checking backup",
+ __func__, fullpath, safe_strerror(errno));
confp = vty_use_backup_config(fullpath);
if (confp)
- zlog_warn(
+ flog_warn(
+ LIB_WARN_BACKUP_CONFIG,
"WARNING: using backup configuration file!");
else {
flog_err(LIB_ERR_VTY,
@@ -2550,13 +2560,16 @@ bool vty_read_config(const char *config_file, char *config_default_dir)
#endif /* VTYSH */
confp = fopen(config_default_dir, "r");
if (confp == NULL) {
- zlog_warn("%s: failed to open configuration file %s: %s, checking backup",
- __func__, config_default_dir,
- safe_strerror(errno));
+ flog_err(
+ LIB_ERR_SYSTEM_CALL,
+ "%s: failed to open configuration file %s: %s, checking backup",
+ __func__, config_default_dir,
+ safe_strerror(errno));
confp = vty_use_backup_config(config_default_dir);
if (confp) {
- zlog_warn(
+ flog_warn(
+ LIB_WARN_BACKUP_CONFIG,
"WARNING: using backup configuration file!");
fullpath = config_default_dir;
} else {
diff --git a/lib/zclient.c b/lib/zclient.c
index c5a48c178..340eb0db3 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -221,9 +221,9 @@ int zclient_socket_connect(struct zclient *zclient)
ret = connect(sock, (struct sockaddr *)&zclient_addr, zclient_addr_len);
if (ret < 0) {
if (zclient_debug)
- zlog_warn("%s connect failure: %d(%s)",
- __PRETTY_FUNCTION__, errno,
- safe_strerror(errno));
+ zlog_debug("%s connect failure: %d(%s)",
+ __PRETTY_FUNCTION__, errno,
+ safe_strerror(errno));
close(sock);
return -1;
}
@@ -249,7 +249,8 @@ static int zclient_flush_data(struct thread *thread)
return -1;
switch (buffer_flush_available(zclient->wb, zclient->sock)) {
case BUFFER_ERROR:
- zlog_warn(
+ flog_err(
+ LIB_ERR_ZAPI_SOCKET,
"%s: buffer_flush_available failed on zclient fd %d, closing",
__func__, zclient->sock);
return zclient_failed(zclient);
@@ -273,8 +274,9 @@ int zclient_send_message(struct zclient *zclient)
STREAM_DATA(zclient->obuf),
stream_get_endp(zclient->obuf))) {
case BUFFER_ERROR:
- zlog_warn("%s: buffer_write failed to zclient fd %d, closing",
- __func__, zclient->sock);
+ flog_err(LIB_ERR_ZAPI_SOCKET,
+ "%s: buffer_write failed to zclient fd %d, closing",
+ __func__, zclient->sock);
return zclient_failed(zclient);
break;
case BUFFER_EMPTY:
@@ -575,8 +577,8 @@ int zclient_start(struct zclient *zclient)
}
if (set_nonblocking(zclient->sock) < 0)
- zlog_warn("%s: set_nonblocking(%d) failed", __func__,
- zclient->sock);
+ flog_err(LIB_ERR_ZAPI_SOCKET, "%s: set_nonblocking(%d) failed",
+ __func__, zclient->sock);
/* Clear fail count. */
zclient->fail = 0;
@@ -771,9 +773,9 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api)
char buf[PREFIX2STR_BUFFER];
prefix2str(&api->prefix, buf, sizeof(buf));
- zlog_warn(
- "%s: prefix %s: can't encode %u nexthops "
- "(maximum is %u)",
+ flog_err(
+ LIB_ERR_ZAPI_ENCODE,
+ "%s: prefix %s: can't encode %u nexthops (maximum is %u)",
__func__, buf, api->nexthop_num, MULTIPATH_NUM);
return -1;
}
@@ -808,11 +810,6 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api)
16);
stream_putl(s, api_nh->ifindex);
break;
- default:
- zlog_warn(
- "%s: Specified Nexthop type %d does not exist",
- __PRETTY_FUNCTION__, api_nh->type);
- return -1;
}
/* MPLS labels for BGP-LU or Segment Routing */
@@ -871,8 +868,9 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
/* Type, flags, message. */
STREAM_GETC(s, api->type);
if (api->type > ZEBRA_ROUTE_MAX) {
- zlog_warn("%s: Specified route type: %d is not a legal value\n",
- __PRETTY_FUNCTION__, api->type);
+ flog_err(LIB_ERR_ZAPI_ENCODE,
+ "%s: Specified route type: %d is not a legal value\n",
+ __PRETTY_FUNCTION__, api->type);
return -1;
}
@@ -887,7 +885,8 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
switch (api->prefix.family) {
case AF_INET:
if (api->prefix.prefixlen > IPV4_MAX_PREFIXLEN) {
- zlog_warn(
+ flog_err(
+ LIB_ERR_ZAPI_ENCODE,
"%s: V4 prefixlen is %d which should not be more than 32",
__PRETTY_FUNCTION__, api->prefix.prefixlen);
return -1;
@@ -895,15 +894,17 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
break;
case AF_INET6:
if (api->prefix.prefixlen > IPV6_MAX_PREFIXLEN) {
- zlog_warn(
+ flog_err(
+ LIB_ERR_ZAPI_ENCODE,
"%s: v6 prefixlen is %d which should not be more than 128",
__PRETTY_FUNCTION__, api->prefix.prefixlen);
return -1;
}
break;
default:
- zlog_warn("%s: Specified family %d is not v4 or v6",
- __PRETTY_FUNCTION__, api->prefix.family);
+ flog_err(LIB_ERR_ZAPI_ENCODE,
+ "%s: Specified family %d is not v4 or v6",
+ __PRETTY_FUNCTION__, api->prefix.family);
return -1;
}
STREAM_GET(&api->prefix.u.prefix, s, PSIZE(api->prefix.prefixlen));
@@ -912,7 +913,8 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
api->src_prefix.family = AF_INET6;
STREAM_GETC(s, api->src_prefix.prefixlen);
if (api->src_prefix.prefixlen > IPV6_MAX_PREFIXLEN) {
- zlog_warn(
+ flog_err(
+ LIB_ERR_ZAPI_ENCODE,
"%s: SRC Prefix prefixlen received: %d is too large",
__PRETTY_FUNCTION__, api->src_prefix.prefixlen);
return -1;
@@ -922,7 +924,8 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
if (api->prefix.family != AF_INET6
|| api->src_prefix.prefixlen == 0) {
- zlog_warn(
+ flog_err(
+ LIB_ERR_ZAPI_ENCODE,
"%s: SRC prefix specified in some manner that makes no sense",
__PRETTY_FUNCTION__);
return -1;
@@ -933,8 +936,9 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) {
STREAM_GETW(s, api->nexthop_num);
if (api->nexthop_num > MULTIPATH_NUM) {
- zlog_warn("%s: invalid number of nexthops (%u)",
- __func__, api->nexthop_num);
+ flog_err(LIB_ERR_ZAPI_ENCODE,
+ "%s: invalid number of nexthops (%u)",
+ __func__, api->nexthop_num);
return -1;
}
@@ -966,11 +970,6 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
STREAM_GET(&api_nh->gate.ipv6, s, 16);
STREAM_GETL(s, api_nh->ifindex);
break;
- default:
- zlog_warn(
- "%s: Specified nexthop type %d does not exist",
- __PRETTY_FUNCTION__, api_nh->type);
- return -1;
}
/* MPLS labels for BGP-LU or Segment Routing */
@@ -978,9 +977,9 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
STREAM_GETC(s, api_nh->label_num);
if (api_nh->label_num > MPLS_MAX_LABELS) {
- zlog_warn(
- "%s: invalid number of MPLS "
- "labels (%u)",
+ flog_err(
+ LIB_ERR_ZAPI_ENCODE,
+ "%s: invalid number of MPLS labels (%u)",
__func__, api_nh->label_num);
return -1;
}
@@ -1239,8 +1238,9 @@ bool zapi_nexthop_update_decode(struct stream *s, struct zapi_route *nhr)
}
STREAM_GETC(s, nhr->nexthops[i].label_num);
if (nhr->nexthops[i].label_num > MPLS_MAX_LABELS) {
- zlog_warn("%s: invalid number of MPLS labels (%u)",
- __func__, nhr->nexthops[i].label_num);
+ flog_err(LIB_ERR_ZAPI_ENCODE,
+ "%s: invalid number of MPLS labels (%u)",
+ __func__, nhr->nexthops[i].label_num);
return false;
}
if (nhr->nexthops[i].label_num)
@@ -1424,8 +1424,9 @@ struct interface *zebra_interface_state_read(struct stream *s, vrf_id_t vrf_id)
/* Lookup this by interface index. */
ifp = if_lookup_by_name(ifname_tmp, vrf_id);
if (ifp == NULL) {
- zlog_warn("INTERFACE_STATE: Cannot find IF %s in VRF %d",
- ifname_tmp, vrf_id);
+ flog_err(LIB_ERR_ZAPI_ENCODE,
+ "INTERFACE_STATE: Cannot find IF %s in VRF %d",
+ ifname_tmp, vrf_id);
return NULL;
}
@@ -1633,9 +1634,10 @@ struct connected *zebra_interface_address_read(int type, struct stream *s,
/* Lookup index. */
ifp = if_lookup_by_index(ifindex, vrf_id);
if (ifp == NULL) {
- zlog_warn("INTERFACE_ADDRESS_%s: Cannot find IF %u in VRF %d",
- (type == ZEBRA_INTERFACE_ADDRESS_ADD) ? "ADD" : "DEL",
- ifindex, vrf_id);
+ flog_err(LIB_ERR_ZAPI_ENCODE,
+ "INTERFACE_ADDRESS_%s: Cannot find IF %u in VRF %d",
+ (type == ZEBRA_INTERFACE_ADDRESS_ADD) ? "ADD" : "DEL",
+ ifindex, vrf_id);
return NULL;
}
@@ -1670,9 +1672,9 @@ struct connected *zebra_interface_address_read(int type, struct stream *s,
/* carp interfaces on OpenBSD with 0.0.0.0/0 as
* "peer" */
char buf[PREFIX_STRLEN];
- zlog_warn(
- "warning: interface %s address %s "
- "with peer flag set, but no peer address!",
+ flog_err(
+ LIB_ERR_ZAPI_ENCODE,
+ "warning: interface %s address %s with peer flag set, but no peer address!",
ifp->name,
prefix2str(ifc->address, buf,
sizeof buf));
@@ -1725,10 +1727,11 @@ zebra_interface_nbr_address_read(int type, struct stream *s, vrf_id_t vrf_id)
/* Lookup index. */
ifp = if_lookup_by_index(ifindex, vrf_id);
if (ifp == NULL) {
- zlog_warn("INTERFACE_NBR_%s: Cannot find IF %u in VRF %d",
- (type == ZEBRA_INTERFACE_NBR_ADDRESS_ADD) ? "ADD"
- : "DELETE",
- ifindex, vrf_id);
+ flog_err(LIB_ERR_ZAPI_ENCODE,
+ "INTERFACE_NBR_%s: Cannot find IF %u in VRF %d",
+ (type == ZEBRA_INTERFACE_NBR_ADDRESS_ADD) ? "ADD"
+ : "DELETE",
+ ifindex, vrf_id);
return NULL;
}
@@ -1774,8 +1777,9 @@ struct interface *zebra_interface_vrf_update_read(struct stream *s,
/* Lookup interface. */
ifp = if_lookup_by_index(ifindex, vrf_id);
if (ifp == NULL) {
- zlog_warn("INTERFACE_VRF_UPDATE: Cannot find IF %u in VRF %d",
- ifindex, vrf_id);
+ flog_err(LIB_ERR_ZAPI_ENCODE,
+ "INTERFACE_VRF_UPDATE: Cannot find IF %u in VRF %d",
+ ifindex, vrf_id);
return NULL;
}
@@ -2410,7 +2414,8 @@ static int zclient_read(struct thread *thread)
/* Length check. */
if (length > STREAM_SIZE(zclient->ibuf)) {
struct stream *ns;
- zlog_warn(
+ flog_err(
+ LIB_ERR_ZAPI_ENCODE,
"%s: message size %u exceeds buffer size %lu, expanding...",
__func__, length,
(unsigned long)STREAM_SIZE(zclient->ibuf));
diff --git a/nhrpd/nhrp_peer.c b/nhrpd/nhrp_peer.c
index e051830f8..203d4aa98 100644
--- a/nhrpd/nhrp_peer.c
+++ b/nhrpd/nhrp_peer.c
@@ -814,8 +814,9 @@ static void nhrp_packet_debug(struct zbuf *zb, const char *dir)
reply = packet_types[hdr->type].type == PACKET_REPLY;
debugf(NHRP_DEBUG_COMMON, "%s %s(%d) %s -> %s", dir,
- packet_types[hdr->type].name ?: "Unknown", hdr->type,
- reply ? buf[1] : buf[0], reply ? buf[0] : buf[1]);
+ (packet_types[hdr->type].name ? packet_types[hdr->type].name
+ : "Unknown"),
+ hdr->type, reply ? buf[1] : buf[0], reply ? buf[0] : buf[1]);
}
static int proto2afi(uint16_t proto)
diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c
index 7bccc78e0..586584c65 100644
--- a/ospf6d/ospf6_abr.c
+++ b/ospf6d/ospf6_abr.c
@@ -918,9 +918,6 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
* old as the route.
*/
if (listcount(route->paths) > 1) {
- struct listnode *anode;
- struct ospf6_path *o_path;
-
for (ALL_LIST_ELEMENTS_RO(route->paths, anode,
o_path)) {
inet_ntop(AF_INET,
diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c
index 0ff9d0da5..8cd61a4a9 100644
--- a/ospfd/ospf_abr.c
+++ b/ospfd/ospf_abr.c
@@ -49,6 +49,7 @@
#include "ospfd/ospf_ase.h"
#include "ospfd/ospf_zebra.h"
#include "ospfd/ospf_dump.h"
+#include "ospfd/ospf_errors.h"
static struct ospf_area_range *ospf_area_range_new(struct prefix_ipv4 *p)
{
@@ -742,7 +743,8 @@ void ospf_abr_announce_network_to_area(struct prefix_ipv4 *p, uint32_t cost,
prefix2str((struct prefix *)p, buf,
sizeof(buf));
- zlog_warn("%s: Could not refresh %s to %s",
+ flog_warn(OSPF_WARN_LSA_MISSING,
+ "%s: Could not refresh %s to %s",
__func__, buf,
inet_ntoa(area->area_id));
return;
@@ -764,7 +766,8 @@ void ospf_abr_announce_network_to_area(struct prefix_ipv4 *p, uint32_t cost,
char buf[PREFIX2STR_BUFFER];
prefix2str((struct prefix *)p, buf, sizeof(buf));
- zlog_warn("%s: Could not originate %s to %s", __func__,
+ flog_warn(OSPF_WARN_LSA_MISSING,
+ "%s: Could not originate %s to %s", __func__,
buf, inet_ntoa(area->area_id));
return;
}
@@ -1132,7 +1135,8 @@ static void ospf_abr_announce_rtr_to_area(struct prefix_ipv4 *p, uint32_t cost,
char buf[PREFIX2STR_BUFFER];
prefix2str((struct prefix *)p, buf, sizeof(buf));
- zlog_warn("%s: Could not refresh/originate %s to %s",
+ flog_warn(OSPF_WARN_LSA_MISSING,
+ "%s: Could not refresh/originate %s to %s",
__func__, buf, inet_ntoa(area->area_id));
return;
}
diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c
index 57e0ae5ec..d4a8a266c 100644
--- a/ospfd/ospf_apiserver.c
+++ b/ospfd/ospf_apiserver.c
@@ -54,6 +54,7 @@
#include "ospfd/ospf_route.h"
#include "ospfd/ospf_ase.h"
#include "ospfd/ospf_zebra.h"
+#include "ospfd/ospf_errors.h"
#include "ospfd/ospf_api.h"
#include "ospfd/ospf_apiserver.h"
@@ -152,7 +153,8 @@ int ospf_apiserver_init(void)
NULL, /* ospf_apiserver_lsa_refresher */
ospf_apiserver_lsa_update, ospf_apiserver_lsa_delete);
if (rc != 0) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_OPAQUE_REGISTRATION,
"ospf_apiserver_init: Failed to register opaque type [0/0]");
}
@@ -867,7 +869,8 @@ int ospf_apiserver_register_opaque_type(struct ospf_apiserver *apiserv,
NULL /* ospf_apiserver_lsa_delete */);
if (rc != 0) {
- zlog_warn("Failed to register opaque type [%d/%d]", lsa_type,
+ flog_warn(OSPF_WARN_OPAQUE_REGISTRATION,
+ "Failed to register opaque type [%d/%d]", lsa_type,
opaque_type);
return OSPF_API_OPAQUETYPEINUSE;
}
@@ -1662,7 +1665,8 @@ int ospf_apiserver_originate1(struct ospf_lsa *lsa)
/* Install this LSA into LSDB. */
if (ospf_lsa_install(ospf, lsa->oi, lsa) == NULL) {
- zlog_warn("ospf_apiserver_originate1: ospf_lsa_install failed");
+ flog_warn(OSPF_WARN_LSA_INSTALL_FAILURE,
+ "ospf_apiserver_originate1: ospf_lsa_install failed");
return -1;
}
@@ -1773,7 +1777,8 @@ struct ospf_lsa *ospf_apiserver_lsa_refresher(struct ospf_lsa *lsa)
/* Install LSA into LSDB. */
if (ospf_lsa_install(ospf, new->oi, new) == NULL) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA_INSTALL_FAILURE,
"ospf_apiserver_lsa_refresher: ospf_lsa_install failed");
ospf_lsa_unlock(&new);
goto out;
diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c
index 8e8f65530..ba2e04bf7 100644
--- a/ospfd/ospf_asbr.c
+++ b/ospfd/ospf_asbr.c
@@ -135,11 +135,12 @@ ospf_external_info_add(struct ospf *ospf, uint8_t type, unsigned short instance,
inet_ntop(AF_INET, (void *)&nexthop.s_addr, inetbuf,
INET6_BUFSIZ);
- zlog_warn(
- "Redistribute[%s][%d][%u]: %s/%d discarding old info with NH %s.",
- ospf_redist_string(type), instance,
- ospf->vrf_id, inet_ntoa(p.prefix), p.prefixlen,
- inetbuf);
+ if (IS_DEBUG_OSPF(lsa, LSA_GENERATE))
+ zlog_debug(
+ "Redistribute[%s][%d][%u]: %s/%d discarding old info with NH %s.",
+ ospf_redist_string(type), instance,
+ ospf->vrf_id, inet_ntoa(p.prefix),
+ p.prefixlen, inetbuf);
XFREE(MTYPE_OSPF_EXTERNAL_INFO, rn->info);
rn->info = NULL;
}
diff --git a/ospfd/ospf_errors.c b/ospfd/ospf_errors.c
index 2927f7cb1..4646ed33b 100644
--- a/ospfd/ospf_errors.c
+++ b/ospfd/ospf_errors.c
@@ -23,6 +23,97 @@
#include "lib/ferr.h"
#include "ospf_errors.h"
+/* clang-format off */
+static struct log_ref ferr_ospf_warn[] = {
+ {
+ .code = OSPF_WARN_SET_METRIC_PLUS,
+ .title = "OSPF does not support `set metric +rtt/-rtt`",
+ .description = "This implementation of OSPF does not currently support `set metric +rtt/-rtt`",
+ .suggestion = "Do not use this particular set command for an ospf route-map",
+ },
+ {
+ .code = OSPF_WARN_MD5,
+ .title = "OSPF has noticed a MD5 issue",
+ .description = "Something has gone wrong with the calculation of the MD5 data",
+ .suggestion = "Ensure your key is correct, gather log data from this side as well as peer and open an Issue",
+ },
+ {
+ .code = OSPF_WARN_PACKET,
+ .title = "OSPF has detected packet information missmatch",
+ .description = "OSPF has detected that packet information received is incorrect",
+ .suggestion = "Ensure interface configuration is correct, gather log files from here and the peer and open an Issue",
+ },
+ {
+ .code = OSPF_WARN_LARGE_LSA,
+ .title = "OSPF has determined that a LSA packet will be too large",
+ .description = "OSPF has received data that is causing it to recalculate how large packets should be and has discovered that the packet size needed would be too large and we will need to fragment packets",
+ .suggestion = "Further divide up your network with areas",
+ },
+ {
+ .code = OSPF_WARN_LSA_UNEXPECTED,
+ .title = "OSPF has received a LSA-type that it was not expecting",
+ .description = "OSPF has received a LSA-type that it was not expecting during processing",
+ .suggestion = "Gather log data from this machine and it's peer and open an Issue",
+ },
+ {
+ .code = OSPF_WARN_LSA,
+ .title = "OSPF has discovered inconsistent internal state for a LSA",
+ .description = "During handling of a LSA, OSPF has discovered that the LSA's internal state is inconsistent",
+ .suggestion = "Gather log data and open an Issue",
+ },
+ {
+ .code = OSPF_WARN_OPAQUE_REGISTRATION,
+ .title = "OSPF has failed to properly register Opaque Handler",
+ .description = "During initialization OSPF has detected a failure to install an opaque handler",
+ .suggestion = "Gather log data and open an Issue",
+ },
+ {
+ .code = OSPF_WARN_TE_UNEXPECTED,
+ .title = "OSPF has received TE information that it was not expecting",
+ .description = "OSPF has received TE information that it was not expecting during normal processing of data",
+ .suggestion = "Gather log data from this machine and it's peer and open an Issue",
+ },
+ {
+ .code = OSPF_WARN_LSA_INSTALL_FAILURE,
+ .title = "OSPF was unable to save the LSA into it's database",
+ .description = "During processing of a new lsa and attempting to save the lsa into the OSPF database, this process failed.",
+ .suggestion = "Gather log data from this machine and open an Issue",
+ },
+ {
+ .code = OSPF_WARN_LSA_NULL,
+ .title = "OSPF has received a NULL lsa pointer",
+ .description = "When processing a LSA update we have found and noticed an internal error where we are passing around a NULL pointer",
+ .suggestion = "Gather data from this machine and it's peer and open an Issue",
+ },
+ {
+ .code = OSPF_WARN_EXT_LSA_UNEXPECTED,
+ .title = "OSPF has received EXT information that leaves it in an unexpected state",
+ .description = "While processing EXT LSA information, OSPF has noticed that the internal state of OSPF has gotten inconsistent",
+ .suggestion = "Gather data from this machine and it's peer and open an Issue",
+ },
+ {
+ .code = OSPF_WARN_LSA_MISSING,
+ .title = "OSPF attempted to look up a LSA and it was not found",
+ .description = "During processing of new LSA information, we attempted to look up an old LSA and it was not found",
+ .suggestion = "Gather data from this machine and open an Issue",
+ },
+ {
+ .code = OSPF_WARN_PTP_NEIGHBOR,
+ .title = "OSPF has detected more than 1 neighbor on a P2P interface",
+ .description = "If you configure a ospf interface as P2P we should not detect more than one neighbor on the interface",
+ .suggestion = "Fix your config",
+ },
+ {
+ .code = OSPF_WARN_LSA_SIZE,
+ .title = "OSPF has detected an invalid LSA size",
+ .description = "OSPF has detected a state where we are attempting to grow a LSA but the LSA has reached it's maximum size",
+ .suggestion = "Gather data and open an Issue",
+ },
+ {
+ .code = END_FERR,
+ }
+};
+
static struct log_ref ferr_ospf_err[] = {
{
.code = OSPF_ERR_PKT_PROCESS,
@@ -67,18 +158,25 @@ static struct log_ref ferr_ospf_err[] = {
.suggestion = "Restart OSPF instance, If the problem persists, report the problem for troubleshooting"
},
{
- .code = OSPF_ERR_SR_INVALID_ALGORITHM,
+ .code = OSPF_ERR_INVALID_ALGORITHM,
.title = "OSPF SR Invalid Algorithm",
.description = "OSPF Segment Routing invalid Algorithm",
.suggestion = "Most likely a bug. If the problem persists, report the problem for troubleshooting"
},
-
+ {
+ .code = OSPF_ERR_FSM_INVALID_STATE,
+ .title = "OSPF FSM invalid state detected",
+ .description = "OSPF has attempted to change states when it should not be able to",
+ .suggestion = "Gather log files and open an issue",
+ },
{
.code = END_FERR,
}
};
+/* clang-format on */
void ospf_error_init(void)
{
+ log_ref_add(ferr_ospf_warn);
log_ref_add(ferr_ospf_err);
}
diff --git a/ospfd/ospf_errors.h b/ospfd/ospf_errors.h
index c3f101855..664f6f1bd 100644
--- a/ospfd/ospf_errors.h
+++ b/ospfd/ospf_errors.h
@@ -31,7 +31,22 @@ enum ospf_log_refs {
OSPF_ERR_SR_INVALID_DB,
OSPF_ERR_SR_NODE_CREATE,
OSPF_ERR_SR_INVALID_LSA_ID,
- OSPF_ERR_SR_INVALID_ALGORITHM,
+ OSPF_ERR_INVALID_ALGORITHM,
+ OSPF_ERR_FSM_INVALID_STATE,
+ OSPF_WARN_SET_METRIC_PLUS,
+ OSPF_WARN_MD5,
+ OSPF_WARN_PACKET,
+ OSPF_WARN_LARGE_LSA,
+ OSPF_WARN_LSA_UNEXPECTED,
+ OSPF_WARN_LSA,
+ OSPF_WARN_OPAQUE_REGISTRATION,
+ OSPF_WARN_TE_UNEXPECTED,
+ OSPF_WARN_LSA_INSTALL_FAILURE,
+ OSPF_WARN_LSA_NULL,
+ OSPF_WARN_EXT_LSA_UNEXPECTED,
+ OSPF_WARN_LSA_MISSING,
+ OSPF_WARN_PTP_NEIGHBOR,
+ OSPF_WARN_LSA_SIZE,
};
extern void ospf_error_init(void);
diff --git a/ospfd/ospf_ext.c b/ospfd/ospf_ext.c
index f6ed9b81b..1aab61168 100644
--- a/ospfd/ospf_ext.c
+++ b/ospfd/ospf_ext.c
@@ -62,6 +62,7 @@
#include "ospfd/ospf_zebra.h"
#include "ospfd/ospf_sr.h"
#include "ospfd/ospf_ext.h"
+#include "ospfd/ospf_errors.h"
/* Following structure are internal use only. */
@@ -136,7 +137,8 @@ int ospf_ext_init(void)
NULL); /* del_lsa_hook */
if (rc != 0) {
- zlog_warn("EXT (%s): Failed to register Extended Link LSA",
+ flog_warn(OSPF_WARN_OPAQUE_REGISTRATION,
+ "EXT (%s): Failed to register Extended Link LSA",
__func__);
return rc;
}
@@ -157,7 +159,8 @@ int ospf_ext_init(void)
ospf_ext_pref_lsa_update, /* new_lsa_hook */
NULL); /* del_lsa_hook */
if (rc != 0) {
- zlog_warn("EXT (%s): Failed to register Extended Prefix LSA",
+ flog_warn(OSPF_WARN_OPAQUE_REGISTRATION,
+ "EXT (%s): Failed to register Extended Prefix LSA",
__func__);
return rc;
}
@@ -174,12 +177,8 @@ int ospf_ext_init(void)
void ospf_ext_term(void)
{
- if ((OspfEXT.scope != OSPF_OPAQUE_AREA_LSA)
- && (OspfEXT.scope != OSPF_OPAQUE_AS_LSA))
- zlog_warn(
- "EXT: Unable to unregister Extended Prefix "
- "Opaque LSA functions: Wrong scope!");
- else
+ if ((OspfEXT.scope == OSPF_OPAQUE_AREA_LSA)
+ || (OspfEXT.scope == OSPF_OPAQUE_AS_LSA))
ospf_delete_opaque_functab(OspfEXT.scope,
OPAQUE_TYPE_EXTENDED_PREFIX_LSA);
@@ -316,8 +315,9 @@ static void set_prefix_sid(struct ext_itf *exti, uint8_t algorithm,
if ((algorithm != SR_ALGORITHM_SPF)
&& (algorithm != SR_ALGORITHM_STRICT_SPF)) {
- zlog_warn("EXT (%s): unrecognized algorithm, not SPF or S-SPF",
- __func__);
+ flog_err(OSPF_ERR_INVALID_ALGORITHM,
+ "EXT (%s): unrecognized algorithm, not SPF or S-SPF",
+ __func__);
return;
}
@@ -538,8 +538,6 @@ static int ospf_ext_link_new_if(struct interface *ifp)
int rc = -1;
if (lookup_ext_by_ifp(ifp) != NULL) {
- zlog_warn("EXT (%s): interface %s is already in use", __func__,
- ifp ? ifp->name : "-");
rc = 0; /* Do nothing here. */
return rc;
}
@@ -573,7 +571,8 @@ static int ospf_ext_link_del_if(struct interface *ifp)
rc = 0;
} else {
- zlog_warn("EXT (%s): interface %s is not found", __func__,
+ flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+ "EXT (%s): interface %s is not found", __func__,
ifp ? ifp->name : "-");
}
@@ -590,11 +589,8 @@ static void ospf_ext_link_ism_change(struct ospf_interface *oi, int old_status)
/* Get interface information for Segment Routing */
exti = lookup_ext_by_ifp(oi->ifp);
- if (exti == NULL) {
- zlog_warn("EXT (%s): Cannot get Extended info. from OI(%s)",
- __func__, IF_NAME(oi));
+ if (exti == NULL)
return;
- }
/* Determine if interface is related to Adjacency or LAN Adj. SID */
if (oi->type != OSPF_IFTYPE_LOOPBACK) {
@@ -623,7 +619,8 @@ static void ospf_ext_pref_ism_change(struct ospf_interface *oi, int old_status)
/* Get interface information for Segment Routing */
exti = lookup_ext_by_ifp(oi->ifp);
if (exti == NULL) {
- zlog_warn("EXT (%s): Cannot get Extended info. from OI(%s)",
+ flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+ "EXT (%s): Cannot get Extended info. from OI(%s)",
__func__, IF_NAME(oi));
return;
}
@@ -660,13 +657,15 @@ static void ospf_ext_link_nsm_change(struct ospf_neighbor *nbr, int old_status)
/* Get interface information for Segment Routing */
exti = lookup_ext_by_ifp(oi->ifp);
if (exti == NULL) {
- zlog_warn("EXT (%s): Cannot get Extended info. from OI(%s)",
+ flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+ "EXT (%s): Cannot get Extended info. from OI(%s)",
__func__, IF_NAME(oi));
return;
}
if (oi->area == NULL || oi->area->ospf == NULL) {
- zlog_warn("EXT (%s): Cannot refer to OSPF from OI(%s)",
+ flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+ "EXT (%s): Cannot refer to OSPF from OI(%s)",
__func__, IF_NAME(oi));
return;
}
@@ -761,7 +760,8 @@ static int ospf_ext_link_lsa_update(struct ospf_lsa *lsa)
{
/* Sanity Check */
if (lsa == NULL) {
- zlog_warn("EXT (%s): Abort! LSA is NULL", __func__);
+ flog_warn(OSPF_WARN_LSA_NULL, "EXT (%s): Abort! LSA is NULL",
+ __func__);
return -1;
}
@@ -794,7 +794,8 @@ static int ospf_ext_pref_lsa_update(struct ospf_lsa *lsa)
/* Sanity Check */
if (lsa == NULL) {
- zlog_warn("EXT (%s): Abort! LSA is NULL", __func__);
+ flog_warn(OSPF_WARN_LSA_NULL, "EXT (%s): Abort! LSA is NULL",
+ __func__);
return -1;
}
@@ -929,10 +930,6 @@ static struct ospf_lsa *ospf_ext_pref_lsa_new(struct ospf_area *area,
/* Create a stream for LSA. */
s = stream_new(OSPF_MAX_LSA_SIZE);
- if (s == NULL) {
- zlog_warn("EXT (%s): stream_new() error", __func__);
- return NULL;
- }
/* Prepare LSA Header */
lsah = (struct lsa_header *)STREAM_DATA(s);
@@ -1007,10 +1004,6 @@ static struct ospf_lsa *ospf_ext_link_lsa_new(struct ospf_area *area,
/* Create a stream for LSA. */
s = stream_new(OSPF_MAX_LSA_SIZE);
- if (s == NULL) {
- zlog_warn("EXT (%s): stream_new() error", __func__);
- return NULL;
- }
lsah = (struct lsa_header *)STREAM_DATA(s);
options = OSPF_OPTION_O; /* Don't forget this :-) */
@@ -1069,13 +1062,15 @@ static int ospf_ext_pref_lsa_originate1(struct ospf_area *area,
/* Create new Opaque-LSA/Extended Prefix Opaque LSA instance. */
new = ospf_ext_pref_lsa_new(area, exti);
if (new == NULL) {
- zlog_warn("EXT (%s): ospf_ext_pref_lsa_new() error", __func__);
+ flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+ "EXT (%s): ospf_ext_pref_lsa_new() error", __func__);
return rc;
}
/* Install this LSA into LSDB. */
if (ospf_lsa_install(area->ospf, NULL /*oi */, new) == NULL) {
- zlog_warn("EXT (%s): ospf_lsa_install() error", __func__);
+ flog_warn(OSPF_WARN_LSA_INSTALL_FAILURE,
+ "EXT (%s): ospf_lsa_install() error", __func__);
ospf_lsa_unlock(&new);
return rc;
}
@@ -1121,13 +1116,15 @@ static int ospf_ext_link_lsa_originate1(struct ospf_area *area,
/* Create new Opaque-LSA/Extended Link Opaque LSA instance. */
new = ospf_ext_link_lsa_new(area, exti);
if (new == NULL) {
- zlog_warn("EXT (%s): ospf_ext_link_lsa_new() error", __func__);
+ flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+ "EXT (%s): ospf_ext_link_lsa_new() error", __func__);
return rc;
}
/* Install this LSA into LSDB. */
if (ospf_lsa_install(area->ospf, NULL /*oi */, new) == NULL) {
- zlog_warn("EXT (%s): ospf_lsa_install() error", __func__);
+ flog_warn(OSPF_WARN_LSA_INSTALL_FAILURE,
+ "EXT (%s): ospf_lsa_install() error", __func__);
ospf_lsa_unlock(&new);
return rc;
}
@@ -1193,9 +1190,9 @@ static int ospf_ext_pref_lsa_originate(void *arg)
if (CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ENGAGED)) {
if (CHECK_FLAG(exti->flags,
EXT_LPFLG_LSA_FORCED_REFRESH)) {
- zlog_warn(
- "EXT (%s): Refresh instead of "
- "Originate",
+ flog_warn(
+ OSPF_WARN_EXT_LSA_UNEXPECTED,
+ "EXT (%s): Refresh instead of Originate",
__func__);
UNSET_FLAG(exti->flags,
EXT_LPFLG_LSA_FORCED_REFRESH);
@@ -1251,9 +1248,9 @@ static int ospf_ext_link_lsa_originate(void *arg)
if (CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ENGAGED)) {
if (CHECK_FLAG(exti->flags,
EXT_LPFLG_LSA_FORCED_REFRESH)) {
- zlog_warn(
- "EXT (%s): Refresh instead of "
- "Originate",
+ flog_warn(
+ OSPF_WARN_EXT_LSA_UNEXPECTED,
+ "EXT (%s): Refresh instead of Originate",
__func__);
UNSET_FLAG(exti->flags,
EXT_LPFLG_LSA_FORCED_REFRESH);
@@ -1303,14 +1300,16 @@ static struct ospf_lsa *ospf_ext_pref_lsa_refresh(struct ospf_lsa *lsa)
/* Lookup this lsa corresponding Extended parameters */
exti = lookup_ext_by_instance(lsa);
if (exti == NULL) {
- zlog_warn("EXT (%s): Invalid parameter LSA ID", __func__);
+ flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+ "EXT (%s): Invalid parameter LSA ID", __func__);
/* Flush it anyway. */
lsa->data->ls_age = htons(OSPF_LSA_MAXAGE);
}
/* Check if Interface was not disable in the interval */
if ((exti != NULL) && !CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ACTIVE)) {
- zlog_warn("EXT (%s): Interface was Disabled: Flush it!",
+ flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+ "EXT (%s): Interface was Disabled: Flush it!",
__func__);
/* Flush it anyway. */
lsa->data->ls_age = htons(OSPF_LSA_MAXAGE);
@@ -1328,7 +1327,8 @@ static struct ospf_lsa *ospf_ext_pref_lsa_refresh(struct ospf_lsa *lsa)
new = ospf_ext_pref_lsa_new(area, exti);
if (new == NULL) {
- zlog_warn("EXT (%s): ospf_ext_pref_lsa_new() error", __func__);
+ flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+ "EXT (%s): ospf_ext_pref_lsa_new() error", __func__);
return NULL;
}
new->data->ls_seqnum = lsa_seqnum_increment(lsa);
@@ -1345,7 +1345,8 @@ static struct ospf_lsa *ospf_ext_pref_lsa_refresh(struct ospf_lsa *lsa)
top = ospf_lookup_by_vrf_id(VRF_DEFAULT);
if (ospf_lsa_install(top, NULL /*oi */, new) == NULL) {
- zlog_warn("EXT (%s): ospf_lsa_install() error", __func__);
+ flog_warn(OSPF_WARN_LSA_INSTALL_FAILURE,
+ "EXT (%s): ospf_lsa_install() error", __func__);
ospf_lsa_unlock(&new);
return NULL;
}
@@ -1386,14 +1387,16 @@ static struct ospf_lsa *ospf_ext_link_lsa_refresh(struct ospf_lsa *lsa)
/* Lookup this LSA corresponding Extended parameters */
exti = lookup_ext_by_instance(lsa);
if (exti == NULL) {
- zlog_warn("EXT (%s): Invalid parameter LSA ID", __func__);
+ flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+ "EXT (%s): Invalid parameter LSA ID", __func__);
/* Flush it anyway. */
lsa->data->ls_age = htons(OSPF_LSA_MAXAGE);
}
/* Check if Interface was not disable in the interval */
if ((exti != NULL) && !CHECK_FLAG(exti->flags, EXT_LPFLG_LSA_ACTIVE)) {
- zlog_warn("EXT (%s): Interface was Disabled: Flush it!",
+ flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+ "EXT (%s): Interface was Disabled: Flush it!",
__func__);
lsa->data->ls_age = htons(OSPF_LSA_MAXAGE);
}
@@ -1409,7 +1412,8 @@ static struct ospf_lsa *ospf_ext_link_lsa_refresh(struct ospf_lsa *lsa)
/* Create new Opaque-LSA/Extended Link instance */
new = ospf_ext_link_lsa_new(area, exti);
if (new == NULL) {
- zlog_warn("EXT (%s): Error creating new LSA", __func__);
+ flog_warn(OSPF_WARN_EXT_LSA_UNEXPECTED,
+ "EXT (%s): Error creating new LSA", __func__);
return NULL;
}
new->data->ls_seqnum = lsa_seqnum_increment(lsa);
@@ -1417,7 +1421,8 @@ static struct ospf_lsa *ospf_ext_link_lsa_refresh(struct ospf_lsa *lsa)
/* Install this LSA into LSDB. */
/* Given "lsa" will be freed in the next function */
if (ospf_lsa_install(top, NULL /*oi */, new) == NULL) {
- zlog_warn("EXT (%s): Error installing new LSA", __func__);
+ flog_warn(OSPF_WARN_LSA_INSTALL_FAILURE,
+ "EXT (%s): Error installing new LSA", __func__);
ospf_lsa_unlock(&new);
return NULL;
}
@@ -1464,9 +1469,9 @@ static void ospf_ext_pref_lsa_schedule(struct ext_itf *exti,
/* Set LSA header information */
if (exti->area == NULL) {
- zlog_warn(
- "EXT (%s): Flooding is Area scope but area is not yet "
- "set",
+ flog_warn(
+ OSPF_WARN_EXT_LSA_UNEXPECTED,
+ "EXT (%s): Flooding is Area scope but area is not yet set",
__func__);
if (OspfEXT.area == NULL) {
top = ospf_lookup_by_vrf_id(VRF_DEFAULT);
@@ -1494,9 +1499,6 @@ static void ospf_ext_pref_lsa_schedule(struct ext_itf *exti,
UNSET_FLAG(exti->flags, EXT_LPFLG_LSA_ENGAGED);
ospf_opaque_lsa_flush_schedule(&lsa);
break;
- default:
- zlog_warn("EXT (%s): Unknown opcode", __func__);
- break;
}
}
@@ -1528,9 +1530,9 @@ static void ospf_ext_link_lsa_schedule(struct ext_itf *exti,
/* Set LSA header information */
if (exti->area == NULL) {
- zlog_warn(
- "EXT (%s): Flooding is Area scope but area is not "
- "yet set",
+ flog_warn(
+ OSPF_WARN_EXT_LSA_UNEXPECTED,
+ "EXT (%s): Flooding is Area scope but area is not yet set",
__func__);
if (OspfEXT.area == NULL) {
top = ospf_lookup_by_vrf_id(VRF_DEFAULT);
@@ -1558,9 +1560,6 @@ static void ospf_ext_link_lsa_schedule(struct ext_itf *exti,
UNSET_FLAG(exti->flags, EXT_LPFLG_LSA_ENGAGED);
ospf_opaque_lsa_flush_schedule(&lsa);
break;
- default:
- zlog_warn("EXT (%s): Unknown opcode", __func__);
- break;
}
}
diff --git a/ospfd/ospf_flood.c b/ospfd/ospf_flood.c
index b4e9dda58..807845593 100644
--- a/ospfd/ospf_flood.c
+++ b/ospfd/ospf_flood.c
@@ -539,7 +539,6 @@ static int ospf_flood_through_interface(struct ospf_interface *oi,
IP addresses for these packets are the neighbors' IP
addresses. */
if (oi->type == OSPF_IFTYPE_NBMA) {
- struct route_node *rn;
struct ospf_neighbor *nbr;
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn))
diff --git a/ospfd/ospf_ia.c b/ospfd/ospf_ia.c
index 86d15480a..f1ba8a31e 100644
--- a/ospfd/ospf_ia.c
+++ b/ospfd/ospf_ia.c
@@ -589,23 +589,19 @@ static void ospf_examine_transit_summaries(struct ospf_area *area,
void ospf_ia_routing(struct ospf *ospf, struct route_table *rt,
struct route_table *rtrs)
{
+ struct listnode *node;
struct ospf_area *area;
if (IS_DEBUG_OSPF_EVENT)
zlog_debug("ospf_ia_routing():start");
if (IS_OSPF_ABR(ospf)) {
- struct listnode *node;
- struct ospf_area *area;
-
switch (ospf->abr_type) {
case OSPF_ABR_STAND:
if (IS_DEBUG_OSPF_EVENT)
zlog_debug("ospf_ia_routing():Standard ABR");
if ((area = ospf->backbone)) {
- struct listnode *node;
-
if (IS_DEBUG_OSPF_EVENT) {
zlog_debug(
"ospf_ia_routing():backbone area found");
@@ -694,8 +690,6 @@ void ospf_ia_routing(struct ospf *ospf, struct route_table *rt,
break;
}
} else {
- struct listnode *node;
-
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
"ospf_ia_routing():not ABR, considering all areas");
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index 24584f671..2ad36ae36 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -1033,7 +1033,7 @@ static int ospf_vl_set_params(struct ospf_vl_data *vl_data, struct vertex *v)
* there should be due to the ospf_spf_has_link() check
* in SPF. Lets warn and try pick a link anyway.
*/
- zlog_warn("ospf_vl_set_params: No backlink for %s!",
+ zlog_info("ospf_vl_set_params: No backlink for %s!",
vl_data->vl_oi->ifp->name);
for (i = 0; i < ntohs(rl->links); i++) {
switch (rl->link[i].type) {
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index 7c8a68994..4d46e9739 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -50,7 +50,7 @@
#include "ospfd/ospf_ase.h"
#include "ospfd/ospf_zebra.h"
#include "ospfd/ospf_abr.h"
-
+#include "ospfd/ospf_errors.h"
uint32_t get_metric(uint8_t *metric)
{
@@ -398,7 +398,8 @@ struct ospf_neighbor *ospf_nbr_lookup_ptop(struct ospf_interface *oi)
/* PtoP link must have only 1 neighbor. */
if (ospf_nbr_count(oi, 0) > 1)
- zlog_warn("Point-to-Point link has more than 1 neighobrs.");
+ flog_warn(OSPF_WARN_PTP_NEIGHBOR,
+ "Point-to-Point link has more than 1 neighobrs.");
return nbr;
}
@@ -446,7 +447,8 @@ static char link_info_set(struct stream **s, struct in_addr id,
}
if (ret == OSPF_MAX_LSA_SIZE) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA_SIZE,
"%s: Out of space in LSA stream, left %zd, size %zd",
__func__, STREAM_WRITEABLE(*s),
STREAM_SIZE(*s));
@@ -1817,12 +1819,11 @@ struct ospf_lsa *ospf_translated_nssa_originate(struct ospf *ospf,
}
if ((new = ospf_lsa_install(ospf, NULL, new)) == NULL) {
- if (IS_DEBUG_OSPF_NSSA)
- zlog_debug(
- "ospf_lsa_translated_nssa_originate(): "
- "Could not install LSA "
- "id %s",
- inet_ntoa(type7->data->id));
+ flog_warn(OSPF_WARN_LSA_INSTALL_FAILURE,
+ "ospf_lsa_translated_nssa_originate(): "
+ "Could not install LSA "
+ "id %s",
+ inet_ntoa(type7->data->id));
return NULL;
}
@@ -1918,11 +1919,10 @@ struct ospf_lsa *ospf_translated_nssa_refresh(struct ospf *ospf,
}
if (!(new = ospf_lsa_install(ospf, NULL, new))) {
- if (IS_DEBUG_OSPF_NSSA)
- zlog_debug(
- "ospf_translated_nssa_refresh(): Could not install "
- "translated LSA, Id %s",
- inet_ntoa(type7->data->id));
+ flog_warn(
+ OSPF_WARN_LSA_INSTALL_FAILURE,
+ "ospf_translated_nssa_refresh(): Could not install translated LSA, Id %s",
+ inet_ntoa(type7->data->id));
return NULL;
}
@@ -2043,19 +2043,28 @@ int ospf_external_lsa_originate_timer(struct thread *thread)
if (!ext_list)
return 0;
- for (ALL_LIST_ELEMENTS_RO(ext_list, node, ext))
+ for (ALL_LIST_ELEMENTS_RO(ext_list, node, ext)) {
/* Originate As-external-LSA from all type of distribute source.
*/
- if ((rt = ext->external_info))
- for (rn = route_top(rt); rn; rn = route_next(rn))
- if ((ei = rn->info) != NULL)
- if (!is_prefix_default(
- (struct prefix_ipv4 *)&ei
- ->p))
- if (!ospf_external_lsa_originate(
- ospf, ei))
- zlog_warn(
- "LSA: AS-external-LSA was not originated.");
+ rt = ext->external_info;
+ if (!rt)
+ continue;
+
+ for (rn = route_top(rt); rn; rn = route_next(rn)) {
+ ei = rn->info;
+
+ if (!ei)
+ continue;
+
+ if (is_prefix_default((struct prefix_ipv4 *)&ei->p))
+ continue;
+
+ if (!ospf_external_lsa_originate(ospf, ei))
+ flog_warn(
+ OSPF_WARN_LSA_INSTALL_FAILURE,
+ "LSA: AS-external-LSA was not originated.");
+ }
+ }
return 0;
}
@@ -2522,15 +2531,8 @@ void ospf_discard_from_db(struct ospf *ospf, struct ospf_lsdb *lsdb,
{
struct ospf_lsa *old;
- if (!lsdb) {
- zlog_warn("%s: Called with NULL lsdb!", __func__);
- if (!lsa)
- zlog_warn("%s: and NULL LSA!", __func__);
- else
- zlog_warn("LSA[Type%d:%s]: not associated with LSDB!",
- lsa->data->type, inet_ntoa(lsa->data->id));
+ if (!lsdb)
return;
- }
old = ospf_lsdb_lookup(lsdb, lsa);
@@ -2841,11 +2843,13 @@ static int ospf_maxage_lsa_remover(struct thread *thread)
if (lsa->lsdb) {
ospf_discard_from_db(ospf, lsa->lsdb, lsa);
ospf_lsdb_delete(lsa->lsdb, lsa);
- } else
- zlog_warn(
- "%s: LSA[Type%d:%s]: No associated LSDB!",
- __func__, lsa->data->type,
- inet_ntoa(lsa->data->id));
+ } else {
+ if (IS_DEBUG_OSPF(lsa, LSA_FLOODING))
+ zlog_debug(
+ "%s: LSA[Type%d:%s]: No associated LSDB!",
+ __func__, lsa->data->type,
+ inet_ntoa(lsa->data->id));
+ }
}
/* A MaxAge LSA must be removed immediately from the router's link
diff --git a/ospfd/ospf_lsdb.c b/ospfd/ospf_lsdb.c
index ef965a5f9..f39bea976 100644
--- a/ospfd/ospf_lsdb.c
+++ b/ospfd/ospf_lsdb.c
@@ -142,19 +142,8 @@ void ospf_lsdb_delete(struct ospf_lsdb *lsdb, struct ospf_lsa *lsa)
struct prefix_ls lp;
struct route_node *rn;
- if (!lsdb) {
- zlog_warn("%s: Called with NULL LSDB", __func__);
- if (lsa)
- zlog_warn("LSA[Type%d:%s]: LSA %p, lsa->lsdb %p",
- lsa->data->type, inet_ntoa(lsa->data->id),
- (void *)lsa, (void *)lsa->lsdb);
+ if (!lsdb || !lsa)
return;
- }
-
- if (!lsa) {
- zlog_warn("%s: Called with NULL LSA", __func__);
- return;
- }
assert(lsa->data->type < OSPF_MAX_LSA);
table = lsdb->type[lsa->data->type].db;
diff --git a/ospfd/ospf_neighbor.c b/ospfd/ospf_neighbor.c
index d647525ea..a58bd93b6 100644
--- a/ospfd/ospf_neighbor.c
+++ b/ospfd/ospf_neighbor.c
@@ -269,9 +269,10 @@ void ospf_nbr_add_self(struct ospf_interface *oi, struct in_addr router_id)
rn = route_node_get(oi->nbrs, &p);
if (rn->info) {
/* There is already pseudo neighbor. */
- zlog_warn(
- "router_id %s already present in neighbor table. node refcount %u",
- inet_ntoa(router_id), rn->lock);
+ if (IS_DEBUG_OSPF_EVENT)
+ zlog_debug(
+ "router_id %s already present in neighbor table. node refcount %u",
+ inet_ntoa(router_id), rn->lock);
route_unlock_node(rn);
} else
rn->info = oi->nbr_self;
diff --git a/ospfd/ospf_network.c b/ospfd/ospf_network.c
index 1fb930659..ed11f4535 100644
--- a/ospfd/ospf_network.c
+++ b/ospfd/ospf_network.c
@@ -51,7 +51,8 @@ int ospf_if_add_allspfrouters(struct ospf *top, struct prefix *p,
p->u.prefix4, htonl(OSPF_ALLSPFROUTERS),
ifindex);
if (ret < 0)
- zlog_warn(
+ flog_err(
+ LIB_ERR_SOCKET,
"can't setsockopt IP_ADD_MEMBERSHIP (fd %d, addr %s, "
"ifindex %u, AllSPFRouters): %s; perhaps a kernel limit "
"on # of multicast group memberships has been exceeded?",
@@ -76,11 +77,11 @@ int ospf_if_drop_allspfrouters(struct ospf *top, struct prefix *p,
p->u.prefix4, htonl(OSPF_ALLSPFROUTERS),
ifindex);
if (ret < 0)
- zlog_warn(
- "can't setsockopt IP_DROP_MEMBERSHIP (fd %d, addr %s, "
- "ifindex %u, AllSPFRouters): %s",
- top->fd, inet_ntoa(p->u.prefix4), ifindex,
- safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "can't setsockopt IP_DROP_MEMBERSHIP (fd %d, addr %s, "
+ "ifindex %u, AllSPFRouters): %s",
+ top->fd, inet_ntoa(p->u.prefix4), ifindex,
+ safe_strerror(errno));
else {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
@@ -101,7 +102,8 @@ int ospf_if_add_alldrouters(struct ospf *top, struct prefix *p,
p->u.prefix4, htonl(OSPF_ALLDROUTERS),
ifindex);
if (ret < 0)
- zlog_warn(
+ flog_err(
+ LIB_ERR_SOCKET,
"can't setsockopt IP_ADD_MEMBERSHIP (fd %d, addr %s, "
"ifindex %u, AllDRouters): %s; perhaps a kernel limit "
"on # of multicast group memberships has been exceeded?",
@@ -124,11 +126,11 @@ int ospf_if_drop_alldrouters(struct ospf *top, struct prefix *p,
p->u.prefix4, htonl(OSPF_ALLDROUTERS),
ifindex);
if (ret < 0)
- zlog_warn(
- "can't setsockopt IP_DROP_MEMBERSHIP (fd %d, addr %s, "
- "ifindex %u, AllDRouters): %s",
- top->fd, inet_ntoa(p->u.prefix4), ifindex,
- safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "can't setsockopt IP_DROP_MEMBERSHIP (fd %d, addr %s, "
+ "ifindex %u, AllDRouters): %s",
+ top->fd, inet_ntoa(p->u.prefix4), ifindex,
+ safe_strerror(errno));
else
zlog_debug(
"interface %s [%u] leave AllDRouters Multicast group.",
@@ -145,8 +147,9 @@ int ospf_if_ipmulticast(struct ospf *top, struct prefix *p, ifindex_t ifindex)
/* Prevent receiving self-origined multicast packets. */
ret = setsockopt_ipv4_multicast_loop(top->fd, 0);
if (ret < 0)
- zlog_warn("can't setsockopt IP_MULTICAST_LOOP(0) for fd %d: %s",
- top->fd, safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "can't setsockopt IP_MULTICAST_LOOP(0) for fd %d: %s",
+ top->fd, safe_strerror(errno));
/* Explicitly set multicast ttl to 1 -- endo. */
val = 1;
@@ -154,19 +157,20 @@ int ospf_if_ipmulticast(struct ospf *top, struct prefix *p, ifindex_t ifindex)
ret = setsockopt(top->fd, IPPROTO_IP, IP_MULTICAST_TTL, (void *)&val,
len);
if (ret < 0)
- zlog_warn("can't setsockopt IP_MULTICAST_TTL(1) for fd %d: %s",
- top->fd, safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "can't setsockopt IP_MULTICAST_TTL(1) for fd %d: %s",
+ top->fd, safe_strerror(errno));
#ifndef GNU_LINUX
/* For GNU LINUX ospf_write uses IP_PKTINFO, in_pktinfo to send
* packet out of ifindex. Below would be used Non Linux system.
*/
ret = setsockopt_ipv4_multicast_if(top->fd, p->u.prefix4, ifindex);
if (ret < 0)
- zlog_warn(
- "can't setsockopt IP_MULTICAST_IF(fd %d, addr %s, "
- "ifindex %u): %s",
- top->fd, inet_ntoa(p->u.prefix4), ifindex,
- safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "can't setsockopt IP_MULTICAST_IF(fd %d, addr %s, "
+ "ifindex %u): %s",
+ top->fd, inet_ntoa(p->u.prefix4), ifindex,
+ safe_strerror(errno));
#endif
return ret;
@@ -190,7 +194,8 @@ int ospf_sock_init(struct ospf *ospf)
ospf_sock = vrf_socket(AF_INET, SOCK_RAW, IPPROTO_OSPFIGP,
ospf->vrf_id, ospf->name);
if (ospf_sock < 0) {
- zlog_err("ospf_read_sock_init: socket: %s",
+ flog_err(LIB_ERR_SOCKET,
+ "ospf_read_sock_init: socket: %s",
safe_strerror(errno));
exit(1);
}
@@ -200,8 +205,9 @@ int ospf_sock_init(struct ospf *ospf)
ret = setsockopt(ospf_sock, IPPROTO_IP, IP_HDRINCL, &hincl,
sizeof(hincl));
if (ret < 0) {
- zlog_warn("Can't set IP_HDRINCL option for fd %d: %s",
- ospf_sock, safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "Can't set IP_HDRINCL option for fd %d: %s",
+ ospf_sock, safe_strerror(errno));
close(ospf_sock);
break;
}
@@ -211,21 +217,24 @@ int ospf_sock_init(struct ospf *ospf)
ret = setsockopt_ipv4_tos(ospf_sock,
IPTOS_PREC_INTERNETCONTROL);
if (ret < 0) {
- zlog_warn("can't set sockopt IP_TOS %d to socket %d: %s",
- tos, ospf_sock, safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "can't set sockopt IP_TOS %d to socket %d: %s",
+ tos, ospf_sock, safe_strerror(errno));
close(ospf_sock); /* Prevent sd leak. */
break;
}
#else /* !IPTOS_PREC_INTERNETCONTROL */
#warning "IP_HDRINCL not available, nor is IPTOS_PREC_INTERNETCONTROL"
- zlog_warn("IP_HDRINCL option not available");
+ flog_err(LIB_ERR_UNAVAILABLE,
+ "IP_HDRINCL option not available");
#endif /* IP_HDRINCL */
ret = setsockopt_ifindex(AF_INET, ospf_sock, 1);
if (ret < 0)
- zlog_warn("Can't set pktinfo option for fd %d",
- ospf_sock);
+ flog_err(LIB_ERR_SOCKET,
+ "Can't set pktinfo option for fd %d",
+ ospf_sock);
setsockopt_so_sendbuf(ospf_sock, bufsize);
setsockopt_so_recvbuf(ospf_sock, bufsize);
diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c
index 1e72e3db6..fc8b516af 100644
--- a/ospfd/ospf_nsm.c
+++ b/ospfd/ospf_nsm.c
@@ -48,6 +48,7 @@
#include "ospfd/ospf_flood.h"
#include "ospfd/ospf_abr.h"
#include "ospfd/ospf_bfd.h"
+#include "ospfd/ospf_errors.h"
DEFINE_HOOK(ospf_nsm_change,
(struct ospf_neighbor * on, int state, int oldstate),
@@ -713,7 +714,7 @@ static void nsm_change_state(struct ospf_neighbor *nbr, int state)
ospf_router_lsa_update_area(oi->area);
if (oi->type == OSPF_IFTYPE_VIRTUALLINK) {
- struct ospf_area *vl_area = ospf_area_lookup_by_area_id(
+ vl_area = ospf_area_lookup_by_area_id(
oi->ospf, oi->vl_data->vl_area_id);
if (vl_area)
@@ -795,7 +796,8 @@ int ospf_nsm_event(struct thread *thread)
* not
* try set next_state.
*/
- zlog_warn(
+ flog_err(
+ OSPF_ERR_FSM_INVALID_STATE,
"NSM[%s:%s]: %s (%s): "
"Warning: action tried to change next_state to %s",
IF_NAME(nbr->oi), inet_ntoa(nbr->router_id),
diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c
index be62eb390..9066dda73 100644
--- a/ospfd/ospf_opaque.c
+++ b/ospfd/ospf_opaque.c
@@ -54,6 +54,7 @@
#include "ospfd/ospf_sr.h"
#include "ospfd/ospf_ri.h"
#include "ospfd/ospf_ext.h"
+#include "ospfd/ospf_errors.h"
DEFINE_MTYPE_STATIC(OSPFD, OSPF_OPAQUE_FUNCTAB, "OSPF opaque function table")
DEFINE_MTYPE_STATIC(OSPFD, OPAQUE_INFO_PER_TYPE, "OSPF opaque per-type info")
@@ -352,7 +353,8 @@ static struct list *ospf_get_opaque_funclist(uint8_t lsa_type)
funclist = ospf_opaque_type11_funclist;
break;
default:
- zlog_warn("ospf_get_opaque_funclist: Unexpected LSA-type(%u)",
+ flog_warn(OSPF_WARN_LSA_UNEXPECTED,
+ "ospf_get_opaque_funclist: Unexpected LSA-type(%u)",
lsa_type);
break;
}
@@ -377,27 +379,21 @@ int ospf_register_opaque_functab(
{
struct list *funclist;
struct ospf_opaque_functab *new;
- int rc = -1;
- if ((funclist = ospf_get_opaque_funclist(lsa_type)) == NULL) {
- zlog_warn(
- "ospf_register_opaque_functab: Cannot get funclist"
- " for Type-%u LSAs?",
- lsa_type);
- goto out;
- } else {
- struct listnode *node, *nnode;
- struct ospf_opaque_functab *functab;
+ if ((funclist = ospf_get_opaque_funclist(lsa_type)) == NULL)
+ return -1;
- for (ALL_LIST_ELEMENTS(funclist, node, nnode, functab))
- if (functab->opaque_type == opaque_type) {
- zlog_warn(
- "ospf_register_opaque_functab: Duplicated entry?:"
- " lsa_type(%u), opaque_type(%u)",
- lsa_type, opaque_type);
- goto out;
- }
- }
+ struct listnode *node, *nnode;
+ struct ospf_opaque_functab *functab;
+
+ for (ALL_LIST_ELEMENTS(funclist, node, nnode, functab))
+ if (functab->opaque_type == opaque_type) {
+ flog_warn(
+ OSPF_WARN_LSA,
+ "ospf_register_opaque_functab: Duplicated entry?: lsa_type(%u), opaque_type(%u)",
+ lsa_type, opaque_type);
+ return -1;
+ }
new = XCALLOC(MTYPE_OSPF_OPAQUE_FUNCTAB,
sizeof(struct ospf_opaque_functab));
@@ -418,10 +414,8 @@ int ospf_register_opaque_functab(
new->del_lsa_hook = del_lsa_hook;
listnode_add(funclist, new);
- rc = 0;
-out:
- return rc;
+ return 0;
}
void ospf_delete_opaque_functab(uint8_t lsa_type, uint8_t opaque_type)
@@ -573,7 +567,8 @@ register_opaque_info_per_type(struct ospf_opaque_functab *functab,
listnode_add(top->opaque_lsa_self, oipt);
break;
default:
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA_UNEXPECTED,
"register_opaque_info_per_type: Unexpected LSA-type(%u)",
new->data->type);
free_opaque_info_per_type((void *)oipt);
@@ -618,7 +613,8 @@ static void free_opaque_info_owner(void *val)
break;
}
default:
- zlog_warn("free_opaque_info_owner: Unexpected LSA-type(%u)",
+ flog_warn(OSPF_WARN_LSA_UNEXPECTED,
+ "free_opaque_info_owner: Unexpected LSA-type(%u)",
oipt->lsa_type);
break; /* This case may not exist. */
}
@@ -662,27 +658,31 @@ lookup_opaque_info_by_type(struct ospf_lsa *lsa)
if ((oi = lsa->oi) != NULL)
listtop = oi->opaque_lsa_self;
else
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA,
"Type-9 Opaque-LSA: Reference to OI is missing?");
break;
case OSPF_OPAQUE_AREA_LSA:
if ((area = lsa->area) != NULL)
listtop = area->opaque_lsa_self;
else
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA,
"Type-10 Opaque-LSA: Reference to AREA is missing?");
break;
case OSPF_OPAQUE_AS_LSA:
top = ospf_lookup_by_vrf_id(lsa->vrf_id);
if ((area = lsa->area) != NULL && (top = area->ospf) == NULL) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA,
"Type-11 Opaque-LSA: Reference to OSPF is missing?");
break; /* Unlikely to happen. */
}
listtop = top->opaque_lsa_self;
break;
default:
- zlog_warn("lookup_opaque_info_by_type: Unexpected LSA-type(%u)",
+ flog_warn(OSPF_WARN_LSA_UNEXPECTED,
+ "lookup_opaque_info_by_type: Unexpected LSA-type(%u)",
lsa->data->type);
break;
}
@@ -1286,9 +1286,10 @@ void ospf_opaque_lsa_originate_schedule(struct ospf_interface *oi, int *delay0)
int delay = 0;
if ((top = oi_to_top(oi)) == NULL || (area = oi->area) == NULL) {
- zlog_warn(
- "ospf_opaque_lsa_originate_schedule: Invalid argument?");
- goto out;
+ if (IS_DEBUG_OSPF_EVENT)
+ zlog_debug(
+ "ospf_opaque_lsa_originate_schedule: Invalid argument?");
+ return;
}
/* It may not a right time to schedule origination now. */
@@ -1296,7 +1297,7 @@ void ospf_opaque_lsa_originate_schedule(struct ospf_interface *oi, int *delay0)
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
"ospf_opaque_lsa_originate_schedule: Not operational.");
- goto out; /* This is not an error. */
+ return; /* This is not an error. */
}
if (delay0 != NULL)
@@ -1443,9 +1444,6 @@ void ospf_opaque_lsa_originate_schedule(struct ospf_interface *oi, int *delay0)
if (delay0 != NULL)
*delay0 = delay;
-
-out:
- return;
}
static int ospf_opaque_type9_lsa_originate(struct thread *t)
@@ -1524,7 +1522,8 @@ static void ospf_opaque_lsa_reoriginate_resume(struct list *listtop, void *arg)
continue;
if ((*functab->lsa_originator)(arg) != 0) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA,
"ospf_opaque_lsa_reoriginate_resume: Failed (opaque-type=%u)",
oipt->opaque_type);
continue;
@@ -1564,7 +1563,8 @@ struct ospf_lsa *ospf_opaque_lsa_install(struct ospf_lsa *lsa, int rt_recalc)
}
/* Register the new lsa entry and get its control info. */
else if ((oipi = register_opaque_lsa(lsa)) == NULL) {
- zlog_warn("ospf_opaque_lsa_install: register_opaque_lsa() ?");
+ flog_warn(OSPF_WARN_LSA,
+ "ospf_opaque_lsa_install: register_opaque_lsa() ?");
goto out;
}
@@ -1576,14 +1576,16 @@ struct ospf_lsa *ospf_opaque_lsa_install(struct ospf_lsa *lsa, int rt_recalc)
case OSPF_OPAQUE_LINK_LSA:
if ((top = oi_to_top(lsa->oi)) == NULL) {
/* Above conditions must have passed. */
- zlog_warn("ospf_opaque_lsa_install: Sonmething wrong?");
+ flog_warn(OSPF_WARN_LSA,
+ "ospf_opaque_lsa_install: Something wrong?");
goto out;
}
break;
case OSPF_OPAQUE_AREA_LSA:
if (lsa->area == NULL || (top = lsa->area->ospf) == NULL) {
/* Above conditions must have passed. */
- zlog_warn("ospf_opaque_lsa_install: Sonmething wrong?");
+ flog_warn(OSPF_WARN_LSA,
+ "ospf_opaque_lsa_install: Something wrong?");
goto out;
}
break;
@@ -1591,12 +1593,14 @@ struct ospf_lsa *ospf_opaque_lsa_install(struct ospf_lsa *lsa, int rt_recalc)
top = ospf_lookup_by_vrf_id(lsa->vrf_id);
if (lsa->area != NULL && (top = lsa->area->ospf) == NULL) {
/* Above conditions must have passed. */
- zlog_warn("ospf_opaque_lsa_install: Sonmething wrong?");
+ flog_warn(OSPF_WARN_LSA,
+ "ospf_opaque_lsa_install: Something wrong?");
goto out;
}
break;
default:
- zlog_warn("ospf_opaque_lsa_install: Unexpected LSA-type(%u)",
+ flog_warn(OSPF_WARN_LSA_UNEXPECTED,
+ "ospf_opaque_lsa_install: Unexpected LSA-type(%u)",
lsa->data->type);
goto out;
}
@@ -1668,13 +1672,14 @@ void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent,
case OSPF_OPAQUE_LINK_LSA:
if ((oi = (struct ospf_interface *)lsa_type_dependent)
== NULL) {
- zlog_warn(
- "ospf_opaque_lsa_reoriginate_schedule:"
- " Type-9 Opaque-LSA: Invalid parameter?");
+ flog_warn(
+ OSPF_WARN_LSA,
+ "ospf_opaque_lsa_reoriginate_schedule: Type-9 Opaque-LSA: Invalid parameter?");
goto out;
}
if ((top = oi_to_top(oi)) == NULL) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA,
"ospf_opaque_lsa_reoriginate_schedule: OI(%s) -> TOP?",
IF_NAME(oi));
goto out;
@@ -1682,9 +1687,9 @@ void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent,
if (!list_isempty(ospf_opaque_type9_funclist)
&& list_isempty(oi->opaque_lsa_self)
&& oi->t_opaque_lsa_self != NULL) {
- zlog_warn(
- "Type-9 Opaque-LSA (opaque_type=%u):"
- " Common origination for OI(%s) has already started",
+ flog_warn(
+ OSPF_WARN_LSA,
+ "Type-9 Opaque-LSA (opaque_type=%u): Common origination for OI(%s) has already started",
opaque_type, IF_NAME(oi));
goto out;
}
@@ -1692,24 +1697,24 @@ void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent,
break;
case OSPF_OPAQUE_AREA_LSA:
if ((area = (struct ospf_area *)lsa_type_dependent) == NULL) {
- zlog_warn(
- "ospf_opaque_lsa_reoriginate_schedule:"
- " Type-10 Opaque-LSA: Invalid parameter?");
+ flog_warn(
+ OSPF_WARN_LSA,
+ "ospf_opaque_lsa_reoriginate_schedule: Type-10 Opaque-LSA: Invalid parameter?");
goto out;
}
if ((top = area->ospf) == NULL) {
- zlog_warn(
- "ospf_opaque_lsa_reoriginate_schedule:"
- " AREA(%s) -> TOP?",
+ flog_warn(
+ OSPF_WARN_LSA,
+ "ospf_opaque_lsa_reoriginate_schedule: AREA(%s) -> TOP?",
inet_ntoa(area->area_id));
goto out;
}
if (!list_isempty(ospf_opaque_type10_funclist)
&& list_isempty(area->opaque_lsa_self)
&& area->t_opaque_lsa_self != NULL) {
- zlog_warn(
- "Type-10 Opaque-LSA (opaque_type=%u):"
- " Common origination for AREA(%s) has already started",
+ flog_warn(
+ OSPF_WARN_LSA,
+ "Type-10 Opaque-LSA (opaque_type=%u): Common origination for AREA(%s) has already started",
opaque_type, inet_ntoa(area->area_id));
goto out;
}
@@ -1717,17 +1722,17 @@ void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent,
break;
case OSPF_OPAQUE_AS_LSA:
if ((top = (struct ospf *)lsa_type_dependent) == NULL) {
- zlog_warn(
- "ospf_opaque_lsa_reoriginate_schedule:"
- " Type-11 Opaque-LSA: Invalid parameter?");
+ flog_warn(
+ OSPF_WARN_LSA,
+ "ospf_opaque_lsa_reoriginate_schedule: Type-11 Opaque-LSA: Invalid parameter?");
goto out;
}
if (!list_isempty(ospf_opaque_type11_funclist)
&& list_isempty(top->opaque_lsa_self)
&& top->t_opaque_lsa_self != NULL) {
- zlog_warn(
- "Type-11 Opaque-LSA (opaque_type=%u):"
- " Common origination has already started",
+ flog_warn(
+ OSPF_WARN_LSA,
+ "Type-11 Opaque-LSA (opaque_type=%u): Common origination has already started",
opaque_type);
goto out;
}
@@ -1739,9 +1744,9 @@ void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent,
func = ospf_opaque_type11_lsa_reoriginate_timer;
break;
default:
- zlog_warn(
- "ospf_opaque_lsa_reoriginate_schedule:"
- " Unexpected LSA-type(%u)",
+ flog_warn(
+ OSPF_WARN_LSA_UNEXPECTED,
+ "ospf_opaque_lsa_reoriginate_schedule: Unexpected LSA-type(%u)",
lsa_type);
goto out;
}
@@ -1761,19 +1766,17 @@ void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent,
if ((oipt = lookup_opaque_info_by_type(lsa)) == NULL) {
struct ospf_opaque_functab *functab;
if ((functab = ospf_opaque_functab_lookup(lsa)) == NULL) {
- zlog_warn(
- "ospf_opaque_lsa_reoriginate_schedule:"
- " No associated function?: lsa_type(%u),"
- " opaque_type(%u)",
+ flog_warn(
+ OSPF_WARN_LSA,
+ "ospf_opaque_lsa_reoriginate_schedule: No associated function?: lsa_type(%u), opaque_type(%u)",
lsa_type, opaque_type);
goto out;
}
if ((oipt = register_opaque_info_per_type(functab, lsa))
== NULL) {
- zlog_warn(
- "ospf_opaque_lsa_reoriginate_schedule:"
- " Cannot get a control info?: lsa_type(%u),"
- " opaque_type(%u)",
+ flog_warn(
+ OSPF_WARN_LSA,
+ "ospf_opaque_lsa_reoriginate_schedule: Cannot get a control info?: lsa_type(%u), opaque_type(%u)",
lsa_type, opaque_type);
goto out;
}
@@ -1844,14 +1847,16 @@ static int ospf_opaque_type9_lsa_reoriginate_timer(struct thread *t)
if ((functab = oipt->functab) == NULL
|| functab->lsa_originator == NULL) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA,
"ospf_opaque_type9_lsa_reoriginate_timer: No associated function?");
goto out;
}
oi = (struct ospf_interface *)oipt->owner;
if ((top = oi_to_top(oi)) == NULL) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA,
"ospf_opaque_type9_lsa_reoriginate_timer: Something wrong?");
goto out;
}
@@ -1894,14 +1899,16 @@ static int ospf_opaque_type10_lsa_reoriginate_timer(struct thread *t)
if ((functab = oipt->functab) == NULL
|| functab->lsa_originator == NULL) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA,
"ospf_opaque_type10_lsa_reoriginate_timer: No associated function?");
goto out;
}
area = (struct ospf_area *)oipt->owner;
if (area == NULL || (top = area->ospf) == NULL) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA,
"ospf_opaque_type10_lsa_reoriginate_timer: Something wrong?");
goto out;
}
@@ -1948,14 +1955,15 @@ static int ospf_opaque_type11_lsa_reoriginate_timer(struct thread *t)
if ((functab = oipt->functab) == NULL
|| functab->lsa_originator == NULL) {
- zlog_warn(
- "ospf_opaque_type11_lsa_reoriginate_timer:"
- " No associated function?");
+ flog_warn(
+ OSPF_WARN_LSA,
+ "ospf_opaque_type11_lsa_reoriginate_timer: No associated function?");
goto out;
}
if ((top = (struct ospf *)oipt->owner) == NULL) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA,
"ospf_opaque_type11_lsa_reoriginate_timer: Something wrong?");
goto out;
}
@@ -1991,14 +1999,16 @@ void ospf_opaque_lsa_refresh_schedule(struct ospf_lsa *lsa0)
if ((oipt = lookup_opaque_info_by_type(lsa0)) == NULL
|| (oipi = lookup_opaque_info_by_id(oipt, lsa0)) == NULL) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA,
"ospf_opaque_lsa_refresh_schedule: Invalid parameter?");
goto out;
}
/* Given "lsa0" and current "oipi->lsa" may different, but harmless. */
if ((lsa = oipi->lsa) == NULL) {
- zlog_warn("ospf_opaque_lsa_refresh_schedule: Something wrong?");
+ flog_warn(OSPF_WARN_LSA,
+ "ospf_opaque_lsa_refresh_schedule: Something wrong?");
goto out;
}
@@ -2025,7 +2035,8 @@ void ospf_opaque_lsa_refresh_schedule(struct ospf_lsa *lsa0)
ospf_ls_retransmit_delete_nbr_as(top, lsa);
break;
default:
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA_UNEXPECTED,
"ospf_opaque_lsa_refresh_schedule: Unexpected LSA-type(%u)",
lsa->data->type);
goto out;
@@ -2077,13 +2088,15 @@ void ospf_opaque_lsa_flush_schedule(struct ospf_lsa *lsa0)
if ((oipt = lookup_opaque_info_by_type(lsa0)) == NULL
|| (oipi = lookup_opaque_info_by_id(oipt, lsa0)) == NULL) {
- zlog_warn("ospf_opaque_lsa_flush_schedule: Invalid parameter?");
+ flog_warn(OSPF_WARN_LSA,
+ "ospf_opaque_lsa_flush_schedule: Invalid parameter?");
goto out;
}
/* Given "lsa0" and current "oipi->lsa" may different, but harmless. */
if ((lsa = oipi->lsa) == NULL) {
- zlog_warn("ospf_opaque_lsa_flush_schedule: Something wrong?");
+ flog_warn(OSPF_WARN_LSA,
+ "ospf_opaque_lsa_flush_schedule: Something wrong?");
goto out;
}
@@ -2099,7 +2112,8 @@ void ospf_opaque_lsa_flush_schedule(struct ospf_lsa *lsa0)
ospf_ls_retransmit_delete_nbr_as(top, lsa);
break;
default:
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA_UNEXPECTED,
"ospf_opaque_lsa_flush_schedule: Unexpected LSA-type(%u)",
lsa->data->type);
goto out;
@@ -2156,7 +2170,8 @@ void ospf_opaque_self_originated_lsa_received(struct ospf_neighbor *nbr,
ospf_flood_through_as(top, NULL /*inbr*/, lsa);
break;
default:
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA_UNEXPECTED,
"ospf_opaque_self_originated_lsa_received: Unexpected LSA-type(%u)",
lsa->data->type);
return;
@@ -2175,7 +2190,8 @@ struct ospf *oi_to_top(struct ospf_interface *oi)
if (oi == NULL || (area = oi->area) == NULL
|| (top = area->ospf) == NULL)
- zlog_warn("Broken relationship for \"OI -> AREA -> OSPF\"?");
+ flog_warn(OSPF_WARN_LSA,
+ "Broken relationship for \"OI -> AREA -> OSPF\"?");
return top;
}
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index 56b83d22d..59340fbf1 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -35,7 +35,7 @@
#include "checksum.h"
#include "md5.h"
#include "vrf.h"
-#include "ospf_errors.h"
+#include "lib_errors.h"
#include "ospfd/ospfd.h"
#include "ospfd/ospf_network.h"
@@ -50,6 +50,7 @@
#include "ospfd/ospf_spf.h"
#include "ospfd/ospf_flood.h"
#include "ospfd/ospf_dump.h"
+#include "ospfd/ospf_errors.h"
/*
* OSPF Fragmentation / fragmented writes
@@ -291,7 +292,7 @@ struct ospf_packet *ospf_packet_dup(struct ospf_packet *op)
if (stream_get_endp(op->s) != op->length)
/* XXX size_t */
- zlog_warn(
+ zlog_debug(
"ospf_packet_dup stream %lu ospf_packet %u size mismatch",
(unsigned long)STREAM_SIZE(op->s), op->length);
@@ -341,7 +342,8 @@ static int ospf_check_md5_digest(struct ospf_interface *oi,
ck = ospf_crypt_key_lookup(OSPF_IF_PARAM(oi, auth_crypt),
ospfh->u.crypt.key_id);
if (ck == NULL) {
- zlog_warn("interface %s: ospf_check_md5 no key %d", IF_NAME(oi),
+ flog_warn(OSPF_WARN_MD5,
+ "interface %s: ospf_check_md5 no key %d", IF_NAME(oi),
ospfh->u.crypt.key_id);
return 0;
}
@@ -351,7 +353,8 @@ static int ospf_check_md5_digest(struct ospf_interface *oi,
if (nbr
&& ntohl(nbr->crypt_seqnum) > ntohl(ospfh->u.crypt.crypt_seqnum)) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_MD5,
"interface %s: ospf_check_md5 bad sequence %d (expect %d)",
IF_NAME(oi), ntohl(ospfh->u.crypt.crypt_seqnum),
ntohl(nbr->crypt_seqnum));
@@ -367,7 +370,8 @@ static int ospf_check_md5_digest(struct ospf_interface *oi,
/* compare the two */
if (memcmp((caddr_t)ospfh + length, digest, OSPF_AUTH_MD5_SIZE)) {
- zlog_warn("interface %s: ospf_check_md5 checksum mismatch",
+ flog_warn(OSPF_WARN_MD5,
+ "interface %s: ospf_check_md5 checksum mismatch",
IF_NAME(oi));
return 0;
}
@@ -433,7 +437,8 @@ static int ospf_make_md5_digest(struct ospf_interface *oi,
if (stream_get_endp(op->s) != op->length)
/* XXX size_t */
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_MD5,
"ospf_make_md5_digest: length mismatch stream %lu ospf_packet %u",
(unsigned long)stream_get_endp(op->s), op->length);
@@ -596,7 +601,8 @@ static void ospf_write_frags(int fd, struct ospf_packet *op, struct ip *iph,
sockopt_iphdrincl_swab_systoh(iph);
if (ret < 0)
- zlog_warn(
+ flog_err(
+ LIB_ERR_SOCKET,
"*** ospf_write_frags: sendmsg failed to %s,"
" id %d, off %d, len %d, mtu %u failed with %s",
inet_ntoa(iph->ip_dst), iph->ip_id, iph->ip_off,
@@ -799,7 +805,8 @@ static int ospf_write(struct thread *thread)
iph.ip_len, oi->ifp->name, oi->ifp->mtu);
if (ret < 0)
- zlog_warn(
+ flog_err(
+ LIB_ERR_SOCKET,
"*** sendmsg in ospf_write failed to %s, "
"id %d, off %d, len %d, interface %s, mtu %u: %s",
inet_ntoa(iph.ip_dst), iph.ip_id, iph.ip_off,
@@ -915,7 +922,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh,
if (oi->type != OSPF_IFTYPE_POINTOPOINT
&& oi->type != OSPF_IFTYPE_VIRTUALLINK)
if (oi->address->prefixlen != p.prefixlen) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"Packet %s [Hello:RECV]: NetworkMask mismatch on %s (configured prefix length is %d, but hello packet indicates %d).",
inet_ntoa(ospfh->router_id), IF_NAME(oi),
(int)oi->address->prefixlen, (int)p.prefixlen);
@@ -924,11 +932,12 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh,
/* Compare Router Dead Interval. */
if (OSPF_IF_PARAM(oi, v_wait) != ntohl(hello->dead_interval)) {
- zlog_warn(
- "Packet %s [Hello:RECV]: RouterDeadInterval mismatch "
- "(expected %u, but received %u).",
- inet_ntoa(ospfh->router_id), OSPF_IF_PARAM(oi, v_wait),
- ntohl(hello->dead_interval));
+ flog_warn(OSPF_WARN_PACKET,
+ "Packet %s [Hello:RECV]: RouterDeadInterval mismatch "
+ "(expected %u, but received %u).",
+ inet_ntoa(ospfh->router_id),
+ OSPF_IF_PARAM(oi, v_wait),
+ ntohl(hello->dead_interval));
return;
}
@@ -936,7 +945,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh,
if (OSPF_IF_PARAM(oi, fast_hello) == 0) {
if (OSPF_IF_PARAM(oi, v_hello)
!= ntohs(hello->hello_interval)) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"Packet %s [Hello:RECV]: HelloInterval mismatch "
"(expected %u, but received %u).",
inet_ntoa(ospfh->router_id),
@@ -961,7 +971,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh,
* Drop this Hello packet not to establish neighbor
* relationship.
*/
- zlog_warn("Packet %s [Hello:RECV]: T-bit on, drop it.",
+ flog_warn(OSPF_WARN_PACKET,
+ "Packet %s [Hello:RECV]: T-bit on, drop it.",
inet_ntoa(ospfh->router_id));
return;
}
@@ -973,7 +984,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh,
* This router does know the correct usage of O-bit
* the bit should be set in DD packet only.
*/
- zlog_warn("Packet %s [Hello:RECV]: O-bit abuse?",
+ flog_warn(OSPF_WARN_PACKET,
+ "Packet %s [Hello:RECV]: O-bit abuse?",
inet_ntoa(ospfh->router_id));
#ifdef STRICT_OBIT_USAGE_CHECK
return; /* Reject this packet. */
@@ -989,7 +1001,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh,
&& CHECK_FLAG(hello->options, OSPF_OPTION_NP)
&& !CHECK_FLAG(OPTIONS(oi), OSPF_OPTION_E)
&& !CHECK_FLAG(hello->options, OSPF_OPTION_E))) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"NSSA-Packet-%s[Hello:RECV]: my options: %x, his options %x",
inet_ntoa(ospfh->router_id), OPTIONS(oi),
hello->options);
@@ -1006,7 +1019,8 @@ static void ospf_hello(struct ip *iph, struct ospf_header *ospfh,
Packet's Options field should be ignored. */
if (CHECK_FLAG(OPTIONS(oi), OSPF_OPTION_E)
!= CHECK_FLAG(hello->options, OSPF_OPTION_E)) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"Packet %s [Hello:RECV]: my options: %x, his options %x",
inet_ntoa(ospfh->router_id), OPTIONS(oi),
hello->options);
@@ -1123,7 +1137,8 @@ static void ospf_db_desc_proc(struct stream *s, struct ospf_interface *oi,
/* Unknown LS type. */
if (lsah->type < OSPF_MIN_LSA || lsah->type >= OSPF_MAX_LSA) {
- zlog_warn("Packet [DD:RECV]: Unknown LS type %d.",
+ flog_warn(OSPF_WARN_PACKET,
+ "Packet [DD:RECV]: Unknown LS type %d.",
lsah->type);
OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_SeqNumberMismatch);
return;
@@ -1131,7 +1146,8 @@ static void ospf_db_desc_proc(struct stream *s, struct ospf_interface *oi,
if (IS_OPAQUE_LSA(lsah->type)
&& !CHECK_FLAG(nbr->options, OSPF_OPTION_O)) {
- zlog_warn("LSA[Type%d:%s]: Opaque capability mismatch?",
+ flog_warn(OSPF_WARN_PACKET,
+ "LSA[Type%d:%s]: Opaque capability mismatch?",
lsah->type, inet_ntoa(lsah->id));
OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_SeqNumberMismatch);
return;
@@ -1144,7 +1160,8 @@ static void ospf_db_desc_proc(struct stream *s, struct ospf_interface *oi,
but
allow if from NSSA. */
if (oi->area->external_routing == OSPF_AREA_STUB) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"Packet [DD:RECV]: LSA[Type%d:%s] from %s area.",
lsah->type, inet_ntoa(lsah->id),
(oi->area->external_routing
@@ -1271,7 +1288,7 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh,
nbr = ospf_nbr_lookup(oi, iph, ospfh);
if (nbr == NULL) {
- zlog_warn("Packet[DD]: Unknown Neighbor %s",
+ flog_warn(OSPF_WARN_PACKET, "Packet[DD]: Unknown Neighbor %s",
inet_ntoa(ospfh->router_id));
return;
}
@@ -1279,7 +1296,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh,
/* Check MTU. */
if ((OSPF_IF_PARAM(oi, mtu_ignore) == 0)
&& (ntohs(dd->mtu) > oi->ifp->mtu)) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"Packet[DD]: Neighbor %s MTU %u is larger than [%s]'s MTU %u",
inet_ntoa(nbr->router_id), ntohs(dd->mtu), IF_NAME(oi),
oi->ifp->mtu);
@@ -1318,7 +1336,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh,
* In Hello protocol, optional capability must have checked
* to prevent this T-bit enabled router be my neighbor.
*/
- zlog_warn("Packet[DD]: Neighbor %s: T-bit on?",
+ flog_warn(OSPF_WARN_PACKET,
+ "Packet[DD]: Neighbor %s: T-bit on?",
inet_ntoa(nbr->router_id));
return;
}
@@ -1342,7 +1361,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh,
case NSM_Down:
case NSM_Attempt:
case NSM_TwoWay:
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"Packet[DD]: Neighbor %s state is %s, packet discarded.",
inet_ntoa(nbr->router_id),
lookup_msg(ospf_nsm_state_msg, nbr->state, NULL));
@@ -1396,7 +1416,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh,
/* Reset I, leaving MS */
UNSET_FLAG(nbr->dd_flags, OSPF_DD_FLAG_I);
} else {
- zlog_warn("Packet[DD]: Neighbor %s Negotiation fails.",
+ flog_warn(OSPF_WARN_PACKET,
+ "Packet[DD]: Neighbor %s Negotiation fails.",
inet_ntoa(nbr->router_id));
break;
}
@@ -1416,10 +1437,9 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh,
if (!CHECK_FLAG(nbr->options, OSPF_OPTION_O)
&& IPV4_ADDR_SAME(&DR(oi),
&nbr->address.u.prefix4)) {
- zlog_warn(
- "DR-neighbor[%s] is NOT opaque-capable; "
- "Opaque-LSAs cannot be reliably advertised "
- "in this network.",
+ flog_warn(
+ OSPF_WARN_PACKET,
+ "DR-neighbor[%s] is NOT opaque-capable; Opaque-LSAs cannot be reliably advertised in this network.",
inet_ntoa(nbr->router_id));
/* This situation is undesirable, but not a real
* error. */
@@ -1454,7 +1474,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh,
/* Check Master/Slave bit mismatch */
if (IS_SET_DD_MS(dd->flags)
!= IS_SET_DD_MS(nbr->last_recv.flags)) {
- zlog_warn("Packet[DD]: Neighbor %s MS-bit mismatch.",
+ flog_warn(OSPF_WARN_PACKET,
+ "Packet[DD]: Neighbor %s MS-bit mismatch.",
inet_ntoa(nbr->router_id));
OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_SeqNumberMismatch);
if (IS_DEBUG_OSPF_EVENT)
@@ -1478,7 +1499,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh,
/* Save the new options for debugging */
nbr->options = dd->options;
#endif /* ORIGINAL_CODING */
- zlog_warn("Packet[DD]: Neighbor %s options mismatch.",
+ flog_warn(OSPF_WARN_PACKET,
+ "Packet[DD]: Neighbor %s options mismatch.",
inet_ntoa(nbr->router_id));
OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_SeqNumberMismatch);
break;
@@ -1489,7 +1511,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh,
&& ntohl(dd->dd_seqnum) != nbr->dd_seqnum)
|| (!IS_SET_DD_MS(nbr->dd_flags)
&& ntohl(dd->dd_seqnum) != nbr->dd_seqnum + 1)) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"Packet[DD]: Neighbor %s sequence number mismatch.",
inet_ntoa(nbr->router_id));
OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_SeqNumberMismatch);
@@ -1539,7 +1562,8 @@ static void ospf_db_desc(struct ip *iph, struct ospf_header *ospfh,
OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_SeqNumberMismatch);
break;
default:
- zlog_warn("Packet[DD]: Neighbor %s NSM illegal status %u.",
+ flog_warn(OSPF_WARN_PACKET,
+ "Packet[DD]: Neighbor %s NSM illegal status %u.",
inet_ntoa(nbr->router_id), nbr->state);
break;
}
@@ -1565,7 +1589,8 @@ static void ospf_ls_req(struct ip *iph, struct ospf_header *ospfh,
nbr = ospf_nbr_lookup(oi, iph, ospfh);
if (nbr == NULL) {
- zlog_warn("Link State Request: Unknown Neighbor %s.",
+ flog_warn(OSPF_WARN_PACKET,
+ "Link State Request: Unknown Neighbor %s.",
inet_ntoa(ospfh->router_id));
return;
}
@@ -1576,9 +1601,9 @@ static void ospf_ls_req(struct ip *iph, struct ospf_header *ospfh,
/* Neighbor State should be Exchange or later. */
if (nbr->state != NSM_Exchange && nbr->state != NSM_Loading
&& nbr->state != NSM_Full) {
- zlog_warn(
- "Link State Request received from %s: "
- "Neighbor state is %s, packet discarded.",
+ flog_warn(
+ OSPF_WARN_PACKET,
+ "Link State Request received from %s: Neighbor state is %s, packet discarded.",
inet_ntoa(ospfh->router_id),
lookup_msg(ospf_nsm_state_msg, nbr->state, NULL));
return;
@@ -1669,7 +1694,8 @@ static struct list *ospf_ls_upd_list_lsa(struct ospf_neighbor *nbr,
length = ntohs(lsah->length);
if (length > size) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"Link State Update: LSA length exceeds packet size.");
break;
}
@@ -1683,7 +1709,8 @@ static struct list *ospf_ls_upd_list_lsa(struct ospf_neighbor *nbr,
* have a better
* chance to compress repeated messages in syslog on the
* other */
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"Link State Update: LSA checksum error %x/%x, ID=%s from: nbr %s, router ID %s, adv router %s",
sum, lsah->checksum, inet_ntoa(lsah->id),
inet_ntoa(nbr->src), inet_ntoa(nbr->router_id),
@@ -1693,7 +1720,8 @@ static struct list *ospf_ls_upd_list_lsa(struct ospf_neighbor *nbr,
/* Examine the LSA's LS type. */
if (lsah->type < OSPF_MIN_LSA || lsah->type >= OSPF_MAX_LSA) {
- zlog_warn("Link State Update: Unknown LS type %d",
+ flog_warn(OSPF_WARN_PACKET,
+ "Link State Update: Unknown LS type %d",
lsah->type);
continue;
}
@@ -1717,7 +1745,8 @@ static struct list *ospf_ls_upd_list_lsa(struct ospf_neighbor *nbr,
* the bit will be set in Type-9,10,11 LSAs
* only.
*/
- zlog_warn("LSA[Type%d:%s]: O-bit abuse?",
+ flog_warn(OSPF_WARN_PACKET,
+ "LSA[Type%d:%s]: O-bit abuse?",
lsah->type, inet_ntoa(lsah->id));
continue;
}
@@ -1736,7 +1765,8 @@ static struct list *ospf_ls_upd_list_lsa(struct ospf_neighbor *nbr,
continue;
}
} else if (IS_OPAQUE_LSA(lsah->type)) {
- zlog_warn("LSA[Type%d:%s]: Opaque capability mismatch?",
+ flog_warn(OSPF_WARN_PACKET,
+ "LSA[Type%d:%s]: Opaque capability mismatch?",
lsah->type, inet_ntoa(lsah->id));
continue;
}
@@ -1806,7 +1836,8 @@ static void ospf_ls_upd(struct ospf *ospf, struct ip *iph,
/* Check neighbor. */
nbr = ospf_nbr_lookup(oi, iph, ospfh);
if (nbr == NULL) {
- zlog_warn("Link State Update: Unknown Neighbor %s on int: %s",
+ flog_warn(OSPF_WARN_PACKET,
+ "Link State Update: Unknown Neighbor %s on int: %s",
inet_ntoa(ospfh->router_id), IF_NAME(oi));
return;
}
@@ -1971,7 +2002,7 @@ static void ospf_ls_upd(struct ospf *ospf, struct ip *iph,
* Just send an LSAck message to cease retransmission.
*/
if (IS_LSA_MAXAGE(lsa)) {
- zlog_warn("LSA[%s]: Boomerang effect?",
+ zlog_info("LSA[%s]: Boomerang effect?",
dump_lsa_key(lsa));
ospf_ls_ack_send(nbr, lsa);
ospf_lsa_discard(lsa);
@@ -2087,7 +2118,8 @@ static void ospf_ls_upd(struct ospf *ospf, struct ip *iph,
if (ospf_ls_request_lookup(nbr, lsa)) {
OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_BadLSReq);
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"LSA[%s] instance exists on Link state request list",
dump_lsa_key(lsa));
@@ -2200,7 +2232,8 @@ static void ospf_ls_ack(struct ip *iph, struct ospf_header *ospfh,
nbr = ospf_nbr_lookup(oi, iph, ospfh);
if (nbr == NULL) {
- zlog_warn("Link State Acknowledgment: Unknown Neighbor %s.",
+ flog_warn(OSPF_WARN_PACKET,
+ "Link State Acknowledgment: Unknown Neighbor %s.",
inet_ntoa(ospfh->router_id));
return;
}
@@ -2270,12 +2303,14 @@ static struct stream *ospf_recv_packet(struct ospf *ospf, int fd,
ret = stream_recvmsg(ibuf, fd, &msgh, 0, OSPF_MAX_PACKET_SIZE + 1);
if (ret < 0) {
- zlog_warn("stream_recvmsg failed: %s", safe_strerror(errno));
+ flog_warn(OSPF_WARN_PACKET, "stream_recvmsg failed: %s",
+ safe_strerror(errno));
return NULL;
}
if ((unsigned int)ret < sizeof(iph)) /* ret must be > 0 now */
{
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"ospf_recv_packet: discarding runt packet of length %d "
"(ip header size is %u)",
ret, (unsigned int)sizeof(iph));
@@ -2321,7 +2356,8 @@ static struct stream *ospf_recv_packet(struct ospf *ospf, int fd,
*ifp = if_lookup_by_index(ifindex, ospf->vrf_id);
if (ret != ip_len) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"ospf_recv_packet read length mismatch: ip_len is %d, "
"but recvmsg returned %d",
ip_len, ret);
@@ -2427,7 +2463,8 @@ static int ospf_check_auth(struct ospf_interface *oi, struct ospf_header *ospfh)
case OSPF_AUTH_NULL: /* RFC2328 D.5.1 */
if (OSPF_AUTH_NULL != (iface_auth_type = ospf_auth_type(oi))) {
if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV))
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"interface %s: auth-type mismatch, local %s, rcvd Null",
IF_NAME(oi),
lookup_msg(ospf_auth_type_str,
@@ -2436,7 +2473,8 @@ static int ospf_check_auth(struct ospf_interface *oi, struct ospf_header *ospfh)
}
if (!ospf_check_sum(ospfh)) {
if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV))
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"interface %s: Null auth OK, but checksum error, Router-ID %s",
IF_NAME(oi),
inet_ntoa(ospfh->router_id));
@@ -2447,7 +2485,8 @@ static int ospf_check_auth(struct ospf_interface *oi, struct ospf_header *ospfh)
if (OSPF_AUTH_SIMPLE
!= (iface_auth_type = ospf_auth_type(oi))) {
if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV))
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"interface %s: auth-type mismatch, local %s, rcvd Simple",
IF_NAME(oi),
lookup_msg(ospf_auth_type_str,
@@ -2457,13 +2496,15 @@ static int ospf_check_auth(struct ospf_interface *oi, struct ospf_header *ospfh)
if (memcmp(OSPF_IF_PARAM(oi, auth_simple), ospfh->u.auth_data,
OSPF_AUTH_SIMPLE_SIZE)) {
if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV))
- zlog_warn("interface %s: Simple auth failed",
+ flog_warn(OSPF_WARN_PACKET,
+ "interface %s: Simple auth failed",
IF_NAME(oi));
return 0;
}
if (!ospf_check_sum(ospfh)) {
if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV))
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"interface %s: Simple auth OK, checksum error, Router-ID %s",
IF_NAME(oi),
inet_ntoa(ospfh->router_id));
@@ -2474,7 +2515,8 @@ static int ospf_check_auth(struct ospf_interface *oi, struct ospf_header *ospfh)
if (OSPF_AUTH_CRYPTOGRAPHIC
!= (iface_auth_type = ospf_auth_type(oi))) {
if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV))
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"interface %s: auth-type mismatch, local %s, rcvd Cryptographic",
IF_NAME(oi),
lookup_msg(ospf_auth_type_str,
@@ -2483,7 +2525,8 @@ static int ospf_check_auth(struct ospf_interface *oi, struct ospf_header *ospfh)
}
if (ospfh->checksum) {
if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV))
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"interface %s: OSPF header checksum is not 0",
IF_NAME(oi));
return 0;
@@ -2498,14 +2541,16 @@ static int ospf_check_auth(struct ospf_interface *oi, struct ospf_header *ospfh)
bug? */
!ospf_check_md5_digest(oi, ospfh)) {
if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV))
- zlog_warn("interface %s: MD5 auth failed",
+ flog_warn(OSPF_WARN_MD5,
+ "interface %s: MD5 auth failed",
IF_NAME(oi));
return 0;
}
return 1;
default:
if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV))
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"interface %s: invalid packet auth-type (%02x)",
IF_NAME(oi), pkt_auth_type);
return 0;
@@ -2854,14 +2899,16 @@ static int ospf_verify_header(struct stream *ibuf, struct ospf_interface *oi,
{
/* Check Area ID. */
if (!ospf_check_area_id(oi, ospfh)) {
- zlog_warn("interface %s: ospf_read invalid Area ID %s.",
+ flog_warn(OSPF_WARN_PACKET,
+ "interface %s: ospf_read invalid Area ID %s.",
IF_NAME(oi), inet_ntoa(ospfh->area_id));
return -1;
}
/* Check network mask, Silently discarded. */
if (!ospf_check_network_mask(oi, iph->ip_src)) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"interface %s: ospf_read network address is not same [%s]",
IF_NAME(oi), inet_ntoa(iph->ip_src));
return -1;
@@ -3006,12 +3053,14 @@ int ospf_read(struct thread *thread)
*/
else if (oi->ifp != ifp) {
if (IS_DEBUG_OSPF_EVENT)
- zlog_warn("Packet from [%s] received on wrong link %s",
+ flog_warn(OSPF_WARN_PACKET,
+ "Packet from [%s] received on wrong link %s",
inet_ntoa(iph->ip_src), ifp->name);
return 0;
} else if (oi->state == ISM_Down) {
char buf[2][INET_ADDRSTRLEN];
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"Ignoring packet from %s to %s received on interface that is "
"down [%s]; interface flags are %s",
inet_ntop(AF_INET, &iph->ip_src, buf[0],
@@ -3036,7 +3085,8 @@ int ospf_read(struct thread *thread)
*/
if (iph->ip_dst.s_addr == htonl(OSPF_ALLDROUTERS)
&& (oi->state != ISM_DR && oi->state != ISM_Backup)) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"Dropping packet for AllDRouters from [%s] via [%s] (ISM: %s)",
inet_ntoa(iph->ip_src), IF_NAME(oi),
lookup_msg(ospf_ism_state_msg, oi->state, NULL));
@@ -3099,7 +3149,8 @@ int ospf_read(struct thread *thread)
ospf_ls_ack(iph, ospfh, ibuf, oi, length);
break;
default:
- zlog_warn("interface %s: OSPF packet header type %d is illegal",
+ flog_warn(OSPF_WARN_PACKET,
+ "interface %s: OSPF packet header type %d is illegal",
IF_NAME(oi), ospfh->type);
break;
}
@@ -3830,7 +3881,8 @@ static struct ospf_packet *ospf_ls_upd_packet_new(struct list *update,
if ((OSPF_LS_UPD_MIN_SIZE + ntohs(lsa->data->length))
> ospf_packet_max(oi)) {
if (!warned) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LARGE_LSA,
"ospf_ls_upd_packet_new: oversized LSA encountered!"
"will need to fragment. Not optimal. Try divide up"
" your network with areas. Use 'debug ospf packet send'"
@@ -3858,12 +3910,12 @@ static struct ospf_packet *ospf_ls_upd_packet_new(struct list *update,
size = oi->ifp->mtu;
if (size > OSPF_MAX_PACKET_SIZE) {
- zlog_warn(
- "ospf_ls_upd_packet_new: oversized LSA id:%s too big,"
- " %d bytes, packet size %ld, dropping it completely."
- " OSPF routing is broken!",
- inet_ntoa(lsa->data->id), ntohs(lsa->data->length),
- (long int)size);
+ flog_warn(OSPF_WARN_LARGE_LSA,
+ "ospf_ls_upd_packet_new: oversized LSA id:%s too big,"
+ " %d bytes, packet size %ld, dropping it completely."
+ " OSPF routing is broken!",
+ inet_ntoa(lsa->data->id), ntohs(lsa->data->length),
+ (long int)size);
list_delete_node(update, ln);
return NULL;
}
@@ -4019,10 +4071,12 @@ void ospf_ls_upd_send(struct ospf_neighbor *nbr, struct list *update, int flag,
if (oi->type == OSPF_IFTYPE_NBMA) {
if (flag == OSPF_SEND_PACKET_INDIRECT)
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_PACKET,
"* LS-Update is directly sent on NBMA network.");
if (IPV4_ADDR_SAME(&oi->address->u.prefix4, &p.prefix))
- zlog_warn("* LS-Update is sent to myself.");
+ flog_warn(OSPF_WARN_PACKET,
+ "* LS-Update is sent to myself.");
}
rn = route_node_get(oi->ls_upd_queue, (struct prefix *)&p);
@@ -4037,7 +4091,7 @@ void ospf_ls_upd_send(struct ospf_neighbor *nbr, struct list *update, int flag,
ospf_lsa_lock(lsa)); /* oi->ls_upd_queue */
if (send_lsupd_now) {
struct list *send_update_list;
- struct route_node *rn, *rnext;
+ struct route_node *rnext;
for (rn = route_top(oi->ls_upd_queue); rn; rn = rnext) {
rnext = route_next(rn);
diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c
index c9d0a53c8..974822ba8 100644
--- a/ospfd/ospf_ri.c
+++ b/ospfd/ospf_ri.c
@@ -57,6 +57,7 @@
#include "ospfd/ospf_zebra.h"
#include "ospfd/ospf_sr.h"
#include "ospfd/ospf_ri.h"
+#include "ospfd/ospf_errors.h"
/* Store Router Information PCE TLV and SubTLV in network byte order. */
struct ospf_pce_info {
@@ -185,7 +186,8 @@ static int ospf_router_info_register(uint8_t scope)
NULL); /* del_lsa_hook */
if (rc != 0) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_OPAQUE_REGISTRATION,
"ospf_router_info_init: Failed to register functions");
return rc;
}
@@ -200,8 +202,8 @@ static int ospf_router_info_unregister()
if ((OspfRI.scope != OSPF_OPAQUE_AS_LSA)
&& (OspfRI.scope != OSPF_OPAQUE_AREA_LSA)) {
- zlog_warn(
- "Unable to unregister Router Info functions: Wrong scope!");
+ assert("Unable to unregister Router Info functions: Wrong scope!"
+ == NULL);
return -1;
}
@@ -742,10 +744,8 @@ static struct ospf_lsa *ospf_router_info_lsa_new()
uint16_t length;
/* Create a stream for LSA. */
- if ((s = stream_new(OSPF_MAX_LSA_SIZE)) == NULL) {
- zlog_warn("ospf_router_info_lsa_new: stream_new() ?");
- return NULL;
- }
+ s = stream_new(OSPF_MAX_LSA_SIZE);
+
lsah = (struct lsa_header *)STREAM_DATA(s);
options = OSPF_OPTION_E; /* Enable AS external as we flood RI with
@@ -814,11 +814,7 @@ static int ospf_router_info_lsa_originate1(void *arg)
}
/* Create new Opaque-LSA/ROUTER INFORMATION instance. */
- if ((new = ospf_router_info_lsa_new()) == NULL) {
- zlog_warn(
- "ospf_router_info_lsa_originate1: ospf_router_info_lsa_new() ?");
- return rc;
- }
+ new = ospf_router_info_lsa_new();
new->vrf_id = vrf_id;
/* Get ospf info */
@@ -832,7 +828,8 @@ static int ospf_router_info_lsa_originate1(void *arg)
/* Install this LSA into LSDB. */
if (ospf_lsa_install(top, NULL /*oi */, new) == NULL) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA_INSTALL_FAILURE,
"ospf_router_info_lsa_originate1: ospf_lsa_install() ?");
ospf_lsa_unlock(&new);
return rc;
@@ -881,7 +878,8 @@ static int ospf_router_info_lsa_originate(void *arg)
}
} else {
if (!is_mandated_params_set(OspfRI))
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA,
"ospf_router_info_lsa_originate: lacks mandated ROUTER INFORMATION parameters");
/* Ok, let's try to originate an LSA */
@@ -912,7 +910,8 @@ static struct ospf_lsa *ospf_router_info_lsa_refresh(struct ospf_lsa *lsa)
/* Verify that the Router Information ID is supported */
if (GET_OPAQUE_ID(ntohl(lsa->data->id.s_addr)) != 0) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA,
"ospf_router_info_lsa_refresh: Unsupported Router Information ID");
return NULL;
}
@@ -925,11 +924,7 @@ static struct ospf_lsa *ospf_router_info_lsa_refresh(struct ospf_lsa *lsa)
}
/* Create new Opaque-LSA/ROUTER INFORMATION instance. */
- if ((new = ospf_router_info_lsa_new()) == NULL) {
- zlog_warn(
- "ospf_router_info_lsa_refresh: ospf_router_info_lsa_new() ?");
- return NULL;
- }
+ new = ospf_router_info_lsa_new();
new->data->ls_seqnum = lsa_seqnum_increment(lsa);
new->vrf_id = lsa->vrf_id;
@@ -937,7 +932,8 @@ static struct ospf_lsa *ospf_router_info_lsa_refresh(struct ospf_lsa *lsa)
/* Given "lsa" will be freed in the next function. */
top = ospf_lookup_by_vrf_id(lsa->vrf_id);
if (ospf_lsa_install(top, NULL /*oi */, new) == NULL) {
- zlog_warn("ospf_router_info_lsa_refresh: ospf_lsa_install() ?");
+ flog_warn(OSPF_WARN_LSA_INSTALL_FAILURE,
+ "ospf_router_info_lsa_refresh: ospf_lsa_install() ?");
ospf_lsa_unlock(&new);
return new;
}
@@ -985,7 +981,8 @@ static void ospf_router_info_lsa_schedule(enum lsa_opcode opcode)
top = ospf_lookup_by_vrf_id(VRF_DEFAULT);
if ((OspfRI.scope == OSPF_OPAQUE_AREA_LSA) && (OspfRI.area == NULL)) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA,
"ospf_router_info_lsa_schedule(): Router Info is Area scope flooding but area is not set");
OspfRI.area = ospf_area_lookup_by_area_id(top, OspfRI.area_id);
}
@@ -1015,10 +1012,6 @@ static void ospf_router_info_lsa_schedule(enum lsa_opcode opcode)
UNSET_FLAG(OspfRI.flags, RIFLG_LSA_ENGAGED);
ospf_opaque_lsa_flush_schedule(&lsa);
break;
- default:
- zlog_warn("ospf_router_info_lsa_schedule: Unknown opcode (%u)",
- opcode);
- break;
}
return;
@@ -1030,7 +1023,8 @@ static int ospf_router_info_lsa_update(struct ospf_lsa *lsa)
/* Sanity Check */
if (lsa == NULL) {
- zlog_warn("OSPF-RI (%s): Abort! LSA is NULL", __func__);
+ flog_warn(OSPF_WARN_LSA, "OSPF-RI (%s): Abort! LSA is NULL",
+ __func__);
return -1;
}
@@ -1452,7 +1446,10 @@ DEFUN (router_info,
/* First start to register Router Information callbacks */
if ((ospf_router_info_register(scope)) != 0) {
- zlog_warn(
+ vty_out(vty,
+ "%% Unable to register Router Information callbacks.");
+ flog_err(
+ OSPF_ERR_INIT_FAIL,
"Unable to register Router Information callbacks. Abort!");
return CMD_WARNING_CONFIG_FAILED;
}
diff --git a/ospfd/ospf_routemap.c b/ospfd/ospf_routemap.c
index c5ec1db33..d4513eebd 100644
--- a/ospfd/ospf_routemap.c
+++ b/ospfd/ospf_routemap.c
@@ -40,6 +40,7 @@
#include "ospfd/ospf_lsa.h"
#include "ospfd/ospf_route.h"
#include "ospfd/ospf_zebra.h"
+#include "ospfd/ospf_errors.h"
/* Hook function for updating route_map assignment. */
static void ospf_route_map_update(const char *name)
@@ -392,7 +393,8 @@ static void *route_set_metric_compile(const char *arg)
metric->type = metric_absolute;
if (strmatch(arg, "+rtt") || strmatch(arg, "-rtt")) {
- zlog_warn("OSPF does not support 'set metric +rtt / -rtt'");
+ flog_warn(OSPF_WARN_SET_METRIC_PLUS,
+ "OSPF does not support 'set metric +rtt / -rtt'");
return metric;
}
diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c
index e3c729f65..41bf0a410 100644
--- a/ospfd/ospf_spf.c
+++ b/ospfd/ospf_spf.c
@@ -47,6 +47,7 @@
#include "ospfd/ospf_abr.h"
#include "ospfd/ospf_dump.h"
#include "ospfd/ospf_sr.h"
+#include "ospfd/ospf_errors.h"
/* Variables to ensure a SPF scheduled log message is printed only once */
@@ -859,7 +860,8 @@ static void ospf_spf_next(struct vertex *v, struct ospf *ospf,
zlog_debug("found the LSA");
break;
default:
- zlog_warn("Invalid LSA link type %d", type);
+ flog_warn(OSPF_WARN_LSA,
+ "Invalid LSA link type %d", type);
continue;
}
} else {
diff --git a/ospfd/ospf_sr.c b/ospfd/ospf_sr.c
index 220de3234..17aa10ba0 100644
--- a/ospfd/ospf_sr.c
+++ b/ospfd/ospf_sr.c
@@ -237,10 +237,6 @@ static int ospf_sr_start(struct ospf *ospf)
srn = hash_get(OspfSR.neighbors, (void *)&(ospf->router_id),
(void *)sr_node_new);
- /* Sanity Check */
- if (srn == NULL)
- return rc;
-
/* Complete & Store self SR Node */
srn->srgb.range_size = OspfSR.srgb.range_size;
srn->srgb.lower_bound = OspfSR.srgb.lower_bound;
@@ -825,9 +821,9 @@ static struct sr_prefix *get_ext_prefix_sid(struct tlv_header *tlvh)
case EXT_SUBTLV_PREFIX_SID:
psid = (struct ext_subtlv_prefix_sid *)sub_tlvh;
if (psid->algorithm != SR_ALGORITHM_SPF) {
- flog_err(OSPF_ERR_SR_INVALID_ALGORITHM,
- "SR (%s): Unsupported Algorithm",
- __func__);
+ flog_err(OSPF_ERR_INVALID_ALGORITHM,
+ "SR (%s): Unsupported Algorithm",
+ __func__);
XFREE(MTYPE_OSPF_SR_PARAMS, srp);
return NULL;
}
@@ -1107,7 +1103,7 @@ void ospf_sr_ri_lsa_update(struct ospf_lsa *lsa)
if (OspfSR.neighbors == NULL) {
flog_err(OSPF_ERR_SR_INVALID_DB,
- "SR (%s): Abort! no valid SR DataBase", __func__);
+ "SR (%s): Abort! no valid SR DataBase", __func__);
return;
}
@@ -1171,8 +1167,9 @@ void ospf_sr_ri_lsa_update(struct ospf_lsa *lsa)
/* Check that we collect mandatory parameters */
if (srn->algo[0] == SR_ALGORITHM_UNSET || srgb.range_size == 0
|| srgb.lower_bound == 0) {
- zlog_warn("SR (%s): Missing mandatory parameters. Abort!",
- __func__);
+ flog_err(OSPF_ERR_SR_NODE_CREATE,
+ "SR (%s): Missing mandatory parameters. Abort!",
+ __func__);
hash_release(OspfSR.neighbors, &(srn->adv_router));
XFREE(MTYPE_OSPF_SR_PARAMS, srn);
return;
@@ -1218,7 +1215,7 @@ void ospf_sr_ri_lsa_delete(struct ospf_lsa *lsa)
/* Sanity check */
if (OspfSR.neighbors == NULL) {
flog_err(OSPF_ERR_SR_INVALID_DB,
- "SR (%s): Abort! no valid SR Data Base", __func__);
+ "SR (%s): Abort! no valid SR Data Base", __func__);
return;
}
@@ -1265,7 +1262,7 @@ void ospf_sr_ext_link_lsa_update(struct ospf_lsa *lsa)
/* Sanity check */
if (OspfSR.neighbors == NULL) {
flog_err(OSPF_ERR_SR_INVALID_DB,
- "SR (%s): Abort! no valid SR DataBase", __func__);
+ "SR (%s): Abort! no valid SR DataBase", __func__);
return;
}
@@ -1317,7 +1314,7 @@ void ospf_sr_ext_link_lsa_delete(struct ospf_lsa *lsa)
/* Sanity check */
if (OspfSR.neighbors == NULL) {
flog_err(OSPF_ERR_SR_INVALID_DB,
- "SR (%s): Abort! no valid SR DataBase", __func__);
+ "SR (%s): Abort! no valid SR DataBase", __func__);
return;
}
@@ -1330,8 +1327,9 @@ void ospf_sr_ext_link_lsa_delete(struct ospf_lsa *lsa)
* processing Router Information LSA deletion
*/
if (srn == NULL) {
- zlog_warn("SR (%s): Stop! no entry in SRDB for SR Node %s",
- __func__, inet_ntoa(lsah->adv_router));
+ flog_err(OSPF_ERR_SR_INVALID_DB,
+ "SR (%s): Stop! no entry in SRDB for SR Node %s",
+ __func__, inet_ntoa(lsah->adv_router));
return;
}
@@ -1347,11 +1345,11 @@ void ospf_sr_ext_link_lsa_delete(struct ospf_lsa *lsa)
listnode_delete(srn->ext_link, srl);
XFREE(MTYPE_OSPF_SR_PARAMS, srl);
} else {
- zlog_warn(
- "SR (%s): Didn't found corresponding SR Link 8.0.0.%u "
- "for SR Node %s",
- __func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)),
- inet_ntoa(lsah->adv_router));
+ flog_err(OSPF_ERR_SR_INVALID_DB,
+ "SR (%s): Didn't found corresponding SR Link 8.0.0.%u "
+ "for SR Node %s",
+ __func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)),
+ inet_ntoa(lsah->adv_router));
}
}
@@ -1375,7 +1373,7 @@ void ospf_sr_ext_prefix_lsa_update(struct ospf_lsa *lsa)
/* Sanity check */
if (OspfSR.neighbors == NULL) {
flog_err(OSPF_ERR_SR_INVALID_DB,
- "SR (%s): Abort! no valid SR DataBase", __func__);
+ "SR (%s): Abort! no valid SR DataBase", __func__);
return;
}
@@ -1387,8 +1385,8 @@ void ospf_sr_ext_prefix_lsa_update(struct ospf_lsa *lsa)
/* Sanity check */
if (srn == NULL) {
flog_err(OSPF_ERR_SR_NODE_CREATE,
- "SR (%s): Abort! can't create SR node in hash table",
- __func__);
+ "SR (%s): Abort! can't create SR node in hash table",
+ __func__);
return;
}
@@ -1428,7 +1426,7 @@ void ospf_sr_ext_prefix_lsa_delete(struct ospf_lsa *lsa)
/* Sanity check */
if (OspfSR.neighbors == NULL) {
flog_err(OSPF_ERR_SR_INVALID_DB,
- "SR (%s): Abort! no valid SR DataBase", __func__);
+ "SR (%s): Abort! no valid SR DataBase", __func__);
return;
}
@@ -1441,8 +1439,9 @@ void ospf_sr_ext_prefix_lsa_delete(struct ospf_lsa *lsa)
* processing Router Information LSA deletion
*/
if (srn == NULL) {
- zlog_warn("SR (%s): Stop! no entry in SRDB for SR Node %s",
- __func__, inet_ntoa(lsah->adv_router));
+ flog_err(OSPF_ERR_SR_INVALID_DB,
+ "SR (%s): Stop! no entry in SRDB for SR Node %s",
+ __func__, inet_ntoa(lsah->adv_router));
return;
}
@@ -1457,9 +1456,9 @@ void ospf_sr_ext_prefix_lsa_delete(struct ospf_lsa *lsa)
listnode_delete(srn->ext_link, srp);
XFREE(MTYPE_OSPF_SR_PARAMS, srp);
} else {
- zlog_warn(
- "SR (%s): Didn't found corresponding SR Prefix "
- "7.0.0.%u for SR Node %s",
+ flog_err(
+ OSPF_ERR_SR_INVALID_DB,
+ "SR (%s): Didn't found corresponding SR Prefix 7.0.0.%u for SR Node %s",
__func__, GET_OPAQUE_ID(ntohl(lsah->id.s_addr)),
inet_ntoa(lsah->adv_router));
}
@@ -1706,10 +1705,7 @@ DEFUN(ospf_sr_enable,
/* Start Segment Routing */
OspfSR.enabled = true;
- if (!ospf_sr_start(ospf)) {
- zlog_warn("SR: Unable to start Segment Routing. Abort!");
- return CMD_WARNING;
- }
+ ospf_sr_start(ospf);
/* Set Router Information SR parameters */
if (IS_DEBUG_OSPF_EVENT)
@@ -1994,7 +1990,7 @@ DEFUN (sr_prefix_sid,
* update of this Extended Prefix
*/
listnode_add(OspfSR.self->ext_prefix, new);
- zlog_warn(
+ zlog_info(
"Interface for prefix %s/%u not found. Deferred LSA "
"flooding",
inet_ntoa(p.u.prefix4), p.prefixlen);
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index a9dc1c18e..f3be77195 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -61,6 +61,7 @@
#include "ospfd/ospf_zebra.h"
#include "ospfd/ospf_te.h"
#include "ospfd/ospf_vty.h"
+#include "ospfd/ospf_errors.h"
/*
* Global variable to manage Opaque-LSA/MPLS-TE on this node.
@@ -102,7 +103,8 @@ int ospf_mpls_te_init(void)
ospf_mpls_te_lsa_refresh, NULL, /* ospf_mpls_te_new_lsa_hook */
NULL /* ospf_mpls_te_del_lsa_hook */);
if (rc != 0) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_OPAQUE_REGISTRATION,
"ospf_mpls_te_init: Failed to register Traffic Engineering functions");
return rc;
}
@@ -139,7 +141,8 @@ static int ospf_mpls_te_register(enum inter_as_mode mode)
ospf_mpls_te_lsa_refresh, NULL, NULL);
if (rc != 0) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_OPAQUE_REGISTRATION,
"ospf_router_info_init: Failed to register Inter-AS functions");
return rc;
}
@@ -231,7 +234,7 @@ static struct mpls_te_link *lookup_linkparams_by_instance(struct ospf_lsa *lsa)
if (lp->instance == key)
return lp;
- zlog_warn("lookup_linkparams_by_instance: Entry not found: key(%x)",
+ zlog_info("lookup_linkparams_by_instance: Entry not found: key(%x)",
key);
return NULL;
}
@@ -783,7 +786,7 @@ static void initialize_linkparams(struct mpls_te_link *lp)
if ((oi == NULL) || (oi->ifp != ifp)) {
if (IS_DEBUG_OSPF_TE)
- zlog_warn(
+ zlog_debug(
"MPLS-TE(initialize_linkparams) Could not find corresponding OSPF Interface for %s",
ifp->name);
return;
@@ -816,18 +819,21 @@ static int is_mandated_params_set(struct mpls_te_link *lp)
int rc = 0;
if (ntohs(OspfMplsTE.router_addr.header.type) == 0) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_TE_UNEXPECTED,
"MPLS-TE(is_mandated_params_set) Missing Router Address");
return rc;
}
if (ntohs(lp->link_type.header.type) == 0) {
- zlog_warn("MPLS-TE(is_mandated_params_set) Missing Link Type");
+ flog_warn(OSPF_WARN_TE_UNEXPECTED,
+ "MPLS-TE(is_mandated_params_set) Missing Link Type");
return rc;
}
if (!IS_INTER_AS(lp->type) && (ntohs(lp->link_id.header.type) == 0)) {
- zlog_warn("MPLS-TE(is_mandated_params_set) Missing Link ID");
+ flog_warn(OSPF_WARN_TE_UNEXPECTED,
+ "MPLS-TE(is_mandated_params_set) Missing Link ID");
return rc;
}
@@ -842,19 +848,14 @@ static int is_mandated_params_set(struct mpls_te_link *lp)
static int ospf_mpls_te_new_if(struct interface *ifp)
{
struct mpls_te_link *new;
- int rc = -1;
if (IS_DEBUG_OSPF_TE)
zlog_debug(
"MPLS-TE(ospf_mpls_te_new_if) Add new %s interface %s to MPLS-TE list",
ifp->link_params ? "Active" : "Inactive", ifp->name);
- if (lookup_linkparams_by_ifp(ifp) != NULL) {
- zlog_warn("ospf_mpls_te_new_if: ifp(%p) already in use?",
- (void *)ifp);
- rc = 0; /* Do nothing here. */
- return rc;
- }
+ if (lookup_linkparams_by_ifp(ifp) != NULL)
+ return 0;
new = XCALLOC(MTYPE_OSPF_MPLS_TE, sizeof(struct mpls_te_link));
@@ -882,9 +883,7 @@ static int ospf_mpls_te_new_if(struct interface *ifp)
ifp->name, new->flags, new->type);
/* Schedule Opaque-LSA refresh. */ /* XXX */
-
- rc = 0;
- return rc;
+ return 0;
}
static int ospf_mpls_te_del_if(struct interface *ifp)
@@ -925,7 +924,8 @@ void ospf_mpls_te_update_if(struct interface *ifp)
/* Get Link context from interface */
if ((lp = lookup_linkparams_by_ifp(ifp)) == NULL) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_TE_UNEXPECTED,
"OSPF MPLS-TE Update: Did not find Link Parameters context for interface %s",
ifp->name);
return;
@@ -969,14 +969,16 @@ static void ospf_mpls_te_ism_change(struct ospf_interface *oi, int old_state)
struct mpls_te_link *lp;
if ((lp = lookup_linkparams_by_ifp(oi->ifp)) == NULL) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_TE_UNEXPECTED,
"ospf_mpls_te_ism_change: Cannot get linkparams from OI(%s)?",
IF_NAME(oi));
return;
}
if (oi->area == NULL || oi->area->ospf == NULL) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_TE_UNEXPECTED,
"ospf_mpls_te_ism_change: Cannot refer to OSPF from OI(%s)?",
IF_NAME(oi));
return;
@@ -986,7 +988,8 @@ static void ospf_mpls_te_ism_change(struct ospf_interface *oi, int old_state)
&& !IPV4_ADDR_SAME(&lp->area->area_id, &oi->area->area_id))
|| (lp->area != NULL && oi->area == NULL)) {
/* How should we consider this case? */
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_TE_UNEXPECTED,
"MPLS-TE: Area for OI(%s) has changed to [%s], flush previous LSAs",
IF_NAME(oi),
oi->area ? inet_ntoa(oi->area->area_id) : "N/A");
@@ -1146,10 +1149,7 @@ static struct ospf_lsa *ospf_mpls_te_lsa_new(struct ospf *ospf,
uint16_t length;
/* Create a stream for LSA. */
- if ((s = stream_new(OSPF_MAX_LSA_SIZE)) == NULL) {
- zlog_warn("ospf_mpls_te_lsa_new: stream_new() ?");
- return NULL;
- }
+ s = stream_new(OSPF_MAX_LSA_SIZE);
lsah = (struct lsa_header *)STREAM_DATA(s);
options = OSPF_OPTION_O; /* Don't forget this :-) */
@@ -1223,14 +1223,16 @@ static int ospf_mpls_te_lsa_originate1(struct ospf_area *area,
/* Create new Opaque-LSA/MPLS-TE instance. */
new = ospf_mpls_te_lsa_new(area->ospf, area, lp);
if (new == NULL) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_TE_UNEXPECTED,
"ospf_mpls_te_lsa_originate1: ospf_mpls_te_lsa_new() ?");
return rc;
}
/* Install this LSA into LSDB. */
if (ospf_lsa_install(area->ospf, NULL /*oi*/, new) == NULL) {
- zlog_warn("ospf_mpls_te_lsa_originate1: ospf_lsa_install() ?");
+ flog_warn(OSPF_WARN_LSA_INSTALL_FAILURE,
+ "ospf_mpls_te_lsa_originate1: ospf_lsa_install() ?");
ospf_lsa_unlock(&new);
return rc;
}
@@ -1286,7 +1288,7 @@ static int ospf_mpls_te_lsa_originate_area(void *arg)
if (CHECK_FLAG(lp->flags, LPFLG_LSA_ENGAGED)) {
if (CHECK_FLAG(lp->flags, LPFLG_LSA_FORCED_REFRESH)) {
UNSET_FLAG(lp->flags, LPFLG_LSA_FORCED_REFRESH);
- zlog_warn(
+ zlog_info(
"OSPF MPLS-TE (ospf_mpls_te_lsa_originate_area): Refresh instead of Originate");
ospf_mpls_te_lsa_schedule(lp, REFRESH_THIS_LSA);
}
@@ -1294,7 +1296,7 @@ static int ospf_mpls_te_lsa_originate_area(void *arg)
}
if (!is_mandated_params_set(lp)) {
- zlog_warn(
+ zlog_info(
"ospf_mpls_te_lsa_originate_area: Link(%s) lacks some mandated MPLS-TE parameters.",
lp->ifp ? lp->ifp->name : "?");
continue;
@@ -1323,7 +1325,8 @@ static int ospf_mpls_te_lsa_originate2(struct ospf *top,
/* Create new Opaque-LSA/Inter-AS instance. */
new = ospf_mpls_te_lsa_new(top, NULL, lp);
if (new == NULL) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_LSA_UNEXPECTED,
"ospf_mpls_te_lsa_originate2: ospf_router_info_lsa_new() ?");
return rc;
}
@@ -1331,7 +1334,8 @@ static int ospf_mpls_te_lsa_originate2(struct ospf *top,
/* Install this LSA into LSDB. */
if (ospf_lsa_install(top, NULL /*oi */, new) == NULL) {
- zlog_warn("ospf_mpls_te_lsa_originate2: ospf_lsa_install() ?");
+ flog_warn(OSPF_WARN_LSA_INSTALL_FAILURE,
+ "ospf_mpls_te_lsa_originate2: ospf_lsa_install() ?");
ospf_lsa_unlock(&new);
return rc;
}
@@ -1385,7 +1389,8 @@ static int ospf_mpls_te_lsa_originate_as(void *arg)
}
if (!is_mandated_params_set(lp)) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_TE_UNEXPECTED,
"ospf_mpls_te_lsa_originate_as: Link(%s) lacks some mandated MPLS-TE parameters.",
lp->ifp ? lp->ifp->name : "?");
continue;
@@ -1432,7 +1437,8 @@ static struct ospf_lsa *ospf_mpls_te_lsa_refresh(struct ospf_lsa *lsa)
/* At first, resolve lsa/lp relationship. */
if ((lp = lookup_linkparams_by_instance(lsa)) == NULL) {
- zlog_warn("ospf_mpls_te_lsa_refresh: Invalid parameter?");
+ flog_warn(OSPF_WARN_TE_UNEXPECTED,
+ "ospf_mpls_te_lsa_refresh: Invalid parameter?");
lsa->data->ls_age =
htons(OSPF_LSA_MAXAGE); /* Flush it anyway. */
ospf_opaque_lsa_flush_schedule(lsa);
@@ -1441,7 +1447,8 @@ static struct ospf_lsa *ospf_mpls_te_lsa_refresh(struct ospf_lsa *lsa)
/* Check if lp was not disable in the interval */
if (!CHECK_FLAG(lp->flags, LPFLG_LSA_ACTIVE)) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_TE_UNEXPECTED,
"ospf_mpls_te_lsa_refresh: lp was disabled: Flush it!");
lsa->data->ls_age =
htons(OSPF_LSA_MAXAGE); /* Flush it anyway. */
@@ -1457,7 +1464,8 @@ static struct ospf_lsa *ospf_mpls_te_lsa_refresh(struct ospf_lsa *lsa)
/* Create new Opaque-LSA/MPLS-TE instance. */
new = ospf_mpls_te_lsa_new(top, area, lp);
if (new == NULL) {
- zlog_warn("ospf_mpls_te_lsa_refresh: ospf_mpls_te_lsa_new() ?");
+ flog_warn(OSPF_WARN_TE_UNEXPECTED,
+ "ospf_mpls_te_lsa_refresh: ospf_mpls_te_lsa_new() ?");
return NULL;
}
new->data->ls_seqnum = lsa_seqnum_increment(lsa);
@@ -1470,7 +1478,8 @@ static struct ospf_lsa *ospf_mpls_te_lsa_refresh(struct ospf_lsa *lsa)
top = area->ospf;
if (ospf_lsa_install(top, NULL /*oi */, new) == NULL) {
- zlog_warn("ospf_mpls_te_lsa_refresh: ospf_lsa_install() ?");
+ flog_warn(OSPF_WARN_LSA_INSTALL_FAILURE,
+ "ospf_mpls_te_lsa_refresh: ospf_lsa_install() ?");
ospf_lsa_unlock(&new);
return NULL;
}
@@ -1524,7 +1533,8 @@ void ospf_mpls_te_lsa_schedule(struct mpls_te_link *lp, enum lsa_opcode opcode)
top, OspfMplsTE.interas_areaid);
/* Unable to set the area context. Abort! */
if (lp->area == NULL) {
- zlog_warn(
+ flog_warn(
+ OSPF_WARN_TE_UNEXPECTED,
"MPLS-TE(ospf_mpls_te_lsa_schedule) Area context is null. Abort !");
return;
}
@@ -1567,7 +1577,8 @@ void ospf_mpls_te_lsa_schedule(struct mpls_te_link *lp, enum lsa_opcode opcode)
ospf_opaque_lsa_flush_schedule(&lsa);
break;
default:
- zlog_warn("ospf_mpls_te_lsa_schedule: Unknown opcode (%u)",
+ flog_warn(OSPF_WARN_TE_UNEXPECTED,
+ "ospf_mpls_te_lsa_schedule: Unknown opcode (%u)",
opcode);
break;
}
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index 8c94a8ef9..912142b78 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -152,10 +152,6 @@ static int ospf_interface_delete(int command, struct zclient *zclient,
if (ifp == NULL)
return 0;
- if (if_is_up(ifp))
- zlog_warn("Zebra: got delete of %s, but interface is still up",
- ifp->name);
-
if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE))
zlog_debug(
"Zebra: interface delete %s vrf %s[%u] index %d flags %llx metric %d mtu %d",
@@ -1209,7 +1205,6 @@ static void ospf_filter_update(struct access_list *access)
/* Update distribute-list, and apply filter. */
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) {
struct list *red_list;
- struct listnode *node;
struct ospf_redist *red;
red_list = ospf->redist[type];
@@ -1299,7 +1294,6 @@ void ospf_prefix_list_update(struct prefix_list *plist)
*/
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) {
struct list *red_list;
- struct listnode *node;
struct ospf_redist *red;
red_list = ospf->redist[type];
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index d311b4da6..b18c5a93a 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -308,12 +308,8 @@ static struct ospf *ospf_new(unsigned short instance, const char *name)
new->lsa_refresh_interval, &new->t_lsa_refresher);
new->lsa_refresher_started = monotime(NULL);
- if ((new->ibuf = stream_new(OSPF_MAX_PACKET_SIZE + 1)) == NULL) {
- zlog_err(
- "ospf_new: fatal error: stream_new(%u) failed allocating ibuf",
- OSPF_MAX_PACKET_SIZE + 1);
- exit(1);
- }
+ new->ibuf = stream_new(OSPF_MAX_PACKET_SIZE + 1);
+
new->t_read = NULL;
new->oi_write_q = list_new();
new->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT;
@@ -328,7 +324,8 @@ static struct ospf *ospf_new(unsigned short instance, const char *name)
new->fd = -1;
if ((ospf_sock_init(new)) < 0) {
if (new->vrf_id != VRF_UNKNOWN)
- zlog_warn(
+ flog_err(
+ LIB_ERR_SOCKET,
"%s: ospf_sock_init is unable to open a socket",
__func__);
return new;
@@ -722,8 +719,6 @@ static void ospf_finish_final(struct ospf *ospf)
ospf_lsdb_free(ospf->lsdb);
for (rn = route_top(ospf->maxage_lsa); rn; rn = route_next(rn)) {
- struct ospf_lsa *lsa;
-
if ((lsa = rn->info) != NULL) {
ospf_lsa_unlock(&lsa);
rn->info = NULL;
@@ -759,7 +754,6 @@ static void ospf_finish_final(struct ospf *ospf)
for (i = ZEBRA_ROUTE_SYSTEM; i <= ZEBRA_ROUTE_MAX; i++) {
struct list *ext_list;
- struct listnode *node;
struct ospf_external *ext;
ext_list = ospf->external[i];
diff --git a/pimd/mtracebis_netlink.c b/pimd/mtracebis_netlink.c
index 30ee8f24a..47b5f7e52 100644
--- a/pimd/mtracebis_netlink.c
+++ b/pimd/mtracebis_netlink.c
@@ -243,7 +243,7 @@ int rtnl_dump_filter_l(struct rtnl_handle *rth,
break; /* process next filter */
}
if (h->nlmsg_type == NLMSG_ERROR) {
- struct nlmsgerr *err =
+ struct nlmsgerr *merr =
(struct nlmsgerr *)NLMSG_DATA(
h);
if (h->nlmsg_len
@@ -252,7 +252,7 @@ int rtnl_dump_filter_l(struct rtnl_handle *rth,
fprintf(stderr,
"ERROR truncated\n");
} else {
- errno = -err->error;
+ errno = -merr->error;
perror("RTNETLINK answers");
}
return -1;
@@ -379,12 +379,12 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
}
if (h->nlmsg_type == NLMSG_ERROR) {
- struct nlmsgerr *err =
+ struct nlmsgerr *merr =
(struct nlmsgerr *)NLMSG_DATA(h);
if (l < (int)sizeof(struct nlmsgerr)) {
fprintf(stderr, "ERROR truncated\n");
} else {
- errno = -err->error;
+ errno = -merr->error;
if (errno == 0) {
if (answer)
memcpy(answer, h,
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index 8ef8f87d1..968fc378f 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -6474,13 +6474,13 @@ static int pim_cmd_interface_delete(struct interface *ifp)
static int interface_no_ip_pim_helper(struct vty *vty)
{
- VTY_DECLVAR_CONTEXT(interface, ifp);
- if (!pim_cmd_interface_delete(ifp)) {
- vty_out(vty, "Unable to delete interface information\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
+ VTY_DECLVAR_CONTEXT(interface, ifp);
+ if (!pim_cmd_interface_delete(ifp)) {
+ vty_out(vty, "Unable to delete interface information\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
- return CMD_SUCCESS;
+ return CMD_SUCCESS;
}
DEFUN_HIDDEN (interface_no_ip_pim_ssm,
diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c
index 313734503..a3d6a2e65 100644
--- a/pimd/pim_ifchannel.c
+++ b/pimd/pim_ifchannel.c
@@ -1115,7 +1115,8 @@ void pim_ifchannel_local_membership_del(struct interface *ifp,
struct channel_oil *c_oil = child->channel_oil;
struct pim_ifchannel *chchannel =
pim_ifchannel_find(ifp, &child->sg);
- struct pim_interface *pim_ifp = ifp->info;
+
+ pim_ifp = ifp->info;
if (PIM_DEBUG_EVENTS)
zlog_debug("%s %s: Prune(S,G)=%s(%s) from %s",
diff --git a/pimd/pim_pim.c b/pimd/pim_pim.c
index d5ee30fb2..cf078064d 100644
--- a/pimd/pim_pim.c
+++ b/pimd/pim_pim.c
@@ -573,8 +573,6 @@ int pim_msg_send(int fd, struct in_addr src, struct in_addr dst,
ip->ip_len = htons(sendlen);
if (PIM_DEBUG_PIM_PACKETS) {
- struct pim_msg_header *header =
- (struct pim_msg_header *)pim_msg;
char dst_str[INET_ADDRSTRLEN];
pim_inet4_dump("<dst?>", dst, dst_str, sizeof(dst_str));
zlog_debug("%s: to %s on %s: msg_size=%d checksum=%x",
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index 364e23c5e..5b50c031a 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -712,7 +712,7 @@ static int rip_enable_network_lookup_if(struct interface *ifp)
for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, connected)) {
struct prefix *p;
- struct route_node *node;
+ struct route_node *n;
p = connected->address;
@@ -721,10 +721,10 @@ static int rip_enable_network_lookup_if(struct interface *ifp)
address.prefix = p->u.prefix4;
address.prefixlen = IPV4_MAX_BITLEN;
- node = route_node_match(rip_enable_network,
- (struct prefix *)&address);
- if (node) {
- route_unlock_node(node);
+ n = route_node_match(rip_enable_network,
+ (struct prefix *)&address);
+ if (n) {
+ route_unlock_node(n);
return 1;
}
}
diff --git a/ripd/ripd.c b/ripd/ripd.c
index 02ead6fde..560e649a8 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -436,8 +436,6 @@ static void rip_rte_process(struct rte *rte, struct sockaddr_in *from,
/* Modify entry according to the interface routemap. */
if (ri->routemap[RIP_FILTER_IN]) {
- int ret;
-
/* The object should be of the type of rip_info */
ret = route_map_apply(ri->routemap[RIP_FILTER_IN],
(struct prefix *)&p, RMAP_RIP, &newinfo);
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index d1341d67b..850216b44 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -706,8 +706,6 @@ static void ripng_route_process(struct rte *rte, struct sockaddr_in6 *from,
/* Modify entry. */
if (ri->routemap[RIPNG_FILTER_IN]) {
- int ret;
-
ret = route_map_apply(ri->routemap[RIPNG_FILTER_IN],
(struct prefix *)&p, RMAP_RIPNG,
&newinfo);
@@ -1618,8 +1616,6 @@ void ripng_output_process(struct interface *ifp, struct sockaddr_in6 *to,
/* Interface route-map */
if (ri->routemap[RIPNG_FILTER_OUT]) {
- int ret;
-
ret = route_map_apply(
ri->routemap[RIPNG_FILTER_OUT],
(struct prefix *)p, RMAP_RIPNG, rinfo);
@@ -1636,8 +1632,6 @@ void ripng_output_process(struct interface *ifp, struct sockaddr_in6 *to,
/* Redistribute route-map. */
if (ripng->route_map[rinfo->type].name) {
- int ret;
-
ret = route_map_apply(
ripng->route_map[rinfo->type].map,
(struct prefix *)p, RMAP_RIPNG, rinfo);
@@ -1724,7 +1718,6 @@ void ripng_output_process(struct interface *ifp, struct sockaddr_in6 *to,
/* Interface route-map */
if (ri->routemap[RIPNG_FILTER_OUT]) {
- int ret;
struct ripng_info newinfo;
/* let's cast the aggregate structure to
diff --git a/zebra/connected.c b/zebra/connected.c
index 57bfcc4d1..ff9c82883 100644
--- a/zebra/connected.c
+++ b/zebra/connected.c
@@ -40,6 +40,7 @@
#include "zebra/rtadv.h"
#include "zebra/zebra_mpls.h"
#include "zebra/debug.h"
+#include "zebra/zebra_errors.h"
/* communicate the withdrawal of a connected address */
static void connected_withdraw(struct connected *ifc)
@@ -236,7 +237,8 @@ void connected_up(struct interface *ifp, struct connected *ifc)
#endif
break;
default:
- zlog_warn("Received unknown AFI: %s", afi2str(afi));
+ flog_warn(ZEBRA_ERR_CONNECTED_AFI_UNKNOWN,
+ "Received unknown AFI: %s", afi2str(afi));
return;
break;
}
@@ -309,7 +311,8 @@ void connected_add_ipv4(struct interface *ifp, int flags, struct in_addr *addr,
/* validate the destination address */
if (CONNECTED_PEER(ifc)) {
if (IPV4_ADDR_SAME(addr, broad))
- zlog_warn(
+ flog_warn(
+ ZEBRA_ERR_IFACE_SAME_LOCAL_AS_PEER,
"warning: interface %s has same local and peer "
"address %s, routing protocols may malfunction",
ifp->name, inet_ntoa(*addr));
@@ -320,7 +323,8 @@ void connected_add_ipv4(struct interface *ifp, int flags, struct in_addr *addr,
struct in_addr bcalc;
bcalc.s_addr = ipv4_broadcast_addr(addr->s_addr,
prefixlen);
- zlog_warn(
+ flog_warn(
+ ZEBRA_ERR_BCAST_ADDR_MISMATCH,
"warning: interface %s broadcast addr %s/%d != "
"calculated %s, routing protocols may malfunction",
ifp->name,
@@ -334,7 +338,7 @@ void connected_add_ipv4(struct interface *ifp, int flags, struct in_addr *addr,
} else {
if (CHECK_FLAG(ifc->flags, ZEBRA_IFA_PEER)) {
- zlog_warn(
+ zlog_debug(
"warning: %s called for interface %s "
"with peer flag set, but no peer address supplied",
__func__, ifp->name);
@@ -343,7 +347,7 @@ void connected_add_ipv4(struct interface *ifp, int flags, struct in_addr *addr,
/* no broadcast or destination address was supplied */
if ((prefixlen == IPV4_MAX_PREFIXLEN) && if_is_pointopoint(ifp))
- zlog_warn(
+ zlog_debug(
"warning: PtP interface %s with addr %s/%d needs a "
"peer address",
ifp->name, inet_ntoa(*addr), prefixlen);
@@ -527,8 +531,9 @@ void connected_add_ipv6(struct interface *ifp, int flags, struct in6_addr *addr,
ifc->destination = (struct prefix *)p;
} else {
if (CHECK_FLAG(ifc->flags, ZEBRA_IFA_PEER)) {
- zlog_warn("warning: %s called for interface %s with peer flag set, but no peer address supplied",
- __func__, ifp->name);
+ zlog_debug(
+ "warning: %s called for interface %s with peer flag set, but no peer address supplied",
+ __func__, ifp->name);
UNSET_FLAG(ifc->flags, ZEBRA_IFA_PEER);
}
}
diff --git a/zebra/if_ioctl.c b/zebra/if_ioctl.c
index 176bb2bba..6155e8c4e 100644
--- a/zebra/if_ioctl.c
+++ b/zebra/if_ioctl.c
@@ -38,6 +38,7 @@
#include "zebra/interface.h"
#include "zebra/rib.h"
#include "zebra/rt.h"
+#include "zebra/zebra_errors.h"
#include <ifaddrs.h>
@@ -57,8 +58,9 @@ static int interface_list_ioctl(void)
/* Normally SIOCGIFCONF works with AF_INET socket. */
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0) {
- zlog_warn("Can't make AF_INET socket stream: %s",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "Can't make AF_INET socket stream: %s",
+ safe_strerror(errno));
return -1;
}
@@ -86,7 +88,8 @@ static int interface_list_ioctl(void)
ret = ioctl(sock, SIOCGIFCONF, &ifconf);
if (ret < 0) {
- zlog_warn("SIOCGIFCONF: %s", safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL, "SIOCGIFCONF: %s",
+ safe_strerror(errno));
goto end;
}
/* Repeatedly get info til buffer fails to grow. */
diff --git a/zebra/if_ioctl_solaris.c b/zebra/if_ioctl_solaris.c
index 7ec73ea11..1f12d4c02 100644
--- a/zebra/if_ioctl_solaris.c
+++ b/zebra/if_ioctl_solaris.c
@@ -40,6 +40,7 @@
#include "zebra/ioctl_solaris.h"
#include "zebra/rib.h"
#include "zebra/rt.h"
+#include "zebra/zebra_errors.h"
static int if_get_addr(struct interface *, struct sockaddr *, const char *);
static void interface_info_ioctl(struct interface *);
@@ -64,9 +65,9 @@ static int interface_list_ioctl(int af)
}
if (sock < 0) {
- zlog_warn("Can't make %s socket stream: %s",
- (af == AF_INET ? "AF_INET" : "AF_INET6"),
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "Can't make %s socket stream: %s",
+ (af == AF_INET ? "AF_INET" : "AF_INET6"),
+ safe_strerror(errno));
return -1;
}
@@ -79,8 +80,9 @@ calculate_lifc_len:
}
if (ret < 0) {
- zlog_warn("interface_list_ioctl: SIOCGLIFNUM failed %s",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "interface_list_ioctl: SIOCGLIFNUM failed %s",
+ safe_strerror(errno));
close(sock);
return -1;
}
@@ -113,7 +115,8 @@ calculate_lifc_len:
if (errno == EINVAL)
goto calculate_lifc_len;
- zlog_warn("SIOCGLIFCONF: %s", safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL, "SIOCGLIFCONF: %s",
+ safe_strerror(errno));
goto end;
}
@@ -204,7 +207,8 @@ static int if_get_index(struct interface *ifp)
ret = -1;
if (ret < 0) {
- zlog_warn("SIOCGLIFINDEX(%s) failed", ifp->name);
+ flog_err_sys(LIB_ERR_SYSTEM_CALL, "SIOCGLIFINDEX(%s) failed",
+ ifp->name);
return ret;
}
@@ -266,8 +270,9 @@ static int if_get_addr(struct interface *ifp, struct sockaddr *addr,
if (ret < 0) {
if (errno != EADDRNOTAVAIL) {
- zlog_warn("SIOCGLIFNETMASK (%s) fail: %s",
- ifp->name, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "SIOCGLIFNETMASK (%s) fail: %s",
+ ifp->name, safe_strerror(errno));
return ret;
}
return 0;
@@ -286,8 +291,9 @@ static int if_get_addr(struct interface *ifp, struct sockaddr *addr,
if (ifp->flags & IFF_POINTOPOINT)
prefixlen = IPV6_MAX_BITLEN;
else
- zlog_warn("SIOCGLIFSUBNET (%s) fail: %s",
- ifp->name, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "SIOCGLIFSUBNET (%s) fail: %s",
+ ifp->name, safe_strerror(errno));
} else {
prefixlen = lifreq.lifr_addrlen;
}
@@ -317,7 +323,7 @@ static void interface_info_ioctl(struct interface *ifp)
void interface_list(struct zebra_ns *zns)
{
if (zns->ns_id != NS_DEFAULT) {
- zlog_warn("interface_list: ignore NS %u", zns->ns_id);
+ zlog_debug("interface_list: ignore NS %u", zns->ns_id);
return;
}
interface_list_ioctl(AF_INET);
diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c
index 3d67e3378..184c5a4fa 100644
--- a/zebra/if_netlink.c
+++ b/zebra/if_netlink.c
@@ -67,6 +67,7 @@
#include "zebra/zebra_mpls.h"
#include "zebra/kernel_netlink.h"
#include "zebra/if_netlink.h"
+#include "zebra/zebra_errors.h"
extern struct zebra_privs_t zserv_privs;
@@ -112,8 +113,8 @@ static void netlink_interface_update_hw_addr(struct rtattr **tb,
hw_addr_len = RTA_PAYLOAD(tb[IFLA_ADDRESS]);
if (hw_addr_len > INTERFACE_HWADDR_MAX)
- zlog_warn("Hardware address is too large: %d",
- hw_addr_len);
+ zlog_debug("Hardware address is too large: %d",
+ hw_addr_len);
else {
ifp->hw_addr_len = hw_addr_len;
memcpy(ifp->hw_addr, RTA_DATA(tb[IFLA_ADDRESS]),
@@ -349,7 +350,8 @@ static void netlink_vrf_change(struct nlmsghdr *h, struct rtattr *tb,
vrf = vrf_lookup_by_id((vrf_id_t)ifi->ifi_index);
if (!vrf) {
- zlog_warn("%s: vrf not found", __func__);
+ flog_warn(ZEBRA_ERR_VRF_NOT_FOUND, "%s: vrf not found",
+ __func__);
return;
}
@@ -531,7 +533,8 @@ static int netlink_bridge_interface(struct nlmsghdr *h, int len, ns_id_t ns_id,
/* The interface should already be known, if not discard. */
ifp = if_lookup_by_index_per_ns(zebra_ns_lookup(ns_id), ifi->ifi_index);
if (!ifp) {
- zlog_warn("Cannot find bridge IF %s(%u)", name, ifi->ifi_index);
+ zlog_debug("Cannot find bridge IF %s(%u)", name,
+ ifi->ifi_index);
return 0;
}
if (!IS_ZEBRA_IF_VXLAN(ifp))
@@ -896,7 +899,8 @@ int netlink_interface_addr(struct nlmsghdr *h, ns_id_t ns_id, int startup)
ifa = NLMSG_DATA(h);
if (ifa->ifa_family != AF_INET && ifa->ifa_family != AF_INET6) {
- zlog_warn(
+ flog_warn(
+ ZEBRA_ERR_UNKNOWN_FAMILY,
"Invalid address family: %u received from kernel interface addr change: %u",
ifa->ifa_family, h->nlmsg_type);
return 0;
@@ -1069,14 +1073,15 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
/* assume if not default zns, then new VRF */
if (!(h->nlmsg_type == RTM_NEWLINK || h->nlmsg_type == RTM_DELLINK)) {
/* If this is not link add/delete message so print warning. */
- zlog_warn("netlink_link_change: wrong kernel message %d",
- h->nlmsg_type);
+ zlog_debug("netlink_link_change: wrong kernel message %d",
+ h->nlmsg_type);
return 0;
}
if (!(ifi->ifi_family == AF_UNSPEC || ifi->ifi_family == AF_BRIDGE
|| ifi->ifi_family == AF_INET6)) {
- zlog_warn(
+ flog_warn(
+ ZEBRA_ERR_UNKNOWN_FAMILY,
"Invalid address family: %u received from kernel link change: %u",
ifi->ifi_family, h->nlmsg_type);
return 0;
@@ -1187,7 +1192,7 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
set_ifindex(ifp, ifi->ifi_index, zns);
ifp->flags = ifi->ifi_flags & 0x0000fffff;
if (!tb[IFLA_MTU]) {
- zlog_warn(
+ zlog_debug(
"RTM_NEWLINK for interface %s(%u) without MTU set",
name, ifi->ifi_index);
return 0;
@@ -1240,7 +1245,7 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
set_ifindex(ifp, ifi->ifi_index, zns);
if (!tb[IFLA_MTU]) {
- zlog_warn(
+ zlog_debug(
"RTM_NEWLINK for interface %s(%u) without MTU set",
name, ifi->ifi_index);
return 0;
@@ -1294,8 +1299,10 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
} else {
/* Delete interface notification from kernel */
if (ifp == NULL) {
- zlog_warn("RTM_DELLINK for unknown interface %s(%u)",
- name, ifi->ifi_index);
+ if (IS_ZEBRA_DEBUG_KERNEL)
+ zlog_debug(
+ "RTM_DELLINK for unknown interface %s(%u)",
+ name, ifi->ifi_index);
return 0;
}
diff --git a/zebra/if_sysctl.c b/zebra/if_sysctl.c
index 39b7204e8..df0831a9f 100644
--- a/zebra/if_sysctl.c
+++ b/zebra/if_sysctl.c
@@ -37,6 +37,7 @@
#include "zebra/rt.h"
#include "zebra/kernel_socket.h"
#include "zebra/rib.h"
+#include "zebra/zebra_errors.h"
void ifstat_update_sysctl(void)
{
@@ -52,7 +53,8 @@ void ifstat_update_sysctl(void)
/* Query buffer size. */
if (sysctl(mib, MIBSIZ, NULL, &bufsiz, NULL, 0) < 0) {
- zlog_warn("sysctl() error by %s", safe_strerror(errno));
+ flog_warn(ZEBRA_ERR_SYSCTL_FAILED, "sysctl() error by %s",
+ safe_strerror(errno));
return;
}
@@ -61,7 +63,8 @@ void ifstat_update_sysctl(void)
/* Fetch interface informations into allocated buffer. */
if (sysctl(mib, MIBSIZ, buf, &bufsiz, NULL, 0) < 0) {
- zlog_warn("sysctl error by %s", safe_strerror(errno));
+ flog_warn(ZEBRA_ERR_SYSCTL_FAILED, "sysctl error by %s",
+ safe_strerror(errno));
XFREE(MTYPE_TMP, ref);
return;
}
@@ -95,13 +98,15 @@ void interface_list(struct zebra_ns *zns)
NET_RT_IFLIST, 0};
if (zns->ns_id != NS_DEFAULT) {
- zlog_warn("interface_list: ignore NS %u", zns->ns_id);
+ zlog_debug("interface_list: ignore NS %u", zns->ns_id);
return;
}
/* Query buffer size. */
if (sysctl(mib, MIBSIZ, NULL, &bufsiz, NULL, 0) < 0) {
- zlog_warn("sysctl() error by %s", safe_strerror(errno));
+ flog_err_sys(ZEBRA_ERR_IFLIST_FAILED,
+ "Could not enumerate interfaces: %s",
+ safe_strerror(errno));
return;
}
@@ -110,7 +115,9 @@ void interface_list(struct zebra_ns *zns)
/* Fetch interface informations into allocated buffer. */
if (sysctl(mib, MIBSIZ, buf, &bufsiz, NULL, 0) < 0) {
- zlog_warn("sysctl error by %s", safe_strerror(errno));
+ flog_err_sys(ZEBRA_ERR_IFLIST_FAILED,
+ "Could not enumerate interfaces: %s",
+ safe_strerror(errno));
return;
}
diff --git a/zebra/interface.c b/zebra/interface.c
index 0c9e21d06..488980c46 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -49,6 +49,7 @@
#include "zebra/rt_netlink.h"
#include "zebra/interface.h"
#include "zebra/zebra_vxlan.h"
+#include "zebra/zebra_errors.h"
#define ZEBRA_PTM_SUPPORT
@@ -311,9 +312,9 @@ int if_subnet_delete(struct interface *ifp, struct connected *ifc)
/* Get address derived subnet node. */
rn = route_node_lookup(zebra_if->ipv4_subnets, &cp);
if (!(rn && rn->info)) {
- zlog_warn(
- "Trying to remove an address from an unknown subnet."
- " (please report this bug)");
+ flog_warn(ZEBRA_ERR_REMOVE_ADDR_UNKNOWN_SUBNET,
+ "Trying to remove an address from an unknown subnet."
+ " (please report this bug)");
return -1;
}
route_unlock_node(rn);
@@ -325,7 +326,8 @@ int if_subnet_delete(struct interface *ifp, struct connected *ifc)
* In any case, we shouldn't decrement the lock counter if the address
* is unknown. */
if (!listnode_lookup(addr_list, ifc)) {
- zlog_warn(
+ flog_warn(
+ ZEBRA_ERR_REMOVE_UNREGISTERED_ADDR,
"Trying to remove an address from a subnet where it is not"
" currently registered. (please report this bug)");
return -1;
@@ -471,7 +473,8 @@ static void if_addr_wakeup(struct interface *ifp)
ret = if_set_prefix(ifp, ifc);
if (ret < 0) {
- zlog_warn(
+ flog_err_sys(
+ ZEBRA_ERR_IFACE_ADDR_ADD_FAILED,
"Can't set interface's address: %s",
safe_strerror(errno));
continue;
@@ -493,7 +496,8 @@ static void if_addr_wakeup(struct interface *ifp)
ret = if_prefix_add_ipv6(ifp, ifc);
if (ret < 0) {
- zlog_warn(
+ flog_err_sys(
+ ZEBRA_ERR_IFACE_ADDR_ADD_FAILED,
"Can't set interface's address: %s",
safe_strerror(errno));
continue;
@@ -887,7 +891,8 @@ void if_up(struct interface *ifp)
/* Notify the protocol daemons. */
if (ifp->ptm_enable && (ifp->ptm_status == ZEBRA_PTM_STATUS_DOWN)) {
- zlog_warn("%s: interface %s hasn't passed ptm check\n",
+ flog_warn(ZEBRA_ERR_PTM_NOT_READY,
+ "%s: interface %s hasn't passed ptm check\n",
__func__, ifp->name);
return;
}
diff --git a/zebra/ioctl.c b/zebra/ioctl.c
index 0469bc38c..5c2380cdd 100644
--- a/zebra/ioctl.c
+++ b/zebra/ioctl.c
@@ -33,6 +33,7 @@
#include "zebra/rib.h"
#include "zebra/rt.h"
#include "zebra/interface.h"
+#include "zebra/zebra_errors.h"
#ifndef SUNOS_5
diff --git a/zebra/ioctl_solaris.c b/zebra/ioctl_solaris.c
index 260911ce6..2f92cf256 100644
--- a/zebra/ioctl_solaris.c
+++ b/zebra/ioctl_solaris.c
@@ -37,6 +37,7 @@
#include "zebra/rt.h"
#include "zebra/interface.h"
#include "zebra/ioctl_solaris.h"
+#include "zebra/zebra_errors.h"
extern struct zebra_privs_t zserv_privs;
@@ -380,7 +381,7 @@ int if_prefix_add_ipv6(struct interface *ifp, struct connected *ifc)
{
char addrbuf[PREFIX_STRLEN];
- zlog_warn("Can't set %s on interface %s",
+ flog_warn(LIB_ERR_DEVELOPMENT, "Can't set %s on interface %s",
prefix2str(ifc->address, addrbuf, sizeof(addrbuf)),
ifp->name);
@@ -391,7 +392,7 @@ int if_prefix_delete_ipv6(struct interface *ifp, struct connected *ifc)
{
char addrbuf[PREFIX_STRLEN];
- zlog_warn("Can't delete %s on interface %s",
+ flog_warn(LIB_ERR_DEVELOPMENT, "Can't delete %s on interface %s",
prefix2str(ifc->address, addrbuf, sizeof(addrbuf)),
ifp->name);
diff --git a/zebra/ipforward_proc.c b/zebra/ipforward_proc.c
index 3a766b1ea..8f44c377b 100644
--- a/zebra/ipforward_proc.c
+++ b/zebra/ipforward_proc.c
@@ -25,7 +25,6 @@
#include "log.h"
#include "privs.h"
-#include "lib_errors.h"
#include "zebra/ipforward.h"
diff --git a/zebra/ipforward_solaris.c b/zebra/ipforward_solaris.c
index b06baa04a..7f372e32f 100644
--- a/zebra/ipforward_solaris.c
+++ b/zebra/ipforward_solaris.c
@@ -29,6 +29,7 @@
#include "privs.h"
#include "zebra/ipforward.h"
+#include "zebra/zebra_errors.h"
/*
** Solaris should define IP_DEV_NAME in <inet/ip.h>, but we'll save
@@ -84,15 +85,16 @@ static int solaris_nd(const int cmd, const char *parameter, const int value)
frr_elevate_privs(&zserv_privs) {
if ((fd = open(device, O_RDWR)) < 0) {
- zlog_warn("failed to open device %s - %s", device,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "failed to open device %s - %s", device,
+ safe_strerror(errno));
return -1;
}
if (ioctl(fd, I_STR, &strioctl) < 0) {
close(fd);
- zlog_warn("ioctl I_STR failed on device %s - %s",
- device,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "ioctl I_STR failed on device %s - %s",
+ device, safe_strerror(errno));
return -1;
}
close(fd);
@@ -102,7 +104,7 @@ static int solaris_nd(const int cmd, const char *parameter, const int value)
errno = 0;
retval = atoi(nd_buf);
if (errno) {
- zlog_warn(
+ zlog_debug(
"failed to convert returned value to integer - %s",
safe_strerror(errno));
retval = -1;
diff --git a/zebra/ipforward_sysctl.c b/zebra/ipforward_sysctl.c
index 74a178e59..24ebf0a28 100644
--- a/zebra/ipforward_sysctl.c
+++ b/zebra/ipforward_sysctl.c
@@ -24,6 +24,7 @@
#include "privs.h"
#include "zebra/ipforward.h"
+#include "zebra/zebra_errors.h"
#include "log.h"
#include "lib_errors.h"
@@ -42,7 +43,7 @@ int ipforward(void)
len = sizeof ipforwarding;
if (sysctl(mib, MIB_SIZ, &ipforwarding, &len, 0, 0) < 0) {
- zlog_warn("Can't get ipforwarding value");
+ flog_err_sys(LIB_ERR_SYSTEM_CALL, "Can't get ipforwarding value");
return -1;
}
return ipforwarding;
@@ -56,7 +57,8 @@ int ipforward_on(void)
len = sizeof ipforwarding;
frr_elevate_privs(&zserv_privs) {
if (sysctl(mib, MIB_SIZ, NULL, NULL, &ipforwarding, len) < 0) {
- zlog_warn("Can't set ipforwarding on");
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "Can't set ipforwarding on");
return -1;
}
}
@@ -71,7 +73,8 @@ int ipforward_off(void)
len = sizeof ipforwarding;
frr_elevate_privs(&zserv_privs) {
if (sysctl(mib, MIB_SIZ, NULL, NULL, &ipforwarding, len) < 0) {
- zlog_warn("Can't set ipforwarding on");
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "Can't set ipforwarding on");
return -1;
}
}
@@ -95,7 +98,8 @@ int ipforward_ipv6(void)
len = sizeof ip6forwarding;
frr_elevate_privs(&zserv_privs) {
if (sysctl(mib_ipv6, MIB_SIZ, &ip6forwarding, &len, 0, 0) < 0) {
- zlog_warn("can't get ip6forwarding value");
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "can't get ip6forwarding value");
return -1;
}
}
@@ -111,7 +115,8 @@ int ipforward_ipv6_on(void)
frr_elevate_privs(&zserv_privs) {
if (sysctl(mib_ipv6, MIB_SIZ, NULL, NULL, &ip6forwarding, len)
< 0) {
- zlog_warn("can't get ip6forwarding value");
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "can't get ip6forwarding value");
return -1;
}
}
@@ -127,7 +132,8 @@ int ipforward_ipv6_off(void)
frr_elevate_privs(&zserv_privs) {
if (sysctl(mib_ipv6, MIB_SIZ, NULL, NULL, &ip6forwarding, len)
< 0) {
- zlog_warn("can't get ip6forwarding value");
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "can't get ip6forwarding value");
return -1;
}
}
diff --git a/zebra/irdp_interface.c b/zebra/irdp_interface.c
index f02ba1fa2..cda6f0e21 100644
--- a/zebra/irdp_interface.c
+++ b/zebra/irdp_interface.c
@@ -41,12 +41,14 @@
#include "log.h"
#include "zclient.h"
#include "thread.h"
+#include "lib_errors.h"
#include "zebra/interface.h"
#include "zebra/rtadv.h"
#include "zebra/rib.h"
#include "zebra/zserv.h"
#include "zebra/redistribute.h"
#include "zebra/irdp.h"
+#include "zebra/zebra_errors.h"
#include <netinet/ip_icmp.h>
#include "if.h"
#include "sockunion.h"
@@ -124,7 +126,8 @@ static int if_group(struct interface *ifp, int sock, uint32_t group,
p = irdp_get_prefix(ifp);
if (!p) {
- zlog_warn("IRDP: can't get address for %s", ifp->name);
+ flog_warn(ZEBRA_ERR_NO_IFACE_ADDR,
+ "IRDP: can't get address for %s", ifp->name);
return 1;
}
@@ -133,10 +136,10 @@ static int if_group(struct interface *ifp, int sock, uint32_t group,
ret = setsockopt(sock, IPPROTO_IP, add_leave, (char *)&m,
sizeof(struct ip_mreq));
if (ret < 0)
- zlog_warn("IRDP: %s can't setsockopt %s: %s",
- add_leave == IP_ADD_MEMBERSHIP ? "join group"
- : "leave group",
- inet_2a(group, b1), safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "IRDP: %s can't setsockopt %s: %s",
+ add_leave == IP_ADD_MEMBERSHIP ? "join group"
+ : "leave group",
+ inet_2a(group, b1), safe_strerror(errno));
return ret;
}
@@ -215,14 +218,14 @@ static void irdp_if_start(struct interface *ifp, int multicast,
irdp->started = true;
if (irdp->flags & IF_ACTIVE) {
- zlog_warn("IRDP: Interface is already active %s", ifp->name);
+ zlog_debug("IRDP: Interface is already active %s", ifp->name);
return;
}
if ((irdp_sock < 0) && ((irdp_sock = irdp_sock_init()) < 0)) {
- zlog_warn(
- "IRDP: Cannot activate interface %s (cannot create "
- "IRDP socket)",
- ifp->name);
+ flog_warn(ZEBRA_ERR_IRDP_CANNOT_ACTIVATE_IFACE,
+ "IRDP: Cannot activate interface %s (cannot create "
+ "IRDP socket)",
+ ifp->name);
return;
}
irdp->flags |= IF_ACTIVE;
@@ -233,7 +236,8 @@ static void irdp_if_start(struct interface *ifp, int multicast,
if_add_update(ifp);
if (!(ifp->flags & IFF_UP)) {
- zlog_warn("IRDP: Interface is down %s", ifp->name);
+ flog_warn(ZEBRA_ERR_IRDP_IFACE_DOWN,
+ "IRDP: Interface is down %s", ifp->name);
}
/* Shall we cancel if_start if if_add_group fails? */
@@ -242,7 +246,8 @@ static void irdp_if_start(struct interface *ifp, int multicast,
if_add_group(ifp);
if (!(ifp->flags & (IFF_MULTICAST | IFF_ALLMULTI))) {
- zlog_warn("IRDP: Interface not multicast enabled %s",
+ flog_warn(ZEBRA_ERR_IRDP_IFACE_MCAST_DISABLED,
+ "IRDP: Interface not multicast enabled %s",
ifp->name);
}
}
@@ -290,12 +295,12 @@ static void irdp_if_stop(struct interface *ifp)
struct irdp_interface *irdp = zi->irdp;
if (irdp == NULL) {
- zlog_warn("Interface %s structure is NULL", ifp->name);
+ zlog_debug("Interface %s structure is NULL", ifp->name);
return;
}
if (!(irdp->flags & IF_ACTIVE)) {
- zlog_warn("Interface is not active %s", ifp->name);
+ zlog_debug("Interface is not active %s", ifp->name);
return;
}
@@ -319,7 +324,7 @@ static void irdp_if_shutdown(struct interface *ifp)
return;
if (irdp->flags & IF_SHUTDOWN) {
- zlog_warn("IRDP: Interface is already shutdown %s", ifp->name);
+ zlog_debug("IRDP: Interface is already shutdown %s", ifp->name);
return;
}
@@ -341,7 +346,7 @@ static void irdp_if_no_shutdown(struct interface *ifp)
return;
if (!(irdp->flags & IF_SHUTDOWN)) {
- zlog_warn("IRDP: Interface is not shutdown %s", ifp->name);
+ zlog_debug("IRDP: Interface is not shutdown %s", ifp->name);
return;
}
diff --git a/zebra/irdp_main.c b/zebra/irdp_main.c
index 771ae796e..fe7e58e1a 100644
--- a/zebra/irdp_main.c
+++ b/zebra/irdp_main.c
@@ -59,6 +59,7 @@
#include "zebra/zserv.h"
#include "zebra/redistribute.h"
#include "zebra/irdp.h"
+#include "zebra/zebra_errors.h"
#include <netinet/ip_icmp.h>
#include "checksum.h"
@@ -89,24 +90,25 @@ int irdp_sock_init(void)
}
if (sock < 0) {
- zlog_warn("IRDP: can't create irdp socket %s",
- safe_strerror(save_errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "IRDP: can't create irdp socket %s",
+ safe_strerror(save_errno));
return sock;
};
i = 1;
ret = setsockopt(sock, IPPROTO_IP, IP_TTL, (void *)&i, sizeof(i));
if (ret < 0) {
- zlog_warn("IRDP: can't do irdp sockopt %s",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "IRDP: can't do irdp sockopt %s",
+ safe_strerror(errno));
close(sock);
return ret;
};
ret = setsockopt_ifindex(AF_INET, sock, 1);
if (ret < 0) {
- zlog_warn("IRDP: can't do irdp sockopt %s",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "IRDP: can't do irdp sockopt %s",
+ safe_strerror(errno));
close(sock);
return ret;
};
diff --git a/zebra/irdp_packet.c b/zebra/irdp_packet.c
index c36c95897..31351b146 100644
--- a/zebra/irdp_packet.c
+++ b/zebra/irdp_packet.c
@@ -52,6 +52,7 @@
#include "thread.h"
#include "vty.h"
#include "zclient.h"
+#include "lib_errors.h"
#include "zebra_memory.h"
#include "zebra/interface.h"
@@ -122,7 +123,8 @@ static void parse_irdp_packet(char *p, int len, struct interface *ifp)
/* check icmp checksum */
if (in_cksum(icmp, datalen) != icmp->checksum) {
- zlog_warn(
+ flog_warn(
+ ZEBRA_ERR_IRDP_BAD_CHECKSUM,
"IRDP: RX ICMP packet from %s. Bad checksum, silently ignored",
inet_ntoa(src));
return;
@@ -134,10 +136,10 @@ static void parse_irdp_packet(char *p, int len, struct interface *ifp)
return;
if (icmp->code != 0) {
- zlog_warn(
- "IRDP: RX packet type %d from %s. Bad ICMP type code,"
- " silently ignored",
- icmp->type, inet_ntoa(src));
+ flog_warn(ZEBRA_ERR_IRDP_BAD_TYPE_CODE,
+ "IRDP: RX packet type %d from %s. Bad ICMP type code,"
+ " silently ignored",
+ icmp->type, inet_ntoa(src));
return;
}
@@ -145,16 +147,15 @@ static void parse_irdp_packet(char *p, int len, struct interface *ifp)
&& (irdp->flags & IF_BROADCAST))
|| (ntohl(ip->ip_dst.s_addr) == INADDR_ALLRTRS_GROUP
&& !(irdp->flags & IF_BROADCAST))) {
- zlog_warn(
- "IRDP: RX illegal from %s to %s while %s operates in %s\n",
+ flog_warn(
+ ZEBRA_ERR_IRDP_BAD_RX_FLAGS,
+ "IRDP: RX illegal from %s to %s while %s operates in %s; Please correct settings\n",
inet_ntoa(src),
ntohl(ip->ip_dst.s_addr) == INADDR_ALLRTRS_GROUP
? "multicast"
: inet_ntoa(ip->ip_dst),
ifp->name,
irdp->flags & IF_BROADCAST ? "broadcast" : "multicast");
-
- zlog_warn("IRDP: Please correct settings\n");
return;
}
@@ -172,7 +173,8 @@ static void parse_irdp_packet(char *p, int len, struct interface *ifp)
break;
default:
- zlog_warn(
+ flog_warn(
+ ZEBRA_ERR_IRDP_BAD_TYPE,
"IRDP: RX type %d from %s. Bad ICMP type, silently ignored",
icmp->type, inet_ntoa(src));
}
@@ -198,16 +200,18 @@ static int irdp_recvmsg(int sock, uint8_t *buf, int size, int *ifindex)
ret = recvmsg(sock, &msg, 0);
if (ret < 0) {
- zlog_warn("IRDP: recvmsg: read error %s", safe_strerror(errno));
+ flog_warn(LIB_ERR_SOCKET, "IRDP: recvmsg: read error %s",
+ safe_strerror(errno));
return ret;
}
if (msg.msg_flags & MSG_TRUNC) {
- zlog_warn("IRDP: recvmsg: truncated message");
+ flog_warn(LIB_ERR_SOCKET, "IRDP: recvmsg: truncated message");
return ret;
}
if (msg.msg_flags & MSG_CTRUNC) {
- zlog_warn("IRDP: recvmsg: truncated control message");
+ flog_warn(LIB_ERR_SOCKET,
+ "IRDP: recvmsg: truncated control message");
return ret;
}
@@ -232,7 +236,7 @@ int irdp_read_raw(struct thread *r)
ret = irdp_recvmsg(irdp_sock, (uint8_t *)buf, IRDP_RX_BUF, &ifindex);
if (ret < 0)
- zlog_warn("IRDP: RX Error length = %d", ret);
+ flog_warn(LIB_ERR_SOCKET, "IRDP: RX Error length = %d", ret);
ifp = if_lookup_by_index(ifindex, VRF_DEFAULT);
if (!ifp)
@@ -311,7 +315,7 @@ void send_packet(struct interface *ifp, struct stream *s, uint32_t dst,
if (setsockopt(irdp_sock, IPPROTO_IP, IP_HDRINCL, (char *)&on,
sizeof(on))
< 0)
- zlog_warn("sendto %s", safe_strerror(errno));
+ zlog_debug("sendto %s", safe_strerror(errno));
if (dst == INADDR_BROADCAST) {
@@ -319,7 +323,7 @@ void send_packet(struct interface *ifp, struct stream *s, uint32_t dst,
if (setsockopt(irdp_sock, SOL_SOCKET, SO_BROADCAST, (char *)&on,
sizeof(on))
< 0)
- zlog_warn("sendto %s", safe_strerror(errno));
+ zlog_debug("sendto %s", safe_strerror(errno));
}
if (dst != INADDR_BROADCAST)
@@ -351,7 +355,7 @@ void send_packet(struct interface *ifp, struct stream *s, uint32_t dst,
sockopt_iphdrincl_swab_htosys(ip);
if (sendmsg(irdp_sock, msg, 0) < 0) {
- zlog_warn("sendto %s", safe_strerror(errno));
+ zlog_debug("sendto %s", safe_strerror(errno));
}
/* printf("TX on %s idx %d\n", ifp->name, ifp->ifindex); */
}
diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c
index 545b4d9d6..323a6c33f 100644
--- a/zebra/kernel_netlink.c
+++ b/zebra/kernel_netlink.c
@@ -453,8 +453,9 @@ static void netlink_install_filter(int sock, __u32 pid)
if (setsockopt(sock, SOL_SOCKET, SO_ATTACH_FILTER, &prog, sizeof(prog))
< 0)
- zlog_warn("Can't install socket filter: %s\n",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "Can't install socket filter: %s\n",
+ safe_strerror(errno));
}
void netlink_parse_rtattr(struct rtattr **tb, int max, struct rtattr *rta,
@@ -641,8 +642,8 @@ static void netlink_parse_extended_ack(struct nlmsghdr *h)
* but noticing it for later.
*/
err_nlh = &err->msg;
- zlog_warn("%s: Received %d extended Ack",
- __PRETTY_FUNCTION__, err_nlh->nlmsg_type);
+ zlog_debug("%s: Received %d extended Ack",
+ __PRETTY_FUNCTION__, err_nlh->nlmsg_type);
}
}
@@ -652,7 +653,8 @@ static void netlink_parse_extended_ack(struct nlmsghdr *h)
if (is_err)
zlog_err("Extended Error: %s", msg);
else
- zlog_warn("Extended Warning: %s", msg);
+ flog_warn(ZEBRA_ERR_NETLINK_EXTENDED_WARNING,
+ "Extended Warning: %s", msg);
}
}
@@ -890,7 +892,8 @@ int netlink_parse_info(int (*filter)(struct nlmsghdr *, ns_id_t, int),
error = (*filter)(h, zns->ns_id, startup);
if (error < 0) {
- zlog_warn("%s filter function error", nl->name);
+ zlog_debug("%s filter function error",
+ nl->name);
ret = error;
}
}
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c
index 78e25e762..5f4158e35 100644
--- a/zebra/kernel_socket.c
+++ b/zebra/kernel_socket.c
@@ -502,8 +502,8 @@ int ifm_read(struct if_msghdr *ifm)
* RTA_IFP) is required.
*/
if (!ifnlen) {
- zlog_warn("Interface index %d (new) missing ifname\n",
- ifm->ifm_index);
+ zlog_debug("Interface index %d (new) missing ifname\n",
+ ifm->ifm_index);
return -1;
}
@@ -586,7 +586,7 @@ int ifm_read(struct if_msghdr *ifm)
*/
{
if (ifp->ifindex != ifm->ifm_index) {
- zlog_warn(
+ zlog_debug(
"%s: index mismatch, ifname %s, ifp index %d, "
"ifm index %d",
__func__, ifp->name, ifp->ifindex,
@@ -709,7 +709,7 @@ static void ifam_read_mesg(struct ifa_msghdr *ifm, union sockunion *addr,
/* Assert read up end point matches to end point */
if (pnt != end)
- zlog_warn("ifam_read() doesn't read all socket data");
+ zlog_debug("ifam_read() doesn't read all socket data");
}
/* Interface's address information get. */
@@ -728,7 +728,8 @@ int ifam_read(struct ifa_msghdr *ifam)
ifam_read_mesg(ifam, &addr, &mask, &brd, ifname, &ifnlen);
if ((ifp = if_lookup_by_index(ifam->ifam_index, VRF_DEFAULT)) == NULL) {
- zlog_warn("%s: no interface for ifname %s, index %d", __func__,
+ flog_warn(ZEBRA_ERR_UNKNOWN_INTERFACE,
+ "%s: no interface for ifname %s, index %d", __func__,
ifname, ifam->ifam_index);
return -1;
}
@@ -822,10 +823,10 @@ static int rtm_read_mesg(struct rt_msghdr *rtm, union sockunion *dest,
/* rt_msghdr version check. */
if (rtm->rtm_version != RTM_VERSION)
- zlog_warn(
- "Routing message version different %d should be %d."
- "This may cause problem\n",
- rtm->rtm_version, RTM_VERSION);
+ flog_warn(ZEBRA_ERR_RTM_VERSION_MISMATCH,
+ "Routing message version different %d should be %d."
+ "This may cause problem\n",
+ rtm->rtm_version, RTM_VERSION);
/* Be sure structure is cleared */
memset(dest, 0, sizeof(union sockunion));
@@ -860,7 +861,7 @@ static int rtm_read_mesg(struct rt_msghdr *rtm, union sockunion *dest,
/* Assert read up to the end of pointer. */
if (pnt != end)
- zlog_warn("rtm_read() doesn't read all socket data.");
+ zlog_debug("rtm_read() doesn't read all socket data.");
return rtm->rtm_flags;
}
@@ -1182,7 +1183,8 @@ int rtm_write(int message, union sockunion *dest, union sockunion *mask,
if (mask)
inet_ntop(AF_INET, &mask->sin.sin_addr,
mask_buf, INET_ADDRSTRLEN);
- zlog_warn(
+ flog_warn(
+ ZEBRA_ERR_RTM_NO_GATEWAY,
"%s: %s/%s: gate == NULL and no gateway found for ifindex %d",
__func__, dest_buf, mask_buf, index);
return -1;
@@ -1250,8 +1252,8 @@ int rtm_write(int message, union sockunion *dest, union sockunion *mask,
if (errno == ESRCH)
return ZEBRA_ERR_RTNOEXIST;
- zlog_warn("%s: write : %s (%d)", __func__, safe_strerror(errno),
- errno);
+ flog_err_sys(LIB_ERR_SOCKET, "%s: write : %s (%d)", __func__,
+ safe_strerror(errno), errno);
return ZEBRA_ERR_KERNEL;
}
return ZEBRA_ERR_NOERROR;
@@ -1333,8 +1335,8 @@ static int kernel_read(struct thread *thread)
if (nbytes <= 0) {
if (nbytes < 0 && errno != EWOULDBLOCK && errno != EAGAIN)
- zlog_warn("routing socket error: %s",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "routing socket error: %s",
+ safe_strerror(errno));
return 0;
}
@@ -1350,7 +1352,7 @@ static int kernel_read(struct thread *thread)
* can assume they have the whole message.
*/
if (rtm->rtm_msglen != nbytes) {
- zlog_warn(
+ zlog_debug(
"kernel_read: rtm->rtm_msglen %d, nbytes %d, type %d\n",
rtm->rtm_msglen, nbytes, rtm->rtm_type);
return -1;
@@ -1390,7 +1392,8 @@ static void routing_socket(struct zebra_ns *zns)
}
if (routing_sock < 0) {
- zlog_warn("Can't init kernel routing socket");
+ flog_err_sys(LIB_ERR_SOCKET,
+ "Can't init kernel routing socket");
return;
}
diff --git a/zebra/label_manager.c b/zebra/label_manager.c
index e53764c77..793d6cfa1 100644
--- a/zebra/label_manager.c
+++ b/zebra/label_manager.c
@@ -209,7 +209,8 @@ int zread_relay_label_manager_request(int cmd, struct zserv *zserv,
/* check & set client proto if unset */
if (zserv->proto && zserv->proto != proto) {
- zlog_warn("Client proto(%u) != msg proto(%u)", zserv->proto,
+ flog_warn(ZEBRA_WARNING_LM_PROTO_MISMATCH,
+ "Client proto(%u) != msg proto(%u)", zserv->proto,
proto);
return -1;
}
@@ -277,9 +278,7 @@ static int lm_zclient_connect(struct thread *t)
}
/* make socket non-blocking */
- if (set_nonblocking(zclient->sock) < 0)
- zlog_warn("%s: set_nonblocking(%d) failed", __func__,
- zclient->sock);
+ (void)set_nonblocking(zclient->sock);
return 0;
}
diff --git a/zebra/redistribute.c b/zebra/redistribute.c
index 640d58e17..f30255355 100644
--- a/zebra/redistribute.c
+++ b/zebra/redistribute.c
@@ -43,6 +43,7 @@
#include "zebra/zapi_msg.h"
#include "zebra/zebra_memory.h"
#include "zebra/zebra_vxlan.h"
+#include "zebra/zebra_errors.h"
#define ZEBRA_PTM_SUPPORT
@@ -166,7 +167,8 @@ void redistribute_update(const struct prefix *p, const struct prefix *src_p,
afi = family2afi(p->family);
if (!afi) {
- zlog_warn("%s: Unknown AFI/SAFI prefix received\n",
+ flog_warn(ZEBRA_ERR_REDISTRIBUTE_UNKNOWN_AF,
+ "%s: Unknown AFI/SAFI prefix received\n",
__FUNCTION__);
return;
}
@@ -236,7 +238,8 @@ void redistribute_delete(const struct prefix *p, const struct prefix *src_p,
afi = family2afi(p->family);
if (!afi) {
- zlog_warn("%s: Unknown AFI/SAFI prefix received\n",
+ flog_warn(ZEBRA_ERR_REDISTRIBUTE_UNKNOWN_AF,
+ "%s: Unknown AFI/SAFI prefix received\n",
__FUNCTION__);
return;
}
@@ -275,14 +278,15 @@ void zebra_redistribute_add(ZAPI_HANDLER_ARGS)
zebra_route_string(type), zvrf_id(zvrf), instance);
if (afi == 0 || afi >= AFI_MAX) {
- zlog_warn("%s: Specified afi %d does not exist",
+ flog_warn(ZEBRA_ERR_REDISTRIBUTE_UNKNOWN_AF,
+ "%s: Specified afi %d does not exist",
__PRETTY_FUNCTION__, afi);
return;
}
if (type == 0 || type >= ZEBRA_ROUTE_MAX) {
- zlog_warn("%s: Specified Route Type %d does not exist",
- __PRETTY_FUNCTION__, type);
+ zlog_debug("%s: Specified Route Type %d does not exist",
+ __PRETTY_FUNCTION__, type);
return;
}
@@ -321,14 +325,15 @@ void zebra_redistribute_delete(ZAPI_HANDLER_ARGS)
STREAM_GETW(msg, instance);
if (afi == 0 || afi >= AFI_MAX) {
- zlog_warn("%s: Specified afi %d does not exist",
+ flog_warn(ZEBRA_ERR_REDISTRIBUTE_UNKNOWN_AF,
+ "%s: Specified afi %d does not exist",
__PRETTY_FUNCTION__, afi);
return;
}
if (type == 0 || type >= ZEBRA_ROUTE_MAX) {
- zlog_warn("%s: Specified Route Type %d does not exist",
- __PRETTY_FUNCTION__, type);
+ zlog_debug("%s: Specified Route Type %d does not exist",
+ __PRETTY_FUNCTION__, type);
return;
}
@@ -444,7 +449,8 @@ void zebra_interface_address_add_update(struct interface *ifp,
}
if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL))
- zlog_warn(
+ flog_warn(
+ ZEBRA_ERR_ADVERTISING_UNUSABLE_ADDR,
"WARNING: advertising address to clients that is not yet usable.");
zebra_vxlan_add_del_gw_macip(ifp, ifc->address, 1);
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index 56d5d1ce5..70bd8a784 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -64,6 +64,7 @@
#include "zebra/rt_netlink.h"
#include "zebra/zebra_mroute.h"
#include "zebra/zebra_vxlan.h"
+#include "zebra/zebra_errors.h"
#ifndef AF_MPLS
#define AF_MPLS 28
@@ -156,8 +157,9 @@ static inline int zebra2proto(int proto)
* is intentionally a warn because we should see
* this as part of development of a new protocol
*/
- zlog_warn("%s: Please add this protocol(%d) to proper rt_netlink.c handling",
- __PRETTY_FUNCTION__, proto);
+ zlog_debug(
+ "%s: Please add this protocol(%d) to proper rt_netlink.c handling",
+ __PRETTY_FUNCTION__, proto);
proto = RTPROT_ZEBRA;
break;
}
@@ -216,9 +218,9 @@ static inline int proto2zebra(int proto, int family)
* is intentionally a warn because we should see
* this as part of development of a new protocol
*/
- zlog_warn("%s: Please add this protocol(%d) to proper rt_netlink.c handling",
- __PRETTY_FUNCTION__,
- proto);
+ zlog_debug(
+ "%s: Please add this protocol(%d) to proper rt_netlink.c handling",
+ __PRETTY_FUNCTION__, proto);
proto = ZEBRA_ROUTE_KERNEL;
break;
}
@@ -432,8 +434,10 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
if (rtm->rtm_src_len != 0) {
char buf[PREFIX_STRLEN];
- zlog_warn("unsupported IPv4 sourcedest route (dest %s vrf %u)",
- prefix2str(&p, buf, sizeof(buf)), vrf_id);
+ flog_warn(
+ ZEBRA_ERR_UNSUPPORTED_V4_SRCDEST,
+ "unsupported IPv4 sourcedest route (dest %s vrf %u)",
+ prefix2str(&p, buf, sizeof(buf)), vrf_id);
return 0;
}
@@ -600,7 +604,8 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
if (ifp)
nh_vrf_id = ifp->vrf_id;
else {
- zlog_warn(
+ flog_warn(
+ ZEBRA_ERR_UNKNOWN_INTERFACE,
"%s: Unknown interface %u specified, defaulting to VRF_DEFAULT",
__PRETTY_FUNCTION__,
index);
@@ -823,12 +828,13 @@ int netlink_route_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
if (!(h->nlmsg_type == RTM_NEWROUTE || h->nlmsg_type == RTM_DELROUTE)) {
/* If this is not route add/delete message print warning. */
- zlog_warn("Kernel message: %d NS %u\n", h->nlmsg_type, ns_id);
+ zlog_debug("Kernel message: %d NS %u\n", h->nlmsg_type, ns_id);
return 0;
}
if (!(rtm->rtm_family == AF_INET || rtm->rtm_family == AF_INET6)) {
- zlog_warn(
+ flog_warn(
+ ZEBRA_ERR_UNKNOWN_FAMILY,
"Invalid address family: %u received from kernel route change: %u",
rtm->rtm_family, h->nlmsg_type);
return 0;
@@ -1957,10 +1963,10 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
zif = (struct zebra_if *)ifp->info;
if ((br_if = zif->brslave_info.br_if) == NULL) {
- zlog_warn("%s family %s IF %s(%u) brIF %u - no bridge master",
- nl_msg_type_to_str(h->nlmsg_type),
- nl_family_to_str(ndm->ndm_family), ifp->name,
- ndm->ndm_ifindex, zif->brslave_info.bridge_ifindex);
+ zlog_debug("%s family %s IF %s(%u) brIF %u - no bridge master",
+ nl_msg_type_to_str(h->nlmsg_type),
+ nl_family_to_str(ndm->ndm_family), ifp->name,
+ ndm->ndm_ifindex, zif->brslave_info.bridge_ifindex);
return 0;
}
@@ -1969,15 +1975,15 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
netlink_parse_rtattr(tb, NDA_MAX, NDA_RTA(ndm), len);
if (!tb[NDA_LLADDR]) {
- zlog_warn("%s family %s IF %s(%u) brIF %u - no LLADDR",
- nl_msg_type_to_str(h->nlmsg_type),
- nl_family_to_str(ndm->ndm_family), ifp->name,
- ndm->ndm_ifindex, zif->brslave_info.bridge_ifindex);
+ zlog_debug("%s family %s IF %s(%u) brIF %u - no LLADDR",
+ nl_msg_type_to_str(h->nlmsg_type),
+ nl_family_to_str(ndm->ndm_family), ifp->name,
+ ndm->ndm_ifindex, zif->brslave_info.bridge_ifindex);
return 0;
}
if (RTA_PAYLOAD(tb[NDA_LLADDR]) != ETH_ALEN) {
- zlog_warn(
+ zlog_debug(
"%s family %s IF %s(%u) brIF %u - LLADDR is not MAC, len %lu",
nl_msg_type_to_str(h->nlmsg_type),
nl_family_to_str(ndm->ndm_family), ifp->name,
@@ -2173,9 +2179,9 @@ static int netlink_macfdb_update(struct interface *ifp, vlanid_t vid,
zns = zvrf->zns;
zif = ifp->info;
if ((br_if = zif->brslave_info.br_if) == NULL) {
- zlog_warn("MAC %s on IF %s(%u) - no mapping to bridge",
- (cmd == RTM_NEWNEIGH) ? "add" : "del", ifp->name,
- ifp->ifindex);
+ zlog_debug("MAC %s on IF %s(%u) - no mapping to bridge",
+ (cmd == RTM_NEWNEIGH) ? "add" : "del", ifp->name,
+ ifp->ifindex);
return -1;
}
@@ -2258,10 +2264,10 @@ static int netlink_ipneigh_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
netlink_parse_rtattr(tb, NDA_MAX, NDA_RTA(ndm), len);
if (!tb[NDA_DST]) {
- zlog_warn("%s family %s IF %s(%u) - no DST",
- nl_msg_type_to_str(h->nlmsg_type),
- nl_family_to_str(ndm->ndm_family), ifp->name,
- ndm->ndm_ifindex);
+ zlog_debug("%s family %s IF %s(%u) - no DST",
+ nl_msg_type_to_str(h->nlmsg_type),
+ nl_family_to_str(ndm->ndm_family), ifp->name,
+ ndm->ndm_ifindex);
return 0;
}
@@ -2317,7 +2323,7 @@ static int netlink_ipneigh_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
if (h->nlmsg_type == RTM_NEWNEIGH) {
if (tb[NDA_LLADDR]) {
if (RTA_PAYLOAD(tb[NDA_LLADDR]) != ETH_ALEN) {
- zlog_warn(
+ zlog_debug(
"%s family %s IF %s(%u) - LLADDR is not MAC, len %lu",
nl_msg_type_to_str(h->nlmsg_type),
nl_family_to_str(ndm->ndm_family),
@@ -2479,7 +2485,8 @@ int netlink_neigh_change(struct nlmsghdr *h, ns_id_t ns_id)
if (ndm->ndm_family == AF_INET || ndm->ndm_family == AF_INET6)
return netlink_ipneigh_change(h, len, ns_id);
else {
- zlog_warn(
+ flog_warn(
+ ZEBRA_ERR_UNKNOWN_FAMILY,
"Invalid address family: %u received from kernel neighbor change: %u",
ndm->ndm_family, h->nlmsg_type);
return 0;
diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c
index c0ad87ce3..2ee450dd9 100644
--- a/zebra/rt_socket.c
+++ b/zebra/rt_socket.c
@@ -40,6 +40,7 @@
#include "zebra/rt.h"
#include "zebra/kernel_socket.h"
#include "zebra/zebra_mpls.h"
+#include "zebra/zebra_errors.h"
extern struct zebra_privs_t zserv_privs;
@@ -72,10 +73,10 @@ static int kernel_rtm_add_labels(struct mpls_label_stack *nh_label,
struct sockaddr_mpls *smpls)
{
if (nh_label->num_labels > 1) {
- zlog_warn(
- "%s: can't push %u labels at "
- "once (maximum is 1)",
- __func__, nh_label->num_labels);
+ flog_warn(ZEBRA_ERR_MAX_LABELS_PUSH,
+ "%s: can't push %u labels at "
+ "once (maximum is 1)",
+ __func__, nh_label->num_labels);
return -1;
}
@@ -399,7 +400,8 @@ enum dp_req_result kernel_route_rib(struct route_node *rn,
int route = 0;
if (src_p && src_p->prefixlen) {
- zlog_warn("%s: IPv6 sourcedest routes unsupported!", __func__);
+ flog_warn(ZEBRA_ERR_UNSUPPORTED_V6_SRCDEST,
+ "%s: IPv6 sourcedest routes unsupported!", __func__);
return DP_REQUEST_FAILURE;
}
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index 43dfca10e..696190492 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -44,6 +44,7 @@
#include "zebra/zapi_msg.h"
#include "zebra/zebra_ns.h"
#include "zebra/zebra_vrf.h"
+#include "zebra/zebra_errors.h"
extern struct zebra_privs_t zserv_privs;
@@ -181,7 +182,7 @@ static void rtadv_send_packet(int sock, struct interface *ifp)
adata = calloc(1, CMSG_SPACE(sizeof(struct in6_pktinfo)));
if (adata == NULL) {
- zlog_warn(
+ zlog_debug(
"rtadv_send_packet: can't malloc control data");
exit(-1);
}
@@ -468,12 +469,12 @@ static void rtadv_process_advert(uint8_t *msg, unsigned int len,
inet_ntop(AF_INET6, &addr->sin6_addr, addr_str, INET6_ADDRSTRLEN);
if (len < sizeof(struct nd_router_advert)) {
- zlog_warn("%s(%u): Rx RA with invalid length %d from %s",
- ifp->name, ifp->ifindex, len, addr_str);
+ zlog_debug("%s(%u): Rx RA with invalid length %d from %s",
+ ifp->name, ifp->ifindex, len, addr_str);
return;
}
if (!IN6_IS_ADDR_LINKLOCAL(&addr->sin6_addr)) {
- zlog_warn(
+ zlog_debug(
"%s(%u): Rx RA with non-linklocal source address from %s",
ifp->name, ifp->ifindex, addr_str);
return;
@@ -483,21 +484,24 @@ static void rtadv_process_advert(uint8_t *msg, unsigned int len,
if ((radvert->nd_ra_curhoplimit && zif->rtadv.AdvCurHopLimit)
&& (radvert->nd_ra_curhoplimit != zif->rtadv.AdvCurHopLimit)) {
- zlog_warn(
+ flog_warn(
+ ZEBRA_ERR_RA_PARAM_MISMATCH,
"%s(%u): Rx RA - our AdvCurHopLimit doesn't agree with %s",
ifp->name, ifp->ifindex, addr_str);
}
if ((radvert->nd_ra_flags_reserved & ND_RA_FLAG_MANAGED)
&& !zif->rtadv.AdvManagedFlag) {
- zlog_warn(
+ flog_warn(
+ ZEBRA_ERR_RA_PARAM_MISMATCH,
"%s(%u): Rx RA - our AdvManagedFlag doesn't agree with %s",
ifp->name, ifp->ifindex, addr_str);
}
if ((radvert->nd_ra_flags_reserved & ND_RA_FLAG_OTHER)
&& !zif->rtadv.AdvOtherConfigFlag) {
- zlog_warn(
+ flog_warn(
+ ZEBRA_ERR_RA_PARAM_MISMATCH,
"%s(%u): Rx RA - our AdvOtherConfigFlag doesn't agree with %s",
ifp->name, ifp->ifindex, addr_str);
}
@@ -505,7 +509,8 @@ static void rtadv_process_advert(uint8_t *msg, unsigned int len,
if ((radvert->nd_ra_reachable && zif->rtadv.AdvReachableTime)
&& (ntohl(radvert->nd_ra_reachable)
!= zif->rtadv.AdvReachableTime)) {
- zlog_warn(
+ flog_warn(
+ ZEBRA_ERR_RA_PARAM_MISMATCH,
"%s(%u): Rx RA - our AdvReachableTime doesn't agree with %s",
ifp->name, ifp->ifindex, addr_str);
}
@@ -513,7 +518,8 @@ static void rtadv_process_advert(uint8_t *msg, unsigned int len,
if ((radvert->nd_ra_retransmit && zif->rtadv.AdvRetransTimer)
&& (ntohl(radvert->nd_ra_retransmit)
!= (unsigned int)zif->rtadv.AdvRetransTimer)) {
- zlog_warn(
+ flog_warn(
+ ZEBRA_ERR_RA_PARAM_MISMATCH,
"%s(%u): Rx RA - our AdvRetransTimer doesn't agree with %s",
ifp->name, ifp->ifindex, addr_str);
}
@@ -543,7 +549,8 @@ static void rtadv_process_packet(uint8_t *buf, unsigned int len,
/* Interface search. */
ifp = if_lookup_by_index_per_ns(zns, ifindex);
if (ifp == NULL) {
- zlog_warn("RA/RS received on unknown IF %u from %s", ifindex,
+ flog_warn(ZEBRA_ERR_UNKNOWN_INTERFACE,
+ "RA/RS received on unknown IF %u from %s", ifindex,
addr_str);
return;
}
@@ -563,8 +570,8 @@ static void rtadv_process_packet(uint8_t *buf, unsigned int len,
/* ICMP message length check. */
if (len < sizeof(struct icmp6_hdr)) {
- zlog_warn("%s(%u): Rx RA with Invalid ICMPV6 packet length %d",
- ifp->name, ifp->ifindex, len);
+ zlog_debug("%s(%u): Rx RA with Invalid ICMPV6 packet length %d",
+ ifp->name, ifp->ifindex, len);
return;
}
@@ -573,15 +580,15 @@ static void rtadv_process_packet(uint8_t *buf, unsigned int len,
/* ICMP message type check. */
if (icmph->icmp6_type != ND_ROUTER_SOLICIT
&& icmph->icmp6_type != ND_ROUTER_ADVERT) {
- zlog_warn("%s(%u): Rx RA - Unwanted ICMPV6 message type %d",
- ifp->name, ifp->ifindex, icmph->icmp6_type);
+ zlog_debug("%s(%u): Rx RA - Unwanted ICMPV6 message type %d",
+ ifp->name, ifp->ifindex, icmph->icmp6_type);
return;
}
/* Hoplimit check. */
if (hoplimit >= 0 && hoplimit != 255) {
- zlog_warn("%s(%u): Rx RA - Invalid hoplimit %d", ifp->name,
- ifp->ifindex, hoplimit);
+ zlog_debug("%s(%u): Rx RA - Invalid hoplimit %d", ifp->name,
+ ifp->ifindex, hoplimit);
return;
}
@@ -614,8 +621,9 @@ static int rtadv_read(struct thread *thread)
&hoplimit);
if (len < 0) {
- zlog_warn("RA/RS recv failed, socket %u error %s", sock,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "RA/RS recv failed, socket %u error %s", sock,
+ safe_strerror(errno));
return len;
}
@@ -822,15 +830,17 @@ static void zebra_interface_radv_set(ZAPI_HANDLER_ARGS, int enable)
/* Locate interface and check VRF match. */
ifp = if_lookup_by_index_per_ns(zebra_ns_lookup(NS_DEFAULT), ifindex);
if (!ifp) {
- zlog_warn("%u: IF %u RA %s client %s - interface unknown",
+ flog_warn(ZEBRA_ERR_UNKNOWN_INTERFACE,
+ "%u: IF %u RA %s client %s - interface unknown",
zvrf_id(zvrf), ifindex, enable ? "enable" : "disable",
zebra_route_string(client->proto));
return;
}
if (ifp->vrf_id != zvrf_id(zvrf)) {
- zlog_warn("%u: IF %u RA %s client %s - VRF mismatch, IF VRF %u",
- zvrf_id(zvrf), ifindex, enable ? "enable" : "disable",
- zebra_route_string(client->proto), ifp->vrf_id);
+ zlog_debug(
+ "%u: IF %u RA %s client %s - VRF mismatch, IF VRF %u",
+ zvrf_id(zvrf), ifindex, enable ? "enable" : "disable",
+ zebra_route_string(client->proto), ifp->vrf_id);
return;
}
@@ -1757,8 +1767,10 @@ static int if_join_all_router(int sock, struct interface *ifp)
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, (char *)&mreq,
sizeof mreq);
if (ret < 0)
- zlog_warn("%s(%u): Failed to join group, socket %u error %s",
- ifp->name, ifp->ifindex, sock, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "%s(%u): Failed to join group, socket %u error %s",
+ ifp->name, ifp->ifindex, sock,
+ safe_strerror(errno));
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug(
@@ -1781,8 +1793,10 @@ static int if_leave_all_router(int sock, struct interface *ifp)
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_LEAVE_GROUP, (char *)&mreq,
sizeof mreq);
if (ret < 0)
- zlog_warn("%s(%u): Failed to leave group, socket %u error %s",
- ifp->name, ifp->ifindex, sock, safe_strerror(errno));
+ flog_err_sys(
+ LIB_ERR_SOCKET,
+ "%s(%u): Failed to leave group, socket %u error %s",
+ ifp->name, ifp->ifindex, sock, safe_strerror(errno));
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug(
diff --git a/zebra/rtread_getmsg.c b/zebra/rtread_getmsg.c
index 8e5d7fbdb..40982639c 100644
--- a/zebra/rtread_getmsg.c
+++ b/zebra/rtread_getmsg.c
@@ -28,10 +28,12 @@
#include "if.h"
#include "vrf.h"
#include "vty.h"
+#include "lib_errors.h"
#include "zebra/rib.h"
#include "zebra/rt.h"
#include "zebra/zebra_pbr.h"
+#include "zebra/zebra_errors.h"
/* Thank you, Solaris, for polluting application symbol namespace. */
#undef hook_register
@@ -119,8 +121,8 @@ void route_read(struct zebra_ns *zns)
int flags, dev, retval, process;
if ((dev = open(_PATH_GETMSG_ROUTE, O_RDWR)) == -1) {
- zlog_warn("can't open %s: %s", _PATH_GETMSG_ROUTE,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL, "can't open %s: %s",
+ _PATH_GETMSG_ROUTE, safe_strerror(errno));
return;
}
@@ -141,7 +143,8 @@ void route_read(struct zebra_ns *zns)
flags = 0;
if (putmsg(dev, &msgdata, NULL, flags) == -1) {
- zlog_warn("putmsg failed: %s", safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "putmsg failed: %s",
+ safe_strerror(errno));
goto exit;
}
@@ -153,8 +156,9 @@ void route_read(struct zebra_ns *zns)
retval = getmsg(dev, &msgdata, NULL, &flags);
if (retval == -1) {
- zlog_warn("getmsg(ctl) failed: %s",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "getmsg(ctl) failed: %s",
+ safe_strerror(errno));
goto exit;
}
@@ -167,10 +171,10 @@ void route_read(struct zebra_ns *zns)
if ((size_t)msgdata.len >= sizeof(struct T_error_ack)
&& TLIerr->PRIM_type == T_ERROR_ACK) {
- zlog_warn("getmsg(ctl) returned T_ERROR_ACK: %s",
- safe_strerror((TLIerr->TLI_error == TSYSERR)
- ? TLIerr->UNIX_error
- : EPROTO));
+ zlog_debug("getmsg(ctl) returned T_ERROR_ACK: %s",
+ safe_strerror((TLIerr->TLI_error == TSYSERR)
+ ? TLIerr->UNIX_error
+ : EPROTO));
break;
}
@@ -182,7 +186,7 @@ void route_read(struct zebra_ns *zns)
|| TLIack->PRIM_type != T_OPTMGMT_ACK
|| TLIack->MGMT_flags != T_SUCCESS) {
errno = ENOMSG;
- zlog_warn("getmsg(ctl) returned bizarreness");
+ zlog_debug("getmsg(ctl) returned bizarreness");
break;
}
@@ -211,20 +215,21 @@ void route_read(struct zebra_ns *zns)
retval = getmsg(dev, NULL, &msgdata, &flags);
if (retval == -1) {
- zlog_warn("getmsg(data) failed: %s",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "getmsg(data) failed: %s",
+ safe_strerror(errno));
goto exit;
}
if (!(retval == 0 || retval == MOREDATA)) {
- zlog_warn("getmsg(data) returned %d", retval);
+ zlog_debug("getmsg(data) returned %d", retval);
goto exit;
}
if (process) {
if (msgdata.len % sizeof(mib2_ipRouteEntry_t)
!= 0) {
- zlog_warn(
+ zlog_debug(
"getmsg(data) returned "
"msgdata.len = %d (%% sizeof (mib2_ipRouteEntry_t) != 0)",
msgdata.len);
diff --git a/zebra/rtread_sysctl.c b/zebra/rtread_sysctl.c
index fba67e3d0..5f6b62df2 100644
--- a/zebra/rtread_sysctl.c
+++ b/zebra/rtread_sysctl.c
@@ -31,6 +31,7 @@
#include "zebra/rt.h"
#include "zebra/kernel_socket.h"
#include "zebra/zebra_pbr.h"
+#include "zebra/zebra_errors.h"
/* Kernel routing table read up by sysctl function. */
void route_read(struct zebra_ns *zns)
@@ -47,7 +48,8 @@ void route_read(struct zebra_ns *zns)
/* Get buffer size. */
if (sysctl(mib, MIBSIZ, NULL, &bufsiz, NULL, 0) < 0) {
- zlog_warn("sysctl fail: %s", safe_strerror(errno));
+ flog_warn(ZEBRA_ERR_SYSCTL_FAILED, "sysctl fail: %s",
+ safe_strerror(errno));
return;
}
@@ -56,7 +58,8 @@ void route_read(struct zebra_ns *zns)
/* Read routing table information by calling sysctl(). */
if (sysctl(mib, MIBSIZ, buf, &bufsiz, NULL, 0) < 0) {
- zlog_warn("sysctl() fail by %s", safe_strerror(errno));
+ flog_warn(ZEBRA_ERR_SYSCTL_FAILED, "sysctl() fail by %s",
+ safe_strerror(errno));
XFREE(MTYPE_TMP, ref);
return;
}
diff --git a/zebra/rule_netlink.c b/zebra/rule_netlink.c
index 87d3769a5..4244a9af8 100644
--- a/zebra/rule_netlink.c
+++ b/zebra/rule_netlink.c
@@ -40,6 +40,7 @@
#include "zebra/kernel_netlink.h"
#include "zebra/rule_netlink.h"
#include "zebra/zebra_pbr.h"
+#include "zebra/zebra_errors.h"
/* definitions */
@@ -205,7 +206,8 @@ int netlink_rule_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
frh = NLMSG_DATA(h);
if (frh->family != AF_INET && frh->family != AF_INET6) {
- zlog_warn(
+ flog_warn(
+ ZEBRA_ERR_NETLINK_INVALID_AF,
"Invalid address family: %u received from kernel rule change: %u",
frh->family, h->nlmsg_type);
return 0;
diff --git a/zebra/rule_socket.c b/zebra/rule_socket.c
index 620410de0..8faca1bbc 100644
--- a/zebra/rule_socket.c
+++ b/zebra/rule_socket.c
@@ -41,6 +41,7 @@
#include "zebra/kernel_netlink.h"
#include "zebra/rule_netlink.h"
#include "zebra/zebra_pbr.h"
+#include "zebra/zebra_errors.h"
enum dp_req_result kernel_add_pbr_rule(struct zebra_pbr_rule *rule)
{
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index d95f78109..e4fbb7362 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -62,6 +62,7 @@
#include "zebra/zebra_pbr.h"
#include "zebra/table_manager.h"
#include "zebra/zapi_msg.h"
+#include "zebra/zebra_errors.h"
/* Encoding helpers -------------------------------------------------------- */
@@ -1042,7 +1043,7 @@ static void zread_rnh_register(ZAPI_HANDLER_ARGS)
l += 4;
if (p.family == AF_INET) {
if (p.prefixlen > IPV4_MAX_BITLEN) {
- zlog_warn(
+ zlog_debug(
"%s: Specified prefix hdr->length %d is too large for a v4 address",
__PRETTY_FUNCTION__, p.prefixlen);
return;
@@ -1051,7 +1052,7 @@ static void zread_rnh_register(ZAPI_HANDLER_ARGS)
l += IPV4_MAX_BYTELEN;
} else if (p.family == AF_INET6) {
if (p.prefixlen > IPV6_MAX_BITLEN) {
- zlog_warn(
+ zlog_debug(
"%s: Specified prefix hdr->length %d is to large for a v6 address",
__PRETTY_FUNCTION__, p.prefixlen);
return;
@@ -1126,7 +1127,7 @@ static void zread_rnh_unregister(ZAPI_HANDLER_ARGS)
l += 4;
if (p.family == AF_INET) {
if (p.prefixlen > IPV4_MAX_BITLEN) {
- zlog_warn(
+ zlog_debug(
"%s: Specified prefix hdr->length %d is to large for a v4 address",
__PRETTY_FUNCTION__, p.prefixlen);
return;
@@ -1135,7 +1136,7 @@ static void zread_rnh_unregister(ZAPI_HANDLER_ARGS)
l += IPV4_MAX_BYTELEN;
} else if (p.family == AF_INET6) {
if (p.prefixlen > IPV6_MAX_BITLEN) {
- zlog_warn(
+ zlog_debug(
"%s: Specified prefix hdr->length %d is to large for a v6 address",
__PRETTY_FUNCTION__, p.prefixlen);
return;
@@ -1202,7 +1203,7 @@ static void zread_fec_register(ZAPI_HANDLER_ARGS)
if ((p.family == AF_INET && p.prefixlen > IPV4_MAX_BITLEN)
|| (p.family == AF_INET6
&& p.prefixlen > IPV6_MAX_BITLEN)) {
- zlog_warn(
+ zlog_debug(
"%s: Specified prefix hdr->length: %d is to long for %d",
__PRETTY_FUNCTION__, p.prefixlen, p.family);
return;
@@ -1265,7 +1266,7 @@ static void zread_fec_unregister(ZAPI_HANDLER_ARGS)
if ((p.family == AF_INET && p.prefixlen > IPV4_MAX_BITLEN)
|| (p.family == AF_INET6
&& p.prefixlen > IPV6_MAX_BITLEN)) {
- zlog_warn(
+ zlog_debug(
"%s: Received prefix hdr->length %d which is greater than %d can support",
__PRETTY_FUNCTION__, p.prefixlen, p.family);
return;
@@ -1318,7 +1319,8 @@ void zserv_nexthop_num_warn(const char *caller, const struct prefix *p,
char buff[PREFIX2STR_BUFFER];
prefix2str(p, buff, sizeof(buff));
- zlog_warn(
+ flog_warn(
+ ZEBRA_ERR_MORE_NH_THAN_MULTIPATH,
"%s: Prefix %s has %d nexthops, but we can only use the first %d",
caller, buff, nexthop_num, multipath_num);
}
@@ -1481,7 +1483,8 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
}
if (!nexthop) {
- zlog_warn(
+ flog_warn(
+ ZEBRA_ERR_NEXTHOP_CREATION_FAILED,
"%s: Nexthops Specified: %d but we failed to properly create one",
__PRETTY_FUNCTION__, api.nexthop_num);
nexthops_free(re->ng.nexthop);
@@ -1521,7 +1524,8 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
afi = family2afi(api.prefix.family);
if (afi != AFI_IP6 && CHECK_FLAG(api.message, ZAPI_MESSAGE_SRCPFX)) {
- zlog_warn("%s: Received SRC Prefix but afi is not v6",
+ flog_warn(ZEBRA_ERR_RX_SRCDEST_WRONG_AFI,
+ "%s: Received SRC Prefix but afi is not v6",
__PRETTY_FUNCTION__);
nexthops_free(re->ng.nexthop);
XFREE(MTYPE_RE, re);
@@ -1563,7 +1567,8 @@ static void zread_route_del(ZAPI_HANDLER_ARGS)
afi = family2afi(api.prefix.family);
if (afi != AFI_IP6 && CHECK_FLAG(api.message, ZAPI_MESSAGE_SRCPFX)) {
- zlog_warn("%s: Received a src prefix while afi is not v6",
+ flog_warn(ZEBRA_ERR_RX_SRCDEST_WRONG_AFI,
+ "%s: Received a src prefix while afi is not v6",
__PRETTY_FUNCTION__);
return;
}
@@ -1703,7 +1708,7 @@ static void zread_mpls_labels(ZAPI_HANDLER_ARGS)
STREAM_GET(&prefix.u.prefix4.s_addr, s, IPV4_MAX_BYTELEN);
STREAM_GETC(s, prefix.prefixlen);
if (prefix.prefixlen > IPV4_MAX_BITLEN) {
- zlog_warn(
+ zlog_debug(
"%s: Specified prefix length %d is greater than a v4 address can support",
__PRETTY_FUNCTION__, prefix.prefixlen);
return;
@@ -1714,7 +1719,7 @@ static void zread_mpls_labels(ZAPI_HANDLER_ARGS)
STREAM_GET(&prefix.u.prefix6, s, 16);
STREAM_GETC(s, prefix.prefixlen);
if (prefix.prefixlen > IPV6_MAX_BITLEN) {
- zlog_warn(
+ zlog_debug(
"%s: Specified prefix length %d is greater than a v6 address can support",
__PRETTY_FUNCTION__, prefix.prefixlen);
return;
@@ -1722,8 +1727,8 @@ static void zread_mpls_labels(ZAPI_HANDLER_ARGS)
STREAM_GET(&gate.ipv6, s, 16);
break;
default:
- zlog_warn("%s: Specified AF %d is not supported for this call",
- __PRETTY_FUNCTION__, prefix.family);
+ zlog_debug("%s: Specified AF %d is not supported for this call",
+ __PRETTY_FUNCTION__, prefix.family);
return;
}
STREAM_GETL(s, ifindex);
@@ -2077,7 +2082,8 @@ static void zread_pseudowire(ZAPI_HANDLER_ARGS)
switch (hdr->command) {
case ZEBRA_PW_ADD:
if (pw) {
- zlog_warn("%s: pseudowire %s already exists [%s]",
+ flog_warn(ZEBRA_ERR_PSEUDOWIRE_EXISTS,
+ "%s: pseudowire %s already exists [%s]",
__func__, ifname,
zserv_command_string(hdr->command));
return;
@@ -2087,7 +2093,8 @@ static void zread_pseudowire(ZAPI_HANDLER_ARGS)
break;
case ZEBRA_PW_DELETE:
if (!pw) {
- zlog_warn("%s: pseudowire %s not found [%s]", __func__,
+ flog_warn(ZEBRA_ERR_PSEUDOWIRE_NONEXISTENT,
+ "%s: pseudowire %s not found [%s]", __func__,
ifname, zserv_command_string(hdr->command));
return;
}
@@ -2097,7 +2104,8 @@ static void zread_pseudowire(ZAPI_HANDLER_ARGS)
case ZEBRA_PW_SET:
case ZEBRA_PW_UNSET:
if (!pw) {
- zlog_warn("%s: pseudowire %s not found [%s]", __func__,
+ flog_warn(ZEBRA_ERR_PSEUDOWIRE_NONEXISTENT,
+ "%s: pseudowire %s not found [%s]", __func__,
ifname, zserv_command_string(hdr->command));
return;
}
@@ -2509,8 +2517,8 @@ void zserv_handle_commands(struct zserv *client, struct stream *msg)
zvrf = zebra_vrf_lookup_by_id(hdr.vrf_id);
if (!zvrf) {
if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV)
- zlog_warn("ZAPI message specifies unknown VRF: %d",
- hdr.vrf_id);
+ zlog_debug("ZAPI message specifies unknown VRF: %d",
+ hdr.vrf_id);
return;
}
diff --git a/zebra/zebra_errors.c b/zebra/zebra_errors.c
index 198e1cce2..79d9caf11 100644
--- a/zebra/zebra_errors.c
+++ b/zebra/zebra_errors.c
@@ -110,6 +110,12 @@ static struct log_ref ferr_zebra_err[] = {
.suggestion = "Check all configuration parameters for correctness.",
},
{
+ .code = ZEBRA_ERR_DP_DELETE_FAIL,
+ .title = "Dataplane deletion failure",
+ .description = "Deletion of routes from underlying dataplane failed.",
+ .suggestion = "Check all configuration parameters for correctness.",
+ },
+ {
.code = ZEBRA_ERR_TABLE_LOOKUP_FAILED,
.title = "Zebra table lookup failed",
.description = "Zebra attempted to look up a table for a particular address family and subsequent address family, but didn't find anything.",
@@ -266,6 +272,429 @@ static struct log_ref ferr_zebra_err[] = {
.suggestion = "Notify a developer.",
},
{
+ .code = ZEBRA_ERR_NS_NOTIFY_READ,
+ .title = "Zebra failed to read namespace inotify information",
+ .description = "Zebra received an event from inotify, but failed to read what it was.",
+ .suggestion = "Notify a developer.",
+ },
+ /* Warnings */
+ {
+ .code = ZEBRA_WARNING_LM_PROTO_MISMATCH,
+ .title =
+ "Zebra label manager received malformed label request",
+ .description =
+ "Zebra's label manager received a label request from a client whose protocol type does not match the protocol field received in the message.",
+ .suggestion =
+ "This is a bug. Please report it.",
+ },
+ {
+ .code = ZEBRA_ERR_LSP_INSTALL_FAILURE,
+ .title =
+ "Zebra failed to install LSP into the kernel",
+ .description =
+ "Zebra made an attempt to install a label switched path, but the kernel indicated that the installation was not successful.",
+ .suggestion =
+ "Wait for Zebra to reattempt installation.",
+ },
+ {
+ .code = ZEBRA_ERR_LSP_DELETE_FAILURE,
+ .title =
+ "Zebra failed to remove LSP from the kernel",
+ .description =
+ "Zebra made an attempt to remove a label switched path, but the kernel indicated that the deletion was not successful.",
+ .suggestion =
+ "Wait for Zebra to reattempt deletion.",
+ },
+ {
+ .code = ZEBRA_ERR_MPLS_SUPPORT_DISABLED,
+ .title =
+ "Zebra will not run with MPLS support",
+ .description =
+ "Zebra noticed that the running kernel does not support MPLS, so it disabled MPLS support.",
+ .suggestion =
+ "If you want MPLS support, upgrade the kernel to a version that provides MPLS support.",
+ },
+ {
+ .code = ZEBRA_ERR_SYSCTL_FAILED,
+ .title = "A call to sysctl() failed",
+ .description =
+ "sysctl() returned a nonzero exit code, indicating an error.",
+ .suggestion =
+ "The log message should contain further details on the specific error that occurred; investigate the reported error.",
+ },
+ {
+ .code = ZEBRA_ERR_NS_VRF_CREATION_FAILED,
+ .title =
+ "Zebra failed to create namespace VRF",
+ .description =
+ "Zebra failed to create namespace VRF",
+ .suggestion = "",
+ },
+ {
+ .code = ZEBRA_ERR_NS_DELETION_FAILED_NO_VRF,
+ .title =
+ "Zebra attempted to delete nonexistent namespace",
+ .description =
+ "Zebra attempted to delete a particular namespace, but no VRF associated with that namespace could be found to delete.",
+ .suggestion = "Please report this bug.",
+ },
+ {
+ .code = ZEBRA_ERR_IFLIST_FAILED,
+ .title =
+ "Zebra interface listing failed",
+ .description =
+ "Zebra encountered an error attempting to query sysctl for a list of interfaces on the system.",
+ .suggestion =
+ "Check that Zebra is running with the appropriate permissions. If it is, please report this as a bug.",
+ },
+ {
+ .code = ZEBRA_ERR_IRDP_BAD_CHECKSUM,
+ .title =
+ "Zebra received ICMP packet with invalid checksum",
+ .description =
+ "Zebra received an ICMP packet with a bad checksum and has silently ignored it.",
+ .suggestion =
+ "If the problem continues to occur, investigate the source of the bad ICMP packets.",
+ },
+ {
+ .code = ZEBRA_ERR_IRDP_BAD_TYPE_CODE,
+ .title =
+ "Zebra received ICMP packet with bad type code",
+ .description =
+ "Zebra received an ICMP packet with a bad code for the message type and has silently ignored it.",
+ .suggestion =
+ "If the problem continues to occur, investigate the source of the bad ICMP packets.",
+ },
+ {
+ .code = ZEBRA_ERR_IRDP_BAD_RX_FLAGS,
+ .title =
+ "Zebra received IRDP packet while operating in wrong mode",
+ .description =
+ "Zebra received a multicast IRDP packet while operating in unicast mode, or vice versa.",
+ .suggestion =
+ "If you wish to receive the messages, change your IRDP settings accordingly.",
+ },
+ {
+ .code = ZEBRA_ERR_IRDP_BAD_TYPE,
+ .title =
+ "Zebra received IRDP packet with bad type",
+ .description =
+ "THIS IS BULLSHIT REMOVE ME",
+ .suggestion = "asdf",
+ },
+ {
+ .code = ZEBRA_ERR_RNH_NO_TABLE,
+ .title =
+ "Zebra could not find table for next hop",
+ .description =
+ "Zebra attempted to add a next hop but could not find the appropriate table to install it in.",
+ .suggestion = "Please report this bug.",
+ },
+ {
+ .code = ZEBRA_ERR_FPM_FORMAT_UNKNOWN,
+ .title =
+ "Unknown message format for Zebra's FPM module",
+ .description =
+ "Zebra's FPM module takes an argument which specifies the message format to use, but the format was either not provided or was not a valid format. The FPM interface will be disabled.",
+ .suggestion =
+ "Provide or correct the module argument to provide a valid format. See documentation for further information.",
+ },
+ {
+ .code = ZEBRA_ERR_CLIENT_IO_ERROR,
+ .title =
+ "Zebra client connection failed",
+ .description =
+ "A Zebra client encountered an I/O error and is shutting down. This can occur under normal circumstances, such as when FRR is restarting or shutting down; it can also happen if the daemon crashed. Usually this warning can be ignored.",
+ .suggestion =
+ "Ignore this warning, it is mostly informational.",
+ },
+ {
+ .code = ZEBRA_ERR_CLIENT_WRITE_FAILED,
+ .title =
+ "Zebra failed to send message to client",
+ .description =
+ "Zebra attempted to send a message to one of its clients, but the write operation failed. The connection will be closed.",
+ .suggestion =
+ "Ignore this warning, it is mostly informational.",
+ },
+ {
+ .code = ZEBRA_ERR_NETLINK_INVALID_AF,
+ .title =
+ "Zebra received Netlink message with invalid family",
+ .description =
+ "Zebra received a Netlink message with an invalid address family.",
+ .suggestion =
+ "Inspect the logged address family and submit it with a bug report.",
+ },
+ {
+ .code = ZEBRA_ERR_REMOVE_ADDR_UNKNOWN_SUBNET,
+ .title =
+ "Zebra tried to remove address from unknown subnet",
+ .description =
+ "Zebra attempted to remove an address from an unknown subnet.",
+ .suggestion =
+ "This is a bug, please report it.",
+ },
+ {
+ .code = ZEBRA_ERR_REMOVE_UNREGISTERED_ADDR,
+ .title =
+ "Zebra tried to remove unregistered address",
+ .description =
+ "Zebra attempted to remove an address from a subnet it was not registered on.",
+ .suggestion =
+ "This is a bug, please report it.",
+ },
+ {
+ .code = ZEBRA_ERR_PTM_NOT_READY,
+ .title =
+ "Interface is up but PTM check has not completed",
+ .description =
+ "Zebra noticed that an interface came up and attempted to perform its usual setup procedures, but the PTM check failed and the operation was aborted.",
+ .suggestion =
+ "If the problem persists, ensure that the interface is actually up and that PTM is functioning properly.",
+ },
+ {
+ .code = ZEBRA_ERR_UNSUPPORTED_V4_SRCDEST,
+ .title =
+ "Kernel rejected sourcedest route",
+ .description =
+ "Zebra attempted to install a sourcedest route into the kernel, but the kernel did not acknowledge its installation. The route is unsupported.",
+ .suggestion =
+ "Check configuration values for correctness",
+ },
+ {
+ .code = ZEBRA_ERR_UNKNOWN_INTERFACE,
+ .title =
+ "Zebra encountered an unknown interface specifier",
+ .description =
+ "Zebra was asked to look up an interface with a given name or index, but could not find the interface corresponding to the given name or index.",
+ .suggestion =
+ "Check configuration values for correctness.",
+ },
+ {
+ .code = ZEBRA_ERR_VRF_NOT_FOUND,
+ .title =
+ "Zebra could not find the specified VRF",
+ .description =
+ "Zebra tried to look up a VRF, either by name or ID, and could not find it. This could be due to internal inconsistency (a bug) or a configuration error.",
+ .suggestion =
+ "Check configuration values for correctness. If values are correct, please file a bug report.",
+ },
+ {
+ .code = ZEBRA_ERR_MORE_NH_THAN_MULTIPATH,
+ .title =
+ "More nexthops were provided than the configured multipath limit",
+ .description =
+ "A route with multiple nexthops was given, but the number of nexthops exceeded the configured multipath limit.",
+ .suggestion =
+ "Reduce the number of nexthops, or increase the multipath limit.",
+ },
+ {
+ .code = ZEBRA_ERR_NEXTHOP_CREATION_FAILED,
+ .title =
+ "Zebra failed to create one or more nexthops",
+ .description =
+ "While attempting to create nexthops for a route installation operation, Zebra found that it was unable to create one or more of the given nexthops.",
+ .suggestion =
+ "Check configuration values for correctness. If they are correct, report this as a bug.",
+ },
+ {
+ .code = ZEBRA_ERR_RX_SRCDEST_WRONG_AFI,
+ .title =
+ "Zebra received sourcedest route install without IPv6 address family",
+ .description =
+ "Zebra received a message from a client requesting a sourcedest route installation, but the address family was not set to IPv6. Only IPv6 is supported for sourcedest routing.",
+ .suggestion =
+ "This is a bug; please report it.",
+ },
+ {
+ .code = ZEBRA_ERR_PSEUDOWIRE_EXISTS,
+ .title =
+ "Zebra received an installation / creation request for a pseudowire that already exists",
+ .description =
+ "Zebra received an installation or creation request for a pseudowire that already exists, so the installation / creation has been skipped.",
+ .suggestion =
+ "This message is informational.",
+ },
+ {
+ .code = ZEBRA_ERR_PSEUDOWIRE_NONEXISTENT,
+ .title =
+ "Zebra received an uninstallation / deletion request for a pseudowire that already exists",
+ .description =
+ "Zebra received an uninstallation / deletion request for a pseudowire that doesn't exist, so the uninstallation / deletion has been skipped.",
+ .suggestion =
+ "This message is informational.",
+ },
+ {
+ .code = ZEBRA_ERR_PSEUDOWIRE_UNINSTALL_NOT_FOUND,
+ .title =
+ "Zebra received uninstall request for a pseudowire that doesn't exist",
+ .description =
+ "Zebra received an uninstall request for a pseudowire that doesn't exist, so the uninstallation has been skipped.",
+ .suggestion =
+ "This message is informational.",
+ },
+ {
+ .code = ZEBRA_ERR_NO_IFACE_ADDR,
+ .title = "No address on interface",
+ .description =
+ "Zebra attempted to retrieve a connected address for an interface, but the interface had no connected addresses.",
+ .suggestion =
+ "This warning is situational; it is usually informative but can indicate a misconfiguration.",
+ },
+ {
+ .code = ZEBRA_ERR_IFACE_ADDR_ADD_FAILED,
+ .title =
+ "Zebra failed to add address to interface",
+ .description =
+ "Zebra attempted to add an address to an interface but was unsuccessful.",
+ .suggestion =
+ "Check configuration values for correctness.",
+ },
+ {
+ .code = ZEBRA_ERR_IRDP_CANNOT_ACTIVATE_IFACE,
+ .title =
+ "Zebra could not enable IRDP on interface",
+ .description =
+ "Zebra attempted to enable IRDP on an interface, but could not create the IRDP socket. The system may be out of socket resources, or privilege elevation may have failed.",
+ .suggestion =
+ "Verify that Zebra has the appropriate privileges and that the system has sufficient socket resources.",
+ },
+ {
+ .code = ZEBRA_ERR_IRDP_IFACE_DOWN,
+ .title =
+ "Zebra attempted to enable IRDP on an interface, but the interface was down",
+ .description = "Zebra attempted to enable IRDP on an interface, but the interface was down.",
+ .suggestion =
+ "Bring up the interface that IRDP is desired on.",
+ },
+ {
+ .code = ZEBRA_ERR_IRDP_IFACE_MCAST_DISABLED,
+ .title =
+ "Zebra cannot enable IRDP on interface because multicast is disabled",
+ .description =
+ "Zebra attempted to enable IRDP on an interface, but multicast functionality was not enabled on the interface.",
+ .suggestion =
+ "Enable multicast on the interface.",
+ },
+ {
+ .code = ZEBRA_ERR_NETLINK_EXTENDED_WARNING,
+ .title =
+ "Zebra received warning message from Netlink",
+ .description =
+ "Zebra received a warning message from Netlink",
+ .suggestion =
+ "This message is informational. See the Netlink error message for details.",
+ },
+ {
+ .code = ZEBRA_ERR_NAMESPACE_DIR_INACCESSIBLE,
+ .title =
+ "Zebra could not access /var/run/netns",
+ .description =
+ "Zebra tried to verify that the run directory for Linux network namespaces existed, but this test failed.",
+ .suggestion =
+ "Ensure that Zebra has the proper privileges to access this directory.",
+ },
+ {
+ .code = ZEBRA_ERR_CONNECTED_AFI_UNKNOWN,
+ .title =
+ "Zebra received unknown address family on interface",
+ .description =
+ "Zebra received a notification of a connected prefix on an interface but did not recognize the address family as IPv4 or IPv6",
+ .suggestion =
+ "This message is informational.",
+ },
+ {
+ .code = ZEBRA_ERR_IFACE_SAME_LOCAL_AS_PEER,
+ .title =
+ "Zebra route has same destination address as local interface",
+ .description =
+ "Zebra noticed that a route on an interface has the same destination address as an address on the interface itself, which may cause issues with routing protocols.",
+ .suggestion =
+ "Investigate the source of the route to determine why the destination and interface addresses are the same.",
+ },
+ {
+ .code = ZEBRA_ERR_BCAST_ADDR_MISMATCH,
+ .title =
+ "Zebra broadcast address sanity check failed",
+ .description =
+ "Zebra computed the broadcast address for a connected prefix based on the netmask and found that it did not match the broadcast address it received for the prefix on that interface",
+ .suggestion =
+ "Investigate the source of the broadcast address to determine why it does not match the computed address.",
+ },
+ {
+ .code = ZEBRA_ERR_REDISTRIBUTE_UNKNOWN_AF,
+ .title =
+ "Zebra encountered unknown address family during redistribution",
+ .description =
+ "During a redistribution operation Zebra encountered an unknown address family.",
+ .suggestion =
+ "This warning can be ignored; the redistribution operation will skip the unknown address family.",
+ },
+ {
+ .code = ZEBRA_ERR_ADVERTISING_UNUSABLE_ADDR,
+ .title =
+ "Zebra advertising unusable interface address",
+ .description =
+ "Zebra is advertising an address on an interface that is not yet fully installed on the interface.",
+ .suggestion =
+ "This message is informational. The address should show up on the interface shortly after advertisement.",
+ },
+ {
+ .code = ZEBRA_ERR_RA_PARAM_MISMATCH,
+ .title =
+ "Zebra received route advertisement with parameter mismatch",
+ .description =
+ "Zebra received a router advertisement, but one of the non-critical parameters (AdvCurHopLimit, AdvManagedFlag, AdvOtherConfigFlag, AdvReachableTime or AdvRetransTimer) does not match Zebra's local settings.",
+ .suggestion =
+ "This message is informational; the route advertisement will be processed as normal. If issues arise due to the parameter mismatch, check Zebra's router advertisement configuration.",
+ },
+ {
+ .code = ZEBRA_ERR_RTM_VERSION_MISMATCH,
+ .title =
+ "Zebra received kernel message with uknown version",
+ .description =
+ "Zebra received a message from the kernel with a message version that does not match Zebra's internal version. Depending on version compatibility, this may cause issues sending and receiving messages to the kernel.",
+ .suggestion =
+ "If issues arise, check if there is a version of FRR available for your kernel version.",
+ },
+ {
+ .code = ZEBRA_ERR_RTM_NO_GATEWAY,
+ .title =
+ "Zebra could not determine proper gateway for kernel route",
+ .description =
+ "Zebra attempted to install a route into the kernel, but noticed it had no gateway and no interface with a gateway could be located.",
+ .suggestion =
+ "Check configuration values for correctness.",
+ },
+ {
+ .code = ZEBRA_ERR_MAX_LABELS_PUSH,
+ .title =
+ "Zebra exceeded maximum LSP labels for a single rtmsg",
+ .description =
+ "Zebra attempted to push more than one label into the kernel; the maximum on OpenBSD is 1 label.",
+ .suggestion =
+ "This message is informational.",
+ },
+ {
+ .code = ZEBRA_ERR_STICKY_MAC_ALREADY_LEARNT,
+ .title =
+ "EVPN MAC already learnt as remote sticky MAC",
+ .description =
+ "Zebra tried to handle a local MAC addition but noticed that it had already learnt the MAC from a remote peer.",
+ .suggestion =
+ "Check configuration values for correctness.",
+ },
+ {
+ .code = ZEBRA_ERR_UNSUPPORTED_V6_SRCDEST,
+ .title =
+ "Kernel does not support IPv6 sourcedest routes",
+ .description =
+ "Zebra attempted to install a sourcedest route into the kernel, but IPv6 sourcedest routes are not supported on the current kernel.",
+ .suggestion =
+ "Do not use v6 sourcedest routes, or upgrade your kernel.",
+ },
+ {
.code = END_FERR,
}
};
diff --git a/zebra/zebra_errors.h b/zebra/zebra_errors.h
index f8a00bce0..650f74871 100644
--- a/zebra/zebra_errors.h
+++ b/zebra/zebra_errors.h
@@ -41,6 +41,7 @@ enum zebra_log_refs {
ZEBRA_ERR_IRDP_LEN_MISMATCH,
ZEBRA_ERR_RNH_UNKNOWN_FAMILY,
ZEBRA_ERR_DP_INSTALL_FAIL,
+ ZEBRA_ERR_DP_DELETE_FAIL,
ZEBRA_ERR_TABLE_LOOKUP_FAILED,
ZEBRA_ERR_NETLINK_NOT_AVAILABLE,
ZEBRA_ERR_PROTOBUF_NOT_AVAILABLE,
@@ -66,6 +67,56 @@ enum zebra_log_refs {
ZEBRA_ERR_VNI_DEL_FAILED,
ZEBRA_ERR_VTEP_ADD_FAILED,
ZEBRA_ERR_VNI_ADD_FAILED,
+ /* warnings */
+ ZEBRA_ERR_NS_NOTIFY_READ,
+ ZEBRA_WARNING_LM_PROTO_MISMATCH,
+ ZEBRA_ERR_LSP_INSTALL_FAILURE,
+ ZEBRA_ERR_LSP_DELETE_FAILURE,
+ ZEBRA_ERR_MPLS_SUPPORT_DISABLED,
+ ZEBRA_ERR_SYSCTL_FAILED,
+ ZEBRA_ERR_CONVERT_TO_DEBUG,
+ ZEBRA_ERR_NS_VRF_CREATION_FAILED,
+ ZEBRA_ERR_NS_DELETION_FAILED_NO_VRF,
+ ZEBRA_ERR_IRDP_BAD_CHECKSUM,
+ ZEBRA_ERR_IRDP_BAD_TYPE_CODE,
+ ZEBRA_ERR_IRDP_BAD_RX_FLAGS,
+ ZEBRA_ERR_IRDP_BAD_TYPE,
+ ZEBRA_ERR_RNH_NO_TABLE,
+ ZEBRA_ERR_IFLIST_FAILED,
+ ZEBRA_ERR_FPM_FORMAT_UNKNOWN,
+ ZEBRA_ERR_CLIENT_IO_ERROR,
+ ZEBRA_ERR_CLIENT_WRITE_FAILED,
+ ZEBRA_ERR_NETLINK_INVALID_AF,
+ ZEBRA_ERR_REMOVE_ADDR_UNKNOWN_SUBNET,
+ ZEBRA_ERR_REMOVE_UNREGISTERED_ADDR,
+ ZEBRA_ERR_PTM_NOT_READY,
+ ZEBRA_ERR_UNSUPPORTED_V4_SRCDEST,
+ ZEBRA_ERR_UNKNOWN_INTERFACE,
+ ZEBRA_ERR_VRF_NOT_FOUND,
+ ZEBRA_ERR_MORE_NH_THAN_MULTIPATH,
+ ZEBRA_ERR_NEXTHOP_CREATION_FAILED,
+ ZEBRA_ERR_RX_SRCDEST_WRONG_AFI,
+ ZEBRA_ERR_PSEUDOWIRE_EXISTS,
+ ZEBRA_ERR_PSEUDOWIRE_UNINSTALL_NOT_FOUND,
+ ZEBRA_ERR_PSEUDOWIRE_NONEXISTENT,
+ ZEBRA_ERR_NO_IFACE_ADDR,
+ ZEBRA_ERR_IFACE_ADDR_ADD_FAILED,
+ ZEBRA_ERR_IRDP_CANNOT_ACTIVATE_IFACE,
+ ZEBRA_ERR_IRDP_IFACE_DOWN,
+ ZEBRA_ERR_IRDP_IFACE_MCAST_DISABLED,
+ ZEBRA_ERR_NETLINK_EXTENDED_WARNING,
+ ZEBRA_ERR_NAMESPACE_DIR_INACCESSIBLE,
+ ZEBRA_ERR_CONNECTED_AFI_UNKNOWN,
+ ZEBRA_ERR_IFACE_SAME_LOCAL_AS_PEER,
+ ZEBRA_ERR_BCAST_ADDR_MISMATCH,
+ ZEBRA_ERR_REDISTRIBUTE_UNKNOWN_AF,
+ ZEBRA_ERR_ADVERTISING_UNUSABLE_ADDR,
+ ZEBRA_ERR_RA_PARAM_MISMATCH,
+ ZEBRA_ERR_RTM_VERSION_MISMATCH,
+ ZEBRA_ERR_RTM_NO_GATEWAY,
+ ZEBRA_ERR_MAX_LABELS_PUSH,
+ ZEBRA_ERR_STICKY_MAC_ALREADY_LEARNT,
+ ZEBRA_ERR_UNSUPPORTED_V6_SRCDEST,
};
void zebra_error_init(void);
diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c
index 1cb14abbf..dae37cbd3 100644
--- a/zebra/zebra_fpm.c
+++ b/zebra/zebra_fpm.c
@@ -1538,7 +1538,8 @@ static inline void zfpm_init_message_format(const char *format)
return;
}
- zlog_warn("Unknown fpm format '%s'", format);
+ flog_warn(ZEBRA_ERR_FPM_FORMAT_UNKNOWN, "Unknown fpm format '%s'",
+ format);
}
/**
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c
index 8f48cc519..9a76408bb 100644
--- a/zebra/zebra_mpls.c
+++ b/zebra/zebra_mpls.c
@@ -1728,7 +1728,8 @@ void kernel_lsp_pass_fail(zebra_lsp_t *lsp, enum dp_results res)
case DP_INSTALL_FAILURE:
UNSET_FLAG(lsp->flags, LSP_FLAG_INSTALLED);
clear_nhlfe_installed(lsp);
- zlog_warn("LSP Install Failure: %u", lsp->ile.in_label);
+ flog_warn(ZEBRA_ERR_LSP_INSTALL_FAILURE,
+ "LSP Install Failure: %u", lsp->ile.in_label);
break;
case DP_INSTALL_SUCCESS:
SET_FLAG(lsp->flags, LSP_FLAG_INSTALLED);
@@ -1746,7 +1747,8 @@ void kernel_lsp_pass_fail(zebra_lsp_t *lsp, enum dp_results res)
clear_nhlfe_installed(lsp);
break;
case DP_DELETE_FAILURE:
- zlog_warn("LSP Deletion Failure: %u", lsp->ile.in_label);
+ flog_warn(ZEBRA_ERR_LSP_DELETE_FAILURE,
+ "LSP Deletion Failure: %u", lsp->ile.in_label);
break;
}
}
@@ -2945,7 +2947,8 @@ void zebra_mpls_init(void)
mpls_enabled = 0;
if (mpls_kernel_init() < 0) {
- zlog_warn("Disabling MPLS support (no kernel support)");
+ flog_warn(ZEBRA_ERR_MPLS_SUPPORT_DISABLED,
+ "Disabling MPLS support (no kernel support)");
return;
}
diff --git a/zebra/zebra_mpls_openbsd.c b/zebra/zebra_mpls_openbsd.c
index 542de27e8..b42cf3243 100644
--- a/zebra/zebra_mpls_openbsd.c
+++ b/zebra/zebra_mpls_openbsd.c
@@ -26,6 +26,7 @@
#include "zebra/rt.h"
#include "zebra/zebra_mpls.h"
#include "zebra/debug.h"
+#include "zebra/zebra_errors.h"
#include "privs.h"
#include "prefix.h"
@@ -256,11 +257,11 @@ static int kernel_lsp_cmd(int action, zebra_lsp_t *lsp)
&& (CHECK_FLAG(nhlfe->flags, NHLFE_FLAG_INSTALLED)
&& CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)))) {
if (nhlfe->nexthop->nh_label->num_labels > 1) {
- zlog_warn(
- "%s: can't push %u labels at once "
- "(maximum is 1)",
- __func__,
- nhlfe->nexthop->nh_label->num_labels);
+ flog_warn(ZEBRA_ERR_MAX_LABELS_PUSH,
+ "%s: can't push %u labels at once "
+ "(maximum is 1)",
+ __func__,
+ nhlfe->nexthop->nh_label->num_labels);
continue;
}
@@ -359,8 +360,8 @@ static int kmpw_install(struct zebra_pw *pw)
imr.imr_type = IMR_TYPE_ETHERNET_TAGGED;
break;
default:
- zlog_warn("%s: unhandled pseudowire type (%#X)", __func__,
- pw->type);
+ zlog_debug("%s: unhandled pseudowire type (%#X)", __func__,
+ pw->type);
return -1;
}
@@ -381,8 +382,8 @@ static int kmpw_install(struct zebra_pw *pw)
sa_in6->sin6_addr = pw->nexthop.ipv6;
break;
default:
- zlog_warn("%s: unhandled pseudowire address-family (%u)",
- __func__, pw->af);
+ zlog_debug("%s: unhandled pseudowire address-family (%u)",
+ __func__, pw->af);
return -1;
}
memcpy(&imr.imr_nexthop, (struct sockaddr *)&ss,
@@ -430,13 +431,13 @@ int mpls_kernel_init(void)
socklen_t optlen;
if ((kr_state.fd = socket(AF_ROUTE, SOCK_RAW, 0)) == -1) {
- zlog_warn("%s: socket", __func__);
+ flog_err_sys(LIB_ERR_SOCKET, "%s: socket", __func__);
return -1;
}
if ((kr_state.ioctl_fd = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, 0))
== -1) {
- zlog_warn("%s: ioctl socket", __func__);
+ flog_err_sys(LIB_ERR_SOCKET, "%s: ioctl socket", __func__);
return -1;
}
@@ -445,7 +446,8 @@ int mpls_kernel_init(void)
if (getsockopt(kr_state.fd, SOL_SOCKET, SO_RCVBUF, &default_rcvbuf,
&optlen)
== -1)
- zlog_warn("kr_init getsockopt SOL_SOCKET SO_RCVBUF");
+ flog_err_sys(LIB_ERR_SOCKET,
+ "kr_init getsockopt SOL_SOCKET SO_RCVBUF");
else
for (rcvbuf = MAX_RTSOCK_BUF;
rcvbuf > default_rcvbuf
diff --git a/zebra/zebra_netns_id.c b/zebra/zebra_netns_id.c
index a3278c478..9921ce017 100644
--- a/zebra/zebra_netns_id.c
+++ b/zebra/zebra_netns_id.c
@@ -269,7 +269,7 @@ ns_id_t zebra_ns_id_get(const char *netnspath)
close(sock);
close(fd);
if (errno == ENOTSUP) {
- zlog_warn("NEWNSID locally generated");
+ zlog_debug("NEWNSID locally generated");
return zebra_ns_id_get_fallback(netnspath);
}
return NS_UNKNOWN;
@@ -337,7 +337,8 @@ static void zebra_ns_create_netns_directory(void)
/* S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH */
if (mkdir(NS_RUN_DIR, 0755)) {
if (errno != EEXIST) {
- zlog_warn("NS check: failed to access %s", NS_RUN_DIR);
+ flog_warn(ZEBRA_ERR_NAMESPACE_DIR_INACCESSIBLE,
+ "NS check: failed to access %s", NS_RUN_DIR);
return;
}
}
diff --git a/zebra/zebra_netns_notify.c b/zebra/zebra_netns_notify.c
index 12207805d..be36dc96b 100644
--- a/zebra/zebra_netns_notify.c
+++ b/zebra/zebra_netns_notify.c
@@ -42,6 +42,7 @@
#include "zebra_netns_notify.h"
#include "zebra_netns_id.h"
+#include "zebra_errors.h"
#ifdef HAVE_NETLINK
@@ -85,13 +86,14 @@ static void zebra_ns_notify_create_context_from_entry_name(const char *name)
/* if VRF with NS ID already present */
vrf = vrf_lookup_by_id((vrf_id_t)ns_id_external);
if (vrf) {
- zlog_warn(
+ zlog_debug(
"NS notify : same NSID used by VRF %s. Ignore NS %s creation",
vrf->name, netnspath);
return;
}
if (vrf_handler_create(NULL, name, &vrf) != CMD_SUCCESS) {
- zlog_warn("NS notify : failed to create VRF %s", name);
+ flog_warn(ZEBRA_ERR_NS_VRF_CREATION_FAILED,
+ "NS notify : failed to create VRF %s", name);
ns_map_nsid_with_external(ns_id, false);
return;
}
@@ -100,7 +102,8 @@ static void zebra_ns_notify_create_context_from_entry_name(const char *name)
ns_id_external, ns_id);
}
if (ret != CMD_SUCCESS) {
- zlog_warn("NS notify : failed to create NS %s", netnspath);
+ flog_warn(ZEBRA_ERR_NS_VRF_CREATION_FAILED,
+ "NS notify : failed to create NS %s", netnspath);
ns_map_nsid_with_external(ns_id, false);
vrf_delete(vrf);
return;
@@ -130,9 +133,8 @@ static int zebra_ns_delete(char *name)
struct ns *ns;
if (!vrf) {
- zlog_warn(
- "NS notify : no VRF found using NS %s",
- name);
+ flog_warn(ZEBRA_ERR_NS_DELETION_FAILED_NO_VRF,
+ "NS notify : no VRF found using NS %s", name);
return 0;
}
/* Clear configured flag and invoke delete. */
@@ -237,8 +239,9 @@ static int zebra_ns_notify_read(struct thread *t)
zebrad.master, zebra_ns_notify_read, NULL, fd_monitor, NULL);
len = read(fd_monitor, buf, sizeof(buf));
if (len < 0) {
- zlog_warn("NS notify read: failed to read (%s)",
- safe_strerror(errno));
+ flog_err_sys(ZEBRA_ERR_NS_NOTIFY_READ,
+ "NS notify read: failed to read (%s)",
+ safe_strerror(errno));
return 0;
}
for (event = (struct inotify_event *)buf; (char *)event < &buf[len];
@@ -254,12 +257,14 @@ static int zebra_ns_notify_read(struct thread *t)
if (offsetof(struct inotify_event, name) + event->len
>= sizeof(buf)) {
- zlog_err("NS notify read: buffer underflow");
+ flog_err(ZEBRA_ERR_NS_NOTIFY_READ,
+ "NS notify read: buffer underflow");
break;
}
if (strnlen(event->name, event->len) == event->len) {
- zlog_err("NS notify error: bad event name");
+ flog_err(ZEBRA_ERR_NS_NOTIFY_READ,
+ "NS notify error: bad event name");
break;
}
@@ -283,7 +288,8 @@ void zebra_ns_notify_parse(void)
DIR *srcdir = opendir(NS_RUN_DIR);
if (srcdir == NULL) {
- zlog_warn("NS parsing init: failed to parse %s", NS_RUN_DIR);
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "NS parsing init: failed to parse %s", NS_RUN_DIR);
return;
}
while ((dent = readdir(srcdir)) != NULL) {
@@ -293,13 +299,15 @@ void zebra_ns_notify_parse(void)
|| strcmp(dent->d_name, "..") == 0)
continue;
if (fstatat(dirfd(srcdir), dent->d_name, &st, 0) < 0) {
- zlog_warn("NS parsing init: failed to parse entry %s",
- dent->d_name);
+ flog_err_sys(
+ LIB_ERR_SYSTEM_CALL,
+ "NS parsing init: failed to parse entry %s",
+ dent->d_name);
continue;
}
if (S_ISDIR(st.st_mode)) {
- zlog_warn("NS parsing init: %s is not a NS",
- dent->d_name);
+ zlog_debug("NS parsing init: %s is not a NS",
+ dent->d_name);
continue;
}
if (zebra_ns_notify_is_default_netns(dent->d_name)) {
@@ -321,13 +329,16 @@ void zebra_ns_notify_init(void)
zebra_netns_notify_current = NULL;
fd_monitor = inotify_init();
if (fd_monitor < 0) {
- zlog_warn("NS notify init: failed to initialize inotify (%s)",
- safe_strerror(errno));
+ flog_err_sys(
+ LIB_ERR_SYSTEM_CALL,
+ "NS notify init: failed to initialize inotify (%s)",
+ safe_strerror(errno));
}
if (inotify_add_watch(fd_monitor, NS_RUN_DIR,
IN_CREATE | IN_DELETE) < 0) {
- zlog_warn("NS notify watch: failed to add watch (%s)",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "NS notify watch: failed to add watch (%s)",
+ safe_strerror(errno));
}
zebra_netns_notify_current = thread_add_read(
zebrad.master, zebra_ns_notify_read, NULL, fd_monitor, NULL);
diff --git a/zebra/zebra_ns.c b/zebra/zebra_ns.c
index 456253cc3..aedb7c949 100644
--- a/zebra/zebra_ns.c
+++ b/zebra/zebra_ns.c
@@ -26,7 +26,6 @@
#include "lib/logicalrouter.h"
#include "lib/prefix.h"
#include "lib/memory.h"
-#include "lib/lib_errors.h"
#include "rtadv.h"
#include "zebra_ns.h"
diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c
index e2217a5d2..275e045d4 100644
--- a/zebra/zebra_pbr.c
+++ b/zebra/zebra_pbr.c
@@ -464,8 +464,8 @@ void zebra_pbr_del_rule(struct zebra_ns *zns, struct zebra_pbr_rule *rule)
hash_release(zns->rules_hash, lookup);
XFREE(MTYPE_TMP, lookup);
} else
- zlog_warn("%s: Rule being deleted we know nothing about",
- __PRETTY_FUNCTION__);
+ zlog_debug("%s: Rule being deleted we know nothing about",
+ __PRETTY_FUNCTION__);
}
static void zebra_pbr_cleanup_rules(struct hash_backet *b, void *data)
@@ -581,8 +581,9 @@ void zebra_pbr_destroy_ipset(struct zebra_ns *zns,
hash_release(zns->ipset_hash, lookup);
XFREE(MTYPE_TMP, lookup);
} else
- zlog_warn("%s: IPSet Entry being deleted we know nothing about",
- __PRETTY_FUNCTION__);
+ zlog_debug(
+ "%s: IPSet Entry being deleted we know nothing about",
+ __PRETTY_FUNCTION__);
}
struct pbr_ipset_name_lookup {
@@ -665,8 +666,8 @@ void zebra_pbr_del_ipset_entry(struct zebra_ns *zns,
hash_release(zns->ipset_entry_hash, lookup);
XFREE(MTYPE_TMP, lookup);
} else
- zlog_warn("%s: IPSet being deleted we know nothing about",
- __PRETTY_FUNCTION__);
+ zlog_debug("%s: IPSet being deleted we know nothing about",
+ __PRETTY_FUNCTION__);
}
static void *pbr_iptable_alloc_intern(void *arg)
@@ -716,8 +717,8 @@ void zebra_pbr_del_iptable(struct zebra_ns *zns,
}
XFREE(MTYPE_TMP, lookup);
} else
- zlog_warn("%s: IPTable being deleted we know nothing about",
- __PRETTY_FUNCTION__);
+ zlog_debug("%s: IPTable being deleted we know nothing about",
+ __PRETTY_FUNCTION__);
}
/*
diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c
index 39cb073b7..7f9b70b0a 100644
--- a/zebra/zebra_ptm.c
+++ b/zebra/zebra_ptm.c
@@ -34,6 +34,7 @@
#include "version.h"
#include "vrf.h"
#include "vty.h"
+#include "lib_errors.h"
#include "zebra/debug.h"
#include "zebra/interface.h"
@@ -116,13 +117,13 @@ void zebra_ptm_init(void)
ptm_cb.out_data = calloc(1, ZEBRA_PTM_SEND_MAX_SOCKBUF);
if (!ptm_cb.out_data) {
- zlog_warn("%s: Allocation of send data failed", __func__);
+ zlog_debug("%s: Allocation of send data failed", __func__);
return;
}
ptm_cb.in_data = calloc(1, ZEBRA_PTM_MAX_SOCKBUF);
if (!ptm_cb.in_data) {
- zlog_warn("%s: Allocation of recv data failed", __func__);
+ zlog_debug("%s: Allocation of recv data failed", __func__);
free(ptm_cb.out_data);
return;
}
@@ -180,8 +181,8 @@ static int zebra_ptm_flush_messages(struct thread *thread)
switch (buffer_flush_available(ptm_cb.wb, ptm_cb.ptm_sock)) {
case BUFFER_ERROR:
- zlog_warn("%s ptm socket error: %s", __func__,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "%s ptm socket error: %s",
+ __func__, safe_strerror(errno));
close(ptm_cb.ptm_sock);
ptm_cb.ptm_sock = -1;
zebra_ptm_reset_status(0);
@@ -206,8 +207,8 @@ static int zebra_ptm_send_message(char *data, int size)
errno = 0;
switch (buffer_write(ptm_cb.wb, ptm_cb.ptm_sock, data, size)) {
case BUFFER_ERROR:
- zlog_warn("%s ptm socket error: %s", __func__,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "%s ptm socket error: %s",
+ __func__, safe_strerror(errno));
close(ptm_cb.ptm_sock);
ptm_cb.ptm_sock = -1;
zebra_ptm_reset_status(0);
@@ -608,7 +609,8 @@ static int zebra_ptm_handle_msg_cb(void *arg, void *in_ctxt)
ifp = if_lookup_by_name_all_vrf(port_str);
if (!ifp) {
- zlog_warn("%s: %s not found in interface list",
+ flog_warn(ZEBRA_ERR_UNKNOWN_INTERFACE,
+ "%s: %s not found in interface list",
__func__, port_str);
return -1;
}
@@ -647,8 +649,9 @@ int zebra_ptm_sock_read(struct thread *thread)
if (((rc == 0) && !errno)
|| (errno && (errno != EWOULDBLOCK) && (errno != EAGAIN))) {
- zlog_warn("%s routing socket error: %s(%d) bytes %d",
- __func__, safe_strerror(errno), errno, rc);
+ flog_err_sys(LIB_ERR_SOCKET,
+ "%s routing socket error: %s(%d) bytes %d",
+ __func__, safe_strerror(errno), errno, rc);
close(ptm_cb.ptm_sock);
ptm_cb.ptm_sock = -1;
@@ -1032,8 +1035,8 @@ int zebra_ptm_bfd_client_deregister(struct zserv *client)
return 0;
if (IS_ZEBRA_DEBUG_EVENT)
- zlog_warn("bfd_client_deregister msg for client %s",
- zebra_route_string(proto));
+ zlog_debug("bfd_client_deregister msg for client %s",
+ zebra_route_string(proto));
if (ptm_cb.ptm_sock == -1) {
ptm_cb.t_timer = NULL;
@@ -1269,7 +1272,7 @@ static void zebra_ptm_send_bfdd(struct stream *msg)
/* Create copy for replication. */
msgc = stream_dup(msg);
if (msgc == NULL) {
- zlog_warn("%s: not enough memory", __func__);
+ zlog_debug("%s: not enough memory", __func__);
return;
}
@@ -1283,7 +1286,7 @@ static void zebra_ptm_send_bfdd(struct stream *msg)
/* Allocate more messages. */
msg = stream_dup(msgc);
if (msg == NULL) {
- zlog_warn("%s: not enough memory", __func__);
+ zlog_debug("%s: not enough memory", __func__);
return;
}
}
@@ -1301,7 +1304,7 @@ static void zebra_ptm_send_clients(struct stream *msg)
/* Create copy for replication. */
msgc = stream_dup(msg);
if (msgc == NULL) {
- zlog_warn("%s: not enough memory", __func__);
+ zlog_debug("%s: not enough memory", __func__);
return;
}
@@ -1324,7 +1327,7 @@ static void zebra_ptm_send_clients(struct stream *msg)
/* Allocate more messages. */
msg = stream_dup(msgc);
if (msg == NULL) {
- zlog_warn("%s: not enough memory", __func__);
+ zlog_debug("%s: not enough memory", __func__);
return;
}
}
@@ -1366,7 +1369,7 @@ static int _zebra_ptm_bfd_client_deregister(struct zserv *zs)
/* Generate, send message and free() daemon related data. */
msg = stream_new(ZEBRA_MAX_PACKET_SIZ);
if (msg == NULL) {
- zlog_warn("%s: not enough memory", __func__);
+ zlog_debug("%s: not enough memory", __func__);
return 0;
}
@@ -1429,7 +1432,7 @@ static void _zebra_ptm_reroute(struct zserv *zs, struct stream *msg,
*/
msgc = stream_new(ZEBRA_MAX_PACKET_SIZ);
if (msgc == NULL) {
- zlog_warn("%s: not enough memory", __func__);
+ zlog_debug("%s: not enough memory", __func__);
return;
}
@@ -1528,7 +1531,7 @@ void zebra_ptm_bfd_dst_replay(ZAPI_HANDLER_ARGS)
*/
msgc = stream_new(ZEBRA_MAX_PACKET_SIZ);
if (msgc == NULL) {
- zlog_warn("%s: not enough memory", __func__);
+ zlog_debug("%s: not enough memory", __func__);
return;
}
diff --git a/zebra/zebra_pw.c b/zebra/zebra_pw.c
index c6db1463f..fb9a40fe3 100644
--- a/zebra/zebra_pw.c
+++ b/zebra/zebra_pw.c
@@ -248,8 +248,8 @@ static int zebra_pw_check_reachability(struct zebra_pw *pw)
&pw->nexthop, NULL);
if (!re) {
if (IS_ZEBRA_DEBUG_PW)
- zlog_warn("%s: no route found for %s", __func__,
- pw->ifname);
+ zlog_debug("%s: no route found for %s", __func__,
+ pw->ifname);
return -1;
}
@@ -260,8 +260,8 @@ static int zebra_pw_check_reachability(struct zebra_pw *pw)
for (ALL_NEXTHOPS(re->ng, nexthop)) {
if (!nexthop->nh_label) {
if (IS_ZEBRA_DEBUG_PW)
- zlog_warn("%s: unlabeled route for %s",
- __func__, pw->ifname);
+ zlog_debug("%s: unlabeled route for %s",
+ __func__, pw->ifname);
return -1;
}
}
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 2c8fa77c3..2eb789d74 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -1091,8 +1091,9 @@ void kernel_route_rib_pass_fail(struct route_node *rn, const struct prefix *p,
dest->selected_fib = re;
zsend_route_notify_owner(re, p, ZAPI_ROUTE_FAIL_INSTALL);
- zlog_warn("%u:%s: Route install failed", re->vrf_id,
- prefix2str(p, buf, sizeof(buf)));
+ flog_err(ZEBRA_ERR_DP_INSTALL_FAIL,
+ "%u:%s: Route install failed", re->vrf_id,
+ prefix2str(p, buf, sizeof(buf)));
break;
case DP_DELETE_SUCCESS:
/*
@@ -1115,8 +1116,9 @@ void kernel_route_rib_pass_fail(struct route_node *rn, const struct prefix *p,
* delete fails?
*/
dest->selected_fib = NULL;
- zlog_warn("%u:%s: Route Deletion failure", re->vrf_id,
- prefix2str(p, buf, sizeof(buf)));
+ flog_err(ZEBRA_ERR_DP_DELETE_FAIL,
+ "%u:%s: Route Deletion failure", re->vrf_id,
+ prefix2str(p, buf, sizeof(buf)));
zsend_route_notify_owner(re, p, ZAPI_ROUTE_REMOVE_FAIL);
break;
diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c
index 0b585af6a..e9c2a4d7f 100644
--- a/zebra/zebra_rnh.c
+++ b/zebra/zebra_rnh.c
@@ -118,7 +118,8 @@ struct rnh *zebra_add_rnh(struct prefix *p, vrf_id_t vrfid, rnh_type_t type,
table = get_rnh_table(vrfid, PREFIX_FAMILY(p), type);
if (!table) {
prefix2str(p, buf, sizeof(buf));
- zlog_warn("%u: Add RNH %s type %d - table not found", vrfid,
+ flog_warn(ZEBRA_ERR_RNH_NO_TABLE,
+ "%u: Add RNH %s type %d - table not found", vrfid,
buf, type);
exists = false;
return NULL;
@@ -249,7 +250,7 @@ static void addr2hostprefix(int af, const union g_addr *addr,
break;
default:
memset(prefix, 0, sizeof(*prefix));
- zlog_warn("%s: unknown address family %d", __func__, af);
+ zlog_debug("%s: unknown address family %d", __func__, af);
break;
}
}
diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c
index eb1b07170..a0a90ac28 100644
--- a/zebra/zebra_vxlan.c
+++ b/zebra/zebra_vxlan.c
@@ -211,8 +211,8 @@ static int host_rb_entry_compare(const struct host_rb_entry *hle1,
return memcmp(&hle1->p.u.prefix6, &hle2->p.u.prefix6,
IPV6_MAX_BYTELEN);
} else {
- zlog_warn("%s: Unexpected family type: %d", __PRETTY_FUNCTION__,
- hle1->p.family);
+ zlog_debug("%s: Unexpected family type: %d",
+ __PRETTY_FUNCTION__, hle1->p.family);
return 0;
}
}
@@ -1597,8 +1597,8 @@ static int zvni_neigh_uninstall(zebra_vni_t *zvni, zebra_neigh_t *n)
return 0;
if (!zvni->vxlan_if) {
- zlog_warn("VNI %u hash %p couldn't be uninstalled - no intf",
- zvni->vni, zvni);
+ zlog_debug("VNI %u hash %p couldn't be uninstalled - no intf",
+ zvni->vni, zvni);
return -1;
}
@@ -1848,9 +1848,9 @@ static int zvni_gw_macip_del(struct interface *ifp, zebra_vni_t *zvni,
/* mac entry should be present */
mac = zvni_mac_lookup(zvni, &n->emac);
if (!mac) {
- zlog_warn("MAC %s doesnt exists for neigh %s on VNI %u",
- prefix_mac2str(&n->emac, buf1, sizeof(buf1)),
- ipaddr2str(ip, buf2, sizeof(buf2)), zvni->vni);
+ zlog_debug("MAC %s doesnt exists for neigh %s on VNI %u",
+ prefix_mac2str(&n->emac, buf1, sizeof(buf1)),
+ ipaddr2str(ip, buf2, sizeof(buf2)), zvni->vni);
return -1;
}
@@ -1985,9 +1985,9 @@ static int zvni_local_neigh_update(zebra_vni_t *zvni,
zmac = zvni_mac_add(zvni, macaddr);
if (!zmac) {
- zlog_warn("Failed to add MAC %s VNI %u",
- prefix_mac2str(macaddr, buf, sizeof(buf)),
- zvni->vni);
+ zlog_debug("Failed to add MAC %s VNI %u",
+ prefix_mac2str(macaddr, buf, sizeof(buf)),
+ zvni->vni);
return -1;
}
@@ -2192,7 +2192,7 @@ static int zvni_remote_neigh_update(zebra_vni_t *zvni,
*/
zmac = zvni_mac_lookup(zvni, macaddr);
if (!zmac || !CHECK_FLAG(zmac->flags, ZEBRA_MAC_REMOTE)) {
- zlog_warn(
+ zlog_debug(
"Ignore remote neigh %s (MAC %s) on L2-VNI %u - MAC unknown or local",
ipaddr2str(&n->ip, buf2, sizeof(buf2)),
prefix_mac2str(macaddr, buf, sizeof(buf)),
@@ -2625,8 +2625,8 @@ static int zvni_mac_uninstall(zebra_vni_t *zvni, zebra_mac_t *mac, int local)
return 0;
if (!zvni->vxlan_if) {
- zlog_warn("VNI %u hash %p couldn't be uninstalled - no intf",
- zvni->vni, zvni);
+ zlog_debug("VNI %u hash %p couldn't be uninstalled - no intf",
+ zvni->vni, zvni);
return -1;
}
@@ -2953,7 +2953,7 @@ static void zvni_build_hash_table()
/* VNI hash entry is not expected to exist. */
zvni = zvni_lookup(vni);
if (zvni) {
- zlog_warn(
+ zlog_debug(
"VNI hash already present for IF %s(%u) L2-VNI %u",
ifp->name, ifp->ifindex, vni);
continue;
@@ -2961,7 +2961,7 @@ static void zvni_build_hash_table()
zvni = zvni_add(vni);
if (!zvni) {
- zlog_warn(
+ zlog_debug(
"Failed to add VNI hash, IF %s(%u) L2-VNI %u",
ifp->name, ifp->ifindex, vni);
return;
@@ -3084,8 +3084,8 @@ static int zvni_vtep_install(zebra_vni_t *zvni, struct in_addr *vtep_ip)
static int zvni_vtep_uninstall(zebra_vni_t *zvni, struct in_addr *vtep_ip)
{
if (!zvni->vxlan_if) {
- zlog_warn("VNI %u hash %p couldn't be uninstalled - no intf",
- zvni->vni, zvni);
+ zlog_debug("VNI %u hash %p couldn't be uninstalled - no intf",
+ zvni->vni, zvni);
return -1;
}
@@ -3275,7 +3275,7 @@ static int zl3vni_rmac_uninstall(zebra_l3vni_t *zl3vni, zebra_mac_t *zrmac)
return 0;
if (!zl3vni->vxlan_if) {
- zlog_warn(
+ zlog_debug(
"RMAC %s on L3-VNI %u hash %p couldn't be uninstalled - no vxlan_if",
prefix_mac2str(&zrmac->macaddr, buf, sizeof(buf)),
zl3vni->vni, zl3vni);
@@ -3306,7 +3306,7 @@ static int zl3vni_remote_rmac_add(zebra_l3vni_t *zl3vni, struct ethaddr *rmac,
zrmac = zl3vni_rmac_add(zl3vni, rmac);
if (!zrmac) {
- zlog_warn(
+ zlog_debug(
"Failed to add RMAC %s L3VNI %u Remote VTEP %s",
prefix_mac2str(rmac, buf, sizeof(buf)),
zl3vni->vni,
@@ -3470,7 +3470,7 @@ static int zl3vni_remote_nh_add(zebra_l3vni_t *zl3vni, struct ipaddr *vtep_ip,
nh = zl3vni_nh_add(zl3vni, vtep_ip, rmac);
if (!nh) {
- zlog_warn(
+ zlog_debug(
"Failed to add NH as Neigh (IP %s MAC %s L3-VNI %u)",
ipaddr2str(vtep_ip, buf1, sizeof(buf1)),
prefix_mac2str(rmac, buf, sizeof(buf)),
@@ -5325,7 +5325,7 @@ int zebra_vxlan_handle_kernel_neigh_del(struct interface *ifp,
return 0;
if (!zvni->vxlan_if) {
- zlog_warn(
+ zlog_debug(
"VNI %u hash %p doesn't have intf upon local neighbor DEL",
zvni->vni, zvni);
return -1;
@@ -5344,7 +5344,7 @@ int zebra_vxlan_handle_kernel_neigh_del(struct interface *ifp,
zmac = zvni_mac_lookup(zvni, &n->emac);
if (!zmac) {
if (IS_ZEBRA_DEBUG_VXLAN)
- zlog_warn(
+ zlog_debug(
"Trying to del a neigh %s without a mac %s on VNI %u",
ipaddr2str(ip, buf, sizeof(buf)),
prefix_mac2str(&n->emac, buf2, sizeof(buf2)),
@@ -5477,7 +5477,6 @@ void zebra_vxlan_remote_macip_del(ZAPI_HANDLER_ARGS)
zebra_route_string(client->proto));
process_remote_macip_del(vni, &macaddr, ipa_len, &ip, vtep_ip);
-
}
stream_failure:
@@ -5507,7 +5506,7 @@ void zebra_vxlan_remote_macip_add(ZAPI_HANDLER_ARGS)
memset(&vtep_ip, 0, sizeof(struct in_addr));
if (!EVPN_ENABLED(zvrf)) {
- zlog_warn("EVPN not enabled, ignoring remote MACIP ADD");
+ zlog_debug("EVPN not enabled, ignoring remote MACIP ADD");
return;
}
@@ -5689,8 +5688,9 @@ int zebra_vxlan_local_mac_del(struct interface *ifp, struct interface *br_if,
if (!zvni)
return 0;
if (!zvni->vxlan_if) {
- zlog_warn("VNI %u hash %p doesn't have intf upon local MAC DEL",
- zvni->vni, zvni);
+ zlog_debug(
+ "VNI %u hash %p doesn't have intf upon local MAC DEL",
+ zvni->vni, zvni);
return -1;
}
@@ -5758,8 +5758,9 @@ int zebra_vxlan_local_mac_add_update(struct interface *ifp,
}
if (!zvni->vxlan_if) {
- zlog_warn("VNI %u hash %p doesn't have intf upon local MAC ADD",
- zvni->vni, zvni);
+ zlog_debug(
+ "VNI %u hash %p doesn't have intf upon local MAC ADD",
+ zvni->vni, zvni);
return -1;
}
@@ -5844,8 +5845,9 @@ int zebra_vxlan_local_mac_add_update(struct interface *ifp,
* operator error.
*/
if (CHECK_FLAG(mac->flags, ZEBRA_MAC_STICKY)) {
- zlog_warn(
- "MAC %s already learnt as remote sticky behind VTEP %s VNI %u",
+ flog_warn(
+ ZEBRA_ERR_STICKY_MAC_ALREADY_LEARNT,
+ "MAC %s already learnt as remote sticky MAC behind VTEP %s VNI %u",
prefix_mac2str(macaddr, buf,
sizeof(buf)),
inet_ntoa(mac->fwd_info.r_vtep_ip),
@@ -5905,15 +5907,15 @@ void zebra_vxlan_remote_vtep_del(ZAPI_HANDLER_ARGS)
struct zebra_if *zif;
if (!is_evpn_enabled()) {
- zlog_warn(
+ zlog_debug(
"%s: EVPN is not enabled yet we have received a vtep del command",
__PRETTY_FUNCTION__);
return;
}
if (zvrf_id(zvrf) != VRF_DEFAULT) {
- zlog_warn("Recv MACIP DEL for non-default VRF %u",
- zvrf_id(zvrf));
+ zlog_debug("Recv MACIP DEL for non-default VRF %u",
+ zvrf_id(zvrf));
return;
}
@@ -5944,7 +5946,7 @@ void zebra_vxlan_remote_vtep_del(ZAPI_HANDLER_ARGS)
ifp = zvni->vxlan_if;
if (!ifp) {
- zlog_warn(
+ zlog_debug(
"VNI %u hash %p doesn't have intf upon remote VTEP DEL",
zvni->vni, zvni);
continue;
@@ -5989,15 +5991,15 @@ void zebra_vxlan_remote_vtep_add(ZAPI_HANDLER_ARGS)
struct zebra_if *zif;
if (!is_evpn_enabled()) {
- zlog_warn(
+ zlog_debug(
"%s: EVPN not enabled yet we received a vtep_add zapi call",
__PRETTY_FUNCTION__);
return;
}
if (zvrf_id(zvrf) != VRF_DEFAULT) {
- zlog_warn("Recv MACIP ADD for non-default VRF %u",
- zvrf_id(zvrf));
+ zlog_debug("Recv MACIP ADD for non-default VRF %u",
+ zvrf_id(zvrf));
return;
}
@@ -6099,8 +6101,8 @@ int zebra_vxlan_add_del_gw_macip(struct interface *ifp, struct prefix *p,
svi_if = if_lookup_by_index_per_ns(zebra_ns_lookup(NS_DEFAULT),
ifp_zif->link_ifindex);
if (!svi_if) {
- zlog_warn("MACVLAN %s(%u) without link information",
- ifp->name, ifp->ifindex);
+ zlog_debug("MACVLAN %s(%u) without link information",
+ ifp->name, ifp->ifindex);
return -1;
}
@@ -6147,8 +6149,8 @@ int zebra_vxlan_add_del_gw_macip(struct interface *ifp, struct prefix *p,
return 0;
if (!zvni->vxlan_if) {
- zlog_warn("VNI %u hash %p doesn't have intf upon MACVLAN up",
- zvni->vni, zvni);
+ zlog_debug("VNI %u hash %p doesn't have intf upon MACVLAN up",
+ zvni->vni, zvni);
return -1;
}
@@ -6244,7 +6246,7 @@ int zebra_vxlan_svi_up(struct interface *ifp, struct interface *link_if)
return 0;
if (!zvni->vxlan_if) {
- zlog_warn(
+ zlog_debug(
"VNI %u hash %p doesn't have intf upon SVI up",
zvni->vni, zvni);
return -1;
@@ -6307,7 +6309,7 @@ int zebra_vxlan_if_down(struct interface *ifp)
/* Locate hash entry; it is expected to exist. */
zvni = zvni_lookup(vni);
if (!zvni) {
- zlog_warn(
+ zlog_debug(
"Failed to locate VNI hash at DOWN, IF %s(%u) VNI %u",
ifp->name, ifp->ifindex, vni);
return -1;
@@ -6373,7 +6375,7 @@ int zebra_vxlan_if_up(struct interface *ifp)
/* Locate hash entry; it is expected to exist. */
zvni = zvni_lookup(vni);
if (!zvni) {
- zlog_warn(
+ zlog_debug(
"Failed to locate VNI hash at UP, IF %s(%u) VNI %u",
ifp->name, ifp->ifindex, vni);
return -1;
@@ -6444,7 +6446,7 @@ int zebra_vxlan_if_del(struct interface *ifp)
/* Locate hash entry; it is expected to exist. */
zvni = zvni_lookup(vni);
if (!zvni) {
- zlog_warn(
+ zlog_debug(
"Failed to locate VNI hash at del, IF %s(%u) VNI %u",
ifp->name, ifp->ifindex, vni);
return 0;
@@ -6555,7 +6557,7 @@ int zebra_vxlan_if_update(struct interface *ifp, uint16_t chgflags)
/* Update VNI hash. */
zvni = zvni_lookup(vni);
if (!zvni) {
- zlog_warn(
+ zlog_debug(
"Failed to find L2-VNI hash on update, IF %s(%u) VNI %u",
ifp->name, ifp->ifindex, vni);
return -1;
@@ -6887,8 +6889,8 @@ void zebra_vxlan_advertise_subnet(ZAPI_HANDLER_ARGS)
struct interface *vlan_if = NULL;
if (zvrf_id(zvrf) != VRF_DEFAULT) {
- zlog_warn("EVPN GW-MACIP Adv for non-default VRF %u",
- zvrf_id(zvrf));
+ zlog_debug("EVPN GW-MACIP Adv for non-default VRF %u",
+ zvrf_id(zvrf));
return;
}
@@ -6950,8 +6952,8 @@ void zebra_vxlan_advertise_gw_macip(ZAPI_HANDLER_ARGS)
struct interface *ifp = NULL;
if (zvrf_id(zvrf) != VRF_DEFAULT) {
- zlog_warn("EVPN GW-MACIP Adv for non-default VRF %u",
- zvrf_id(zvrf));
+ zlog_debug("EVPN GW-MACIP Adv for non-default VRF %u",
+ zvrf_id(zvrf));
return;
}
@@ -7055,7 +7057,8 @@ void zebra_vxlan_advertise_all_vni(ZAPI_HANDLER_ARGS)
struct zebra_ns *zns = NULL;
if (zvrf_id(zvrf) != VRF_DEFAULT) {
- zlog_warn("EVPN VNI Adv for non-default VRF %u", zvrf_id(zvrf));
+ zlog_debug("EVPN VNI Adv for non-default VRF %u",
+ zvrf_id(zvrf));
return;
}
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 4a341bfe1..d1d6a2d3f 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -61,6 +61,7 @@
#include "zebra/zapi_msg.h" /* for zserv_handle_commands */
#include "zebra/zebra_vrf.h" /* for zebra_vrf_lookup_by_id, zvrf */
#include "zebra/zserv.h" /* for zserv */
+#include "zebra/zebra_errors.h" /* for error messages */
/* clang-format on */
/* privileges */
@@ -171,7 +172,8 @@ static void zserv_log_message(const char *errmsg, struct stream *msg,
*/
static void zserv_client_fail(struct zserv *client)
{
- zlog_warn("Client '%s' encountered an error and is shutting down.",
+ flog_warn(ZEBRA_ERR_CLIENT_IO_ERROR,
+ "Client '%s' encountered an error and is shutting down.",
zebra_route_string(client->proto));
atomic_store_explicit(&client->pthread->running, false,
@@ -270,7 +272,8 @@ static int zserv_write(struct thread *thread)
return 0;
zwrite_fail:
- zlog_warn("%s: could not write to %s [fd = %d], closing.", __func__,
+ flog_warn(ZEBRA_ERR_CLIENT_WRITE_FAILED,
+ "%s: could not write to %s [fd = %d], closing.", __func__,
zebra_route_string(client->proto), client->sock);
zserv_client_fail(client);
return 0;
@@ -741,8 +744,8 @@ static int zserv_accept(struct thread *thread)
client_sock = accept(accept_sock, (struct sockaddr *)&client, &len);
if (client_sock < 0) {
- zlog_warn("Can't accept zebra socket: %s",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "Can't accept zebra socket: %s",
+ safe_strerror(errno));
return -1;
}
@@ -772,10 +775,8 @@ void zserv_start(char *path)
/* Make UNIX domain socket. */
zebrad.sock = socket(sa.ss_family, SOCK_STREAM, 0);
if (zebrad.sock < 0) {
- zlog_warn("Can't create zserv socket: %s",
- safe_strerror(errno));
- zlog_warn(
- "zebra can't provide full functionality due to above error");
+ flog_err_sys(LIB_ERR_SOCKET, "Can't create zserv socket: %s",
+ safe_strerror(errno));
return;
}
@@ -797,10 +798,9 @@ void zserv_start(char *path)
ret = bind(zebrad.sock, (struct sockaddr *)&sa, sa_len);
}
if (ret < 0) {
- zlog_warn("Can't bind zserv socket on %s: %s", path,
- safe_strerror(errno));
- zlog_warn(
- "zebra can't provide full functionality due to above error");
+ flog_err_sys(LIB_ERR_SOCKET,
+ "Can't bind zserv socket on %s: %s", path,
+ safe_strerror(errno));
close(zebrad.sock);
zebrad.sock = -1;
return;
@@ -808,10 +808,9 @@ void zserv_start(char *path)
ret = listen(zebrad.sock, 5);
if (ret < 0) {
- zlog_warn("Can't listen to zserv socket %s: %s", path,
- safe_strerror(errno));
- zlog_warn(
- "zebra can't provide full functionality due to above error");
+ flog_err_sys(LIB_ERR_SOCKET,
+ "Can't listen to zserv socket %s: %s", path,
+ safe_strerror(errno));
close(zebrad.sock);
zebrad.sock = -1;
return;