]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: Nexthop hash onlink and ifindex with one call
authorStephen Worley <sworley@cumulusnetworks.com>
Mon, 12 Aug 2019 15:07:53 +0000 (11:07 -0400)
committerStephen Worley <sworley@cumulusnetworks.com>
Fri, 25 Oct 2019 15:13:42 +0000 (11:13 -0400)
In the nexthop hashing function, lets reduce the hash calls as
much as possible. So, reduce the onlink and infindex to one
call to jhash_2words().

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

index 3ab7284492168f35487ca8491140d72ed5b14d44..3f6d9ad71138e56f038d685eeae5290328acb603 100644 (file)
@@ -435,19 +435,9 @@ uint32_t nexthop_hash(const struct nexthop *nexthop)
                        key = jhash_1word(nexthop->nh_label->label[i], key);
        }
 
-       switch (nexthop->type) {
-       case NEXTHOP_TYPE_IPV4_IFINDEX:
-       case NEXTHOP_TYPE_IPV6_IFINDEX:
-       case NEXTHOP_TYPE_IFINDEX:
-               key = jhash_1word(nexthop->ifindex, key);
-               break;
-       case NEXTHOP_TYPE_BLACKHOLE:
-       case NEXTHOP_TYPE_IPV4:
-       case NEXTHOP_TYPE_IPV6:
-               break;
-       }
-
-       key = jhash_1word(CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK), key);
+       key = jhash_2words(nexthop->ifindex,
+                          CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK),
+                          key);
 
        return key;
 }