Skip to content

Commit

Permalink
zebra: convert interface ipv6 nd home-agent-lifetime command to NB
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Ryzhov <[email protected]>
  • Loading branch information
idryzhov committed Jan 23, 2024
1 parent 65e9bfd commit c84e0f1
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 25 deletions.
9 changes: 9 additions & 0 deletions yang/frr-zebra.yang
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
37 changes: 12 additions & 25 deletions zebra/rtadv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions zebra/zebra_nb.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,13 @@ const struct frr_yang_module_info frr_zebra_info = {
.destroy = lib_interface_zebra_ipv6_router_advertisements_home_agent_preference_destroy,
}
},
{
.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 = {
Expand Down
4 changes: 4 additions & 0 deletions zebra/zebra_nb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down
40 changes: 40 additions & 0 deletions zebra/zebra_nb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -2806,6 +2806,46 @@ int lib_interface_zebra_ipv6_router_advertisements_home_agent_preference_destroy
return NB_OK;
}

/*
* 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
*/
Expand Down

0 comments on commit c84e0f1

Please sign in to comment.