Skip to contentSkip to conversation

netdevsim: don't overwrite read only ethtool parms

PATCH Applied Filip Pokryvka 2 participants 2 messages Dec 10, 2021 – Dec 11, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netdevsim: don't overwrite read only ethtool parms

Ethtool ring feature has _max_pending attributes read-only. Set only read-write attributes in nsim_set_ringparam.

This patch is useful, if netdevsim device is set-up using NetworkManager, because NetworkManager sends 0 as MAX values, as it is pointless to retrieve them in extra call, because they should be read-only. Then, the device is left in incosistent state (value > MAX).

Fixes a7fc6db099b5 ("netdevsim: support ethtool ring and coalesce settings")
---
 drivers/net/netdevsim/ethtool.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/netdevsim/ethtool.c +4 -1
index b03a0513e..2e7c1cc16 100644
@@ -77,7 +77,10 @@ static int nsim_set_ringparam(struct net_device *dev,
 {
 	struct netdevsim *ns = netdev_priv(dev);
 
-	memcpy(&ns->ethtool.ring, ring, sizeof(ns->ethtool.ring));
+	ns->ethtool.ring.rx_pending = ring->rx_pending;
+	ns->ethtool.ring.rx_jumbo_pending = ring->rx_jumbo_pending;
+	ns->ethtool.ring.rx_mini_pending = ring->rx_mini_pending;
+	ns->ethtool.ring.tx_pending = ring->tx_pending;
 	return 0;
 }
 
Signature · 1 line
2.27.0
#1 lore raw
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:

Hello:

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

Quoted 9 lines · On Fri, 10 Dec 2021 18:50:32 +0100 you wrote:

Ethtool ring feature has _max_pending attributes read-only. Set only read-write attributes in nsim_set_ringparam.

This patch is useful, if netdevsim device is set-up using NetworkManager, because NetworkManager sends 0 as MAX values, as it is pointless to retrieve them in extra call, because they should be read-only. Then, the device is left in incosistent state (value > MAX).

[...]

Here is the summary with links:
- [net] netdevsim: don't overwrite read only ethtool parms

    https://git.kernel.org/netdev/net/c/ee60e626d536

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html