Skip to content

Commit 4d7c3c1

Browse files
gal-pressmankuba-moo
authored andcommitted
ethtool: Fix context creation with no parameters
The 'at least one change' requirement is not applicable for context creation, skip the check in such case. This allows a command such as 'ethtool -X eth0 context new' to work. The command works by mistake when using older versions of userspace ethtool due to an incompatibility issue where rxfh.input_xfrm is passed as zero (unset) instead of RXH_XFRM_NO_CHANGE as done with recent userspace. This patch does not try to solve the incompatibility issue. Link: https://lore.kernel.org/netdev/[email protected]/ Fixes: 84a1d9c ("net: ethtool: extend RXNFC API to support RSS spreading of filter matches") Reviewed-by: Dragos Tatulea <[email protected]> Reviewed-by: Jianbo Liu <[email protected]> Signed-off-by: Gal Pressman <[email protected]> Reviewed-by: Edward Cree <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b54de55 commit 4d7c3c1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

net/ethtool/ioctl.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,14 +1369,17 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
13691369
return -EOPNOTSUPP;
13701370
create = rxfh.rss_context == ETH_RXFH_CONTEXT_ALLOC;
13711371

1372-
/* If either indir, hash key or function is valid, proceed further.
1373-
* Must request at least one change: indir size, hash key, function
1374-
* or input transformation.
1375-
*/
13761372
if ((rxfh.indir_size &&
13771373
rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE &&
13781374
rxfh.indir_size != dev_indir_size) ||
1379-
(rxfh.key_size && (rxfh.key_size != dev_key_size)) ||
1375+
(rxfh.key_size && rxfh.key_size != dev_key_size))
1376+
return -EINVAL;
1377+
1378+
/* Must request at least one change: indir size, hash key, function
1379+
* or input transformation.
1380+
* There's no need for any of it in case of context creation.
1381+
*/
1382+
if (!create &&
13801383
(rxfh.indir_size == ETH_RXFH_INDIR_NO_CHANGE &&
13811384
rxfh.key_size == 0 && rxfh.hfunc == ETH_RSS_HASH_NO_CHANGE &&
13821385
rxfh.input_xfrm == RXH_XFRM_NO_CHANGE))

0 commit comments

Comments
 (0)