Skip to contentSkip to conversation

net: ethtool: fix compat with old RSS context API

PATCH Applied Jakub Kicinski 4 participants 4 messages Jul 2, 2024 – Jul 9, 2024

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 net: ethtool: fix compat with old RSS context API

Device driver gets access to rxfh_dev, while rxfh is just a local copy of user space params. We need to check what RSS context ID driver assigned in rxfh_dev, not rxfh.

Using rxfh leads to trying to store all contexts at index 0xffffffff. From the user perspective it leads to "driver chose duplicate ID" warnings when second context is added and inability to access any contexts even tho they were successfully created - xa_load() for the actual context ID will return NULL, and syscall will return -ENOENT.

Looks like a rebasing mistake, since rxfh_dev was added relatively recently by fb6e30a72539 ("net: ethtool: pass a pointer to parameters to get/set_rxfh ethtool ops").

Fixes eac9122f0c41 ("net: ethtool: record custom RSS contexts in the XArray")

---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 net/ethtool/ioctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/ethtool/ioctl.c +2 -2
index d8795ed07ba3..46f0497ae6bc 100644
@@ -1483,13 +1483,13 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
 	/* Update rss_ctx tracking */
 	if (create && !ops->create_rxfh_context) {
 		/* driver uses old API, it chose context ID */
-		if (WARN_ON(xa_load(&dev->ethtool->rss_ctx, rxfh.rss_context))) {
+		if (WARN_ON(xa_load(&dev->ethtool->rss_ctx, rxfh_dev.rss_context))) {
 			/* context ID reused, our tracking is screwed */
 			kfree(ctx);
 			goto out;
 		}
 		/* Allocate the exact ID the driver gave us */
-		if (xa_is_err(xa_store(&dev->ethtool->rss_ctx, rxfh.rss_context,
+		if (xa_is_err(xa_store(&dev->ethtool->rss_ctx, rxfh_dev.rss_context,
 				       ctx, GFP_KERNEL))) {
 			kfree(ctx);
 			goto out;
Signature · 1 line
2.45.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Jakub Kicinski

Device driver gets access to rxfh_dev, while rxfh is just a local copy of user space params. We need to check what RSS context ID driver assigned in rxfh_dev, not rxfh.

Using rxfh leads to trying to store all contexts at index 0xffffffff. From the user perspective it leads to "driver chose duplicate ID" warnings when second context is added and inability to access any contexts even tho they were successfully created - xa_load() for the actual context ID will return NULL, and syscall will return -ENOENT.

Quoted 6 lines

Looks like a rebasing mistake, since rxfh_dev was added relatively recently by fb6e30a72539 ("net: ethtool: pass a pointer to parameters to get/set_rxfh ethtool ops").

Fixes eac9122f0c41 ("net: ethtool: record custom RSS contexts in the XArray")

My bad, I should have re-tested that side of things after the rebase
onto Ahmed's changes, instead of just testing the new API via sfc.
Thanks for catching it so quickly.

#2 lore raw
In reply to Jakub Kicinski
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Tue, 2 Jul 2024 09:41:57 -0700 you wrote:

Device driver gets access to rxfh_dev, while rxfh is just a local copy of user space params. We need to check what RSS context ID driver assigned in rxfh_dev, not rxfh.

Using rxfh leads to trying to store all contexts at index 0xffffffff. From the user perspective it leads to "driver chose duplicate ID" warnings when second context is added and inability to access any contexts even tho they were successfully created - xa_load() for the actual context ID will return NULL, and syscall will return -ENOENT.

[...]

Here is the summary with links:
- [net-next] net: ethtool: fix compat with old RSS context API

    https://git.kernel.org/netdev/net-next/c/1a16cdf77e0d

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Tested-by on v1 1/1
#3 lore raw
In reply to Jakub Kicinski
Quoted 10 lines · Jakub Kicinski

Device driver gets access to rxfh_dev, while rxfh is just a local copy of user space params. We need to check what RSS context ID driver assigned in rxfh_dev, not rxfh.

Using rxfh leads to trying to store all contexts at index 0xffffffff.

Quoted 1 line

From the user perspective it leads to "driver chose duplicate ID"

warnings when second context is added and inability to access any contexts even tho they were successfully created - xa_load() for the actual context ID will return NULL, and syscall will return -ENOENT.

Quoted 6 lines

Looks like a rebasing mistake, since rxfh_dev was added relatively recently by fb6e30a72539 ("net: ethtool: pass a pointer to parameters to get/set_rxfh ethtool ops").

Fixes eac9122f0c41 ("net: ethtool: record custom RSS contexts in the XArray")

FWIW, better late than never: