Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 78557
b: refs/heads/master
c: 3449882
h: refs/heads/master
i:
  78555: 62fa17d
v: v3
  • Loading branch information
Patrick McHardy authored and David S. Miller committed Jan 28, 2008
1 parent 02748c4 commit 7c7dfa8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 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: 7b21e09d1c17ef0296ec5a6df231a6c5c87b2fd7
refs/heads/master: 34498825cb9062192b77fa02dae672a4fe6eec70
2 changes: 1 addition & 1 deletion trunk/net/ipv4/netfilter/ipt_CLUSTERIP.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ clusterip_hashfn(const struct sk_buff *skb,
}

/* node numbers are 1..n, not 0..n */
return (hashval % config->num_total_nodes) + 1;
return (((u64)hashval * config->num_total_nodes) >> 32) + 1;
}

static inline int
Expand Down
10 changes: 7 additions & 3 deletions trunk/net/ipv4/netfilter/nf_nat_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@ EXPORT_SYMBOL_GPL(nf_nat_proto_put);
static inline unsigned int
hash_by_src(const struct nf_conntrack_tuple *tuple)
{
unsigned int hash;

/* Original src, to ensure we map it consistently if poss. */
return jhash_3words((__force u32)tuple->src.u3.ip,
hash = jhash_3words((__force u32)tuple->src.u3.ip,
(__force u32)tuple->src.u.all,
tuple->dst.protonum, 0) % nf_nat_htable_size;
tuple->dst.protonum, 0);
return ((u64)hash * nf_nat_htable_size) >> 32;
}

/* Is this tuple already taken? (not by us) */
Expand Down Expand Up @@ -211,7 +214,8 @@ find_best_ips_proto(struct nf_conntrack_tuple *tuple,
maxip = ntohl(range->max_ip);
j = jhash_2words((__force u32)tuple->src.u3.ip,
(__force u32)tuple->dst.u3.ip, 0);
*var_ipp = htonl(minip + j % (maxip - minip + 1));
j = ((u64)j * (maxip - minip + 1)) >> 32;
*var_ipp = htonl(minip + j);
}

/* Manipulate the tuple into the range given. For NF_INET_POST_ROUTING,
Expand Down
2 changes: 1 addition & 1 deletion trunk/net/netfilter/nf_conntrack_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static u_int32_t __hash_conntrack(const struct nf_conntrack_tuple *tuple,
((__force __u16)tuple->src.u.all << 16) |
(__force __u16)tuple->dst.u.all);

return jhash_2words(a, b, rnd) % size;
return ((u64)jhash_2words(a, b, rnd) * size) >> 32;
}

static inline u_int32_t hash_conntrack(const struct nf_conntrack_tuple *tuple)
Expand Down
8 changes: 5 additions & 3 deletions trunk/net/netfilter/nf_conntrack_expect.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,17 @@ static void nf_ct_expectation_timed_out(unsigned long ul_expect)

static unsigned int nf_ct_expect_dst_hash(const struct nf_conntrack_tuple *tuple)
{
unsigned int hash;

if (unlikely(!nf_ct_expect_hash_rnd_initted)) {
get_random_bytes(&nf_ct_expect_hash_rnd, 4);
nf_ct_expect_hash_rnd_initted = 1;
}

return jhash2(tuple->dst.u3.all, ARRAY_SIZE(tuple->dst.u3.all),
hash = jhash2(tuple->dst.u3.all, ARRAY_SIZE(tuple->dst.u3.all),
(((tuple->dst.protonum ^ tuple->src.l3num) << 16) |
(__force __u16)tuple->dst.u.all) ^ nf_ct_expect_hash_rnd) %
nf_ct_expect_hsize;
(__force __u16)tuple->dst.u.all) ^ nf_ct_expect_hash_rnd);
return ((u64)hash * nf_ct_expect_hsize) >> 32;
}

struct nf_conntrack_expect *
Expand Down

0 comments on commit 7c7dfa8

Please sign in to comment.