diff options
Diffstat (limited to 'net/ipv4/inet_fragment.c')
-rw-r--r-- | net/ipv4/inet_fragment.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c index 4ed429bd5951..0546a0bc97ea 100644 --- a/net/ipv4/inet_fragment.c +++ b/net/ipv4/inet_fragment.c | |||
@@ -192,14 +192,21 @@ EXPORT_SYMBOL(inet_frag_evictor); | |||
192 | 192 | ||
193 | static struct inet_frag_queue *inet_frag_intern(struct netns_frags *nf, | 193 | static struct inet_frag_queue *inet_frag_intern(struct netns_frags *nf, |
194 | struct inet_frag_queue *qp_in, struct inet_frags *f, | 194 | struct inet_frag_queue *qp_in, struct inet_frags *f, |
195 | unsigned int hash, void *arg) | 195 | void *arg) |
196 | { | 196 | { |
197 | struct inet_frag_queue *qp; | 197 | struct inet_frag_queue *qp; |
198 | #ifdef CONFIG_SMP | 198 | #ifdef CONFIG_SMP |
199 | struct hlist_node *n; | 199 | struct hlist_node *n; |
200 | #endif | 200 | #endif |
201 | unsigned int hash; | ||
201 | 202 | ||
202 | write_lock(&f->lock); | 203 | write_lock(&f->lock); |
204 | /* | ||
205 | * While we stayed w/o the lock other CPU could update | ||
206 | * the rnd seed, so we need to re-calculate the hash | ||
207 | * chain. Fortunatelly the qp_in can be used to get one. | ||
208 | */ | ||
209 | hash = f->hashfn(qp_in); | ||
203 | #ifdef CONFIG_SMP | 210 | #ifdef CONFIG_SMP |
204 | /* With SMP race we have to recheck hash table, because | 211 | /* With SMP race we have to recheck hash table, because |
205 | * such entry could be created on other cpu, while we | 212 | * such entry could be created on other cpu, while we |
@@ -247,7 +254,7 @@ static struct inet_frag_queue *inet_frag_alloc(struct netns_frags *nf, | |||
247 | } | 254 | } |
248 | 255 | ||
249 | static struct inet_frag_queue *inet_frag_create(struct netns_frags *nf, | 256 | static struct inet_frag_queue *inet_frag_create(struct netns_frags *nf, |
250 | struct inet_frags *f, void *arg, unsigned int hash) | 257 | struct inet_frags *f, void *arg) |
251 | { | 258 | { |
252 | struct inet_frag_queue *q; | 259 | struct inet_frag_queue *q; |
253 | 260 | ||
@@ -255,7 +262,7 @@ static struct inet_frag_queue *inet_frag_create(struct netns_frags *nf, | |||
255 | if (q == NULL) | 262 | if (q == NULL) |
256 | return NULL; | 263 | return NULL; |
257 | 264 | ||
258 | return inet_frag_intern(nf, q, f, hash, arg); | 265 | return inet_frag_intern(nf, q, f, arg); |
259 | } | 266 | } |
260 | 267 | ||
261 | struct inet_frag_queue *inet_frag_find(struct netns_frags *nf, | 268 | struct inet_frag_queue *inet_frag_find(struct netns_frags *nf, |
@@ -264,7 +271,6 @@ struct inet_frag_queue *inet_frag_find(struct netns_frags *nf, | |||
264 | struct inet_frag_queue *q; | 271 | struct inet_frag_queue *q; |
265 | struct hlist_node *n; | 272 | struct hlist_node *n; |
266 | 273 | ||
267 | read_lock(&f->lock); | ||
268 | hlist_for_each_entry(q, n, &f->hash[hash], list) { | 274 | hlist_for_each_entry(q, n, &f->hash[hash], list) { |
269 | if (q->net == nf && f->match(q, key)) { | 275 | if (q->net == nf && f->match(q, key)) { |
270 | atomic_inc(&q->refcnt); | 276 | atomic_inc(&q->refcnt); |
@@ -274,6 +280,6 @@ struct inet_frag_queue *inet_frag_find(struct netns_frags *nf, | |||
274 | } | 280 | } |
275 | read_unlock(&f->lock); | 281 | read_unlock(&f->lock); |
276 | 282 | ||
277 | return inet_frag_create(nf, f, key, hash); | 283 | return inet_frag_create(nf, f, key); |
278 | } | 284 | } |
279 | EXPORT_SYMBOL(inet_frag_find); | 285 | EXPORT_SYMBOL(inet_frag_find); |