diff options
author | Christian Hopps <chopps@labn.net> | 2023-07-15 00:21:55 +0200 |
---|---|---|
committer | Christian Hopps <chopps@labn.net> | 2023-07-15 00:24:44 +0200 |
commit | 07035ce9548021c2d9484358aa620572d7dad851 (patch) | |
tree | a9d468b9ab4e007cd34330f31ac9d5232976d6b3 /vtysh | |
parent | lib: mgmtd: only clear pending for the in-progress command (diff) | |
download | frr-07035ce9548021c2d9484358aa620572d7dad851.tar.xz frr-07035ce9548021c2d9484358aa620572d7dad851.zip |
vtysh: track and fix file-lock use in the workaround from 2004
There's a workaround in the code from a bug from back in 2004, it ends
and re-enters config mode anytime an `exit` is done from a level below
the top-level config node (e.g., from a `router isis` node). We need to
re-enter config mode with or without a lock according to how we actually
entered it to begin with.
fixes #13920
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'vtysh')
-rw-r--r-- | vtysh/vtysh.c | 7 | ||||
-rw-r--r-- | vtysh/vtysh_config.c | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 6744bfe72..8b223d1aa 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -2357,8 +2357,13 @@ static int vtysh_exit(struct vty *vty) /* resync in case one of the daemons is somewhere else */ vtysh_execute("end"); /* NOTE: a rather expensive thing to do, can we avoid it? */ - vtysh_execute("configure terminal file-lock"); + + if (vty->vtysh_file_locked) + vtysh_execute("configure terminal file-lock"); + else + vtysh_execute("configure terminal"); } + return CMD_SUCCESS; } diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c index a5f790bbc..593de7ffb 100644 --- a/vtysh/vtysh_config.c +++ b/vtysh/vtysh_config.c @@ -607,7 +607,8 @@ static int vtysh_read_file(FILE *confp, bool dry_run) vty->node = CONFIG_NODE; vtysh_execute_no_pager("enable"); - vtysh_execute_no_pager("configure terminal file-lock"); + vtysh_execute_no_pager("conf term file-lock"); + vty->vtysh_file_locked = true; if (!dry_run) vtysh_execute_no_pager("XFRR_start_configuration"); @@ -619,6 +620,7 @@ static int vtysh_read_file(FILE *confp, bool dry_run) vtysh_execute_no_pager("XFRR_end_configuration"); vtysh_execute_no_pager("end"); + vty->vtysh_file_locked = false; vtysh_execute_no_pager("disable"); vty_close(vty); |