mlx4: use netdev_rss_key_fill() helper
authorEric Dumazet <edumazet@google.com>
Sun, 16 Nov 2014 14:23:16 +0000 (06:23 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sun, 16 Nov 2014 20:59:13 +0000 (15:59 -0500)
Use of well known RSS key increases attack surface.
Switch to a random one, using generic helper so that all
ports share a common key.

Also provide ethtool -x support to fetch RSS key

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Amir Vadai <amirv@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
drivers/net/ethernet/mellanox/mlx4/en_rx.c
include/linux/mlx4/qp.h

index 6c643230a5ed657d48e8ab1624f222dc844580f1..710cf309962a05fdffd1b6f5f8c91cdbd8ed63ed 100644 (file)
@@ -973,6 +973,11 @@ static u32 mlx4_en_get_rxfh_indir_size(struct net_device *dev)
        return priv->rx_ring_num;
 }
 
+static u32 mlx4_en_get_rxfh_key_size(struct net_device *netdev)
+{
+       return MLX4_EN_RSS_KEY_SIZE;
+}
+
 static int mlx4_en_get_rxfh(struct net_device *dev, u32 *ring_index, u8 *key)
 {
        struct mlx4_en_priv *priv = netdev_priv(dev);
@@ -988,7 +993,8 @@ static int mlx4_en_get_rxfh(struct net_device *dev, u32 *ring_index, u8 *key)
                ring_index[n] = rss_map->qps[n % rss_rings].qpn -
                        rss_map->base_qpn;
        }
-
+       if (key)
+               netdev_rss_key_fill(key, MLX4_EN_RSS_KEY_SIZE);
        return err;
 }
 
@@ -1799,6 +1805,7 @@ const struct ethtool_ops mlx4_en_ethtool_ops = {
        .get_rxnfc = mlx4_en_get_rxnfc,
        .set_rxnfc = mlx4_en_set_rxnfc,
        .get_rxfh_indir_size = mlx4_en_get_rxfh_indir_size,
+       .get_rxfh_key_size = mlx4_en_get_rxfh_key_size,
        .get_rxfh = mlx4_en_get_rxfh,
        .set_rxfh = mlx4_en_set_rxfh,
        .get_channels = mlx4_en_get_channels,
index ccd95177ea7c5d294b4c19f3c756d9ba309217c1..b7bda8956011e0d0e42adad6d9e2eb5b200691c2 100644 (file)
@@ -1169,9 +1169,6 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv)
        int i, qpn;
        int err = 0;
        int good_qps = 0;
-       static const u32 rsskey[10] = { 0xD181C62C, 0xF7F4DB5B, 0x1983A2FC,
-                               0x943E1ADB, 0xD9389E6B, 0xD1039C2C, 0xA74499AD,
-                               0x593D56D9, 0xF3253C06, 0x2ADC1FFC};
 
        en_dbg(DRV, priv, "Configuring rss steering\n");
        err = mlx4_qp_reserve_range(mdev->dev, priv->rx_ring_num,
@@ -1226,8 +1223,7 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv)
 
        rss_context->flags = rss_mask;
        rss_context->hash_fn = MLX4_RSS_HASH_TOP;
-       for (i = 0; i < 10; i++)
-               rss_context->rss_key[i] = cpu_to_be32(rsskey[i]);
+       netdev_rss_key_fill(rss_context->rss_key, MLX4_EN_RSS_KEY_SIZE);
 
        err = mlx4_qp_to_ready(mdev->dev, &priv->res.mtt, &context,
                               &rss_map->indir_qp, &rss_map->indir_state);
index 5f4e36cf00910c7220b743fd06f5471cdd7dc441..467ccdf94c981f7a7f90b04b6d2855c4b4a56d18 100644 (file)
@@ -120,13 +120,15 @@ enum {
        MLX4_RSS_QPC_FLAG_OFFSET                = 13,
 };
 
+#define MLX4_EN_RSS_KEY_SIZE 40
+
 struct mlx4_rss_context {
        __be32                  base_qpn;
        __be32                  default_qpn;
        u16                     reserved;
        u8                      hash_fn;
        u8                      flags;
-       __be32                  rss_key[10];
+       __be32                  rss_key[MLX4_EN_RSS_KEY_SIZE / sizeof(__be32)];
        __be32                  base_qpn_udp;
 };