]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: fix outdated candidate configuration issue
authorRenato Westphal <renato@opensourcerouting.org>
Mon, 27 May 2019 22:48:13 +0000 (19:48 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Tue, 9 Jul 2019 14:09:05 +0000 (11:09 -0300)
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>
lib/command.c
lib/vty.c

index b3ef028004f687dcf686c7669bc205f10a50548c..f427ccb4ca76f92a3b1d94a2d7a3847ff6e89210 100644 (file)
@@ -1052,9 +1052,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);
        }
index 0ee9b78b91f9afa77951178dbd734bd003396e08..b1ed3d63c0fff1e7c40f0f07cd3416611e145564 100644 (file)
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2308,6 +2308,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 {