Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for file-lock mode of configuration node (backport #14498) #14501

Merged
merged 3 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -1335,8 +1335,8 @@ DEFUN (config_terminal,
config_terminal_cmd,
"configure [terminal [file-lock]]",
"Configuration from vty interface\n"
"Configuration with locked datastores\n"
"Configuration terminal\n")
"Configuration terminal\n"
"Configuration with locked datastores\n")
{
return vty_config_enter(vty, false, false, argc == 3);
}
Expand Down
8 changes: 8 additions & 0 deletions lib/vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -2884,6 +2884,12 @@ int vty_config_enter(struct vty *vty, bool private_config, bool exclusive,
}
assert(vty->mgmt_locked_candidate_ds);
assert(vty->mgmt_locked_running_ds);

/*
* As datastores are locked explicitly, we don't need implicit
* commits and should allow pending changes.
*/
vty->pending_allowed = true;
}

vty->node = CONFIG_NODE;
Expand Down Expand Up @@ -2940,6 +2946,8 @@ int vty_config_node_exit(struct vty *vty)

/* TODO: could we check for un-commited changes here? */

vty->pending_allowed = false;

if (vty->mgmt_locked_running_ds)
vty_mgmt_unlock_running_inline(vty);

Expand Down
16 changes: 14 additions & 2 deletions vtysh/vtysh.c
Original file line number Diff line number Diff line change
Expand Up @@ -2333,15 +2333,26 @@ DEFUNSH(VTYSH_REALLYALL, vtysh_disable, vtysh_disable_cmd, "disable",
}

DEFUNSH(VTYSH_REALLYALL, vtysh_config_terminal, vtysh_config_terminal_cmd,
"configure [terminal [file-lock]]",
"configure [terminal]",
"Configuration from vty interface\n"
"Configuration with locked datastores\n"
"Configuration terminal\n")
{
vty->node = CONFIG_NODE;
return CMD_SUCCESS;
}

DEFUNSH(VTYSH_REALLYALL, vtysh_config_terminal_file_lock,
vtysh_config_terminal_file_lock_cmd,
"configure terminal file-lock",
"Configuration from vty interface\n"
"Configuration terminal\n"
"Configuration with locked datastores\n")
{
vty->node = CONFIG_NODE;
vty->vtysh_file_locked = true;
return CMD_SUCCESS;
}

static int vtysh_exit(struct vty *vty)
{
struct cmd_node *cnode = vector_lookup(cmdvec, vty->node);
Expand Down Expand Up @@ -4930,6 +4941,7 @@ void vtysh_init_vty(void)
if (!user_mode)
install_element(VIEW_NODE, &vtysh_enable_cmd);
install_element(ENABLE_NODE, &vtysh_config_terminal_cmd);
install_element(ENABLE_NODE, &vtysh_config_terminal_file_lock_cmd);
install_element(ENABLE_NODE, &vtysh_disable_cmd);

/* "exit" command. */
Expand Down
Loading