lib: Log invalid/unknown commands to log file

Ticket: CM-6855

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
Quentin Young 2016-10-06 18:39:31 +00:00
parent 56158e1235
commit cbd7259d95
2 changed files with 11 additions and 8 deletions

View File

@ -738,10 +738,6 @@ cmd_execute_command_real (vector vline,
case MATCHER_AMBIGUOUS:
return CMD_ERR_AMBIGUOUS;
default:
{} // C...
char *inputline = cmd_concat_strvec (vline);
zlog_err ("invalid command \"%s\" for node %d\n", inputline, vty->node);
free (inputline);
return CMD_ERR_NO_MATCH;
}
@ -909,10 +905,12 @@ command_config_read_one_line (struct vty *vty, struct cmd_element **cmd, int use
ret != CMD_WARNING)
{
vty->node = saved_node;
memcpy(vty->error_buf, vty->buf, VTY_BUFSIZ);
}
}
if (ret != CMD_SUCCESS && ret != CMD_WARNING)
memcpy (vty->error_buf, vty->buf, VTY_BUFSIZ);
cmd_free_strvec (vline);
return ret;

View File

@ -2361,17 +2361,22 @@ vty_read_file (FILE *confp)
if ( !((ret == CMD_SUCCESS) || (ret == CMD_ERR_NOTHING_TODO)) )
{
const char *message = NULL;
switch (ret)
{
case CMD_ERR_AMBIGUOUS:
fprintf (stderr, "*** Error reading config: Ambiguous command.\n");
message = "*** Error reading config: Ambiguous command.";
break;
case CMD_ERR_NO_MATCH:
fprintf (stderr, "*** Error reading config: There is no such command.\n");
message = "*** Error reading config: There is no such command.";
break;
}
fprintf (stderr, "*** Error occured processing line %u, below:\n%s\n",
fprintf (stderr, "%s\n", message);
zlog_err ("%s", message);
fprintf (stderr, "*** Error occurred processing line %u, below:\n%s\n",
line_num, vty->error_buf);
zlog_err ("*** Error occurred processing line %u, below:\n%s",
line_num, vty->error_buf);
}
vty_close (vty);