]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: mgmtd: simplify implicit commit code
authorChristian Hopps <chopps@labn.net>
Fri, 9 Jun 2023 20:52:56 +0000 (16:52 -0400)
committerChristian Hopps <chopps@labn.net>
Mon, 12 Jun 2023 11:22:30 +0000 (07:22 -0400)
Signed-off-by: Christian Hopps <chopps@labn.net>
lib/northbound_cli.c
lib/vty.c
lib/vty.h
mgmtd/mgmt_vty.c

index e9c89d202906dfac18c38d70b086cb7c6adee212..9d6ec6668900bd1051fb3db3e5d54c0af4d5694f 100644 (file)
@@ -202,7 +202,7 @@ int nb_cli_apply_changes(struct vty *vty, const char *xpath_base_fmt, ...)
                        return CMD_SUCCESS;
 
                implicit_commit = vty_needs_implicit_commit(vty);
-               ret = vty_mgmt_send_config_data(vty);
+               ret = vty_mgmt_send_config_data(vty, implicit_commit);
                if (ret >= 0 && !implicit_commit)
                        vty->mgmt_num_pending_setcfg++;
                return ret;
@@ -229,9 +229,16 @@ int nb_cli_apply_changes_clear_pending(struct vty *vty,
 
        if (vty_mgmt_should_process_cli_apply_changes(vty)) {
                VTY_CHECK_XPATH;
-
+               /*
+                * The legacy user wanted to clear pending (i.e., perform a
+                * commit immediately) due to some non-yang compatible
+                * functionality. This new mgmtd code however, continues to send
+                * changes putting off the commit until XFRR_end is received
+                * (i.e., end-of-config-file). This should be fine b/c all
+                * conversions to mgmtd require full proper implementations.
+                */
                implicit_commit = vty_needs_implicit_commit(vty);
-               ret = vty_mgmt_send_config_data(vty);
+               ret = vty_mgmt_send_config_data(vty, implicit_commit);
                if (ret >= 0 && !implicit_commit)
                        vty->mgmt_num_pending_setcfg++;
                return ret;
index fedbdbb81316124edad18731bb909fad581acd41..c2eb78852e53b467b1b5f5e6ece4fb1843c6abb2 100644 (file)
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -3620,7 +3620,7 @@ int vty_mgmt_send_lockds_req(struct vty *vty, Mgmtd__DatastoreId ds_id,
        return 0;
 }
 
-int vty_mgmt_send_config_data(struct vty *vty)
+int vty_mgmt_send_config_data(struct vty *vty, bool implicit_commit)
 {
        Mgmtd__YangDataValue value[VTY_MAXCFGCHANGES];
        Mgmtd__YangData cfg_data[VTY_MAXCFGCHANGES];
@@ -3628,7 +3628,6 @@ int vty_mgmt_send_config_data(struct vty *vty)
        Mgmtd__YangCfgDataReq *cfgreq[VTY_MAXCFGCHANGES] = {0};
        size_t indx;
        int cnt;
-       bool implicit_commit = false;
 
        if (vty->type == VTY_FILE) {
                /*
@@ -3702,7 +3701,6 @@ int vty_mgmt_send_config_data(struct vty *vty)
                }
 
                vty->mgmt_req_id++;
-               implicit_commit = vty_needs_implicit_commit(vty);
                if (cnt && mgmt_fe_send_setcfg_req(
                                   mgmt_fe_client, vty->mgmt_session_id,
                                   vty->mgmt_req_id, MGMTD_DS_CANDIDATE, cfgreq,
index 28f27d0d4777e60b208420f5586f5030e32ba9db..3ad5c16365144cc852c3925518187c5ae59bbc6c 100644 (file)
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -147,7 +147,6 @@ struct vty {
        /* Dynamic transaction information. */
        bool pending_allowed;
        bool pending_commit;
-       bool no_implicit_commit;
        char *pending_cmds_buf;
        size_t pending_cmds_buflen;
        size_t pending_cmds_bufpos;
@@ -408,7 +407,7 @@ extern bool vty_mgmt_fe_enabled(void);
 extern bool vty_mgmt_should_process_cli_apply_changes(struct vty *vty);
 
 extern bool mgmt_vty_read_configs(void);
-extern int vty_mgmt_send_config_data(struct vty *vty);
+extern int vty_mgmt_send_config_data(struct vty *vty, bool implicit_commit);
 extern int vty_mgmt_send_commit_config(struct vty *vty, bool validate_only,
                                       bool abort);
 extern int vty_mgmt_send_get_config(struct vty *vty,
@@ -422,11 +421,7 @@ extern void vty_mgmt_resume_response(struct vty *vty, bool success);
 
 static inline bool vty_needs_implicit_commit(struct vty *vty)
 {
-       return (frr_get_cli_mode() == FRR_CLI_CLASSIC
-                       ? ((vty->pending_allowed || vty->no_implicit_commit)
-                                  ? false
-                                  : true)
-                       : false);
+       return frr_get_cli_mode() == FRR_CLI_CLASSIC && !vty->pending_allowed;
 }
 
 #ifdef __cplusplus
index 93c5145d712e20726e21db6c018f5affadbb6b68..6a6f32353df44d0de4b2b1f53ab52d844131a462 100644 (file)
@@ -157,9 +157,7 @@ DEFPY(mgmt_set_config_data, mgmt_set_config_data_cmd,
        vty->cfg_changes[0].operation = NB_OP_CREATE;
        vty->num_cfg_changes = 1;
 
-       vty->no_implicit_commit = true;
-       vty_mgmt_send_config_data(vty);
-       vty->no_implicit_commit = false;
+       vty_mgmt_send_config_data(vty, false);
        return CMD_SUCCESS;
 }
 
@@ -176,9 +174,7 @@ DEFPY(mgmt_delete_config_data, mgmt_delete_config_data_cmd,
        vty->cfg_changes[0].operation = NB_OP_DESTROY;
        vty->num_cfg_changes = 1;
 
-       vty->no_implicit_commit = true;
-       vty_mgmt_send_config_data(vty);
-       vty->no_implicit_commit = false;
+       vty_mgmt_send_config_data(vty, false);
        return CMD_SUCCESS;
 }