summaryrefslogtreecommitdiff
path: root/lib/vty.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2018-09-08 23:15:09 +0200
committerDavid Lamparter <equinox@diac24.net>2020-04-16 12:53:00 +0200
commit243895805abcd27cc23f784c0b42036197fa1c3c (patch)
treeb1cbf49040a4a5ce981ef84541cd8ad30384d4d4 /lib/vty.c
parent612c2c15d86e0e5c7e35f1a9a1491f90f365b93c (diff)
*: move CLI parent data to cmd_node->parent_node
Same as before, instead of shoving this into a big central list we can just put the parent node in cmd_node. Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib/vty.c')
-rw-r--r--lib/vty.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/vty.c b/lib/vty.c
index 1d94d3d310..24cdfeda42 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2605,6 +2605,24 @@ int vty_config_enter(struct vty *vty, bool private_config, bool exclusive)
void vty_config_exit(struct vty *vty)
{
+ enum node_type node = vty->node;
+ struct cmd_node *cnode;
+
+ /* unlock and jump up to ENABLE_NODE if -and only if- we're
+ * somewhere below CONFIG_NODE */
+ while (node && node != CONFIG_NODE) {
+ cnode = vector_lookup(cmdvec, node);
+ node = cnode->parent_node;
+ }
+ if (node != CONFIG_NODE) {
+ vty_out(vty,
+ "WARNING: vty_config_exit() from outside CONFIG_NODE!\n");
+ return;
+ }
+
+ while (vty->node != ENABLE_NODE)
+ cmd_exit(vty);
+
/* Check if there's a pending confirmed commit. */
if (vty->t_confirmed_commit_timeout) {
vty_out(vty,
@@ -2992,6 +3010,7 @@ static int vty_config_write(struct vty *vty)
static int vty_config_write(struct vty *vty);
struct cmd_node vty_node = {
.node = VTY_NODE,
+ .parent_node = CONFIG_NODE,
.prompt = "%s(config-line)# ",
.config_write = vty_config_write,
};