From: Pavel Emelyanov <xemul@openvz.org>
To: David Miller <davem@davemloft.net>
Cc: Linux Netdev List <netdev@vger.kernel.org>
Subject: [PATCH net-next 6/8] Inet: add struct net argument to inet_ehashfn
Date: Mon, 16 Jun 2008 13:47:06 +0400 [thread overview]
Message-ID: <4856369A.2090905@openvz.org> (raw)
In-Reply-To: <485633E4.10900@openvz.org>
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>
---
include/net/inet_sock.h | 6 ++++--
net/ipv4/inet_hashtables.c | 6 +++---
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index a42cd63..ab8e19d 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);
extern u32 inet_ehash_secret;
extern void build_ehash_secret(void);
-static inline unsigned int inet_ehashfn(const __be32 laddr, const __u16 lport,
+static inline unsigned int inet_ehashfn(struct net *net,
+ const __be32 laddr, const __u16 lport,
const __be32 faddr, const __be16 fport)
{
return jhash_3words((__force __u32) laddr,
@@ -187,8 +188,9 @@ static inline int inet_sk_ehashfn(const struct sock *sk)
const __u16 lport = inet->num;
const __be32 faddr = inet->daddr;
const __be16 fport = inet->dport;
+ struct net *net = sock_net(sk);
- return inet_ehashfn(laddr, lport, faddr, fport);
+ return inet_ehashfn(net, laddr, lport, faddr, fport);
}
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 4f597b3..eca5899 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,
/* Optimize here for direct hit, only listening connections can
* have wildcards anyways.
*/
- unsigned int hash = inet_ehashfn(daddr, hnum, saddr, sport);
+ unsigned int hash = inet_ehashfn(net, daddr, hnum, saddr, sport);
struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash);
rwlock_t *lock = inet_ehash_lockp(hashinfo, hash);
@@ -267,13 +267,13 @@ static int __inet_check_established(struct inet_timewait_death_row *death_row,
int dif = sk->sk_bound_dev_if;
INET_ADDR_COOKIE(acookie, saddr, daddr)
const __portpair ports = INET_COMBINED_PORTS(inet->dport, lport);
- unsigned int hash = inet_ehashfn(daddr, lport, saddr, inet->dport);
+ struct net *net = sock_net(sk);
+ unsigned int hash = inet_ehashfn(net, daddr, lport, saddr, inet->dport);
struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash);
rwlock_t *lock = inet_ehash_lockp(hinfo, hash);
struct sock *sk2;
const struct hlist_node *node;
struct inet_timewait_sock *tw;
- struct net *net = sock_net(sk);
prefetch(head->chain.first);
write_lock(lock);
--
1.5.3.4
next prev parent reply other threads:[~2008-06-16 9:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-16 9:35 [PATCH net-next 0/8] netns: optimize tcp and udp hashtables wrt net namespaces Pavel Emelyanov
2008-06-16 9:38 ` [PATCH net-next 1/8] UDP: introduce a udp_hashfn function Pavel Emelyanov
2008-06-16 9:40 ` [PATCH net-next 2/8] UDP: provide a struct net pointer for __udp[46]_lib_mcast_deliver Pavel Emelyanov
2008-06-16 9:41 ` [PATCH net-next 3/8] UDP: add struct net argument to udp_hashfn Pavel Emelyanov
2008-06-16 9:43 ` [PATCH net-next 4/8] Inet: add struct net argument to inet_bhashfn Pavel Emelyanov
2008-06-16 9:44 ` [PATCH net-next 5/8] Inet: add struct net argument to inet_lhashfn Pavel Emelyanov
2008-06-16 9:47 ` Pavel Emelyanov [this message]
2008-06-16 9:48 ` [PATCH net-next 7/8] Inet6: add struct net argument to inet6_ehashfn Pavel Emelyanov
2008-06-16 9:51 ` [PATCH net-next 8/8] Netns: introduce the net_hash_mix "salt" for hashes Pavel Emelyanov
2008-06-17 0:14 ` [PATCH net-next 0/8] netns: optimize tcp and udp hashtables wrt net namespaces David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4856369A.2090905@openvz.org \
--to=xemul@openvz.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).