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

lib: fix outdated candidate configuration issue #4506

Merged
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
lib: fix outdated candidate configuration issue
Even when using the classic CLI mode (i.e. when --tcli is not
used), the northbound code still uses vty->candidate_config
to perform configuration changes. From the perspective of the
user, the running configuration is being edited directly, but
under the hood the northbound layer does a full configuration
transaction for each command.  When the running configuration is
edited by a northbound client other than the CLI (e.g. kernel,
gRPC), vty->candidate_config might become outdated, and this can
lead to lots of weird problems. To fix this, always regenerate
vty->candidate_config before each configuration command when
using the classic CLI mode. When using the transactional CLI,
the user needs to update the candidate manually using the "update"
command, otherwise the "commit" command will fail with this error:
"% Candidate configuration needs to be updated before commit".

Fixes some problems reported by Don after moving an interface from
one VRF to another one while zebra is running.

Reported-by: Don Slice <dslice@cumulusnetworks.com>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
  • Loading branch information
rwestphal committed Jun 12, 2019
commit eaf6705d7a9fdcfd48c8fb51fc4fe7cffd7701f2
13 changes: 10 additions & 3 deletions lib/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -1053,9 +1053,16 @@ static int cmd_execute_command_real(vector vline, enum cmd_filter_type filter,
if (matched_element->daemon)
ret = CMD_SUCCESS_DAEMON;
else {
/* Clear enqueued configuration changes. */
vty->num_cfg_changes = 0;
memset(&vty->cfg_changes, 0, sizeof(vty->cfg_changes));
if (vty->config) {
/* Clear array of enqueued configuration changes. */
vty->num_cfg_changes = 0;
memset(&vty->cfg_changes, 0, sizeof(vty->cfg_changes));

/* Regenerate candidate configuration. */
if (frr_get_cli_mode() == FRR_CLI_CLASSIC)
nb_config_replace(vty->candidate_config,
running_config, true);
}

ret = matched_element->func(matched_element, vty, argc, argv);
}
Expand Down
1 change: 1 addition & 0 deletions lib/vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -2289,6 +2289,7 @@ static void vty_read_file(struct nb_config *config, FILE *confp)
vty->wfd = STDERR_FILENO;
vty->type = VTY_FILE;
vty->node = CONFIG_NODE;
vty->config = true;
if (config)
vty->candidate_config = config;
else {
Expand Down