]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: Hash on resolved nexthops by default
authorStephen Worley <sworley@cumulusnetworks.com>
Tue, 2 Jul 2019 05:34:57 +0000 (01:34 -0400)
committerStephen Worley <sworley@cumulusnetworks.com>
Fri, 25 Oct 2019 15:13:40 +0000 (11:13 -0400)
Include resolved nexthops when hashing a nexthop
group but provide an API that allows you to non-recursively
hash as well.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
lib/nexthop_group.c
lib/nexthop_group.h

index c9a8f1af5102e0987cd4151302eb37b98563d6a6..a79b2741c5486b2dbef5636f6a998f095039d644 100644 (file)
@@ -273,7 +273,7 @@ void copy_nexthops(struct nexthop **tnh, const struct nexthop *nh,
        }
 }
 
-uint32_t nexthop_group_hash(const struct nexthop_group *nhg)
+uint32_t nexthop_group_hash_no_recurse(const struct nexthop_group *nhg)
 {
        struct nexthop *nh;
        uint32_t key = 0;
@@ -288,6 +288,17 @@ uint32_t nexthop_group_hash(const struct nexthop_group *nhg)
        return key;
 }
 
+uint32_t nexthop_group_hash(const struct nexthop_group *nhg)
+{
+       struct nexthop *nh;
+       uint32_t key = 0;
+
+       for (ALL_NEXTHOPS_PTR(nhg, nh))
+               key = jhash_1word(nexthop_hash(nh), key);
+
+       return key;
+}
+
 static void nhgc_delete_nexthops(struct nexthop_group_cmd *nhgc)
 {
        struct nexthop *nexthop;
index 57a5a975993e149d9f82a67beeccde0872e103f5..a765b4b76b130b6db05509a3297f455ccd69f8e2 100644 (file)
@@ -48,6 +48,7 @@ void nexthop_group_copy(struct nexthop_group *to,
 void copy_nexthops(struct nexthop **tnh, const struct nexthop *nh,
                   struct nexthop *rparent);
 
+uint32_t nexthop_group_hash_no_recurse(const struct nexthop_group *nhg);
 uint32_t nexthop_group_hash(const struct nexthop_group *nhg);
 
 /* The following for loop allows to iterate over the nexthop