Skip to contentSkip to conversation

netdevsim: fix backwards compatibility in nsim_get_iflink()

PATCH Applied David Wei 2 participants 2 messages Jun 6, 2024 – Jun 10, 2024

Subsystems (3)
lore
Share & tools
lore

David Wei

author
#0 lore raw

PATCH 1/1 netdevsim: fix backwards compatibility in nsim_get_iflink()

The default ndo_get_iflink() implementation returns the current ifindex of the netdev. But the overridden nsim_get_iflink() returns 0 if the current nsim is not linked, breaking backwards compatibility for userspace that depend on this behaviour.

Fix the problem by returning the current ifindex if not linked to a peer.

Fixes 8debcf5832c3 ("netdevsim: add ndo_get_iflink() implementation")
---
 drivers/net/netdevsim/netdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/netdevsim/netdev.c +2 -1
index c22897bf5509..017a6102be0a 100644
@@ -324,7 +324,8 @@ static int nsim_get_iflink(const struct net_device *dev)
 
 	rcu_read_lock();
 	peer = rcu_dereference(nsim->peer);
-	iflink = peer ? READ_ONCE(peer->netdev->ifindex) : 0;
+	iflink = peer ? READ_ONCE(peer->netdev->ifindex) :
+			READ_ONCE(dev->ifindex);
 	rcu_read_unlock();
 
 	return iflink;
Signature · 1 line
2.43.0
#1 lore raw
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:

Quoted 9 lines · On Thu, 6 Jun 2024 07:59:08 -0700 you wrote:

The default ndo_get_iflink() implementation returns the current ifindex of the netdev. But the overridden nsim_get_iflink() returns 0 if the current nsim is not linked, breaking backwards compatibility for userspace that depend on this behaviour.

Fix the problem by returning the current ifindex if not linked to a peer.

[...]

Here is the summary with links:
- [net] netdevsim: fix backwards compatibility in nsim_get_iflink()

    https://git.kernel.org/netdev/net/c/5add2f728846

You are awesome, thank you!

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