aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-01-31 08:03:27 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-31 22:28:17 -0500
commit535174efbe0f0454f0595c31b823498c197eeb4f (patch)
tree7fc438f82e73f117882e31b6f7025e295e399b09
parent22e0e62cd09dcf56fe1a7be66698b6e130e4314c (diff)
[IPV6]: Introduce the INET6_TW_MATCH macro.
We have INET_MATCH, INET_TW_MATCH and INET6_MATCH to test sockets and twbuckets for matching, but ipv6 twbuckets are tested manually. Here's the INET6_TW_MATCH to help with it. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/ipv6.h8
-rw-r--r--net/ipv6/inet6_hashtables.c21
2 files changed, 11 insertions, 18 deletions
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index 5d35a4cc3bff..c34786044a1b 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -465,6 +465,14 @@ static inline struct raw6_sock *raw6_sk(const struct sock *sk)
465 ipv6_addr_equal(&inet6_sk(__sk)->rcv_saddr, (__daddr)) && \ 465 ipv6_addr_equal(&inet6_sk(__sk)->rcv_saddr, (__daddr)) && \
466 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) 466 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
467 467
468#define INET6_TW_MATCH(__sk, __hash, __saddr, __daddr, __ports, __dif) \
469 (((__sk)->sk_hash == (__hash)) && \
470 (*((__portpair *)&(inet_twsk(__sk)->tw_dport)) == (__ports)) && \
471 ((__sk)->sk_family == PF_INET6) && \
472 (ipv6_addr_equal(&inet6_twsk(__sk)->tw_v6_daddr, (__saddr))) && \
473 (ipv6_addr_equal(&inet6_twsk(__sk)->tw_v6_rcv_saddr, (__daddr))) && \
474 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
475
468#endif /* __KERNEL__ */ 476#endif /* __KERNEL__ */
469 477
470#endif /* _IPV6_H */ 478#endif /* _IPV6_H */
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index a66a7d8e2811..06b01befc90e 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -80,17 +80,8 @@ struct sock *__inet6_lookup_established(struct inet_hashinfo *hashinfo,
80 } 80 }
81 /* Must check for a TIME_WAIT'er before going to listener hash. */ 81 /* Must check for a TIME_WAIT'er before going to listener hash. */
82 sk_for_each(sk, node, &head->twchain) { 82 sk_for_each(sk, node, &head->twchain) {
83 const struct inet_timewait_sock *tw = inet_twsk(sk); 83 if (INET6_TW_MATCH(sk, hash, saddr, daddr, ports, dif))
84 84 goto hit;
85 if(*((__portpair *)&(tw->tw_dport)) == ports &&
86 sk->sk_family == PF_INET6) {
87 const struct inet6_timewait_sock *tw6 = inet6_twsk(sk);
88
89 if (ipv6_addr_equal(&tw6->tw_v6_daddr, saddr) &&
90 ipv6_addr_equal(&tw6->tw_v6_rcv_saddr, daddr) &&
91 (!sk->sk_bound_dev_if || sk->sk_bound_dev_if == dif))
92 goto hit;
93 }
94 } 85 }
95 read_unlock(lock); 86 read_unlock(lock);
96 return NULL; 87 return NULL;
@@ -185,15 +176,9 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row,
185 176
186 /* Check TIME-WAIT sockets first. */ 177 /* Check TIME-WAIT sockets first. */
187 sk_for_each(sk2, node, &head->twchain) { 178 sk_for_each(sk2, node, &head->twchain) {
188 const struct inet6_timewait_sock *tw6 = inet6_twsk(sk2);
189
190 tw = inet_twsk(sk2); 179 tw = inet_twsk(sk2);
191 180
192 if(*((__portpair *)&(tw->tw_dport)) == ports && 181 if (INET6_TW_MATCH(sk2, hash, saddr, daddr, ports, dif)) {
193 sk2->sk_family == PF_INET6 &&
194 ipv6_addr_equal(&tw6->tw_v6_daddr, saddr) &&
195 ipv6_addr_equal(&tw6->tw_v6_rcv_saddr, daddr) &&
196 (!sk2->sk_bound_dev_if || sk2->sk_bound_dev_if == dif)) {
197 if (twsk_unique(sk, sk2, twp)) 182 if (twsk_unique(sk, sk2, twp))
198 goto unique; 183 goto unique;
199 else 184 else