diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2019-10-09 22:17:08 -0300 |
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2019-10-11 21:18:36 -0300 |
| commit | 91f9fd78cb32396e95567fc59ec9741b620c22be (patch) | |
| tree | 88781f91e3e645226c210ea9c433881dc2c32336 | |
| parent | 5e6a9350c16f54113eeedb497c98fe45b8ce6222 (diff) | |
lib: optimize loading of the startup configuration
Load the startup configuration directly into the CLI shared candidate
configuration instead of loading it into a private candidate
configuration. This way we don't need to initialize the shared
candidate separately later as a copy of the running configuration,
which is a potentially expensive operation.
Also, make the northbound process SIGHUP correctly even when --tcli
is not used.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
| -rw-r--r-- | lib/libfrr.c | 22 | ||||
| -rw-r--r-- | lib/vty.c | 3 |
2 files changed, 18 insertions, 7 deletions
diff --git a/lib/libfrr.c b/lib/libfrr.c index d4aa1f899a..8ef32eaa8a 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -853,22 +853,34 @@ static void frr_daemonize(void) */ static int frr_config_read_in(struct thread *t) { - if (!vty_read_config(NULL, di->config_file, config_default) && - di->backup_config_file) { + if (!vty_read_config(vty_shared_candidate_config, di->config_file, + config_default) + && di->backup_config_file) { char *orig = XSTRDUP(MTYPE_TMP, host_config_get()); zlog_info("Attempting to read backup config file: %s specified", di->backup_config_file); - vty_read_config(NULL, di->backup_config_file, config_default); + vty_read_config(vty_shared_candidate_config, + di->backup_config_file, config_default); host_config_set(orig); XFREE(MTYPE_TMP, orig); } /* - * Update the shared candidate after reading the startup configuration. + * Automatically commit the candidate configuration after + * reading the configuration file. */ - nb_config_replace(vty_shared_candidate_config, running_config, true); + if (frr_get_cli_mode() == FRR_CLI_TRANSACTIONAL) { + int ret; + + ret = nb_candidate_commit(vty_shared_candidate_config, + NB_CLIENT_CLI, NULL, true, + "Read configuration file", NULL); + if (ret != NB_OK && ret != NB_ERR_NO_CHANGES) + zlog_err("%s: failed to read configuration file.", + __func__); + } return 0; } @@ -2341,8 +2341,7 @@ static void vty_read_file(struct nb_config *config, FILE *confp) * Automatically commit the candidate configuration after * reading the configuration file. */ - if (config == NULL && vty->candidate_config - && frr_get_cli_mode() == FRR_CLI_TRANSACTIONAL) { + if (config == NULL) { ret = nb_candidate_commit(vty->candidate_config, NB_CLIENT_CLI, vty, true, "Read configuration file", NULL); |
