Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 78555
b: refs/heads/master
c: e2f82ac
h: refs/heads/master
i:
  78553: 2191771
  78551: fd5c3ff
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Jan 28, 2008
1 parent cba9962 commit 62fa17d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 22c2d8bca212a655c120fd6617328ffa3480afad
refs/heads/master: e2f82ac3fcffffca59751b65124544d11ed8be4a
11 changes: 10 additions & 1 deletion trunk/net/netfilter/xt_hashlimit.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,16 @@ static inline bool dst_cmp(const struct dsthash_ent *ent,
static u_int32_t
hash_dst(const struct xt_hashlimit_htable *ht, const struct dsthash_dst *dst)
{
return jhash(dst, sizeof(*dst), ht->rnd) % ht->cfg.size;
u_int32_t hash = jhash2((const u32 *)dst,
sizeof(*dst)/sizeof(u32),
ht->rnd);
/*
* Instead of returning hash % ht->cfg.size (implying a divide)
* we return the high 32 bits of the (hash * ht->cfg.size) that will
* give results between [0 and cfg.size-1] and same hash distribution,
* but using a multiply, less expensive than a divide
*/
return ((u64)hash * ht->cfg.size) >> 32;
}

static struct dsthash_ent *
Expand Down

0 comments on commit 62fa17d

Please sign in to comment.