diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2008-01-31 08:07:21 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-31 22:28:20 -0500 |
commit | d86e0dac2ce412715181f792aa0749fe3effff11 (patch) | |
tree | bc9197a7316c7d7641112d5f5975d8b91afdbd08 /net/ipv6/inet6_hashtables.c | |
parent | c67499c0e772064b37ad75eb69b28fc218752636 (diff) |
[NETNS]: Tcp-v6 sockets per-net lookup.
Add a net argument to inet6_lookup and propagate it further.
Actually, this is tcp-v6 implementation of what was done for
tcp-v4 sockets in a previous patch.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/inet6_hashtables.c')
-rw-r--r-- | net/ipv6/inet6_hashtables.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c index ece6d0ee2da5..d325a9958909 100644 --- a/net/ipv6/inet6_hashtables.c +++ b/net/ipv6/inet6_hashtables.c | |||
@@ -54,7 +54,8 @@ EXPORT_SYMBOL(__inet6_hash); | |||
54 | * | 54 | * |
55 | * The sockhash lock must be held as a reader here. | 55 | * The sockhash lock must be held as a reader here. |
56 | */ | 56 | */ |
57 | struct sock *__inet6_lookup_established(struct inet_hashinfo *hashinfo, | 57 | struct sock *__inet6_lookup_established(struct net *net, |
58 | struct inet_hashinfo *hashinfo, | ||
58 | const struct in6_addr *saddr, | 59 | const struct in6_addr *saddr, |
59 | const __be16 sport, | 60 | const __be16 sport, |
60 | const struct in6_addr *daddr, | 61 | const struct in6_addr *daddr, |
@@ -75,12 +76,12 @@ struct sock *__inet6_lookup_established(struct inet_hashinfo *hashinfo, | |||
75 | read_lock(lock); | 76 | read_lock(lock); |
76 | sk_for_each(sk, node, &head->chain) { | 77 | sk_for_each(sk, node, &head->chain) { |
77 | /* For IPV6 do the cheaper port and family tests first. */ | 78 | /* For IPV6 do the cheaper port and family tests first. */ |
78 | if (INET6_MATCH(sk, hash, saddr, daddr, ports, dif)) | 79 | if (INET6_MATCH(sk, net, hash, saddr, daddr, ports, dif)) |
79 | goto hit; /* You sunk my battleship! */ | 80 | goto hit; /* You sunk my battleship! */ |
80 | } | 81 | } |
81 | /* Must check for a TIME_WAIT'er before going to listener hash. */ | 82 | /* Must check for a TIME_WAIT'er before going to listener hash. */ |
82 | sk_for_each(sk, node, &head->twchain) { | 83 | sk_for_each(sk, node, &head->twchain) { |
83 | if (INET6_TW_MATCH(sk, hash, saddr, daddr, ports, dif)) | 84 | if (INET6_TW_MATCH(sk, net, hash, saddr, daddr, ports, dif)) |
84 | goto hit; | 85 | goto hit; |
85 | } | 86 | } |
86 | read_unlock(lock); | 87 | read_unlock(lock); |
@@ -93,9 +94,9 @@ hit: | |||
93 | } | 94 | } |
94 | EXPORT_SYMBOL(__inet6_lookup_established); | 95 | EXPORT_SYMBOL(__inet6_lookup_established); |
95 | 96 | ||
96 | struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo, | 97 | struct sock *inet6_lookup_listener(struct net *net, |
97 | const struct in6_addr *daddr, | 98 | struct inet_hashinfo *hashinfo, const struct in6_addr *daddr, |
98 | const unsigned short hnum, const int dif) | 99 | const unsigned short hnum, const int dif) |
99 | { | 100 | { |
100 | struct sock *sk; | 101 | struct sock *sk; |
101 | const struct hlist_node *node; | 102 | const struct hlist_node *node; |
@@ -104,7 +105,8 @@ struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo, | |||
104 | 105 | ||
105 | read_lock(&hashinfo->lhash_lock); | 106 | read_lock(&hashinfo->lhash_lock); |
106 | sk_for_each(sk, node, &hashinfo->listening_hash[inet_lhashfn(hnum)]) { | 107 | sk_for_each(sk, node, &hashinfo->listening_hash[inet_lhashfn(hnum)]) { |
107 | if (inet_sk(sk)->num == hnum && sk->sk_family == PF_INET6) { | 108 | if (sk->sk_net == net && inet_sk(sk)->num == hnum && |
109 | sk->sk_family == PF_INET6) { | ||
108 | const struct ipv6_pinfo *np = inet6_sk(sk); | 110 | const struct ipv6_pinfo *np = inet6_sk(sk); |
109 | 111 | ||
110 | score = 1; | 112 | score = 1; |
@@ -136,7 +138,7 @@ struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo, | |||
136 | 138 | ||
137 | EXPORT_SYMBOL_GPL(inet6_lookup_listener); | 139 | EXPORT_SYMBOL_GPL(inet6_lookup_listener); |
138 | 140 | ||
139 | struct sock *inet6_lookup(struct inet_hashinfo *hashinfo, | 141 | struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo, |
140 | const struct in6_addr *saddr, const __be16 sport, | 142 | const struct in6_addr *saddr, const __be16 sport, |
141 | const struct in6_addr *daddr, const __be16 dport, | 143 | const struct in6_addr *daddr, const __be16 dport, |
142 | const int dif) | 144 | const int dif) |
@@ -144,7 +146,7 @@ struct sock *inet6_lookup(struct inet_hashinfo *hashinfo, | |||
144 | struct sock *sk; | 146 | struct sock *sk; |
145 | 147 | ||
146 | local_bh_disable(); | 148 | local_bh_disable(); |
147 | sk = __inet6_lookup(hashinfo, saddr, sport, daddr, ntohs(dport), dif); | 149 | sk = __inet6_lookup(net, hashinfo, saddr, sport, daddr, ntohs(dport), dif); |
148 | local_bh_enable(); | 150 | local_bh_enable(); |
149 | 151 | ||
150 | return sk; | 152 | return sk; |
@@ -170,6 +172,7 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row, | |||
170 | struct sock *sk2; | 172 | struct sock *sk2; |
171 | const struct hlist_node *node; | 173 | const struct hlist_node *node; |
172 | struct inet_timewait_sock *tw; | 174 | struct inet_timewait_sock *tw; |
175 | struct net *net = sk->sk_net; | ||
173 | 176 | ||
174 | prefetch(head->chain.first); | 177 | prefetch(head->chain.first); |
175 | write_lock(lock); | 178 | write_lock(lock); |
@@ -178,7 +181,7 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row, | |||
178 | sk_for_each(sk2, node, &head->twchain) { | 181 | sk_for_each(sk2, node, &head->twchain) { |
179 | tw = inet_twsk(sk2); | 182 | tw = inet_twsk(sk2); |
180 | 183 | ||
181 | if (INET6_TW_MATCH(sk2, hash, saddr, daddr, ports, dif)) { | 184 | if (INET6_TW_MATCH(sk2, net, hash, saddr, daddr, ports, dif)) { |
182 | if (twsk_unique(sk, sk2, twp)) | 185 | if (twsk_unique(sk, sk2, twp)) |
183 | goto unique; | 186 | goto unique; |
184 | else | 187 | else |
@@ -189,7 +192,7 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row, | |||
189 | 192 | ||
190 | /* And established part... */ | 193 | /* And established part... */ |
191 | sk_for_each(sk2, node, &head->chain) { | 194 | sk_for_each(sk2, node, &head->chain) { |
192 | if (INET6_MATCH(sk2, hash, saddr, daddr, ports, dif)) | 195 | if (INET6_MATCH(sk2, net, hash, saddr, daddr, ports, dif)) |
193 | goto not_unique; | 196 | goto not_unique; |
194 | } | 197 | } |
195 | 198 | ||