Skip to content

Commit

Permalink
netfilter: xt_HMARK: modulus is expensive for hash calculation
Browse files Browse the repository at this point in the history
Use:

((u64)(HASH_VAL * HASH_SIZE)) >> 32

as suggested by David S. Miller.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Pablo Neira Ayuso committed May 16, 2012
1 parent 5861811 commit c44f5fa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/netfilter/xt_HMARK.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ hmark_hash(struct hmark_tuple *t, const struct xt_hmark_info *info)
hash = jhash_3words(t->src, t->dst, t->uports.v32, info->hashrnd);
hash = hash ^ (t->proto & info->proto_mask);

return (hash % info->hmodulus) + info->hoffset;
return (((u64)hash * info->hmodulus) >> 32) + info->hoffset;
}

static void
Expand Down

0 comments on commit c44f5fa

Please sign in to comment.