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

vtysh: clean vtysh_file_locked when exiting config node #14813

Merged
merged 1 commit into from
Nov 20, 2023
Merged
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
7 changes: 6 additions & 1 deletion vtysh/vtysh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1652,6 +1652,7 @@ static int vtysh_end(void)
/* Nothing to do. */
break;
default:
vty->vtysh_file_locked = false;
vty->node = ENABLE_NODE;
break;
}
Expand Down Expand Up @@ -2396,14 +2397,18 @@ static int vtysh_exit(struct vty *vty)
vty->node = cnode->parent_node;

if (vty->node == CONFIG_NODE) {
bool locked = vty->vtysh_file_locked;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of adding a bool here? Why isn't the if (vty->vtysh_file_locked) sufficient?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vty->vtysh_file_locked will be overwritten by vtysh_execute("end") on the next line. We need to remember it.


/* resync in case one of the daemons is somewhere else */
vtysh_execute("end");
/* NOTE: a rather expensive thing to do, can we avoid it? */

if (vty->vtysh_file_locked)
if (locked)
vtysh_execute("configure terminal file-lock");
else
vtysh_execute("configure terminal");
} else if (vty->node == ENABLE_NODE) {
vty->vtysh_file_locked = false;
}

return CMD_SUCCESS;
Expand Down
Loading