diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index f3ccf83fbc..244bbc65e4 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -52,9 +52,10 @@ DEFINE_MTYPE_STATIC(ZEBRA, NHG_CTX, "Nexthop Group Context"); /* id counter to keep in sync with kernel */ uint32_t id_counter; -/* */ +/* Controlled through ui */ static bool g_nexthops_enabled = true; static bool proto_nexthops_only; +static bool use_recursive_backups = true; static struct nhg_hash_entry *depends_find(const struct nexthop *nh, afi_t afi, int type, bool from_dplane); @@ -2088,10 +2089,12 @@ static int nexthop_active(afi_t afi, struct nexthop *nexthop, /* Examine installed backup nexthops, if any. There * are only installed backups *if* there is a - * dedicated fib list. + * dedicated fib list. The UI can also control use + * of backups for resolution. */ nhg = rib_get_fib_backup_nhg(match); - if (nhg == NULL || nhg->nexthop == NULL) + if (!use_recursive_backups || + nhg == NULL || nhg->nexthop == NULL) goto done_with_match; for (ALL_NEXTHOPS_PTR(nhg, newhop)) { @@ -2834,6 +2837,17 @@ bool zebra_nhg_kernel_nexthops_enabled(void) return g_nexthops_enabled; } +/* Global control for use of activated backups for recursive resolution. */ +void zebra_nhg_set_recursive_use_backups(bool set) +{ + use_recursive_backups = set; +} + +bool zebra_nhg_recursive_use_backups(void) +{ + return use_recursive_backups; +} + /* * Global control to only use kernel nexthops for protocol created NHGs. * There are some use cases where you may not want zebra to implicitly diff --git a/zebra/zebra_nhg.h b/zebra/zebra_nhg.h index 2de34fec68..38015bf557 100644 --- a/zebra/zebra_nhg.h +++ b/zebra/zebra_nhg.h @@ -212,6 +212,10 @@ bool zebra_nhg_kernel_nexthops_enabled(void); void zebra_nhg_set_proto_nexthops_only(bool set); bool zebra_nhg_proto_nexthops_only(void); +/* Global control for use of activated backups for recursive resolution. */ +void zebra_nhg_set_recursive_use_backups(bool set); +bool zebra_nhg_recursive_use_backups(void); + /** * NHE abstracted tree functions. * Use these where possible instead of direct access. diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index f18d8fbb6d..3349c18204 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -1636,6 +1636,18 @@ DEFPY_HIDDEN(proto_nexthop_group_only, proto_nexthop_group_only_cmd, return CMD_SUCCESS; } +DEFPY_HIDDEN(backup_nexthop_recursive_use_enable, + backup_nexthop_recursive_use_enable_cmd, + "[no] zebra nexthop resolve-via-backup", + NO_STR + ZEBRA_STR + "Nexthop configuration \n" + "Configure use of backup nexthops in recursive resolution\n") +{ + zebra_nhg_set_recursive_use_backups(!no); + return CMD_SUCCESS; +} + DEFUN (no_ip_nht_default_route, no_ip_nht_default_route_cmd, "no ip nht resolve-via-default", @@ -3619,6 +3631,9 @@ static int config_write_protocol(struct vty *vty) if (zebra_nhg_proto_nexthops_only()) vty_out(vty, "zebra nexthop proto only\n"); + if (!zebra_nhg_recursive_use_backups()) + vty_out(vty, "no zebra nexthop resolve-via-backup\n"); + #ifdef HAVE_NETLINK /* Include netlink info */ netlink_config_write_helper(vty); @@ -4054,6 +4069,7 @@ void zebra_vty_init(void) install_element(CONFIG_NODE, &no_zebra_packet_process_cmd); install_element(CONFIG_NODE, &nexthop_group_use_enable_cmd); install_element(CONFIG_NODE, &proto_nexthop_group_only_cmd); + install_element(CONFIG_NODE, &backup_nexthop_recursive_use_enable_cmd); install_element(VIEW_NODE, &show_nexthop_group_cmd); install_element(VIEW_NODE, &show_interface_nexthop_group_cmd);