Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ripngd: convert ripngd to mgmtd #15240

Merged
merged 1 commit into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ char const *const mgmt_daemons[] = {
#ifdef HAVE_RIPD
"ripd",
#endif
#ifdef HAVE_RIPNGD
"ripngd",
#endif
#ifdef HAVE_STATICD
"staticd",
#endif
Expand Down
26 changes: 25 additions & 1 deletion mgmtd/mgmt_be_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@

const char *mgmt_be_client_names[MGMTD_BE_CLIENT_ID_MAX + 1] = {
[MGMTD_BE_CLIENT_ID_ZEBRA] = "zebra",
#ifdef HAVE_STATICD
#ifdef HAVE_RIPD
[MGMTD_BE_CLIENT_ID_RIPD] = "ripd",
#endif
#ifdef HAVE_RIPNGD
[MGMTD_BE_CLIENT_ID_RIPNGD] = "ripngd",
#endif
#ifdef HAVE_STATICD
[MGMTD_BE_CLIENT_ID_STATICD] = "staticd",
#endif
Expand Down Expand Up @@ -77,6 +80,21 @@ static const char *const ripd_oper_xpaths[] = {
};
#endif

#if HAVE_RIPNGD
static const char *const ripngd_config_xpaths[] = {
"/frr-filter:lib",
"/frr-interface:lib/interface",
"/frr-ripngd:ripngd",
"/frr-route-map:lib",
"/frr-vrf:lib",
NULL,
};
static const char *const ripngd_oper_xpaths[] = {
"/frr-ripd:ripd",
NULL,
};
#endif

#if HAVE_STATICD
static const char *const staticd_config_xpaths[] = {
"/frr-vrf:lib",
Expand All @@ -90,6 +108,9 @@ 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_RIPNGD
[MGMTD_BE_CLIENT_ID_RIPNGD] = ripngd_config_xpaths,
#endif
#ifdef HAVE_STATICD
[MGMTD_BE_CLIENT_ID_STATICD] = staticd_config_xpaths,
#endif
Expand All @@ -105,6 +126,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
#ifdef HAVE_RIPNGD
[MGMTD_BE_CLIENT_ID_RIPNGD] = ripngd_oper_xpaths,
#endif
[MGMTD_BE_CLIENT_ID_ZEBRA] = zebra_oper_xpaths,
};
Expand Down
5 changes: 4 additions & 1 deletion mgmtd/mgmt_be_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#define MGMTD_BE_CONN_INIT_DELAY_MSEC 50

#define MGMTD_FIND_ADAPTER_BY_INDEX(adapter_index) \
#define MGMTD_FIND_ADAPTER_BY_INDEX(adapter_index) \
mgmt_adaptr_ref[adapter_index]

/**
Expand All @@ -30,6 +30,9 @@ enum mgmt_be_client_id {
#ifdef HAVE_RIPD
MGMTD_BE_CLIENT_ID_RIPD,
#endif
#ifdef HAVE_RIPNGD
MGMTD_BE_CLIENT_ID_RIPNGD,
#endif
#ifdef HAVE_STATICD
MGMTD_BE_CLIENT_ID_STATICD,
#endif
Expand Down
4 changes: 4 additions & 0 deletions mgmtd/mgmt_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "mgmtd/mgmt.h"
#include "mgmtd/mgmt_ds.h"
#include "ripd/rip_nb.h"
#include "ripngd/ripng_nb.h"
#include "routing_nb.h"


Expand Down Expand Up @@ -188,6 +189,9 @@ static const struct frr_yang_module_info *const mgmt_yang_modules[] = {
#ifdef HAVE_RIPD
&frr_ripd_cli_info,
#endif
#ifdef HAVE_RIPNGD
&frr_ripngd_cli_info,
#endif
#ifdef HAVE_STATICD
&frr_staticd_cli_info,
#endif
Expand Down
7 changes: 6 additions & 1 deletion mgmtd/mgmt_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <zebra.h>

#include "command.h"
#include "filter.h"
#include "json.h"
#include "network.h"
#include "northbound_cli.h"
Expand All @@ -21,7 +22,8 @@
#include "mgmtd/mgmt_history.h"

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

extern struct frr_daemon_info *mgmt_daemon_info;
Expand Down Expand Up @@ -578,6 +580,9 @@ void mgmt_vty_init(void)
#if HAVE_RIPD
rip_cli_init();
#endif
#if HAVE_RIPNGD
ripng_cli_init();
#endif
#if HAVE_STATICD
static_vty_init();
#endif
Expand Down
9 changes: 9 additions & 0 deletions mgmtd/subdir.am
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ mgmtd_libmgmt_be_nb_la_SOURCES += \
# end
endif

if RIPNGD
nodist_mgmtd_mgmtd_SOURCES += \
yang/frr-ripngd.yang.c \
# end
mgmtd_libmgmt_be_nb_la_SOURCES += \
ripngd/ripng_cli.c \
# end
endif

if STATICD
nodist_mgmtd_mgmtd_SOURCES += \
yang/frr-staticd.yang.c \
Expand Down
5 changes: 1 addition & 4 deletions python/xref2vtysh.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,7 @@ def _get_daemons(self):
}

if defun_file == "lib/if_rmap.c":
if v6_cmd:
return {"VTYSH_RIPNGD"}
else:
return {"VTYSH_MGMTD"}
return {"VTYSH_MGMTD"}

return {}

Expand Down
2 changes: 2 additions & 0 deletions ripd/rip_nb.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,6 @@ void cli_show_ip_rip_bfd_profile(struct vty *vty, const struct lyd_node *dnode,
extern void ripd_notif_send_auth_type_failure(const char *ifname);
extern void ripd_notif_send_auth_failure(const char *ifname);

extern void rip_cli_init(void);

#endif /* _FRR_RIP_NB_H_ */
1 change: 0 additions & 1 deletion ripd/ripd.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,6 @@ extern int offset_list_cmp(struct rip_offset_list *o1,

extern void rip_vrf_init(void);
extern void rip_vrf_terminate(void);
extern void rip_cli_init(void);

extern struct zebra_privs_t ripd_privs;
extern struct rip_instance_head rip_instances;
Expand Down
102 changes: 101 additions & 1 deletion ripngd/ripng_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 @@ -648,8 +649,20 @@ DEFPY_YANG(no_ripng_ipv6_distribute_list_prefix,
return nb_cli_apply_changes(vty, NULL);
}

/* RIPng node structure. */
static struct cmd_node cmd_ripng_node = {
.name = "ripng",
.node = RIPNG_NODE,
.parent_node = CONFIG_NODE,
.prompt = "%s(config-router)# ",
};

void ripng_cli_init(void)
{
/* Install RIPNG_NODE. */
install_node(&cmd_ripng_node);
install_default(RIPNG_NODE);

install_element(CONFIG_NODE, &router_ripng_cmd);
install_element(CONFIG_NODE, &no_router_ripng_cmd);

Expand All @@ -676,4 +689,91 @@ void ripng_cli_init(void)
install_element(INTERFACE_NODE, &ipv6_ripng_split_horizon_cmd);

install_element(ENABLE_NODE, &clear_ipv6_rip_cmd);
}

if_rmap_init(RIPNG_NODE);
}

/* clang-format off */
const struct frr_yang_module_info frr_ripngd_cli_info = {
.name = "frr-ripngd",
.ignore_cfg_cbs = true,
.nodes = {
{
.xpath = "/frr-ripngd:ripngd/instance",
.cbs.cli_show = cli_show_router_ripng,
},
{
.xpath = "/frr-ripngd:ripngd/instance/allow-ecmp",
.cbs.cli_show = cli_show_ripng_allow_ecmp,
},
{
.xpath = "/frr-ripngd:ripngd/instance/default-information-originate",
.cbs.cli_show = cli_show_ripng_default_information_originate,
},
{
.xpath = "/frr-ripngd:ripngd/instance/default-metric",
.cbs.cli_show = cli_show_ripng_default_metric,
},
{
.xpath = "/frr-ripngd:ripngd/instance/network",
.cbs.cli_show = cli_show_ripng_network_prefix,
},
{
.xpath = "/frr-ripngd:ripngd/instance/interface",
.cbs.cli_show = cli_show_ripng_network_interface,
},
{
.xpath = "/frr-ripngd:ripngd/instance/offset-list",
.cbs.cli_show = cli_show_ripng_offset_list,
},
{
.xpath = "/frr-ripngd:ripngd/instance/passive-interface",
.cbs.cli_show = cli_show_ripng_passive_interface,
},
{
.xpath = "/frr-ripngd:ripngd/instance/distribute-list/in/access-list",
.cbs.cli_show = group_distribute_list_ipv6_cli_show,
},
{
.xpath = "/frr-ripngd:ripngd/instance/distribute-list/out/access-list",
.cbs.cli_show = group_distribute_list_ipv6_cli_show,
},
{
.xpath = "/frr-ripngd:ripngd/instance/distribute-list/in/prefix-list",
.cbs.cli_show = group_distribute_list_ipv6_cli_show,
},
{
.xpath = "/frr-ripngd:ripngd/instance/distribute-list/out/prefix-list",
.cbs.cli_show = group_distribute_list_ipv6_cli_show,
},
{
.xpath = "/frr-ripngd:ripngd/instance/redistribute",
.cbs.cli_show = cli_show_ripng_redistribute,
},
{
.xpath = "/frr-ripngd:ripngd/instance/if-route-maps/if-route-map",
.cbs.cli_show = cli_show_if_route_map,
},
{
.xpath = "/frr-ripngd:ripngd/instance/static-route",
.cbs.cli_show = cli_show_ripng_route,
},
{
.xpath = "/frr-ripngd:ripngd/instance/aggregate-address",
.cbs.cli_show = cli_show_ripng_aggregate_address,
},
{
.xpath = "/frr-ripngd:ripngd/instance/timers",
.cbs.cli_show = cli_show_ripng_timers,
},
{
.xpath = "/frr-interface:lib/interface/frr-ripngd:ripng/split-horizon",
.cbs = {
.cli_show = cli_show_ipv6_ripng_split_horizon,
},
},
{
.xpath = NULL,
},
}
};
1 change: 0 additions & 1 deletion ripngd/ripng_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,6 @@ void ripng_if_init(void)
hook_register_prio(if_del, 0, ripng_if_delete_hook);

/* Install interface node. */
if_cmd_init_default();
hook_register_prio(if_real, 0, ripng_ifp_create);
hook_register_prio(if_up, 0, ripng_ifp_up);
hook_register_prio(if_down, 0, ripng_ifp_down);
Expand Down
14 changes: 13 additions & 1 deletion ripngd/ripng_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "if_rmap.h"
#include "libfrr.h"
#include "routemap.h"
#include "mgmt_be_client.h"

#include "ripngd/ripngd.h"
#include "ripngd/ripng_nb.h"
Expand Down Expand Up @@ -52,6 +53,8 @@ struct zebra_privs_t ripngd_privs = {
/* Master of threads. */
struct event_loop *master;

struct mgmt_be_client *mgmt_be_client;

static struct frr_daemon_info ripngd_di;

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

zlog_notice("Terminating on signal");

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 @@ -131,6 +138,9 @@ FRR_DAEMON_INFO(ripngd, RIPNG, .vty_port = RIPNG_VTY_PORT,

.yang_modules = ripngd_yang_modules,
.n_yang_modules = array_size(ripngd_yang_modules),

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

#define DEPRECATED_OPTIONS ""
Expand Down Expand Up @@ -172,7 +182,9 @@ int main(int argc, char **argv)

/* RIPngd inits. */
ripng_init();
ripng_cli_init();

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

zebra_init(master);

frr_config_fork();
Expand Down
Loading
Loading