]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: add ui control for use of backup nexthops in resolution
authorMark Stapp <mjs@voltanet.io>
Mon, 22 Feb 2021 20:06:28 +0000 (15:06 -0500)
committerMark Stapp <mjs@voltanet.io>
Tue, 16 Mar 2021 16:14:53 +0000 (12:14 -0400)
Add a control and api for the use of backup nexthops in
recursive resolution. With 'no', we won't try to use installed
backup nexthops when resolving a recursive route.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
zebra/zebra_nhg.c
zebra/zebra_nhg.h
zebra/zebra_vty.c

index f3ccf83fbc29ba4f177cebd2a1008fef8f3b5f02..244bbc65e4ce182d47f807bf5cddf35927d68d29 100644 (file)
@@ -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
index 2de34fec681b0f65bc4a080efde5e134fc396983..38015bf557d3fede57ae50bf70c20de94d8ebabf 100644 (file)
@@ -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.
index f18d8fbb6d9151fc2af304eb14be4201d357b8d4..3349c182049119931a9e67e62a12834b468d9209 100644 (file)
@@ -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);