From 594597757d8fa7146a231a8994425c7b62f8ccbe Mon Sep 17 00:00:00 2001 From: Christian Hopps Date: Fri, 19 Jan 2024 16:40:12 +0000 Subject: [PATCH] ripd: ripd convert to mgmtd Signed-off-by: Christian Hopps --- lib/vty.c | 3 + mgmtd/mgmt_be_adapter.c | 25 ++++++++ mgmtd/mgmt_be_adapter.h | 3 + mgmtd/mgmt_main.c | 8 ++- mgmtd/mgmt_vty.c | 6 +- mgmtd/subdir.am | 26 +++++++- python/xref2vtysh.py | 2 +- ripd/rip_cli.c | 139 +++++++++++++++++++++++++++++++++++++++- ripd/rip_main.c | 15 ++++- ripd/rip_nb.c | 38 ----------- ripd/rip_nb.h | 1 + ripd/rip_routemap.c | 2 +- ripd/ripd.c | 48 ++------------ ripd/subdir.am | 1 - staticd/static_nb.h | 1 + staticd/static_vty.c | 4 +- vtysh/vtysh.c | 6 +- 17 files changed, 232 insertions(+), 96 deletions(-) diff --git a/lib/vty.c b/lib/vty.c index 3fc7c380830e..f2076552c7cb 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -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 diff --git a/mgmtd/mgmt_be_adapter.c b/mgmtd/mgmt_be_adapter.c index 93ce23ae4b04..7c18301b1ed4 100644 --- a/mgmtd/mgmt_be_adapter.c +++ b/mgmtd/mgmt_be_adapter.c @@ -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 @@ -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", @@ -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 @@ -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, }; diff --git a/mgmtd/mgmt_be_adapter.h b/mgmtd/mgmt_be_adapter.h index 3407d4c6a73a..35c8ec4c7add 100644 --- a/mgmtd/mgmt_be_adapter.h +++ b/mgmtd/mgmt_be_adapter.h @@ -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 diff --git a/mgmtd/mgmt_main.c b/mgmtd/mgmt_main.c index bd0a9895c294..6532e9b1bf72 100644 --- a/mgmtd/mgmt_main.c +++ b/mgmtd/mgmt_main.c @@ -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" @@ -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 @@ -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 }; diff --git a/mgmtd/mgmt_vty.c b/mgmtd/mgmt_vty.c index 5dd7be657af8..c88fd2f25b24 100644 --- a/mgmtd/mgmt_vty.c +++ b/mgmtd/mgmt_vty.c @@ -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; @@ -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 diff --git a/mgmtd/subdir.am b/mgmtd/subdir.am index 89a6596f49f2..244710d733f6 100644 --- a/mgmtd/subdir.am +++ b/mgmtd/subdir.am @@ -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 @@ -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 + diff --git a/python/xref2vtysh.py b/python/xref2vtysh.py index edaa2945cec0..c52ae5b9a6fd 100644 --- a/python/xref2vtysh.py +++ b/python/xref2vtysh.py @@ -209,7 +209,7 @@ def _get_daemons(self): if v6_cmd: return {"VTYSH_RIPNGD"} else: - return {"VTYSH_RIPD"} + return {"VTYSH_MGMTD"} return {} diff --git a/ripd/rip_cli.c b/ripd/rip_cli.c index fbe647c5cafa..29db1b232d1f 100644 --- a/ripd/rip_cli.c +++ b/ripd/rip_cli.c @@ -8,6 +8,7 @@ #include #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_main.c b/ripd/rip_main.c index cb23098a7e26..c86caabaf1c1 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 7167be124a74..d5df5916ada6 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, }, }, { @@ -261,12 +244,6 @@ const struct frr_yang_module_info frr_ripd_info = { .modify = ripd_instance_timers_update_interval_modify, }, }, - { - .xpath = "/frr-ripd:ripd/instance/version", - .cbs = { - .cli_show = cli_show_rip_version, - }, - }, { .xpath = "/frr-ripd:ripd/instance/version/receive", .cbs = { @@ -284,43 +261,32 @@ 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 = { @@ -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 811fee55ec25..7521e0fba92c 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 2ae8857e3f12..be172774490a 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 a744e081d19c..ad97634c9b1f 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) @@ -3662,20 +3627,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 +3651,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 c793a6d68538..aed8d249fea2 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 \ diff --git a/staticd/static_nb.h b/staticd/static_nb.h index 9f80653b762d..f929997a78e7 100644 --- a/staticd/static_nb.h +++ b/staticd/static_nb.h @@ -11,6 +11,7 @@ extern "C" { #endif extern const struct frr_yang_module_info frr_staticd_info; +extern const struct frr_yang_module_info frr_staticd_cli_info; /* Mandatory callbacks. */ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_create( diff --git a/staticd/static_vty.c b/staticd/static_vty.c index a641d1a09f28..95f79564af9e 100644 --- a/staticd/static_vty.c +++ b/staticd/static_vty.c @@ -1578,7 +1578,7 @@ static int static_path_list_cli_cmp(const struct lyd_node *dnode1, return (int)distance1 - (int)distance2; } -const struct frr_yang_module_info frr_staticd_info = { +const struct frr_yang_module_info frr_staticd_cli_info = { .name = "frr-staticd", .ignore_cfg_cbs = true, .nodes = { @@ -1714,5 +1714,7 @@ void static_vty_init(void) install_element(CONFIG_NODE, &ipv6_route_cmd); install_element(VRF_NODE, &ipv6_route_vrf_cmd); +#ifndef INCLUDE_MGMTD_CMDDEFS_ONLY mgmt_be_client_lib_vty_init(); +#endif } diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index e86eeeb2870e..6d2600cd9682 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -2006,7 +2006,7 @@ DEFUNSH(VTYSH_KEYS, key, key_cmd, "key (0-2147483647)", } #ifdef HAVE_RIPD -DEFUNSH(VTYSH_RIPD, router_rip, router_rip_cmd, "router rip [vrf NAME]", +DEFUNSH(VTYSH_MGMTD, router_rip, router_rip_cmd, "router rip [vrf NAME]", ROUTER_STR "RIP\n" VRF_CMD_HELP_STR) { vty->node = RIP_NODE; @@ -2545,13 +2545,13 @@ DEFUNSH(VTYSH_ZEBRA, exit_srv6_encap, exit_srv6_encap_cmd, "exit", } #ifdef HAVE_RIPD -DEFUNSH(VTYSH_RIPD, vtysh_exit_ripd, vtysh_exit_ripd_cmd, "exit", +DEFUNSH(VTYSH_MGMTD, vtysh_exit_ripd, vtysh_exit_ripd_cmd, "exit", "Exit current mode and down to previous mode\n") { return vtysh_exit(vty); } -DEFUNSH(VTYSH_RIPD, vtysh_quit_ripd, vtysh_quit_ripd_cmd, "quit", +DEFUNSH(VTYSH_MGMTD, vtysh_quit_ripd, vtysh_quit_ripd_cmd, "quit", "Exit current mode and down to previous mode\n") { return vtysh_exit_ripd(self, vty, argc, argv);