diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2008-01-31 08:06:40 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-31 22:28:19 -0500 |
commit | c67499c0e772064b37ad75eb69b28fc218752636 (patch) | |
tree | 7d2873308f16080c0c3801d6024881360dd8e196 /include | |
parent | 941b1d22cc035ad58b3d9b44a1c74efac2d7e499 (diff) |
[NETNS]: Tcp-v4 sockets per-net lookup.
Add a net argument to inet_lookup and propagate it further
into lookup calls. Plus tune the __inet_check_established.
The dccp and inet_diag, which use that lookup functions
pass the init_net into them.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/net/inet_hashtables.h | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index 55532b9bb59a..c23c4ed30724 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h | |||
@@ -302,15 +302,17 @@ out: | |||
302 | wake_up(&hashinfo->lhash_wait); | 302 | wake_up(&hashinfo->lhash_wait); |
303 | } | 303 | } |
304 | 304 | ||
305 | extern struct sock *__inet_lookup_listener(struct inet_hashinfo *hashinfo, | 305 | extern struct sock *__inet_lookup_listener(struct net *net, |
306 | struct inet_hashinfo *hashinfo, | ||
306 | const __be32 daddr, | 307 | const __be32 daddr, |
307 | const unsigned short hnum, | 308 | const unsigned short hnum, |
308 | const int dif); | 309 | const int dif); |
309 | 310 | ||
310 | static inline struct sock *inet_lookup_listener(struct inet_hashinfo *hashinfo, | 311 | static inline struct sock *inet_lookup_listener(struct net *net, |
311 | __be32 daddr, __be16 dport, int dif) | 312 | struct inet_hashinfo *hashinfo, |
313 | __be32 daddr, __be16 dport, int dif) | ||
312 | { | 314 | { |
313 | return __inet_lookup_listener(hashinfo, daddr, ntohs(dport), dif); | 315 | return __inet_lookup_listener(net, hashinfo, daddr, ntohs(dport), dif); |
314 | } | 316 | } |
315 | 317 | ||
316 | /* Socket demux engine toys. */ | 318 | /* Socket demux engine toys. */ |
@@ -344,26 +346,26 @@ typedef __u64 __bitwise __addrpair; | |||
344 | (((__force __u64)(__be32)(__daddr)) << 32) | \ | 346 | (((__force __u64)(__be32)(__daddr)) << 32) | \ |
345 | ((__force __u64)(__be32)(__saddr))); | 347 | ((__force __u64)(__be32)(__saddr))); |
346 | #endif /* __BIG_ENDIAN */ | 348 | #endif /* __BIG_ENDIAN */ |
347 | #define INET_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ | 349 | #define INET_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ |
348 | (((__sk)->sk_hash == (__hash)) && \ | 350 | (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ |
349 | ((*((__addrpair *)&(inet_sk(__sk)->daddr))) == (__cookie)) && \ | 351 | ((*((__addrpair *)&(inet_sk(__sk)->daddr))) == (__cookie)) && \ |
350 | ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ | 352 | ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ |
351 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) | 353 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) |
352 | #define INET_TW_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ | 354 | #define INET_TW_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ |
353 | (((__sk)->sk_hash == (__hash)) && \ | 355 | (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ |
354 | ((*((__addrpair *)&(inet_twsk(__sk)->tw_daddr))) == (__cookie)) && \ | 356 | ((*((__addrpair *)&(inet_twsk(__sk)->tw_daddr))) == (__cookie)) && \ |
355 | ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ | 357 | ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ |
356 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) | 358 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) |
357 | #else /* 32-bit arch */ | 359 | #else /* 32-bit arch */ |
358 | #define INET_ADDR_COOKIE(__name, __saddr, __daddr) | 360 | #define INET_ADDR_COOKIE(__name, __saddr, __daddr) |
359 | #define INET_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif) \ | 361 | #define INET_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif) \ |
360 | (((__sk)->sk_hash == (__hash)) && \ | 362 | (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ |
361 | (inet_sk(__sk)->daddr == (__saddr)) && \ | 363 | (inet_sk(__sk)->daddr == (__saddr)) && \ |
362 | (inet_sk(__sk)->rcv_saddr == (__daddr)) && \ | 364 | (inet_sk(__sk)->rcv_saddr == (__daddr)) && \ |
363 | ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ | 365 | ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ |
364 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) | 366 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) |
365 | #define INET_TW_MATCH(__sk, __hash,__cookie, __saddr, __daddr, __ports, __dif) \ | 367 | #define INET_TW_MATCH(__sk, __net, __hash,__cookie, __saddr, __daddr, __ports, __dif) \ |
366 | (((__sk)->sk_hash == (__hash)) && \ | 368 | (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ |
367 | (inet_twsk(__sk)->tw_daddr == (__saddr)) && \ | 369 | (inet_twsk(__sk)->tw_daddr == (__saddr)) && \ |
368 | (inet_twsk(__sk)->tw_rcv_saddr == (__daddr)) && \ | 370 | (inet_twsk(__sk)->tw_rcv_saddr == (__daddr)) && \ |
369 | ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ | 371 | ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ |
@@ -376,32 +378,36 @@ typedef __u64 __bitwise __addrpair; | |||
376 | * | 378 | * |
377 | * Local BH must be disabled here. | 379 | * Local BH must be disabled here. |
378 | */ | 380 | */ |
379 | extern struct sock * __inet_lookup_established(struct inet_hashinfo *hashinfo, | 381 | extern struct sock * __inet_lookup_established(struct net *net, |
382 | struct inet_hashinfo *hashinfo, | ||
380 | const __be32 saddr, const __be16 sport, | 383 | const __be32 saddr, const __be16 sport, |
381 | const __be32 daddr, const u16 hnum, const int dif); | 384 | const __be32 daddr, const u16 hnum, const int dif); |
382 | 385 | ||
383 | static inline struct sock * | 386 | static inline struct sock * |
384 | inet_lookup_established(struct inet_hashinfo *hashinfo, | 387 | inet_lookup_established(struct net *net, struct inet_hashinfo *hashinfo, |
385 | const __be32 saddr, const __be16 sport, | 388 | const __be32 saddr, const __be16 sport, |
386 | const __be32 daddr, const __be16 dport, | 389 | const __be32 daddr, const __be16 dport, |
387 | const int dif) | 390 | const int dif) |
388 | { | 391 | { |
389 | return __inet_lookup_established(hashinfo, saddr, sport, daddr, | 392 | return __inet_lookup_established(net, hashinfo, saddr, sport, daddr, |
390 | ntohs(dport), dif); | 393 | ntohs(dport), dif); |
391 | } | 394 | } |
392 | 395 | ||
393 | static inline struct sock *__inet_lookup(struct inet_hashinfo *hashinfo, | 396 | static inline struct sock *__inet_lookup(struct net *net, |
397 | struct inet_hashinfo *hashinfo, | ||
394 | const __be32 saddr, const __be16 sport, | 398 | const __be32 saddr, const __be16 sport, |
395 | const __be32 daddr, const __be16 dport, | 399 | const __be32 daddr, const __be16 dport, |
396 | const int dif) | 400 | const int dif) |
397 | { | 401 | { |
398 | u16 hnum = ntohs(dport); | 402 | u16 hnum = ntohs(dport); |
399 | struct sock *sk = __inet_lookup_established(hashinfo, saddr, sport, daddr, | 403 | struct sock *sk = __inet_lookup_established(net, hashinfo, |
400 | hnum, dif); | 404 | saddr, sport, daddr, hnum, dif); |
401 | return sk ? : __inet_lookup_listener(hashinfo, daddr, hnum, dif); | 405 | |
406 | return sk ? : __inet_lookup_listener(net, hashinfo, daddr, hnum, dif); | ||
402 | } | 407 | } |
403 | 408 | ||
404 | static inline struct sock *inet_lookup(struct inet_hashinfo *hashinfo, | 409 | static inline struct sock *inet_lookup(struct net *net, |
410 | struct inet_hashinfo *hashinfo, | ||
405 | const __be32 saddr, const __be16 sport, | 411 | const __be32 saddr, const __be16 sport, |
406 | const __be32 daddr, const __be16 dport, | 412 | const __be32 daddr, const __be16 dport, |
407 | const int dif) | 413 | const int dif) |
@@ -409,7 +415,7 @@ static inline struct sock *inet_lookup(struct inet_hashinfo *hashinfo, | |||
409 | struct sock *sk; | 415 | struct sock *sk; |
410 | 416 | ||
411 | local_bh_disable(); | 417 | local_bh_disable(); |
412 | sk = __inet_lookup(hashinfo, saddr, sport, daddr, dport, dif); | 418 | sk = __inet_lookup(net, hashinfo, saddr, sport, daddr, dport, dif); |
413 | local_bh_enable(); | 419 | local_bh_enable(); |
414 | 420 | ||
415 | return sk; | 421 | return sk; |