Skip to content

Commit 1c172fe

Browse files
committed
net: rss: fix reporting RXH_XFRM_NO_CHANGE as input_xfrm for contexts
Initializing input_xfrm to RXH_XFRM_NO_CHANGE in RSS contexts is problematic. I think I did this to make it clear that the context does not have its own settings applied. But unlike ETH_RSS_HASH_NO_CHANGE which is zero, RXH_XFRM_NO_CHANGE is 0xff. We need to be careful when reading the value back, and remember to treat 0xff as 0. Remove the initialization and switch to storing 0. This lets us also remove the workaround in ethnl_rss_set(). Get side does not need any adjustments and context get no longer reports: RSS input transformation: symmetric-xor: on symmetric-or-xor: on Unknown bits in RSS input transformation: 0xfc for NICs which don't support input_xfrm. Remove the init of hfunc to ETH_RSS_HASH_NO_CHANGE while at it. As already mentioned this is a noop since ETH_RSS_HASH_NO_CHANGE is 0 and struct is zalloc'd. But as this fix exemplifies storing NO_CHANGE as state is fragile. This issue is implicitly caught by running our selftests because YNL in selftests errors out on unknown bits. Fixes: d3e2c7b ("ethtool: rss: support setting input-xfrm via Netlink") Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 83b67cc commit 1c172fe

2 files changed

Lines changed: 2 additions & 10 deletions

File tree

net/ethtool/common.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -862,9 +862,6 @@ ethtool_rxfh_ctx_alloc(const struct ethtool_ops *ops,
862862
ctx->key_off = key_off;
863863
ctx->priv_size = ops->rxfh_priv_size;
864864

865-
ctx->hfunc = ETH_RSS_HASH_NO_CHANGE;
866-
ctx->input_xfrm = RXH_XFRM_NO_CHANGE;
867-
868865
return ctx;
869866
}
870867

net/ethtool/rss.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -824,8 +824,8 @@ rss_set_ctx_update(struct ethtool_rxfh_context *ctx, struct nlattr **tb,
824824
static int
825825
ethnl_rss_set(struct ethnl_req_info *req_info, struct genl_info *info)
826826
{
827-
bool indir_reset = false, indir_mod, xfrm_sym = false;
828827
struct rss_req_info *request = RSS_REQINFO(req_info);
828+
bool indir_reset = false, indir_mod, xfrm_sym;
829829
struct ethtool_rxfh_context *ctx = NULL;
830830
struct net_device *dev = req_info->dev;
831831
bool mod = false, fields_mod = false;
@@ -860,12 +860,7 @@ ethnl_rss_set(struct ethnl_req_info *req_info, struct genl_info *info)
860860

861861
rxfh.input_xfrm = data.input_xfrm;
862862
ethnl_update_u8(&rxfh.input_xfrm, tb[ETHTOOL_A_RSS_INPUT_XFRM], &mod);
863-
/* For drivers which don't support input_xfrm it will be set to 0xff
864-
* in the RSS context info. In all other case input_xfrm != 0 means
865-
* symmetric hashing is requested.
866-
*/
867-
if (!request->rss_context || ops->rxfh_per_ctx_key)
868-
xfrm_sym = rxfh.input_xfrm || data.input_xfrm;
863+
xfrm_sym = rxfh.input_xfrm || data.input_xfrm;
869864
if (rxfh.input_xfrm == data.input_xfrm)
870865
rxfh.input_xfrm = RXH_XFRM_NO_CHANGE;
871866

0 commit comments

Comments
 (0)