Skip to content

Commit 501869f

Browse files
Gerhard Englederkuba-moo
Gerhard Engleder
authored andcommitted
net: ethtool: Fix symmetric-xor RSS RX flow hash check
Commit 13e5934 ("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: 13e5934 ("net: ethtool: add support for symmetric-xor RSS hash") Signed-off-by: Gerhard Engleder <[email protected]> Reviewed-by: Ravi Gunasekaran <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 88b8fd9 commit 501869f

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

net/ethtool/ioctl.c

+18-15
Original file line numberDiff line numberDiff line change
@@ -973,32 +973,35 @@ static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
973973
u32 cmd, void __user *useraddr)
974974
{
975975
const struct ethtool_ops *ops = dev->ethtool_ops;
976-
struct ethtool_rxfh_param rxfh = {};
977976
struct ethtool_rxnfc info;
978977
size_t info_size = sizeof(info);
979978
int rc;
980979

981-
if (!ops->set_rxnfc || !ops->get_rxfh)
980+
if (!ops->set_rxnfc)
982981
return -EOPNOTSUPP;
983982

984983
rc = ethtool_rxnfc_copy_struct(cmd, &info, &info_size, useraddr);
985984
if (rc)
986985
return rc;
987986

988-
rc = ops->get_rxfh(dev, &rxfh);
989-
if (rc)
990-
return rc;
987+
if (ops->get_rxfh) {
988+
struct ethtool_rxfh_param rxfh = {};
991989

992-
/* Sanity check: if symmetric-xor is set, then:
993-
* 1 - no other fields besides IP src/dst and/or L4 src/dst
994-
* 2 - If src is set, dst must also be set
995-
*/
996-
if ((rxfh.input_xfrm & RXH_XFRM_SYM_XOR) &&
997-
((info.data & ~(RXH_IP_SRC | RXH_IP_DST |
998-
RXH_L4_B_0_1 | RXH_L4_B_2_3)) ||
999-
(!!(info.data & RXH_IP_SRC) ^ !!(info.data & RXH_IP_DST)) ||
1000-
(!!(info.data & RXH_L4_B_0_1) ^ !!(info.data & RXH_L4_B_2_3))))
1001-
return -EINVAL;
990+
rc = ops->get_rxfh(dev, &rxfh);
991+
if (rc)
992+
return rc;
993+
994+
/* Sanity check: if symmetric-xor is set, then:
995+
* 1 - no other fields besides IP src/dst and/or L4 src/dst
996+
* 2 - If src is set, dst must also be set
997+
*/
998+
if ((rxfh.input_xfrm & RXH_XFRM_SYM_XOR) &&
999+
((info.data & ~(RXH_IP_SRC | RXH_IP_DST |
1000+
RXH_L4_B_0_1 | RXH_L4_B_2_3)) ||
1001+
(!!(info.data & RXH_IP_SRC) ^ !!(info.data & RXH_IP_DST)) ||
1002+
(!!(info.data & RXH_L4_B_0_1) ^ !!(info.data & RXH_L4_B_2_3))))
1003+
return -EINVAL;
1004+
}
10021005

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

0 commit comments

Comments
 (0)