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>
diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
index 4206b14..fbb42f4 100644
--- a/net/ipv4/tcp_metrics.c
+++ b/net/ipv4/tcp_metrics.c
@@ -252,6 +252,7 @@
}
net = dev_net(dst->dev);
+ hash ^= net_hash_mix(net);
hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log);
for (tm = rcu_dereference(net->ipv4.tcp_metrics_hash[hash].chain); tm;
@@ -299,6 +300,7 @@
return NULL;
net = twsk_net(tw);
+ hash ^= net_hash_mix(net);
hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log);
for (tm = rcu_dereference(net->ipv4.tcp_metrics_hash[hash].chain); tm;
@@ -347,6 +349,7 @@
return NULL;
net = dev_net(dst->dev);
+ hash ^= net_hash_mix(net);
hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log);
tm = __tcp_get_metrics(&saddr, &daddr, net, hash);
@@ -994,6 +997,7 @@
if (!reply)
goto nla_put_failure;
+ hash ^= net_hash_mix(net);
hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log);
ret = -ESRCH;
rcu_read_lock();
@@ -1070,6 +1074,7 @@
if (ret < 0)
src = false;
+ hash ^= net_hash_mix(net);
hash = hash_32(hash, net->ipv4.tcp_metrics_hash_log);
hb = net->ipv4.tcp_metrics_hash + hash;
pp = &hb->chain;