]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: convert interface ipv6 nd home-agent-config-flag command to NB
authorIgor Ryzhov <iryzhov@nfware.com>
Tue, 23 Jan 2024 16:28:33 +0000 (18: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 df8439d118c0c9d4af2525fce530e86df23bd243..0e4b5a129fd34d58ebc1262611cd62e7bfa4ea30 100644 (file)
@@ -2342,6 +2342,15 @@ module frr-zebra {
             "RFC 4861: Neighbor Discovery for IP version 6 (IPv6)
                        - AdvOtherConfigFlag";
         }
+        leaf home-agent-flag {
+          type boolean;
+          default "false";
+          description
+            "The value to be placed in the 'Home Agent'
+            flag field in the Router Advertisement.";
+          reference
+            "RFC 6275: Mobility Support in IPv6";
+        }
         leaf link-mtu {
           type uint32;
           default "0";
index ee19c19aa5da363d94edcea1947f94065726ea1f..38e4a382094814893d1a244383815e764b379c60 100644 (file)
@@ -1762,35 +1762,23 @@ DEFPY_YANG (ipv6_nd_managed_config_flag,
        return nb_cli_apply_changes(vty, NULL);
 }
 
-DEFUN (ipv6_nd_homeagent_config_flag,
+DEFPY_YANG (ipv6_nd_homeagent_config_flag,
        ipv6_nd_homeagent_config_flag_cmd,
-       "ipv6 nd home-agent-config-flag",
-       "Interface IPv6 config commands\n"
-       "Neighbor discovery\n"
-       "Home Agent configuration flag\n")
-{
-       VTY_DECLVAR_CONTEXT(interface, ifp);
-       struct zebra_if *zif = ifp->info;
-
-       zif->rtadv.AdvHomeAgentFlag = 1;
-
-       return CMD_SUCCESS;
-}
-
-DEFUN (no_ipv6_nd_homeagent_config_flag,
-       no_ipv6_nd_homeagent_config_flag_cmd,
-       "no ipv6 nd home-agent-config-flag",
+       "[no] ipv6 nd home-agent-config-flag",
        NO_STR
        "Interface IPv6 config commands\n"
        "Neighbor discovery\n"
        "Home Agent configuration flag\n")
 {
-       VTY_DECLVAR_CONTEXT(interface, ifp);
-       struct zebra_if *zif = ifp->info;
-
-       zif->rtadv.AdvHomeAgentFlag = 0;
-
-       return CMD_SUCCESS;
+       if (!no)
+               nb_cli_enqueue_change(vty,
+                                     "./frr-zebra:zebra/ipv6-router-advertisements/home-agent-flag",
+                                     NB_OP_MODIFY, "true");
+       else
+               nb_cli_enqueue_change(vty,
+                                     "./frr-zebra:zebra/ipv6-router-advertisements/home-agent-flag",
+                                     NB_OP_DESTROY, NULL);
+       return nb_cli_apply_changes(vty, NULL);
 }
 
 DEFUN (ipv6_nd_adv_interval_config_option,
@@ -2697,7 +2685,6 @@ void rtadv_cmd_init(void)
        install_element(INTERFACE_NODE, &ipv6_nd_managed_config_flag_cmd);
        install_element(INTERFACE_NODE, &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);
        install_element(INTERFACE_NODE, &no_ipv6_nd_homeagent_preference_cmd);
        install_element(INTERFACE_NODE, &ipv6_nd_homeagent_lifetime_cmd);
index 7fb8d03d52d3cd8dfdb672560151c5d28ff9f928..53a7fae6beb46408571c9aac5fe8111cc4704915 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/home-agent-flag",
+                       .cbs = {
+                               .modify = lib_interface_zebra_ipv6_router_advertisements_home_agent_flag_modify,
+                       }
+               },
                {
                        .xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/link-mtu",
                        .cbs = {
index e3735245b91c664f6085dd623e2d61b0a6287474..f5c70b0887e406ee8d61ed5d45c5485188407f64 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_home_agent_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(
index 7d765728ceb5c3bf887ff3f9b638efd961024d9a..edd2e68881776cd57d90330c7df05f71b190e540 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/home-agent-flag
+ */
+int lib_interface_zebra_ipv6_router_advertisements_home_agent_flag_modify(
+       struct nb_cb_modify_args *args)
+{
+       struct interface *ifp;
+       struct zebra_if *zif;
+       bool home_agent_flag;
+
+       if (args->event != NB_EV_APPLY)
+               return NB_OK;
+
+       ifp = nb_running_get_entry(args->dnode, NULL, true);
+       zif = ifp->info;
+
+       home_agent_flag = yang_dnode_get_bool(args->dnode, NULL);
+
+       zif->rtadv.AdvHomeAgentFlag = !!home_agent_flag;
+
+       return NB_OK;
+}
+
 /*
  * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/link-mtu
  */