diff --git a/doc/user/nexthop_groups.rst b/doc/user/nexthop_groups.rst index 45f64eecb7e6..be0cd0838c6d 100644 --- a/doc/user/nexthop_groups.rst +++ b/doc/user/nexthop_groups.rst @@ -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. diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c index 11bd1299de1f..4a29aed8b062 100644 --- a/lib/nexthop_group.c +++ b/lib/nexthop_group.c @@ -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 @@ -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", @@ -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));