diff mbox series

[net] net: ethtool: Fix RSS setting

Message ID 20240710225538.43368-1-saeed@kernel.org (mailing list archive)
State Accepted
Commit 503757c809281a24d50ac2538401d3b1302b301c
Delegated to: Netdev Maintainers
Headers show
Series [net] net: ethtool: Fix RSS setting | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 833 this patch: 833
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers fail 1 blamed authors not CCed: wojciech.drewek@intel.com; 2 maintainers not CCed: wojciech.drewek@intel.com andrew@lunn.ch
netdev/build_clang success Errors and warnings before: 835 this patch: 835
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 835 this patch: 835
netdev/checkpatch warning WARNING: Unexpected content after email: 'David Wei <dw@davidwei.uk>,', should be: 'David Wei <dw@davidwei.uk>'
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Saeed Mahameed July 10, 2024, 10:55 p.m. UTC
From: Saeed Mahameed <saeedm@nvidia.com>

When user submits a rxfh set command without touching XFRM_SYM_XOR,
rxfh.input_xfrm is set to RXH_XFRM_NO_CHANGE, which is equal to 0xff.

Testing if (rxfh.input_xfrm & RXH_XFRM_SYM_XOR &&
	    !ops->cap_rss_sym_xor_supported)
		return -EOPNOTSUPP;

Will always be true on devices that don't set cap_rss_sym_xor_supported,
since rxfh.input_xfrm & RXH_XFRM_SYM_XOR is always true, if input_xfrm
was not set, i.e RXH_XFRM_NO_CHANGE=0xff, which will result in failure
of any command that doesn't require any change of XFRM, e.g RSS context
or hash function changes.

To avoid this breakage, test if rxfh.input_xfrm != RXH_XFRM_NO_CHANGE
before testing other conditions.

Fixes: 13e59344fb9d ("net: ethtool: add support for symmetric-xor RSS hash")
CC: Ahmed Zaki <ahmed.zaki@intel.com>
CC: David Wei <dw@davidwei.uk>,
CC: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 net/ethtool/ioctl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Ahmed Zaki July 11, 2024, 1:41 p.m. UTC | #1
On 2024-07-10 4:55 p.m., Saeed Mahameed wrote:
> From: Saeed Mahameed <saeedm@nvidia.com>
> 
> When user submits a rxfh set command without touching XFRM_SYM_XOR,
> rxfh.input_xfrm is set to RXH_XFRM_NO_CHANGE, which is equal to 0xff.
> 
> Testing if (rxfh.input_xfrm & RXH_XFRM_SYM_XOR &&
> 	    !ops->cap_rss_sym_xor_supported)
> 		return -EOPNOTSUPP;
> 
> Will always be true on devices that don't set cap_rss_sym_xor_supported,
> since rxfh.input_xfrm & RXH_XFRM_SYM_XOR is always true, if input_xfrm
> was not set, i.e RXH_XFRM_NO_CHANGE=0xff, which will result in failure
> of any command that doesn't require any change of XFRM, e.g RSS context
> or hash function changes.
> 
> To avoid this breakage, test if rxfh.input_xfrm != RXH_XFRM_NO_CHANGE
> before testing other conditions.
> 
> Fixes: 13e59344fb9d ("net: ethtool: add support for symmetric-xor RSS hash")
> CC: Ahmed Zaki <ahmed.zaki@intel.com>
> CC: David Wei <dw@davidwei.uk>,
> CC: Pavel Begunkov <asml.silence@gmail.com>
> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
> ---
>   net/ethtool/ioctl.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
> index e645d751a5e8..223dcd25d88a 100644
> --- a/net/ethtool/ioctl.c
> +++ b/net/ethtool/ioctl.c
> @@ -1306,7 +1306,8 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
>   	if (rxfh.input_xfrm && rxfh.input_xfrm != RXH_XFRM_SYM_XOR &&
>   	    rxfh.input_xfrm != RXH_XFRM_NO_CHANGE)
>   		return -EINVAL;
> -	if ((rxfh.input_xfrm & RXH_XFRM_SYM_XOR) &&
> +	if (rxfh.input_xfrm != RXH_XFRM_NO_CHANGE &&
> +	    (rxfh.input_xfrm & RXH_XFRM_SYM_XOR) &&
>   	    !ops->cap_rss_sym_xor_supported)
>   		return -EOPNOTSUPP;
>   

LGTM, thank you for catching this.

Reviewed-by: Ahmed Zaki <ahmed.zaki@intel.com>
Jakub Kicinski July 12, 2024, 12:20 a.m. UTC | #2
On Wed, 10 Jul 2024 15:55:38 -0700 Saeed Mahameed wrote:
> Fixes: 13e59344fb9d ("net: ethtool: add support for symmetric-xor RSS hash")

I think :

Fixes: 0dd415d15505 ("net: ethtool: add a NO_CHANGE uAPI for new RXFH's input_xfrm")

will swap when applying.
patchwork-bot+netdevbpf@kernel.org July 12, 2024, 12:30 a.m. UTC | #3
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 10 Jul 2024 15:55:38 -0700 you wrote:
> From: Saeed Mahameed <saeedm@nvidia.com>
> 
> When user submits a rxfh set command without touching XFRM_SYM_XOR,
> rxfh.input_xfrm is set to RXH_XFRM_NO_CHANGE, which is equal to 0xff.
> 
> Testing if (rxfh.input_xfrm & RXH_XFRM_SYM_XOR &&
> 	    !ops->cap_rss_sym_xor_supported)
> 		return -EOPNOTSUPP;
> 
> [...]

Here is the summary with links:
  - [net] net: ethtool: Fix RSS setting
    https://git.kernel.org/netdev/net/c/503757c80928

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index e645d751a5e8..223dcd25d88a 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -1306,7 +1306,8 @@  static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
 	if (rxfh.input_xfrm && rxfh.input_xfrm != RXH_XFRM_SYM_XOR &&
 	    rxfh.input_xfrm != RXH_XFRM_NO_CHANGE)
 		return -EINVAL;
-	if ((rxfh.input_xfrm & RXH_XFRM_SYM_XOR) &&
+	if (rxfh.input_xfrm != RXH_XFRM_NO_CHANGE &&
+	    (rxfh.input_xfrm & RXH_XFRM_SYM_XOR) &&
 	    !ops->cap_rss_sym_xor_supported)
 		return -EOPNOTSUPP;