]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: convert interface ipv6 nd mtu command to NB
authorIgor Ryzhov <iryzhov@nfware.com>
Tue, 23 Jan 2024 15:18:41 +0000 (17:18 +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 04f4023da67423c997737c9bd9da99854d06112f..1a00b84ed3dd5a7fca0d70bca03f27fd09de5faf 100644 (file)
@@ -2342,6 +2342,17 @@ module frr-zebra {
             "RFC 4861: Neighbor Discovery for IP version 6 (IPv6)
                        - 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 {
           type uint32 {
             range "0..3600000";
index fed6db4ddf8e8ba41bd36d29a24997778acbe380..6bc1d5aded7c23bfb772695a3c99075dc4ee5d72 100644 (file)
@@ -2090,34 +2090,24 @@ DEFUN (no_ipv6_nd_router_preference,
        return CMD_SUCCESS;
 }
 
-DEFUN (ipv6_nd_mtu,
+DEFPY_YANG (ipv6_nd_mtu,
        ipv6_nd_mtu_cmd,
-       "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] ipv6 nd mtu ![(1-65535)]",
        NO_STR
        "Interface IPv6 config commands\n"
        "Neighbor discovery\n"
        "Advertised MTU\n"
        "MTU in bytes\n")
 {
-       VTY_DECLVAR_CONTEXT(interface, ifp);
-       struct zebra_if *zif = ifp->info;
-       zif->rtadv.AdvLinkMTU = 0;
-       return CMD_SUCCESS;
+       if (!no)
+               nb_cli_enqueue_change(vty,
+                                     "./frr-zebra:zebra/ipv6-router-advertisements/link-mtu",
+                                     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)
@@ -2798,7 +2788,6 @@ void rtadv_cmd_init(void)
        install_element(INTERFACE_NODE, &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, &no_ipv6_nd_mtu_cmd);
        install_element(INTERFACE_NODE, &ipv6_nd_rdnss_cmd);
        install_element(INTERFACE_NODE, &no_ipv6_nd_rdnss_cmd);
        install_element(INTERFACE_NODE, &ipv6_nd_dnssl_cmd);
index f3f7d4b8f56d45c189a105705bf400e85f3aef50..380f239b368143f96571228b555264f176902094 100644 (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,
                        }
                },
+               {
+                       .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",
                        .cbs = {
index 65a7a4b7a1726bff7d0a76969a16822b84839022..f1efa99f73ce1a06dd9a3cf2914370373032dfda 100644 (file)
@@ -189,6 +189,8 @@ int lib_interface_zebra_ipv6_router_advertisements_managed_flag_modify(
        struct nb_cb_modify_args *args);
 int lib_interface_zebra_ipv6_router_advertisements_other_config_flag_modify(
        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(
        struct nb_cb_modify_args *args);
 int lib_interface_zebra_ipv6_router_advertisements_default_lifetime_modify(
index ef6ea012df29047d5b7044f112192d6abcb374f5..91ed6f5e1ee73a30f704601986f893030bcd572d 100644 (file)
@@ -2551,6 +2551,29 @@ int lib_interface_zebra_ipv6_router_advertisements_other_config_flag_modify(
        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
  */