mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-03 17:24:26 +00:00
lib: mgmtd: simplify implicit commit code
Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit 70ff6bb80b
)
This commit is contained in:
parent
5b14f854df
commit
ce23b1e4f4
@ -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;
|
||||
|
@ -3630,7 +3630,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];
|
||||
@ -3638,7 +3638,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) {
|
||||
/*
|
||||
@ -3712,7 +3711,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,
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user