Commit 501869fe authored by Gerhard Engleder's avatar Gerhard Engleder Committed by Jakub Kicinski
Browse files

net: ethtool: Fix symmetric-xor RSS RX flow hash check



Commit 13e59344 ("net: ethtool: add support for symmetric-xor RSS hash")
adds a check to the ethtool set_rxnfc operation, which checks the RX
flow hash if the flag RXH_XFRM_SYM_XOR is set. This flag is introduced
with the same commit. It calls the ethtool get_rxfh operation to get the
RX flow hash data. If get_rxfh is not supported, then EOPNOTSUPP is
returned.

There are driver like tsnep, macb, asp2, genet, gianfar, mtk, ... which
support the ethtool operation set_rxnfc but not get_rxfh. This results
in EOPNOTSUPP returned by ethtool_set_rxnfc() without actually calling
the ethtool operation set_rxnfc. Thus, set_rxnfc got broken for all
these drivers.

Check RX flow hash in ethtool_set_rxnfc() only if driver supports RX
flow hash.

Fixes: 13e59344 ("net: ethtool: add support for symmetric-xor RSS hash")
Signed-off-by: default avatarGerhard Engleder <gerhard@engleder-embedded.com>
Reviewed-by: default avatarRavi Gunasekaran <r-gunasekaran@ti.com>
Link: https://lore.kernel.org/r/20231226205536.32003-1-gerhard@engleder-embedded.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 88b8fd97
Loading
Loading
Loading
Loading
+18 −15
Original line number Diff line number Diff line
@@ -973,18 +973,20 @@ static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
						u32 cmd, void __user *useraddr)
{
	const struct ethtool_ops *ops = dev->ethtool_ops;
	struct ethtool_rxfh_param rxfh = {};
	struct ethtool_rxnfc info;
	size_t info_size = sizeof(info);
	int rc;

	if (!ops->set_rxnfc || !ops->get_rxfh)
	if (!ops->set_rxnfc)
		return -EOPNOTSUPP;

	rc = ethtool_rxnfc_copy_struct(cmd, &info, &info_size, useraddr);
	if (rc)
		return rc;

	if (ops->get_rxfh) {
		struct ethtool_rxfh_param rxfh = {};

		rc = ops->get_rxfh(dev, &rxfh);
		if (rc)
			return rc;
@@ -999,6 +1001,7 @@ static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
		     (!!(info.data & RXH_IP_SRC) ^ !!(info.data & RXH_IP_DST)) ||
		     (!!(info.data & RXH_L4_B_0_1) ^ !!(info.data & RXH_L4_B_2_3))))
			return -EINVAL;
	}

	rc = ops->set_rxnfc(dev, &info);
	if (rc)