summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2024-01-23 18:31:27 +0200
committerIgor Ryzhov <iryzhov@nfware.com>2024-01-28 23:28:40 +0200
commita003ecda7140fff07de19f51ebd860b09d539dd3 (patch)
treee1e3ceaf22910ab963183d1fe1853ee2c709cd97
parent8a1fdff198cf21bc6463b7283c7e4abac73873ef (diff)
zebra: convert interface ipv6 nd home-agent-lifetime command to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
-rw-r--r--yang/frr-zebra.yang9
-rw-r--r--zebra/rtadv.c37
-rw-r--r--zebra/zebra_nb.c7
-rw-r--r--zebra/zebra_nb.h4
-rw-r--r--zebra/zebra_nb_config.c40
5 files changed, 72 insertions, 25 deletions
diff --git a/yang/frr-zebra.yang b/yang/frr-zebra.yang
index e425fc1443..384585332f 100644
--- a/yang/frr-zebra.yang
+++ b/yang/frr-zebra.yang
@@ -2458,6 +2458,15 @@ module frr-zebra {
reference
"RFC 6275: Mobility Support in IPv6";
}
+ leaf home-agent-lifetime {
+ type uint16;
+ description
+ "The value to be placed in the Home Agent Lifetime
+ field in the Router Advertisement messages sent by the
+ router.";
+ reference
+ "RFC 6275: Mobility Support in IPv6";
+ }
}
container state {
config false;
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index dfab33d9f5..e44cf547da 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -1698,36 +1698,24 @@ DEFPY_YANG (ipv6_nd_homeagent_preference,
return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (ipv6_nd_homeagent_lifetime,
+DEFPY_YANG (ipv6_nd_homeagent_lifetime,
ipv6_nd_homeagent_lifetime_cmd,
- "ipv6 nd home-agent-lifetime (0-65520)",
- "Interface IPv6 config commands\n"
- "Neighbor discovery\n"
- "Home Agent lifetime\n"
- "Home Agent lifetime in seconds (0 to track ra-lifetime)\n")
-{
- int idx_number = 3;
- VTY_DECLVAR_CONTEXT(interface, ifp);
- struct zebra_if *zif = ifp->info;
- zif->rtadv.HomeAgentLifetime = strtoul(argv[idx_number]->arg, NULL, 10);
- return CMD_SUCCESS;
-}
-
-DEFUN (no_ipv6_nd_homeagent_lifetime,
- no_ipv6_nd_homeagent_lifetime_cmd,
- "no ipv6 nd home-agent-lifetime [(0-65520)]",
+ "[no] ipv6 nd home-agent-lifetime ![(1-65520)$lifetime]",
NO_STR
"Interface IPv6 config commands\n"
"Neighbor discovery\n"
"Home Agent lifetime\n"
- "Home Agent lifetime in seconds (0 to track ra-lifetime)\n")
+ "Home Agent lifetime in seconds\n")
{
- VTY_DECLVAR_CONTEXT(interface, ifp);
- struct zebra_if *zif = ifp->info;
-
- zif->rtadv.HomeAgentLifetime = -1;
-
- return CMD_SUCCESS;
+ if (!no)
+ nb_cli_enqueue_change(vty,
+ "./frr-zebra:zebra/ipv6-router-advertisements/home-agent-lifetime",
+ NB_OP_MODIFY, lifetime_str);
+ else
+ nb_cli_enqueue_change(vty,
+ "./frr-zebra:zebra/ipv6-router-advertisements/home-agent-lifetime",
+ NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
DEFPY_YANG (ipv6_nd_managed_config_flag,
@@ -2662,7 +2650,6 @@ void rtadv_cmd_init(void)
install_element(INTERFACE_NODE, &ipv6_nd_homeagent_config_flag_cmd);
install_element(INTERFACE_NODE, &ipv6_nd_homeagent_preference_cmd);
install_element(INTERFACE_NODE, &ipv6_nd_homeagent_lifetime_cmd);
- install_element(INTERFACE_NODE, &no_ipv6_nd_homeagent_lifetime_cmd);
install_element(INTERFACE_NODE, &ipv6_nd_adv_interval_config_option_cmd);
install_element(INTERFACE_NODE, &ipv6_nd_prefix_cmd);
install_element(INTERFACE_NODE, &no_ipv6_nd_prefix_cmd);
diff --git a/zebra/zebra_nb.c b/zebra/zebra_nb.c
index 71f9ae8e7b..f4368ec2a8 100644
--- a/zebra/zebra_nb.c
+++ b/zebra/zebra_nb.c
@@ -628,6 +628,13 @@ const struct frr_yang_module_info frr_zebra_info = {
}
},
{
+ .xpath = "/frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/home-agent-lifetime",
+ .cbs = {
+ .modify = lib_interface_zebra_ipv6_router_advertisements_home_agent_lifetime_modify,
+ .destroy = lib_interface_zebra_ipv6_router_advertisements_home_agent_lifetime_destroy,
+ }
+ },
+ {
.xpath = "/frr-interface:lib/interface/frr-zebra:zebra/state/up-count",
.cbs = {
.get_elem = lib_interface_zebra_state_up_count_get_elem,
diff --git a/zebra/zebra_nb.h b/zebra/zebra_nb.h
index ef01f10f49..bf4c37f10d 100644
--- a/zebra/zebra_nb.h
+++ b/zebra/zebra_nb.h
@@ -213,6 +213,10 @@ int lib_interface_zebra_ipv6_router_advertisements_home_agent_preference_modify(
struct nb_cb_modify_args *args);
int lib_interface_zebra_ipv6_router_advertisements_home_agent_preference_destroy(
struct nb_cb_destroy_args *args);
+int lib_interface_zebra_ipv6_router_advertisements_home_agent_lifetime_modify(
+ struct nb_cb_modify_args *args);
+int lib_interface_zebra_ipv6_router_advertisements_home_agent_lifetime_destroy(
+ struct nb_cb_destroy_args *args);
struct yang_data *
lib_interface_zebra_state_up_count_get_elem(struct nb_cb_get_elem_args *args);
struct yang_data *
diff --git a/zebra/zebra_nb_config.c b/zebra/zebra_nb_config.c
index 433b9cda75..870cb97df3 100644
--- a/zebra/zebra_nb_config.c
+++ b/zebra/zebra_nb_config.c
@@ -2807,6 +2807,46 @@ int lib_interface_zebra_ipv6_router_advertisements_home_agent_preference_destroy
}
/*
+ * XPath: /frr-interface:lib/interface/frr-zebra:zebra/ipv6-router-advertisements/home-agent-lifetime
+ */
+int lib_interface_zebra_ipv6_router_advertisements_home_agent_lifetime_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct interface *ifp;
+ struct zebra_if *zif;
+ uint16_t lifetime;
+
+ if (args->event != NB_EV_APPLY)
+ return NB_OK;
+
+ ifp = nb_running_get_entry(args->dnode, NULL, true);
+ zif = ifp->info;
+
+ lifetime = yang_dnode_get_uint16(args->dnode, NULL);
+
+ zif->rtadv.HomeAgentLifetime = lifetime;
+
+ return NB_OK;
+}
+
+int lib_interface_zebra_ipv6_router_advertisements_home_agent_lifetime_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ struct interface *ifp;
+ struct zebra_if *zif;
+
+ if (args->event != NB_EV_APPLY)
+ return NB_OK;
+
+ ifp = nb_running_get_entry(args->dnode, NULL, true);
+ zif = ifp->info;
+
+ zif->rtadv.HomeAgentLifetime = -1;
+
+ return NB_OK;
+}
+
+/*
* XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/l3vni-id
*/
int lib_vrf_zebra_l3vni_id_modify(struct nb_cb_modify_args *args)