Skip to content

Commit

Permalink
zebra: convert interface configuration to mgmtd
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Ryzhov <[email protected]>
  • Loading branch information
idryzhov committed Jan 25, 2024
1 parent a100989 commit 66fe8cd
Show file tree
Hide file tree
Showing 18 changed files with 2,143 additions and 1,985 deletions.
14 changes: 1 addition & 13 deletions lib/vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ bool vty_log_commands;
static bool vty_log_commands_perm;

char const *const mgmt_daemons[] = {
"zebra",
#ifdef HAVE_STATICD
"staticd",
#endif
Expand Down Expand Up @@ -2256,19 +2257,6 @@ bool mgmt_vty_read_configs(void)

snprintf(path, sizeof(path), "%s/mgmtd.conf", frr_sysconfdir);
confp = vty_open_config(path, config_default);
if (!confp) {
char *orig;

snprintf(path, sizeof(path), "%s/zebra.conf", frr_sysconfdir);
orig = XSTRDUP(MTYPE_TMP, host_config_get());

zlog_info("mgmtd: trying backup config file: %s", path);
confp = vty_open_config(path, config_default);

host_config_set(path);
XFREE(MTYPE_TMP, orig);
}

if (confp) {
zlog_info("mgmtd: reading config file: %s", path);

Expand Down
7 changes: 7 additions & 0 deletions mgmtd/mgmt_be_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ struct mgmt_be_xpath_map {
uint64_t clients;
};

static const char *const zebra_config_xpaths[] = {
"/frr-affinity-map:lib",
"/frr-interface:lib",
NULL,
};

/*
* Each client gets their own map, but also union all the strings into the
* above map as well.
Expand All @@ -68,6 +74,7 @@ static const char *const staticd_config_xpaths[] = {
#endif

static const char *const *be_client_config_xpaths[MGMTD_BE_CLIENT_ID_MAX] = {
[MGMTD_BE_CLIENT_ID_ZEBRA] = zebra_config_xpaths,
#ifdef HAVE_STATICD
[MGMTD_BE_CLIENT_ID_STATICD] = staticd_config_xpaths,
#endif
Expand Down
24 changes: 2 additions & 22 deletions mgmtd/mgmt_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "mgmtd/mgmt_ds.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[] = {
Expand Down Expand Up @@ -141,32 +142,11 @@ static struct frr_signal_t mgmt_signals[] = {
extern const struct frr_yang_module_info frr_staticd_info;
#endif

#if HAVE_BFDD == 0 || defined(HAVE_RTADV)
const char *zebra_features[] = {
#if HAVE_BFDD == 0
"ptm-bfd",
#endif
#if defined(HAVE_RTADV)
"ipv6-router-advertisements",
#endif
NULL
};
#endif

/*
* 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_info = {
.name = "frr-zebra",
#if HAVE_BFDD == 0 || defined(HAVE_RTADV)
.features = zebra_features,
#endif
.ignore_cfg_cbs = true,
.nodes = { { .xpath = NULL } },
};

const struct frr_yang_module_info zebra_route_map_info = {
.name = "frr-zebra-route-map",
.ignore_cfg_cbs = true,
Expand All @@ -189,7 +169,7 @@ static const struct frr_yang_module_info *const mgmt_yang_modules[] = {
* YANG module info used by backend clients get added here.
*/

&zebra_info,
&frr_zebra_cli_info,
&zebra_route_map_info,

#ifdef HAVE_STATICD
Expand Down
3 changes: 3 additions & 0 deletions mgmtd/mgmt_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "mgmtd/mgmt_history.h"

#include "mgmtd/mgmt_vty_clippy.c"
#include "zebra/zebra_cli.h"

extern struct frr_daemon_info *mgmt_daemon_info;

Expand Down Expand Up @@ -569,6 +570,8 @@ void mgmt_vty_init(void)
*/
affinity_map_init();

zebra_cli_init();

#if HAVE_STATICD
extern void static_vty_init(void);
static_vty_init();
Expand Down
7 changes: 6 additions & 1 deletion mgmtd/subdir.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ clippy_scan += \
# end

lib_LTLIBRARIES += mgmtd/libmgmt_be_nb.la
nodist_mgmtd_libmgmt_be_nb_la_SOURCES = \
mgmtd_libmgmt_be_nb_la_SOURCES = \
lib/affinitymap_cli.c \
zebra/zebra_cli.c \
# end
nodist_mgmtd_libmgmt_be_nb_la_SOURCES = \
# end
mgmtd_libmgmt_be_nb_la_CFLAGS = $(AM_CFLAGS) -DINCLUDE_MGMTD_CMDDEFS_ONLY
mgmtd_libmgmt_be_nb_la_CPPFLAGS = $(AM_CPPFLAGS) -DINCLUDE_MGMTD_CMDDEFS_ONLY
Expand All @@ -42,6 +45,7 @@ noinst_HEADERS += \
mgmtd/mgmt_history.h \
mgmtd/mgmt_memory.h \
mgmtd/mgmt_txn.h \
zebra/zebra_cli.h \
# end

sbin_PROGRAMS += mgmtd/mgmtd
Expand All @@ -50,6 +54,7 @@ mgmtd_mgmtd_SOURCES = \
mgmtd/mgmt_main.c \
# end
nodist_mgmtd_mgmtd_SOURCES = \
yang/frr-zebra.yang.c \
# nothing
mgmtd_mgmtd_CFLAGS = $(AM_CFLAGS) -I ./
mgmtd_mgmtd_LDADD = mgmtd/libmgmtd.a lib/libfrr.la $(LIBCAP) $(LIBM) $(LIBYANG_LIBS) $(UST_LIBS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
"interface": [
{
"name": "r1-eth0",
"description": "r1-eth0-desc"
"description": "r1-eth0-desc",
"frr-zebra:zebra": {
"ipv4-addrs": [
{
"ip": "1.1.1.1",
"prefix-length": 24
}
]
}
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
"phy-address": "rubout"
},
"frr-zebra:zebra": {
"ipv4-addrs": [
{
"ip": "1.1.1.1",
"prefix-length": 24
}
],
"state": {
"up-count": 0,
"down-count": 0
Expand Down
12 changes: 6 additions & 6 deletions vtysh/vtysh.c
Original file line number Diff line number Diff line change
Expand Up @@ -3007,38 +3007,38 @@ DEFUN (vtysh_show_work_queues_daemon,
return show_one_daemon(vty, argv, argc - 1, argv[argc - 1]->text);
}

DEFUNSH(VTYSH_ZEBRA, vtysh_link_params, vtysh_link_params_cmd, "link-params",
DEFUNSH(VTYSH_MGMTD, vtysh_link_params, vtysh_link_params_cmd, "link-params",
LINK_PARAMS_STR)
{
vty->node = LINK_PARAMS_NODE;
return CMD_SUCCESS;
}

DEFUNSH_HIDDEN(VTYSH_ZEBRA, no_link_params_enable, no_link_params_enable_cmd,
"no enable", NO_STR "Disable link parameters on this interface\n")
DEFUNSH_HIDDEN(VTYSH_MGMTD, no_link_params_enable, no_link_params_enable_cmd,
"no enable", NO_STR "Disable link parameters on this interface\n")
{
if (vty->node == LINK_PARAMS_NODE)
vty->node = INTERFACE_NODE;
return CMD_SUCCESS;
}

DEFUNSH(VTYSH_ZEBRA, exit_link_params, exit_link_params_cmd, "exit-link-params",
DEFUNSH(VTYSH_MGMTD, exit_link_params, exit_link_params_cmd, "exit-link-params",
"Exit from Link Params configuration node\n")
{
if (vty->node == LINK_PARAMS_NODE)
vty->node = INTERFACE_NODE;
return CMD_SUCCESS;
}

DEFUNSH(VTYSH_ZEBRA, vtysh_exit_link_params, vtysh_exit_link_params_cmd, "exit",
DEFUNSH(VTYSH_MGMTD, vtysh_exit_link_params, vtysh_exit_link_params_cmd, "exit",
"Exit current mode and down to previous mode\n")
{
if (vty->node == LINK_PARAMS_NODE)
vty->node = INTERFACE_NODE;
return CMD_SUCCESS;
}

DEFUNSH(VTYSH_ZEBRA, vtysh_quit_link_params, vtysh_quit_link_params_cmd, "quit",
DEFUNSH(VTYSH_MGMTD, vtysh_quit_link_params, vtysh_quit_link_params_cmd, "quit",
"Exit current mode and down to previous mode\n")
{
return vtysh_exit_link_params(self, vty, argc, argv);
Expand Down
12 changes: 6 additions & 6 deletions vtysh/vtysh.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ extern struct event_loop *master;
VTYSH_SHARPD | VTYSH_PBRD | VTYSH_STATICD | VTYSH_BFDD | \
VTYSH_FABRICD | VTYSH_VRRPD | VTYSH_PATHD | VTYSH_MGMTD
#define VTYSH_ACL VTYSH_BFDD|VTYSH_BABELD|VTYSH_BGPD|VTYSH_EIGRPD|VTYSH_ISISD|VTYSH_FABRICD|VTYSH_LDPD|VTYSH_NHRPD|VTYSH_OSPF6D|VTYSH_OSPFD|VTYSH_PBRD|VTYSH_PIMD|VTYSH_PIM6D|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_VRRPD|VTYSH_ZEBRA
#define VTYSH_AFFMAP VTYSH_ZEBRA | VTYSH_ISISD | VTYSH_MGMTD
#define VTYSH_AFFMAP VTYSH_ISISD | VTYSH_MGMTD
#define VTYSH_RMAP VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD|VTYSH_EIGRPD|VTYSH_FABRICD
#define VTYSH_INTERFACE_SUBSET \
VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_RIPNGD | VTYSH_OSPFD | VTYSH_OSPF6D | \
VTYSH_ISISD | VTYSH_PIMD | VTYSH_PIM6D | VTYSH_NHRPD | \
VTYSH_EIGRPD | VTYSH_BABELD | VTYSH_PBRD | VTYSH_FABRICD | \
VTYSH_VRRPD | VTYSH_MGMTD
VTYSH_RIPD | VTYSH_RIPNGD | VTYSH_OSPFD | VTYSH_OSPF6D | VTYSH_ISISD | \
VTYSH_PIMD | VTYSH_PIM6D | VTYSH_NHRPD | VTYSH_EIGRPD | \
VTYSH_BABELD | VTYSH_PBRD | VTYSH_FABRICD | VTYSH_VRRPD | \
VTYSH_MGMTD
#define VTYSH_INTERFACE VTYSH_INTERFACE_SUBSET | VTYSH_BGPD
#define VTYSH_VRF VTYSH_INTERFACE_SUBSET | VTYSH_BGPD
#define VTYSH_VRF VTYSH_INTERFACE_SUBSET | VTYSH_BGPD | VTYSH_ZEBRA
#define VTYSH_KEYS VTYSH_RIPD | VTYSH_EIGRPD | VTYSH_OSPF6D | VTYSH_OSPFD
/* Daemons who can process nexthop-group configs */
#define VTYSH_NH_GROUP VTYSH_PBRD|VTYSH_SHARPD
Expand Down
Loading

0 comments on commit 66fe8cd

Please sign in to comment.