aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-06-16 20:13:27 -0400
committerDavid S. Miller <davem@davemloft.net>2008-06-16 20:13:27 -0400
commit9f26b3add3783c0af869ea2207871da5dafefffa (patch)
treeadadfc84d2daf5133c0c536d87242df049daf53e
parent2086a65078bd24682bdcf413d9c91d81988b8359 (diff)
inet: add struct net argument to inet_ehashfn
Although this hash takes addresses into account, the ehash chains can also be too long when, for instance, communications via lo occur. So, prepare the inet_hashfn 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_sock.h6
-rw-r--r--net/ipv4/inet_hashtables.c6
2 files changed, 7 insertions, 5 deletions
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index 9fabe5b38912..85bb420c5d86 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -171,7 +171,8 @@ extern int inet_sk_rebuild_header(struct sock *sk);
171extern u32 inet_ehash_secret; 171extern u32 inet_ehash_secret;
172extern void build_ehash_secret(void); 172extern void build_ehash_secret(void);
173 173
174static inline unsigned int inet_ehashfn(const __be32 laddr, const __u16 lport, 174static inline unsigned int inet_ehashfn(struct net *net,
175 const __be32 laddr, const __u16 lport,
175 const __be32 faddr, const __be16 fport) 176 const __be32 faddr, const __be16 fport)
176{ 177{
177 return jhash_3words((__force __u32) laddr, 178 return jhash_3words((__force __u32) laddr,
@@ -187,8 +188,9 @@ static inline int inet_sk_ehashfn(const struct sock *sk)
187 const __u16 lport = inet->num; 188 const __u16 lport = inet->num;
188 const __be32 faddr = inet->daddr; 189 const __be32 faddr = inet->daddr;
189 const __be16 fport = inet->dport; 190 const __be16 fport = inet->dport;
191 struct net *net = sock_net(sk);
190 192
191 return inet_ehashfn(laddr, lport, faddr, fport); 193 return inet_ehashfn(net, laddr, lport, faddr, fport);
192} 194}
193 195
194 196
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 4f597b3175e7..eca5899729e3 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -227,7 +227,7 @@ struct sock * __inet_lookup_established(struct net *net,
227 /* Optimize here for direct hit, only listening connections can 227 /* Optimize here for direct hit, only listening connections can
228 * have wildcards anyways. 228 * have wildcards anyways.
229 */ 229 */
230 unsigned int hash = inet_ehashfn(daddr, hnum, saddr, sport); 230 unsigned int hash = inet_ehashfn(net, daddr, hnum, saddr, sport);
231 struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash); 231 struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash);
232 rwlock_t *lock = inet_ehash_lockp(hashinfo, hash); 232 rwlock_t *lock = inet_ehash_lockp(hashinfo, hash);
233 233
@@ -267,13 +267,13 @@ static int __inet_check_established(struct inet_timewait_death_row *death_row,
267 int dif = sk->sk_bound_dev_if; 267 int dif = sk->sk_bound_dev_if;
268 INET_ADDR_COOKIE(acookie, saddr, daddr) 268 INET_ADDR_COOKIE(acookie, saddr, daddr)
269 const __portpair ports = INET_COMBINED_PORTS(inet->dport, lport); 269 const __portpair ports = INET_COMBINED_PORTS(inet->dport, lport);
270 unsigned int hash = inet_ehashfn(daddr, lport, saddr, inet->dport); 270 struct net *net = sock_net(sk);
271 unsigned int hash = inet_ehashfn(net, daddr, lport, saddr, inet->dport);
271 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash); 272 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash);
272 rwlock_t *lock = inet_ehash_lockp(hinfo, hash); 273 rwlock_t *lock = inet_ehash_lockp(hinfo, hash);
273 struct sock *sk2; 274 struct sock *sk2;
274 const struct hlist_node *node; 275 const struct hlist_node *node;
275 struct inet_timewait_sock *tw; 276 struct inet_timewait_sock *tw;
276 struct net *net = sock_net(sk);
277 277
278 prefetch(head->chain.first); 278 prefetch(head->chain.first);
279 write_lock(lock); 279 write_lock(lock);