summaryrefslogtreecommitdiffstats
path: root/vtysh
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2022-07-20 21:57:33 +0200
committerDonatas Abraitis <donatas@opensourcerouting.org>2022-07-20 21:57:33 +0200
commitce2e1a0ed852a6d22385afba7ca44f9ec7f1454e (patch)
tree50a97963773806bdc8217e4957a951c33b347799 /vtysh
parentMerge pull request #11643 from ARShreenidhi/df_or_ntw_auto (diff)
downloadfrr-ce2e1a0ed852a6d22385afba7ca44f9ec7f1454e.tar.xz
frr-ce2e1a0ed852a6d22385afba7ca44f9ec7f1454e.zip
vtysh: Ignore `end` when parsing frr.conf
If we have `end` at the end of the frr.conf, then we never execute XFRR_end_configuration command, and start/end markers do not work. This leads to for example waiting BGP configuration parsing thread to hang, and the peers are in shutdown state until the timer expires. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Diffstat (limited to 'vtysh')
-rw-r--r--vtysh/vtysh.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index 051b10c7d..f39ecf070 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -886,10 +886,23 @@ int vtysh_config_from_file(struct vty *vty, FILE *fp)
int lineno = 0;
/* once we have an error, we remember & return that */
int retcode = CMD_SUCCESS;
+ char *vty_buf_copy = XCALLOC(MTYPE_VTYSH_CMD, VTY_BUFSIZ);
+ char *vty_buf_trimmed = NULL;
while (fgets(vty->buf, VTY_BUFSIZ, fp)) {
lineno++;
+ strlcpy(vty_buf_copy, vty->buf, VTY_BUFSIZ);
+ vty_buf_trimmed = trim(vty_buf_copy);
+
+ /*
+ * Ignore the "end" lines, we will generate these where
+ * appropriate, otherwise we never execute
+ * XFRR_end_configuration, and start/end markers do not work.
+ */
+ if (strmatch(vty_buf_trimmed, "end"))
+ continue;
+
ret = command_config_read_one_line(vty, &cmd, lineno, 1);
switch (ret) {
@@ -956,6 +969,8 @@ int vtysh_config_from_file(struct vty *vty, FILE *fp)
}
}
+ XFREE(MTYPE_VTYSH_CMD, vty_buf_copy);
+
return (retcode);
}