]> git.puffer.fish Git - matthieu/frr.git/commitdiff
vtysh: clean vtysh_file_locked when exiting config node
authorIgor Ryzhov <iryzhov@nfware.com>
Thu, 16 Nov 2023 19:00:07 +0000 (20:00 +0100)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Mon, 20 Nov 2023 20:19:45 +0000 (20:19 +0000)
The flag should be cleared to make sure it's not reused the next time
we enter the config node.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
(cherry picked from commit 40def43dfa889b43f343498dae0cd196420a4023)

vtysh/vtysh.c

index bd283803fedc55d8fbb032d7ece79ddee4de9012..e87a69d821181f8f34e1f205aade7514d6c66643 100644 (file)
@@ -1652,6 +1652,7 @@ static int vtysh_end(void)
                /* Nothing to do. */
                break;
        default:
+               vty->vtysh_file_locked = false;
                vty->node = ENABLE_NODE;
                break;
        }
@@ -2396,14 +2397,18 @@ static int vtysh_exit(struct vty *vty)
                vty->node = cnode->parent_node;
 
        if (vty->node == CONFIG_NODE) {
+               bool locked = vty->vtysh_file_locked;
+
                /* resync in case one of the daemons is somewhere else */
                vtysh_execute("end");
                /* NOTE: a rather expensive thing to do, can we avoid it? */
 
-               if (vty->vtysh_file_locked)
+               if (locked)
                        vtysh_execute("configure terminal file-lock");
                else
                        vtysh_execute("configure terminal");
+       } else if (vty->node == ENABLE_NODE) {
+               vty->vtysh_file_locked = false;
        }
 
        return CMD_SUCCESS;