diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2018-11-29 11:02:35 -0200 | 
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2018-12-03 13:47:58 -0200 | 
| commit | 6fc293855457baf848b05fcf30b2ffeddb43445f (patch) | |
| tree | 68d14c304426044bcff7da254a27fce632aa8cd5 /ripngd | |
| parent | 521d1b1283f50b15bd5dd6b57c7d22f2078058b9 (diff) | |
ripngd: retrofit the 'aggregate-address' command to the new northbound model
Trivial conversion. Remove the ripng->aggregate routing table and
associated code because this variable was used only to show the
running configuration.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ripngd')
| -rw-r--r-- | ripngd/ripng_cli.c | 25 | ||||
| -rw-r--r-- | ripngd/ripng_cli.h | 3 | ||||
| -rw-r--r-- | ripngd/ripng_northbound.c | 24 | ||||
| -rw-r--r-- | ripngd/ripngd.c | 86 | ||||
| -rw-r--r-- | ripngd/ripngd.h | 3 | 
5 files changed, 50 insertions, 91 deletions
diff --git a/ripngd/ripng_cli.c b/ripngd/ripng_cli.c index 876c537aff..e6daa62980 100644 --- a/ripngd/ripng_cli.c +++ b/ripngd/ripng_cli.c @@ -334,6 +334,30 @@ void cli_show_ripng_route(struct vty *vty, struct lyd_node *dnode,  	vty_out(vty, " route %s\n", yang_dnode_get_string(dnode, NULL));  } +/* + * XPath: /frr-ripngd:ripngd/instance/aggregate-addres + */ +DEFPY (ripng_aggregate_address, +       ripng_aggregate_address_cmd, +       "[no] aggregate-address X:X::X:X/M", +       NO_STR +       "Set aggregate RIPng route announcement\n" +       "Aggregate network\n") +{ +	nb_cli_enqueue_change(vty, "./aggregate-address", +			      no ? NB_OP_DELETE : NB_OP_CREATE, +			      aggregate_address_str); + +	return nb_cli_apply_changes(vty, NULL); +} + +void cli_show_ripng_aggregate_address(struct vty *vty, struct lyd_node *dnode, +				      bool show_defaults) +{ +	vty_out(vty, " aggregate-address %s\n", +		yang_dnode_get_string(dnode, NULL)); +} +  void ripng_cli_init(void)  {  	install_element(CONFIG_NODE, &router_ripng_cmd); @@ -349,4 +373,5 @@ void ripng_cli_init(void)  	install_element(RIPNG_NODE, &ripng_passive_interface_cmd);  	install_element(RIPNG_NODE, &ripng_redistribute_cmd);  	install_element(RIPNG_NODE, &ripng_route_cmd); +	install_element(RIPNG_NODE, &ripng_aggregate_address_cmd);  } diff --git a/ripngd/ripng_cli.h b/ripngd/ripng_cli.h index def7f2f6f5..1eafd69f9e 100644 --- a/ripngd/ripng_cli.h +++ b/ripngd/ripng_cli.h @@ -46,5 +46,8 @@ extern void cli_show_ripng_redistribute(struct vty *vty, struct lyd_node *dnode,  					bool show_defaults);  extern void cli_show_ripng_route(struct vty *vty, struct lyd_node *dnode,  				 bool show_defaults); +extern void cli_show_ripng_aggregate_address(struct vty *vty, +					     struct lyd_node *dnode, +					     bool show_defaults);  #endif /* _FRR_RIPNG_CLI_H_ */ diff --git a/ripngd/ripng_northbound.c b/ripngd/ripng_northbound.c index 07e000c7e2..163baecc95 100644 --- a/ripngd/ripng_northbound.c +++ b/ripngd/ripng_northbound.c @@ -31,6 +31,7 @@  #include "libfrr.h"  #include "ripngd/ripngd.h" +#include "ripngd/ripng_route.h"  #include "ripngd/ripng_cli.h"  /* @@ -483,7 +484,16 @@ ripngd_instance_aggregate_address_create(enum nb_event event,  					 const struct lyd_node *dnode,  					 union nb_resource *resource)  { -	/* TODO: implement me. */ +	struct prefix_ipv6 p; + +	if (event != NB_EV_APPLY) +		return NB_OK; + +	yang_dnode_get_ipv6p(&p, dnode, NULL); +	apply_mask_ipv6(&p); + +	ripng_aggregate_add((struct prefix *)&p); +  	return NB_OK;  } @@ -491,7 +501,16 @@ static int  ripngd_instance_aggregate_address_delete(enum nb_event event,  					 const struct lyd_node *dnode)  { -	/* TODO: implement me. */ +	struct prefix_ipv6 p; + +	if (event != NB_EV_APPLY) +		return NB_OK; + +	yang_dnode_get_ipv6p(&p, dnode, NULL); +	apply_mask_ipv6(&p); + +	ripng_aggregate_delete((struct prefix *)&p); +  	return NB_OK;  } @@ -777,6 +796,7 @@ const struct frr_yang_module_info frr_ripngd_info = {  			.xpath = "/frr-ripngd:ripngd/instance/aggregate-address",  			.cbs.create = ripngd_instance_aggregate_address_create,  			.cbs.delete = ripngd_instance_aggregate_address_delete, +			.cbs.cli_show = cli_show_ripng_aggregate_address,  		},  		{  			.xpath = "/frr-ripngd:ripngd/instance/timers/flush-interval", diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index 77e8491154..dfa75361a2 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -1805,7 +1805,6 @@ int ripng_create(int socket)  	/* Initialize RIPng routig table. */  	ripng->table = agg_table_init(); -	ripng->aggregate = agg_table_init();  	/* Make socket. */  	ripng->sock = socket; @@ -2156,71 +2155,6 @@ DEFUN (clear_ipv6_rip,  	return CMD_SUCCESS;  } -DEFUN (ripng_aggregate_address, -       ripng_aggregate_address_cmd, -       "aggregate-address X:X::X:X/M", -       "Set aggregate RIPng route announcement\n" -       "Aggregate network\n") -{ -	int idx_ipv6_prefixlen = 1; -	int ret; -	struct prefix p; -	struct agg_node *node; - -	ret = str2prefix_ipv6(argv[idx_ipv6_prefixlen]->arg, -			      (struct prefix_ipv6 *)&p); -	if (ret <= 0) { -		vty_out(vty, "Malformed address\n"); -		return CMD_WARNING_CONFIG_FAILED; -	} - -	/* Check aggregate alredy exist or not. */ -	node = agg_node_get(ripng->aggregate, &p); -	if (node->info) { -		vty_out(vty, "There is already same aggregate route.\n"); -		agg_unlock_node(node); -		return CMD_WARNING; -	} -	node->info = (void *)1; - -	ripng_aggregate_add(&p); - -	return CMD_SUCCESS; -} - -DEFUN (no_ripng_aggregate_address, -       no_ripng_aggregate_address_cmd, -       "no aggregate-address X:X::X:X/M", -       NO_STR -       "Delete aggregate RIPng route announcement\n" -       "Aggregate network\n") -{ -	int idx_ipv6_prefixlen = 2; -	int ret; -	struct prefix p; -	struct agg_node *rn; - -	ret = str2prefix_ipv6(argv[idx_ipv6_prefixlen]->arg, -			      (struct prefix_ipv6 *)&p); -	if (ret <= 0) { -		vty_out(vty, "Malformed address\n"); -		return CMD_WARNING_CONFIG_FAILED; -	} - -	rn = agg_node_lookup(ripng->aggregate, &p); -	if (!rn) { -		vty_out(vty, "Can't find aggregate route.\n"); -		return CMD_WARNING_CONFIG_FAILED; -	} -	agg_unlock_node(rn); -	rn->info = NULL; -	agg_unlock_node(rn); - -	ripng_aggregate_delete(&p); - -	return CMD_SUCCESS; -} -  #if 0  /* RIPng update timer setup. */  DEFUN (ripng_update_timer, @@ -2446,21 +2380,12 @@ static int ripng_config_write(struct vty *vty)  {  	struct lyd_node *dnode;  	int write = 0; -	struct agg_node *rp;  	dnode = yang_dnode_get(running_config->dnode,  			       "/frr-ripngd:ripngd/instance");  	if (dnode) {  		nb_cli_show_dnode_cmds(vty, dnode, false); -		/* RIPng aggregate routes. */ -		for (rp = agg_route_top(ripng->aggregate); rp; -		     rp = agg_route_next(rp)) -			if (rp->info != NULL) -				vty_out(vty, " aggregate-address %s/%d\n", -					inet6_ntoa(rp->p.u.prefix6), -					rp->p.prefixlen); -  		/* RIPng timers configuration. */  		if (ripng->update_time != RIPNG_UPDATE_TIMER_DEFAULT  		    || ripng->timeout_time != RIPNG_TIMEOUT_TIMER_DEFAULT @@ -2629,20 +2554,11 @@ void ripng_clean()  			ripng->sock = -1;  		} -		/* RIPng aggregated prefixes */ -		for (rp = agg_route_top(ripng->aggregate); rp; -		     rp = agg_route_next(rp)) -			if (rp->info) { -				rp->info = NULL; -				agg_unlock_node(rp); -			} -  		for (i = 0; i < ZEBRA_ROUTE_MAX; i++)  			if (ripng->route_map[i].name)  				free(ripng->route_map[i].name);  		XFREE(MTYPE_ROUTE_TABLE, ripng->table); -		XFREE(MTYPE_ROUTE_TABLE, ripng->aggregate);  		stream_free(ripng->ibuf);  		stream_free(ripng->obuf); @@ -2755,8 +2671,6 @@ void ripng_init()  	install_element(ENABLE_NODE, &clear_ipv6_rip_cmd);  	install_default(RIPNG_NODE); -	install_element(RIPNG_NODE, &ripng_aggregate_address_cmd); -	install_element(RIPNG_NODE, &no_ripng_aggregate_address_cmd);  	install_element(RIPNG_NODE, &ripng_timers_cmd);  	install_element(RIPNG_NODE, &no_ripng_timers_cmd); diff --git a/ripngd/ripngd.h b/ripngd/ripngd.h index 82aba1f753..4863d22069 100644 --- a/ripngd/ripngd.h +++ b/ripngd/ripngd.h @@ -111,9 +111,6 @@ struct ripng {  	/* RIPng routing information base. */  	struct agg_table *table; -	/* RIPng aggregate route information. */ -	struct agg_table *aggregate; -  	/* RIPng threads. */  	struct thread *t_read;  	struct thread *t_write;  | 
