netdevsim: fix backwards compatibility in nsim_get_iflink()
authorDavid Wei <dw@davidwei.uk>
Thu, 6 Jun 2024 14:59:08 +0000 (07:59 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 10 Jun 2024 10:51:04 +0000 (11:51 +0100)
commit5add2f7288468f35a374620dabf126c13baaea9c
tree339666a05cbfd21809538d016bc81df4f4d19e6c
parent0579f27249047006a818e463ee66a6c314d04cea
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")
Reported-by: Yu Watanabe <watanabe.yu@gmail.com>
Suggested-by: Yu Watanabe <watanabe.yu@gmail.com>
Signed-off-by: David Wei <dw@davidwei.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/netdevsim/netdev.c