]> git.puffer.fish Git - matthieu/frr.git/commitdiff
vtysh: track and fix file-lock use in the workaround from 2004
authorChristian Hopps <chopps@labn.net>
Fri, 14 Jul 2023 22:21:55 +0000 (18:21 -0400)
committerChristian Hopps <chopps@labn.net>
Sun, 16 Jul 2023 17:18:37 +0000 (13:18 -0400)
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>
lib/vty.h
vtysh/vtysh.c
vtysh/vtysh_config.c

index ac3d2e5019592635e037d245f004801dcb1d45a6..a8654f8b6999f7e0f1f4980c2492818b1e26c538 100644 (file)
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -231,6 +231,10 @@ struct vty {
        const char *mgmt_req_pending_cmd;
        bool mgmt_locked_candidate_ds;
        bool mgmt_locked_running_ds;
+       /* Need to track when we file-lock in vtysh to re-lock on end/conf t
+        * workaround
+        */
+       bool vtysh_file_locked;
 };
 
 static inline void vty_push_context(struct vty *vty, int node, uint64_t id)
index 6744bfe7283de5446a26bda658012b9dc1818744..8b223d1aa482091e494b5a58aa5d69f9ff8999b5 100644 (file)
@@ -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;
 }
 
index a5f790bbc62cdd50de624f96e2348545151ac153..593de7ffbc77a56777c10e299225b4ab52a0178f 100644 (file)
@@ -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);