]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: convert interface ipv6 nd ra-fast-retrans command to NB
authorIgor Ryzhov <iryzhov@nfware.com>
Tue, 23 Jan 2024 16:25:31 +0000 (18:25 +0200)
committerIgor Ryzhov <iryzhov@nfware.com>
Sun, 28 Jan 2024 21:28:39 +0000 (23:28 +0200)
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
yang/frr-zebra.yang
zebra/rtadv.c
zebra/zebra_nb.c
zebra/zebra_nb.h
zebra/zebra_nb_config.c

index c68aa0fbcd8695348633de116c107236057dd363..df8439d118c0c9d4af2525fce530e86df23bd243 100644 (file)
@@ -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;
index 6720c47f1d9054185b811192f5ac23d8fe5dc1b8..ee19c19aa5da363d94edcea1947f94065726ea1f 100644 (file)
@@ -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);
index b20dabdb3a5a9871b4e7729059ff179913b31d04..7fb8d03d52d3cd8dfdb672560151c5d28ff9f928 100644 (file)
@@ -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 = {
index d3e9300ccd4a5293f90aa8867faca3242b5c4eb4..e3735245b91c664f6085dd623e2d61b0a6287474 100644 (file)
@@ -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 *
index 707e49d8c11255709cab4b39ae6e49d2b40cf098..7d765728ceb5c3bf887ff3f9b638efd961024d9a 100644 (file)
@@ -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
  */