diff options
| author | Christian Hopps <chopps@labn.net> | 2024-01-26 17:40:55 -0500 | 
|---|---|---|
| committer | Christian Hopps <chopps@labn.net> | 2024-01-26 17:40:55 -0500 | 
| commit | e6eec072abd7088c09a23d0328ac9bc9fd00ad7e (patch) | |
| tree | 99db60967b6c49482759f6a13548bc50127144f1 /ripngd | |
| parent | 1254d5fc4e7d6b3717177fd353974a55b1777d4a (diff) | |
ripngd: convert ripngd to mgmtd
- a couple small fixes for ripd conversion as well.
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'ripngd')
| -rw-r--r-- | ripngd/ripng_cli.c | 102 | ||||
| -rw-r--r-- | ripngd/ripng_interface.c | 1 | ||||
| -rw-r--r-- | ripngd/ripng_main.c | 14 | ||||
| -rw-r--r-- | ripngd/ripng_nb.c | 18 | ||||
| -rw-r--r-- | ripngd/ripng_nb.h | 3 | ||||
| -rw-r--r-- | ripngd/ripng_routemap.c | 2 | ||||
| -rw-r--r-- | ripngd/ripngd.c | 52 | ||||
| -rw-r--r-- | ripngd/ripngd.h | 1 | ||||
| -rw-r--r-- | ripngd/subdir.am | 1 | 
9 files changed, 123 insertions, 71 deletions
diff --git a/ripngd/ripng_cli.c b/ripngd/ripng_cli.c index ee561087c9..a4a0f5a2cb 100644 --- a/ripngd/ripng_cli.c +++ b/ripngd/ripng_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" @@ -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); @@ -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, +		}, +	} +}; diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c index 35d92632a0..9ef9f89005 100644 --- a/ripngd/ripng_interface.c +++ b/ripngd/ripng_interface.c @@ -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); diff --git a/ripngd/ripng_main.c b/ripngd/ripng_main.c index a799943be1..80b78a150a 100644 --- a/ripngd/ripng_main.c +++ b/ripngd/ripng_main.c @@ -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" @@ -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. */ @@ -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; @@ -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 "" @@ -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(); diff --git a/ripngd/ripng_nb.c b/ripngd/ripng_nb.c index 583a4d08d0..8e20541733 100644 --- a/ripngd/ripng_nb.c +++ b/ripngd/ripng_nb.c @@ -20,7 +20,6 @@ const struct frr_yang_module_info frr_ripngd_info = {  		{  			.xpath = "/frr-ripngd:ripngd/instance",  			.cbs = { -				.cli_show = cli_show_router_ripng,  				.create = ripngd_instance_create,  				.destroy = ripngd_instance_destroy,  				.get_keys = ripngd_instance_get_keys, @@ -31,28 +30,24 @@ const struct frr_yang_module_info frr_ripngd_info = {  		{  			.xpath = "/frr-ripngd:ripngd/instance/allow-ecmp",  			.cbs = { -				.cli_show = cli_show_ripng_allow_ecmp,  				.modify = ripngd_instance_allow_ecmp_modify,  			},  		},  		{  			.xpath = "/frr-ripngd:ripngd/instance/default-information-originate",  			.cbs = { -				.cli_show = cli_show_ripng_default_information_originate,  				.modify = ripngd_instance_default_information_originate_modify,  			},  		},  		{  			.xpath = "/frr-ripngd:ripngd/instance/default-metric",  			.cbs = { -				.cli_show = cli_show_ripng_default_metric,  				.modify = ripngd_instance_default_metric_modify,  			},  		},  		{  			.xpath = "/frr-ripngd:ripngd/instance/network",  			.cbs = { -				.cli_show = cli_show_ripng_network_prefix,  				.create = ripngd_instance_network_create,  				.destroy = ripngd_instance_network_destroy,  			}, @@ -60,7 +55,6 @@ const struct frr_yang_module_info frr_ripngd_info = {  		{  			.xpath = "/frr-ripngd:ripngd/instance/interface",  			.cbs = { -				.cli_show = cli_show_ripng_network_interface,  				.create = ripngd_instance_interface_create,  				.destroy = ripngd_instance_interface_destroy,  			}, @@ -68,7 +62,6 @@ const struct frr_yang_module_info frr_ripngd_info = {  		{  			.xpath = "/frr-ripngd:ripngd/instance/offset-list",  			.cbs = { -				.cli_show = cli_show_ripng_offset_list,  				.create = ripngd_instance_offset_list_create,  				.destroy = ripngd_instance_offset_list_destroy,  			}, @@ -88,7 +81,6 @@ const struct frr_yang_module_info frr_ripngd_info = {  		{  			.xpath = "/frr-ripngd:ripngd/instance/passive-interface",  			.cbs = { -				.cli_show = cli_show_ripng_passive_interface,  				.create = ripngd_instance_passive_interface_create,  				.destroy = ripngd_instance_passive_interface_destroy,  			}, @@ -105,7 +97,6 @@ const struct frr_yang_module_info frr_ripngd_info = {  			.cbs = {  				.modify = group_distribute_list_ipv6_modify,  				.destroy = group_distribute_list_ipv6_destroy, -				.cli_show = group_distribute_list_ipv6_cli_show,  			}  		},  		{ @@ -113,7 +104,6 @@ const struct frr_yang_module_info frr_ripngd_info = {  			.cbs = {  				.modify = group_distribute_list_ipv6_modify,  				.destroy = group_distribute_list_ipv6_destroy, -				.cli_show = group_distribute_list_ipv6_cli_show,  			}  		},  		{ @@ -121,7 +111,6 @@ const struct frr_yang_module_info frr_ripngd_info = {  			.cbs = {  				.modify = group_distribute_list_ipv6_modify,  				.destroy = group_distribute_list_ipv6_destroy, -				.cli_show = group_distribute_list_ipv6_cli_show,  			}  		},  		{ @@ -129,14 +118,12 @@ const struct frr_yang_module_info frr_ripngd_info = {  			.cbs = {  				.modify = group_distribute_list_ipv6_modify,  				.destroy = group_distribute_list_ipv6_destroy, -				.cli_show = group_distribute_list_ipv6_cli_show,  			}  		},  		{  			.xpath = "/frr-ripngd:ripngd/instance/redistribute",  			.cbs = {  				.apply_finish = ripngd_instance_redistribute_apply_finish, -				.cli_show = cli_show_ripng_redistribute,  				.create = ripngd_instance_redistribute_create,  				.destroy = ripngd_instance_redistribute_destroy,  			}, @@ -160,7 +147,6 @@ const struct frr_yang_module_info frr_ripngd_info = {  			.cbs = {  				.create = ripngd_instance_if_route_maps_if_route_map_create,  				.destroy = ripngd_instance_if_route_maps_if_route_map_destroy, -				.cli_show = cli_show_if_route_map,  			}  		},  		{ @@ -180,7 +166,6 @@ const struct frr_yang_module_info frr_ripngd_info = {  		{  			.xpath = "/frr-ripngd:ripngd/instance/static-route",  			.cbs = { -				.cli_show = cli_show_ripng_route,  				.create = ripngd_instance_static_route_create,  				.destroy = ripngd_instance_static_route_destroy,  			}, @@ -188,7 +173,6 @@ const struct frr_yang_module_info frr_ripngd_info = {  		{  			.xpath = "/frr-ripngd:ripngd/instance/aggregate-address",  			.cbs = { -				.cli_show = cli_show_ripng_aggregate_address,  				.create = ripngd_instance_aggregate_address_create,  				.destroy = ripngd_instance_aggregate_address_destroy,  			}, @@ -197,7 +181,6 @@ const struct frr_yang_module_info frr_ripngd_info = {  			.xpath = "/frr-ripngd:ripngd/instance/timers",  			.cbs = {  				.apply_finish = ripngd_instance_timers_apply_finish, -				.cli_show = cli_show_ripng_timers,  			},  		},  		{ @@ -291,7 +274,6 @@ const struct frr_yang_module_info frr_ripngd_info = {  		{  			.xpath = "/frr-interface:lib/interface/frr-ripngd:ripng/split-horizon",  			.cbs = { -				.cli_show = cli_show_ipv6_ripng_split_horizon,  				.modify = lib_interface_ripng_split_horizon_modify,  			},  		}, diff --git a/ripngd/ripng_nb.h b/ripngd/ripng_nb.h index 12d3cd5129..a6ac1fba07 100644 --- a/ripngd/ripng_nb.h +++ b/ripngd/ripng_nb.h @@ -10,6 +10,7 @@  #include "northbound.h"  extern const struct frr_yang_module_info frr_ripngd_info; +extern const struct frr_yang_module_info frr_ripngd_cli_info;  /* Mandatory callbacks. */  int ripngd_instance_create(struct nb_cb_create_args *args); @@ -138,4 +139,6 @@ void cli_show_ipv6_ripng_split_horizon(struct vty *vty,  				       const struct lyd_node *dnode,  				       bool show_defaults); +extern void ripng_cli_init(void); +  #endif /* _FRR_RIPNG_NB_H_ */ diff --git a/ripngd/ripng_routemap.c b/ripngd/ripng_routemap.c index b5f74be3f6..3370546d5c 100644 --- a/ripngd/ripng_routemap.c +++ b/ripngd/ripng_routemap.c @@ -386,7 +386,7 @@ static const struct route_map_rule_cmd route_set_tag_cmd = {  void ripng_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/ripngd/ripngd.c b/ripngd/ripngd.c index 4c3405d7dd..f4dadf377d 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -23,6 +23,7 @@  #include "lib_errors.h"  #include "northbound_cli.h"  #include "network.h" +#include "mgmt_be_client.h"  #include "ripngd/ripngd.h"  #include "ripngd/ripng_route.h" @@ -2267,43 +2268,6 @@ void ripng_ecmp_disable(struct ripng *ripng)  		}  } -/* RIPng configuration write function. */ -static int ripng_config_write(struct vty *vty) -{ -	struct ripng *ripng; -	int write = 0; - -	RB_FOREACH(ripng, ripng_instance_head, &ripng_instances) { -		char xpath[XPATH_MAXLEN]; -		struct lyd_node *dnode; - -		snprintf(xpath, sizeof(xpath), -			 "/frr-ripngd:ripngd/instance[vrf='%s']", -			 ripng->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 ripng_config_write(struct vty *vty); -/* RIPng node structure. */ -static struct cmd_node cmd_ripng_node = { -	.name = "ripng", -	.node = RIPNG_NODE, -	.parent_node = CONFIG_NODE, -	.prompt = "%s(config-router)# ", -	.config_write = ripng_config_write, -}; -  static void ripng_distribute_update(struct distribute_ctx *ctx,  				    struct distribute *dist)  { @@ -2671,8 +2635,6 @@ void ripng_vrf_init(void)  {  	vrf_init(ripng_vrf_new, ripng_vrf_enable, ripng_vrf_disable,  		 ripng_vrf_delete); - -	vrf_cmd_init(NULL);  }  void ripng_vrf_terminate(void) @@ -2683,20 +2645,18 @@ void ripng_vrf_terminate(void)  /* Initialize ripng structure and set commands. */  void ripng_init(void)  { -	/* Install RIPNG_NODE. */ -	install_node(&cmd_ripng_node); -  	/* Install ripng commands. */  	install_element(VIEW_NODE, &show_ipv6_ripng_cmd);  	install_element(VIEW_NODE, &show_ipv6_ripng_status_cmd); -	install_default(RIPNG_NODE); -  	ripng_if_init();  	ripng_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(ripng_distribute_update_all_wrapper);  	access_list_delete_hook(ripng_distribute_update_all_wrapper); @@ -2710,6 +2670,4 @@ void ripng_init(void)  	route_map_add_hook(ripng_routemap_update);  	route_map_delete_hook(ripng_routemap_update); - -	if_rmap_init(RIPNG_NODE);  } diff --git a/ripngd/ripngd.h b/ripngd/ripngd.h index 3a2bc0c9d3..b4f7b4e52d 100644 --- a/ripngd/ripngd.h +++ b/ripngd/ripngd.h @@ -432,7 +432,6 @@ extern void ripng_ecmp_change(struct ripng *ripng);  extern void ripng_vrf_init(void);  extern void ripng_vrf_terminate(void); -extern void ripng_cli_init(void);  extern uint32_t zebra_ecmp_count; diff --git a/ripngd/subdir.am b/ripngd/subdir.am index 162426c58c..83e376b555 100644 --- a/ripngd/subdir.am +++ b/ripngd/subdir.am @@ -9,7 +9,6 @@ man8 += $(MANBUILD)/frr-ripngd.8  endif  ripngd_ripngd_SOURCES = \ -	ripngd/ripng_cli.c \  	ripngd/ripng_debug.c \  	ripngd/ripng_interface.c \  	ripngd/ripng_nexthop.c \  | 
