From 518e377f395ccd83aa084cebace6ea340afd83b0 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 19 Jun 2018 16:13:45 -0400 Subject: [PATCH] ripd: Add RIP_ERR_XXX to move from zlog_err to zlog_ferr Signed-off-by: Donald Sharp --- ripd/rip_errors.c | 42 ++++++++++++++++++++++++++++++++++++++++++ ripd/rip_errors.h | 33 +++++++++++++++++++++++++++++++++ ripd/rip_main.c | 2 ++ ripd/ripd.c | 7 ++++--- ripd/subdir.am | 2 ++ 5 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 ripd/rip_errors.c create mode 100644 ripd/rip_errors.h diff --git a/ripd/rip_errors.c b/ripd/rip_errors.c new file mode 100644 index 0000000000..9fefec6841 --- /dev/null +++ b/ripd/rip_errors.c @@ -0,0 +1,42 @@ +/* + * rip_errors - code for error messages that may occur in the + * rip process + * 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. + * + * 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. + * + * 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 "rip_errors.h" + +static struct ferr_ref ferr_rip_err[] = { + { + .code = RIP_ERR_PACKET, + .title = "RIP Packet Error", + .description = "RIP has detected a packet encode/decode issue", + .suggestion = "Gather log files from both sides and open a Issue" + }, + { + .code = END_FERR, + } +}; + +void rip_error_init(void) +{ + ferr_ref_init(); + + ferr_ref_add(ferr_rip_err); +} diff --git a/ripd/rip_errors.h b/ripd/rip_errors.h new file mode 100644 index 0000000000..6e2bdfc9eb --- /dev/null +++ b/ripd/rip_errors.h @@ -0,0 +1,33 @@ +/* + * rip_errors - header for error messages that may occur in the rip process + * 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. + * + * 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. + * + * 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" + +enum rip_ferr_refs { + RIP_ERR_PACKET = RIP_FERR_START, + RIP_ERR_CONFIG, +}; + +extern void rip_error_init(void); + +#endif diff --git a/ripd/rip_main.c b/ripd/rip_main.c index 0194e53128..e5a5c3e227 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -37,6 +37,7 @@ #include "libfrr.h" #include "ripd/ripd.h" +#include "ripd/rip_errors.h" /* ripd options. */ #if CONFDATE > 20190521 @@ -167,6 +168,7 @@ int main(int argc, char **argv) master = frr_init(); /* Library initialization. */ + rip_error_init(); keychain_init(); vrf_init(NULL, NULL, NULL, NULL); diff --git a/ripd/ripd.c b/ripd/ripd.c index b91e7a4ced..a0e38a7cdd 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -44,6 +44,7 @@ #include "ripd/ripd.h" #include "ripd/rip_debug.h" +#include "ripd/rip_errors.h" DEFINE_QOBJ_TYPE(rip) @@ -1057,9 +1058,9 @@ static void rip_auth_md5_set(struct stream *s, struct rip_interface *ri, /* Check packet length. */ if (len < (RIP_HEADER_SIZE + RIP_RTE_SIZE)) { - zlog_err( - "rip_auth_md5_set(): packet length %ld is less than minimum length.", - len); + zlog_ferr(RIP_ERR_PACKET, + "rip_auth_md5_set(): packet length %ld is less than minimum length.", + len); return; } diff --git a/ripd/subdir.am b/ripd/subdir.am index 1c5167ef4a..612db1a7ab 100644 --- a/ripd/subdir.am +++ b/ripd/subdir.am @@ -13,6 +13,7 @@ endif ripd_librip_a_SOURCES = \ ripd/rip_debug.c \ + ripd/rip_errors.c \ ripd/rip_interface.c \ ripd/rip_memory.c \ ripd/rip_offset.c \ @@ -24,6 +25,7 @@ ripd_librip_a_SOURCES = \ noinst_HEADERS += \ ripd/rip_debug.h \ + ripd/rip_errors.h \ ripd/rip_interface.h \ ripd/rip_memory.h \ ripd/ripd.h \ -- 2.39.5