Skip to content

Commit

Permalink
zebra: Add a configurable knob zebra nexthop-group keep (1-3600)
Browse files Browse the repository at this point in the history
Allow end operator to set how long a nexthop-group is kept around
in the system after it is no-longer being used.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
  • Loading branch information
donaldsharp committed Jun 16, 2022
1 parent 35729f3 commit c9af62e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
6 changes: 6 additions & 0 deletions doc/user/zebra.rst
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ Nexthop tracking doesn't resolve nexthops via the default route by default.
Allowing this might be useful when e.g. you want to allow BGP to peer across
the default route.

.. clicmd:: zebra nexthop-group keep (1-3600)

Set the time that zebra will keep a created and installed nexthop group
before removing it from the system if the nexthop group is no longer
being used. The default time is 180 seconds.

.. clicmd:: ip nht resolve-via-default

Allow IPv4 nexthop tracking to resolve via the default route. This parameter
Expand Down
4 changes: 2 additions & 2 deletions zebra/zebra_nhg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1649,8 +1649,8 @@ void zebra_nhg_decrement_ref(struct nhg_hash_entry *nhe)
!CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_KEEP_AROUND)) {
nhe->refcnt = 1;
SET_FLAG(nhe->flags, NEXTHOP_GROUP_KEEP_AROUND);
thread_add_timer(zrouter.master, zebra_nhg_timer, nhe, 180,
&nhe->timer);
thread_add_timer(zrouter.master, zebra_nhg_timer, nhe,
zrouter.nhg_keep, &nhe->timer);
}

if (!zebra_nhg_depends_is_empty(nhe))
Expand Down
2 changes: 2 additions & 0 deletions zebra/zebra_router.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ void zebra_router_init(bool asic_offload, bool notify_on_ack)

zrouter.packets_to_process = ZEBRA_ZAPI_PACKETS_TO_PROCESS;

zrouter.nhg_keep = ZEBRA_DEFAULT_NHG_KEEP_TIMER;

zebra_vxlan_init();
zebra_mlag_init();

Expand Down
3 changes: 3 additions & 0 deletions zebra/zebra_router.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ struct zebra_router {
bool notify_on_ack;

bool supports_nhgs;

#define ZEBRA_DEFAULT_NHG_KEEP_TIMER 180
uint32_t nhg_keep;
};

#define GRACEFUL_RESTART_TIME 60
Expand Down
21 changes: 21 additions & 0 deletions zebra/zebra_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -3850,11 +3850,31 @@ DEFUN (no_ip_zebra_import_table,
return (zebra_import_table(AFI_IP, VRF_DEFAULT, table_id, 0, NULL, 0));
}

DEFPY (zebra_nexthop_group_keep,
zebra_nexthop_group_keep_cmd,
"[no] zebra nexthop-group keep (1-3600)",
NO_STR
ZEBRA_STR
"Nexthop-Group\n"
"How long to keep\n"
"Time in seconds from 1-3600\n")
{
if (no)
zrouter.nhg_keep = ZEBRA_DEFAULT_NHG_KEEP_TIMER;
else
zrouter.nhg_keep = keep;

return CMD_SUCCESS;
}

static int config_write_protocol(struct vty *vty)
{
if (allow_delete)
vty_out(vty, "allow-external-route-update\n");

if (zrouter.nhg_keep != ZEBRA_DEFAULT_NHG_KEEP_TIMER)
vty_out(vty, "zebra nexthop-group keep %u\n", zrouter.nhg_keep);

if (zrouter.ribq->spec.hold != ZEBRA_RIB_PROCESS_HOLD_TIME)
vty_out(vty, "zebra work-queue %u\n", zrouter.ribq->spec.hold);

Expand Down Expand Up @@ -4433,6 +4453,7 @@ void zebra_vty_init(void)
install_element(CONFIG_NODE, &ip_multicast_mode_cmd);
install_element(CONFIG_NODE, &no_ip_multicast_mode_cmd);

install_element(CONFIG_NODE, &zebra_nexthop_group_keep_cmd);
install_element(CONFIG_NODE, &ip_zebra_import_table_distance_cmd);
install_element(CONFIG_NODE, &no_ip_zebra_import_table_cmd);
install_element(CONFIG_NODE, &zebra_workqueue_timer_cmd);
Expand Down

0 comments on commit c9af62e

Please sign in to comment.