]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: convert interface ipv6 nd other-config-flag command to NB
authorIgor Ryzhov <iryzhov@nfware.com>
Tue, 23 Jan 2024 15:17:48 +0000 (17:17 +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 7b5e5808d8a24b4aa2df370b7abbfe0a0c378168..04f4023da67423c997737c9bd9da99854d06112f 100644 (file)
@@ -2332,6 +2332,16 @@ module frr-zebra {
             "RFC 4861: Neighbor Discovery for IP version 6 (IPv6)
                        - AdvManagedFlag";
         }
+        leaf other-config-flag {
+          type boolean;
+          default "false";
+          description
+            "The value to be placed in the 'Other configuration'
+            flag field in the Router Advertisement.";
+          reference
+            "RFC 4861: Neighbor Discovery for IP version 6 (IPv6)
+                       - AdvOtherConfigFlag";
+        }
         leaf reachable-time {
           type uint32 {
             range "0..3600000";
index 2622bcfce9916017a4799bfaf5907efdc3c46980..fed6db4ddf8e8ba41bd36d29a24997778acbe380 100644 (file)
@@ -1898,35 +1898,23 @@ DEFUN (no_ipv6_nd_adv_interval_config_option,
        return CMD_SUCCESS;
 }
 
-DEFUN (ipv6_nd_other_config_flag,
+DEFPY_YANG (ipv6_nd_other_config_flag,
        ipv6_nd_other_config_flag_cmd,
-       "ipv6 nd other-config-flag",
-       "Interface IPv6 config commands\n"
-       "Neighbor discovery\n"
-       "Other statefull configuration flag\n")
-{
-       VTY_DECLVAR_CONTEXT(interface, ifp);
-       struct zebra_if *zif = ifp->info;
-
-       zif->rtadv.AdvOtherConfigFlag = 1;
-
-       return CMD_SUCCESS;
-}
-
-DEFUN (no_ipv6_nd_other_config_flag,
-       no_ipv6_nd_other_config_flag_cmd,
-       "no ipv6 nd other-config-flag",
+       "[no] ipv6 nd other-config-flag",
        NO_STR
        "Interface IPv6 config commands\n"
        "Neighbor discovery\n"
        "Other statefull configuration flag\n")
 {
-       VTY_DECLVAR_CONTEXT(interface, ifp);
-       struct zebra_if *zif = ifp->info;
-
-       zif->rtadv.AdvOtherConfigFlag = 0;
-
-       return CMD_SUCCESS;
+       if (!no)
+               nb_cli_enqueue_change(vty,
+                                     "./frr-zebra:zebra/ipv6-router-advertisements/other-config-flag",
+                                     NB_OP_MODIFY, "true");
+       else
+               nb_cli_enqueue_change(vty,
+                                     "./frr-zebra:zebra/ipv6-router-advertisements/other-config-flag",
+                                     NB_OP_DESTROY, NULL);
+       return nb_cli_apply_changes(vty, NULL);
 }
 
 DEFUN (ipv6_nd_prefix,
@@ -2795,7 +2783,6 @@ void rtadv_cmd_init(void)
        install_element(INTERFACE_NODE, &ipv6_nd_reachable_time_cmd);
        install_element(INTERFACE_NODE, &ipv6_nd_managed_config_flag_cmd);
        install_element(INTERFACE_NODE, &ipv6_nd_other_config_flag_cmd);
-       install_element(INTERFACE_NODE, &no_ipv6_nd_other_config_flag_cmd);
        install_element(INTERFACE_NODE, &ipv6_nd_homeagent_config_flag_cmd);
        install_element(INTERFACE_NODE, &no_ipv6_nd_homeagent_config_flag_cmd);
        install_element(INTERFACE_NODE, &ipv6_nd_homeagent_preference_cmd);
index 58dfd233c4afea8eacea9fe09fff63427e69d633..f3f7d4b8f56d45c189a105705bf400e85f3aef50 100644 (file)
@@ -564,6 +564,12 @@ const struct frr_yang_module_info frr_zebra_info = {
                                .modify = lib_interface_zebra_ipv6_router_advertisements_managed_flag_modify,
                        }
                },
+               {
+                       .xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/other-config-flag",
+                       .cbs = {
+                               .modify = lib_interface_zebra_ipv6_router_advertisements_other_config_flag_modify,
+                       }
+               },
                {
                        .xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/reachable-time",
                        .cbs = {
index c9f7c0b31490bd876a3b89b4af607716e5974a70..65a7a4b7a1726bff7d0a76969a16822b84839022 100644 (file)
@@ -187,6 +187,8 @@ 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_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_reachable_time_modify(
        struct nb_cb_modify_args *args);
 int lib_interface_zebra_ipv6_router_advertisements_default_lifetime_modify(
index 0875b76cb3a5be7b1af4269323043f0a9f545207..ef6ea012df29047d5b7044f112192d6abcb374f5 100644 (file)
@@ -2528,6 +2528,29 @@ int lib_interface_zebra_ipv6_router_advertisements_managed_flag_modify(
        return NB_OK;
 }
 
+/*
+ * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/other-config-flag
+ */
+int lib_interface_zebra_ipv6_router_advertisements_other_config_flag_modify(
+       struct nb_cb_modify_args *args)
+{
+       struct interface *ifp;
+       struct zebra_if *zif;
+       bool other_config_flag;
+
+       if (args->event != NB_EV_APPLY)
+               return NB_OK;
+
+       ifp = nb_running_get_entry(args->dnode, NULL, true);
+       zif = ifp->info;
+
+       other_config_flag = yang_dnode_get_bool(args->dnode, NULL);
+
+       zif->rtadv.AdvOtherConfigFlag = !!other_config_flag;
+
+       return NB_OK;
+}
+
 /*
  * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/reachable-time
  */