]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: convert interface ipv6 nd ra-retrans-interval command to NB
authorIgor Ryzhov <iryzhov@nfware.com>
Tue, 23 Jan 2024 15:19:41 +0000 (17:19 +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 1a00b84ed3dd5a7fca0d70bca03f27fd09de5faf..16daee3d34108bf73cf3bfa5eb9eef09e36849d1 100644 (file)
@@ -2367,6 +2367,18 @@ module frr-zebra {
             "RFC 4861: Neighbor Discovery for IP version 6 (IPv6)
                        - AdvReachableTime";
         }
+        leaf retrans-timer {
+          type uint32;
+          units "milliseconds";
+          default "0";
+          description
+            "The value to be placed in the Retrans Timer field in
+            the Router Advertisement messages sent by the router.
+            A value of zero means unspecified (by this router).";
+          reference
+            "RFC 4861: Neighbor Discovery for IP version 6 (IPv6)
+                       - AdvRetransTimer";
+        }
         leaf default-lifetime {
           type uint16 {
             range "0..9000";
index 6bc1d5aded7c23bfb772695a3c99075dc4ee5d72..6f1405296284db32543438a0689d3daad238be17 100644 (file)
@@ -1618,49 +1618,24 @@ DEFPY (no_ipv6_nd_ra_hop_limit,
        return CMD_SUCCESS;
 }
 
-DEFPY (ipv6_nd_ra_retrans_interval,
+DEFPY_YANG (ipv6_nd_ra_retrans_interval,
        ipv6_nd_ra_retrans_interval_cmd,
-       "ipv6 nd ra-retrans-interval (0-4294967295)$interval",
-       "Interface IPv6 config commands\n"
-       "Neighbor discovery\n"
-       "Advertisement Retransmit Interval\n"
-       "Advertisement Retransmit Interval in msec\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 loopback interface\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
-
-       zif->rtadv.AdvRetransTimer = interval;
-
-       return CMD_SUCCESS;
-}
-
-DEFPY (no_ipv6_nd_ra_retrans_interval,
-       no_ipv6_nd_ra_retrans_interval_cmd,
-       "no ipv6 nd ra-retrans-interval [(0-4294967295)]",
+       "[no] ipv6 nd ra-retrans-interval ![(0-4294967295)$interval]",
        NO_STR
        "Interface IPv6 config commands\n"
        "Neighbor discovery\n"
        "Advertisement Retransmit Interval\n"
        "Advertisement Retransmit Interval in msec\n")
 {
-       VTY_DECLVAR_CONTEXT(interface, ifp);
-       struct zebra_if *zif = ifp->info;
-
-       if (if_is_loopback(ifp)) {
-               vty_out(vty,
-                       "Cannot remove IPv6 Router Advertisements on loopback interface\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
-
-       zif->rtadv.AdvRetransTimer = 0;
-
-       return CMD_SUCCESS;
+       if (!no)
+               nb_cli_enqueue_change(vty,
+                                     "./frr-zebra:zebra/ipv6-router-advertisements/retrans-timer",
+                                     NB_OP_MODIFY, interval_str);
+       else
+               nb_cli_enqueue_change(vty,
+                                     "./frr-zebra:zebra/ipv6-router-advertisements/retrans-timer",
+                                     NB_OP_DESTROY, NULL);
+       return nb_cli_apply_changes(vty, NULL);
 }
 
 DEFPY_YANG (ipv6_nd_suppress_ra,
@@ -2764,7 +2739,6 @@ void rtadv_cmd_init(void)
        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, &no_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);
index 380f239b368143f96571228b555264f176902094..c3640b8ee24075470460cea27984f25c4e61e68b 100644 (file)
@@ -582,6 +582,12 @@ const struct frr_yang_module_info frr_zebra_info = {
                                .modify = lib_interface_zebra_ipv6_router_advertisements_reachable_time_modify,
                        }
                },
+               {
+                       .xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/retrans-timer",
+                       .cbs = {
+                               .modify = lib_interface_zebra_ipv6_router_advertisements_retrans_timer_modify,
+                       }
+               },
                {
                        .xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/default-lifetime",
                        .cbs = {
index f1efa99f73ce1a06dd9a3cf2914370373032dfda..fc75740540cb5b580997d0a77eba6f1317eb0330 100644 (file)
@@ -193,6 +193,8 @@ 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(
        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_default_lifetime_modify(
        struct nb_cb_modify_args *args);
 int lib_interface_zebra_ipv6_router_advertisements_default_lifetime_destroy(
index 91ed6f5e1ee73a30f704601986f893030bcd572d..3c333147888e45be5e252733b90fd0181758530b 100644 (file)
@@ -2596,6 +2596,28 @@ int lib_interface_zebra_ipv6_router_advertisements_reachable_time_modify(
        return NB_OK;
 }
 
+/*
+ * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/retrans-timer
+ */
+int lib_interface_zebra_ipv6_router_advertisements_retrans_timer_modify(
+       struct nb_cb_modify_args *args)
+{
+       struct interface *ifp;
+       struct zebra_if *zif;
+       uint32_t timer;
+
+       if (args->event != NB_EV_APPLY)
+               return NB_OK;
+
+       ifp = nb_running_get_entry(args->dnode, NULL, true);
+       zif = ifp->info;
+       timer = yang_dnode_get_uint32(args->dnode, NULL);
+
+       zif->rtadv.AdvRetransTimer = timer;
+
+       return NB_OK;
+}
+
 /*
  * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/default-lifetime
  */