summaryrefslogtreecommitdiff
path: root/mgmtd/mgmt_history.c
diff options
context:
space:
mode:
authorPushpasis Sarkar <pushpasis.frr@gmail.com>2023-03-14 03:36:06 -0700
committerChristian Hopps <chopps@gmail.com>2023-03-22 05:22:56 +0000
commit1401ee8bf74b7688ca5f5bdfc3411734e9f0cb3b (patch)
tree04c63358d2e90417cf95dd0eee6968a3f9c08521 /mgmtd/mgmt_history.c
parentf82370b47bddb214d53ffb94775805d637300e9b (diff)
lib, mgmtd: Add few fixes for commit-check and rollback
This commit contains fixes for the following issues found - 'mgmt commit check' issued through 'vtysh -f' was actually commtting the changeset. - On config validation failure backend, mgmtd was not passing the correct error-reason to frontend. - 'mgmt rollback ...' was reverting the change on backend, but config on mgmtd daemon remains intact Signed-off-by: Pushpasis Sarkar <pushpasis@gmail.com>
Diffstat (limited to 'mgmtd/mgmt_history.c')
-rw-r--r--mgmtd/mgmt_history.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/mgmtd/mgmt_history.c b/mgmtd/mgmt_history.c
index 4fecfa9835..75def3a05e 100644
--- a/mgmtd/mgmt_history.c
+++ b/mgmtd/mgmt_history.c
@@ -29,7 +29,11 @@ DECLARE_DLIST(mgmt_cmt_infos, struct mgmt_cmt_info_t, cmts);
#define FOREACH_CMT_REC(mm, cmt_info) \
frr_each_safe (mgmt_cmt_infos, &mm->cmts, cmt_info)
-
+/*
+ * The only instance of VTY session that has triggered an ongoing
+ * config rollback operation.
+ */
+static struct vty *rollback_vty = NULL;
static bool mgmt_history_record_exists(char *file_path)
{
@@ -194,6 +198,11 @@ static int mgmt_history_rollback_to_cmt(struct vty *vty,
struct mgmt_ds_ctx *dst_ds_ctx;
int ret = 0;
+ if (rollback_vty) {
+ vty_out(vty, "ERROR: Rollback already in progress!\n");
+ return -1;
+ }
+
src_ds_ctx = mgmt_ds_get_ctx_by_id(mm, MGMTD_DS_CANDIDATE);
if (!src_ds_ctx) {
vty_out(vty, "ERROR: Couldnot access Candidate datastore!\n");
@@ -241,9 +250,23 @@ static int mgmt_history_rollback_to_cmt(struct vty *vty,
}
mgmt_history_dump_cmt_record_index();
+
+ /*
+ * Block the rollback command from returning till the rollback
+ * is completed. On rollback completion mgmt_history_rollback_complete()
+ * shall be called to resume the rollback command return to VTYSH.
+ */
+ vty->mgmt_req_pending = true;
+ rollback_vty = vty;
return 0;
}
+void mgmt_history_rollback_complete(bool success)
+{
+ vty_mgmt_resume_response(rollback_vty, success);
+ rollback_vty = NULL;
+}
+
int mgmt_history_rollback_by_id(struct vty *vty, const char *cmtid_str)
{
int ret = 0;