diff options
| author | Igor Ryzhov <iryzhov@nfware.com> | 2024-01-23 17:20:22 +0200 | 
|---|---|---|
| committer | Igor Ryzhov <iryzhov@nfware.com> | 2024-01-28 23:28:39 +0200 | 
| commit | a4fee0cb52ffd6e2af0567b4f5d464ba501afa79 (patch) | |
| tree | 050126c10943e79d883fdfbfa9937b5590adac56 | |
| parent | 224429da6f8e90e9999b9a7fabebabca72a63015 (diff) | |
zebra: convert interface ipv6 nd ra-hop-limit command to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
| -rw-r--r-- | yang/frr-zebra.yang | 19 | ||||
| -rw-r--r-- | zebra/rtadv.c | 50 | ||||
| -rw-r--r-- | zebra/zebra_nb.c | 7 | ||||
| -rw-r--r-- | zebra/zebra_nb.h | 4 | ||||
| -rw-r--r-- | zebra/zebra_nb_config.c | 39 | 
5 files changed, 81 insertions, 38 deletions
diff --git a/yang/frr-zebra.yang b/yang/frr-zebra.yang index 16daee3d34..c68aa0fbcd 100644 --- a/yang/frr-zebra.yang +++ b/yang/frr-zebra.yang @@ -2379,6 +2379,25 @@ module frr-zebra {              "RFC 4861: Neighbor Discovery for IP version 6 (IPv6)                         - AdvRetransTimer";          } +        leaf cur-hop-limit { +          type uint8; +          description +            "The value to be placed in the Cur Hop Limit field in +            the Router Advertisement messages sent by the router. +            A value of zero means unspecified (by this router). + +            If this parameter is not configured, the device SHOULD +            use the IANA-specified value for the default IPv4 +            Time to Live (TTL) parameter that was in effect at the +            time of implementation."; +          reference +            "RFC 3232: Assigned Numbers: RFC 1700 is Replaced by +                       an On-line Database +             RFC 4861: Neighbor Discovery for IP version 6 (IPv6) +                       - AdvCurHopLimit +             IANA: IP Parameters +                   (https://www.iana.org/assignments/ip-parameters)"; +        }          leaf default-lifetime {            type uint16 {              range "0..9000"; diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 6f14052962..6720c47f1d 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -1573,49 +1573,24 @@ DEFUN (no_ipv6_nd_ra_fast_retrans,  	return CMD_SUCCESS;  } -DEFPY (ipv6_nd_ra_hop_limit, +DEFPY_YANG (ipv6_nd_ra_hop_limit,         ipv6_nd_ra_hop_limit_cmd, -       "ipv6 nd ra-hop-limit (0-255)$hopcount", -       "Interface IPv6 config commands\n" -       "Neighbor discovery\n" -       "Advertisement Hop Limit\n" -       "Advertisement Hop Limit in hops (default:64)\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; -	} - -	zif->rtadv.AdvCurHopLimit = hopcount; - -	return CMD_SUCCESS; -} - -DEFPY (no_ipv6_nd_ra_hop_limit, -       no_ipv6_nd_ra_hop_limit_cmd, -       "no ipv6 nd ra-hop-limit [(0-255)]", +       "[no] ipv6 nd ra-hop-limit ![(0-255)$hopcount]",         NO_STR         "Interface IPv6 config commands\n"         "Neighbor discovery\n"         "Advertisement Hop Limit\n" -       "Advertisement Hop Limit in hops\n") +       "Advertisement Hop Limit in hops (default:64)\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; -	} - -	zif->rtadv.AdvCurHopLimit = RTADV_DEFAULT_HOPLIMIT; - -	return CMD_SUCCESS; +	if (!no) +		nb_cli_enqueue_change(vty, +				      "./frr-zebra:zebra/ipv6-router-advertisements/cur-hop-limit", +				      NB_OP_MODIFY, hopcount_str); +	else +		nb_cli_enqueue_change(vty, +				      "./frr-zebra:zebra/ipv6-router-advertisements/cur-hop-limit", +				      NB_OP_DESTROY, NULL); +	return nb_cli_apply_changes(vty, NULL);  }  DEFPY_YANG (ipv6_nd_ra_retrans_interval, @@ -2740,7 +2715,6 @@ void rtadv_cmd_init(void)  	install_element(INTERFACE_NODE, &no_ipv6_nd_ra_fast_retrans_cmd);  	install_element(INTERFACE_NODE, &ipv6_nd_ra_retrans_interval_cmd);  	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, &ipv6_nd_ra_interval_cmd);  	install_element(INTERFACE_NODE, &ipv6_nd_ra_lifetime_cmd); diff --git a/zebra/zebra_nb.c b/zebra/zebra_nb.c index c3640b8ee2..b20dabdb3a 100644 --- a/zebra/zebra_nb.c +++ b/zebra/zebra_nb.c @@ -589,6 +589,13 @@ const struct frr_yang_module_info frr_zebra_info = {  			}  		},  		{ +			.xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/cur-hop-limit", +			.cbs = { +				.modify = lib_interface_zebra_ipv6_router_advertisements_cur_hop_limit_modify, +				.destroy = lib_interface_zebra_ipv6_router_advertisements_cur_hop_limit_destroy, +			} +		}, +		{  			.xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/default-lifetime",  			.cbs = {  				.modify = lib_interface_zebra_ipv6_router_advertisements_default_lifetime_modify, diff --git a/zebra/zebra_nb.h b/zebra/zebra_nb.h index fc75740540..d3e9300ccd 100644 --- a/zebra/zebra_nb.h +++ b/zebra/zebra_nb.h @@ -195,6 +195,10 @@ int lib_interface_zebra_ipv6_router_advertisements_reachable_time_modify(  	struct nb_cb_modify_args *args);  int lib_interface_zebra_ipv6_router_advertisements_retrans_timer_modify(  	struct nb_cb_modify_args *args); +int lib_interface_zebra_ipv6_router_advertisements_cur_hop_limit_modify( +	struct nb_cb_modify_args *args); +int lib_interface_zebra_ipv6_router_advertisements_cur_hop_limit_destroy( +	struct nb_cb_destroy_args *args);  int lib_interface_zebra_ipv6_router_advertisements_default_lifetime_modify(  	struct nb_cb_modify_args *args);  int lib_interface_zebra_ipv6_router_advertisements_default_lifetime_destroy( diff --git a/zebra/zebra_nb_config.c b/zebra/zebra_nb_config.c index 3c33314788..707e49d8c1 100644 --- a/zebra/zebra_nb_config.c +++ b/zebra/zebra_nb_config.c @@ -2619,6 +2619,45 @@ int lib_interface_zebra_ipv6_router_advertisements_retrans_timer_modify(  }  /* + * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/cur-hop-limit + */ +int lib_interface_zebra_ipv6_router_advertisements_cur_hop_limit_modify( +	struct nb_cb_modify_args *args) +{ +	struct interface *ifp; +	struct zebra_if *zif; +	uint8_t limit; + +	if (args->event != NB_EV_APPLY) +		return NB_OK; + +	ifp = nb_running_get_entry(args->dnode, NULL, true); +	zif = ifp->info; +	limit = yang_dnode_get_uint8(args->dnode, NULL); + +	zif->rtadv.AdvCurHopLimit = limit; + +	return NB_OK; +} + +int lib_interface_zebra_ipv6_router_advertisements_cur_hop_limit_destroy( +	struct nb_cb_destroy_args *args) +{ +	struct interface *ifp; +	struct zebra_if *zif; + +	if (args->event != NB_EV_APPLY) +		return NB_OK; + +	ifp = nb_running_get_entry(args->dnode, NULL, true); +	zif = ifp->info; + +	zif->rtadv.AdvCurHopLimit = RTADV_DEFAULT_HOPLIMIT; + +	return NB_OK; +} + +/*   * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/default-lifetime   */  int lib_interface_zebra_ipv6_router_advertisements_default_lifetime_modify(  | 
