diff options
author | Jafar Al-Gharaibeh <jafar@atcorp.com> | 2023-04-04 15:42:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-04 15:42:04 +0200 |
commit | 3b28a5ef6b9b7296196f5f65de493668307be5cb (patch) | |
tree | 44e4a1d21e4840034ce285740dbe17e92f2841b9 /mgmtd | |
parent | Merge pull request #12969 from opensourcerouting/ospfd-nssa (diff) | |
parent | mgmtd: lib: read transitioned daemons split config files in mgmtd (diff) | |
download | frr-3b28a5ef6b9b7296196f5f65de493668307be5cb.tar.xz frr-3b28a5ef6b9b7296196f5f65de493668307be5cb.zip |
Merge pull request #13131 from LabNConsulting/chopps/no-startup-file
mgmtd: remove startup config feature for now
Diffstat (limited to 'mgmtd')
-rw-r--r-- | mgmtd/mgmt.h | 2 | ||||
-rw-r--r-- | mgmtd/mgmt_ds.c | 24 | ||||
-rw-r--r-- | mgmtd/mgmt_ds.h | 2 | ||||
-rw-r--r-- | mgmtd/mgmt_main.c | 7 | ||||
-rw-r--r-- | mgmtd/mgmt_vty.c | 31 |
5 files changed, 40 insertions, 26 deletions
diff --git a/mgmtd/mgmt.h b/mgmtd/mgmt.h index 4d186c176..9579b0223 100644 --- a/mgmtd/mgmt.h +++ b/mgmtd/mgmt.h @@ -62,6 +62,8 @@ struct mgmt_master { }; extern struct mgmt_master *mm; +extern char const *const mgmt_daemons[]; +extern uint mgmt_daemons_count; /* Inline functions */ static inline unsigned long timeval_elapsed(struct timeval a, struct timeval b) diff --git a/mgmtd/mgmt_ds.c b/mgmtd/mgmt_ds.c index 1724afb18..10b3cecb9 100644 --- a/mgmtd/mgmt_ds.c +++ b/mgmtd/mgmt_ds.c @@ -87,7 +87,6 @@ static int mgmt_ds_replace_dst_with_src_ds(struct mgmt_ds_ctx *src, struct mgmt_ds_ctx *dst) { struct lyd_node *dst_dnode, *src_dnode; - struct ly_out *out; if (!src || !dst) return -1; @@ -117,13 +116,6 @@ static int mgmt_ds_replace_dst_with_src_ds(struct mgmt_ds_ctx *src, nb_config_diff_del_changes(&src->root.cfg_root->cfg_chgs); } - if (dst->ds_id == MGMTD_DS_RUNNING) { - if (ly_out_new_filepath(MGMTD_STARTUP_DS_FILE_PATH, &out) - == LY_SUCCESS) - mgmt_ds_dump_in_memory(dst, "", LYD_JSON, out); - ly_out_free(out, NULL, 0); - } - /* TODO: Update the versions if nb_config present */ return 0; @@ -134,7 +126,6 @@ static int mgmt_ds_merge_src_with_dst_ds(struct mgmt_ds_ctx *src, { int ret; struct lyd_node **dst_dnode, *src_dnode; - struct ly_out *out; if (!src || !dst) return -1; @@ -159,13 +150,6 @@ static int mgmt_ds_merge_src_with_dst_ds(struct mgmt_ds_ctx *src, nb_config_diff_del_changes(&src->root.cfg_root->cfg_chgs); } - if (dst->ds_id == MGMTD_DS_RUNNING) { - if (ly_out_new_filepath(MGMTD_STARTUP_DS_FILE_PATH, &out) - == LY_SUCCESS) - mgmt_ds_dump_in_memory(dst, "", LYD_JSON, out); - ly_out_free(out, NULL, 0); - } - return 0; } @@ -200,8 +184,6 @@ void mgmt_ds_reset_candidate(void) int mgmt_ds_init(struct mgmt_master *mm) { - struct lyd_node *root; - if (mgmt_ds_mm || mm->running_ds || mm->candidate_ds || mm->oper_ds) assert(!"MGMTD: Call ds_init only once!"); @@ -209,12 +191,6 @@ int mgmt_ds_init(struct mgmt_master *mm) if (!running_config) assert(!"MGMTD: Call ds_init after frr_init only!"); - if (mgmt_ds_load_cfg_from_file(MGMTD_STARTUP_DS_FILE_PATH, &root) - == 0) { - nb_config_free(running_config); - running_config = nb_config_new(root); - } - running.root.cfg_root = running_config; running.config_ds = true; running.ds_id = MGMTD_DS_RUNNING; diff --git a/mgmtd/mgmt_ds.h b/mgmtd/mgmt_ds.h index 89a2ea942..8d01f3d5b 100644 --- a/mgmtd/mgmt_ds.h +++ b/mgmtd/mgmt_ds.h @@ -24,8 +24,6 @@ #define MGMTD_DS_NAME_CANDIDATE "candidate" #define MGMTD_DS_NAME_OPERATIONAL "operational" -#define MGMTD_STARTUP_DS_FILE_PATH DAEMON_DB_DIR "/frr_startup.json" - #define FOREACH_MGMTD_DS_ID(id) \ for ((id) = MGMTD_DS_NONE; (id) < MGMTD_DS_MAX_ID; (id)++) diff --git a/mgmtd/mgmt_main.c b/mgmtd/mgmt_main.c index 7d176059f..08c999260 100644 --- a/mgmtd/mgmt_main.c +++ b/mgmtd/mgmt_main.c @@ -17,6 +17,13 @@ #include "routing_nb.h" +char const *const mgmt_daemons[] = { +#ifdef HAVE_STATICD + "staticd", +#endif +}; +uint mgmt_daemons_count = array_size(mgmt_daemons); + /* mgmt options, we use GNU getopt library. */ static const struct option longopts[] = { {"skip_runas", no_argument, NULL, 'S'}, diff --git a/mgmtd/mgmt_vty.c b/mgmtd/mgmt_vty.c index 898eb4391..cb09544fd 100644 --- a/mgmtd/mgmt_vty.c +++ b/mgmtd/mgmt_vty.c @@ -10,6 +10,8 @@ #include "command.h" #include "json.h" +#include "northbound_cli.h" + #include "mgmtd/mgmt.h" #include "mgmtd/mgmt_be_server.h" #include "mgmtd/mgmt_be_adapter.h" @@ -455,6 +457,33 @@ DEFPY(debug_mgmt, debug_mgmt_cmd, return CMD_SUCCESS; } +/* + * Analog of `frr_config_read_in()`, instead of our config file though we loop + * over all daemons that have transitioned to mgmtd, loading their configs + */ +static int mgmt_config_pre_hook(struct event_loop *loop) +{ + FILE *confp; + char *p; + + for (uint i = 0; i < mgmt_daemons_count; i++) { + p = asprintfrr(MTYPE_TMP, "%s/%s.conf", frr_sysconfdir, + mgmt_daemons[i]); + confp = fopen(p, "r"); + if (confp == NULL) { + if (errno != ENOENT) + zlog_err("%s: couldn't read config file %s: %s", + __func__, p, safe_strerror(errno)); + } else { + zlog_info("mgmtd: reading daemon config from %s", p); + vty_read_file(vty_shared_candidate_config, confp); + fclose(confp); + } + XFREE(MTYPE_TMP, p); + } + return 0; +} + void mgmt_vty_init(void) { /* @@ -468,6 +497,8 @@ void mgmt_vty_init(void) static_vty_init(); #endif + hook_register(frr_config_pre, mgmt_config_pre_hook); + install_node(&debug_node); install_element(VIEW_NODE, &show_mgmt_be_adapter_cmd); |