From 26f80e96698f35ffe6f41aabb9c2fcd0af998a42 Mon Sep 17 00:00:00 2001 From: Igor Ryzhov Date: Tue, 23 Jan 2024 18:25:31 +0200 Subject: [PATCH] zebra: convert interface ipv6 nd ra-fast-retrans command to NB Signed-off-by: Igor Ryzhov --- yang/frr-zebra.yang | 8 +++++++ zebra/rtadv.c | 47 ++++++++++------------------------------- zebra/zebra_nb.c | 6 ++++++ zebra/zebra_nb.h | 2 ++ zebra/zebra_nb_config.c | 23 ++++++++++++++++++++ 5 files changed, 50 insertions(+), 36 deletions(-) diff --git a/yang/frr-zebra.yang b/yang/frr-zebra.yang index c68aa0fbcd..df8439d118 100644 --- a/yang/frr-zebra.yang +++ b/yang/frr-zebra.yang @@ -2423,6 +2423,14 @@ module frr-zebra { "RFC 4861: Neighbor Discovery for IP version 6 (IPv6) - AdvDefaultLifetime"; } + leaf fast-retransmit { + type boolean; + default "true"; + description + "Allow sending unsolicited multicast Router Advertisements + more frequently than once every 3 seconds as required by + RFC 4861."; + } } container state { config false; diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 6720c47f1d..ee19c19aa5 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -1530,47 +1530,23 @@ DEFPY(show_ipv6_nd_ra_if, show_ipv6_nd_ra_if_cmd, return CMD_SUCCESS; } -DEFUN (ipv6_nd_ra_fast_retrans, +DEFPY_YANG (ipv6_nd_ra_fast_retrans, ipv6_nd_ra_fast_retrans_cmd, - "ipv6 nd ra-fast-retrans", - "Interface IPv6 config commands\n" - "Neighbor discovery\n" - "Fast retransmit of RA packets\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.UseFastRexmit = true; - - return CMD_SUCCESS; -} - -DEFUN (no_ipv6_nd_ra_fast_retrans, - no_ipv6_nd_ra_fast_retrans_cmd, - "no ipv6 nd ra-fast-retrans", + "[no] ipv6 nd ra-fast-retrans", NO_STR "Interface IPv6 config commands\n" "Neighbor discovery\n" "Fast retransmit of RA packets\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.UseFastRexmit = false; - - return CMD_SUCCESS; + if (no) + nb_cli_enqueue_change(vty, + "./frr-zebra:zebra/ipv6-router-advertisements/fast-retransmit", + NB_OP_MODIFY, "false"); + else + nb_cli_enqueue_change(vty, + "./frr-zebra:zebra/ipv6-router-advertisements/fast-retransmit", + NB_OP_DESTROY, NULL); + return nb_cli_apply_changes(vty, NULL); } DEFPY_YANG (ipv6_nd_ra_hop_limit, @@ -2712,7 +2688,6 @@ void rtadv_cmd_init(void) install_element(VIEW_NODE, &show_ipv6_nd_ra_if_cmd); install_element(INTERFACE_NODE, &ipv6_nd_ra_fast_retrans_cmd); - 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, &ipv6_nd_suppress_ra_cmd); diff --git a/zebra/zebra_nb.c b/zebra/zebra_nb.c index b20dabdb3a..7fb8d03d52 100644 --- a/zebra/zebra_nb.c +++ b/zebra/zebra_nb.c @@ -602,6 +602,12 @@ const struct frr_yang_module_info frr_zebra_info = { .destroy = lib_interface_zebra_ipv6_router_advertisements_default_lifetime_destroy, } }, + { + .xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/fast-retransmit", + .cbs = { + .modify = lib_interface_zebra_ipv6_router_advertisements_fast_retransmit_modify, + } + }, { .xpath = "/frr-interface:lib/interface/frr-zebra:zebra/state/up-count", .cbs = { diff --git a/zebra/zebra_nb.h b/zebra/zebra_nb.h index d3e9300ccd..e3735245b9 100644 --- a/zebra/zebra_nb.h +++ b/zebra/zebra_nb.h @@ -203,6 +203,8 @@ 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( struct nb_cb_destroy_args *args); +int lib_interface_zebra_ipv6_router_advertisements_fast_retransmit_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 707e49d8c1..7d765728ce 100644 --- a/zebra/zebra_nb_config.c +++ b/zebra/zebra_nb_config.c @@ -2697,6 +2697,29 @@ int lib_interface_zebra_ipv6_router_advertisements_default_lifetime_destroy( return NB_OK; } +/* + * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/fast-retransmit + */ +int lib_interface_zebra_ipv6_router_advertisements_fast_retransmit_modify( + struct nb_cb_modify_args *args) +{ + struct interface *ifp; + struct zebra_if *zif; + bool fast_retransmit; + + if (args->event != NB_EV_APPLY) + return NB_OK; + + ifp = nb_running_get_entry(args->dnode, NULL, true); + zif = ifp->info; + + fast_retransmit = yang_dnode_get_bool(args->dnode, NULL); + + zif->rtadv.UseFastRexmit = fast_retransmit; + + return NB_OK; +} + /* * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/l3vni-id */ -- 2.39.5