aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/reassembly.c
diff options
context:
space:
mode:
authorHannes Frederic Sowa <hannes@stressinduktion.org>2013-10-23 05:06:56 -0400
committerDavid S. Miller <davem@davemloft.net>2013-10-23 17:01:40 -0400
commitb1190570b451fb9fd77be8c115fcdb418c5108a5 (patch)
tree6b9d50498ba3b2904b021da902362f90105ded8d /net/ipv6/reassembly.c
parente7b519ba55aeb675daee1d304e80d752c385f7f0 (diff)
ipv6: split inet6_hash_frag for netfilter and initialize secrets with net_get_random_once
Defer the fragmentation hash secret initialization for IPv6 like the previous patch did for IPv4. Because the netfilter logic reuses the hash secret we have to split it first. Thus introduce a new nf_hash_frag function which takes care to seed the hash secret. Cc: David S. Miller <davem@davemloft.net> Cc: Eric Dumazet <edumazet@google.com> Cc: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/reassembly.c')
-rw-r--r--net/ipv6/reassembly.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 1aeb473b2cc6..cc85a9ba5010 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -82,24 +82,24 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
82 * callers should be careful not to use the hash value outside the ipfrag_lock 82 * callers should be careful not to use the hash value outside the ipfrag_lock
83 * as doing so could race with ipfrag_hash_rnd being recalculated. 83 * as doing so could race with ipfrag_hash_rnd being recalculated.
84 */ 84 */
85unsigned int inet6_hash_frag(__be32 id, const struct in6_addr *saddr, 85static unsigned int inet6_hash_frag(__be32 id, const struct in6_addr *saddr,
86 const struct in6_addr *daddr, u32 rnd) 86 const struct in6_addr *daddr)
87{ 87{
88 u32 c; 88 u32 c;
89 89
90 net_get_random_once(&ip6_frags.rnd, sizeof(ip6_frags.rnd));
90 c = jhash_3words(ipv6_addr_hash(saddr), ipv6_addr_hash(daddr), 91 c = jhash_3words(ipv6_addr_hash(saddr), ipv6_addr_hash(daddr),
91 (__force u32)id, rnd); 92 (__force u32)id, ip6_frags.rnd);
92 93
93 return c & (INETFRAGS_HASHSZ - 1); 94 return c & (INETFRAGS_HASHSZ - 1);
94} 95}
95EXPORT_SYMBOL_GPL(inet6_hash_frag);
96 96
97static unsigned int ip6_hashfn(struct inet_frag_queue *q) 97static unsigned int ip6_hashfn(struct inet_frag_queue *q)
98{ 98{
99 struct frag_queue *fq; 99 struct frag_queue *fq;
100 100
101 fq = container_of(q, struct frag_queue, q); 101 fq = container_of(q, struct frag_queue, q);
102 return inet6_hash_frag(fq->id, &fq->saddr, &fq->daddr, ip6_frags.rnd); 102 return inet6_hash_frag(fq->id, &fq->saddr, &fq->daddr);
103} 103}
104 104
105bool ip6_frag_match(struct inet_frag_queue *q, void *a) 105bool ip6_frag_match(struct inet_frag_queue *q, void *a)
@@ -193,7 +193,7 @@ fq_find(struct net *net, __be32 id, const struct in6_addr *src,
193 arg.ecn = ecn; 193 arg.ecn = ecn;
194 194
195 read_lock(&ip6_frags.lock); 195 read_lock(&ip6_frags.lock);
196 hash = inet6_hash_frag(id, src, dst, ip6_frags.rnd); 196 hash = inet6_hash_frag(id, src, dst);
197 197
198 q = inet_frag_find(&net->ipv6.frags, &ip6_frags, &arg, hash); 198 q = inet_frag_find(&net->ipv6.frags, &ip6_frags, &arg, hash);
199 if (IS_ERR_OR_NULL(q)) { 199 if (IS_ERR_OR_NULL(q)) {