zebra: convert interface ipv6 nd mtu command to NB

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
Igor Ryzhov 2024-01-23 17:18:41 +02:00
parent b829d5fca2
commit 966fcb6c0f
5 changed files with 53 additions and 22 deletions

View File

@ -2342,6 +2342,17 @@ module frr-zebra {
"RFC 4861: Neighbor Discovery for IP version 6 (IPv6) "RFC 4861: Neighbor Discovery for IP version 6 (IPv6)
- AdvOtherConfigFlag"; - AdvOtherConfigFlag";
} }
leaf link-mtu {
type uint32;
default "0";
description
"The value to be placed in MTU options sent by the
router. A value of zero indicates that no MTU options
are sent.";
reference
"RFC 4861: Neighbor Discovery for IP version 6 (IPv6)
- AdvLinkMTU";
}
leaf reachable-time { leaf reachable-time {
type uint32 { type uint32 {
range "0..3600000"; range "0..3600000";

View File

@ -2090,34 +2090,24 @@ DEFUN (no_ipv6_nd_router_preference,
return CMD_SUCCESS; return CMD_SUCCESS;
} }
DEFUN (ipv6_nd_mtu, DEFPY_YANG (ipv6_nd_mtu,
ipv6_nd_mtu_cmd, ipv6_nd_mtu_cmd,
"ipv6 nd mtu (1-65535)", "[no] ipv6 nd mtu ![(1-65535)]",
"Interface IPv6 config commands\n"
"Neighbor discovery\n"
"Advertised MTU\n"
"MTU in bytes\n")
{
int idx_number = 3;
VTY_DECLVAR_CONTEXT(interface, ifp);
struct zebra_if *zif = ifp->info;
zif->rtadv.AdvLinkMTU = strtoul(argv[idx_number]->arg, NULL, 10);
return CMD_SUCCESS;
}
DEFUN (no_ipv6_nd_mtu,
no_ipv6_nd_mtu_cmd,
"no ipv6 nd mtu [(1-65535)]",
NO_STR NO_STR
"Interface IPv6 config commands\n" "Interface IPv6 config commands\n"
"Neighbor discovery\n" "Neighbor discovery\n"
"Advertised MTU\n" "Advertised MTU\n"
"MTU in bytes\n") "MTU in bytes\n")
{ {
VTY_DECLVAR_CONTEXT(interface, ifp); if (!no)
struct zebra_if *zif = ifp->info; nb_cli_enqueue_change(vty,
zif->rtadv.AdvLinkMTU = 0; "./frr-zebra:zebra/ipv6-router-advertisements/link-mtu",
return CMD_SUCCESS; NB_OP_MODIFY, mtu_str);
else
nb_cli_enqueue_change(vty,
"./frr-zebra:zebra/ipv6-router-advertisements/link-mtu",
NB_OP_DESTROY, NULL);
return nb_cli_apply_changes(vty, NULL);
} }
static struct rtadv_rdnss *rtadv_rdnss_new(void) static struct rtadv_rdnss *rtadv_rdnss_new(void)
@ -2798,7 +2788,6 @@ void rtadv_cmd_init(void)
install_element(INTERFACE_NODE, &ipv6_nd_router_preference_cmd); install_element(INTERFACE_NODE, &ipv6_nd_router_preference_cmd);
install_element(INTERFACE_NODE, &no_ipv6_nd_router_preference_cmd); install_element(INTERFACE_NODE, &no_ipv6_nd_router_preference_cmd);
install_element(INTERFACE_NODE, &ipv6_nd_mtu_cmd); install_element(INTERFACE_NODE, &ipv6_nd_mtu_cmd);
install_element(INTERFACE_NODE, &no_ipv6_nd_mtu_cmd);
install_element(INTERFACE_NODE, &ipv6_nd_rdnss_cmd); install_element(INTERFACE_NODE, &ipv6_nd_rdnss_cmd);
install_element(INTERFACE_NODE, &no_ipv6_nd_rdnss_cmd); install_element(INTERFACE_NODE, &no_ipv6_nd_rdnss_cmd);
install_element(INTERFACE_NODE, &ipv6_nd_dnssl_cmd); install_element(INTERFACE_NODE, &ipv6_nd_dnssl_cmd);

View File

@ -570,6 +570,12 @@ const struct frr_yang_module_info frr_zebra_info = {
.modify = lib_interface_zebra_ipv6_router_advertisements_other_config_flag_modify, .modify = lib_interface_zebra_ipv6_router_advertisements_other_config_flag_modify,
} }
}, },
{
.xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/link-mtu",
.cbs = {
.modify = lib_interface_zebra_ipv6_router_advertisements_link_mtu_modify,
}
},
{ {
.xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/reachable-time", .xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/reachable-time",
.cbs = { .cbs = {

View File

@ -189,6 +189,8 @@ int lib_interface_zebra_ipv6_router_advertisements_managed_flag_modify(
struct nb_cb_modify_args *args); struct nb_cb_modify_args *args);
int lib_interface_zebra_ipv6_router_advertisements_other_config_flag_modify( int lib_interface_zebra_ipv6_router_advertisements_other_config_flag_modify(
struct nb_cb_modify_args *args); struct nb_cb_modify_args *args);
int lib_interface_zebra_ipv6_router_advertisements_link_mtu_modify(
struct nb_cb_modify_args *args);
int lib_interface_zebra_ipv6_router_advertisements_reachable_time_modify( int lib_interface_zebra_ipv6_router_advertisements_reachable_time_modify(
struct nb_cb_modify_args *args); struct nb_cb_modify_args *args);
int lib_interface_zebra_ipv6_router_advertisements_default_lifetime_modify( int lib_interface_zebra_ipv6_router_advertisements_default_lifetime_modify(

View File

@ -2551,6 +2551,29 @@ int lib_interface_zebra_ipv6_router_advertisements_other_config_flag_modify(
return NB_OK; return NB_OK;
} }
/*
* XPath: /frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/link-mtu
*/
int lib_interface_zebra_ipv6_router_advertisements_link_mtu_modify(
struct nb_cb_modify_args *args)
{
struct interface *ifp;
struct zebra_if *zif;
uint32_t mtu;
if (args->event != NB_EV_APPLY)
return NB_OK;
ifp = nb_running_get_entry(args->dnode, NULL, true);
zif = ifp->info;
mtu = yang_dnode_get_uint32(args->dnode, NULL);
zif->rtadv.AdvLinkMTU = mtu;
return NB_OK;
}
/* /*
* XPath: /frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/reachable-time * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/reachable-time
*/ */