Skip to content

Commit

Permalink
ripd: ripd convert to mgmtd
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Hopps <[email protected]>
  • Loading branch information
choppsv1 committed Jan 26, 2024
1 parent d79ca93 commit 83abe9c
Show file tree
Hide file tree
Showing 18 changed files with 232 additions and 99 deletions.
3 changes: 3 additions & 0 deletions lib/vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ bool vty_log_commands;
static bool vty_log_commands_perm;

char const *const mgmt_daemons[] = {
#ifdef HAVE_RIPD
"ripd",
#endif
#ifdef HAVE_STATICD
"staticd",
#endif
Expand Down
25 changes: 25 additions & 0 deletions mgmtd/mgmt_be_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@

const char *mgmt_be_client_names[MGMTD_BE_CLIENT_ID_MAX + 1] = {
[MGMTD_BE_CLIENT_ID_ZEBRA] = "zebra",
#ifdef HAVE_STATICD
[MGMTD_BE_CLIENT_ID_RIPD] = "ripd",
#endif
#ifdef HAVE_STATICD
[MGMTD_BE_CLIENT_ID_STATICD] = "staticd",
#endif
Expand All @@ -58,6 +61,22 @@ struct mgmt_be_xpath_map {
* Each client gets their own map, but also union all the strings into the
* above map as well.
*/

#if HAVE_RIPD
static const char *const ripd_config_xpaths[] = {
"/frr-filter:lib",
"/frr-interface:lib/interface",
"/frr-ripd:ripd",
"/frr-route-map:lib",
"/frr-vrf:lib",
NULL,
};
static const char *const ripd_oper_xpaths[] = {
"/frr-ripd:ripd",
NULL,
};
#endif

#if HAVE_STATICD
static const char *const staticd_config_xpaths[] = {
"/frr-vrf:lib",
Expand All @@ -68,6 +87,9 @@ static const char *const staticd_config_xpaths[] = {
#endif

static const char *const *be_client_config_xpaths[MGMTD_BE_CLIENT_ID_MAX] = {
#ifdef HAVE_RIPD
[MGMTD_BE_CLIENT_ID_RIPD] = ripd_config_xpaths,
#endif
#ifdef HAVE_STATICD
[MGMTD_BE_CLIENT_ID_STATICD] = staticd_config_xpaths,
#endif
Expand All @@ -81,6 +103,9 @@ static const char *const zebra_oper_xpaths[] = {
};

static const char *const *be_client_oper_xpaths[MGMTD_BE_CLIENT_ID_MAX] = {
#ifdef HAVE_RIPD
[MGMTD_BE_CLIENT_ID_RIPD] = ripd_oper_xpaths,
#endif
[MGMTD_BE_CLIENT_ID_ZEBRA] = zebra_oper_xpaths,
};

Expand Down
3 changes: 3 additions & 0 deletions mgmtd/mgmt_be_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
* #ifdef HAVE_COMPONENT
*/
enum mgmt_be_client_id {
#ifdef HAVE_RIPD
MGMTD_BE_CLIENT_ID_RIPD,
#endif
#ifdef HAVE_STATICD
MGMTD_BE_CLIENT_ID_STATICD,
#endif
Expand Down
8 changes: 6 additions & 2 deletions mgmtd/mgmt_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "frr_pthread.h"
#include "mgmtd/mgmt.h"
#include "mgmtd/mgmt_ds.h"
#include "ripd/rip_nb.h"
#include "routing_nb.h"


Expand Down Expand Up @@ -138,7 +139,7 @@ static struct frr_signal_t mgmt_signals[] = {
};

#ifdef HAVE_STATICD
extern const struct frr_yang_module_info frr_staticd_info;
extern const struct frr_yang_module_info frr_staticd_cli_info;
#endif


Expand Down Expand Up @@ -184,8 +185,11 @@ static const struct frr_yang_module_info *const mgmt_yang_modules[] = {
&affinity_map_info,
&zebra_route_map_info,

#ifdef HAVE_RIPD
&frr_ripd_cli_info,
#endif
#ifdef HAVE_STATICD
&frr_staticd_info,
&frr_staticd_cli_info,
#endif
};

Expand Down
6 changes: 5 additions & 1 deletion mgmtd/mgmt_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "mgmtd/mgmt_history.h"

#include "mgmtd/mgmt_vty_clippy.c"
#include "ripd/ripd.h"
#include "staticd/static_vty.h"

extern struct frr_daemon_info *mgmt_daemon_info;

Expand Down Expand Up @@ -573,8 +575,10 @@ void mgmt_vty_init(void)
* backend components that are moved to new MGMTD infra
* here one by one.
*/
#if HAVE_RIPD
rip_cli_init();
#endif
#if HAVE_STATICD
extern void static_vty_init(void);
static_vty_init();
#endif

Expand Down
26 changes: 24 additions & 2 deletions mgmtd/subdir.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ clippy_scan += \
# end

lib_LTLIBRARIES += mgmtd/libmgmt_be_nb.la
mgmtd_libmgmt_be_nb_la_SOURCES = \
# end
nodist_mgmtd_libmgmt_be_nb_la_SOURCES = \
# end
mgmtd_libmgmt_be_nb_la_CFLAGS = $(AM_CFLAGS) -DINCLUDE_MGMTD_CMDDEFS_ONLY
Expand Down Expand Up @@ -54,10 +56,30 @@ mgmtd_mgmtd_CFLAGS = $(AM_CFLAGS) -I ./
mgmtd_mgmtd_LDADD = mgmtd/libmgmtd.a lib/libfrr.la $(LIBCAP) $(LIBM) $(LIBYANG_LIBS) $(UST_LIBS)
mgmtd_mgmtd_LDADD += mgmtd/libmgmt_be_nb.la


if STATICD
nodist_mgmtd_mgmtd_SOURCES += yang/frr-bfdd.yang.c
else
if RIPD
nodist_mgmtd_mgmtd_SOURCES += yang/frr-bfdd.yang.c
endif
endif

if RIPD
nodist_mgmtd_mgmtd_SOURCES += \
yang/frr-ripd.yang.c \
# end
mgmtd_libmgmt_be_nb_la_SOURCES += \
ripd/rip_cli.c \
# end
endif

if STATICD
nodist_mgmtd_mgmtd_SOURCES += \
yang/frr-staticd.yang.c \
yang/frr-bfdd.yang.c \
# end
nodist_mgmtd_libmgmt_be_nb_la_SOURCES += staticd/static_vty.c
nodist_mgmtd_libmgmt_be_nb_la_SOURCES += \
staticd/static_vty.c \
# end
endif

2 changes: 1 addition & 1 deletion python/xref2vtysh.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def _get_daemons(self):
if v6_cmd:
return {"VTYSH_RIPNGD"}
else:
return {"VTYSH_RIPD"}
return {"VTYSH_MGMTD"}

return {}

Expand Down
139 changes: 138 additions & 1 deletion ripd/rip_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <zebra.h>

#include "if.h"
#include "if_rmap.h"
#include "vrf.h"
#include "log.h"
#include "prefix.h"
Expand Down Expand Up @@ -1257,8 +1258,19 @@ DEFPY_YANG(no_rip_distribute_list_prefix,
return nb_cli_apply_changes(vty, NULL);
}

/* RIP node structure. */
static struct cmd_node rip_node = {
.name = "rip",
.node = RIP_NODE,
.parent_node = CONFIG_NODE,
.prompt = "%s(config-router)# ",
// .config_write = config_write_rip,
};

void rip_cli_init(void)
{
install_node(&rip_node);

install_element(CONFIG_NODE, &router_rip_cmd);
install_element(CONFIG_NODE, &no_router_rip_cmd);

Expand Down Expand Up @@ -1289,6 +1301,7 @@ void rip_cli_init(void)
install_element(RIP_NODE, &no_rip_version_cmd);
install_element(RIP_NODE, &rip_bfd_default_profile_cmd);
install_element(RIP_NODE, &no_rip_bfd_default_profile_cmd);
install_default(RIP_NODE);

install_element(INTERFACE_NODE, &ip_rip_split_horizon_cmd);
install_element(INTERFACE_NODE, &ip_rip_v2_broadcast_cmd);
Expand All @@ -1308,4 +1321,128 @@ void rip_cli_init(void)
install_element(INTERFACE_NODE, &no_ip_rip_bfd_profile_cmd);

install_element(ENABLE_NODE, &clear_ip_rip_cmd);
}

if_rmap_init(RIP_NODE);
}
/* clang-format off */
const struct frr_yang_module_info frr_ripd_cli_info = {
.name = "frr-ripd",
.ignore_cfg_cbs = true,
.nodes = {
{
.xpath = "/frr-ripd:ripd/instance",
.cbs.cli_show = cli_show_router_rip,
},
{
.xpath = "/frr-ripd:ripd/instance/allow-ecmp",
.cbs.cli_show = cli_show_rip_allow_ecmp,
},
{
.xpath = "/frr-ripd:ripd/instance/default-information-originate",
.cbs.cli_show = cli_show_rip_default_information_originate,
},
{
.xpath = "/frr-ripd:ripd/instance/default-metric",
.cbs.cli_show = cli_show_rip_default_metric,
},
{
.xpath = "/frr-ripd:ripd/instance/distance/default",
.cbs.cli_show = cli_show_rip_distance,
},
{
.xpath = "/frr-ripd:ripd/instance/distance/source",
.cbs.cli_show = cli_show_rip_distance_source,
},
{
.xpath = "/frr-ripd:ripd/instance/explicit-neighbor",
.cbs.cli_show = cli_show_rip_neighbor,
},
{
.xpath = "/frr-ripd:ripd/instance/network",
.cbs.cli_show = cli_show_rip_network_prefix,
},
{
.xpath = "/frr-ripd:ripd/instance/interface",
.cbs.cli_show = cli_show_rip_network_interface,
},
{
.xpath = "/frr-ripd:ripd/instance/offset-list",
.cbs.cli_show = cli_show_rip_offset_list,
},
{
.xpath = "/frr-ripd:ripd/instance/passive-default",
.cbs.cli_show = cli_show_rip_passive_default,
},
{
.xpath = "/frr-ripd:ripd/instance/passive-interface",
.cbs.cli_show = cli_show_rip_passive_interface,
},
{
.xpath = "/frr-ripd:ripd/instance/non-passive-interface",
.cbs.cli_show = cli_show_rip_non_passive_interface,
},
{
.xpath = "/frr-ripd:ripd/instance/redistribute",
.cbs.cli_show = cli_show_rip_redistribute,
},
{
.xpath = "/frr-ripd:ripd/instance/if-route-maps/if-route-map",
.cbs.cli_show = cli_show_if_route_map,
},
{
.xpath = "/frr-ripd:ripd/instance/static-route",
.cbs.cli_show = cli_show_rip_route,
},
{
.xpath = "/frr-ripd:ripd/instance/timers",
.cbs.cli_show = cli_show_rip_timers,
},
{
.xpath = "/frr-ripd:ripd/instance/version",
.cbs.cli_show = cli_show_rip_version,
},
{
.xpath = "/frr-ripd:ripd/instance/default-bfd-profile",
.cbs.cli_show = cli_show_ripd_instance_default_bfd_profile,
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/split-horizon",
.cbs.cli_show = cli_show_ip_rip_split_horizon,
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/v2-broadcast",
.cbs.cli_show = cli_show_ip_rip_v2_broadcast,
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/version-receive",
.cbs.cli_show = cli_show_ip_rip_receive_version,
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/version-send",
.cbs.cli_show = cli_show_ip_rip_send_version,
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-scheme",
.cbs.cli_show = cli_show_ip_rip_authentication_scheme,
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-password",
.cbs.cli_show = cli_show_ip_rip_authentication_string,
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-key-chain",
.cbs.cli_show = cli_show_ip_rip_authentication_key_chain,
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/bfd-monitoring/enable",
.cbs.cli_show = cli_show_ip_rip_bfd_enable,
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/bfd-monitoring/profile",
.cbs.cli_show = cli_show_ip_rip_bfd_profile,
},
{
.xpath = NULL,
},
}
};
1 change: 0 additions & 1 deletion ripd/rip_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,6 @@ void rip_if_init(void)
hook_register_prio(if_del, 0, rip_interface_delete_hook);

/* Install interface node. */
if_cmd_init_default();
hook_register_prio(if_real, 0, rip_ifp_create);
hook_register_prio(if_up, 0, rip_ifp_up);
hook_register_prio(if_down, 0, rip_ifp_down);
Expand Down
15 changes: 14 additions & 1 deletion ripd/rip_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "libfrr.h"
#include "routemap.h"
#include "bfd.h"
#include "mgmt_be_client.h"

#include "ripd/ripd.h"
#include "ripd/rip_bfd.h"
Expand Down Expand Up @@ -53,6 +54,8 @@ struct zebra_privs_t ripd_privs = {
/* Master of threads. */
struct event_loop *master;

struct mgmt_be_client *mgmt_be_client;

static struct frr_daemon_info ripd_di;

/* SIGHUP handler. */
Expand All @@ -73,6 +76,11 @@ static void sigint(void)

bfd_protocol_integration_set_shutdown(true);


nb_oper_cancel_all_walks();
mgmt_be_client_destroy(mgmt_be_client);
mgmt_be_client = NULL;

RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
if (!vrf->info)
continue;
Expand Down Expand Up @@ -133,6 +141,9 @@ FRR_DAEMON_INFO(ripd, RIP, .vty_port = RIP_VTY_PORT,

.privs = &ripd_privs, .yang_modules = ripd_yang_modules,
.n_yang_modules = array_size(ripd_yang_modules),

/* mgmtd will load the per-daemon config file now */
.flags = FRR_NO_SPLIT_CONFIG,
);

#define DEPRECATED_OPTIONS ""
Expand Down Expand Up @@ -179,7 +190,9 @@ int main(int argc, char **argv)
/* RIP related initialization. */
rip_init();
rip_if_init();
rip_cli_init();

mgmt_be_client = mgmt_be_client_create("ripd", NULL, 0, master);

rip_zclient_init(master);
rip_bfd_init(master);

Expand Down
Loading

0 comments on commit 83abe9c

Please sign in to comment.