summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristian Hopps <chopps@labn.net>2023-06-11 22:19:54 -0400
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2023-06-22 21:56:44 +0000
commitc874d567cce8932bf1238a5cc6d5427a18a53c8c (patch)
tree8f33d7e9beaaf69b43b4940fe82d70f8caf1cc29 /lib
parentcfca317c597b61049ba9123281b393ade48ca1b6 (diff)
lib: mgmtd: avoid recursion with vty_close and add error log
Avoid recursion into vty_close() when being notified of a session closure that happened inside vty_close(). If a vty is closed with outstanding config yet to be commited issue a warning that it is being lost. Signed-off-by: Christian Hopps <chopps@labn.net> (cherry picked from commit 4307fdd07047dc2f7c9daef7a74af6cddf635c34)
Diffstat (limited to 'lib')
-rw-r--r--lib/vty.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/vty.c b/lib/vty.c
index fedbdbb813..cbf42de473 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2423,6 +2423,14 @@ void vty_close(struct vty *vty)
vty->status = VTY_CLOSE;
+ /*
+ * If we reach here with pending config to commit we will be losing it
+ * so warn the user.
+ */
+ if (vty->mgmt_num_pending_setcfg)
+ MGMTD_FE_CLIENT_ERR(
+ "vty closed, uncommitted config will be lost.");
+
if (mgmt_fe_client && vty->mgmt_session_id) {
MGMTD_FE_CLIENT_DBG("closing vty session");
mgmt_fe_destroy_client_session(mgmt_fe_client,
@@ -3445,7 +3453,9 @@ static void vty_mgmt_session_notify(struct mgmt_fe_client *client,
vty->mgmt_session_id = session_id;
} else {
vty->mgmt_session_id = 0;
- vty_close(vty);
+ /* We may come here by way of vty_close() and short-circuits */
+ if (vty->status != VTY_CLOSE)
+ vty_close(vty);
}
}