diff options
author | Eric Dumazet <edumazet@google.com> | 2014-11-16 09:23:05 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-11-16 15:59:11 -0500 |
commit | 960fb622f85180f36d3aff82af53e2be3db2f888 (patch) | |
tree | c567b80d26270e3d4a3437c9710be6ca0f1eddc3 /net/core/ethtool.c | |
parent | ca245024349c0d44434a6381583b99f0eb559c7c (diff) |
net: provide a per host RSS key generic infrastructure
RSS (Receive Side Scaling) typically uses Toeplitz hash and a 40 or 52 bytes
RSS key.
Some drivers use a constant (and well known key), some drivers use a random
key per port, making bonding setups hard to tune. Well known keys increase
attack surface, considering that number of queues is usually a power of two.
This patch provides infrastructure to help drivers doing the right thing.
netdev_rss_key_fill() should be used by drivers to initialize their RSS key,
even if they provide ethtool -X support to let user redefine the key later.
A new /proc/sys/net/core/netdev_rss_key file can be used to get the host
RSS key even for drivers not providing ethtool -x support, in case some
applications want to precisely setup flows to match some RX queues.
Tested:
myhost:~# cat /proc/sys/net/core/netdev_rss_key
11:63:99:bb:79:fb:a5:a7:07:45:b2:20:bf:02:42:2d:08:1a:dd:19:2b:6b:23:ac:56:28:9d:70:c3:ac:e8:16:4b:b7:c1:10:53:a4:78:41:36:40:74:b6:15:ca:27:44:aa:b3:4d:72
myhost:~# ethtool -x eth0
RX flow hash indirection table for eth0 with 8 RX ring(s):
0: 0 1 2 3 4 5 6 7
RSS hash key:
11:63:99:bb:79:fb:a5:a7:07:45:b2:20:bf:02:42:2d:08:1a:dd:19:2b:6b:23:ac:56:28:9d:70:c3:ac:e8:16:4b:b7:c1:10:53:a4:78:41
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/ethtool.c')
-rw-r--r-- | net/core/ethtool.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index b0f84f5ddda8..715f51f321e9 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/rtnetlink.h> | 26 | #include <linux/rtnetlink.h> |
27 | #include <linux/sched.h> | 27 | #include <linux/sched.h> |
28 | #include <linux/net.h> | ||
28 | 29 | ||
29 | /* | 30 | /* |
30 | * Some useful ethtool_ops methods that're device independent. | 31 | * Some useful ethtool_ops methods that're device independent. |
@@ -573,6 +574,16 @@ static int ethtool_copy_validate_indir(u32 *indir, void __user *useraddr, | |||
573 | return 0; | 574 | return 0; |
574 | } | 575 | } |
575 | 576 | ||
577 | u8 netdev_rss_key[NETDEV_RSS_KEY_LEN]; | ||
578 | |||
579 | void netdev_rss_key_fill(void *buffer, size_t len) | ||
580 | { | ||
581 | BUG_ON(len > sizeof(netdev_rss_key)); | ||
582 | net_get_random_once(netdev_rss_key, sizeof(netdev_rss_key)); | ||
583 | memcpy(buffer, netdev_rss_key, len); | ||
584 | } | ||
585 | EXPORT_SYMBOL(netdev_rss_key_fill); | ||
586 | |||
576 | static noinline_for_stack int ethtool_get_rxfh_indir(struct net_device *dev, | 587 | static noinline_for_stack int ethtool_get_rxfh_indir(struct net_device *dev, |
577 | void __user *useraddr) | 588 | void __user *useraddr) |
578 | { | 589 | { |