From b66d022e8d843bbc5daec9d1cb59f66d338f7433 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 14 Jun 2018 08:23:49 -0400 Subject: lib, bgpd: Add code to make lib auto create the ferr infrastructure Add code to auto-create the ferr infrastructure as well as add some initial error handling for vrf.c Signed-off-by: Donald Sharp --- lib/lib_errors.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 lib/lib_errors.h (limited to 'lib/lib_errors.h') diff --git a/lib/lib_errors.h b/lib/lib_errors.h new file mode 100644 index 0000000000..67a6f8faed --- /dev/null +++ b/lib/lib_errors.h @@ -0,0 +1,34 @@ +/* + * Library-specific error messages. + * Copyright (C) 2018 Cumulus Networks, Inc. + * Donald Sharp + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; see the file COPYING; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef __LIB_ERRORS_H__ +#define __LIB_ERRORS_H__ + +#include "ferr.h" +#include "lib_errors.h" + +enum lib_ferr_refs { + LIB_ERR_PRIVILEGES = LIB_FERR_START, + LIB_ERR_VRF_START, + LIB_ERR_VRF_SOCKET, +}; + +extern void lib_error_init(void); + +#endif -- cgit v1.2.3 From 1ca3850c88035cef8bb2fe0f45112f774d9a328e Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 14 Jun 2018 08:56:27 -0400 Subject: lib: Convert to zlog_ferr for zclient.c Convert the zclient.c file to use zlog_ferr. Signed-off-by: Donald Sharp --- lib/lib_errors.c | 18 ++++++++++ lib/lib_errors.h | 3 ++ lib/zclient.c | 101 +++++++++++++++++++++++++++++++------------------------ 3 files changed, 78 insertions(+), 44 deletions(-) (limited to 'lib/lib_errors.h') diff --git a/lib/lib_errors.c b/lib/lib_errors.c index 73b90a9c55..c98534da03 100644 --- a/lib/lib_errors.c +++ b/lib/lib_errors.c @@ -40,6 +40,24 @@ static struct ferr_ref ferr_lib_err[] = { .description = "When attempting to access a socket for the VRF specified, we\nwere unable to properly complete the request", .suggestion = "Ensure that there is sufficient system resources available and\nensure that the frr user has sufficient permisions to work", }, + { + .code = LIB_ERR_ZAPI_MISSMATCH, + .title = "Zapi Error", + .description = "A version miss-match has been detected between zebra and client protocol", + .suggestion = "Two different versions of FRR have been installed and the install is\nnot properly setup. Completely stop FRR, remove it from the system and\nreinstall. Typically only developers should see this issue" + }, + { + .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" + }, + { + .code = LIB_ERR_ZAPI_SOCKET, + .title = "Zapi Error", + .description = "The Zapi subsystem has detected a socket error between zebra and a client", + .suggestion = "Restart FRR" + }, { .code = END_FERR } diff --git a/lib/lib_errors.h b/lib/lib_errors.h index 67a6f8faed..409b2f749c 100644 --- a/lib/lib_errors.h +++ b/lib/lib_errors.h @@ -27,6 +27,9 @@ enum lib_ferr_refs { LIB_ERR_PRIVILEGES = LIB_FERR_START, LIB_ERR_VRF_START, LIB_ERR_VRF_SOCKET, + LIB_ERR_ZAPI_MISSMATCH, + LIB_ERR_ZAPI_ENCODE, + LIB_ERR_ZAPI_SOCKET, }; extern void lib_error_init(void); diff --git a/lib/zclient.c b/lib/zclient.c index 38a9e6c78e..105435fb2e 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -38,6 +38,7 @@ #include "sockopt.h" #include "pbr.h" #include "nexthop_group.h" +#include "lib_errors.h" DEFINE_MTYPE_STATIC(LIB, ZCLIENT, "Zclient") DEFINE_MTYPE_STATIC(LIB, REDIST_INST, "Redistribution instance IDs") @@ -312,9 +313,9 @@ int zclient_read_header(struct stream *s, int sock, uint16_t *size, STREAM_GETW(s, *cmd); if (*version != ZSERV_VERSION || *marker != ZEBRA_HEADER_MARKER) { - zlog_err( - "%s: socket %d version mismatch, marker %d, version %d", - __func__, sock, *marker, *version); + zlog_ferr(LIB_ERR_ZAPI_MISSMATCH, + "%s: socket %d version mismatch, marker %d, version %d", + __func__, sock, *marker, *version); return -1; } @@ -1045,12 +1046,12 @@ 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_err( - "%s: prefix %s: can't encode " - "%u labels (maximum is %u)", - __func__, buf, - api_nh->label_num, - MPLS_MAX_LABELS); + zlog_ferr(LIB_ERR_ZAPI_ENCODE, + "%s: prefix %s: can't encode " + "%u labels (maximum is %u)", + __func__, buf, + api_nh->label_num, + MPLS_MAX_LABELS); return -1; } @@ -1671,10 +1672,10 @@ static void link_params_set_value(struct stream *s, struct if_link_params *iflp) for (i = 0; i < bwclassnum && i < MAX_CLASS_TYPE; i++) iflp->unrsv_bw[i] = stream_getf(s); if (i < bwclassnum) - zlog_err( - "%s: received %d > %d (MAX_CLASS_TYPE) bw entries" - " - outdated library?", - __func__, bwclassnum, MAX_CLASS_TYPE); + zlog_ferr(LIB_ERR_ZAPI_MISSMATCH, + "%s: received %d > %d (MAX_CLASS_TYPE) bw entries" + " - outdated library?", + __func__, bwclassnum, MAX_CLASS_TYPE); } iflp->admin_grp = stream_getl(s); iflp->rmt_as = stream_getl(s); @@ -1703,8 +1704,9 @@ struct interface *zebra_interface_link_params_read(struct stream *s) struct interface *ifp = if_lookup_by_index(ifindex, VRF_DEFAULT); if (ifp == NULL) { - zlog_err("%s: unknown ifindex %u, shouldn't happen", __func__, - ifindex); + zlog_ferr(LIB_ERR_ZAPI_ENCODE, + "%s: unknown ifindex %u, shouldn't happen", __func__, + ifindex); return NULL; } @@ -2039,7 +2041,8 @@ static int zclient_read_sync_response(struct zclient *zclient, size); } if (ret != 0) { - zlog_err("%s: Invalid Sync Message Reply", __func__); + zlog_ferr(LIB_ERR_ZAPI_ENCODE, + "%s: Invalid Sync Message Reply", __func__); return -1; } @@ -2081,13 +2084,13 @@ int lm_label_manager_connect(struct zclient *zclient) ret = writen(zclient->sock, s->data, stream_get_endp(s)); if (ret < 0) { - zlog_err("Can't write to zclient sock"); + zlog_ferr(LIB_ERR_ZAPI_SOCKET, "Can't write to zclient sock"); close(zclient->sock); zclient->sock = -1; return -1; } if (ret == 0) { - zlog_err("Zclient sock closed"); + zlog_ferr(LIB_ERR_ZAPI_SOCKET, "Zclient sock closed"); close(zclient->sock); zclient->sock = -1; return -1; @@ -2108,13 +2111,13 @@ int lm_label_manager_connect(struct zclient *zclient) /* sanity */ if (proto != zclient->redist_default) - zlog_err( - "Wrong proto (%u) in LM connect response. Should be %u", - proto, zclient->redist_default); + zlog_ferr(LIB_ERR_ZAPI_ENCODE, + "Wrong proto (%u) in LM connect response. Should be %u", + proto, zclient->redist_default); if (instance != zclient->instance) - zlog_err( - "Wrong instId (%u) in LM connect response. Should be %u", - instance, zclient->instance); + zlog_ferr(LIB_ERR_ZAPI_ENCODE, + "Wrong instId (%u) in LM connect response. Should be %u", + instance, zclient->instance); /* result code */ result = stream_getc(s); @@ -2203,13 +2206,15 @@ int lm_get_label_chunk(struct zclient *zclient, uint8_t keep, ret = writen(zclient->sock, s->data, stream_get_endp(s)); if (ret < 0) { - zlog_err("Can't write to zclient sock"); + zlog_ferr(LIB_ERR_ZAPI_SOCKET, + "Can't write to zclient sock"); close(zclient->sock); zclient->sock = -1; return -1; } if (ret == 0) { - zlog_err("Zclient sock closed"); + zlog_ferr(LIB_ERR_ZAPI_SOCKET, + "Zclient sock closed"); close(zclient->sock); zclient->sock = -1; return -1; @@ -2230,11 +2235,13 @@ int lm_get_label_chunk(struct zclient *zclient, uint8_t keep, /* sanities */ if (proto != zclient->redist_default) - zlog_err("Wrong proto (%u) in get chunk response. Should be %u", - proto, zclient->redist_default); + zlog_ferr(LIB_ERR_ZAPI_ENCODE, + "Wrong proto (%u) in get chunk response. Should be %u", + proto, zclient->redist_default); if (instance != zclient->instance) - zlog_err("Wrong instId (%u) in get chunk response Should be %u", - instance, zclient->instance); + zlog_ferr(LIB_ERR_ZAPI_ENCODE, + "Wrong instId (%u) in get chunk response Should be %u", + instance, zclient->instance); /* keep */ response_keep = stream_getc(s); @@ -2244,14 +2251,15 @@ int lm_get_label_chunk(struct zclient *zclient, uint8_t keep, /* not owning this response */ if (keep != response_keep) { - zlog_err( - "Invalid Label chunk: %u - %u, keeps mismatch %u != %u", - *start, *end, keep, response_keep); + zlog_ferr(LIB_ERR_ZAPI_ENCODE, + "Invalid Label chunk: %u - %u, keeps mismatch %u != %u", + *start, *end, keep, response_keep); } /* sanity */ if (*start > *end || *start < MPLS_LABEL_UNRESERVED_MIN || *end > MPLS_LABEL_UNRESERVED_MAX) { - zlog_err("Invalid Label chunk: %u - %u", *start, *end); + zlog_ferr(LIB_ERR_ZAPI_ENCODE, + "Invalid Label chunk: %u - %u", *start, *end); return -1; } @@ -2301,13 +2309,14 @@ int lm_release_label_chunk(struct zclient *zclient, uint32_t start, ret = writen(zclient->sock, s->data, stream_get_endp(s)); if (ret < 0) { - zlog_err("Can't write to zclient sock"); + zlog_ferr(LIB_ERR_ZAPI_SOCKET, "Can't write to zclient sock"); close(zclient->sock); zclient->sock = -1; return -1; } if (ret == 0) { - zlog_err("Zclient sock connection closed"); + zlog_ferr(LIB_ERR_ZAPI_SOCKET, + "Zclient sock connection closed"); close(zclient->sock); zclient->sock = -1; return -1; @@ -2410,13 +2419,15 @@ int tm_get_table_chunk(struct zclient *zclient, uint32_t chunk_size, ret = writen(zclient->sock, s->data, stream_get_endp(s)); if (ret < 0) { - zlog_err("%s: can't write to zclient->sock", __func__); + zlog_ferr(LIB_ERR_ZAPI_SOCKET, + "%s: can't write to zclient->sock", __func__); close(zclient->sock); zclient->sock = -1; return -1; } if (ret == 0) { - zlog_err("%s: zclient->sock connection closed", __func__); + zlog_ferr(LIB_ERR_ZAPI_SOCKET, + "%s: zclient->sock connection closed", __func__); close(zclient->sock); zclient->sock = -1; return -1; @@ -2502,7 +2513,8 @@ int zebra_send_pw(struct zclient *zclient, int command, struct zapi_pw *pw) stream_write(s, (uint8_t *)&pw->nexthop.ipv6, 16); break; default: - zlog_err("%s: unknown af", __func__); + zlog_ferr(LIB_ERR_ZAPI_ENCODE, + "%s: unknown af", __func__); return -1; } @@ -2604,15 +2616,16 @@ static int zclient_read(struct thread *thread) command = stream_getw(zclient->ibuf); if (marker != ZEBRA_HEADER_MARKER || version != ZSERV_VERSION) { - zlog_err( - "%s: socket %d version mismatch, marker %d, version %d", - __func__, zclient->sock, marker, version); + zlog_ferr(LIB_ERR_ZAPI_MISSMATCH, + "%s: socket %d version mismatch, marker %d, version %d", + __func__, zclient->sock, marker, version); return zclient_failed(zclient); } if (length < ZEBRA_HEADER_SIZE) { - zlog_err("%s: socket %d message length %u is less than %d ", - __func__, zclient->sock, length, ZEBRA_HEADER_SIZE); + zlog_ferr(LIB_ERR_ZAPI_MISSMATCH, + "%s: socket %d message length %u is less than %d ", + __func__, zclient->sock, length, ZEBRA_HEADER_SIZE); return zclient_failed(zclient); } -- cgit v1.2.3 From 481bc15ffcebcc7d0395a3ffa8ce70249e221d5b Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 14 Jun 2018 09:13:18 -0400 Subject: lib: Add LIB_ERR_SYSTEM_CALL and convert VRF_SOCKET to SOCKET Add a new error code LIB_ERR_SYSTEM_CALL to the ferr subsystem. Additionally convert LIB_ERR_VRF_SOCKET to a more generic LIB_ERR_SOCKET. Signed-off-by: Donald Sharp --- lib/buffer.c | 12 +++++++----- lib/command.c | 4 +++- lib/lib_errors.c | 14 ++++++++++---- lib/lib_errors.h | 3 ++- lib/log.c | 27 +++++++++++++++------------ lib/netns_linux.c | 7 ++++--- lib/pid_output.c | 25 ++++++++++++++----------- lib/sigevent.c | 4 +++- lib/sockopt.c | 11 +++++++---- lib/vrf.c | 16 ++++++++-------- lib/vty.c | 42 +++++++++++++++++++++++++----------------- 11 files changed, 98 insertions(+), 67 deletions(-) (limited to 'lib/lib_errors.h') diff --git a/lib/buffer.c b/lib/buffer.c index b573981c1b..207f2320ff 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -25,6 +25,8 @@ #include "buffer.h" #include "log.h" #include "network.h" +#include "lib_errors.h" + #include DEFINE_MTYPE_STATIC(LIB, BUFFER, "Buffer") @@ -341,11 +343,11 @@ buffer_status_t buffer_flush_window(struct buffer *b, int fd, int width, iov_alloc * sizeof(*iov)); } else { /* This should absolutely never occur. */ - zlog_err( - "%s: corruption detected: iov_small overflowed; " - "head %p, tail %p, head->next %p", - __func__, (void *)b->head, - (void *)b->tail, (void *)b->head->next); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "%s: corruption detected: iov_small overflowed; " + "head %p, tail %p, head->next %p", + __func__, (void *)b->head, + (void *)b->tail, (void *)b->head->next); iov = XMALLOC(MTYPE_TMP, iov_alloc * sizeof(*iov)); memcpy(iov, small_iov, sizeof(small_iov)); diff --git a/lib/command.c b/lib/command.c index 7eda239ee4..ca916c6043 100644 --- a/lib/command.c +++ b/lib/command.c @@ -45,6 +45,7 @@ #include "libfrr.h" #include "jhash.h" #include "hook.h" +#include "lib_errors.h" DEFINE_MTYPE(LIB, HOST, "Host config") DEFINE_MTYPE(LIB, COMPLETION, "Completion item") @@ -2416,7 +2417,8 @@ static int set_log_file(struct vty *vty, const char *fname, int loglevel) cwd[MAXPATHLEN] = '\0'; if (getcwd(cwd, MAXPATHLEN) == NULL) { - zlog_err("config_log_file: Unable to alloc mem!"); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "config_log_file: Unable to alloc mem!"); return CMD_WARNING_CONFIG_FAILED; } diff --git a/lib/lib_errors.c b/lib/lib_errors.c index c98534da03..f9bfa17b2e 100644 --- a/lib/lib_errors.c +++ b/lib/lib_errors.c @@ -35,9 +35,9 @@ static struct ferr_ref ferr_lib_err[] = { .suggestion = "Ensure that there is sufficient memory to start processes and restart FRR", }, { - .code = LIB_ERR_VRF_SOCKET, - .title = "VRF Socket Error", - .description = "When attempting to access a socket for the VRF specified, we\nwere unable to properly complete the request", + .code = LIB_ERR_SOCKET, + .title = "Socket Error", + .description = "When attempting to access a socket a system error has occured\nand we were unable to properly complete the request", .suggestion = "Ensure that there is sufficient system resources available and\nensure that the frr user has sufficient permisions to work", }, { @@ -59,7 +59,13 @@ static struct ferr_ref ferr_lib_err[] = { .suggestion = "Restart FRR" }, { - .code = END_FERR + .code = LIB_ERR_SYSTEM_CALL, + .title = "System Call Error", + .description = "FRR has detected a error from using a vital system call and has probably\nalready exited", + .suggestion = "Ensure permissions are correct for FRR and FRR user and groups are correct\nAdditionally check that system resources are still available" + }, + { + .code = END_FERR, } }; diff --git a/lib/lib_errors.h b/lib/lib_errors.h index 409b2f749c..24521a6008 100644 --- a/lib/lib_errors.h +++ b/lib/lib_errors.h @@ -26,10 +26,11 @@ enum lib_ferr_refs { LIB_ERR_PRIVILEGES = LIB_FERR_START, LIB_ERR_VRF_START, - LIB_ERR_VRF_SOCKET, + LIB_ERR_SOCKET, LIB_ERR_ZAPI_MISSMATCH, LIB_ERR_ZAPI_ENCODE, LIB_ERR_ZAPI_SOCKET, + LIB_ERR_SYSTEM_CALL, }; extern void lib_error_init(void); diff --git a/lib/log.c b/lib/log.c index 1345ff2fd1..afecbef19c 100644 --- a/lib/log.c +++ b/lib/log.c @@ -28,6 +28,8 @@ #include "log_int.h" #include "memory.h" #include "command.h" +#include "lib_errors.h" + #ifndef SUNOS_5 #include #endif @@ -631,15 +633,16 @@ void zlog_backtrace(int priority) size = backtrace(array, array_size(array)); if (size <= 0 || (size_t)size > array_size(array)) { - zlog_err( - "Cannot get backtrace, returned invalid # of frames %d " - "(valid range is between 1 and %lu)", - size, (unsigned long)(array_size(array))); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "Cannot get backtrace, returned invalid # of frames %d " + "(valid range is between 1 and %lu)", + size, (unsigned long)(array_size(array))); return; } zlog(priority, "Backtrace for %d stack frames:", size); if (!(strings = backtrace_symbols(array, size))) { - zlog_err("Cannot get backtrace symbols (out of memory?)"); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "Cannot get backtrace symbols (out of memory?)"); for (i = 0; i < size; i++) zlog(priority, "[bt %d] %p", i, array[i]); } else { @@ -712,10 +715,10 @@ void _zlog_assert_failed(const char *assertion, const char *file, void memory_oom(size_t size, const char *name) { - zlog_err( - "out of memory: failed to allocate %zu bytes for %s" - "object", - size, name); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "out of memory: failed to allocate %zu bytes for %s" + "object", + size, name); zlog_backtrace(LOG_ERR); abort(); } @@ -864,9 +867,9 @@ int zlog_rotate(void) save_errno = errno; umask(oldumask); if (zl->fp == NULL) { - zlog_err( - "Log rotate failed: cannot open file %s for append: %s", - zl->filename, safe_strerror(save_errno)); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "Log rotate failed: cannot open file %s for append: %s", + zl->filename, safe_strerror(save_errno)); ret = -1; } else { logfile_fd = fileno(zl->fp); diff --git a/lib/netns_linux.c b/lib/netns_linux.c index a80b51fa00..801264d1a8 100644 --- a/lib/netns_linux.c +++ b/lib/netns_linux.c @@ -35,10 +35,10 @@ #include "ns.h" #include "log.h" #include "memory.h" - #include "command.h" #include "vty.h" #include "vrf.h" +#include "lib_errors.h" DEFINE_MTYPE_STATIC(LIB, NS, "NetNS Context") DEFINE_MTYPE_STATIC(LIB, NS_NAME, "NetNS Name") @@ -219,8 +219,9 @@ static int ns_enable_internal(struct ns *ns, void (*func)(ns_id_t, void *)) } if (!ns_is_enabled(ns)) { - zlog_err("Can not enable NS %u: %s!", ns->ns_id, - safe_strerror(errno)); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "Can not enable NS %u: %s!", ns->ns_id, + safe_strerror(errno)); return 0; } diff --git a/lib/pid_output.c b/lib/pid_output.c index 023a166f27..21687e48c4 100644 --- a/lib/pid_output.c +++ b/lib/pid_output.c @@ -24,6 +24,7 @@ #include #include "version.h" #include "network.h" +#include "lib_errors.h" #define PIDFILE_MASK 0644 @@ -41,8 +42,9 @@ pid_t pid_output(const char *path) oldumask = umask(0777 & ~PIDFILE_MASK); fd = open(path, O_RDWR | O_CREAT, PIDFILE_MASK); if (fd < 0) { - zlog_err("Can't create pid lock file %s (%s), exiting", path, - safe_strerror(errno)); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "Can't create pid lock file %s (%s), exiting", path, + safe_strerror(errno)); umask(oldumask); exit(1); } else { @@ -57,22 +59,23 @@ pid_t pid_output(const char *path) lock.l_whence = SEEK_SET; if (fcntl(fd, F_SETLK, &lock) < 0) { - zlog_err("Could not lock pid_file %s (%s), exiting", - path, safe_strerror(errno)); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "Could not lock pid_file %s (%s), exiting", + path, safe_strerror(errno)); exit(1); } sprintf(buf, "%d\n", (int)pid); pidsize = strlen(buf); if ((tmp = write(fd, buf, pidsize)) != (int)pidsize) - zlog_err( - "Could not write pid %d to pid_file %s, rc was %d: %s", - (int)pid, path, tmp, safe_strerror(errno)); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "Could not write pid %d to pid_file %s, rc was %d: %s", + (int)pid, path, tmp, safe_strerror(errno)); else if (ftruncate(fd, pidsize) < 0) - zlog_err( - "Could not truncate pid_file %s to %u bytes: %s", - path, (unsigned int)pidsize, - safe_strerror(errno)); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "Could not truncate pid_file %s to %u bytes: %s", + path, (unsigned int)pidsize, + safe_strerror(errno)); } return pid; } diff --git a/lib/sigevent.c b/lib/sigevent.c index 59eaa80370..c6a8fcbd12 100644 --- a/lib/sigevent.c +++ b/lib/sigevent.c @@ -22,6 +22,7 @@ #include #include #include +#include #ifdef SA_SIGINFO #ifdef HAVE_UCONTEXT_H @@ -83,7 +84,8 @@ int quagga_sigevent_process(void) sigdelset(&newmask, SIGKILL); if ((sigprocmask(SIG_BLOCK, &newmask, &oldmask)) < 0) { - zlog_err("quagga_signal_timer: couldnt block signals!"); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "quagga_signal_timer: couldnt block signals!"); return -1; } #endif /* SIGEVENT_BLOCK_SIGNALS */ diff --git a/lib/sockopt.c b/lib/sockopt.c index e979bef174..1e45f20aad 100644 --- a/lib/sockopt.c +++ b/lib/sockopt.c @@ -27,6 +27,7 @@ #include "log.h" #include "sockopt.h" #include "sockunion.h" +#include "lib_errors.h" void setsockopt_so_recvbuf(int sock, int size) { @@ -61,8 +62,9 @@ int getsockopt_so_sendbuf(const int sock) int ret = getsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char *)&optval, &optlen); if (ret < 0) { - zlog_err("fd %d: can't getsockopt SO_SNDBUF: %d (%s)", sock, - errno, safe_strerror(errno)); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "fd %d: can't getsockopt SO_SNDBUF: %d (%s)", sock, + errno, safe_strerror(errno)); return ret; } return optval; @@ -670,8 +672,9 @@ int sockopt_tcp_signature(int sock, union sockunion *su, const char *password) if (ENOENT == errno) ret = 0; else - zlog_err("sockopt_tcp_signature: setsockopt(%d): %s", - sock, safe_strerror(errno)); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "sockopt_tcp_signature: setsockopt(%d): %s", + sock, safe_strerror(errno)); } return ret; #else /* HAVE_TCP_MD5SIG */ diff --git a/lib/vrf.c b/lib/vrf.c index ca0bbe1db0..17d389e6df 100644 --- a/lib/vrf.c +++ b/lib/vrf.c @@ -545,7 +545,7 @@ int vrf_socket(int domain, int type, int protocol, vrf_id_t vrf_id, ret = vrf_switch_to_netns(vrf_id); if (ret < 0) - zlog_ferr(LIB_ERR_VRF_SOCKET, + zlog_ferr(LIB_ERR_SOCKET, "%s: Can't switch to VRF %u (%s)", __func__, vrf_id, safe_strerror(errno)); @@ -560,7 +560,7 @@ int vrf_socket(int domain, int type, int protocol, vrf_id_t vrf_id, save_errno = errno; ret2 = vrf_switchback_to_initial(); if (ret2 < 0) - zlog_ferr(LIB_ERR_VRF_SOCKET, + zlog_ferr(LIB_ERR_SOCKET, "%s: Can't switchback from VRF %u (%s)", __func__, vrf_id, safe_strerror(errno)); errno = save_errno; @@ -914,14 +914,14 @@ int vrf_getaddrinfo(const char *node, const char *service, ret = vrf_switch_to_netns(vrf_id); if (ret < 0) - zlog_ferr(LIB_ERR_VRF_SOCKET, + zlog_ferr(LIB_ERR_SOCKET, "%s: Can't switch to VRF %u (%s)", __func__, vrf_id, safe_strerror(errno)); ret = getaddrinfo(node, service, hints, res); save_errno = errno; ret2 = vrf_switchback_to_initial(); if (ret2 < 0) - zlog_ferr(LIB_ERR_VRF_SOCKET, + zlog_ferr(LIB_ERR_SOCKET, "%s: Can't switchback from VRF %u (%s)", __func__, vrf_id, safe_strerror(errno)); errno = save_errno; @@ -934,7 +934,7 @@ int vrf_ioctl(vrf_id_t vrf_id, int d, unsigned long request, char *params) ret = vrf_switch_to_netns(vrf_id); if (ret < 0) { - zlog_ferr(LIB_ERR_VRF_SOCKET, + zlog_ferr(LIB_ERR_SOCKET, "%s: Can't switch to VRF %u (%s)", __func__, vrf_id, safe_strerror(errno)); return 0; @@ -943,7 +943,7 @@ int vrf_ioctl(vrf_id_t vrf_id, int d, unsigned long request, char *params) saved_errno = errno; ret = vrf_switchback_to_initial(); if (ret < 0) - zlog_ferr(LIB_ERR_VRF_SOCKET, + zlog_ferr(LIB_ERR_SOCKET, "%s: Can't switchback from VRF %u (%s)", __func__, vrf_id, safe_strerror(errno)); errno = saved_errno; @@ -957,14 +957,14 @@ int vrf_sockunion_socket(const union sockunion *su, vrf_id_t vrf_id, ret = vrf_switch_to_netns(vrf_id); if (ret < 0) - zlog_ferr(LIB_ERR_VRF_SOCKET, + zlog_ferr(LIB_ERR_SOCKET, "%s: Can't switch to VRF %u (%s)", __func__, vrf_id, safe_strerror(errno)); ret = sockunion_socket(su); save_errno = errno; ret2 = vrf_switchback_to_initial(); if (ret2 < 0) - zlog_ferr(LIB_ERR_VRF_SOCKET, + zlog_ferr(LIB_ERR_SOCKET, "%s: Can't switchback from VRF %u (%s)", __func__, vrf_id, safe_strerror(errno)); errno = save_errno; diff --git a/lib/vty.c b/lib/vty.c index 9beb254420..0b431a5c7f 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -1972,7 +1972,8 @@ static void vty_serv_sock_addrinfo(const char *hostname, unsigned short port) ret = getaddrinfo(hostname, port_str, &req, &ainfo); if (ret != 0) { - zlog_err("getaddrinfo failed: %s", gai_strerror(ret)); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "getaddrinfo failed: %s", gai_strerror(ret)); exit(1); } @@ -2032,7 +2033,8 @@ static void vty_serv_un(const char *path) /* Make UNIX domain socket. */ sock = socket(AF_UNIX, SOCK_STREAM, 0); if (sock < 0) { - zlog_err("Cannot create unix stream socket: %s", + zlog_ferr(LIB_ERR_SOCKET, + "Cannot create unix stream socket: %s", safe_strerror(errno)); return; } @@ -2051,15 +2053,18 @@ static void vty_serv_un(const char *path) ret = bind(sock, (struct sockaddr *)&serv, len); if (ret < 0) { - zlog_err("Cannot bind path %s: %s", path, safe_strerror(errno)); + zlog_ferr(LIB_ERR_SOCKET, + "Cannot bind path %s: %s", + path, safe_strerror(errno)); close(sock); /* Avoid sd leak. */ return; } ret = listen(sock, 5); if (ret < 0) { - zlog_err("listen(fd %d) failed: %s", sock, - safe_strerror(errno)); + zlog_ferr(LIB_ERR_SOCKET, + "listen(fd %d) failed: %s", sock, + safe_strerror(errno)); close(sock); /* Avoid sd leak. */ return; } @@ -2074,8 +2079,9 @@ static void vty_serv_un(const char *path) if ((int)ids.gid_vty > 0) { /* set group of socket */ if (chown(path, -1, ids.gid_vty)) { - zlog_err("vty_serv_un: could chown socket, %s", - safe_strerror(errno)); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "vty_serv_un: could chown socket, %s", + safe_strerror(errno)); } } @@ -2480,9 +2486,9 @@ bool vty_read_config(const char *config_file, char *config_default_dir) if (config_file != NULL) { if (!IS_DIRECTORY_SEP(config_file[0])) { if (getcwd(cwd, MAXPATHLEN) == NULL) { - zlog_err( - "Failure to determine Current Working Directory %d!", - errno); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "Failure to determine Current Working Directory %d!", + errno); exit(1); } tmp = XMALLOC(MTYPE_TMP, @@ -2495,7 +2501,7 @@ bool vty_read_config(const char *config_file, char *config_default_dir) confp = fopen(fullpath, "r"); if (confp == NULL) { - zlog_err("%s: failed to open configuration file %s: %s", + zlog_warn("%s: failed to open configuration file %s: %s, checking backup", __func__, fullpath, safe_strerror(errno)); confp = vty_use_backup_config(fullpath); @@ -2540,9 +2546,9 @@ bool vty_read_config(const char *config_file, char *config_default_dir) #endif /* VTYSH */ confp = fopen(config_default_dir, "r"); if (confp == NULL) { - zlog_err("%s: failed to open configuration file %s: %s", - __func__, config_default_dir, - safe_strerror(errno)); + zlog_warn("%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) { @@ -3064,12 +3070,14 @@ static void vty_save_cwd(void) * Hence not worrying about it too much. */ if (!chdir(SYSCONFDIR)) { - zlog_err("Failure to chdir to %s, errno: %d", - SYSCONFDIR, errno); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "Failure to chdir to %s, errno: %d", + SYSCONFDIR, errno); exit(-1); } if (getcwd(cwd, MAXPATHLEN) == NULL) { - zlog_err("Failure to getcwd, errno: %d", errno); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "Failure to getcwd, errno: %d", errno); exit(-1); } } -- cgit v1.2.3 From ab99c8e2b87e9d0ecfb91f6a05010948f9949cee Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 14 Jun 2018 09:21:11 -0400 Subject: lib: Add LIB_ERR_VTY Add a error code for when the vty subsystem detects an error. Signed-off-by: Donald Sharp --- lib/lib_errors.c | 6 ++++++ lib/lib_errors.h | 1 + lib/vty.c | 16 ++++++++++------ 3 files changed, 17 insertions(+), 6 deletions(-) (limited to 'lib/lib_errors.h') diff --git a/lib/lib_errors.c b/lib/lib_errors.c index f9bfa17b2e..0c36d801d8 100644 --- a/lib/lib_errors.c +++ b/lib/lib_errors.c @@ -64,6 +64,12 @@ static struct ferr_ref ferr_lib_err[] = { .description = "FRR has detected a error from using a vital system call and has probably\nalready exited", .suggestion = "Ensure permissions are correct for FRR and FRR user and groups are correct\nAdditionally check that system resources are still available" }, + { + .code = LIB_ERR_VTY, + .title = "VTY subsystem Error", + .description = "FRR has detected a problem with the specified configuration file", + .suggestion = "Ensure configuration file exists and has correct permissions for operations\nAdditionally ensure that all config lines are correct as well", + }, { .code = END_FERR, } diff --git a/lib/lib_errors.h b/lib/lib_errors.h index 24521a6008..3b5eb577b1 100644 --- a/lib/lib_errors.h +++ b/lib/lib_errors.h @@ -31,6 +31,7 @@ enum lib_ferr_refs { LIB_ERR_ZAPI_ENCODE, LIB_ERR_ZAPI_SOCKET, LIB_ERR_SYSTEM_CALL, + LIB_ERR_VTY, }; extern void lib_error_init(void); diff --git a/lib/vty.c b/lib/vty.c index 0b431a5c7f..d591ef4b5b 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -40,6 +40,7 @@ #include "network.h" #include "libfrr.h" #include "frrstr.h" +#include "lib_errors.h" #include #include @@ -2412,8 +2413,9 @@ static void vty_read_file(FILE *confp) nl = strchr(vty->error_buf, '\n'); if (nl) *nl = '\0'; - zlog_err("ERROR: %s on config line %u: %s", message, line_num, - vty->error_buf); + zlog_ferr(LIB_ERR_VTY, + "ERROR: %s on config line %u: %s", message, line_num, + vty->error_buf); } vty_close(vty); @@ -2509,8 +2511,9 @@ bool vty_read_config(const char *config_file, char *config_default_dir) zlog_warn( "WARNING: using backup configuration file!"); else { - zlog_err("can't open configuration file [%s]", - config_file); + zlog_ferr(LIB_ERR_VTY, + "can't open configuration file [%s]", + config_file); exit(1); } } @@ -2556,8 +2559,9 @@ bool vty_read_config(const char *config_file, char *config_default_dir) "WARNING: using backup configuration file!"); fullpath = config_default_dir; } else { - zlog_err("can't open configuration file [%s]", - config_default_dir); + zlog_ferr(LIB_ERR_VTY, + "can't open configuration file [%s]", + config_default_dir); goto tmp_free_and_out; } } else -- cgit v1.2.3 From 220d736886228043c8d3503eab9cc9831d9c2834 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 14 Jun 2018 09:35:09 -0400 Subject: lib: Add LIB_ERR_SNMP Add code to indicate a SNMP error of some sort that needs to be handled and addressed. Signed-off-by: Donald Sharp --- lib/agentx.c | 13 +++++++++---- lib/lib_errors.c | 6 ++++++ lib/lib_errors.h | 1 + 3 files changed, 16 insertions(+), 4 deletions(-) (limited to 'lib/lib_errors.h') diff --git a/lib/agentx.c b/lib/agentx.c index 302bbf0a42..80422c4805 100644 --- a/lib/agentx.c +++ b/lib/agentx.c @@ -31,6 +31,7 @@ #include "memory.h" #include "linklist.h" #include "version.h" +#include "lib_errors.h" static int agentx_enabled = 0; @@ -141,16 +142,20 @@ static int agentx_log_callback(int major, int minor, void *serverarg, msg[strlen(msg) - 1] = '\0'; switch (slm->priority) { case LOG_EMERG: - zlog_err("snmp[emerg]: %s", msg ? msg : slm->msg); + zlog_ferr(LIB_ERR_SNMP, + "snmp[emerg]: %s", msg ? msg : slm->msg); break; case LOG_ALERT: - zlog_err("snmp[alert]: %s", msg ? msg : slm->msg); + zlog_ferr(LIB_ERR_SNMP, + "snmp[alert]: %s", msg ? msg : slm->msg); break; case LOG_CRIT: - zlog_err("snmp[crit]: %s", msg ? msg : slm->msg); + zlog_ferr(LIB_ERR_SNMP, + "snmp[crit]: %s", msg ? msg : slm->msg); break; case LOG_ERR: - zlog_err("snmp[err]: %s", msg ? msg : slm->msg); + zlog_ferr(LIB_ERR_SNMP, + "snmp[err]: %s", msg ? msg : slm->msg); break; case LOG_WARNING: zlog_warn("snmp[warning]: %s", msg ? msg : slm->msg); diff --git a/lib/lib_errors.c b/lib/lib_errors.c index 0c36d801d8..4ae69589a2 100644 --- a/lib/lib_errors.c +++ b/lib/lib_errors.c @@ -70,6 +70,12 @@ static struct ferr_ref ferr_lib_err[] = { .description = "FRR has detected a problem with the specified configuration file", .suggestion = "Ensure configuration file exists and has correct permissions for operations\nAdditionally ensure that all config lines are correct as well", }, + { + .code = LIB_ERR_SNMP, + .title = "SNMP subsystem Error", + .description = "FRR has detected a problem with the snmp library it uses\nA callback from this subsystem has indicated some error", + .suggestion = "Examine callback message and ensure snmp is properly setup and working" + }, { .code = END_FERR, } diff --git a/lib/lib_errors.h b/lib/lib_errors.h index 3b5eb577b1..671c768eb9 100644 --- a/lib/lib_errors.h +++ b/lib/lib_errors.h @@ -32,6 +32,7 @@ enum lib_ferr_refs { LIB_ERR_ZAPI_SOCKET, LIB_ERR_SYSTEM_CALL, LIB_ERR_VTY, + LIB_ERR_SNMP, }; extern void lib_error_init(void); -- cgit v1.2.3 From 4d43f68aeb2d26d7ea5e69a97970c4a4545882c5 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 18 Jun 2018 08:49:36 -0400 Subject: lib, zebra: Add LIB_ERR_INTERFACE Add a error type that allows us to track bad interface states. Signed-off-by: Donald Sharp --- lib/if.c | 1 + lib/if.h | 12 ++++++++---- lib/lib_errors.c | 6 ++++++ lib/lib_errors.h | 1 + zebra/if_ioctl.c | 8 +++++--- zebra/if_netlink.c | 24 +++++++++++++----------- zebra/interface.c | 4 +++- 7 files changed, 37 insertions(+), 19 deletions(-) (limited to 'lib/lib_errors.h') diff --git a/lib/if.c b/lib/if.c index dd7d210381..6023624dc1 100644 --- a/lib/if.c +++ b/lib/if.c @@ -23,6 +23,7 @@ #include "linklist.h" #include "vector.h" +#include "lib_errors.h" #include "vty.h" #include "command.h" #include "vrf.h" diff --git a/lib/if.h b/lib/if.h index 7b65bbd2e5..4379e1ad8c 100644 --- a/lib/if.h +++ b/lib/if.h @@ -297,28 +297,32 @@ DECLARE_QOBJ_TYPE(interface) #define IFNAME_RB_INSERT(vrf, ifp) \ if (RB_INSERT(if_name_head, &vrf->ifaces_by_name, (ifp))) \ - zlog_err( \ + zlog_ferr( \ + LIB_ERR_INTERFACE, \ "%s(%s): corruption detected -- interface with this " \ "name exists already in VRF %u!", \ __func__, (ifp)->name, (ifp)->vrf_id); #define IFNAME_RB_REMOVE(vrf, ifp) \ if (RB_REMOVE(if_name_head, &vrf->ifaces_by_name, (ifp)) == NULL) \ - zlog_err( \ + zlog_ferr( \ + LIB_ERR_INTERFACE, \ "%s(%s): corruption detected -- interface with this " \ "name doesn't exist in VRF %u!", \ __func__, (ifp)->name, (ifp)->vrf_id); #define IFINDEX_RB_INSERT(vrf, ifp) \ if (RB_INSERT(if_index_head, &vrf->ifaces_by_index, (ifp))) \ - zlog_err( \ + zlog_ferr( \ + LIB_ERR_INTERFACE, \ "%s(%u): corruption detected -- interface with this " \ "ifindex exists already in VRF %u!", \ __func__, (ifp)->ifindex, (ifp)->vrf_id); #define IFINDEX_RB_REMOVE(vrf, ifp) \ if (RB_REMOVE(if_index_head, &vrf->ifaces_by_index, (ifp)) == NULL) \ - zlog_err( \ + zlog_ferr( \ + LIB_ERR_INTERFACE, \ "%s(%u): corruption detected -- interface with this " \ "ifindex doesn't exist in VRF %u!", \ __func__, (ifp)->ifindex, (ifp)->vrf_id); diff --git a/lib/lib_errors.c b/lib/lib_errors.c index 44d9ecd033..d1db7b777a 100644 --- a/lib/lib_errors.c +++ b/lib/lib_errors.c @@ -76,6 +76,12 @@ static struct ferr_ref ferr_lib_err[] = { .description = "FRR has detected a problem with the snmp library it uses\nA callback from this subsystem has indicated some error", .suggestion = "Examine callback message and ensure snmp is properly setup and working" }, + { + .code = LIB_ERR_INTERFACE, + .title = "Interface Subsystem Error", + .description = "FRR has detected a problem with interface data from the kernel as it deviates\nfrom what we would expect to happen via normal netlink messaging", + .suggestion = "Open an Issue with all relevant log files and restart FRR" + }, { .code = END_FERR, } diff --git a/lib/lib_errors.h b/lib/lib_errors.h index 671c768eb9..67feb68827 100644 --- a/lib/lib_errors.h +++ b/lib/lib_errors.h @@ -33,6 +33,7 @@ enum lib_ferr_refs { LIB_ERR_SYSTEM_CALL, LIB_ERR_VTY, LIB_ERR_SNMP, + LIB_ERR_INTERFACE, }; extern void lib_error_init(void); diff --git a/zebra/if_ioctl.c b/zebra/if_ioctl.c index f5ed945527..8e2e64edc6 100644 --- a/zebra/if_ioctl.c +++ b/zebra/if_ioctl.c @@ -181,7 +181,8 @@ static int if_getaddrs(void) for (ifapfree = ifap; ifap; ifap = ifap->ifa_next) { if (ifap->ifa_addr == NULL) { - zlog_err( + zlog_ferr( + LIB_ERR_INTERFACE, "%s: nonsensical ifaddr with NULL ifa_addr, ifname %s", __func__, (ifap->ifa_name ? ifap->ifa_name : "(null)")); @@ -190,8 +191,9 @@ static int if_getaddrs(void) ifp = if_lookup_by_name(ifap->ifa_name, VRF_DEFAULT); if (ifp == NULL) { - zlog_err("if_getaddrs(): Can't lookup interface %s\n", - ifap->ifa_name); + zlog_ferr(LIB_ERR_INTERFACE, + "if_getaddrs(): Can't lookup interface %s\n", + ifap->ifa_name); continue; } diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index cdf24eaf46..26aef2bb0a 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -80,9 +80,9 @@ static void set_ifindex(struct interface *ifp, ifindex_t ifi_index, if (((oifp = if_lookup_by_index_per_ns(zns, ifi_index)) != NULL) && (oifp != ifp)) { if (ifi_index == IFINDEX_INTERNAL) - zlog_err( - "Netlink is setting interface %s ifindex to reserved " - "internal value %u", + zlog_ferr( + LIB_ERR_INTERFACE, + "Netlink is setting interface %s ifindex to reserved internal value %u", ifp->name, ifi_index); else { if (IS_ZEBRA_DEBUG_KERNEL) @@ -90,9 +90,9 @@ static void set_ifindex(struct interface *ifp, ifindex_t ifi_index, "interface index %d was renamed from %s to %s", ifi_index, oifp->name, ifp->name); if (if_is_up(oifp)) - zlog_err( - "interface rename detected on up interface: index %d " - "was renamed from %s to %s, results are uncertain!", + zlog_ferr( + LIB_ERR_INTERFACE, + "interface rename detected on up interface: index %d was renamed from %s to %s, results are uncertain!", ifi_index, oifp->name, ifp->name); if_delete_update(oifp); } @@ -310,8 +310,8 @@ static void netlink_vrf_change(struct nlmsghdr *h, struct rtattr *tb, vrf = vrf_get((vrf_id_t)ifi->ifi_index, name); // It would create vrf if (!vrf) { - zlog_err("VRF %s id %u not created", name, - ifi->ifi_index); + zlog_ferr(LIB_ERR_INTERFACE, "VRF %s id %u not created", + name, ifi->ifi_index); return; } @@ -332,8 +332,9 @@ static void netlink_vrf_change(struct nlmsghdr *h, struct rtattr *tb, /* Enable the created VRF. */ if (!vrf_enable(vrf)) { - zlog_err("Failed to enable VRF %s id %u", name, - ifi->ifi_index); + zlog_ferr(LIB_ERR_INTERFACE, + "Failed to enable VRF %s id %u", name, + ifi->ifi_index); return; } @@ -916,7 +917,8 @@ int netlink_interface_addr(struct nlmsghdr *h, ns_id_t ns_id, int startup) ifp = if_lookup_by_index_per_ns(zns, ifa->ifa_index); if (ifp == NULL) { - zlog_err( + zlog_ferr( + LIB_ERR_INTERFACE, "netlink_interface_addr can't find interface by index %d", ifa->ifa_index); return -1; diff --git a/zebra/interface.c b/zebra/interface.c index 4211155c27..9811badfc4 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -22,6 +22,7 @@ #include #include "if.h" +#include "lib_errors.h" #include "vty.h" #include "sockunion.h" #include "prefix.h" @@ -718,7 +719,8 @@ void if_delete_update(struct interface *ifp) struct zebra_if *zif; if (if_is_up(ifp)) { - zlog_err( + zlog_ferr( + LIB_ERR_INTERFACE, "interface %s vrf %u index %d is still up while being deleted.", ifp->name, ifp->vrf_id, ifp->ifindex); return; -- cgit v1.2.3 From 674c3ca8a837bf732a6a6062bea23a3ec745d971 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 18 Jun 2018 08:55:06 -0400 Subject: lib: Add LIB_ERR_NS to error subsystem Add additional information about NameSpace errors that may happen. Signed-off-by: Donald Sharp --- lib/lib_errors.c | 6 ++++++ lib/lib_errors.h | 1 + lib/netns_linux.c | 16 ++++++++++------ 3 files changed, 17 insertions(+), 6 deletions(-) (limited to 'lib/lib_errors.h') diff --git a/lib/lib_errors.c b/lib/lib_errors.c index d1db7b777a..71ff53053e 100644 --- a/lib/lib_errors.c +++ b/lib/lib_errors.c @@ -82,6 +82,12 @@ static struct ferr_ref ferr_lib_err[] = { .description = "FRR has detected a problem with interface data from the kernel as it deviates\nfrom what we would expect to happen via normal netlink messaging", .suggestion = "Open an Issue with all relevant log files and restart FRR" }, + { + .code = LIB_ERR_NS, + .title = "NameSpace Subsystem Error", + .description = "FRR has detected a problem with NameSpace data from the kernel as it deviates\nfrom what we would expect to happen via normal kernel messaging", + .suggestion = "Open an Issue with all relevant log files and restart FRR" + }, { .code = END_FERR, } diff --git a/lib/lib_errors.h b/lib/lib_errors.h index 67feb68827..e4ab88e994 100644 --- a/lib/lib_errors.h +++ b/lib/lib_errors.h @@ -34,6 +34,7 @@ enum lib_ferr_refs { LIB_ERR_VTY, LIB_ERR_SNMP, LIB_ERR_INTERFACE, + LIB_ERR_NS, }; extern void lib_error_init(void); diff --git a/lib/netns_linux.c b/lib/netns_linux.c index 801264d1a8..3a24e511ae 100644 --- a/lib/netns_linux.c +++ b/lib/netns_linux.c @@ -227,8 +227,9 @@ static int ns_enable_internal(struct ns *ns, void (*func)(ns_id_t, void *)) /* Non default NS. leave */ if (ns->ns_id == NS_UNKNOWN) { - zlog_err("Can not enable NS %s %u: Invalid NSID", - ns->name, ns->ns_id); + zlog_ferr(LIB_ERR_NS, + "Can not enable NS %s %u: Invalid NSID", + ns->name, ns->ns_id); return 0; } if (func) @@ -471,8 +472,9 @@ void ns_init(void) if (have_netns_enabled < 0) { ns_default_ns_fd = open(NS_DEFAULT_NAME, O_RDONLY); if (ns_default_ns_fd == -1) - zlog_err("NS initialization failure %d(%s)", - errno, safe_strerror(errno)); + zlog_ferr(LIB_ERR_NS, + "NS initialization failure %d(%s)", errno, + safe_strerror(errno)); } else { ns_default_ns_fd = -1; default_ns = NULL; @@ -493,7 +495,8 @@ void ns_init_management(ns_id_t default_ns_id, ns_id_t internal_ns) ns_init(); default_ns = ns_get_created_internal(NULL, NULL, default_ns_id); if (!default_ns) { - zlog_err("%s: failed to create the default NS!", __func__); + zlog_ferr(LIB_ERR_NS, "%s: failed to create the default NS!", + __func__); exit(1); } if (have_netns()) { @@ -510,7 +513,8 @@ void ns_init_management(ns_id_t default_ns_id, ns_id_t internal_ns) /* Enable the default NS. */ if (!ns_enable(default_ns, NULL)) { - zlog_err("%s: failed to enable the default NS!", __func__); + zlog_ferr(LIB_ERR_NS, "%s: failed to enable the default NS!", + __func__); exit(1); } } -- cgit v1.2.3 From 472878dc0fdd5e17500e8a6ba8a65d13e36d9467 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 18 Jun 2018 09:13:37 -0400 Subject: lib: Add LIB_ERR_DEVELOPMENT Sometimes a error state is detected when we have added new code to FRR, but not updated all the places that we should have. Consider this a developmental escape that needs to be fixed. Signed-off-by: Donald Sharp --- lib/buffer.c | 6 +++--- lib/lib_errors.c | 6 ++++++ lib/lib_errors.h | 2 +- lib/log.c | 10 +++++++--- lib/prefix.c | 6 ++++-- lib/skiplist.c | 4 +++- lib/vty.c | 6 +++--- 7 files changed, 27 insertions(+), 13 deletions(-) (limited to 'lib/lib_errors.h') diff --git a/lib/buffer.c b/lib/buffer.c index 207f2320ff..acdaf07bbc 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -458,9 +458,9 @@ in one shot. */ while (written > 0) { struct buffer_data *d; if (!(d = b->head)) { - zlog_err( - "%s: corruption detected: buffer queue empty, " - "but written is %lu", + zlog_ferr( + LIB_ERR_DEVELOPMENT, + "%s: corruption detected: buffer queue empty, but written is %lu", __func__, (unsigned long)written); break; } diff --git a/lib/lib_errors.c b/lib/lib_errors.c index 71ff53053e..ae4635673f 100644 --- a/lib/lib_errors.c +++ b/lib/lib_errors.c @@ -88,6 +88,12 @@ static struct ferr_ref ferr_lib_err[] = { .description = "FRR has detected a problem with NameSpace data from the kernel as it deviates\nfrom what we would expect to happen via normal kernel messaging", .suggestion = "Open an Issue with all relevant log files and restart FRR" }, + { + .code = LIB_ERR_DEVELOPMENT, + .title = "Developmental Escape Error", + .description = "FRR has detected an issue where new development has not properly\nupdated all code paths.", + .suggestion = "Open an Issue with all relevant log files" + }, { .code = END_FERR, } diff --git a/lib/lib_errors.h b/lib/lib_errors.h index e4ab88e994..bb83c45e67 100644 --- a/lib/lib_errors.h +++ b/lib/lib_errors.h @@ -21,7 +21,6 @@ #define __LIB_ERRORS_H__ #include "ferr.h" -#include "lib_errors.h" enum lib_ferr_refs { LIB_ERR_PRIVILEGES = LIB_FERR_START, @@ -35,6 +34,7 @@ enum lib_ferr_refs { LIB_ERR_SNMP, LIB_ERR_INTERFACE, LIB_ERR_NS, + LIB_ERR_DEVELOPMENT, }; extern void lib_error_init(void); diff --git a/lib/log.c b/lib/log.c index afecbef19c..6aa718c953 100644 --- a/lib/log.c +++ b/lib/log.c @@ -987,7 +987,8 @@ static const struct zebra_desc_table *zroute_lookup(unsigned int zroute) unsigned int i; if (zroute >= array_size(route_types)) { - zlog_err("unknown zebra route type: %u", zroute); + zlog_ferr(LIB_ERR_DEVELOPMENT, "unknown zebra route type: %u", + zroute); return &unknown; } if (zroute == route_types[zroute].type) @@ -1001,7 +1002,9 @@ static const struct zebra_desc_table *zroute_lookup(unsigned int zroute) return &route_types[i]; } } - zlog_err("internal error: cannot find route type %u in table!", zroute); + zlog_ferr(LIB_ERR_DEVELOPMENT, + "internal error: cannot find route type %u in table!", + zroute); return &unknown; } @@ -1018,7 +1021,8 @@ char zebra_route_char(unsigned int zroute) const char *zserv_command_string(unsigned int command) { if (command >= array_size(command_types)) { - zlog_err("unknown zserv command type: %u", command); + zlog_ferr(LIB_ERR_DEVELOPMENT, "unknown zserv command type: %u", + command); return unknown.string; } return command_types[command].string; diff --git a/lib/prefix.c b/lib/prefix.c index 751f20cb83..fe4f360fb2 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -27,6 +27,7 @@ #include "memory.h" #include "log.h" #include "jhash.h" +#include "lib_errors.h" DEFINE_MTYPE_STATIC(LIB, PREFIX, "Prefix") @@ -656,8 +657,9 @@ void prefix_copy(struct prefix *dest, const struct prefix *src) memcpy((void *)dest->u.prefix_flowspec.ptr, (void *)src->u.prefix_flowspec.ptr, len); } else { - zlog_err("prefix_copy(): Unknown address family %d", - src->family); + zlog_ferr(LIB_ERR_DEVELOPMENT, + "prefix_copy(): Unknown address family %d", + src->family); assert(0); } } diff --git a/lib/skiplist.c b/lib/skiplist.c index a546bb44c0..d2b3acc971 100644 --- a/lib/skiplist.c +++ b/lib/skiplist.c @@ -60,6 +60,7 @@ #include "log.h" #include "vty.h" #include "skiplist.h" +#include "lib_errors.h" DEFINE_MTYPE_STATIC(LIB, SKIP_LIST, "Skip List") DEFINE_MTYPE_STATIC(LIB, SKIP_LIST_NODE, "Skip Node") @@ -182,7 +183,8 @@ int skiplist_insert(register struct skiplist *l, register void *key, /* DEBUG */ if (!key) { - zlog_err("%s: key is 0, value is %p", __func__, value); + zlog_ferr(LIB_ERR_DEVELOPMENT, "%s: key is 0, value is %p", + __func__, value); } p = l->header; diff --git a/lib/vty.c b/lib/vty.c index d591ef4b5b..30db2d0930 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -1330,9 +1330,9 @@ static int vty_telnet_option(struct vty *vty, unsigned char *buf, int nbytes) TELNET_NAWS_SB_LEN, (unsigned long)vty->sb_len); else if (sizeof(vty->sb_buf) < TELNET_NAWS_SB_LEN) - zlog_err( - "Bug detected: sizeof(vty->sb_buf) %lu < %d, " - "too small to handle the telnet NAWS option", + zlog_ferr( + LIB_ERR_DEVELOPMENT, + "Bug detected: sizeof(vty->sb_buf) %lu < %d, too small to handle the telnet NAWS option", (unsigned long)sizeof(vty->sb_buf), TELNET_NAWS_SB_LEN); else { -- cgit v1.2.3 From 357743576d39f756849cd01e4fdd23f350a89370 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 18 Jun 2018 09:25:03 -0400 Subject: lib: Add LIB_ERR_ZMQ Add new error event for when we detect an issue within the ZMQ subsystem. Signed-off-by: Donald Sharp --- lib/frr_zmq.c | 7 +++++-- lib/lib_errors.c | 6 ++++++ lib/lib_errors.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) (limited to 'lib/lib_errors.h') diff --git a/lib/frr_zmq.c b/lib/frr_zmq.c index 3153e697fa..c479543ce4 100644 --- a/lib/frr_zmq.c +++ b/lib/frr_zmq.c @@ -24,6 +24,7 @@ #include "memory.h" #include "frr_zmq.h" #include "log.h" +#include "lib_errors.h" DEFINE_MTYPE_STATIC(LIB, ZEROMQ_CB, "ZeroMQ callback") @@ -140,7 +141,8 @@ static int frrzmq_read_msg(struct thread *t) return 0; out_err: - zlog_err("ZeroMQ read error: %s(%d)", strerror(errno), errno); + zlog_ferr(LIB_ERR_ZMQ, "ZeroMQ read error: %s(%d)", strerror(errno), + errno); if (cb->read.cb_error) cb->read.cb_error(cb->read.arg, cb->zmqsock); return 1; @@ -253,7 +255,8 @@ static int frrzmq_write_msg(struct thread *t) return 0; out_err: - zlog_err("ZeroMQ write error: %s(%d)", strerror(errno), errno); + zlog_ferr(LIB_ERR_ZMQ, "ZeroMQ write error: %s(%d)", strerror(errno), + errno); if (cb->write.cb_error) cb->write.cb_error(cb->write.arg, cb->zmqsock); return 1; diff --git a/lib/lib_errors.c b/lib/lib_errors.c index ae4635673f..d45e21ddc8 100644 --- a/lib/lib_errors.c +++ b/lib/lib_errors.c @@ -94,6 +94,12 @@ static struct ferr_ref ferr_lib_err[] = { .description = "FRR has detected an issue where new development has not properly\nupdated all code paths.", .suggestion = "Open an Issue with all relevant log files" }, + { + .code = LIB_ERR_ZMQ, + .title = "ZMQ Subsystem Error", + .description = "FRR has detected an issue with the Zero MQ subsystem and ZeroMQ\nis not working properly now", + .suggestion = "Open an Issue with all relevant log files and restart FRR" + }, { .code = END_FERR, } diff --git a/lib/lib_errors.h b/lib/lib_errors.h index bb83c45e67..5a68efb30c 100644 --- a/lib/lib_errors.h +++ b/lib/lib_errors.h @@ -35,6 +35,7 @@ enum lib_ferr_refs { LIB_ERR_INTERFACE, LIB_ERR_NS, LIB_ERR_DEVELOPMENT, + LIB_ERR_ZMQ, }; extern void lib_error_init(void); -- cgit v1.2.3 From 43e52561b476e4810e0a1280769e800e2d619621 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Tue, 19 Jun 2018 18:29:05 +0000 Subject: zebra, lib: error references for zebra Signed-off-by: Quentin Young --- lib/bfd.h | 1 + lib/lib_errors.c | 8 ++ lib/lib_errors.h | 1 + lib/mpls.h | 1 + zebra/connected.h | 6 + zebra/debug.h | 2 + zebra/if_ioctl.c | 4 +- zebra/ioctl.c | 23 ++-- zebra/ioctl_solaris.c | 9 +- zebra/ipforward_solaris.c | 8 +- zebra/irdp_interface.c | 23 ++-- zebra/irdp_main.c | 13 ++- zebra/irdp_packet.c | 47 ++++---- zebra/kernel_netlink.c | 94 ++++++++------- zebra/kernel_socket.c | 5 +- zebra/label_manager.c | 47 +++++--- zebra/main.c | 4 +- zebra/rt_socket.c | 8 +- zebra/rtadv.c | 20 ++-- zebra/rule_socket.c | 6 +- zebra/subdir.am | 2 + zebra/table_manager.c | 12 +- zebra/zapi_msg.c | 50 +++++--- zebra/zapi_msg.h | 1 + zebra/zebra_errors.c | 276 +++++++++++++++++++++++++++++++++++++++++++++ zebra/zebra_errors.h | 74 ++++++++++++ zebra/zebra_fpm.c | 7 +- zebra/zebra_mpls.c | 33 ++++-- zebra/zebra_mpls_openbsd.c | 20 ++-- zebra/zebra_netns_id.c | 29 +++-- zebra/zebra_ptm.c | 44 ++++---- zebra/zebra_rib.c | 74 +++++++----- zebra/zebra_rnh.c | 6 +- zebra/zebra_vxlan.c | 204 +++++++++++++++++---------------- 34 files changed, 829 insertions(+), 333 deletions(-) create mode 100644 zebra/zebra_errors.c create mode 100644 zebra/zebra_errors.h (limited to 'lib/lib_errors.h') diff --git a/lib/bfd.h b/lib/bfd.h index 94430051a8..f824b0fd9b 100644 --- a/lib/bfd.h +++ b/lib/bfd.h @@ -24,6 +24,7 @@ #define _ZEBRA_BFD_H #include "lib/json.h" +#include "lib/zclient.h" #define BFD_DEF_MIN_RX 300 #define BFD_MIN_MIN_RX 50 diff --git a/lib/lib_errors.c b/lib/lib_errors.c index d45e21ddc8..1faee603c2 100644 --- a/lib/lib_errors.c +++ b/lib/lib_errors.c @@ -21,6 +21,7 @@ #include #include +/* clang-format off */ static struct ferr_ref ferr_lib_err[] = { { .code = LIB_ERR_PRIVILEGES, @@ -100,10 +101,17 @@ static struct ferr_ref ferr_lib_err[] = { .description = "FRR has detected an issue with the Zero MQ subsystem and ZeroMQ\nis not working properly now", .suggestion = "Open an Issue with all relevant log files and restart FRR" }, + { + .code = LIB_ERR_UNAVAILABLE, + .title = "Feature or system unavailable", + .description = "FRR was not compiled with support for a particular feature, or it is not available on the current platform", + .suggestion = "Recompile FRR with the feature enabled, or find out what platforms support the feature" + }, { .code = END_FERR, } }; +/* clang-format on */ void lib_error_init(void) { diff --git a/lib/lib_errors.h b/lib/lib_errors.h index 5a68efb30c..9e3383793a 100644 --- a/lib/lib_errors.h +++ b/lib/lib_errors.h @@ -36,6 +36,7 @@ enum lib_ferr_refs { LIB_ERR_NS, LIB_ERR_DEVELOPMENT, LIB_ERR_ZMQ, + LIB_ERR_UNAVAILABLE, }; extern void lib_error_init(void); diff --git a/lib/mpls.h b/lib/mpls.h index ff6f1d6c98..c9dd60dce0 100644 --- a/lib/mpls.h +++ b/lib/mpls.h @@ -22,6 +22,7 @@ #ifndef _QUAGGA_MPLS_H #define _QUAGGA_MPLS_H +#include #include #ifdef MPLS_LABEL_MAX diff --git a/zebra/connected.h b/zebra/connected.h index 2a2b093395..75b6e05bda 100644 --- a/zebra/connected.h +++ b/zebra/connected.h @@ -22,6 +22,12 @@ #ifndef _ZEBRA_CONNECTED_H #define _ZEBRA_CONNECTED_H +#include +#include + +#include "lib/if.h" +#include "lib/prefix.h" + extern struct connected *connected_check(struct interface *ifp, union prefixconstptr p); extern struct connected *connected_check_ptp(struct interface *ifp, diff --git a/zebra/debug.h b/zebra/debug.h index 1c08459e26..e74afe476b 100644 --- a/zebra/debug.h +++ b/zebra/debug.h @@ -22,6 +22,8 @@ #ifndef _ZEBRA_DEBUG_H #define _ZEBRA_DEBUG_H +#include "lib/vty.h" + /* Debug flags. */ #define ZEBRA_DEBUG_EVENT 0x01 diff --git a/zebra/if_ioctl.c b/zebra/if_ioctl.c index 8e2e64edc6..7045d51283 100644 --- a/zebra/if_ioctl.c +++ b/zebra/if_ioctl.c @@ -33,6 +33,7 @@ #include "log.h" #include "vrf.h" #include "vty.h" +#include "lib_errors.h" #include "zebra/interface.h" #include "zebra/rib.h" @@ -175,7 +176,8 @@ static int if_getaddrs(void) ret = getifaddrs(&ifap); if (ret != 0) { - zlog_err("getifaddrs(): %s", safe_strerror(errno)); + zlog_ferr(LIB_ERR_SYSTEM_CALL, "getifaddrs(): %s", + safe_strerror(errno)); return -1; } diff --git a/zebra/ioctl.c b/zebra/ioctl.c index 981393965f..aee3abf31a 100644 --- a/zebra/ioctl.c +++ b/zebra/ioctl.c @@ -63,8 +63,8 @@ int if_ioctl(unsigned long request, caddr_t buffer) if (zserv_privs.change(ZPRIVS_LOWER)) zlog_ferr(LIB_ERR_PRIVILEGES, "Can't lower privileges"); - zlog_err("Cannot create UDP socket: %s", - safe_strerror(save_errno)); + zlog_ferr(LIB_ERR_SOCKET, "Cannot create UDP socket: %s", + safe_strerror(save_errno)); exit(1); } if ((ret = ioctl(sock, request, buffer)) < 0) @@ -95,8 +95,8 @@ int vrf_if_ioctl(unsigned long request, caddr_t buffer, vrf_id_t vrf_id) if (zserv_privs.change(ZPRIVS_LOWER)) zlog_ferr(LIB_ERR_PRIVILEGES, "Can't lower privileges"); - zlog_err("Cannot create UDP socket: %s", - safe_strerror(save_errno)); + zlog_ferr(LIB_ERR_SOCKET, "Cannot create UDP socket: %s", + safe_strerror(save_errno)); exit(1); } ret = vrf_ioctl(vrf_id, sock, request, buffer); @@ -128,8 +128,9 @@ static int if_ioctl_ipv6(unsigned long request, caddr_t buffer) if (zserv_privs.change(ZPRIVS_LOWER)) zlog_ferr(LIB_ERR_PRIVILEGES, "Can't lower privileges"); - zlog_err("Cannot create IPv6 datagram socket: %s", - safe_strerror(save_errno)); + zlog_ferr(LIB_ERR_SOCKET, + "Cannot create IPv6 datagram socket: %s", + safe_strerror(save_errno)); exit(1); } @@ -414,8 +415,9 @@ void if_get_flags(struct interface *ifp) ret = vrf_if_ioctl(SIOCGIFFLAGS, (caddr_t)&ifreq, ifp->vrf_id); if (ret < 0) { - zlog_err("vrf_if_ioctl(SIOCGIFFLAGS) failed: %s", - safe_strerror(errno)); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "vrf_if_ioctl(SIOCGIFFLAGS) failed: %s", + safe_strerror(errno)); return; } #ifdef HAVE_BSD_LINK_DETECT /* Detect BSD link-state at start-up */ @@ -432,8 +434,9 @@ void if_get_flags(struct interface *ifp) /* Seems not all interfaces implement this ioctl */ if (if_ioctl(SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) - zlog_err("if_ioctl(SIOCGIFMEDIA) failed: %s", - safe_strerror(errno)); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "if_ioctl(SIOCGIFMEDIA) failed: %s", + safe_strerror(errno)); else if (ifmr.ifm_status & IFM_AVALID) /* Link state is valid */ { if (ifmr.ifm_status & IFM_ACTIVE) diff --git a/zebra/ioctl_solaris.c b/zebra/ioctl_solaris.c index 24f5fde794..1e24e3fbf6 100644 --- a/zebra/ioctl_solaris.c +++ b/zebra/ioctl_solaris.c @@ -66,8 +66,8 @@ int if_ioctl(unsigned long request, caddr_t buffer) int save_errno = errno; if (zserv_privs.change(ZPRIVS_LOWER)) zlog_ferr(LIB_ERR_PRIVILEGES, "Can't lower privileges"); - zlog_err("Cannot create UDP socket: %s", - safe_strerror(save_errno)); + zlog_ferr(LIB_ERR_SOCKET, "Cannot create UDP socket: %s", + safe_strerror(save_errno)); exit(1); } @@ -101,8 +101,9 @@ int if_ioctl_ipv6(unsigned long request, caddr_t buffer) int save_errno = errno; if (zserv_privs.change(ZPRIVS_LOWER)) zlog_ferr(LIB_ERR_PRIVILEGES, "Can't lower privileges"); - zlog_err("Cannot create IPv6 datagram socket: %s", - safe_strerror(save_errno)); + zlog_ferr(LIB_ERR_SOCKET, + "Cannot create IPv6 datagram socket: %s", + safe_strerror(save_errno)); exit(1); } diff --git a/zebra/ipforward_solaris.c b/zebra/ipforward_solaris.c index 36e2211dae..9fc46b25da 100644 --- a/zebra/ipforward_solaris.c +++ b/zebra/ipforward_solaris.c @@ -70,10 +70,10 @@ static int solaris_nd(const int cmd, const char *parameter, const int value) else if (cmd == ND_GET) snprintf(nd_buf, ND_BUFFER_SIZE, "%s", parameter); else { - zlog_err( - "internal error - inappropriate command given to " - "solaris_nd()%s:%d", - __FILE__, __LINE__); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "internal error - inappropriate command given to " + "solaris_nd()%s:%d", + __FILE__, __LINE__); return -1; } diff --git a/zebra/irdp_interface.c b/zebra/irdp_interface.c index ca78404797..f02ba1fa2f 100644 --- a/zebra/irdp_interface.c +++ b/zebra/irdp_interface.c @@ -1,7 +1,13 @@ /* * - * Copyright (C) 2000 Robert Olsson. - * Swedish University of Agricultural Sciences + * Copyright (C) 1997, 2000 + * Portions: + * Swedish University of Agricultural Sciences + * Robert Olsson + * Kunihiro Ishiguro + * + * Thanks to Jens Laas at Swedish University of Agricultural Sciences + * for reviewing and tests. * * This file is part of GNU Zebra. * @@ -20,19 +26,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* - * This work includes work with the following copywrite: - * - * Copyright (C) 1997, 2000 Kunihiro Ishiguro - * - */ - -/* - * Thanks to Jens Låås at Swedish University of Agricultural Sciences - * for reviewing and tests. - */ - - #include #include "if.h" diff --git a/zebra/irdp_main.c b/zebra/irdp_main.c index c2411d083f..8efbdcf480 100644 --- a/zebra/irdp_main.c +++ b/zebra/irdp_main.c @@ -28,7 +28,7 @@ */ /* - * Thanks to Jens Låås at Swedish University of Agricultural Sciences + * Thanks to Jens Laas at Swedish University of Agricultural Sciences * for reviewing and tests. */ @@ -51,6 +51,7 @@ #include "thread.h" #include "privs.h" #include "libfrr.h" +#include "lib_errors.h" #include "version.h" #include "zebra/interface.h" #include "zebra/rtadv.h" @@ -81,15 +82,17 @@ int irdp_sock_init(void) int sock; if (zserv_privs.change(ZPRIVS_RAISE)) - zlog_err("irdp_sock_init: could not raise privs, %s", - safe_strerror(errno)); + zlog_ferr(LIB_ERR_PRIVILEGES, + "irdp_sock_init: could not raise privs, %s", + safe_strerror(errno)); sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); save_errno = errno; if (zserv_privs.change(ZPRIVS_LOWER)) - zlog_err("irdp_sock_init: could not lower privs, %s", - safe_strerror(errno)); + zlog_ferr(LIB_ERR_PRIVILEGES, + "irdp_sock_init: could not lower privs, %s", + safe_strerror(errno)); if (sock < 0) { zlog_warn("IRDP: can't create irdp socket %s", diff --git a/zebra/irdp_packet.c b/zebra/irdp_packet.c index b0dde96cce..31467e51e0 100644 --- a/zebra/irdp_packet.c +++ b/zebra/irdp_packet.c @@ -28,39 +28,39 @@ */ /* - * Thanks to Jens Låås at Swedish University of Agricultural Sciences + * Thanks to Jens Laas at Swedish University of Agricultural Sciences * for reviewing and tests. */ #include +#include - -#include "if.h" -#include "vty.h" -#include "sockunion.h" -#include "prefix.h" +#include "checksum.h" #include "command.h" -#include "memory.h" -#include "zebra_memory.h" -#include "stream.h" -#include "ioctl.h" #include "connected.h" +#include "if.h" +#include "ioctl.h" #include "log.h" -#include "zclient.h" +#include "log.h" +#include "memory.h" +#include "prefix.h" +#include "sockopt.h" +#include "sockunion.h" +#include "sockunion.h" +#include "stream.h" #include "thread.h" +#include "vty.h" +#include "zclient.h" + +#include "zebra_memory.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 -#include "if.h" -#include "checksum.h" -#include "sockunion.h" -#include "log.h" -#include "sockopt.h" +#include "zebra/zebra_errors.h" /* GLOBAL VARS */ @@ -95,13 +95,15 @@ static void parse_irdp_packet(char *p, int len, struct interface *ifp) src = ip->ip_src; if (len != iplen) { - zlog_err("IRDP: RX length doesnt match IP length"); + zlog_ferr(ZEBRA_ERR_IRDP_LEN_MISMATCH, + "IRDP: RX length doesnt match IP length"); return; } if (iplen < ICMP_MINLEN) { - zlog_err("IRDP: RX ICMP packet too short from %s\n", - inet_ntoa(src)); + zlog_ferr(ZEBRA_ERR_IRDP_LEN_MISMATCH, + "IRDP: RX ICMP packet too short from %s\n", + inet_ntoa(src)); return; } @@ -110,8 +112,9 @@ static void parse_irdp_packet(char *p, int len, struct interface *ifp) + len of IP-header) 14+20 */ if (iplen > IRDP_RX_BUF - 34) { - zlog_err("IRDP: RX ICMP packet too long from %s\n", - inet_ntoa(src)); + zlog_ferr(ZEBRA_ERR_IRDP_LEN_MISMATCH, + "IRDP: RX ICMP packet too long from %s\n", + inet_ntoa(src)); return; } diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c index c733b52fc3..de0e8af664 100644 --- a/zebra/kernel_netlink.c +++ b/zebra/kernel_netlink.c @@ -52,6 +52,7 @@ #include "zebra/rt_netlink.h" #include "zebra/if_netlink.h" #include "zebra/rule_netlink.h" +#include "zebra/zebra_errors.h" #ifndef SO_RCVBUFFORCE #define SO_RCVBUFFORCE (33) @@ -148,9 +149,8 @@ int netlink_talk_filter(struct nlmsghdr *h, ns_id_t ns_id, int startup) * received some other message in an unexpected * way. */ - zlog_err("%s: ignoring message type 0x%04x(%s) NS %u", - __PRETTY_FUNCTION__, h->nlmsg_type, - nl_msg_type_to_str(h->nlmsg_type), ns_id); + zlog_debug("%s: ignoring message type 0x%04x(%s) NS %u", __func__, + h->nlmsg_type, nl_msg_type_to_str(h->nlmsg_type), ns_id); return 0; } @@ -163,8 +163,9 @@ static int netlink_recvbuf(struct nlsock *nl, uint32_t newsize) ret = getsockopt(nl->sock, SOL_SOCKET, SO_RCVBUF, &oldsize, &oldlen); if (ret < 0) { - zlog_err("Can't get %s receive buffer size: %s", nl->name, - safe_strerror(errno)); + zlog_ferr(LIB_ERR_SOCKET, + "Can't get %s receive buffer size: %s", nl->name, + safe_strerror(errno)); return -1; } @@ -181,15 +182,17 @@ static int netlink_recvbuf(struct nlsock *nl, uint32_t newsize) ret = setsockopt(nl->sock, SOL_SOCKET, SO_RCVBUF, &nl_rcvbufsize, sizeof(nl_rcvbufsize)); if (ret < 0) { - zlog_err("Can't set %s receive buffer size: %s", nl->name, - safe_strerror(errno)); + zlog_ferr(LIB_ERR_SOCKET, + "Can't set %s receive buffer size: %s", nl->name, + safe_strerror(errno)); return -1; } ret = getsockopt(nl->sock, SOL_SOCKET, SO_RCVBUF, &newsize, &newlen); if (ret < 0) { - zlog_err("Can't get %s receive buffer size: %s", nl->name, - safe_strerror(errno)); + zlog_ferr(LIB_ERR_SOCKET, + "Can't get %s receive buffer size: %s", nl->name, + safe_strerror(errno)); return -1; } @@ -215,8 +218,8 @@ static int netlink_socket(struct nlsock *nl, unsigned long groups, sock = ns_socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE, ns_id); if (sock < 0) { - zlog_err("Can't open %s socket: %s", nl->name, - safe_strerror(errno)); + zlog_ferr(LIB_ERR_SOCKET, "Can't open %s socket: %s", nl->name, + safe_strerror(errno)); return -1; } @@ -231,8 +234,9 @@ static int netlink_socket(struct nlsock *nl, unsigned long groups, zlog_ferr(LIB_ERR_PRIVILEGES, "Can't lower privileges"); if (ret < 0) { - zlog_err("Can't bind %s socket to group 0x%x: %s", nl->name, - snl.nl_groups, safe_strerror(save_errno)); + zlog_ferr(LIB_ERR_SOCKET, + "Can't bind %s socket to group 0x%x: %s", nl->name, + snl.nl_groups, safe_strerror(save_errno)); close(sock); return -1; } @@ -241,8 +245,8 @@ static int netlink_socket(struct nlsock *nl, unsigned long groups, namelen = sizeof snl; ret = getsockname(sock, (struct sockaddr *)&snl, (socklen_t *)&namelen); if (ret < 0 || namelen != sizeof snl) { - zlog_err("Can't get %s socket name: %s", nl->name, - safe_strerror(errno)); + zlog_ferr(LIB_ERR_SOCKET, "Can't get %s socket name: %s", + nl->name, safe_strerror(errno)); close(sock); return -1; } @@ -293,9 +297,10 @@ static int netlink_information_fetch(struct nlmsghdr *h, ns_id_t ns_id, * this message type or not ask for * it to be sent up to us */ - zlog_err("Unknown netlink nlmsg_type %s(%d) vrf %u\n", - nl_msg_type_to_str(h->nlmsg_type), h->nlmsg_type, - ns_id); + zlog_ferr(ZEBRA_ERR_UNKNOWN_NLMSG, + "Unknown netlink nlmsg_type %s(%d) vrf %u\n", + nl_msg_type_to_str(h->nlmsg_type), h->nlmsg_type, + ns_id); break; } return 0; @@ -702,8 +707,9 @@ int netlink_parse_info(int (*filter)(struct nlmsghdr *, ns_id_t, int), continue; if (errno == EWOULDBLOCK || errno == EAGAIN) break; - zlog_err("%s recvmsg overrun: %s", nl->name, - safe_strerror(errno)); + zlog_ferr(ZEBRA_ERR_RECVMSG_OVERRUN, + "%s recvmsg overrun: %s", nl->name, + safe_strerror(errno)); /* * In this case we are screwed. * There is no good way to @@ -714,13 +720,14 @@ int netlink_parse_info(int (*filter)(struct nlmsghdr *, ns_id_t, int), } if (status == 0) { - zlog_err("%s EOF", nl->name); + zlog_ferr(LIB_ERR_SOCKET, "%s EOF", nl->name); return -1; } if (msg.msg_namelen != sizeof snl) { - zlog_err("%s sender address length error: length %d", - nl->name, msg.msg_namelen); + zlog_ferr(ZEBRA_ERR_NETLINK_LENGTH_ERROR, + "%s sender address length error: length %d", + nl->name, msg.msg_namelen); return -1; } @@ -791,6 +798,15 @@ int netlink_parse_info(int (*filter)(struct nlmsghdr *, ns_id_t, int), continue; } + if (h->nlmsg_len + < NLMSG_LENGTH(sizeof(struct nlmsgerr))) { + zlog_ferr( + ZEBRA_ERR_NETLINK_LENGTH_ERROR, + "%s error: message truncated", + nl->name); + return -1; + } + /* Deal with errors that occur because of races * in link handling */ if (nl == &zns->netlink_cmd @@ -839,7 +855,8 @@ int netlink_parse_info(int (*filter)(struct nlmsghdr *, ns_id_t, int), err->msg.nlmsg_seq, err->msg.nlmsg_pid); } else - zlog_err( + zlog_ferr( + ZEBRA_ERR_UNEXPECTED_MESSAGE, "%s error: %s, type=%s(%u), seq=%u, pid=%u", nl->name, safe_strerror(-errnum), @@ -865,27 +882,28 @@ int netlink_parse_info(int (*filter)(struct nlmsghdr *, ns_id_t, int), * other actors besides the kernel */ if (snl.nl_pid != 0) { - zlog_err("Ignoring message from pid %u", - snl.nl_pid); + zlog_debug("Ignoring message from pid %u", + snl.nl_pid); continue; } error = (*filter)(h, zns->ns_id, startup); if (error < 0) { - zlog_err("%s filter function error", nl->name); - zlog_backtrace(LOG_ERR); + zlog_warn("%s filter function error", nl->name); ret = error; } } /* After error care. */ if (msg.msg_flags & MSG_TRUNC) { - zlog_err("%s error: message truncated", nl->name); + zlog_ferr(ZEBRA_ERR_NETLINK_LENGTH_ERROR, + "%s error: message truncated", nl->name); continue; } if (status) { - zlog_err("%s error: data remnant size %d", nl->name, - status); + zlog_ferr(ZEBRA_ERR_NETLINK_LENGTH_ERROR, + "%s error: data remnant size %d", nl->name, + status); return -1; } } @@ -952,8 +970,8 @@ int netlink_talk(int (*filter)(struct nlmsghdr *, ns_id_t, int startup), } if (status < 0) { - zlog_err("netlink_talk sendmsg() error: %s", - safe_strerror(save_errno)); + zlog_ferr(LIB_ERR_SOCKET, "netlink_talk sendmsg() error: %s", + safe_strerror(save_errno)); return -1; } @@ -976,7 +994,7 @@ int netlink_request(struct nlsock *nl, struct nlmsghdr *n) /* Check netlink socket. */ if (nl->sock < 0) { - zlog_err("%s socket isn't active.", nl->name); + zlog_ferr(LIB_ERR_SOCKET, "%s socket isn't active.", nl->name); return -1; } @@ -1002,8 +1020,8 @@ int netlink_request(struct nlsock *nl, struct nlmsghdr *n) zlog_ferr(LIB_ERR_PRIVILEGES, "Can't lower privileges"); if (ret < 0) { - zlog_err("%s sendto failed: %s", nl->name, - safe_strerror(save_errno)); + zlog_ferr(LIB_ERR_SOCKET, "%s sendto failed: %s", nl->name, + safe_strerror(save_errno)); return -1; } @@ -1077,8 +1095,8 @@ void kernel_init(struct zebra_ns *zns) /* Register kernel socket. */ if (fcntl(zns->netlink.sock, F_SETFL, O_NONBLOCK) < 0) - zlog_err("Can't set %s socket error: %s(%d)", - zns->netlink.name, safe_strerror(errno), errno); + zlog_ferr(LIB_ERR_SOCKET, "Can't set %s socket flags: %s", + zns->netlink.name, safe_strerror(errno)); if (fcntl(zns->netlink_cmd.sock, F_SETFL, O_NONBLOCK) < 0) zlog_err("Can't set %s socket error: %s(%d)", diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index 2bbc96a070..315ea8dd4a 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -408,8 +408,9 @@ int ifm_read(struct if_msghdr *ifm) /* paranoia: sanity check structure */ if (ifm->ifm_msglen < sizeof(struct if_msghdr)) { - zlog_err("ifm_read: ifm->ifm_msglen %d too short\n", - ifm->ifm_msglen); + zlog_ferr(ZEBRA_ERR_NETLINK_LENGTH_ERROR, + "ifm_read: ifm->ifm_msglen %d too short\n", + ifm->ifm_msglen); return -1; } diff --git a/zebra/label_manager.c b/zebra/label_manager.c index f2f89fdebe..c6a32343d9 100644 --- a/zebra/label_manager.c +++ b/zebra/label_manager.c @@ -21,12 +21,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include #include #include -#include "zebra.h" -#include "zserv.h" #include "lib/log.h" #include "lib/memory.h" #include "lib/mpls.h" @@ -35,7 +34,9 @@ #include "lib/zclient.h" #include "lib/libfrr.h" -#include "label_manager.h" +#include "zebra/zserv.h" +#include "zebra/label_manager.h" +#include "zebra/zebra_errors.h" #define CONNECTION_DELAY 5 @@ -82,8 +83,9 @@ static int relay_response_back(void) ret = zclient_read_header(src, zclient->sock, &size, &marker, &version, &vrf_id, &resp_cmd); if (ret < 0 && errno != EAGAIN) { - zlog_err("Error reading Label Manager response: %s", - strerror(errno)); + zlog_ferr(ZEBRA_ERR_LM_RESPONSE, + "Error reading Label Manager response: %s", + strerror(errno)); return -1; } zlog_debug("Label Manager response received, %d bytes", size); @@ -101,7 +103,8 @@ static int relay_response_back(void) /* lookup the client to relay the msg to */ zserv = zserv_find_client(proto, instance); if (!zserv) { - zlog_err( + zlog_ferr( + ZEBRA_ERR_LM_NO_SUCH_CLIENT, "Error relaying LM response: can't find client %s, instance %u", proto_str, instance); return -1; @@ -116,8 +119,9 @@ static int relay_response_back(void) /* send response back */ ret = writen(zserv->sock, dst->data, stream_get_endp(dst)); if (ret <= 0) { - zlog_err("Error relaying LM response to %s instance %u: %s", - proto_str, instance, strerror(errno)); + zlog_ferr(ZEBRA_ERR_LM_RELAY_FAILED, + "Error relaying LM response to %s instance %u: %s", + proto_str, instance, strerror(errno)); return -1; } zlog_debug("Relayed LM response (%d bytes) to %s instance %u", ret, @@ -183,7 +187,8 @@ int zread_relay_label_manager_request(int cmd, struct zserv *zserv, unsigned short instance; if (zclient->sock < 0) { - zlog_err("Unable to relay LM request: no socket"); + zlog_ferr(ZEBRA_ERR_LM_NO_SOCKET, + "Unable to relay LM request: no socket"); reply_error(cmd, zserv, vrf_id); return -1; } @@ -211,8 +216,9 @@ int zread_relay_label_manager_request(int cmd, struct zserv *zserv, /* check & set client instance if unset */ if (zserv->instance && zserv->instance != instance) { - zlog_err("Client instance(%u) != msg instance(%u)", - zserv->instance, instance); + zlog_ferr(ZEBRA_ERR_LM_BAD_INSTANCE, + "Client instance(%u) != msg instance(%u)", + zserv->instance, instance); return -1; } @@ -233,8 +239,9 @@ int zread_relay_label_manager_request(int cmd, struct zserv *zserv, /* Send request to external label manager */ ret = writen(zclient->sock, dst->data, stream_get_endp(dst)); if (ret <= 0) { - zlog_err("Error relaying LM request from %s instance %u: %s", - proto_str, instance, strerror(errno)); + zlog_ferr(ZEBRA_ERR_LM_RELAY_FAILED, + "Error relaying LM request from %s instance %u: %s", + proto_str, instance, strerror(errno)); reply_error(cmd, zserv, vrf_id); return -1; } @@ -262,7 +269,8 @@ static int lm_zclient_connect(struct thread *t) return 0; if (zclient_socket_connect(zclient) < 0) { - zlog_err("Error connecting synchronous zclient!"); + zlog_ferr(ZEBRA_ERR_LM_CLIENT_CONNECTION_FAILED, + "Error connecting synchronous zclient!"); thread_add_timer(zebrad.master, lm_zclient_connect, zclient, CONNECTION_DELAY, &zclient->t_connect); return -1; @@ -393,8 +401,9 @@ struct label_manager_chunk *assign_label_chunk(uint8_t proto, ->end + 1; if (lmc->start > MPLS_LABEL_UNRESERVED_MAX - size + 1) { - zlog_err("Reached max labels. Start: %u, size: %u", lmc->start, - size); + zlog_ferr(ZEBRA_ERR_LM_EXHAUSTED_LABELS, + "Reached max labels. Start: %u, size: %u", lmc->start, + size); XFREE(MTYPE_LM_CHUNK, lmc); return NULL; } @@ -432,7 +441,8 @@ int release_label_chunk(uint8_t proto, unsigned short instance, uint32_t start, if (lmc->end != end) continue; if (lmc->proto != proto || lmc->instance != instance) { - zlog_err("%s: Daemon mismatch!!", __func__); + zlog_ferr(ZEBRA_ERR_LM_DAEMON_MISMATCH, + "%s: Daemon mismatch!!", __func__); continue; } lmc->proto = NO_PROTO; @@ -442,7 +452,8 @@ int release_label_chunk(uint8_t proto, unsigned short instance, uint32_t start, break; } if (ret != 0) - zlog_err("%s: Label chunk not released!!", __func__); + zlog_ferr(ZEBRA_ERR_LM_UNRELEASED_CHUNK, + "%s: Label chunk not released!!", __func__); return ret; } diff --git a/zebra/main.c b/zebra/main.c index 4eeba8549a..719a6ca59f 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -39,6 +39,7 @@ #include "routemap.h" #include "frr_pthread.h" +#include "zebra/zebra_errors.h" #include "zebra/rib.h" #include "zebra/zserv.h" #include "zebra/debug.h" @@ -288,7 +289,8 @@ int main(int argc, char **argv) multipath_num = atoi(optarg); if (multipath_num > MULTIPATH_NUM || multipath_num <= 0) { - zlog_err( + zlog_ferr( + ZEBRA_ERR_BAD_MULTIPATH_NUM, "Multipath Number specified must be less than %d and greater than 0", MULTIPATH_NUM); return 1; diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c index 99c74cd4e4..e629e7387d 100644 --- a/zebra/rt_socket.c +++ b/zebra/rt_socket.c @@ -212,7 +212,8 @@ static int kernel_rtm_ipv4(int cmd, const struct prefix *p, */ case ZEBRA_ERR_RTEXIST: if (cmd != RTM_ADD) - zlog_err( + zlog_ferr( + LIB_ERR_SYSTEM_CALL, "%s: rtm_write() returned %d for command %d", __func__, error, cmd); continue; @@ -225,7 +226,8 @@ static int kernel_rtm_ipv4(int cmd, const struct prefix *p, case ZEBRA_ERR_RTNOEXIST: case ZEBRA_ERR_RTUNREACH: default: - zlog_err( + zlog_ferr( + LIB_ERR_SYSTEM_CALL, "%s: %s: rtm_write() unexpectedly returned %d for command %s", __func__, prefix2str(p, prefix_buf, @@ -397,7 +399,7 @@ enum dp_req_result kernel_route_rib(struct route_node *rn, int route = 0; if (src_p && src_p->prefixlen) { - zlog_err("route add: IPv6 sourcedest routes unsupported!"); + zlog_warn("%s: IPv6 sourcedest routes unsupported!", __func__); return DP_REQUEST_FAILURE; } diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 49ffcdd490..03eb1566a6 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -35,6 +35,7 @@ #include "privs.h" #include "vrf.h" #include "ns.h" +#include "lib_errors.h" #include "zebra/interface.h" #include "zebra/rtadv.h" @@ -180,7 +181,7 @@ static void rtadv_send_packet(int sock, struct interface *ifp) adata = calloc(1, CMSG_SPACE(sizeof(struct in6_pktinfo))); if (adata == NULL) { - zlog_err( + zlog_warn( "rtadv_send_packet: can't malloc control data"); exit(-1); } @@ -373,9 +374,10 @@ static void rtadv_send_packet(int sock, struct interface *ifp) ret = sendmsg(sock, &msg, 0); if (ret < 0) { - zlog_err("%s(%u): Tx RA failed, socket %u error %d (%s)", - ifp->name, ifp->ifindex, sock, errno, - safe_strerror(errno)); + zlog_ferr(LIB_ERR_SOCKET, + "%s(%u): Tx RA failed, socket %u error %d (%s)", + ifp->name, ifp->ifindex, sock, errno, + safe_strerror(errno)); } else zif->ra_sent++; } @@ -629,14 +631,16 @@ static int rtadv_make_socket(ns_id_t ns_id) struct icmp6_filter filter; if (zserv_privs.change(ZPRIVS_RAISE)) - zlog_err("rtadv_make_socket: could not raise privs, %s", - safe_strerror(errno)); + zlog_ferr(LIB_ERR_PRIVILEGES, + "rtadv_make_socket: could not raise privs, %s", + safe_strerror(errno)); sock = ns_socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6, ns_id); if (zserv_privs.change(ZPRIVS_LOWER)) - zlog_err("rtadv_make_socket: could not lower privs, %s", - safe_strerror(errno)); + zlog_ferr(LIB_ERR_PRIVILEGES, + "rtadv_make_socket: could not lower privs, %s", + safe_strerror(errno)); if (sock < 0) { return -1; diff --git a/zebra/rule_socket.c b/zebra/rule_socket.c index ecd642d807..573af249ca 100644 --- a/zebra/rule_socket.c +++ b/zebra/rule_socket.c @@ -43,13 +43,15 @@ enum dp_req_result kernel_add_pbr_rule(struct zebra_pbr_rule *rule) { - zlog_err("%s not Implemented for this platform", __PRETTY_FUNCTION__); + zlog_ferr(LIB_ERR_UNAVAILABLE, "%s not Implemented for this platform", + __PRETTY_FUNCTION__); return DP_REQUEST_FAILURE; } enum dp_req_result kernel_del_pbr_rule(struct zebra_pbr_rule *rule) { - zlog_err("%s not Implemented for this platform", __PRETTY_FUNCTION__); + zlog_ferr(LIB_ERR_UNAVAILABLE, "%s not Implemented for this platform", + __PRETTY_FUNCTION__); return DP_REQUEST_FAILURE; } diff --git a/zebra/subdir.am b/zebra/subdir.am index 73354ec38e..f44574b236 100644 --- a/zebra/subdir.am +++ b/zebra/subdir.am @@ -71,6 +71,7 @@ zebra_zebra_SOURCES = \ zebra/zebra_netns_notify.c \ zebra/table_manager.c \ zebra/zapi_msg.c \ + zebra/zebra_errors.c \ # end zebra/zebra_vty_clippy.c: $(CLIPPY_DEPS) @@ -115,6 +116,7 @@ noinst_HEADERS += \ zebra/zebra_netns_notify.h \ zebra/table_manager.h \ zebra/zapi_msg.h \ + zebra/zebra_errors.h \ # end zebra_zebra_irdp_la_SOURCES = \ diff --git a/zebra/table_manager.c b/zebra/table_manager.c index 5bcc2c40d6..ecff9bd85d 100644 --- a/zebra/table_manager.c +++ b/zebra/table_manager.c @@ -35,6 +35,7 @@ #include "zebra/zebra_vrf.h" #include "zebra/label_manager.h" /* for NO_PROTO */ #include "zebra/table_manager.h" +#include "zebra/zebra_errors.h" /* routing table identifiers * @@ -146,8 +147,9 @@ struct table_manager_chunk *assign_table_chunk(uint8_t proto, uint16_t instance, #endif /* SUNOS_5 */ tmc->start = start; if (RT_TABLE_ID_UNRESERVED_MAX - size + 1 < start) { - zlog_err("Reached max table id. Start/Size %u/%u", - start, size); + zlog_ferr(ZEBRA_ERR_TM_EXHAUSTED_IDS, + "Reached max table id. Start/Size %u/%u", start, + size); XFREE(MTYPE_TM_CHUNK, tmc); return NULL; } @@ -184,7 +186,8 @@ int release_table_chunk(uint8_t proto, uint16_t instance, uint32_t start, if (tmc->end != end) continue; if (tmc->proto != proto || tmc->instance != instance) { - zlog_err("%s: Daemon mismatch!!", __func__); + zlog_ferr(ZEBRA_ERR_TM_DAEMON_MISMATCH, + "%s: Daemon mismatch!!", __func__); continue; } tmc->proto = NO_PROTO; @@ -193,7 +196,8 @@ int release_table_chunk(uint8_t proto, uint16_t instance, uint32_t start, break; } if (ret != 0) - zlog_err("%s: Table chunk not released!!", __func__); + zlog_ferr(ZEBRA_ERR_TM_UNRELEASED_CHUNK, + "%s: Table chunk not released!!", __func__); return ret; } diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 22c0dd623c..369dcfeec8 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -1058,7 +1058,8 @@ static void zread_rnh_register(ZAPI_HANDLER_ARGS) STREAM_GET(&p.u.prefix6, s, IPV6_MAX_BYTELEN); l += IPV6_MAX_BYTELEN; } else { - zlog_err( + zlog_ferr( + ZEBRA_ERR_UNKNOWN_FAMILY, "rnh_register: Received unknown family type %d\n", p.family); return; @@ -1136,7 +1137,8 @@ static void zread_rnh_unregister(ZAPI_HANDLER_ARGS) STREAM_GET(&p.u.prefix6, s, IPV6_MAX_BYTELEN); l += IPV6_MAX_BYTELEN; } else { - zlog_err( + zlog_ferr( + ZEBRA_ERR_UNKNOWN_FAMILY, "rnh_register: Received unknown family type %d\n", p.family); return; @@ -1172,7 +1174,8 @@ static void zread_fec_register(ZAPI_HANDLER_ARGS) * registration */ if (hdr->length < ZEBRA_MIN_FEC_LENGTH) { - zlog_err( + zlog_ferr( + ZEBRA_ERR_IRDP_LEN_MISMATCH, "fec_register: Received a fec register of hdr->length %d, it is of insufficient size to properly decode", hdr->length); return; @@ -1183,7 +1186,8 @@ static void zread_fec_register(ZAPI_HANDLER_ARGS) memset(&p, 0, sizeof(p)); STREAM_GETW(s, p.family); if (p.family != AF_INET && p.family != AF_INET6) { - zlog_err( + zlog_ferr( + ZEBRA_ERR_UNKNOWN_FAMILY, "fec_register: Received unknown family type %d\n", p.family); return; @@ -1230,7 +1234,8 @@ static void zread_fec_unregister(ZAPI_HANDLER_ARGS) * fec unregistration */ if (hdr->length < ZEBRA_MIN_FEC_LENGTH) { - zlog_err( + zlog_ferr( + ZEBRA_ERR_IRDP_LEN_MISMATCH, "fec_unregister: Received a fec unregister of hdr->length %d, it is of insufficient size to properly decode", hdr->length); return; @@ -1244,7 +1249,8 @@ static void zread_fec_unregister(ZAPI_HANDLER_ARGS) memset(&p, 0, sizeof(p)); STREAM_GETW(s, p.family); if (p.family != AF_INET && p.family != AF_INET6) { - zlog_err( + zlog_ferr( + ZEBRA_ERR_UNKNOWN_FAMILY, "fec_unregister: Received unknown family type %d\n", p.family); return; @@ -2376,8 +2382,9 @@ static void zread_table_manager_connect(struct zserv *client, /* accept only dynamic routing protocols */ if ((proto >= ZEBRA_ROUTE_MAX) || (proto <= ZEBRA_ROUTE_STATIC)) { - zlog_err("client %d has wrong protocol %s", client->sock, - zebra_route_string(proto)); + zlog_ferr(ZEBRA_ERR_TM_WRONG_PROTO, + "client %d has wrong protocol %s", client->sock, + zebra_route_string(proto)); zsend_table_manager_connect_response(client, vrf_id, 1); return; } @@ -2415,8 +2422,9 @@ static void zread_label_manager_connect(struct zserv *client, /* accept only dynamic routing protocols */ if ((proto >= ZEBRA_ROUTE_MAX) || (proto <= ZEBRA_ROUTE_STATIC)) { - zlog_err("client %d has wrong protocol %s", client->sock, - zebra_route_string(proto)); + zlog_ferr(ZEBRA_ERR_TM_WRONG_PROTO, + "client %d has wrong protocol %s", client->sock, + zebra_route_string(proto)); zsend_label_manager_connect_response(client, vrf_id, 1); return; } @@ -2444,14 +2452,16 @@ static int msg_client_id_mismatch(const char *op, struct zserv *client, uint8_t proto, unsigned int instance) { if (proto != client->proto) { - zlog_err("%s: msg vs client proto mismatch, client=%u msg=%u", - op, client->proto, proto); + zlog_ferr(ZEBRA_ERR_PROTO_OR_INSTANCE_MISMATCH, + "%s: msg vs client proto mismatch, client=%u msg=%u", + op, client->proto, proto); /* TODO: fail when BGP sets proto and instance */ /* return 1; */ } if (instance != client->instance) { - zlog_err( + zlog_ferr( + ZEBRA_ERR_PROTO_OR_INSTANCE_MISMATCH, "%s: msg vs client instance mismatch, client=%u msg=%u", op, client->instance, instance); /* TODO: fail when BGP sets proto and instance */ @@ -2486,7 +2496,8 @@ static void zread_get_label_chunk(struct zserv *client, struct stream *msg, lmc = assign_label_chunk(client->proto, client->instance, keep, size); if (!lmc) - zlog_err( + zlog_ferr( + ZEBRA_ERR_LM_CANNOT_ASSIGN_CHUNK, "Unable to assign Label Chunk of size %u to %s instance %u", size, zebra_route_string(client->proto), client->instance); @@ -2544,7 +2555,8 @@ static void zread_label_manager_request(ZAPI_HANDLER_ARGS) else { /* Sanity: don't allow 'unidentified' requests */ if (!client->proto) { - zlog_err( + zlog_ferr( + ZEBRA_ERR_LM_ALIENS, "Got label request from an unidentified client"); return; } @@ -2572,8 +2584,9 @@ static void zread_get_table_chunk(struct zserv *client, struct stream *msg, tmc = assign_table_chunk(client->proto, client->instance, size); if (!tmc) - zlog_err("%s: Unable to assign Table Chunk of size %u", - __func__, size); + zlog_ferr(ZEBRA_ERR_TM_CANNOT_ASSIGN_CHUNK, + "%s: Unable to assign Table Chunk of size %u", + __func__, size); else zlog_debug("Assigned Table Chunk %u - %u", tmc->start, tmc->end); @@ -2610,7 +2623,8 @@ static void zread_table_manager_request(ZAPI_HANDLER_ARGS) else { /* Sanity: don't allow 'unidentified' requests */ if (!client->proto) { - zlog_err( + zlog_ferr( + ZEBRA_ERR_TM_ALIENS, "Got table request from an unidentified client"); return; } diff --git a/zebra/zapi_msg.h b/zebra/zapi_msg.h index 8289e33c6a..29fe59babf 100644 --- a/zebra/zapi_msg.h +++ b/zebra/zapi_msg.h @@ -28,6 +28,7 @@ #include "zebra/rib.h" #include "zebra/zserv.h" #include "zebra/zebra_pbr.h" +#include "zebra/zebra_errors.h" /* * This is called to process inbound ZAPI messages. diff --git a/zebra/zebra_errors.c b/zebra/zebra_errors.c new file mode 100644 index 0000000000..3f981bc5ef --- /dev/null +++ b/zebra/zebra_errors.c @@ -0,0 +1,276 @@ +/* + * Zebra-specific error messages. + * Copyright (C) 2018 Cumulus Networks, Inc. + * Quentin Young + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; see the file COPYING; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include "zebra_errors.h" +#include "ferr.h" + +/* clang-format off */ +static struct ferr_ref ferr_zebra_err[] = { + { + .code = ZEBRA_ERR_LM_RESPONSE, + .title = "Error reading response from label manager", + .description = "Zebra could not read the ZAPI header from the label manager", + .suggestion = "Wait for the error to resolve on its own. If it does not resolve, restart Zebra.", + }, + { + .code = ZEBRA_ERR_LM_NO_SUCH_CLIENT, + .title = "Label manager could not find ZAPI client", + .description = "Zebra was unable to find a ZAPI client matching the given protocol and instance number.", + .suggestion = "Ensure clients which use the label manager are properly configured and running.", + }, + { + .code = ZEBRA_ERR_LM_RELAY_FAILED, + .title = "Zebra could not relay label manager response", + .description = "Zebra found the client and instance to relay the label manager response or request to, but was not able to do so, possibly because the connection was closed.", + .suggestion = "Ensure clients which use the label manager are properly configured and running.", + }, + { + .code = ZEBRA_ERR_LM_BAD_INSTANCE, + .title = "Mismatch between ZAPI instance and encoded message instance", + .description = "While relaying a request to the external label manager, Zebra noticed that the instance number encoded in the message did not match the client instance number.", + .suggestion = "Notify a developer.", + }, + { + .code = ZEBRA_ERR_LM_EXHAUSTED_LABELS, + .title = "Zebra label manager used all available labels", + .description = "Zebra is unable to assign additional label chunks because it has exhausted its assigned label range.", + .suggestion = "Make the label range bigger and restart Zebra.", + }, + { + .code = ZEBRA_ERR_LM_DAEMON_MISMATCH, + .title = "Daemon mismatch when releasing label chunks", + .description = "Zebra noticed a mismatch between a label chunk and a protocol daemon number or instance when releasing unused label chunks.", + .suggestion = "Ignore this error.", + }, + { + .code = ZEBRA_ERR_LM_UNRELEASED_CHUNK, + .title = "Zebra did not free any label chunks", + .description = "Zebra's chunk cleanup procedure ran, but no label chunks were released.", + .suggestion = "Ignore this error.", + }, + { + .code = ZEBRA_ERR_DP_INVALID_RC, + .title = "Dataplane returned invalid status code", + .description = "The underlying dataplane responded to a Zebra message or other interaction with an unrecognized, unknown or invalid status code.", + .suggestion = "Notify a developer.", + }, + { + .code = ZEBRA_ERR_WQ_NONEXISTENT, + .title = "A necessary work queue does not exist.", + .description = "A necessary work queue does not exist.", + .suggestion = "Notify a developer.", + }, + { + .code = ZEBRA_ERR_FEC_ADD_FAILED, + .title = "Failed to add FEC for MPLS client", + .description = "A client requested a label binding for a new FEC, but Zebra was unable to add the FEC to its internal table.", + .suggestion = "Notify a developer.", + }, + { + .code = ZEBRA_ERR_FEC_RM_FAILED, + .title = "Failed to remove FEC for MPLS client", + .description = "Zebra was unable to find and remove a FEC in its internal table.", + .suggestion = "Notify a developer.", + }, + { + .code = ZEBRA_ERR_IRDP_LEN_MISMATCH, + .title = "IRDP message length mismatch", + .description = "The length encoded in the IP TLV does not match the length of the packet received.", + .suggestion = "Notify a developer.", + }, + { + .code = ZEBRA_ERR_RNH_UNKNOWN_FAMILY, + .title = "Attempted to perform nexthop update for unknown address family", + .description = "Zebra attempted to perform a nexthop update for unknown address family", + .suggestion = "Notify a developer.", + }, + { + .code = ZEBRA_ERR_DP_INSTALL_FAIL, + .title = "Dataplane installation failure", + .description = "Installation of routes to 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.", + .suggestion = "If you entered a command to trigger this error, make sure you entered the arguments correctly. Check your config file for any potential errors. If these look correct, seek help.", + }, + { + .code = ZEBRA_ERR_NETLINK_NOT_AVAILABLE, + .title = "Netlink backend not available", + .description = "FRR was not compiled with support for Netlink. Any operations that require Netlink will fail.", + .suggestion = "Recompile FRR with Netlink, or install a package that supports this feature.", + }, + { + .code = ZEBRA_ERR_PROTOBUF_NOT_AVAILABLE, + .title = "Protocol Buffers backend not available", + .description = "FRR was not compiled with support for Protocol Buffers. Any operations that require Protobuf will fail.", + .suggestion = "Recompile FRR with Protobuf support, or install a package that supports this feature.", + }, + { + .code = ZEBRA_ERR_TM_EXHAUSTED_IDS, + .title = "Table manager used all available IDs", + .description = "Zebra's table manager used up all IDs available to it and can't assign any more.", + .suggestion = "Reconfigure Zebra with a larger range of table IDs.", + }, + { + .code = ZEBRA_ERR_TM_DAEMON_MISMATCH, + .title = "Daemon mismatch when releasing table chunks", + .description = "Zebra noticed a mismatch between a table ID chunk and a protocol daemon number instance when releasing unused table chunks.", + .suggestion = "Ignore this error.", + }, + { + .code = ZEBRA_ERR_TM_UNRELEASED_CHUNK, + .title = "Zebra did not free any table chunks", + .description = "Zebra's table chunk cleanup procedure ran, but no table chunks were released.", + .suggestion = "Ignore this error.", + }, + { + .code = ZEBRA_ERR_UNKNOWN_FAMILY, + .title = "Address family specifier unrecognized", + .description = "Zebra attempted to process information from somewhere that included an address family specifier, but did not recognize the provided specifier.", + .suggestion = "Ensure that your configuration is correct. If it is, notify a developer.", + }, + { + .code = ZEBRA_ERR_TM_WRONG_PROTO, + .title = "Incorrect protocol for table manager client", + .description = "Zebra's table manager only accepts connections from daemons managing dynamic routing protocols, but received a connection attempt from a daemon that does not meet this criterion.", + .suggestion = "Notify a developer.", + }, + { + .code = ZEBRA_ERR_PROTO_OR_INSTANCE_MISMATCH, + .title = "Mismatch between message and client protocol and/or instance", + .description = "Zebra detected a mismatch between a client's protocol and/or instance numbers versus those stored in a message transiting its socket.", + .suggestion = "Notify a developer.", + }, + { + .code = ZEBRA_ERR_LM_CANNOT_ASSIGN_CHUNK, + .title = "Label manager unable to assign label chunk", + .description = "Zebra's label manager was unable to assign a label chunk to client.", + .suggestion = "Ensure that Zebra has a sufficient label range available and that there is not a range collision.", + }, + { + .code = ZEBRA_ERR_LM_ALIENS, + .title = "Label request from unidentified client", + .description = "Zebra's label manager received a label request from an unidentified client.", + .suggestion = "Notify a developer.", + }, + { + .code = ZEBRA_ERR_TM_CANNOT_ASSIGN_CHUNK, + .title = "Table manager unable to assign table chunk", + .description = "Zebra's table manager was unable to assign a table chunk to a client.", + .suggestion = "Ensure that Zebra has sufficient table ID range available and that there is not a range collision.", + }, + { + .code = ZEBRA_ERR_TM_ALIENS, + .title = "Table request from unidentified client", + .description = "Zebra's table manager received a table request from an unidentified client.", + .suggestion = "Notify a developer.", + }, + { + .code = ZEBRA_ERR_RECVBUF, + .title = "Cannot set receive buffer size", + .description = "Socket receive buffer size could not be set in the kernel", + .suggestion = "Ignore this error.", + }, + { + .code = ZEBRA_ERR_UNKNOWN_NLMSG, + .title = "Unknown Netlink message type", + .description = "Zebra received a Netlink message with an unrecognized type field.", + .suggestion = "Verify that you are running the latest version of FRR to ensure kernel compatibility. If the problem persists, notify a developer.", + }, + { + .code = ZEBRA_ERR_RECVMSG_OVERRUN, + .title = "Receive buffer overrun", + .description = "The kernel's buffer for a socket has been overrun, rendering the socket invalid.", + .suggestion = "Zebra will restart itself. Notify a developer if this issue shows up frequently.", + }, + { + .code = ZEBRA_ERR_NETLINK_LENGTH_ERROR, + .title = "Netlink message length mismatch", + .description = "Zebra received a Netlink message with incorrect length fields.", + .suggestion = "Notify a developer.", + }, + { + .code = ZEBRA_ERR_NETLINK_LENGTH_ERROR, + .title = "Netlink message length mismatch", + .description = "Zebra received a Netlink message with incorrect length fields.", + .suggestion = "Notify a developer.", + }, + { + .code = ZEBRA_ERR_UNEXPECTED_MESSAGE, + .title = "Received unexpected response from kernel", + .description = "Received unexpected response from the kernel via Netlink.", + .suggestion = "Notify a developer.", + }, + { + .code = ZEBRA_ERR_NETLINK_BAD_SEQUENCE, + .title = "Bad sequence number in Netlink message", + .description = "Zebra received a Netlink message with a bad sequence number.", + .suggestion = "Notify a developer.", + }, + { + .code = ZEBRA_ERR_BAD_MULTIPATH_NUM, + .title = "Multipath number was out of valid range", + .description = "Multipath number specified to Zebra must be in the appropriate range", + .suggestion = "Provide a multipath number that is within its accepted range", + }, + { + .code = ZEBRA_ERR_PREFIX_PARSE_ERROR, + .title = "String could not be parsed as IP prefix", + .description = "There was an attempt to parse a string as an IPv4 or IPv6 prefix, but the string could not be parsed and this operation failed.", + .suggestion = "Notify a developer.", + }, + { + .code = ZEBRA_ERR_MAC_ADD_FAILED, + .title = "Failed to add MAC address to interface", + .description = "Zebra attempted to assign a MAC address to a vxlan interface but failed", + .suggestion = "Notify a developer.", + }, + { + .code = ZEBRA_ERR_VNI_DEL_FAILED, + .title = "Failed to delete VNI", + .description = "Zebra attempted to delete a VNI entry and failed", + .suggestion = "Notify a developer.", + }, + { + .code = ZEBRA_ERR_VTEP_ADD_FAILED, + .title = "Adding remote VTEP failed", + .description = "Zebra attempted to add a remote VTEP and failed.", + .suggestion = "Notify a developer.", + }, + { + .code = ZEBRA_ERR_VNI_ADD_FAILED, + .title = "Adding VNI failed", + .description = "Zebra attempted to add a VNI hash to an interface and failed", + .suggestion = "Notify a developer.", + }, +}; +/* clang-format on */ + + +void zebra_error_init(void) +{ + ferr_ref_init(); + + ferr_ref_add(ferr_zebra_err); +} diff --git a/zebra/zebra_errors.h b/zebra/zebra_errors.h new file mode 100644 index 0000000000..eea7af5c58 --- /dev/null +++ b/zebra/zebra_errors.h @@ -0,0 +1,74 @@ +/* + * Zebra-specific error messages. + * Copyright (C) 2018 Cumulus Networks, Inc. + * Quentin Young + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; see the file COPYING; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __ZEBRA_ERRORS_H__ +#define __ZEBRA_ERRORS_H__ + +#include +#include "ferr.h" + +enum zebra_ferr_refs { + ZEBRA_ERR_LM_RESPONSE, + ZEBRA_ERR_LM_NO_SUCH_CLIENT, + ZEBRA_ERR_LM_RELAY_FAILED, + ZEBRA_ERR_LM_NO_SOCKET, + ZEBRA_ERR_LM_BAD_INSTANCE, + ZEBRA_ERR_LM_RELAY_REQUEST_FAILED, + ZEBRA_ERR_LM_CLIENT_CONNECTION_FAILED, + ZEBRA_ERR_LM_EXHAUSTED_LABELS, + ZEBRA_ERR_LM_DAEMON_MISMATCH, + ZEBRA_ERR_LM_UNRELEASED_CHUNK, + ZEBRA_ERR_DP_INVALID_RC, + ZEBRA_ERR_WQ_NONEXISTENT, + ZEBRA_ERR_FEC_ADD_FAILED, + ZEBRA_ERR_FEC_RM_FAILED, + ZEBRA_ERR_IRDP_LEN_MISMATCH, + ZEBRA_ERR_RNH_UNKNOWN_FAMILY, + ZEBRA_ERR_DP_INSTALL_FAIL, + ZEBRA_ERR_TABLE_LOOKUP_FAILED, + ZEBRA_ERR_NETLINK_NOT_AVAILABLE, + ZEBRA_ERR_PROTOBUF_NOT_AVAILABLE, + ZEBRA_ERR_TM_EXHAUSTED_IDS, + ZEBRA_ERR_TM_DAEMON_MISMATCH, + ZEBRA_ERR_TM_UNRELEASED_CHUNK, + ZEBRA_ERR_UNKNOWN_FAMILY, + ZEBRA_ERR_TM_WRONG_PROTO, + ZEBRA_ERR_PROTO_OR_INSTANCE_MISMATCH, + ZEBRA_ERR_LM_CANNOT_ASSIGN_CHUNK, + ZEBRA_ERR_LM_ALIENS, + ZEBRA_ERR_TM_CANNOT_ASSIGN_CHUNK, + ZEBRA_ERR_TM_ALIENS, + ZEBRA_ERR_RECVBUF, + ZEBRA_ERR_UNKNOWN_NLMSG, + ZEBRA_ERR_RECVMSG_OVERRUN, + ZEBRA_ERR_NETLINK_LENGTH_ERROR, + ZEBRA_ERR_UNEXPECTED_MESSAGE, + ZEBRA_ERR_NETLINK_BAD_SEQUENCE, + ZEBRA_ERR_BAD_MULTIPATH_NUM, + ZEBRA_ERR_PREFIX_PARSE_ERROR, + ZEBRA_ERR_MAC_ADD_FAILED, + ZEBRA_ERR_VNI_DEL_FAILED, + ZEBRA_ERR_VTEP_ADD_FAILED, + ZEBRA_ERR_VNI_ADD_FAILED, +}; + +void zebra_error_init(void); + +#endif /* __ZEBRA_ERRORS_H__ */ diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index 9d3133f55b..7eaa83644d 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -1517,7 +1517,9 @@ static inline void zfpm_init_message_format(const char *format) if (!strcmp("netlink", format)) { if (!have_netlink) { - zlog_err("FPM netlink message format is not available"); + zlog_ferr( + ZEBRA_ERR_NETLINK_NOT_AVAILABLE, + "FPM netlink message format is not available"); return; } zfpm_g->message_format = ZFPM_MSG_FORMAT_NETLINK; @@ -1526,7 +1528,8 @@ static inline void zfpm_init_message_format(const char *format) if (!strcmp("protobuf", format)) { if (!have_protobuf) { - zlog_err( + zlog_ferr( + ZEBRA_ERR_PROTOBUF_NOT_AVAILABLE, "FPM protobuf message format is not available"); return; } diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index 424a11546d..a778dc9af8 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -45,6 +45,7 @@ #include "zebra/zebra_memory.h" #include "zebra/zebra_vrf.h" #include "zebra/zebra_mpls.h" +#include "zebra/zebra_errors.h" DEFINE_MTYPE_STATIC(ZEBRA, LSP, "MPLS LSP object") DEFINE_MTYPE_STATIC(ZEBRA, FEC, "MPLS FEC object") @@ -917,7 +918,9 @@ static wq_item_status lsp_process(struct work_queue *wq, void *data) UNSET_FLAG(lsp->flags, LSP_FLAG_CHANGED); switch (kernel_add_lsp(lsp)) { case DP_REQUEST_QUEUED: - zlog_err("No current DataPlane interfaces can return this, please fix"); + zlog_ferr( + ZEBRA_ERR_DP_INVALID_RC, + "No current DataPlane interfaces can return this, please fix"); break; case DP_REQUEST_FAILURE: break; @@ -932,7 +935,9 @@ static wq_item_status lsp_process(struct work_queue *wq, void *data) switch (kernel_del_lsp(lsp)) { case DP_REQUEST_QUEUED: - zlog_err("No current DataPlane interfaces can return this, please fix"); + zlog_ferr( + ZEBRA_ERR_DP_INVALID_RC, + "No current DataPlane interfaces can return this, please fix"); break; case DP_REQUEST_FAILURE: break; @@ -970,7 +975,9 @@ static wq_item_status lsp_process(struct work_queue *wq, void *data) switch (kernel_upd_lsp(lsp)) { case DP_REQUEST_QUEUED: - zlog_err("No current DataPlane interfaces can return this, please fix"); + zlog_ferr( + ZEBRA_ERR_DP_INVALID_RC, + "No current DataPlane interfaces can return this, please fix"); break; case DP_REQUEST_FAILURE: break; @@ -1048,7 +1055,8 @@ static int lsp_processq_add(zebra_lsp_t *lsp) return 0; if (zebrad.lsp_process_q == NULL) { - zlog_err("%s: work_queue does not exist!", __func__); + zlog_ferr(ZEBRA_ERR_WQ_NONEXISTENT, + "%s: work_queue does not exist!", __func__); return -1; } @@ -1690,7 +1698,8 @@ static int mpls_processq_init(struct zebra_t *zebra) { zebra->lsp_process_q = work_queue_new(zebra->master, "LSP processing"); if (!zebra->lsp_process_q) { - zlog_err("%s: could not initialise work queue!", __func__); + zlog_ferr(ZEBRA_ERR_WQ_NONEXISTENT, + "%s: could not initialise work queue!", __func__); return -1; } @@ -1825,7 +1834,8 @@ int zebra_mpls_fec_register(struct zebra_vrf *zvrf, struct prefix *p, fec = fec_add(table, p, MPLS_INVALID_LABEL, 0, label_index); if (!fec) { prefix2str(p, buf, BUFSIZ); - zlog_err( + zlog_ferr( + ZEBRA_ERR_FEC_ADD_FAILED, "Failed to add FEC %s upon register, client %s", buf, zebra_route_string(client->proto)); return -1; @@ -1905,8 +1915,9 @@ int zebra_mpls_fec_unregister(struct zebra_vrf *zvrf, struct prefix *p, fec = fec_find(table, p); if (!fec) { prefix2str(p, buf, BUFSIZ); - zlog_err("Failed to find FEC %s upon unregister, client %s", - buf, zebra_route_string(client->proto)); + zlog_ferr(ZEBRA_ERR_FEC_RM_FAILED, + "Failed to find FEC %s upon unregister, client %s", + buf, zebra_route_string(client->proto)); return -1; } @@ -2036,7 +2047,8 @@ int zebra_mpls_static_fec_add(struct zebra_vrf *zvrf, struct prefix *p, MPLS_INVALID_LABEL_INDEX); if (!fec) { prefix2str(p, buf, BUFSIZ); - zlog_err("Failed to add FEC %s upon config", buf); + zlog_ferr(ZEBRA_ERR_FEC_ADD_FAILED, + "Failed to add FEC %s upon config", buf); return -1; } @@ -2083,7 +2095,8 @@ int zebra_mpls_static_fec_del(struct zebra_vrf *zvrf, struct prefix *p) fec = fec_find(table, p); if (!fec) { prefix2str(p, buf, BUFSIZ); - zlog_err("Failed to find FEC %s upon delete", buf); + zlog_ferr(ZEBRA_ERR_FEC_RM_FAILED, + "Failed to find FEC %s upon delete", buf); return -1; } diff --git a/zebra/zebra_mpls_openbsd.c b/zebra/zebra_mpls_openbsd.c index c684167e38..91e1d7118d 100644 --- a/zebra/zebra_mpls_openbsd.c +++ b/zebra/zebra_mpls_openbsd.c @@ -124,7 +124,8 @@ static int kernel_send_rtmsg_v4(int action, mpls_label_t in_label, zlog_ferr(LIB_ERR_PRIVILEGES, "Can't lower privileges"); if (ret == -1) - zlog_err("%s: %s", __func__, safe_strerror(errno)); + zlog_ferr(LIB_ERR_SOCKET, "%s: %s", __func__, + safe_strerror(errno)); return ret; } @@ -232,7 +233,8 @@ static int kernel_send_rtmsg_v6(int action, mpls_label_t in_label, zlog_ferr(LIB_ERR_PRIVILEGES, "Can't lower privileges"); if (ret == -1) - zlog_err("%s: %s", __func__, safe_strerror(errno)); + zlog_ferr(LIB_ERR_SOCKET, "%s: %s", __func__, + safe_strerror(errno)); return ret; } @@ -361,8 +363,8 @@ static int kmpw_install(struct zebra_pw *pw) imr.imr_type = IMR_TYPE_ETHERNET_TAGGED; break; default: - zlog_err("%s: unhandled pseudowire type (%#X)", __func__, - pw->type); + zlog_warn("%s: unhandled pseudowire type (%#X)", __func__, + pw->type); return -1; } @@ -383,8 +385,8 @@ static int kmpw_install(struct zebra_pw *pw) sa_in6->sin6_addr = pw->nexthop.ipv6; break; default: - zlog_err("%s: unhandled pseudowire address-family (%u)", - __func__, pw->af); + zlog_warn("%s: unhandled pseudowire address-family (%u)", + __func__, pw->af); return -1; } memcpy(&imr.imr_nexthop, (struct sockaddr *)&ss, @@ -399,7 +401,8 @@ static int kmpw_install(struct zebra_pw *pw) strlcpy(ifr.ifr_name, pw->ifname, sizeof(ifr.ifr_name)); ifr.ifr_data = (caddr_t)&imr; if (ioctl(kr_state.ioctl_fd, SIOCSETMPWCFG, &ifr) == -1) { - zlog_err("ioctl SIOCSETMPWCFG: %s", safe_strerror(errno)); + zlog_ferr(LIB_ERR_SYSTEM_CALL, "ioctl SIOCSETMPWCFG: %s", + safe_strerror(errno)); return -1; } @@ -416,7 +419,8 @@ static int kmpw_uninstall(struct zebra_pw *pw) strlcpy(ifr.ifr_name, pw->ifname, sizeof(ifr.ifr_name)); ifr.ifr_data = (caddr_t)&imr; if (ioctl(kr_state.ioctl_fd, SIOCSETMPWCFG, &ifr) == -1) { - zlog_err("ioctl SIOCSETMPWCFG: %s", safe_strerror(errno)); + zlog_ferr(LIB_ERR_SYSTEM_CALL, "ioctl SIOCSETMPWCFG: %s", + safe_strerror(errno)); return -1; } diff --git a/zebra/zebra_netns_id.c b/zebra/zebra_netns_id.c index 96e6df34da..698ac2986f 100644 --- a/zebra/zebra_netns_id.c +++ b/zebra/zebra_netns_id.c @@ -22,6 +22,7 @@ #include "ns.h" #include "vrf.h" #include "log.h" +#include "lib_errors.h" #if defined(HAVE_NETLINK) @@ -34,7 +35,8 @@ #include "kernel_netlink.h" #endif /* defined(HAVE_NETLINK) */ -#include "zebra_netns_id.h" +#include "zebra/zebra_netns_id.h" +#include "zebra/zebra_errors.h" /* default NS ID value used when VRF backend is not NETNS */ #define NS_DEFAULT_INTERNAL 0 @@ -86,8 +88,8 @@ static int send_receive(int sock, struct nlmsghdr *nlh, unsigned int seq, ret = sendto(sock, (const void *)nlh, (size_t)nlh->nlmsg_len, 0, (struct sockaddr *)&snl, (socklen_t)sizeof(snl)); if (ret < 0) { - zlog_err("netlink( %u) sendmsg() error: %s", sock, - safe_strerror(errno)); + zlog_ferr(LIB_ERR_SOCKET, "netlink( %u) sendmsg() error: %s", + sock, safe_strerror(errno)); return -1; } @@ -107,16 +109,19 @@ static int send_receive(int sock, struct nlmsghdr *nlh, unsigned int seq, }; ret = recvmsg(sock, &msg, 0); if (ret < 0) { - zlog_err("netlink recvmsg: error %d (errno %u)", ret, errno); + zlog_ferr(LIB_ERR_SOCKET, + "netlink recvmsg: error %d (errno %u)", ret, errno); return -1; } if (msg.msg_flags & MSG_TRUNC) { - zlog_err("netlink recvmsg : error message truncated"); + zlog_ferr(ZEBRA_ERR_NETLINK_LENGTH_ERROR, + "netlink recvmsg : error message truncated"); return -1; } /* nlh already points to buf */ if (nlh->nlmsg_seq != seq) { - zlog_err( + zlog_ferr( + ZEBRA_ERR_NETLINK_BAD_SEQUENCE, "netlink recvmsg: bad sequence number %x (expected %x)", seq, nlh->nlmsg_seq); return -1; @@ -170,8 +175,8 @@ ns_id_t zebra_ns_id_get(const char *netnspath) /* netlink socket */ sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock < 0) { - zlog_err("netlink( %u) socket() error: %s", sock, - safe_strerror(errno)); + zlog_ferr(LIB_ERR_SOCKET, "netlink( %u) socket() error: %s", + sock, safe_strerror(errno)); close(fd); return NS_UNKNOWN; } @@ -181,8 +186,9 @@ ns_id_t zebra_ns_id_get(const char *netnspath) snl.nl_pid = 0; /* AUTO PID */ ret = bind(sock, (struct sockaddr *)&snl, sizeof(snl)); if (ret < 0) { - zlog_err("netlink( %u) socket() bind error: %s", sock, - safe_strerror(errno)); + zlog_ferr(LIB_ERR_SOCKET, + "netlink( %u) socket() bind error: %s", sock, + safe_strerror(errno)); close(sock); close(fd); return NS_UNKNOWN; @@ -255,7 +261,8 @@ ns_id_t zebra_ns_id_get(const char *netnspath) if (ret <= 0) { if (errno != EEXIST && ret != 0) { - zlog_err( + zlog_ferr( + LIB_ERR_SOCKET, "netlink( %u) recvfrom() error 2 when reading: %s", fd, safe_strerror(errno)); close(sock); diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index cc2d5d411d..6e2880ea09 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -19,25 +19,29 @@ */ #include + #include /* for sockaddr_un */ #include + +#include "bfd.h" +#include "buffer.h" +#include "command.h" +#include "if.h" +#include "network.h" +#include "ptm_lib.h" +#include "rib.h" +#include "stream.h" +#include "version.h" +#include "vrf.h" #include "vty.h" -#include "zebra/zserv.h" -#include "zebra/interface.h" + #include "zebra/debug.h" +#include "zebra/interface.h" +#include "zebra/zebra_errors.h" #include "zebra/zebra_ptm.h" -#include "if.h" -#include "command.h" -#include "stream.h" -#include "ptm_lib.h" -#include "network.h" -#include "buffer.h" #include "zebra/zebra_ptm_redistribute.h" -#include "bfd.h" -#include "vrf.h" -#include "rib.h" +#include "zebra/zserv.h" #include "zebra_vrf.h" -#include "version.h" /* * Choose the BFD implementation that we'll use. @@ -500,15 +504,17 @@ static int zebra_ptm_handle_bfd_msg(void *arg, void *in_ctxt, dest_str, src_str); if (str2prefix(dest_str, &dest_prefix) == 0) { - zlog_err("%s: Peer addr %s not found", __func__, dest_str); + zlog_ferr(ZEBRA_ERR_PREFIX_PARSE_ERROR, + "%s: Peer addr %s not found", __func__, dest_str); return -1; } memset(&src_prefix, 0, sizeof(struct prefix)); if (strcmp(ZEBRA_PTM_INVALID_SRC_IP, src_str)) { if (str2prefix(src_str, &src_prefix) == 0) { - zlog_err("%s: Local addr %s not found", __func__, - src_str); + zlog_ferr(ZEBRA_ERR_PREFIX_PARSE_ERROR, + "%s: Local addr %s not found", __func__, + src_str); return -1; } } @@ -602,8 +608,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_err("%s: %s not found in interface list", __func__, - port_str); + zlog_warn("%s: %s not found in interface list", + __func__, port_str); return -1; } } @@ -1026,8 +1032,8 @@ int zebra_ptm_bfd_client_deregister(struct zserv *client) return 0; if (IS_ZEBRA_DEBUG_EVENT) - zlog_err("bfd_client_deregister msg for client %s", - zebra_route_string(proto)); + zlog_warn("bfd_client_deregister msg for client %s", + zebra_route_string(proto)); if (ptm_cb.ptm_sock == -1) { ptm_cb.t_timer = NULL; diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 69f6ff9de7..993f1baf56 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -20,37 +20,38 @@ #include -#include "if.h" -#include "prefix.h" -#include "table.h" -#include "memory.h" -#include "zebra_memory.h" #include "command.h" +#include "if.h" +#include "linklist.h" #include "log.h" #include "log_int.h" -#include "sockunion.h" -#include "linklist.h" -#include "thread.h" -#include "workqueue.h" +#include "memory.h" +#include "mpls.h" +#include "nexthop.h" +#include "prefix.h" #include "prefix.h" #include "routemap.h" -#include "nexthop.h" -#include "vrf.h" -#include "mpls.h" +#include "sockunion.h" #include "srcdest_table.h" +#include "table.h" +#include "thread.h" +#include "vrf.h" +#include "workqueue.h" +#include "zebra/connected.h" +#include "zebra/debug.h" +#include "zebra/interface.h" +#include "zebra/redistribute.h" #include "zebra/rib.h" #include "zebra/rt.h" +#include "zebra/zapi_msg.h" +#include "zebra/zebra_errors.h" +#include "zebra/zebra_memory.h" #include "zebra/zebra_ns.h" -#include "zebra/zebra_vrf.h" -#include "zebra/redistribute.h" -#include "zebra/zebra_routemap.h" -#include "zebra/debug.h" #include "zebra/zebra_rnh.h" -#include "zebra/interface.h" -#include "zebra/connected.h" +#include "zebra/zebra_routemap.h" +#include "zebra/zebra_vrf.h" #include "zebra/zebra_vxlan.h" -#include "zebra/zapi_msg.h" DEFINE_HOOK(rib_update, (struct route_node * rn, const char *reason), (rn, reason)) @@ -1125,10 +1126,14 @@ void rib_install_kernel(struct route_node *rn, struct route_entry *re, hook_call(rib_update, rn, "installing in kernel"); switch (kernel_route_rib(rn, p, src_p, old, re)) { case DP_REQUEST_QUEUED: - zlog_err("No current known DataPlane interfaces can return this, please fix"); + zlog_ferr( + ZEBRA_ERR_DP_INVALID_RC, + "No current known DataPlane interfaces can return this, please fix"); break; case DP_REQUEST_FAILURE: - zlog_err("No current known Rib Install Failure cases, please fix"); + zlog_ferr( + ZEBRA_ERR_DP_INSTALL_FAIL, + "No current known Rib Install Failure cases, please fix"); break; case DP_REQUEST_SUCCESS: zvrf->installs++; @@ -1161,10 +1166,14 @@ void rib_uninstall_kernel(struct route_node *rn, struct route_entry *re) hook_call(rib_update, rn, "uninstalling from kernel"); switch (kernel_route_rib(rn, p, src_p, re, NULL)) { case DP_REQUEST_QUEUED: - zlog_err("No current known DataPlane interfaces can return this, please fix"); + zlog_ferr( + ZEBRA_ERR_DP_INVALID_RC, + "No current known DataPlane interfaces can return this, please fix"); break; case DP_REQUEST_FAILURE: - zlog_err("No current known RIB Install Failure cases, please fix"); + zlog_ferr( + ZEBRA_ERR_DP_INSTALL_FAIL, + "No current known RIB Install Failure cases, please fix"); break; case DP_REQUEST_SUCCESS: if (zvrf) @@ -1936,7 +1945,8 @@ void rib_queue_add(struct route_node *rn) } if (zebrad.ribq == NULL) { - zlog_err("%s: work_queue does not exist!", __func__); + zlog_ferr(ZEBRA_ERR_WQ_NONEXISTENT, + "%s: work_queue does not exist!", __func__); return; } @@ -1991,7 +2001,8 @@ static void rib_queue_init(struct zebra_t *zebra) if (!(zebra->ribq = work_queue_new(zebra->master, "route_node processing"))) { - zlog_err("%s: could not initialise work queue!", __func__); + zlog_ferr(ZEBRA_ERR_WQ_NONEXISTENT, + "%s: could not initialise work queue!", __func__); return; } @@ -2004,7 +2015,8 @@ static void rib_queue_init(struct zebra_t *zebra) zebra->ribq->spec.hold = ZEBRA_RIB_PROCESS_HOLD_TIME; if (!(zebra->mq = meta_queue_new())) { - zlog_err("%s: could not initialise meta queue!", __func__); + zlog_ferr(ZEBRA_ERR_WQ_NONEXISTENT, + "%s: could not initialise meta queue!", __func__); return; } return; @@ -2231,8 +2243,9 @@ void rib_lookup_and_dump(struct prefix_ipv4 *p, vrf_id_t vrf_id) /* Lookup table. */ table = zebra_vrf_table(AFI_IP, SAFI_UNICAST, vrf_id); if (!table) { - zlog_err("%s:%u zebra_vrf_table() returned NULL", - __func__, vrf_id); + zlog_ferr(ZEBRA_ERR_TABLE_LOOKUP_FAILED, + "%s:%u zebra_vrf_table() returned NULL", __func__, + vrf_id); return; } @@ -2278,8 +2291,9 @@ void rib_lookup_and_pushup(struct prefix_ipv4 *p, vrf_id_t vrf_id) rib_dest_t *dest; if (NULL == (table = zebra_vrf_table(AFI_IP, SAFI_UNICAST, vrf_id))) { - zlog_err("%s:%u zebra_vrf_table() returned NULL", - __func__, vrf_id); + zlog_ferr(ZEBRA_ERR_TABLE_LOOKUP_FAILED, + "%s:%u zebra_vrf_table() returned NULL", __func__, + vrf_id); return; } diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c index 453f08a183..6f742e8f13 100644 --- a/zebra/zebra_rnh.c +++ b/zebra/zebra_rnh.c @@ -47,6 +47,7 @@ #include "zebra/zebra_routemap.h" #include "zebra/interface.h" #include "zebra/zebra_memory.h" +#include "zebra/zebra_errors.h" static void free_state(vrf_id_t vrf_id, struct route_entry *re, struct route_node *rn); @@ -857,8 +858,9 @@ static int send_client(struct rnh *rnh, struct zserv *client, rnh_type_t type, stream_put(s, &rn->p.u.prefix6, IPV6_MAX_BYTELEN); break; default: - zlog_err("%s: Unknown family (%d) notification attempted\n", - __FUNCTION__, rn->p.family); + zlog_ferr(ZEBRA_ERR_RNH_UNKNOWN_FAMILY, + "%s: Unknown family (%d) notification attempted\n", + __FUNCTION__, rn->p.family); break; } if (re) { diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 17a25b7005..8e1d5f9670 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -22,33 +22,34 @@ #include +#include "hash.h" #include "if.h" -#include "prefix.h" -#include "table.h" -#include "memory.h" -#include "log.h" +#include "jhash.h" #include "linklist.h" +#include "log.h" +#include "memory.h" +#include "prefix.h" #include "stream.h" -#include "hash.h" -#include "jhash.h" +#include "table.h" #include "vlan.h" #include "vxlan.h" #ifdef GNU_LINUX #include #endif +#include "zebra/debug.h" +#include "zebra/interface.h" #include "zebra/rib.h" #include "zebra/rt.h" +#include "zebra/rt_netlink.h" +#include "zebra/zebra_errors.h" +#include "zebra/zebra_l2.h" +#include "zebra/zebra_memory.h" #include "zebra/zebra_ns.h" -#include "zebra/zserv.h" -#include "zebra/debug.h" -#include "zebra/interface.h" #include "zebra/zebra_vrf.h" -#include "zebra/rt_netlink.h" -#include "zebra/zebra_vxlan_private.h" #include "zebra/zebra_vxlan.h" -#include "zebra/zebra_memory.h" -#include "zebra/zebra_l2.h" +#include "zebra/zebra_vxlan_private.h" +#include "zebra/zserv.h" DEFINE_MTYPE_STATIC(ZEBRA, HOST_PREFIX, "host prefix"); DEFINE_MTYPE_STATIC(ZEBRA, ZVNI, "VNI hash"); @@ -1492,14 +1493,13 @@ static void zvni_process_neigh_on_local_mac_del(zebra_vni_t *zvni, zvni_neigh_send_del_to_client(zvni->vni, &n->ip, &n->emac, 0); } - } else if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_REMOTE)) { - if (IS_ZEBRA_DEBUG_VXLAN) - zlog_err( - "local MAC %s getting deleted on VNI %u has remote neigh %s", - prefix_mac2str(&n->emac, buf, - sizeof(buf)), - zvni->vni, - ipaddr2str(&n->ip, buf2, sizeof(buf2))); + } else if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_REMOTE) + && IS_ZEBRA_DEBUG_VXLAN) { + zlog_debug( + "local MAC %s getting deleted on VNI %u has remote neigh %s", + prefix_mac2str(&n->emac, buf, sizeof(buf)), + zvni->vni, + ipaddr2str(&n->ip, buf2, sizeof(buf2))); } } } @@ -1543,14 +1543,13 @@ static void zvni_process_neigh_on_remote_mac_del(zebra_vni_t *zvni, char buf2[INET6_ADDRSTRLEN]; for (ALL_LIST_ELEMENTS_RO(zmac->neigh_list, node, n)) { - if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_LOCAL)) { - if (IS_ZEBRA_DEBUG_VXLAN) - zlog_err( - "remote MAC %s getting deleted on VNI %u has local neigh %s", - prefix_mac2str(&n->emac, buf, - sizeof(buf)), - zvni->vni, - ipaddr2str(&n->ip, buf2, sizeof(buf2))); + if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_LOCAL) + && IS_ZEBRA_DEBUG_VXLAN) { + zlog_debug( + "remote MAC %s getting deleted on VNI %u has local neigh %s", + prefix_mac2str(&n->emac, buf, sizeof(buf)), + zvni->vni, + ipaddr2str(&n->ip, buf2, sizeof(buf2))); } } } @@ -1628,8 +1627,8 @@ static int zvni_neigh_uninstall(zebra_vni_t *zvni, zebra_neigh_t *n) return 0; if (!zvni->vxlan_if) { - zlog_err("VNI %u hash %p couldn't be uninstalled - no intf", - zvni->vni, zvni); + zlog_warn("VNI %u hash %p couldn't be uninstalled - no intf", + zvni->vni, zvni); return -1; } @@ -1803,9 +1802,10 @@ static int zvni_gw_macip_add(struct interface *ifp, zebra_vni_t *zvni, if (!mac) { mac = zvni_mac_add(zvni, macaddr); if (!mac) { - zlog_err("Failed to add MAC %s intf %s(%u) VID %u", - prefix_mac2str(macaddr, buf, sizeof(buf)), - ifp->name, ifp->ifindex, vxl->access_vlan); + zlog_ferr(ZEBRA_ERR_MAC_ADD_FAILED, + "Failed to add MAC %s intf %s(%u) VID %u", + prefix_mac2str(macaddr, buf, sizeof(buf)), + ifp->name, ifp->ifindex, vxl->access_vlan); return -1; } } @@ -1822,7 +1822,8 @@ static int zvni_gw_macip_add(struct interface *ifp, zebra_vni_t *zvni, if (!n) { n = zvni_neigh_add(zvni, ip, macaddr); if (!n) { - zlog_err( + zlog_ferr( + ZEBRA_ERR_MAC_ADD_FAILED, "Failed to add neighbor %s MAC %s intf %s(%u) -> VNI %u", ipaddr2str(ip, buf2, sizeof(buf2)), prefix_mac2str(macaddr, buf, sizeof(buf)), @@ -1875,9 +1876,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_err("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_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); return -1; } @@ -2085,7 +2086,8 @@ static int zvni_local_neigh_update(zebra_vni_t *zvni, /* New neighbor - create */ n = zvni_neigh_add(zvni, ip, macaddr); if (!n) { - zlog_err( + zlog_ferr( + ZEBRA_ERR_MAC_ADD_FAILED, "Failed to add neighbor %s MAC %s intf %s(%u) -> VNI %u", ipaddr2str(ip, buf2, sizeof(buf2)), prefix_mac2str(macaddr, buf, sizeof(buf)), @@ -2156,10 +2158,11 @@ 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_err("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)), - zvni->vni); + zlog_warn( + "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)), + zvni->vni); return -1; } @@ -2588,8 +2591,8 @@ static int zvni_mac_uninstall(zebra_vni_t *zvni, zebra_mac_t *mac, int local) return 0; if (!zvni->vxlan_if) { - zlog_err("VNI %u hash %p couldn't be uninstalled - no intf", - zvni->vni, zvni); + zlog_warn("VNI %u hash %p couldn't be uninstalled - no intf", + zvni->vni, zvni); return -1; } @@ -2918,7 +2921,7 @@ static void zvni_build_hash_table() /* VNI hash entry is not expected to exist. */ zvni = zvni_lookup(vni); if (zvni) { - zlog_err( + zlog_warn( "VNI hash already present for IF %s(%u) L2-VNI %u", ifp->name, ifp->ifindex, vni); continue; @@ -2926,7 +2929,7 @@ static void zvni_build_hash_table() zvni = zvni_add(vni); if (!zvni) { - zlog_err( + zlog_warn( "Failed to add VNI hash, IF %s(%u) L2-VNI %u", ifp->name, ifp->ifindex, vni); return; @@ -3049,8 +3052,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_err("VNI %u hash %p couldn't be uninstalled - no intf", - zvni->vni, zvni); + zlog_warn("VNI %u hash %p couldn't be uninstalled - no intf", + zvni->vni, zvni); return -1; } @@ -3244,7 +3247,7 @@ static int zl3vni_rmac_uninstall(zebra_l3vni_t *zl3vni, zebra_mac_t *zrmac) return 0; if (!zl3vni->vxlan_if) { - zlog_err( + zlog_warn( "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); @@ -3900,8 +3903,9 @@ static int zebra_vxlan_handle_vni_transition(struct zebra_vrf *zvrf, vni_t vni, /* Delete the hash entry. */ if (zvni_del(zvni)) { - zlog_err("Failed to del VNI hash %p, VNI %u", zvni, - zvni->vni); + zlog_ferr(ZEBRA_ERR_VNI_DEL_FAILED, + "Failed to del VNI hash %p, VNI %u", zvni, + zvni->vni); return -1; } } else { @@ -4920,7 +4924,7 @@ int zebra_vxlan_handle_kernel_neigh_del(struct interface *ifp, return 0; if (!zvni->vxlan_if) { - zlog_err( + zlog_warn( "VNI %u hash %p doesn't have intf upon local neighbor DEL", zvni->vni, zvni); return -1; @@ -4939,7 +4943,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_err( + zlog_warn( "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)), @@ -5086,7 +5090,7 @@ void zebra_vxlan_remote_macip_del(ZAPI_HANDLER_ARGS) } ifp = zvni->vxlan_if; if (!ifp) { - zlog_err( + zlog_warn( "VNI %u hash %p doesn't have intf upon remote MACIP DEL", vni, zvni); continue; @@ -5113,9 +5117,9 @@ void zebra_vxlan_remote_macip_del(ZAPI_HANDLER_ARGS) n = zvni_neigh_lookup(zvni, &ip); if (n && !mac) { - zlog_err("Failed to locate MAC %s for neigh %s VNI %u", - prefix_mac2str(&macaddr, buf, sizeof(buf)), - ipaddr2str(&ip, buf1, sizeof(buf1)), vni); + zlog_warn("Failed to locate MAC %s for neigh %s VNI %u", + prefix_mac2str(&macaddr, buf, sizeof(buf)), + ipaddr2str(&ip, buf1, sizeof(buf1)), vni); continue; } @@ -5129,7 +5133,7 @@ void zebra_vxlan_remote_macip_del(ZAPI_HANDLER_ARGS) /* Ignore the delete if this mac is a gateway mac-ip */ if (mac && CHECK_FLAG(mac->flags, ZEBRA_MAC_LOCAL) && CHECK_FLAG(mac->flags, ZEBRA_MAC_DEF_GW)) { - zlog_err( + zlog_warn( "%u: Ignore Del for MAC %s neigh %s on VNI %u as it is configured as a default gateway", zvrf_id(zvrf), prefix_mac2str(&macaddr, buf, sizeof(buf)), @@ -5248,14 +5252,14 @@ void zebra_vxlan_remote_macip_add(ZAPI_HANDLER_ARGS) /* Locate VNI hash entry - expected to exist. */ zvni = zvni_lookup(vni); if (!zvni) { - zlog_err( + zlog_warn( "Failed to locate VNI hash upon remote MACIP ADD, VNI %u", vni); continue; } ifp = zvni->vxlan_if; if (!ifp) { - zlog_err( + zlog_warn( "VNI %u hash %p doesn't have intf upon remote MACIP add", vni, zvni); continue; @@ -5275,7 +5279,8 @@ void zebra_vxlan_remote_macip_add(ZAPI_HANDLER_ARGS) zvtep = zvni_vtep_find(zvni, &vtep_ip); if (!zvtep) { if (zvni_vtep_add(zvni, &vtep_ip) == NULL) { - zlog_err( + zlog_ferr( + ZEBRA_ERR_VTEP_ADD_FAILED, "Failed to add remote VTEP, VNI %u zvni %p", vni, zvni); continue; @@ -5548,8 +5553,8 @@ int zebra_vxlan_local_mac_del(struct interface *ifp, struct interface *br_if, if (!zvni) return 0; if (!zvni->vxlan_if) { - zlog_err("VNI %u hash %p doesn't have intf upon local MAC DEL", - zvni->vni, zvni); + zlog_warn("VNI %u hash %p doesn't have intf upon local MAC DEL", + zvni->vni, zvni); return -1; } @@ -5616,8 +5621,8 @@ int zebra_vxlan_local_mac_add_update(struct interface *ifp, } if (!zvni->vxlan_if) { - zlog_err("VNI %u hash %p doesn't have intf upon local MAC ADD", - zvni->vni, zvni); + zlog_warn("VNI %u hash %p doesn't have intf upon local MAC ADD", + zvni->vni, zvni); return -1; } @@ -5682,9 +5687,10 @@ int zebra_vxlan_local_mac_add_update(struct interface *ifp, if (!mac) { mac = zvni_mac_add(zvni, macaddr); if (!mac) { - zlog_err("Failed to add MAC %s intf %s(%u) VID %u", - prefix_mac2str(macaddr, buf, sizeof(buf)), - ifp->name, ifp->ifindex, vid); + zlog_ferr(ZEBRA_ERR_MAC_ADD_FAILED, + "Failed to add MAC %s intf %s(%u) VID %u", + prefix_mac2str(macaddr, buf, sizeof(buf)), + ifp->name, ifp->ifindex, vid); return -1; } } @@ -5734,8 +5740,8 @@ void zebra_vxlan_remote_vtep_del(ZAPI_HANDLER_ARGS) } if (zvrf_id(zvrf) != VRF_DEFAULT) { - zlog_err("Recv MACIP DEL for non-default VRF %u", - zvrf_id(zvrf)); + zlog_warn("Recv MACIP DEL for non-default VRF %u", + zvrf_id(zvrf)); return; } @@ -5766,7 +5772,7 @@ void zebra_vxlan_remote_vtep_del(ZAPI_HANDLER_ARGS) ifp = zvni->vxlan_if; if (!ifp) { - zlog_err( + zlog_warn( "VNI %u hash %p doesn't have intf upon remote VTEP DEL", zvni->vni, zvni); continue; @@ -5818,8 +5824,8 @@ void zebra_vxlan_remote_vtep_add(ZAPI_HANDLER_ARGS) } if (zvrf_id(zvrf) != VRF_DEFAULT) { - zlog_err("Recv MACIP ADD for non-default VRF %u", - zvrf_id(zvrf)); + zlog_warn("Recv MACIP ADD for non-default VRF %u", + zvrf_id(zvrf)); return; } @@ -5840,7 +5846,8 @@ void zebra_vxlan_remote_vtep_add(ZAPI_HANDLER_ARGS) /* Locate VNI hash entry - expected to exist. */ zvni = zvni_lookup(vni); if (!zvni) { - zlog_err( + zlog_ferr( + ZEBRA_ERR_VTEP_ADD_FAILED, "Failed to locate VNI hash upon remote VTEP ADD, VNI %u", vni); continue; @@ -5848,7 +5855,8 @@ void zebra_vxlan_remote_vtep_add(ZAPI_HANDLER_ARGS) ifp = zvni->vxlan_if; if (!ifp) { - zlog_err( + zlog_ferr( + ZEBRA_ERR_VTEP_ADD_FAILED, "VNI %u hash %p doesn't have intf upon remote VTEP ADD", zvni->vni, zvni); continue; @@ -5866,8 +5874,9 @@ void zebra_vxlan_remote_vtep_add(ZAPI_HANDLER_ARGS) continue; if (zvni_vtep_add(zvni, &vtep_ip) == NULL) { - zlog_err("Failed to add remote VTEP, VNI %u zvni %p", - vni, zvni); + zlog_ferr(ZEBRA_ERR_VTEP_ADD_FAILED, + "Failed to add remote VTEP, VNI %u zvni %p", + vni, zvni); continue; } @@ -5918,8 +5927,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_err("MACVLAN %s(%u) without link information", - ifp->name, ifp->ifindex); + zlog_warn("MACVLAN %s(%u) without link information", + ifp->name, ifp->ifindex); return -1; } @@ -5966,8 +5975,8 @@ int zebra_vxlan_add_del_gw_macip(struct interface *ifp, struct prefix *p, return 0; if (!zvni->vxlan_if) { - zlog_err("VNI %u hash %p doesn't have intf upon MACVLAN up", - zvni->vni, zvni); + zlog_warn("VNI %u hash %p doesn't have intf upon MACVLAN up", + zvni->vni, zvni); return -1; } @@ -6063,8 +6072,9 @@ int zebra_vxlan_svi_up(struct interface *ifp, struct interface *link_if) return 0; if (!zvni->vxlan_if) { - zlog_err("VNI %u hash %p doesn't have intf upon SVI up", - zvni->vni, zvni); + zlog_warn( + "VNI %u hash %p doesn't have intf upon SVI up", + zvni->vni, zvni); return -1; } @@ -6125,7 +6135,7 @@ int zebra_vxlan_if_down(struct interface *ifp) /* Locate hash entry; it is expected to exist. */ zvni = zvni_lookup(vni); if (!zvni) { - zlog_err( + zlog_warn( "Failed to locate VNI hash at DOWN, IF %s(%u) VNI %u", ifp->name, ifp->ifindex, vni); return -1; @@ -6191,7 +6201,7 @@ int zebra_vxlan_if_up(struct interface *ifp) /* Locate hash entry; it is expected to exist. */ zvni = zvni_lookup(vni); if (!zvni) { - zlog_err( + zlog_warn( "Failed to locate VNI hash at UP, IF %s(%u) VNI %u", ifp->name, ifp->ifindex, vni); return -1; @@ -6262,7 +6272,7 @@ int zebra_vxlan_if_del(struct interface *ifp) /* Locate hash entry; it is expected to exist. */ zvni = zvni_lookup(vni); if (!zvni) { - zlog_err( + zlog_warn( "Failed to locate VNI hash at del, IF %s(%u) VNI %u", ifp->name, ifp->ifindex, vni); return 0; @@ -6285,8 +6295,9 @@ int zebra_vxlan_if_del(struct interface *ifp) /* Delete the hash entry. */ if (zvni_del(zvni)) { - zlog_err("Failed to del VNI hash %p, IF %s(%u) VNI %u", - zvni, ifp->name, ifp->ifindex, zvni->vni); + zlog_ferr(ZEBRA_ERR_VNI_DEL_FAILED, + "Failed to del VNI hash %p, IF %s(%u) VNI %u", + zvni, ifp->name, ifp->ifindex, zvni->vni); return -1; } } @@ -6372,7 +6383,7 @@ int zebra_vxlan_if_update(struct interface *ifp, uint16_t chgflags) /* Update VNI hash. */ zvni = zvni_lookup(vni); if (!zvni) { - zlog_err( + zlog_warn( "Failed to find L2-VNI hash on update, IF %s(%u) VNI %u", ifp->name, ifp->ifindex, vni); return -1; @@ -6500,7 +6511,8 @@ int zebra_vxlan_if_add(struct interface *ifp) if (!zvni) { zvni = zvni_add(vni); if (!zvni) { - zlog_err( + zlog_ferr( + ZEBRA_ERR_VNI_ADD_FAILED, "Failed to add VNI hash, IF %s(%u) VNI %u", ifp->name, ifp->ifindex, vni); return -1; @@ -6703,8 +6715,8 @@ void zebra_vxlan_advertise_subnet(ZAPI_HANDLER_ARGS) struct interface *vlan_if = NULL; if (zvrf_id(zvrf) != VRF_DEFAULT) { - zlog_err("EVPN GW-MACIP Adv for non-default VRF %u", - zvrf_id(zvrf)); + zlog_warn("EVPN GW-MACIP Adv for non-default VRF %u", + zvrf_id(zvrf)); return; } @@ -6766,8 +6778,8 @@ void zebra_vxlan_advertise_gw_macip(ZAPI_HANDLER_ARGS) struct interface *ifp = NULL; if (zvrf_id(zvrf) != VRF_DEFAULT) { - zlog_err("EVPN GW-MACIP Adv for non-default VRF %u", - zvrf_id(zvrf)); + zlog_warn("EVPN GW-MACIP Adv for non-default VRF %u", + zvrf_id(zvrf)); return; } @@ -6871,7 +6883,7 @@ void zebra_vxlan_advertise_all_vni(ZAPI_HANDLER_ARGS) struct zebra_ns *zns = NULL; if (zvrf_id(zvrf) != VRF_DEFAULT) { - zlog_err("EVPN VNI Adv for non-default VRF %u", zvrf_id(zvrf)); + zlog_warn("EVPN VNI Adv for non-default VRF %u", zvrf_id(zvrf)); return; } -- cgit v1.2.3 From 247dcce2b5676abbd0109bdc2d74c36dff73609c Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Tue, 19 Jun 2018 20:58:44 +0000 Subject: *: fix source file headers & includes for errcodes * Use the correct license header * Stop headers from including themselves * Use uniform relative include conventions * Ensure that sources include what they use * Turn off clang-format around struct array blocks Signed-off-by: Quentin Young --- babeld/babel_errors.c | 23 +++++++++++++---------- babeld/babel_errors.h | 22 +++++++++++----------- bgpd/bgp_errors.c | 26 +++++++++++++++----------- bgpd/bgp_errors.h | 22 +++++++++++----------- eigrpd/eigrp_errors.c | 23 +++++++++++++---------- eigrpd/eigrp_errors.h | 22 +++++++++++----------- isisd/isis_errors.c | 23 +++++++++++++---------- isisd/isis_errors.h | 22 +++++++++++----------- lib/lib_errors.c | 2 +- lib/lib_errors.h | 3 ++- nhrpd/nhrp_errors.c | 23 +++++++++++++---------- nhrpd/nhrp_errors.h | 22 +++++++++++----------- ospfd/ospf_errors.c | 24 +++++++++++++----------- ospfd/ospf_errors.h | 21 +++++++++++---------- pimd/pim_errors.c | 23 +++++++++++++---------- pimd/pim_errors.h | 22 +++++++++++----------- ripd/rip_errors.c | 21 +++++++++++---------- ripd/rip_errors.h | 22 +++++++++++----------- watchfrr/watchfrr_errors.c | 23 +++++++++++++---------- watchfrr/watchfrr_errors.h | 21 ++++++++++----------- zebra/zebra_errors.c | 3 ++- zebra/zebra_errors.h | 3 +-- 22 files changed, 221 insertions(+), 195 deletions(-) (limited to 'lib/lib_errors.h') diff --git a/babeld/babel_errors.c b/babeld/babel_errors.c index ed780ea1bb..ffcc3867fc 100644 --- a/babeld/babel_errors.c +++ b/babeld/babel_errors.c @@ -1,27 +1,29 @@ /* - * babel_errors - code for error messages that may occur in the - * babel process + * Babel-specific error messages. * Copyright (C) 2018 Cumulus Networks, Inc. * Donald Sharp * - * FRR is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * FRR is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * * You should have received a copy of the GNU General Public License along * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #include +#include "lib/ferr.h" #include "babel_errors.h" +/* clang-format off */ static struct ferr_ref ferr_babel_err[] = { { .code = BABEL_ERR_MEMORY, @@ -51,6 +53,7 @@ static struct ferr_ref ferr_babel_err[] = { .code = END_FERR, } }; +/* clang-format on */ void babel_error_init(void) { diff --git a/babeld/babel_errors.h b/babeld/babel_errors.h index a52b19481b..f03801272b 100644 --- a/babeld/babel_errors.h +++ b/babeld/babel_errors.h @@ -1,27 +1,27 @@ /* - * babel_errors - header for error messages that may occur in the babel process + * Babel-specific error messages. * Copyright (C) 2018 Cumulus Networks, Inc. * Donald Sharp * - * FRR is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * FRR is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * * You should have received a copy of the GNU General Public License along * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #ifndef __BABEL_ERRORS_H__ #define __BABEL_ERRORS_H__ -#include "ferr.h" -#include "babel_errors.h" +#include "lib/ferr.h" enum babel_ferr_refs { BABEL_ERR_MEMORY = BABEL_FERR_START, diff --git a/bgpd/bgp_errors.c b/bgpd/bgp_errors.c index 6cad8049a0..5535a2a8ad 100644 --- a/bgpd/bgp_errors.c +++ b/bgpd/bgp_errors.c @@ -1,26 +1,29 @@ /* - * bgp_errors - code for error messages that may occur in the - * bgp process + * BGP-specific error messages. * Copyright (C) 2018 Cumulus Networks, Inc. * Don Slice * - * FRR is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * FRR is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * * You should have received a copy of the GNU General Public License along * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #include -#include +#include "lib/ferr.h" +#include "bgp_errors.h" + +/* clang-format off */ static struct ferr_ref ferr_bgp_err[] = { { .code = BGP_ERR_ATTR_FLAG, @@ -295,6 +298,7 @@ static struct ferr_ref ferr_bgp_err[] = { .code = END_FERR, } }; +/* clang-format on */ void bgp_error_init(void) { diff --git a/bgpd/bgp_errors.h b/bgpd/bgp_errors.h index 4bfb7af879..83b834688e 100644 --- a/bgpd/bgp_errors.h +++ b/bgpd/bgp_errors.h @@ -1,27 +1,27 @@ /* - * bgp_errors - header for error messages that may occur in the bgp process + * BGP-specific error messages. * Copyright (C) 2018 Cumulus Networks, Inc. * Don Slice * - * FRR is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * FRR is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * * You should have received a copy of the GNU General Public License along * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #ifndef __BGP_ERRORS_H__ #define __BGP_ERRORS_H__ -#include "ferr.h" -#include "bgp_errors.h" +#include "lib/ferr.h" enum bgp_ferr_refs { diff --git a/eigrpd/eigrp_errors.c b/eigrpd/eigrp_errors.c index 23a2af0056..5732fc39c8 100644 --- a/eigrpd/eigrp_errors.c +++ b/eigrpd/eigrp_errors.c @@ -1,27 +1,29 @@ /* - * eigrp_errors - code for error messages that may occur in the - * eigrp process + * EIGRP-specific error messages. * Copyright (C) 2018 Cumulus Networks, Inc. * Donald Sharp * - * FRR is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * FRR is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * * You should have received a copy of the GNU General Public License along * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #include +#include "lib/ferr.h" #include "eigrp_errors.h" +/* clang-format off */ static struct ferr_ref ferr_eigrp_err[] = { { .code = EIGRP_ERR_PACKET, @@ -39,6 +41,7 @@ static struct ferr_ref ferr_eigrp_err[] = { .code = END_FERR, } }; +/* clang-format on */ void eigrp_error_init(void) { diff --git a/eigrpd/eigrp_errors.h b/eigrpd/eigrp_errors.h index c314ddc465..e59a5d1e6e 100644 --- a/eigrpd/eigrp_errors.h +++ b/eigrpd/eigrp_errors.h @@ -1,27 +1,27 @@ /* - * eigrp_errors - header for error messages that may occur in the eigrp process + * EIGRP-specific error messages. * Copyright (C) 2018 Cumulus Networks, Inc. * Donald Sharp * - * FRR is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * FRR is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * * You should have received a copy of the GNU General Public License along * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #ifndef __EIGRP_ERRORS_H__ #define __EIGRP_ERRORS_H__ -#include "ferr.h" -#include "eigrp_errors.h" +#include "lib/ferr.h" enum eigrp_ferr_refs { EIGRP_ERR_PACKET = EIGRP_FERR_START, diff --git a/isisd/isis_errors.c b/isisd/isis_errors.c index 154ba2bb5b..d7425153a3 100644 --- a/isisd/isis_errors.c +++ b/isisd/isis_errors.c @@ -1,27 +1,29 @@ /* - * isis_errors - code for error messages that may occur in the - * isis process + * ISIS-specific error messages. * Copyright (C) 2018 Cumulus Networks, Inc. * Donald Sharp * - * FRR is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * FRR is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * * You should have received a copy of the GNU General Public License along * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #include +#include "lib/ferr.h" #include "isis_errors.h" +/* clang-format off */ static struct ferr_ref ferr_isis_err[] = { { .code = ISIS_ERR_PACKET, @@ -39,6 +41,7 @@ static struct ferr_ref ferr_isis_err[] = { .code = END_FERR, } }; +/* clang-format on */ void isis_error_init(void) { diff --git a/isisd/isis_errors.h b/isisd/isis_errors.h index d92a4e4038..ffb000f9c9 100644 --- a/isisd/isis_errors.h +++ b/isisd/isis_errors.h @@ -1,27 +1,27 @@ /* - * isis_errors - header for error messages that may occur in the isis process + * ISIS-specific error messages. * Copyright (C) 2018 Cumulus Networks, Inc. * Donald Sharp * - * FRR is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * FRR is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * * You should have received a copy of the GNU General Public License along * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #ifndef __ISIS_ERRORS_H__ #define __ISIS_ERRORS_H__ -#include "ferr.h" -#include "isis_errors.h" +#include "lib/ferr.h" enum isis_ferr_refs { ISIS_ERR_PACKET = ISIS_FERR_START, diff --git a/lib/lib_errors.c b/lib/lib_errors.c index f53ff4e016..e08b03f17f 100644 --- a/lib/lib_errors.c +++ b/lib/lib_errors.c @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include "lib_errors.h" /* clang-format off */ static struct ferr_ref ferr_lib_err[] = { diff --git a/lib/lib_errors.h b/lib/lib_errors.h index 9e3383793a..8be33ae254 100644 --- a/lib/lib_errors.h +++ b/lib/lib_errors.h @@ -17,10 +17,11 @@ * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #ifndef __LIB_ERRORS_H__ #define __LIB_ERRORS_H__ -#include "ferr.h" +#include "lib/ferr.h" enum lib_ferr_refs { LIB_ERR_PRIVILEGES = LIB_FERR_START, diff --git a/nhrpd/nhrp_errors.c b/nhrpd/nhrp_errors.c index f0b2dcfc5b..71ec211136 100644 --- a/nhrpd/nhrp_errors.c +++ b/nhrpd/nhrp_errors.c @@ -1,27 +1,29 @@ /* - * nhrp_errors - code for error messages that may occur in the - * nhrp process + * NHRP-specific error messages. * Copyright (C) 2018 Cumulus Networks, Inc. * Donald Sharp * - * FRR is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * FRR is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * * You should have received a copy of the GNU General Public License along * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #include +#include "lib/ferr.h" #include "nhrp_errors.h" +/* clang-format off */ static struct ferr_ref ferr_nhrp_err[] = { { .code = NHRP_ERR_SWAN, @@ -39,6 +41,7 @@ static struct ferr_ref ferr_nhrp_err[] = { .code = END_FERR, } }; +/* clang-format on */ void nhrp_error_init(void) { diff --git a/nhrpd/nhrp_errors.h b/nhrpd/nhrp_errors.h index 2b3da04f7e..842af82012 100644 --- a/nhrpd/nhrp_errors.h +++ b/nhrpd/nhrp_errors.h @@ -1,27 +1,27 @@ /* - * nhrp_errors - header for error messages that may occur in the nhrp process + * NHRP-specific error messages. * Copyright (C) 2018 Cumulus Networks, Inc. * Donald Sharp * - * FRR is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * FRR is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * * You should have received a copy of the GNU General Public License along * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #ifndef __NHRP_ERRORS_H__ #define __NHRP_ERRORS_H__ -#include "ferr.h" -#include "nhrp_errors.h" +#include "lib/ferr.h" enum nhrp_ferr_refs { NHRP_ERR_SWAN = NHRP_FERR_START, diff --git a/ospfd/ospf_errors.c b/ospfd/ospf_errors.c index 7f94080ceb..f4ae731a9b 100644 --- a/ospfd/ospf_errors.c +++ b/ospfd/ospf_errors.c @@ -1,24 +1,26 @@ /* - * ospf_errors - code for error messages that may occur in the - * ospf process + * OSPF-specific error messages. * Copyright (C) 2018 Cumulus Networks, Inc. - * Chirag Shah + * Chirag Shah * - * FRR is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * FRR is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * * You should have received a copy of the GNU General Public License along * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #include + +#include "lib/ferr.h" #include "ospf_errors.h" static struct ferr_ref ferr_ospf_err[] = { diff --git a/ospfd/ospf_errors.h b/ospfd/ospf_errors.h index a9813640f9..0ba2d45e49 100644 --- a/ospfd/ospf_errors.h +++ b/ospfd/ospf_errors.h @@ -1,26 +1,27 @@ /* - * ospf_errors - header for error messages that may occur in the ospf process + * OSPF-specific error messages. * Copyright (C) 2018 Cumulus Networks, Inc. * Chirag Shah * - * FRR is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * FRR is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * * You should have received a copy of the GNU General Public License along * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #ifndef __OSPF_ERRORS_H__ #define __OSPF_ERRORS_H__ -#include "ferr.h" +#include "lib/ferr.h" enum ospf_ferr_refs { OSPF_ERR_PKT_PROCESS = OSPF_FERR_START, diff --git a/pimd/pim_errors.c b/pimd/pim_errors.c index ffffa8dd9f..15f0345f0c 100644 --- a/pimd/pim_errors.c +++ b/pimd/pim_errors.c @@ -1,27 +1,29 @@ /* - * pim_errors - code for error messages that may occur in the - * pim process + * PIM-specific error messages. * Copyright (C) 2018 Cumulus Networks, Inc. * Donald Sharp * - * FRR is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * FRR is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * * You should have received a copy of the GNU General Public License along * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #include +#include "lib/ferr.h" #include "pim_errors.h" +/* clang-format off */ static struct ferr_ref ferr_pim_err[] = { { .code = PIM_ERR_MSDP_PACKET, @@ -39,6 +41,7 @@ static struct ferr_ref ferr_pim_err[] = { .code = END_FERR, } }; +/* clang-format on */ void pim_error_init(void) { diff --git a/pimd/pim_errors.h b/pimd/pim_errors.h index bcb1628e62..86d2687feb 100644 --- a/pimd/pim_errors.h +++ b/pimd/pim_errors.h @@ -1,27 +1,27 @@ /* - * pim_errors - header for error messages that may occur in the pim process + * PIM-specific error messages. * Copyright (C) 2018 Cumulus Networks, Inc. * Donald Sharp * - * FRR is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * FRR is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * * You should have received a copy of the GNU General Public License along * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #ifndef __PIM_ERRORS_H__ #define __PIM_ERRORS_H__ -#include "ferr.h" -#include "pim_errors.h" +#include "lib/ferr.h" enum pim_ferr_refs { PIM_ERR_MSDP_PACKET = PIM_FERR_START, diff --git a/ripd/rip_errors.c b/ripd/rip_errors.c index 9fefec6841..4a2a2bd5a9 100644 --- a/ripd/rip_errors.c +++ b/ripd/rip_errors.c @@ -1,25 +1,26 @@ /* - * rip_errors - code for error messages that may occur in the - * rip process + * RIP-specific error messages. * Copyright (C) 2018 Cumulus Networks, Inc. * Donald Sharp * - * FRR is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * FRR is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * * You should have received a copy of the GNU General Public License along * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #include +#include "lib/ferr.h" #include "rip_errors.h" static struct ferr_ref ferr_rip_err[] = { diff --git a/ripd/rip_errors.h b/ripd/rip_errors.h index 6e2bdfc9eb..ff5851d095 100644 --- a/ripd/rip_errors.h +++ b/ripd/rip_errors.h @@ -1,27 +1,27 @@ /* - * rip_errors - header for error messages that may occur in the rip process + * RIP-specific error messages. * Copyright (C) 2018 Cumulus Networks, Inc. * Donald Sharp * - * FRR is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * FRR is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * * You should have received a copy of the GNU General Public License along * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #ifndef __RIP_ERRORS_H__ #define __RIP_ERRORS_H__ -#include "ferr.h" -#include "rip_errors.h" +#include "lib/ferr.h" enum rip_ferr_refs { RIP_ERR_PACKET = RIP_FERR_START, diff --git a/watchfrr/watchfrr_errors.c b/watchfrr/watchfrr_errors.c index 6b0f688121..9a4842a5df 100644 --- a/watchfrr/watchfrr_errors.c +++ b/watchfrr/watchfrr_errors.c @@ -1,27 +1,29 @@ /* - * watchfrr_errors - code for error messages that may occur in the - * watchfrr process + * Watchfrr-specific error messages. * Copyright (C) 2018 Cumulus Networks, Inc. * Donald Sharp * - * FRR is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * FRR is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * * You should have received a copy of the GNU General Public License along * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #include +#include "lib/ferr.h" #include "watchfrr_errors.h" +/* clang-format off */ static struct ferr_ref ferr_watchfrr_err[] = { { .code = WATCHFRR_ERR_CONNECTION, @@ -33,6 +35,7 @@ static struct ferr_ref ferr_watchfrr_err[] = { .code = END_FERR, } }; +/* clang-format on */ void watchfrr_error_init(void) { diff --git a/watchfrr/watchfrr_errors.h b/watchfrr/watchfrr_errors.h index bc0cc6f561..9d2912da46 100644 --- a/watchfrr/watchfrr_errors.h +++ b/watchfrr/watchfrr_errors.h @@ -1,28 +1,27 @@ /* - * watchfrr_errors - header for error messages that may occur in the - * watchfrr process + * Watchfrr-specific error messages. * Copyright (C) 2018 Cumulus Networks, Inc. * Donald Sharp * - * FRR is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * FRR is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * * You should have received a copy of the GNU General Public License along * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #ifndef __WATCHFRR_ERRORS_H__ #define __WATCHFRR_ERRORS_H__ #include "lib/ferr.h" -#include "watchfrr_errors.h" enum watchfrr_ferr_refs { WATCHFRR_ERR_CONNECTION = WATCHFRR_FERR_START, diff --git a/zebra/zebra_errors.c b/zebra/zebra_errors.c index 3f981bc5ef..f657bdcdc7 100644 --- a/zebra/zebra_errors.c +++ b/zebra/zebra_errors.c @@ -19,8 +19,9 @@ */ #include + +#include "lib/ferr.h" #include "zebra_errors.h" -#include "ferr.h" /* clang-format off */ static struct ferr_ref ferr_zebra_err[] = { diff --git a/zebra/zebra_errors.h b/zebra/zebra_errors.h index eea7af5c58..66771a33d6 100644 --- a/zebra/zebra_errors.h +++ b/zebra/zebra_errors.h @@ -21,8 +21,7 @@ #ifndef __ZEBRA_ERRORS_H__ #define __ZEBRA_ERRORS_H__ -#include -#include "ferr.h" +#include "lib/ferr.h" enum zebra_ferr_refs { ZEBRA_ERR_LM_RESPONSE, -- cgit v1.2.3 From 85cd2f9f9a43d0c536f445cc65b94a8d90bb4c97 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Fri, 3 Aug 2018 18:07:23 +0000 Subject: *: rename ferr_ref -> log_ref Signed-off-by: Quentin Young --- babeld/babel_errors.c | 4 ++-- babeld/babel_errors.h | 2 +- bgpd/bgp_errors.c | 4 ++-- bgpd/bgp_errors.h | 2 +- eigrpd/eigrp_errors.c | 4 ++-- eigrpd/eigrp_errors.h | 2 +- isisd/isis_errors.c | 4 ++-- isisd/isis_errors.h | 2 +- lib/ferr.c | 26 +++++++++++++------------- lib/ferr.h | 12 ++++++------ lib/lib_errors.c | 4 ++-- lib/lib_errors.h | 2 +- lib/libfrr.c | 4 ++-- nhrpd/nhrp_errors.c | 4 ++-- nhrpd/nhrp_errors.h | 2 +- ospfd/ospf_errors.c | 4 ++-- ospfd/ospf_errors.h | 2 +- pimd/pim_errors.c | 4 ++-- pimd/pim_errors.h | 2 +- ripd/rip_errors.c | 4 ++-- ripd/rip_errors.h | 2 +- watchfrr/watchfrr_errors.c | 4 ++-- watchfrr/watchfrr_errors.h | 2 +- zebra/zebra_errors.c | 4 ++-- zebra/zebra_errors.h | 2 +- 25 files changed, 54 insertions(+), 54 deletions(-) (limited to 'lib/lib_errors.h') diff --git a/babeld/babel_errors.c b/babeld/babel_errors.c index 9fabdf28b5..e03cace379 100644 --- a/babeld/babel_errors.c +++ b/babeld/babel_errors.c @@ -24,7 +24,7 @@ #include "babel_errors.h" /* clang-format off */ -static struct ferr_ref ferr_babel_err[] = { +static struct log_ref ferr_babel_err[] = { { .code = BABEL_ERR_MEMORY, .title = "BABEL Memory Errors", @@ -57,5 +57,5 @@ static struct ferr_ref ferr_babel_err[] = { void babel_error_init(void) { - ferr_ref_add(ferr_babel_err); + log_ref_add(ferr_babel_err); } diff --git a/babeld/babel_errors.h b/babeld/babel_errors.h index f03801272b..19adc63f04 100644 --- a/babeld/babel_errors.h +++ b/babeld/babel_errors.h @@ -23,7 +23,7 @@ #include "lib/ferr.h" -enum babel_ferr_refs { +enum babel_log_refs { BABEL_ERR_MEMORY = BABEL_FERR_START, BABEL_ERR_PACKET, BABEL_ERR_CONFIG, diff --git a/bgpd/bgp_errors.c b/bgpd/bgp_errors.c index 3674c33722..50dd001b8b 100644 --- a/bgpd/bgp_errors.c +++ b/bgpd/bgp_errors.c @@ -24,7 +24,7 @@ #include "bgp_errors.h" /* clang-format off */ -static struct ferr_ref ferr_bgp_err[] = { +static struct log_ref ferr_bgp_err[] = { { .code = BGP_ERR_ATTR_FLAG, .title = "BGP attribute flag is incorrect", @@ -302,5 +302,5 @@ static struct ferr_ref ferr_bgp_err[] = { void bgp_error_init(void) { - ferr_ref_add(ferr_bgp_err); + log_ref_add(ferr_bgp_err); } diff --git a/bgpd/bgp_errors.h b/bgpd/bgp_errors.h index 83b834688e..be718d99e7 100644 --- a/bgpd/bgp_errors.h +++ b/bgpd/bgp_errors.h @@ -23,7 +23,7 @@ #include "lib/ferr.h" -enum bgp_ferr_refs { +enum bgp_log_refs { BGP_ERR_ATTR_FLAG = BGP_FERR_START, BGP_ERR_ATTR_LEN, diff --git a/eigrpd/eigrp_errors.c b/eigrpd/eigrp_errors.c index 4e6337a7ba..3db0ec8545 100644 --- a/eigrpd/eigrp_errors.c +++ b/eigrpd/eigrp_errors.c @@ -24,7 +24,7 @@ #include "eigrp_errors.h" /* clang-format off */ -static struct ferr_ref ferr_eigrp_err[] = { +static struct log_ref ferr_eigrp_err[] = { { .code = EIGRP_ERR_PACKET, .title = "EIGRP Packet Error", @@ -45,5 +45,5 @@ static struct ferr_ref ferr_eigrp_err[] = { void eigrp_error_init(void) { - ferr_ref_add(ferr_eigrp_err); + log_ref_add(ferr_eigrp_err); } diff --git a/eigrpd/eigrp_errors.h b/eigrpd/eigrp_errors.h index e59a5d1e6e..e1ace8ab49 100644 --- a/eigrpd/eigrp_errors.h +++ b/eigrpd/eigrp_errors.h @@ -23,7 +23,7 @@ #include "lib/ferr.h" -enum eigrp_ferr_refs { +enum eigrp_log_refs { EIGRP_ERR_PACKET = EIGRP_FERR_START, EIGRP_ERR_CONFIG, }; diff --git a/isisd/isis_errors.c b/isisd/isis_errors.c index 3f69a10cab..ecff65da1f 100644 --- a/isisd/isis_errors.c +++ b/isisd/isis_errors.c @@ -24,7 +24,7 @@ #include "isis_errors.h" /* clang-format off */ -static struct ferr_ref ferr_isis_err[] = { +static struct log_ref ferr_isis_err[] = { { .code = ISIS_ERR_PACKET, .title = "ISIS Packet Error", @@ -45,5 +45,5 @@ static struct ferr_ref ferr_isis_err[] = { void isis_error_init(void) { - ferr_ref_add(ferr_isis_err); + log_ref_add(ferr_isis_err); } diff --git a/isisd/isis_errors.h b/isisd/isis_errors.h index ffb000f9c9..f738254a30 100644 --- a/isisd/isis_errors.h +++ b/isisd/isis_errors.h @@ -23,7 +23,7 @@ #include "lib/ferr.h" -enum isis_ferr_refs { +enum isis_log_refs { ISIS_ERR_PACKET = ISIS_FERR_START, ISIS_ERR_CONFIG, }; diff --git a/lib/ferr.c b/lib/ferr.c index b0a22d822e..2fa5db6f34 100644 --- a/lib/ferr.c +++ b/lib/ferr.c @@ -62,20 +62,20 @@ struct hash *refs; static int ferr_hash_cmp(const void *a, const void *b) { - const struct ferr_ref *f_a = a; - const struct ferr_ref *f_b = b; + const struct log_ref *f_a = a; + const struct log_ref *f_b = b; return f_a->code == f_b->code; } static inline unsigned int ferr_hash_key(void *a) { - struct ferr_ref *f = a; + struct log_ref *f = a; return f->code; } -void ferr_ref_add(struct ferr_ref *ref) +void log_ref_add(struct log_ref *ref) { uint32_t i = 0; @@ -89,10 +89,10 @@ void ferr_ref_add(struct ferr_ref *ref) pthread_mutex_unlock(&refs_mtx); } -struct ferr_ref *ferr_ref_get(uint32_t code) +struct log_ref *log_ref_get(uint32_t code) { - struct ferr_ref holder; - struct ferr_ref *ref; + struct log_ref holder; + struct log_ref *ref; holder.code = code; pthread_mutex_lock(&refs_mtx); @@ -104,9 +104,9 @@ struct ferr_ref *ferr_ref_get(uint32_t code) return ref; } -void ferr_ref_display(struct vty *vty, uint32_t code, bool json) +void log_ref_display(struct vty *vty, uint32_t code, bool json) { - struct ferr_ref *ref; + struct log_ref *ref; struct json_object *top, *obj; struct list *errlist; struct listnode *ln; @@ -121,7 +121,7 @@ void ferr_ref_display(struct vty *vty, uint32_t code, bool json) pthread_mutex_unlock(&refs_mtx); if (code) { - ref = ferr_ref_get(code); + ref = log_ref_get(code); if (!ref) { vty_out(vty, "Code %"PRIu32" - Unknown\n", code); return; @@ -181,11 +181,11 @@ DEFUN_NOSH(show_error_code, if (!strmatch(argv[2]->text, "all")) arg = strtoul(argv[2]->arg, NULL, 10); - ferr_ref_display(vty, arg, json); + log_ref_display(vty, arg, json); return CMD_SUCCESS; } -void ferr_ref_init(void) +void log_ref_init(void) { pthread_mutex_lock(&refs_mtx); { @@ -197,7 +197,7 @@ void ferr_ref_init(void) install_element(VIEW_NODE, &show_error_code_cmd); } -void ferr_ref_fini(void) +void log_ref_fini(void) { pthread_mutex_lock(&refs_mtx); { diff --git a/lib/ferr.h b/lib/ferr.h index 9e31c9a0a4..335875c166 100644 --- a/lib/ferr.h +++ b/lib/ferr.h @@ -132,7 +132,7 @@ struct ferr { #define ZEBRA_FERR_END 0xF1FFFFFF #define END_FERR 0xFFFFFFFF -struct ferr_ref { +struct log_ref { /* Unique error code displayed to end user as a reference. -1 means * this is an uncoded error that does not have reference material. */ uint32_t code; @@ -144,16 +144,16 @@ struct ferr_ref { const char *suggestion; }; -void ferr_ref_add(struct ferr_ref *ref); -struct ferr_ref *ferr_ref_get(uint32_t code); -void ferr_ref_display(struct vty *vty, uint32_t code, bool json); +void log_ref_add(struct log_ref *ref); +struct log_ref *log_ref_get(uint32_t code); +void log_ref_display(struct vty *vty, uint32_t code, bool json); /* * This function should be called by the * code in libfrr.c */ -void ferr_ref_init(void); -void ferr_ref_fini(void); +void log_ref_init(void); +void log_ref_fini(void); /* get error details. * diff --git a/lib/lib_errors.c b/lib/lib_errors.c index dcda9955df..332a5b1d45 100644 --- a/lib/lib_errors.c +++ b/lib/lib_errors.c @@ -21,7 +21,7 @@ #include "lib_errors.h" /* clang-format off */ -static struct ferr_ref ferr_lib_err[] = { +static struct log_ref ferr_lib_err[] = { { .code = LIB_ERR_PRIVILEGES, .title = "Failure to raise or lower privileges", @@ -114,5 +114,5 @@ static struct ferr_ref ferr_lib_err[] = { void lib_error_init(void) { - ferr_ref_add(ferr_lib_err); + log_ref_add(ferr_lib_err); } diff --git a/lib/lib_errors.h b/lib/lib_errors.h index 8be33ae254..84f5b8dc10 100644 --- a/lib/lib_errors.h +++ b/lib/lib_errors.h @@ -23,7 +23,7 @@ #include "lib/ferr.h" -enum lib_ferr_refs { +enum lib_log_refs { LIB_ERR_PRIVILEGES = LIB_FERR_START, LIB_ERR_VRF_START, LIB_ERR_SOCKET, diff --git a/lib/libfrr.c b/lib/libfrr.c index a49372675a..b7d4b192d5 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -599,7 +599,7 @@ struct thread_master *frr_init(void) vty_init(master); memory_init(); - ferr_ref_init(); + log_ref_init(); lib_error_init(); return master; @@ -941,7 +941,7 @@ void frr_fini(void) /* memory_init -> nothing needed */ vty_terminate(); cmd_terminate(); - ferr_ref_fini(); + log_ref_fini(); zprivs_terminate(di->privs); /* signal_init -> nothing needed */ thread_master_free(master); diff --git a/nhrpd/nhrp_errors.c b/nhrpd/nhrp_errors.c index 3c0d4c3e5e..c557ba8a66 100644 --- a/nhrpd/nhrp_errors.c +++ b/nhrpd/nhrp_errors.c @@ -24,7 +24,7 @@ #include "nhrp_errors.h" /* clang-format off */ -static struct ferr_ref ferr_nhrp_err[] = { +static struct log_ref ferr_nhrp_err[] = { { .code = NHRP_ERR_SWAN, .title = "NHRP Strong Swan Error", @@ -45,5 +45,5 @@ static struct ferr_ref ferr_nhrp_err[] = { void nhrp_error_init(void) { - ferr_ref_add(ferr_nhrp_err); + log_ref_add(ferr_nhrp_err); } diff --git a/nhrpd/nhrp_errors.h b/nhrpd/nhrp_errors.h index 842af82012..c9e947eb2a 100644 --- a/nhrpd/nhrp_errors.h +++ b/nhrpd/nhrp_errors.h @@ -23,7 +23,7 @@ #include "lib/ferr.h" -enum nhrp_ferr_refs { +enum nhrp_log_refs { NHRP_ERR_SWAN = NHRP_FERR_START, NHRP_ERR_RESOLVER, }; diff --git a/ospfd/ospf_errors.c b/ospfd/ospf_errors.c index 60eb3d5657..2927f7cb14 100644 --- a/ospfd/ospf_errors.c +++ b/ospfd/ospf_errors.c @@ -23,7 +23,7 @@ #include "lib/ferr.h" #include "ospf_errors.h" -static struct ferr_ref ferr_ospf_err[] = { +static struct log_ref ferr_ospf_err[] = { { .code = OSPF_ERR_PKT_PROCESS, .title = "Failure to process a packet", @@ -80,5 +80,5 @@ static struct ferr_ref ferr_ospf_err[] = { void ospf_error_init(void) { - ferr_ref_add(ferr_ospf_err); + log_ref_add(ferr_ospf_err); } diff --git a/ospfd/ospf_errors.h b/ospfd/ospf_errors.h index 0ba2d45e49..c3f1018550 100644 --- a/ospfd/ospf_errors.h +++ b/ospfd/ospf_errors.h @@ -23,7 +23,7 @@ #include "lib/ferr.h" -enum ospf_ferr_refs { +enum ospf_log_refs { OSPF_ERR_PKT_PROCESS = OSPF_FERR_START, OSPF_ERR_ROUTER_LSA_MISMATCH, OSPF_ERR_DOMAIN_CORRUPT, diff --git a/pimd/pim_errors.c b/pimd/pim_errors.c index 11451d5abd..d154752bdc 100644 --- a/pimd/pim_errors.c +++ b/pimd/pim_errors.c @@ -24,7 +24,7 @@ #include "pim_errors.h" /* clang-format off */ -static struct ferr_ref ferr_pim_err[] = { +static struct log_ref ferr_pim_err[] = { { .code = PIM_ERR_MSDP_PACKET, .title = "PIM MSDP Packet Error", @@ -45,5 +45,5 @@ static struct ferr_ref ferr_pim_err[] = { void pim_error_init(void) { - ferr_ref_add(ferr_pim_err); + log_ref_add(ferr_pim_err); } diff --git a/pimd/pim_errors.h b/pimd/pim_errors.h index 86d2687feb..ad9c95a93d 100644 --- a/pimd/pim_errors.h +++ b/pimd/pim_errors.h @@ -23,7 +23,7 @@ #include "lib/ferr.h" -enum pim_ferr_refs { +enum pim_log_refs { PIM_ERR_MSDP_PACKET = PIM_FERR_START, PIM_ERR_CONFIG, }; diff --git a/ripd/rip_errors.c b/ripd/rip_errors.c index 133d808524..363b1b7fb5 100644 --- a/ripd/rip_errors.c +++ b/ripd/rip_errors.c @@ -23,7 +23,7 @@ #include "lib/ferr.h" #include "rip_errors.h" -static struct ferr_ref ferr_rip_err[] = { +static struct log_ref ferr_rip_err[] = { { .code = RIP_ERR_PACKET, .title = "RIP Packet Error", @@ -37,5 +37,5 @@ static struct ferr_ref ferr_rip_err[] = { void rip_error_init(void) { - ferr_ref_add(ferr_rip_err); + log_ref_add(ferr_rip_err); } diff --git a/ripd/rip_errors.h b/ripd/rip_errors.h index ff5851d095..6b5f5c0169 100644 --- a/ripd/rip_errors.h +++ b/ripd/rip_errors.h @@ -23,7 +23,7 @@ #include "lib/ferr.h" -enum rip_ferr_refs { +enum rip_log_refs { RIP_ERR_PACKET = RIP_FERR_START, RIP_ERR_CONFIG, }; diff --git a/watchfrr/watchfrr_errors.c b/watchfrr/watchfrr_errors.c index 494132e52f..662e7f654d 100644 --- a/watchfrr/watchfrr_errors.c +++ b/watchfrr/watchfrr_errors.c @@ -24,7 +24,7 @@ #include "watchfrr_errors.h" /* clang-format off */ -static struct ferr_ref ferr_watchfrr_err[] = { +static struct log_ref ferr_watchfrr_err[] = { { .code = WATCHFRR_ERR_CONNECTION, .title = "WATCHFRR Connection Error", @@ -39,5 +39,5 @@ static struct ferr_ref ferr_watchfrr_err[] = { void watchfrr_error_init(void) { - ferr_ref_add(ferr_watchfrr_err); + log_ref_add(ferr_watchfrr_err); } diff --git a/watchfrr/watchfrr_errors.h b/watchfrr/watchfrr_errors.h index 9d2912da46..4652f950f4 100644 --- a/watchfrr/watchfrr_errors.h +++ b/watchfrr/watchfrr_errors.h @@ -23,7 +23,7 @@ #include "lib/ferr.h" -enum watchfrr_ferr_refs { +enum watchfrr_log_refs { WATCHFRR_ERR_CONNECTION = WATCHFRR_FERR_START, }; diff --git a/zebra/zebra_errors.c b/zebra/zebra_errors.c index 39e3939bb2..198e1cce23 100644 --- a/zebra/zebra_errors.c +++ b/zebra/zebra_errors.c @@ -24,7 +24,7 @@ #include "zebra_errors.h" /* clang-format off */ -static struct ferr_ref ferr_zebra_err[] = { +static struct log_ref ferr_zebra_err[] = { { .code = ZEBRA_ERR_LM_RESPONSE, .title = "Error reading response from label manager", @@ -274,5 +274,5 @@ static struct ferr_ref ferr_zebra_err[] = { void zebra_error_init(void) { - ferr_ref_add(ferr_zebra_err); + log_ref_add(ferr_zebra_err); } diff --git a/zebra/zebra_errors.h b/zebra/zebra_errors.h index f5f4894ece..f8a00bce0d 100644 --- a/zebra/zebra_errors.h +++ b/zebra/zebra_errors.h @@ -23,7 +23,7 @@ #include "lib/ferr.h" -enum zebra_ferr_refs { +enum zebra_log_refs { ZEBRA_ERR_LM_RESPONSE = ZEBRA_FERR_START, ZEBRA_ERR_LM_NO_SUCH_CLIENT, ZEBRA_ERR_LM_RELAY_FAILED, -- cgit v1.2.3