diff options
Diffstat (limited to 'net/ethtool/ioctl.c')
-rw-r--r-- | net/ethtool/ioctl.c | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index ae041f51cd2d..65cfe76dafbe 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -1230,7 +1230,8 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev, if (rxfh.rsvd8[0] || rxfh.rsvd8[1] || rxfh.rsvd32) return -EINVAL; /* Most drivers don't handle rss_context, check it's 0 as well */ - if (rxfh.rss_context && !ops->cap_rss_ctx_supported) + if (rxfh.rss_context && !(ops->cap_rss_ctx_supported || + ops->create_rxfh_context)) return -EOPNOTSUPP; rxfh.indir_size = rxfh_dev.indir_size; @@ -1263,10 +1264,15 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev, if (rxfh_dev.indir) memcpy(rxfh_dev.indir, ethtool_rxfh_context_indir(ctx), indir_bytes); - if (rxfh_dev.key) - memcpy(rxfh_dev.key, ethtool_rxfh_context_key(ctx), - user_key_size); - rxfh_dev.hfunc = ctx->hfunc; + if (!ops->rxfh_per_ctx_key) { + rxfh_dev.key_size = 0; + } else { + if (rxfh_dev.key) + memcpy(rxfh_dev.key, + ethtool_rxfh_context_key(ctx), + user_key_size); + rxfh_dev.hfunc = ctx->hfunc; + } rxfh_dev.input_xfrm = ctx->input_xfrm; ret = 0; } else { @@ -1284,6 +1290,11 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev, sizeof(rxfh.input_xfrm))) { ret = -EFAULT; } else if (copy_to_user(useraddr + + offsetof(struct ethtool_rxfh, key_size), + &rxfh_dev.key_size, + sizeof(rxfh.key_size))) { + ret = -EFAULT; + } else if (copy_to_user(useraddr + offsetof(struct ethtool_rxfh, rss_config[0]), rss_config, total_size)) { ret = -EFAULT; @@ -1360,7 +1371,8 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, if (rxfh.rsvd8[0] || rxfh.rsvd8[1] || rxfh.rsvd32) return -EINVAL; /* Most drivers don't handle rss_context, check it's 0 as well */ - if (rxfh.rss_context && !ops->cap_rss_ctx_supported) + if (rxfh.rss_context && !(ops->cap_rss_ctx_supported || + ops->create_rxfh_context)) return -EOPNOTSUPP; /* Check input data transformation capabilities */ if (rxfh.input_xfrm && rxfh.input_xfrm != RXH_XFRM_SYM_XOR && @@ -1390,6 +1402,13 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, indir_bytes = dev_indir_size * sizeof(rxfh_dev.indir[0]); + /* Check settings which may be global rather than per RSS-context */ + if (rxfh.rss_context && !ops->rxfh_per_ctx_key) + if (rxfh.key_size || + (rxfh.hfunc && rxfh.hfunc != ETH_RSS_HASH_NO_CHANGE) || + (rxfh.input_xfrm && rxfh.input_xfrm != RXH_XFRM_NO_CHANGE)) + return -EOPNOTSUPP; + rss_config = kzalloc(indir_bytes + dev_key_size, GFP_USER); if (!rss_config) return -ENOMEM; @@ -2072,8 +2091,6 @@ static noinline_for_stack int ethtool_set_channels(struct net_device *dev, { struct ethtool_channels channels, curr = { .cmd = ETHTOOL_GCHANNELS }; u16 from_channel, to_channel; - u64 max_rxnfc_in_use; - u32 max_rxfh_in_use; unsigned int i; int ret; @@ -2103,14 +2120,9 @@ static noinline_for_stack int ethtool_set_channels(struct net_device *dev, (!channels.rx_count || !channels.tx_count)) return -EINVAL; - /* ensure the new Rx count fits within the configured Rx flow - * indirection table/rxnfc settings */ - if (ethtool_get_max_rxnfc_channel(dev, &max_rxnfc_in_use)) - max_rxnfc_in_use = 0; - max_rxfh_in_use = ethtool_get_max_rxfh_channel(dev); - if (channels.combined_count + channels.rx_count <= - max_t(u64, max_rxnfc_in_use, max_rxfh_in_use)) - return -EINVAL; + ret = ethtool_check_max_channel(dev, channels, NULL); + if (ret) + return ret; /* Disabling channels, query zero-copy AF_XDP sockets */ from_channel = channels.combined_count + |