diff options
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/netfilter/nf_conntrack_reasm.c | 32 | ||||
-rw-r--r-- | net/ipv6/reassembly.c | 11 |
2 files changed, 8 insertions, 35 deletions
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index 52d06dd4b817..9967ac7a01a8 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/ipv6.h> | 27 | #include <linux/ipv6.h> |
28 | #include <linux/icmpv6.h> | 28 | #include <linux/icmpv6.h> |
29 | #include <linux/random.h> | 29 | #include <linux/random.h> |
30 | #include <linux/jhash.h> | ||
31 | 30 | ||
32 | #include <net/sock.h> | 31 | #include <net/sock.h> |
33 | #include <net/snmp.h> | 32 | #include <net/snmp.h> |
@@ -103,39 +102,12 @@ struct ctl_table nf_ct_ipv6_sysctl_table[] = { | |||
103 | }; | 102 | }; |
104 | #endif | 103 | #endif |
105 | 104 | ||
106 | static unsigned int ip6qhashfn(__be32 id, const struct in6_addr *saddr, | ||
107 | const struct in6_addr *daddr) | ||
108 | { | ||
109 | u32 a, b, c; | ||
110 | |||
111 | a = (__force u32)saddr->s6_addr32[0]; | ||
112 | b = (__force u32)saddr->s6_addr32[1]; | ||
113 | c = (__force u32)saddr->s6_addr32[2]; | ||
114 | |||
115 | a += JHASH_GOLDEN_RATIO; | ||
116 | b += JHASH_GOLDEN_RATIO; | ||
117 | c += nf_frags.rnd; | ||
118 | __jhash_mix(a, b, c); | ||
119 | |||
120 | a += (__force u32)saddr->s6_addr32[3]; | ||
121 | b += (__force u32)daddr->s6_addr32[0]; | ||
122 | c += (__force u32)daddr->s6_addr32[1]; | ||
123 | __jhash_mix(a, b, c); | ||
124 | |||
125 | a += (__force u32)daddr->s6_addr32[2]; | ||
126 | b += (__force u32)daddr->s6_addr32[3]; | ||
127 | c += (__force u32)id; | ||
128 | __jhash_mix(a, b, c); | ||
129 | |||
130 | return c & (INETFRAGS_HASHSZ - 1); | ||
131 | } | ||
132 | |||
133 | static unsigned int nf_hashfn(struct inet_frag_queue *q) | 105 | static unsigned int nf_hashfn(struct inet_frag_queue *q) |
134 | { | 106 | { |
135 | const struct nf_ct_frag6_queue *nq; | 107 | const struct nf_ct_frag6_queue *nq; |
136 | 108 | ||
137 | nq = container_of(q, struct nf_ct_frag6_queue, q); | 109 | nq = container_of(q, struct nf_ct_frag6_queue, q); |
138 | return ip6qhashfn(nq->id, &nq->saddr, &nq->daddr); | 110 | return inet6_hash_frag(nq->id, &nq->saddr, &nq->daddr, nf_frags.rnd); |
139 | } | 111 | } |
140 | 112 | ||
141 | static void nf_skb_free(struct sk_buff *skb) | 113 | static void nf_skb_free(struct sk_buff *skb) |
@@ -209,7 +181,7 @@ fq_find(__be32 id, struct in6_addr *src, struct in6_addr *dst) | |||
209 | arg.dst = dst; | 181 | arg.dst = dst; |
210 | 182 | ||
211 | read_lock_bh(&nf_frags.lock); | 183 | read_lock_bh(&nf_frags.lock); |
212 | hash = ip6qhashfn(id, src, dst); | 184 | hash = inet6_hash_frag(id, src, dst, nf_frags.rnd); |
213 | 185 | ||
214 | q = inet_frag_find(&nf_init_frags, &nf_frags, &arg, hash); | 186 | q = inet_frag_find(&nf_init_frags, &nf_frags, &arg, hash); |
215 | local_bh_enable(); | 187 | local_bh_enable(); |
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 89184b576e23..2eeadfa039cb 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c | |||
@@ -99,8 +99,8 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev, | |||
99 | * callers should be careful not to use the hash value outside the ipfrag_lock | 99 | * callers should be careful not to use the hash value outside the ipfrag_lock |
100 | * as doing so could race with ipfrag_hash_rnd being recalculated. | 100 | * as doing so could race with ipfrag_hash_rnd being recalculated. |
101 | */ | 101 | */ |
102 | static unsigned int ip6qhashfn(__be32 id, struct in6_addr *saddr, | 102 | unsigned int inet6_hash_frag(__be32 id, const struct in6_addr *saddr, |
103 | struct in6_addr *daddr) | 103 | const struct in6_addr *daddr, u32 rnd) |
104 | { | 104 | { |
105 | u32 a, b, c; | 105 | u32 a, b, c; |
106 | 106 | ||
@@ -110,7 +110,7 @@ static unsigned int ip6qhashfn(__be32 id, struct in6_addr *saddr, | |||
110 | 110 | ||
111 | a += JHASH_GOLDEN_RATIO; | 111 | a += JHASH_GOLDEN_RATIO; |
112 | b += JHASH_GOLDEN_RATIO; | 112 | b += JHASH_GOLDEN_RATIO; |
113 | c += ip6_frags.rnd; | 113 | c += rnd; |
114 | __jhash_mix(a, b, c); | 114 | __jhash_mix(a, b, c); |
115 | 115 | ||
116 | a += (__force u32)saddr->s6_addr32[3]; | 116 | a += (__force u32)saddr->s6_addr32[3]; |
@@ -125,13 +125,14 @@ static unsigned int ip6qhashfn(__be32 id, struct in6_addr *saddr, | |||
125 | 125 | ||
126 | return c & (INETFRAGS_HASHSZ - 1); | 126 | return c & (INETFRAGS_HASHSZ - 1); |
127 | } | 127 | } |
128 | EXPORT_SYMBOL_GPL(inet6_hash_frag); | ||
128 | 129 | ||
129 | static unsigned int ip6_hashfn(struct inet_frag_queue *q) | 130 | static unsigned int ip6_hashfn(struct inet_frag_queue *q) |
130 | { | 131 | { |
131 | struct frag_queue *fq; | 132 | struct frag_queue *fq; |
132 | 133 | ||
133 | fq = container_of(q, struct frag_queue, q); | 134 | fq = container_of(q, struct frag_queue, q); |
134 | return ip6qhashfn(fq->id, &fq->saddr, &fq->daddr); | 135 | return inet6_hash_frag(fq->id, &fq->saddr, &fq->daddr, ip6_frags.rnd); |
135 | } | 136 | } |
136 | 137 | ||
137 | int ip6_frag_match(struct inet_frag_queue *q, void *a) | 138 | int ip6_frag_match(struct inet_frag_queue *q, void *a) |
@@ -247,7 +248,7 @@ fq_find(struct net *net, __be32 id, struct in6_addr *src, struct in6_addr *dst, | |||
247 | arg.dst = dst; | 248 | arg.dst = dst; |
248 | 249 | ||
249 | read_lock(&ip6_frags.lock); | 250 | read_lock(&ip6_frags.lock); |
250 | hash = ip6qhashfn(id, src, dst); | 251 | hash = inet6_hash_frag(id, src, dst, ip6_frags.rnd); |
251 | 252 | ||
252 | q = inet_frag_find(&net->ipv6.frags, &ip6_frags, &arg, hash); | 253 | q = inet_frag_find(&net->ipv6.frags, &ip6_frags, &arg, hash); |
253 | if (q == NULL) | 254 | if (q == NULL) |