summaryrefslogtreecommitdiffstats
path: root/watchfrr/watchfrr_vty.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2018-03-20 20:07:36 +0100
committerQuentin Young <qlyoung@cumulusnetworks.com>2018-03-21 08:11:02 +0100
commit470bc6191952eb590b8157c4928190ef66fdd6ba (patch)
tree364f0692071599bb1872b28590a266daadae4583 /watchfrr/watchfrr_vty.c
parentMerge pull request #1913 from LabNConsulting/working/master/bgp-vpn-leak-cli (diff)
downloadfrr-470bc6191952eb590b8157c4928190ef66fdd6ba.tar.xz
frr-470bc6191952eb590b8157c4928190ef66fdd6ba.zip
watchfrr, vtysh: do not write config during crash
If a daemon is restarting, crashed, or otherwise in the process of reconnecting to watchfrr and a user issues "write memory" or "write file" the resulting config will not include the configuration of that daemon. This is problematic because this output will overwrite the previous config, potentially causing unintentional loss of configuration stored only in the config file based upon timing. This patch remedies that by making watchfrr check that all daemons are up before attempting a configuration write, and updating vtysh so that its failsafe respects this condition as well. Note that this issue only manifests when using integrated config. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'watchfrr/watchfrr_vty.c')
-rw-r--r--watchfrr/watchfrr_vty.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/watchfrr/watchfrr_vty.c b/watchfrr/watchfrr_vty.c
index 1f872c91f..1bfc41f25 100644
--- a/watchfrr/watchfrr_vty.c
+++ b/watchfrr/watchfrr_vty.c
@@ -40,11 +40,24 @@ DEFUN(config_write_integrated,
pid_t child;
sigset_t oldmask, sigmask;
+ const char *e_inprog = "Configuration write already in progress.";
+ const char *e_dmn = "Not all daemons are up, cannot write config.";
+
if (integrated_write_pid != -1) {
- vty_out(vty, "%% configuration write already in progress.\n");
+ vty_out(vty, "%% %s\n", e_inprog);
return CMD_WARNING;
}
+ /* check that all daemons are up before clobbering config */
+ if (!check_all_up()) {
+ vty_out(vty, "%% %s\n", e_dmn);
+ /*
+ * vtysh interprets this return value to mean that it should
+ * not try to write the config itself
+ */
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+
fflush(stdout);
fflush(stderr);