]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: convert interface ipv6 nd reachable-time command to NB
authorIgor Ryzhov <iryzhov@nfware.com>
Tue, 23 Jan 2024 14:28:43 +0000 (16:28 +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 054192bb1622bf688b1d3c492abf613f101df174..c105836a06972e4bfb74c981a7bfe89724f1ae87 100644 (file)
@@ -2321,6 +2321,20 @@ module frr-zebra {
              RFC 6275: Mobility Support in IPv6";
         }
         */
+        leaf reachable-time {
+          type uint32 {
+            range "0..3600000";
+          }
+          units "milliseconds";
+          default "0";
+          description
+            "The value to be placed in the Reachable Time 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)
+                       - AdvReachableTime";
+        }
         leaf default-lifetime {
           type uint16 {
             range "0..9000";
index fb8ebae550205f3efe1f9f5a2d981bce925e1a8d..a726a2f03ad3ce692234aa19a167b8e8a04d517b 100644 (file)
@@ -1732,36 +1732,24 @@ DEFPY_YANG (ipv6_nd_ra_lifetime,
        return nb_cli_apply_changes(vty, NULL);
 }
 
-DEFUN (ipv6_nd_reachable_time,
+DEFPY_YANG (ipv6_nd_reachable_time,
        ipv6_nd_reachable_time_cmd,
-       "ipv6 nd reachable-time (1-3600000)",
-       "Interface IPv6 config commands\n"
-       "Neighbor discovery\n"
-       "Reachable time\n"
-       "Reachable time in milliseconds\n")
-{
-       int idx_number = 3;
-       VTY_DECLVAR_CONTEXT(interface, ifp);
-       struct zebra_if *zif = ifp->info;
-       zif->rtadv.AdvReachableTime = strtoul(argv[idx_number]->arg, NULL, 10);
-       return CMD_SUCCESS;
-}
-
-DEFUN (no_ipv6_nd_reachable_time,
-       no_ipv6_nd_reachable_time_cmd,
-       "no ipv6 nd reachable-time [(1-3600000)]",
+       "[no] ipv6 nd reachable-time ![(1-3600000)$msec]",
        NO_STR
        "Interface IPv6 config commands\n"
        "Neighbor discovery\n"
        "Reachable time\n"
        "Reachable time in milliseconds\n")
 {
-       VTY_DECLVAR_CONTEXT(interface, ifp);
-       struct zebra_if *zif = ifp->info;
-
-       zif->rtadv.AdvReachableTime = 0;
-
-       return CMD_SUCCESS;
+       if (!no)
+               nb_cli_enqueue_change(vty,
+                                     "./frr-zebra:zebra/ipv6-router-advertisements/reachable-time",
+                                     NB_OP_MODIFY, msec_str);
+       else
+               nb_cli_enqueue_change(vty,
+                                     "./frr-zebra:zebra/ipv6-router-advertisements/reachable-time",
+                                     NB_OP_DESTROY, NULL);
+       return nb_cli_apply_changes(vty, NULL);
 }
 
 DEFUN (ipv6_nd_homeagent_preference,
@@ -2817,7 +2805,6 @@ void rtadv_cmd_init(void)
        install_element(INTERFACE_NODE, &ipv6_nd_ra_interval_cmd);
        install_element(INTERFACE_NODE, &ipv6_nd_ra_lifetime_cmd);
        install_element(INTERFACE_NODE, &ipv6_nd_reachable_time_cmd);
-       install_element(INTERFACE_NODE, &no_ipv6_nd_reachable_time_cmd);
        install_element(INTERFACE_NODE, &ipv6_nd_managed_config_flag_cmd);
        install_element(INTERFACE_NODE, &no_ipv6_nd_managed_config_flag_cmd);
        install_element(INTERFACE_NODE, &ipv6_nd_other_config_flag_cmd);
index 82aebda8ae8339db044726c65b6b886f65c83cef..4b3f27db59e30ad05cffaf63e780b2ee1e7f12ca 100644 (file)
@@ -558,6 +558,12 @@ const struct frr_yang_module_info frr_zebra_info = {
                                .modify = lib_interface_zebra_ipv6_router_advertisements_max_rtr_adv_interval_modify,
                        }
                },
+               {
+                       .xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/reachable-time",
+                       .cbs = {
+                               .modify = lib_interface_zebra_ipv6_router_advertisements_reachable_time_modify,
+                       }
+               },
                {
                        .xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/default-lifetime",
                        .cbs = {
index a7b6797b6379278f8c334737977e9b71ff12dff7..f4f66516dec0503813addfe67ee699191b30de7c 100644 (file)
@@ -185,6 +185,8 @@ int lib_interface_zebra_ipv6_router_advertisements_send_advertisements_modify(
        struct nb_cb_modify_args *args);
 int lib_interface_zebra_ipv6_router_advertisements_max_rtr_adv_interval_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_default_lifetime_modify(
        struct nb_cb_modify_args *args);
 int lib_interface_zebra_ipv6_router_advertisements_default_lifetime_destroy(
index f0d4faaf840ad8b0e1463f4788d88df4c0806635..5cd293e38f379e0e4bfe415aa8cb4d533cdb6580 100644 (file)
@@ -2505,6 +2505,28 @@ int lib_interface_zebra_ipv6_router_advertisements_max_rtr_adv_interval_modify(
        return NB_OK;
 }
 
+/*
+ * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/reachable-time
+ */
+int lib_interface_zebra_ipv6_router_advertisements_reachable_time_modify(
+       struct nb_cb_modify_args *args)
+{
+       struct interface *ifp;
+       struct zebra_if *zif;
+       uint32_t time;
+
+       if (args->event != NB_EV_APPLY)
+               return NB_OK;
+
+       ifp = nb_running_get_entry(args->dnode, NULL, true);
+       zif = ifp->info;
+       time = yang_dnode_get_uint32(args->dnode, NULL);
+
+       zif->rtadv.AdvReachableTime = time;
+
+       return NB_OK;
+}
+
 /*
  * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/default-lifetime
  */