lib: Hash on resolved nexthops by default

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>
This commit is contained in:
Stephen Worley 2019-07-02 01:34:57 -04:00
parent 7f99772169
commit 2f00094498
2 changed files with 13 additions and 1 deletions

View 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;

View 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