]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_nhg.c
Merge pull request #5789 from donaldsharp/bgp_ebgp_reason
[mirror_frr.git] / zebra / zebra_nhg.c
index 732349a570621f96c7e95e4bd480a5e0fb40c5b6..bb95e72382c1840c4305ae04cf811ac6c91d82c3 100644 (file)
@@ -49,6 +49,9 @@ DEFINE_MTYPE_STATIC(ZEBRA, NHG_CTX, "Nexthop Group Context");
 /* id counter to keep in sync with kernel */
 uint32_t id_counter;
 
+/*  */
+static bool g_nexthops_enabled = true;
+
 static struct nhg_hash_entry *depends_find(const struct nexthop *nh,
                                           afi_t afi);
 static void depends_add(struct nhg_connected_tree_head *head,
@@ -711,7 +714,6 @@ static void nhg_ctx_free(struct nhg_ctx **ctx)
 
 done:
        XFREE(MTYPE_NHG_CTX, *ctx);
-       *ctx = NULL;
 }
 
 static struct nhg_ctx *nhg_ctx_init(uint32_t id, struct nexthop *nh,
@@ -1486,7 +1488,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,
                 * resolved by a route NH1. The exception is if the route is a
                 * host route.
                 */
-               if (top && rn == top)
+               if (rn == top)
                        if (((afi == AFI_IP) && (rn->p.prefixlen != 32))
                            || ((afi == AFI_IP6) && (rn->p.prefixlen != 128))) {
                                if (IS_ZEBRA_DEBUG_RIB_DETAILED)
@@ -2029,3 +2031,18 @@ void zebra_nhg_sweep_table(struct hash *hash)
 {
        hash_iterate(hash, zebra_nhg_sweep_entry, NULL);
 }
+
+/* Global control to disable use of kernel nexthops, if available. We can't
+ * force the kernel to support nexthop ids, of course, but we can disable
+ * zebra's use of them, for testing e.g. By default, if the kernel supports
+ * nexthop ids, zebra uses them.
+ */
+void zebra_nhg_enable_kernel_nexthops(bool set)
+{
+       g_nexthops_enabled = set;
+}
+
+bool zebra_nhg_kernel_nexthops_enabled(void)
+{
+       return g_nexthops_enabled;
+}