diff mbox series

[mac80211-next] virt_wifi: implement ndo_get_iflink

Message ID 20200305090636.28221-1-ap420073@gmail.com (mailing list archive)
State Accepted
Delegated to: Johannes Berg
Headers show
Series [mac80211-next] virt_wifi: implement ndo_get_iflink | expand

Commit Message

Taehee Yoo March 5, 2020, 9:06 a.m. UTC
->ndo_get_iflink() is useful for finding lower interface.

Test commands:
    ip link add dummy0 type dummy
    ip link add vw1 link dummy0 type virt_wifi
    ip link show vw1

Before:
    9: vw1: <BROADCAST,MULTICAST> ...
After:
    9: vw1@dummy0: <BROADCAST,MULTICAST> ...

Signed-off-by: Taehee Yoo <ap420073@gmail.com>
---
 drivers/net/wireless/virt_wifi.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Johannes Berg March 11, 2020, 8:01 a.m. UTC | #1
On Thu, 2020-03-05 at 09:06 +0000, Taehee Yoo wrote:
> ->ndo_get_iflink() is useful for finding lower interface.
> 
> Test commands:
>     ip link add dummy0 type dummy
>     ip link add vw1 link dummy0 type virt_wifi
>     ip link show vw1
> 
> Before:
>     9: vw1: <BROADCAST,MULTICAST> ...
> After:
>     9: vw1@dummy0: <BROADCAST,MULTICAST> ...

So I guess from a netdev layering perspective that makes sense, but I'd
like to hear from Cody if that's really desired from a testing
perspective?

This driver is fundamentally a testing tool and doesn't really have a
place in a production system, so I'd be more likely to look at the
testing needs for this.

Thanks,
johannes
diff mbox series

Patch

diff --git a/drivers/net/wireless/virt_wifi.c b/drivers/net/wireless/virt_wifi.c
index 01305ba2d3aa..c878097f0dda 100644
--- a/drivers/net/wireless/virt_wifi.c
+++ b/drivers/net/wireless/virt_wifi.c
@@ -436,10 +436,18 @@  static int virt_wifi_net_device_stop(struct net_device *dev)
 	return 0;
 }
 
+static int virt_wifi_net_device_get_iflink(const struct net_device *dev)
+{
+	struct virt_wifi_netdev_priv *priv = netdev_priv(dev);
+
+	return priv->lowerdev->ifindex;
+}
+
 static const struct net_device_ops virt_wifi_ops = {
 	.ndo_start_xmit = virt_wifi_start_xmit,
-	.ndo_open = virt_wifi_net_device_open,
-	.ndo_stop = virt_wifi_net_device_stop,
+	.ndo_open	= virt_wifi_net_device_open,
+	.ndo_stop	= virt_wifi_net_device_stop,
+	.ndo_get_iflink = virt_wifi_net_device_get_iflink,
 };
 
 /* Invoked as part of rtnl lock release. */