summaryrefslogtreecommitdiffstats
path: root/mgmtd/mgmt_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'mgmtd/mgmt_main.c')
-rw-r--r--mgmtd/mgmt_main.c154
1 files changed, 75 insertions, 79 deletions
diff --git a/mgmtd/mgmt_main.c b/mgmtd/mgmt_main.c
index 39362fa..cce16f5 100644
--- a/mgmtd/mgmt_main.c
+++ b/mgmtd/mgmt_main.c
@@ -14,18 +14,21 @@
#include "frr_pthread.h"
#include "mgmtd/mgmt.h"
#include "mgmtd/mgmt_ds.h"
+#include "ripd/rip_nb.h"
+#include "ripngd/ripng_nb.h"
#include "routing_nb.h"
-
+#include "affinitymap.h"
+#include "zebra/zebra_cli.h"
/* mgmt options, we use GNU getopt library. */
static const struct option longopts[] = {
{"skip_runas", no_argument, NULL, 'S'},
{"no_zebra", no_argument, NULL, 'Z'},
{"socket_size", required_argument, NULL, 's'},
+ {"vrfwnetns", no_argument, NULL, 'n'},
{0}};
static void mgmt_exit(int);
-static void mgmt_vrf_terminate(void);
/* privileges */
static zebra_capabilities_t _caps_p[] = {ZCAP_BIND, ZCAP_NET_RAW,
@@ -45,7 +48,6 @@ struct zebra_privs_t mgmt_privs = {
};
static struct frr_daemon_info mgmtd_di;
-char backup_config_file[256];
/* SIGHUP handler. */
static void sighup(void)
@@ -114,8 +116,6 @@ static __attribute__((__noreturn__)) void mgmt_exit(int status)
/* stop pthreads (if any) */
frr_pthread_stop_all();
- mgmt_vrf_terminate();
-
frr_fini();
exit(status);
}
@@ -139,87 +139,81 @@ static struct frr_signal_t mgmt_signals[] = {
},
};
-static int mgmt_vrf_new(struct vrf *vrf)
-{
- zlog_debug("VRF Created: %s(%u)", vrf->name, vrf->vrf_id);
-
- return 0;
-}
-
-static int mgmt_vrf_delete(struct vrf *vrf)
-{
- zlog_debug("VRF Deletion: %s(%u)", vrf->name, vrf->vrf_id);
-
- return 0;
-}
-
-static int mgmt_vrf_enable(struct vrf *vrf)
-{
- zlog_debug("VRF Enable: %s(%u)", vrf->name, vrf->vrf_id);
-
- return 0;
-}
-
-static int mgmt_vrf_disable(struct vrf *vrf)
-{
- zlog_debug("VRF Disable: %s(%u)", vrf->name, vrf->vrf_id);
-
- /* Note: This is a callback, the VRF will be deleted by the caller. */
- return 0;
-}
-
-static int mgmt_vrf_config_write(struct vty *vty)
-{
- return 0;
-}
+#ifdef HAVE_STATICD
+extern const struct frr_yang_module_info frr_staticd_cli_info;
+#endif
-static void mgmt_vrf_init(void)
-{
- vrf_init(mgmt_vrf_new, mgmt_vrf_enable, mgmt_vrf_disable,
- mgmt_vrf_delete);
- vrf_cmd_init(mgmt_vrf_config_write);
-}
+/*
+ * These are modules that are only needed by mgmtd and hence not included into
+ * the lib and backend daemons.
+ */
+const struct frr_yang_module_info ietf_netconf_with_defaults_info = {
+ .name = "ietf-netconf-with-defaults",
+ .ignore_cfg_cbs = true,
+ .nodes = { { .xpath = NULL } },
+};
-static void mgmt_vrf_terminate(void)
-{
- vrf_terminate();
-}
+/*
+ * These are stub info structs that are used to load the modules used by backend
+ * clients into mgmtd. The modules are used by libyang in order to support
+ * parsing binary data returns from the backend.
+ */
+const struct frr_yang_module_info zebra_route_map_info = {
+ .name = "frr-zebra-route-map",
+ .ignore_cfg_cbs = true,
+ .nodes = { { .xpath = NULL } },
+};
/*
* List of YANG modules to be loaded in the process context of
* MGMTd.
- *
- * NOTE: In future this will also include the YANG modules of
- * all individual Backend clients.
*/
static const struct frr_yang_module_info *const mgmt_yang_modules[] = {
- &frr_filter_info,
- &frr_interface_info,
- &frr_route_map_info,
- &frr_routing_info,
- &frr_vrf_info,
-/*
- * YANG module info supported by backend clients get added here.
- * NOTE: Always set .ignore_cbs true for to avoid validating
- * backend northbound callbacks during loading.
- */
+ &frr_filter_cli_info,
+ &frr_interface_cli_info,
+ &frr_route_map_cli_info,
+ &frr_routing_cli_info,
+ &frr_vrf_cli_info,
+ &frr_affinity_map_cli_info,
+
+ /* mgmtd-only modules */
+ &ietf_netconf_with_defaults_info,
+
+ /*
+ * YANG module info used by backend clients get added here.
+ */
+
+ &frr_zebra_cli_info,
+ &zebra_route_map_info,
+
+#ifdef HAVE_RIPD
+ &frr_ripd_cli_info,
+#endif
+#ifdef HAVE_RIPNGD
+ &frr_ripngd_cli_info,
+#endif
#ifdef HAVE_STATICD
- &(struct frr_yang_module_info){.name = "frr-staticd",
- .ignore_cbs = true},
+ &frr_staticd_cli_info,
#endif
};
-FRR_DAEMON_INFO(mgmtd, MGMTD, .vty_port = MGMTD_VTY_PORT,
+/* clang-format off */
+FRR_DAEMON_INFO(mgmtd, MGMTD,
+ .vty_port = MGMTD_VTY_PORT,
+ .proghelp = "FRR Management Daemon.",
- .proghelp = "FRR Management Daemon.",
+ .signals = mgmt_signals,
+ .n_signals = array_size(mgmt_signals),
- .signals = mgmt_signals, .n_signals = array_size(mgmt_signals),
+ .privs = &mgmt_privs,
- .privs = &mgmt_privs, .yang_modules = mgmt_yang_modules,
- .n_yang_modules = array_size(mgmt_yang_modules),
+ .yang_modules = mgmt_yang_modules,
+ .n_yang_modules = array_size(mgmt_yang_modules),
- /* avoid libfrr trying to read our config file for us */
- .flags = FRR_MANUAL_VTY_START);
+ /* avoid libfrr trying to read our config file for us */
+ .flags = FRR_MANUAL_VTY_START | FRR_NO_SPLIT_CONFIG,
+);
+/* clang-format on */
#define DEPRECATED_OPTIONS ""
@@ -235,8 +229,9 @@ int main(int argc, char **argv)
frr_preinit(&mgmtd_di, argc, argv);
frr_opt_add(
- "s:" DEPRECATED_OPTIONS, longopts,
- " -s, --socket_size Set MGMTD peer socket send buffer size\n");
+ "s:n" DEPRECATED_OPTIONS, longopts,
+ " -s, --socket_size Set MGMTD peer socket send buffer size\n"
+ " -n, --vrfwnetns Use NetNS as VRF backend\n");
/* Command line argument treatment. */
while (1) {
@@ -258,6 +253,9 @@ int main(int argc, char **argv)
case 's':
buffer_size = atoi(optarg);
break;
+ case 'n':
+ vrf_configure_backend(VRF_BACKEND_NETNS);
+ break;
default:
frr_help_exit(1);
break;
@@ -267,17 +265,15 @@ int main(int argc, char **argv)
/* MGMTD master init. */
mgmt_master_init(frr_init(), buffer_size);
- /* VRF Initializations. */
- mgmt_vrf_init();
+ /* VRF commands initialization. */
+ vrf_cmd_init(NULL);
+
+ /* Interface commands initialization. */
+ if_cmd_init(NULL);
/* MGMTD related initialization. */
mgmt_init();
- snprintf(backup_config_file, sizeof(backup_config_file),
- "%s/zebra.conf", frr_sysconfdir);
- mgmtd_di.backup_config_file = backup_config_file;
-
- /* this will queue a read configs event */
frr_config_fork();
frr_run(mm->master);