diff options
Diffstat (limited to 'net/ipv6/inet6_hashtables.c')
-rw-r--r-- | net/ipv6/inet6_hashtables.c | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c index e61116949bee..30b16da739c2 100644 --- a/net/ipv6/inet6_hashtables.c +++ b/net/ipv6/inet6_hashtables.c | |||
@@ -115,7 +115,7 @@ struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo, | |||
115 | sk_for_each(sk, node, &hashinfo->listening_hash[inet_lhashfn(hnum)]) { | 115 | sk_for_each(sk, node, &hashinfo->listening_hash[inet_lhashfn(hnum)]) { |
116 | if (inet_sk(sk)->num == hnum && sk->sk_family == PF_INET6) { | 116 | if (inet_sk(sk)->num == hnum && sk->sk_family == PF_INET6) { |
117 | const struct ipv6_pinfo *np = inet6_sk(sk); | 117 | const struct ipv6_pinfo *np = inet6_sk(sk); |
118 | 118 | ||
119 | score = 1; | 119 | score = 1; |
120 | if (!ipv6_addr_any(&np->rcv_saddr)) { | 120 | if (!ipv6_addr_any(&np->rcv_saddr)) { |
121 | if (!ipv6_addr_equal(&np->rcv_saddr, daddr)) | 121 | if (!ipv6_addr_equal(&np->rcv_saddr, daddr)) |
@@ -249,81 +249,81 @@ int inet6_hash_connect(struct inet_timewait_death_row *death_row, | |||
249 | { | 249 | { |
250 | struct inet_hashinfo *hinfo = death_row->hashinfo; | 250 | struct inet_hashinfo *hinfo = death_row->hashinfo; |
251 | const unsigned short snum = inet_sk(sk)->num; | 251 | const unsigned short snum = inet_sk(sk)->num; |
252 | struct inet_bind_hashbucket *head; | 252 | struct inet_bind_hashbucket *head; |
253 | struct inet_bind_bucket *tb; | 253 | struct inet_bind_bucket *tb; |
254 | int ret; | 254 | int ret; |
255 | 255 | ||
256 | if (snum == 0) { | 256 | if (snum == 0) { |
257 | const int low = sysctl_local_port_range[0]; | 257 | const int low = sysctl_local_port_range[0]; |
258 | const int high = sysctl_local_port_range[1]; | 258 | const int high = sysctl_local_port_range[1]; |
259 | const int range = high - low; | 259 | const int range = high - low; |
260 | int i, port; | 260 | int i, port; |
261 | static u32 hint; | 261 | static u32 hint; |
262 | const u32 offset = hint + inet6_sk_port_offset(sk); | 262 | const u32 offset = hint + inet6_sk_port_offset(sk); |
263 | struct hlist_node *node; | 263 | struct hlist_node *node; |
264 | struct inet_timewait_sock *tw = NULL; | 264 | struct inet_timewait_sock *tw = NULL; |
265 | 265 | ||
266 | local_bh_disable(); | 266 | local_bh_disable(); |
267 | for (i = 1; i <= range; i++) { | 267 | for (i = 1; i <= range; i++) { |
268 | port = low + (i + offset) % range; | 268 | port = low + (i + offset) % range; |
269 | head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; | 269 | head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; |
270 | spin_lock(&head->lock); | 270 | spin_lock(&head->lock); |
271 | 271 | ||
272 | /* Does not bother with rcv_saddr checks, | 272 | /* Does not bother with rcv_saddr checks, |
273 | * because the established check is already | 273 | * because the established check is already |
274 | * unique enough. | 274 | * unique enough. |
275 | */ | 275 | */ |
276 | inet_bind_bucket_for_each(tb, node, &head->chain) { | 276 | inet_bind_bucket_for_each(tb, node, &head->chain) { |
277 | if (tb->port == port) { | 277 | if (tb->port == port) { |
278 | BUG_TRAP(!hlist_empty(&tb->owners)); | 278 | BUG_TRAP(!hlist_empty(&tb->owners)); |
279 | if (tb->fastreuse >= 0) | 279 | if (tb->fastreuse >= 0) |
280 | goto next_port; | 280 | goto next_port; |
281 | if (!__inet6_check_established(death_row, | 281 | if (!__inet6_check_established(death_row, |
282 | sk, port, | 282 | sk, port, |
283 | &tw)) | 283 | &tw)) |
284 | goto ok; | 284 | goto ok; |
285 | goto next_port; | 285 | goto next_port; |
286 | } | 286 | } |
287 | } | 287 | } |
288 | 288 | ||
289 | tb = inet_bind_bucket_create(hinfo->bind_bucket_cachep, | 289 | tb = inet_bind_bucket_create(hinfo->bind_bucket_cachep, |
290 | head, port); | 290 | head, port); |
291 | if (!tb) { | 291 | if (!tb) { |
292 | spin_unlock(&head->lock); | 292 | spin_unlock(&head->lock); |
293 | break; | 293 | break; |
294 | } | 294 | } |
295 | tb->fastreuse = -1; | 295 | tb->fastreuse = -1; |
296 | goto ok; | 296 | goto ok; |
297 | 297 | ||
298 | next_port: | 298 | next_port: |
299 | spin_unlock(&head->lock); | 299 | spin_unlock(&head->lock); |
300 | } | 300 | } |
301 | local_bh_enable(); | 301 | local_bh_enable(); |
302 | 302 | ||
303 | return -EADDRNOTAVAIL; | 303 | return -EADDRNOTAVAIL; |
304 | 304 | ||
305 | ok: | 305 | ok: |
306 | hint += i; | 306 | hint += i; |
307 | 307 | ||
308 | /* Head lock still held and bh's disabled */ | 308 | /* Head lock still held and bh's disabled */ |
309 | inet_bind_hash(sk, tb, port); | 309 | inet_bind_hash(sk, tb, port); |
310 | if (sk_unhashed(sk)) { | 310 | if (sk_unhashed(sk)) { |
311 | inet_sk(sk)->sport = htons(port); | 311 | inet_sk(sk)->sport = htons(port); |
312 | __inet6_hash(hinfo, sk); | 312 | __inet6_hash(hinfo, sk); |
313 | } | 313 | } |
314 | spin_unlock(&head->lock); | 314 | spin_unlock(&head->lock); |
315 | 315 | ||
316 | if (tw) { | 316 | if (tw) { |
317 | inet_twsk_deschedule(tw, death_row); | 317 | inet_twsk_deschedule(tw, death_row); |
318 | inet_twsk_put(tw); | 318 | inet_twsk_put(tw); |
319 | } | 319 | } |
320 | 320 | ||
321 | ret = 0; | 321 | ret = 0; |
322 | goto out; | 322 | goto out; |
323 | } | 323 | } |
324 | 324 | ||
325 | head = &hinfo->bhash[inet_bhashfn(snum, hinfo->bhash_size)]; | 325 | head = &hinfo->bhash[inet_bhashfn(snum, hinfo->bhash_size)]; |
326 | tb = inet_csk(sk)->icsk_bind_hash; | 326 | tb = inet_csk(sk)->icsk_bind_hash; |
327 | spin_lock_bh(&head->lock); | 327 | spin_lock_bh(&head->lock); |
328 | 328 | ||
329 | if (sk_head(&tb->owners) == sk && sk->sk_bind_node.next == NULL) { | 329 | if (sk_head(&tb->owners) == sk && sk->sk_bind_node.next == NULL) { |