summaryrefslogtreecommitdiffstats
path: root/mgmtd
diff options
context:
space:
mode:
authorChristian Hopps <chopps@labn.net>2023-03-31 18:34:49 +0200
committerChristian Hopps <chopps@labn.net>2023-04-02 00:06:43 +0200
commit8033bf3976d85c84f00a3ab320eca5fc8418d756 (patch)
tree945221853843902b26bb0ba00facc01dae628ad7 /mgmtd
parentmgmtd: remove startup config feature for now (diff)
downloadfrr-8033bf3976d85c84f00a3ab320eca5fc8418d756.tar.xz
frr-8033bf3976d85c84f00a3ab320eca5fc8418d756.zip
mgmtd: lib: read transitioned daemons split config files in mgmtd
When daemons transition to mgmtd they should stop reading their split config files, and let mgmtd do that, otherwise things can get out of sync. Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'mgmtd')
-rw-r--r--mgmtd/mgmt.h2
-rw-r--r--mgmtd/mgmt_main.c7
-rw-r--r--mgmtd/mgmt_vty.c31
3 files changed, 40 insertions, 0 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_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 79fa54a79..1ad60ba7c 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"
@@ -439,6 +441,33 @@ DEFPY(debug_mgmt,
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)
{
/*
@@ -452,6 +481,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);