summaryrefslogtreecommitdiff
path: root/lib/vty.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2018-09-09 00:03:19 +0200
committerDavid Lamparter <equinox@diac24.net>2020-04-16 12:54:03 +0200
commit791ded4a62b86d3e05d28e70864ee2723d91bc69 (patch)
tree6ee63e5d866dc790ffccbf6648f8a605eb3ebae4 /lib/vty.c
parent893d8beb4d1ae92b7c3290aad163e65aa0675a5c (diff)
*: add ->node_exit to struct cmd_node
Rather than doing a f*gly hack for the RPKI code, let's do an on-exit hook in cmd_node. Also allows replacing some special-casing in the vty code. Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib/vty.c')
-rw-r--r--lib/vty.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/vty.c b/lib/vty.c
index 683c39f893..86d0a36aa0 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2199,6 +2199,9 @@ void vty_close(struct vty *vty)
int i;
bool was_stdio = false;
+ /* Drop out of configure / transaction if needed. */
+ vty_config_exit(vty);
+
/* Cancel threads.*/
THREAD_OFF(vty->t_read);
THREAD_OFF(vty->t_write);
@@ -2242,9 +2245,6 @@ void vty_close(struct vty *vty)
list_delete(&vty->error);
}
- /* Check configure. */
- vty_config_exit(vty);
-
/* OK free vty. */
XFREE(MTYPE_VTY, vty);
@@ -2614,14 +2614,18 @@ void vty_config_exit(struct vty *vty)
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");
+ if (node != CONFIG_NODE)
+ /* called outside config, e.g. vty_close() in ENABLE_NODE */
return;
- }
while (vty->node != ENABLE_NODE)
+ /* will call vty_config_node_exit() below */
cmd_exit(vty);
+}
+
+int vty_config_node_exit(struct vty *vty)
+{
+ vty->xpath_index = 0;
/* Check if there's a pending confirmed commit. */
if (vty->t_confirmed_commit_timeout) {
@@ -2644,6 +2648,7 @@ void vty_config_exit(struct vty *vty)
}
vty->config = false;
+ return 1;
}
/* Master of the threads. */