lib: Add LIB_ERR_VTY

Add a error code for when the vty subsystem detects
an error.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2018-06-14 09:21:11 -04:00 committed by Quentin Young
parent 481bc15ffc
commit ab99c8e2b8
3 changed files with 17 additions and 6 deletions

View File

@ -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,
}

View File

@ -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);

View File

@ -40,6 +40,7 @@
#include "network.h"
#include "libfrr.h"
#include "frrstr.h"
#include "lib_errors.h"
#include <arpa/telnet.h>
#include <termios.h>
@ -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