summaryrefslogtreecommitdiffstats
path: root/ripd
diff options
context:
space:
mode:
authorChristian Hopps <chopps@labn.net>2024-01-19 17:40:12 +0100
committerChristian Hopps <chopps@labn.net>2024-01-26 18:34:46 +0100
commit83abe9c3cb9acd610dcdf8341374428df5ea9093 (patch)
treea55b83177da6b9f0ef907e4d8c5d97b61e6e61f5 /ripd
parentmgmtd: fix commit request overwrite (diff)
downloadfrr-83abe9c3cb9acd610dcdf8341374428df5ea9093.tar.xz
frr-83abe9c3cb9acd610dcdf8341374428df5ea9093.zip
ripd: ripd convert to mgmtd
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'ripd')
-rw-r--r--ripd/rip_cli.c139
-rw-r--r--ripd/rip_interface.c1
-rw-r--r--ripd/rip_main.c15
-rw-r--r--ripd/rip_nb.c38
-rw-r--r--ripd/rip_nb.h1
-rw-r--r--ripd/rip_routemap.c2
-rw-r--r--ripd/ripd.c50
-rw-r--r--ripd/subdir.am1
8 files changed, 158 insertions, 89 deletions
diff --git a/ripd/rip_cli.c b/ripd/rip_cli.c
index fbe647c5c..29db1b232 100644
--- a/ripd/rip_cli.c
+++ b/ripd/rip_cli.c
@@ -8,6 +8,7 @@
#include <zebra.h>
#include "if.h"
+#include "if_rmap.h"
#include "vrf.h"
#include "log.h"
#include "prefix.h"
@@ -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);
@@ -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);
@@ -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,
+ },
+ }
+};
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index 65afce8cb..486d7b05c 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -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);
diff --git a/ripd/rip_main.c b/ripd/rip_main.c
index cb23098a7..c86caabaf 100644
--- a/ripd/rip_main.c
+++ b/ripd/rip_main.c
@@ -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"
@@ -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. */
@@ -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;
@@ -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 ""
@@ -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);
diff --git a/ripd/rip_nb.c b/ripd/rip_nb.c
index 7167be124..d5df5916a 100644
--- a/ripd/rip_nb.c
+++ b/ripd/rip_nb.c
@@ -20,7 +20,6 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-ripd:ripd/instance",
.cbs = {
- .cli_show = cli_show_router_rip,
.create = ripd_instance_create,
.destroy = ripd_instance_destroy,
.get_keys = ripd_instance_get_keys,
@@ -31,35 +30,30 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-ripd:ripd/instance/allow-ecmp",
.cbs = {
- .cli_show = cli_show_rip_allow_ecmp,
.modify = ripd_instance_allow_ecmp_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/default-information-originate",
.cbs = {
- .cli_show = cli_show_rip_default_information_originate,
.modify = ripd_instance_default_information_originate_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/default-metric",
.cbs = {
- .cli_show = cli_show_rip_default_metric,
.modify = ripd_instance_default_metric_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/distance/default",
.cbs = {
- .cli_show = cli_show_rip_distance,
.modify = ripd_instance_distance_default_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/distance/source",
.cbs = {
- .cli_show = cli_show_rip_distance_source,
.create = ripd_instance_distance_source_create,
.destroy = ripd_instance_distance_source_destroy,
},
@@ -80,7 +74,6 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-ripd:ripd/instance/explicit-neighbor",
.cbs = {
- .cli_show = cli_show_rip_neighbor,
.create = ripd_instance_explicit_neighbor_create,
.destroy = ripd_instance_explicit_neighbor_destroy,
},
@@ -88,7 +81,6 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-ripd:ripd/instance/network",
.cbs = {
- .cli_show = cli_show_rip_network_prefix,
.create = ripd_instance_network_create,
.destroy = ripd_instance_network_destroy,
},
@@ -96,7 +88,6 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-ripd:ripd/instance/interface",
.cbs = {
- .cli_show = cli_show_rip_network_interface,
.create = ripd_instance_interface_create,
.destroy = ripd_instance_interface_destroy,
},
@@ -104,7 +95,6 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-ripd:ripd/instance/offset-list",
.cbs = {
- .cli_show = cli_show_rip_offset_list,
.create = ripd_instance_offset_list_create,
.destroy = ripd_instance_offset_list_destroy,
},
@@ -124,14 +114,12 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-ripd:ripd/instance/passive-default",
.cbs = {
- .cli_show = cli_show_rip_passive_default,
.modify = ripd_instance_passive_default_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/passive-interface",
.cbs = {
- .cli_show = cli_show_rip_passive_interface,
.create = ripd_instance_passive_interface_create,
.destroy = ripd_instance_passive_interface_destroy,
},
@@ -139,7 +127,6 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-ripd:ripd/instance/non-passive-interface",
.cbs = {
- .cli_show = cli_show_rip_non_passive_interface,
.create = ripd_instance_non_passive_interface_create,
.destroy = ripd_instance_non_passive_interface_destroy,
},
@@ -187,7 +174,6 @@ const struct frr_yang_module_info frr_ripd_info = {
.xpath = "/frr-ripd:ripd/instance/redistribute",
.cbs = {
.apply_finish = ripd_instance_redistribute_apply_finish,
- .cli_show = cli_show_rip_redistribute,
.create = ripd_instance_redistribute_create,
.destroy = ripd_instance_redistribute_destroy,
},
@@ -211,7 +197,6 @@ const struct frr_yang_module_info frr_ripd_info = {
.cbs = {
.create = ripd_instance_if_route_maps_if_route_map_create,
.destroy = ripd_instance_if_route_maps_if_route_map_destroy,
- .cli_show = cli_show_if_route_map,
}
},
{
@@ -231,7 +216,6 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-ripd:ripd/instance/static-route",
.cbs = {
- .cli_show = cli_show_rip_route,
.create = ripd_instance_static_route_create,
.destroy = ripd_instance_static_route_destroy,
},
@@ -240,7 +224,6 @@ const struct frr_yang_module_info frr_ripd_info = {
.xpath = "/frr-ripd:ripd/instance/timers",
.cbs = {
.apply_finish = ripd_instance_timers_apply_finish,
- .cli_show = cli_show_rip_timers,
},
},
{
@@ -262,12 +245,6 @@ const struct frr_yang_module_info frr_ripd_info = {
},
},
{
- .xpath = "/frr-ripd:ripd/instance/version",
- .cbs = {
- .cli_show = cli_show_rip_version,
- },
- },
- {
.xpath = "/frr-ripd:ripd/instance/version/receive",
.cbs = {
.modify = ripd_instance_version_receive_modify,
@@ -284,44 +261,33 @@ const struct frr_yang_module_info frr_ripd_info = {
.cbs = {
.modify = ripd_instance_default_bfd_profile_modify,
.destroy = ripd_instance_default_bfd_profile_destroy,
- .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,
.modify = lib_interface_rip_split_horizon_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/v2-broadcast",
.cbs = {
- .cli_show = cli_show_ip_rip_v2_broadcast,
.modify = lib_interface_rip_v2_broadcast_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/version-receive",
.cbs = {
- .cli_show = cli_show_ip_rip_receive_version,
.modify = lib_interface_rip_version_receive_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/version-send",
.cbs = {
- .cli_show = cli_show_ip_rip_send_version,
.modify = lib_interface_rip_version_send_modify,
},
},
{
- .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-scheme/mode",
.cbs = {
.modify = lib_interface_rip_authentication_scheme_mode_modify,
@@ -337,7 +303,6 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-password",
.cbs = {
- .cli_show = cli_show_ip_rip_authentication_string,
.destroy = lib_interface_rip_authentication_password_destroy,
.modify = lib_interface_rip_authentication_password_modify,
},
@@ -345,7 +310,6 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-key-chain",
.cbs = {
- .cli_show = cli_show_ip_rip_authentication_key_chain,
.destroy = lib_interface_rip_authentication_key_chain_destroy,
.modify = lib_interface_rip_authentication_key_chain_modify,
},
@@ -360,14 +324,12 @@ const struct frr_yang_module_info frr_ripd_info = {
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/bfd-monitoring/enable",
.cbs = {
- .cli_show = cli_show_ip_rip_bfd_enable,
.modify = lib_interface_rip_bfd_enable_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/bfd-monitoring/profile",
.cbs = {
- .cli_show = cli_show_ip_rip_bfd_profile,
.modify = lib_interface_rip_bfd_profile_modify,
.destroy = lib_interface_rip_bfd_profile_destroy,
},
diff --git a/ripd/rip_nb.h b/ripd/rip_nb.h
index 811fee55e..7521e0fba 100644
--- a/ripd/rip_nb.h
+++ b/ripd/rip_nb.h
@@ -10,6 +10,7 @@
#include "northbound.h"
extern const struct frr_yang_module_info frr_ripd_info;
+extern const struct frr_yang_module_info frr_ripd_cli_info;
/* Mandatory callbacks. */
int ripd_instance_create(struct nb_cb_create_args *args);
diff --git a/ripd/rip_routemap.c b/ripd/rip_routemap.c
index 2ae8857e3..be1727744 100644
--- a/ripd/rip_routemap.c
+++ b/ripd/rip_routemap.c
@@ -531,7 +531,7 @@ static const struct route_map_rule_cmd route_set_tag_cmd = {
/* Route-map init */
void rip_route_map_init(void)
{
- route_map_init();
+ route_map_init_new(true);
route_map_match_interface_hook(generic_match_add);
route_map_no_match_interface_hook(generic_match_delete);
diff --git a/ripd/ripd.c b/ripd/ripd.c
index a744e081d..b8a140c9c 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -34,6 +34,7 @@
#include "privs.h"
#include "lib_errors.h"
#include "northbound_cli.h"
+#include "mgmt_be_client.h"
#include "network.h"
#include "lib/printfrr.h"
#include "frrdistance.h"
@@ -3253,42 +3254,6 @@ DEFUN (show_ip_rip_status,
return CMD_SUCCESS;
}
-/* RIP configuration write function. */
-static int config_write_rip(struct vty *vty)
-{
- struct rip *rip;
- int write = 0;
-
- RB_FOREACH(rip, rip_instance_head, &rip_instances) {
- char xpath[XPATH_MAXLEN];
- struct lyd_node *dnode;
-
- snprintf(xpath, sizeof(xpath),
- "/frr-ripd:ripd/instance[vrf='%s']", rip->vrf_name);
-
- dnode = yang_dnode_get(running_config->dnode, xpath);
- assert(dnode);
-
- nb_cli_show_dnode_cmds(vty, dnode, false);
-
- vty_out(vty, "exit\n");
-
- write = 1;
- }
-
- return write;
-}
-
-static int config_write_rip(struct vty *vty);
-/* 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,
-};
-
/* Distribute-list update functions. */
static void rip_distribute_update(struct distribute_ctx *ctx,
struct distribute *dist)
@@ -3650,8 +3615,6 @@ static int rip_vrf_disable(struct vrf *vrf)
void rip_vrf_init(void)
{
vrf_init(rip_vrf_new, rip_vrf_enable, rip_vrf_disable, rip_vrf_delete);
-
- vrf_cmd_init(NULL);
}
void rip_vrf_terminate(void)
@@ -3662,20 +3625,17 @@ void rip_vrf_terminate(void)
/* Allocate new rip structure and set default value. */
void rip_init(void)
{
- /* Install top nodes. */
- install_node(&rip_node);
-
/* Install rip commands. */
install_element(VIEW_NODE, &show_ip_rip_cmd);
install_element(VIEW_NODE, &show_ip_rip_status_cmd);
- install_default(RIP_NODE);
-
/* Debug related init. */
rip_debug_init();
+ /* Enable mgmt be debug */
+ mgmt_be_client_lib_vty_init();
/* Access list install. */
- access_list_init();
+ access_list_init_new(true);
access_list_add_hook(rip_distribute_update_all_wrapper);
access_list_delete_hook(rip_distribute_update_all_wrapper);
@@ -3689,6 +3649,4 @@ void rip_init(void)
route_map_add_hook(rip_routemap_update);
route_map_delete_hook(rip_routemap_update);
-
- if_rmap_init(RIP_NODE);
}
diff --git a/ripd/subdir.am b/ripd/subdir.am
index c793a6d68..aed8d249f 100644
--- a/ripd/subdir.am
+++ b/ripd/subdir.am
@@ -14,7 +14,6 @@ endif
ripd_ripd_SOURCES = \
ripd/rip_bfd.c \
- ripd/rip_cli.c \
ripd/rip_debug.c \
ripd/rip_errors.c \
ripd/rip_interface.c \