]> git.proxmox.com Git - mirror_frr.git/commitdiff
vtysh: fix failure to write config w/o watchfrr
authorQuentin Young <qlyoung@cumulusnetworks.com>
Wed, 25 Apr 2018 19:09:02 +0000 (15:09 -0400)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Mon, 30 Apr 2018 07:28:10 +0000 (03:28 -0400)
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
vtysh/vtysh.c

index cdc047e5ae0e9b5445d5f254fea68856b09138bf..867dc9cd1504a9fd4afd554b9078f32340f03a5a 100644 (file)
@@ -2611,20 +2611,25 @@ DEFUN (vtysh_write_memory,
        /* If integrated frr.conf explicitely set. */
        if (want_config_integrated()) {
                ret = CMD_WARNING_CONFIG_FAILED;
+
+               /* first attempt to use watchfrr if it's available */
+               bool used_watchfrr = false;
+
                for (i = 0; i < array_size(vtysh_client); i++)
                        if (vtysh_client[i].flag == VTYSH_WATCHFRR)
                                break;
-               if (i < array_size(vtysh_client) && vtysh_client[i].fd != -1)
+               if (i < array_size(vtysh_client) && vtysh_client[i].fd != -1) {
+                       used_watchfrr = true;
                        ret = vtysh_client_execute(&vtysh_client[i],
                                                   "do write integrated",
                                                   outputfile);
+               }
 
                /*
-                * If watchfrr returns CMD_WARNING_CONFIG_FAILED this means
-                * that it could not write the config, but additionally
-                * indicates that we should not try either
+                * If we didn't use watchfrr, fallback to writing the config
+                * ourselves
                 */
-               if (ret != CMD_SUCCESS && ret != CMD_WARNING_CONFIG_FAILED) {
+               if (!used_watchfrr) {
                        printf("\nWarning: attempting direct configuration write without "
                               "watchfrr.\nFile permissions and ownership may be "
                               "incorrect, or write may fail.\n\n");