From ab99c8e2b87e9d0ecfb91f6a05010948f9949cee Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 14 Jun 2018 09:21:11 -0400 Subject: [PATCH] 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(-) 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 -- 2.39.5