diff options
| author | Igor Ryzhov <iryzhov@nfware.com> | 2024-01-23 14:20:49 +0200 | 
|---|---|---|
| committer | Igor Ryzhov <iryzhov@nfware.com> | 2024-01-28 23:28:39 +0200 | 
| commit | d617c9175a34849408612e724813c6b1bed7736c (patch) | |
| tree | 95b19b35bbbf02b6d159f11f8f1b61f3b0718ebd | |
| parent | 10757acae605cb8215608fec03e1b1ebcdcfe74d (diff) | |
zebra: convert interface ipv6 nd suppress-ra command to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
| -rw-r--r-- | yang/frr-zebra.yang | 15 | ||||
| -rw-r--r-- | zebra/rtadv.c | 54 | ||||
| -rw-r--r-- | zebra/rtadv.h | 3 | ||||
| -rw-r--r-- | zebra/zebra_nb.c | 6 | ||||
| -rw-r--r-- | zebra/zebra_nb.h | 2 | ||||
| -rw-r--r-- | zebra/zebra_nb_config.c | 30 | 
6 files changed, 70 insertions, 40 deletions
diff --git a/yang/frr-zebra.yang b/yang/frr-zebra.yang index 95e4fc6db1..fd263406f3 100644 --- a/yang/frr-zebra.yang +++ b/yang/frr-zebra.yang @@ -2264,6 +2264,21 @@ module frr-zebra {              "Uplink to the VxLAN core.";          }        } +      container ipv6-router-advertisements { +        description +          "Support for IPv6 Router Advertisements."; +        leaf send-advertisements { +          type boolean; +          default "false"; +          description +            "A flag indicating whether or not the router sends +            periodic Router Advertisements and responds to +            Router Solicitations."; +          reference +            "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) +                       - AdvSendAdvertisements"; +        } +      }        container state {          config false;          description diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 00f018d192..f6d3ec40d0 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -21,6 +21,7 @@  #include "vrf.h"  #include "ns.h"  #include "lib_errors.h" +#include "northbound_cli.h"  #include "zebra/interface.h"  #include "zebra/rtadv.h" @@ -1248,8 +1249,8 @@ static void rtadv_start_interface_events(struct zebra_vrf *zvrf,  		rtadv_event(zvrf, RTADV_START, 0);  } -static void ipv6_nd_suppress_ra_set(struct interface *ifp, -				    enum ipv6_nd_suppress_ra_status status) +void ipv6_nd_suppress_ra_set(struct interface *ifp, +			     enum ipv6_nd_suppress_ra_status status)  {  	struct zebra_if *zif;  	struct zebra_vrf *zvrf; @@ -1632,49 +1633,23 @@ DEFPY (no_ipv6_nd_ra_retrans_interval,  	return CMD_SUCCESS;  } -DEFUN (ipv6_nd_suppress_ra, +DEFPY_YANG (ipv6_nd_suppress_ra,         ipv6_nd_suppress_ra_cmd, -       "ipv6 nd suppress-ra", -       "Interface IPv6 config commands\n" -       "Neighbor discovery\n" -       "Suppress Router Advertisement\n") -{ -	VTY_DECLVAR_CONTEXT(interface, ifp); -	struct zebra_if *zif = ifp->info; - -	if (if_is_loopback(ifp)) { -		vty_out(vty, -			"Cannot configure IPv6 Router Advertisements on this  interface\n"); -		return CMD_WARNING_CONFIG_FAILED; -	} - -	if (!CHECK_FLAG(zif->rtadv.ra_configured, BGP_RA_CONFIGURED)) -		ipv6_nd_suppress_ra_set(ifp, RA_SUPPRESS); - -	UNSET_FLAG(zif->rtadv.ra_configured, VTY_RA_CONFIGURED); -	return CMD_SUCCESS; -} - -DEFUN (no_ipv6_nd_suppress_ra, -       no_ipv6_nd_suppress_ra_cmd, -       "no ipv6 nd suppress-ra", +       "[no] ipv6 nd suppress-ra",         NO_STR         "Interface IPv6 config commands\n"         "Neighbor discovery\n"         "Suppress Router Advertisement\n")  { -	VTY_DECLVAR_CONTEXT(interface, ifp); -	struct zebra_if *zif = ifp->info; - -	if (if_is_loopback(ifp)) { -		vty_out(vty, -			"Cannot configure IPv6 Router Advertisements on this interface\n"); -		return CMD_WARNING_CONFIG_FAILED; -	} - -	ipv6_nd_suppress_ra_set(ifp, RA_ENABLE); -	SET_FLAG(zif->rtadv.ra_configured, VTY_RA_CONFIGURED); -	return CMD_SUCCESS; +	if (no) +		nb_cli_enqueue_change(vty, +				      "./frr-zebra:zebra/ipv6-router-advertisements/send-advertisements", +				      NB_OP_MODIFY, "true"); +	else +		nb_cli_enqueue_change(vty, +				      "./frr-zebra:zebra/ipv6-router-advertisements/send-advertisements", +				      NB_OP_DESTROY, NULL); +	return nb_cli_apply_changes(vty, NULL);  }  DEFUN (ipv6_nd_ra_interval_msec, @@ -2928,7 +2903,6 @@ void rtadv_cmd_init(void)  	install_element(INTERFACE_NODE, &ipv6_nd_ra_hop_limit_cmd);  	install_element(INTERFACE_NODE, &no_ipv6_nd_ra_hop_limit_cmd);  	install_element(INTERFACE_NODE, &ipv6_nd_suppress_ra_cmd); -	install_element(INTERFACE_NODE, &no_ipv6_nd_suppress_ra_cmd);  	install_element(INTERFACE_NODE, &ipv6_nd_ra_interval_cmd);  	install_element(INTERFACE_NODE, &ipv6_nd_ra_interval_msec_cmd);  	install_element(INTERFACE_NODE, &no_ipv6_nd_ra_interval_cmd); diff --git a/zebra/rtadv.h b/zebra/rtadv.h index 9d358d4b0d..79abe5f7e0 100644 --- a/zebra/rtadv.h +++ b/zebra/rtadv.h @@ -385,6 +385,9 @@ extern void rtadv_if_fini(struct zebra_if *zif);  extern void rtadv_add_prefix(struct zebra_if *zif, const struct prefix_ipv6 *p);  extern void rtadv_delete_prefix(struct zebra_if *zif, const struct prefix *p); +void ipv6_nd_suppress_ra_set(struct interface *ifp, +			     enum ipv6_nd_suppress_ra_status status); +  #else /* !HAVE_RTADV */  struct rtadv {  	/* empty structs aren't valid ISO C */ diff --git a/zebra/zebra_nb.c b/zebra/zebra_nb.c index 15cb9c0858..87cfab5469 100644 --- a/zebra/zebra_nb.c +++ b/zebra/zebra_nb.c @@ -547,6 +547,12 @@ const struct frr_yang_module_info frr_zebra_info = {  			}  		},  		{ +			.xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/send-advertisements", +			.cbs = { +				.modify = lib_interface_zebra_ipv6_router_advertisements_send_advertisements_modify, +			} +		}, +		{  			.xpath = "/frr-interface:lib/interface/frr-zebra:zebra/state/up-count",  			.cbs = {  				.get_elem = lib_interface_zebra_state_up_count_get_elem, diff --git a/zebra/zebra_nb.h b/zebra/zebra_nb.h index 1ddc985ffd..f45270f7b4 100644 --- a/zebra/zebra_nb.h +++ b/zebra/zebra_nb.h @@ -181,6 +181,8 @@ int lib_interface_zebra_evpn_mh_df_preference_modify(  	struct nb_cb_modify_args *args);  int lib_interface_zebra_evpn_mh_bypass_modify(struct nb_cb_modify_args *args);  int lib_interface_zebra_evpn_mh_uplink_modify(struct nb_cb_modify_args *args); +int lib_interface_zebra_ipv6_router_advertisements_send_advertisements_modify( +	struct nb_cb_modify_args *args);  struct yang_data *  lib_interface_zebra_state_up_count_get_elem(struct nb_cb_get_elem_args *args);  struct yang_data * diff --git a/zebra/zebra_nb_config.c b/zebra/zebra_nb_config.c index eb3d5eec2c..d13a75866f 100644 --- a/zebra/zebra_nb_config.c +++ b/zebra/zebra_nb_config.c @@ -2456,6 +2456,36 @@ int lib_interface_zebra_evpn_mh_uplink_modify(struct nb_cb_modify_args *args)  }  /* + * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/send-advertisements + */ +int lib_interface_zebra_ipv6_router_advertisements_send_advertisements_modify( +	struct nb_cb_modify_args *args) +{ +	struct interface *ifp; +	struct zebra_if *zif; +	bool send_adv; + +	if (args->event != NB_EV_APPLY) +		return NB_OK; + +	ifp = nb_running_get_entry(args->dnode, NULL, true); +	zif = ifp->info; + +	send_adv = yang_dnode_get_bool(args->dnode, NULL); + +	if (send_adv) { +		ipv6_nd_suppress_ra_set(ifp, RA_ENABLE); +		SET_FLAG(zif->rtadv.ra_configured, VTY_RA_CONFIGURED); +	} else { +		if (!CHECK_FLAG(zif->rtadv.ra_configured, BGP_RA_CONFIGURED)) +			ipv6_nd_suppress_ra_set(ifp, RA_SUPPRESS); +		UNSET_FLAG(zif->rtadv.ra_configured, VTY_RA_CONFIGURED); +	} + +	return NB_OK; +} + +/*   * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/l3vni-id   */  int lib_vrf_zebra_l3vni_id_modify(struct nb_cb_modify_args *args)  | 
