aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-06-16 20:13:08 -0400
committerDavid S. Miller <davem@davemloft.net>2008-06-16 20:13:08 -0400
commit2086a65078bd24682bdcf413d9c91d81988b8359 (patch)
treeff1699db9c0cc50f0c2709b74808bc8ef46168a1
parent7f635ab71eef8da012320c0092b662d6af8c1e69 (diff)
inet: add struct net argument to inet_lhashfn
Listening-on-one-port sockets in many namespaces produce long chains in the listening_hash-es, so prepare the inet_lhashfn to take struct net into account. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/inet_hashtables.h4
-rw-r--r--net/ipv4/inet_hashtables.c2
-rw-r--r--net/ipv6/inet6_hashtables.c3
3 files changed, 5 insertions, 4 deletions
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index 61dd3317089c..26336cdcdc11 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -211,14 +211,14 @@ extern void inet_bind_hash(struct sock *sk, struct inet_bind_bucket *tb,
211 const unsigned short snum); 211 const unsigned short snum);
212 212
213/* These can have wildcards, don't try too hard. */ 213/* These can have wildcards, don't try too hard. */
214static inline int inet_lhashfn(const unsigned short num) 214static inline int inet_lhashfn(struct net *net, const unsigned short num)
215{ 215{
216 return num & (INET_LHTABLE_SIZE - 1); 216 return num & (INET_LHTABLE_SIZE - 1);
217} 217}
218 218
219static inline int inet_sk_listen_hashfn(const struct sock *sk) 219static inline int inet_sk_listen_hashfn(const struct sock *sk)
220{ 220{
221 return inet_lhashfn(inet_sk(sk)->num); 221 return inet_lhashfn(sock_net(sk), inet_sk(sk)->num);
222} 222}
223 223
224/* Caller must disable local BH processing. */ 224/* Caller must disable local BH processing. */
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index dc1b78de8990..4f597b3175e7 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -194,7 +194,7 @@ struct sock *__inet_lookup_listener(struct net *net,
194 const struct hlist_head *head; 194 const struct hlist_head *head;
195 195
196 read_lock(&hashinfo->lhash_lock); 196 read_lock(&hashinfo->lhash_lock);
197 head = &hashinfo->listening_hash[inet_lhashfn(hnum)]; 197 head = &hashinfo->listening_hash[inet_lhashfn(net, hnum)];
198 if (!hlist_empty(head)) { 198 if (!hlist_empty(head)) {
199 const struct inet_sock *inet = inet_sk((sk = __sk_head(head))); 199 const struct inet_sock *inet = inet_sk((sk = __sk_head(head)));
200 200
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index 580014aea4d6..b940156ca4f5 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -104,7 +104,8 @@ struct sock *inet6_lookup_listener(struct net *net,
104 int score, hiscore = 0; 104 int score, hiscore = 0;
105 105
106 read_lock(&hashinfo->lhash_lock); 106 read_lock(&hashinfo->lhash_lock);
107 sk_for_each(sk, node, &hashinfo->listening_hash[inet_lhashfn(hnum)]) { 107 sk_for_each(sk, node,
108 &hashinfo->listening_hash[inet_lhashfn(net, hnum)]) {
108 if (net_eq(sock_net(sk), net) && inet_sk(sk)->num == hnum && 109 if (net_eq(sock_net(sk), net) && inet_sk(sk)->num == hnum &&
109 sk->sk_family == PF_INET6) { 110 sk->sk_family == PF_INET6) {
110 const struct ipv6_pinfo *np = inet6_sk(sk); 111 const struct ipv6_pinfo *np = inet6_sk(sk);