aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/inet_hashtables.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/inet_hashtables.h')
-rw-r--r--include/net/inet_hashtables.h55
1 files changed, 34 insertions, 21 deletions
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index 761bdc01425d..c23c4ed30724 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -74,6 +74,7 @@ struct inet_ehash_bucket {
74 * ports are created in O(1) time? I thought so. ;-) -DaveM 74 * ports are created in O(1) time? I thought so. ;-) -DaveM
75 */ 75 */
76struct inet_bind_bucket { 76struct inet_bind_bucket {
77 struct net *ib_net;
77 unsigned short port; 78 unsigned short port;
78 signed short fastreuse; 79 signed short fastreuse;
79 struct hlist_node node; 80 struct hlist_node node;
@@ -194,6 +195,7 @@ static inline void inet_ehash_locks_free(struct inet_hashinfo *hashinfo)
194 195
195extern struct inet_bind_bucket * 196extern struct inet_bind_bucket *
196 inet_bind_bucket_create(struct kmem_cache *cachep, 197 inet_bind_bucket_create(struct kmem_cache *cachep,
198 struct net *net,
197 struct inet_bind_hashbucket *head, 199 struct inet_bind_hashbucket *head,
198 const unsigned short snum); 200 const unsigned short snum);
199extern void inet_bind_bucket_destroy(struct kmem_cache *cachep, 201extern void inet_bind_bucket_destroy(struct kmem_cache *cachep,
@@ -300,15 +302,17 @@ out:
300 wake_up(&hashinfo->lhash_wait); 302 wake_up(&hashinfo->lhash_wait);
301} 303}
302 304
303extern struct sock *__inet_lookup_listener(struct inet_hashinfo *hashinfo, 305extern struct sock *__inet_lookup_listener(struct net *net,
306 struct inet_hashinfo *hashinfo,
304 const __be32 daddr, 307 const __be32 daddr,
305 const unsigned short hnum, 308 const unsigned short hnum,
306 const int dif); 309 const int dif);
307 310
308static inline struct sock *inet_lookup_listener(struct inet_hashinfo *hashinfo, 311static inline struct sock *inet_lookup_listener(struct net *net,
309 __be32 daddr, __be16 dport, int dif) 312 struct inet_hashinfo *hashinfo,
313 __be32 daddr, __be16 dport, int dif)
310{ 314{
311 return __inet_lookup_listener(hashinfo, daddr, ntohs(dport), dif); 315 return __inet_lookup_listener(net, hashinfo, daddr, ntohs(dport), dif);
312} 316}
313 317
314/* Socket demux engine toys. */ 318/* Socket demux engine toys. */
@@ -342,26 +346,26 @@ typedef __u64 __bitwise __addrpair;
342 (((__force __u64)(__be32)(__daddr)) << 32) | \ 346 (((__force __u64)(__be32)(__daddr)) << 32) | \
343 ((__force __u64)(__be32)(__saddr))); 347 ((__force __u64)(__be32)(__saddr)));
344#endif /* __BIG_ENDIAN */ 348#endif /* __BIG_ENDIAN */
345#define INET_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ 349#define INET_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)\
346 (((__sk)->sk_hash == (__hash)) && \ 350 (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \
347 ((*((__addrpair *)&(inet_sk(__sk)->daddr))) == (__cookie)) && \ 351 ((*((__addrpair *)&(inet_sk(__sk)->daddr))) == (__cookie)) && \
348 ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ 352 ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \
349 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) 353 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
350#define INET_TW_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ 354#define INET_TW_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)\
351 (((__sk)->sk_hash == (__hash)) && \ 355 (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \
352 ((*((__addrpair *)&(inet_twsk(__sk)->tw_daddr))) == (__cookie)) && \ 356 ((*((__addrpair *)&(inet_twsk(__sk)->tw_daddr))) == (__cookie)) && \
353 ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ 357 ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \
354 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) 358 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
355#else /* 32-bit arch */ 359#else /* 32-bit arch */
356#define INET_ADDR_COOKIE(__name, __saddr, __daddr) 360#define INET_ADDR_COOKIE(__name, __saddr, __daddr)
357#define INET_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif) \ 361#define INET_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif) \
358 (((__sk)->sk_hash == (__hash)) && \ 362 (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \
359 (inet_sk(__sk)->daddr == (__saddr)) && \ 363 (inet_sk(__sk)->daddr == (__saddr)) && \
360 (inet_sk(__sk)->rcv_saddr == (__daddr)) && \ 364 (inet_sk(__sk)->rcv_saddr == (__daddr)) && \
361 ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ 365 ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \
362 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) 366 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
363#define INET_TW_MATCH(__sk, __hash,__cookie, __saddr, __daddr, __ports, __dif) \ 367#define INET_TW_MATCH(__sk, __net, __hash,__cookie, __saddr, __daddr, __ports, __dif) \
364 (((__sk)->sk_hash == (__hash)) && \ 368 (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \
365 (inet_twsk(__sk)->tw_daddr == (__saddr)) && \ 369 (inet_twsk(__sk)->tw_daddr == (__saddr)) && \
366 (inet_twsk(__sk)->tw_rcv_saddr == (__daddr)) && \ 370 (inet_twsk(__sk)->tw_rcv_saddr == (__daddr)) && \
367 ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ 371 ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \
@@ -374,32 +378,36 @@ typedef __u64 __bitwise __addrpair;
374 * 378 *
375 * Local BH must be disabled here. 379 * Local BH must be disabled here.
376 */ 380 */
377extern struct sock * __inet_lookup_established(struct inet_hashinfo *hashinfo, 381extern struct sock * __inet_lookup_established(struct net *net,
382 struct inet_hashinfo *hashinfo,
378 const __be32 saddr, const __be16 sport, 383 const __be32 saddr, const __be16 sport,
379 const __be32 daddr, const u16 hnum, const int dif); 384 const __be32 daddr, const u16 hnum, const int dif);
380 385
381static inline struct sock * 386static inline struct sock *
382 inet_lookup_established(struct inet_hashinfo *hashinfo, 387 inet_lookup_established(struct net *net, struct inet_hashinfo *hashinfo,
383 const __be32 saddr, const __be16 sport, 388 const __be32 saddr, const __be16 sport,
384 const __be32 daddr, const __be16 dport, 389 const __be32 daddr, const __be16 dport,
385 const int dif) 390 const int dif)
386{ 391{
387 return __inet_lookup_established(hashinfo, saddr, sport, daddr, 392 return __inet_lookup_established(net, hashinfo, saddr, sport, daddr,
388 ntohs(dport), dif); 393 ntohs(dport), dif);
389} 394}
390 395
391static inline struct sock *__inet_lookup(struct inet_hashinfo *hashinfo, 396static inline struct sock *__inet_lookup(struct net *net,
397 struct inet_hashinfo *hashinfo,
392 const __be32 saddr, const __be16 sport, 398 const __be32 saddr, const __be16 sport,
393 const __be32 daddr, const __be16 dport, 399 const __be32 daddr, const __be16 dport,
394 const int dif) 400 const int dif)
395{ 401{
396 u16 hnum = ntohs(dport); 402 u16 hnum = ntohs(dport);
397 struct sock *sk = __inet_lookup_established(hashinfo, saddr, sport, daddr, 403 struct sock *sk = __inet_lookup_established(net, hashinfo,
398 hnum, dif); 404 saddr, sport, daddr, hnum, dif);
399 return sk ? : __inet_lookup_listener(hashinfo, daddr, hnum, dif); 405
406 return sk ? : __inet_lookup_listener(net, hashinfo, daddr, hnum, dif);
400} 407}
401 408
402static inline struct sock *inet_lookup(struct inet_hashinfo *hashinfo, 409static inline struct sock *inet_lookup(struct net *net,
410 struct inet_hashinfo *hashinfo,
403 const __be32 saddr, const __be16 sport, 411 const __be32 saddr, const __be16 sport,
404 const __be32 daddr, const __be16 dport, 412 const __be32 daddr, const __be16 dport,
405 const int dif) 413 const int dif)
@@ -407,12 +415,17 @@ static inline struct sock *inet_lookup(struct inet_hashinfo *hashinfo,
407 struct sock *sk; 415 struct sock *sk;
408 416
409 local_bh_disable(); 417 local_bh_disable();
410 sk = __inet_lookup(hashinfo, saddr, sport, daddr, dport, dif); 418 sk = __inet_lookup(net, hashinfo, saddr, sport, daddr, dport, dif);
411 local_bh_enable(); 419 local_bh_enable();
412 420
413 return sk; 421 return sk;
414} 422}
415 423
424extern int __inet_hash_connect(struct inet_timewait_death_row *death_row,
425 struct sock *sk,
426 int (*check_established)(struct inet_timewait_death_row *,
427 struct sock *, __u16, struct inet_timewait_sock **),
428 void (*hash)(struct inet_hashinfo *, struct sock *));
416extern int inet_hash_connect(struct inet_timewait_death_row *death_row, 429extern int inet_hash_connect(struct inet_timewait_death_row *death_row,
417 struct sock *sk); 430 struct sock *sk);
418#endif /* _INET_HASHTABLES_H */ 431#endif /* _INET_HASHTABLES_H */