diff options
| author | Eric W. Biederman <ebiederm@xmission.com> | 2015-03-13 01:05:24 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2015-03-13 01:57:07 -0400 |
| commit | 3e5da62d0bcbfa86332f66cca0e3983e70557fac (patch) | |
| tree | 4f21e715d4ea768af72c15e8009c246d4a8d5772 | |
| parent | 6493517eaea9b052e081e557f7c8bb06cc6b1852 (diff) | |
tcp_metrics: Mix the network namespace into the hash function.
In preparation for using one hash table for all network namespaces
mix the network namespace into the hash value.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | net/ipv4/tcp_metrics.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c index 4206b14d956d..fbb42f44501e 100644 --- a/net/ipv4/tcp_metrics.c +++ b/net/ipv4/tcp_metrics.c | |||
| @@ -252,6 +252,7 @@ static struct tcp_metrics_block *__tcp_get_metrics_req(struct request_sock *req, | |||
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | net = dev_net(dst->dev); | 254 | net = dev_net(dst->dev); |
| 255 | hash ^= net_hash_mix(net); | ||
| 255 | hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log); | 256 | hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log); |
| 256 | 257 | ||
| 257 | for (tm = rcu_dereference(net->ipv4.tcp_metrics_hash[hash].chain); tm; | 258 | for (tm = rcu_dereference(net->ipv4.tcp_metrics_hash[hash].chain); tm; |
| @@ -299,6 +300,7 @@ static struct tcp_metrics_block *__tcp_get_metrics_tw(struct inet_timewait_sock | |||
| 299 | return NULL; | 300 | return NULL; |
| 300 | 301 | ||
| 301 | net = twsk_net(tw); | 302 | net = twsk_net(tw); |
| 303 | hash ^= net_hash_mix(net); | ||
| 302 | hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log); | 304 | hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log); |
| 303 | 305 | ||
| 304 | for (tm = rcu_dereference(net->ipv4.tcp_metrics_hash[hash].chain); tm; | 306 | for (tm = rcu_dereference(net->ipv4.tcp_metrics_hash[hash].chain); tm; |
| @@ -347,6 +349,7 @@ static struct tcp_metrics_block *tcp_get_metrics(struct sock *sk, | |||
| 347 | return NULL; | 349 | return NULL; |
| 348 | 350 | ||
| 349 | net = dev_net(dst->dev); | 351 | net = dev_net(dst->dev); |
| 352 | hash ^= net_hash_mix(net); | ||
| 350 | hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log); | 353 | hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log); |
| 351 | 354 | ||
| 352 | tm = __tcp_get_metrics(&saddr, &daddr, net, hash); | 355 | tm = __tcp_get_metrics(&saddr, &daddr, net, hash); |
| @@ -994,6 +997,7 @@ static int tcp_metrics_nl_cmd_get(struct sk_buff *skb, struct genl_info *info) | |||
| 994 | if (!reply) | 997 | if (!reply) |
| 995 | goto nla_put_failure; | 998 | goto nla_put_failure; |
| 996 | 999 | ||
| 1000 | hash ^= net_hash_mix(net); | ||
| 997 | hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log); | 1001 | hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log); |
| 998 | ret = -ESRCH; | 1002 | ret = -ESRCH; |
| 999 | rcu_read_lock(); | 1003 | rcu_read_lock(); |
| @@ -1070,6 +1074,7 @@ static int tcp_metrics_nl_cmd_del(struct sk_buff *skb, struct genl_info *info) | |||
| 1070 | if (ret < 0) | 1074 | if (ret < 0) |
| 1071 | src = false; | 1075 | src = false; |
| 1072 | 1076 | ||
| 1077 | hash ^= net_hash_mix(net); | ||
| 1073 | hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log); | 1078 | hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log); |
| 1074 | hb = net->ipv4.tcp_metrics_hash + hash; | 1079 | hb = net->ipv4.tcp_metrics_hash + hash; |
| 1075 | pp = &hb->chain; | 1080 | pp = &hb->chain; |
