summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-05-08 08:35:06 -0400
committerDonald Sharp <sharpd@cumulusnetworks.com>2018-06-19 08:43:59 -0400
commit9e224e60dbffd032d7271ec473366048fb6083d4 (patch)
tree818ad931fea867c8a1b8631aacf993b7a42bee28
parent573de11fab9c6ffd5b647ab1b9b0c23ad99fb52e (diff)
lib: Create a thread for reading in the cli
The read in of cli was happening prior to thread event handling for non-integrated configs. This is interesting for 2 reasons: 1) Read-in of integrated configs was after thread event loop startup, so we had a difference of behavior 2) Read-in can cause a series of events that cause us to attempt to communicate with zebra. The zebra zapi connection only happens after the thread event loop has been started. This can cause data that is being written down to zebra to be lost and no real way to notice that this has happened and to recover gracefully. Modify the code to create a thread event for read in of client config. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
-rw-r--r--lib/libfrr.c25
-rw-r--r--lib/libfrr.h2
2 files changed, 23 insertions, 4 deletions
diff --git a/lib/libfrr.c b/lib/libfrr.c
index 4620cb2586..4f3b8c66d6 100644
--- a/lib/libfrr.c
+++ b/lib/libfrr.c
@@ -721,20 +721,37 @@ static void frr_daemonize(void)
frr_daemon_wait(fds[0]);
}
-void frr_config_fork(void)
+/*
+ * Why is this a thread?
+ *
+ * The read in of config for integrated config happens *after*
+ * thread execution starts( because it is passed in via a vtysh -b -n )
+ * While if you are not using integrated config we want the ability
+ * to read the config in after thread execution starts, so that
+ * we can match this behavior.
+ */
+static int frr_config_read_in(struct thread *t)
{
- hook_call(frr_late_init, master);
-
if (!vty_read_config(di->config_file, config_default) &&
di->backup_config_file) {
zlog_info("Attempting to read backup config file: %s specified",
di->backup_config_file);
vty_read_config(di->backup_config_file, config_default);
}
+ return 0;
+}
+
+void frr_config_fork(void)
+{
+ hook_call(frr_late_init, master);
/* Don't start execution if we are in dry-run mode */
- if (di->dryrun)
+ if (di->dryrun) {
+ frr_config_read_in(NULL);
exit(0);
+ }
+
+ thread_add_event(master, frr_config_read_in, NULL, 0, &di->read_in);
if (di->daemon_mode || di->terminal)
frr_daemonize();
diff --git a/lib/libfrr.h b/lib/libfrr.h
index bd572cce1b..1c744ee1b9 100644
--- a/lib/libfrr.h
+++ b/lib/libfrr.h
@@ -50,6 +50,8 @@ struct frr_daemon_info {
bool dryrun;
bool daemon_mode;
bool terminal;
+
+ struct thread *read_in;
const char *config_file;
const char *backup_config_file;
const char *pid_file;