Skip to content

Commit

Permalink
lib, doc: add recursive support configuration for nexthop-group
Browse files Browse the repository at this point in the history
In sharpd, configuring a nexthop-group with an IP nexthop that is not
directly connected does create an inactive NHG context in zebra:

> ubuntu2204(config)# interface loop1
> ubuntu2204(config-if)# ip address 192.0.2.1/24
> ubuntu2204(config-if)# exi
> ubuntu2204(config)# ip route 10.200.0.0/24 192.0.2.100
> ubuntu2204(config)# nexthop-group ABCD
> ubuntu2204(config-nh-group)# nexthop 10.200.0.62
> 2024/01/17 16:52:44 SHARP: [JWRCN-N9K90] Installed nhg 181818168
> ubuntu2204(config-nh-group)# do show nexthop-group rib 181818168
> ID: 181818168 (sharp)
>      RefCnt: 1
>      Uptime: 00:00:04
>      VRF: default
>      Depends: (841)
>            via 10.200.0.62 (vrf default) inactive, weight 1

Add the 'allow-recursion' vty command under nexthop-group configuration.
When set, the nexthop-group ABCD is added or updated, and will update
the nexthop resolution as expected.

> ubuntu2204(config)# interface loop1
> ubuntu2204(config-if)# ip address 192.0.2.1/24
> ubuntu2204(config-if)# exi
> ubuntu2204(config)# ip route 10.200.0.0/24 192.0.2.100
> ubuntu2204(config)# nexthop-group ABCD
> ubuntu2204(config-nh-group)# allow-recursion
> ubuntu2204(config-nh-group)# nexthop 10.200.0.62
> 2024/01/17 16:57:44 SHARP: [JWRCN-N9K90] Installed nhg 181818168
> ubuntu2204(config-nh-group)# do show nexthop-group rib 181818168
> ID: 181818168 (sharp)
>      RefCnt: 1
>      Uptime: 00:00:04
>      VRF: default
>      Valid, Installed
>      Depends: (842)
>         via 10.200.0.62 (vrf default) (recursive), weight 1
>            via 192.0.2.100, loop1 (vrf default), weight 1

The allow-recursion flag is disabled by default, as it is today with
other control plane daemons.

Signed-off-by: Philippe Guibert <[email protected]>
  • Loading branch information
pguibert6WIND committed Sep 9, 2024
1 parent 064c654 commit 2fe3837
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/user/nexthop_groups.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ listing of ECMP nexthops used to forward packets.
will be automatically re-assigned. This cli command must be the first
command entered currently. Additionally this command only works with linux 5.19
kernels or newer.

.. clicmd:: allow-recursion

By default, a nexthop group is only marked as active when its nexthop is
directly connected. The ``allow-recursion`` option allows zebra to resolve the
nexthop using other types of routes.
26 changes: 26 additions & 0 deletions lib/nexthop_group.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,28 @@ DEFPY(nexthop_group_backup, nexthop_group_backup_cmd,
return CMD_SUCCESS;
}

DEFPY(nexthop_group_allow_recursion,
nexthop_group_allow_recursion_cmd,
"[no] allow-recursion",
NO_STR
"Allow recursion when the nexthop is not directly connected\n")
{
VTY_DECLVAR_CONTEXT(nexthop_group_cmd, nhgc);

if (!!no == !CHECK_FLAG(nhgc->nhg.flags, NEXTHOP_GROUP_ALLOW_RECURSION))
return CMD_SUCCESS;

if (no)
UNSET_FLAG(nhgc->nhg.flags, NEXTHOP_GROUP_ALLOW_RECURSION);
else
SET_FLAG(nhgc->nhg.flags, NEXTHOP_GROUP_ALLOW_RECURSION);

if (nhg_hooks.modify)
nhg_hooks.modify(nhgc);

return CMD_SUCCESS;
}

DEFPY(no_nexthop_group_backup, no_nexthop_group_backup_cmd,
"no backup-group [WORD$name]",
NO_STR
Expand Down Expand Up @@ -1173,6 +1195,9 @@ static int nexthop_group_write(struct vty *vty)

vty_out(vty, "nexthop-group %s\n", nhgc->name);

if (CHECK_FLAG(nhgc->nhg.flags, NEXTHOP_GROUP_ALLOW_RECURSION))
vty_out(vty, " allow-recursion\n");

if (nhgc->nhg.nhgr.buckets)
vty_out(vty,
" resilient buckets %u idle-timer %u unbalanced-timer %u\n",
Expand Down Expand Up @@ -1376,6 +1401,7 @@ void nexthop_group_init(void (*new)(const char *name),

install_element(NH_GROUP_NODE, &nexthop_group_resilience_cmd);
install_element(NH_GROUP_NODE, &no_nexthop_group_resilience_cmd);
install_element(NH_GROUP_NODE, &nexthop_group_allow_recursion_cmd);

memset(&nhg_hooks, 0, sizeof(nhg_hooks));

Expand Down

0 comments on commit 2fe3837

Please sign in to comment.