vtysh: stop reading config file if user exits from root level.

This is required to make sure that we properly send the
XFRR_end_configuration tag to the daemons. Previously if the user had an
`exit` at the root level the parser would just drop out of the config
node and so XFRR_end_configuration, even if sent, would be ignored

Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
Christian Hopps 2023-06-11 17:53:10 -04:00
parent f7a2c2ab5a
commit 315e9032e4

View File

@ -880,6 +880,13 @@ int vtysh_config_from_file(struct vty *vty, FILE *fp)
if (strmatch(vty_buf_trimmed, "end"))
continue;
if (strmatch(vty_buf_trimmed, "exit") &&
vty->node == CONFIG_NODE) {
fprintf(stderr, "line %d: Warning[%d]...: %s\n", lineno,
vty->node, "early exit from config file");
break;
}
ret = command_config_read_one_line(vty, &cmd, lineno, 1);
switch (ret) {