diff options
| author | Donald Sharp <donaldsharp72@gmail.com> | 2022-07-21 08:02:30 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-21 08:02:30 -0400 |
| commit | 7f74014f9903d0e4659649a25b0ab6870b716d2a (patch) | |
| tree | 51b4006df59139bc1ae723763bfed5c0d7b3efdd | |
| parent | efa98761d28b79796c0df91f823b241106d5f7b6 (diff) | |
| parent | ce2e1a0ed852a6d22385afba7ca44f9ec7f1454e (diff) | |
Merge pull request #11655 from opensourcerouting/fix/vtysh_end_parsing
vtysh: Ignore `end` when parsing frr.conf
| -rw-r--r-- | vtysh/vtysh.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 051b10c7d1..f39ecf0709 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); } |
