Skip to content

Commit 5add2f7

Browse files
spikehdavem330
authored andcommitted
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: 8debcf5 ("netdevsim: add ndo_get_iflink() implementation") Reported-by: Yu Watanabe <[email protected]> Suggested-by: Yu Watanabe <[email protected]> Signed-off-by: David Wei <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0579f27 commit 5add2f7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/net/netdevsim/netdev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,8 @@ static int nsim_get_iflink(const struct net_device *dev)
324324

325325
rcu_read_lock();
326326
peer = rcu_dereference(nsim->peer);
327-
iflink = peer ? READ_ONCE(peer->netdev->ifindex) : 0;
327+
iflink = peer ? READ_ONCE(peer->netdev->ifindex) :
328+
READ_ONCE(dev->ifindex);
328329
rcu_read_unlock();
329330

330331
return iflink;

0 commit comments

Comments
 (0)