vxlan: implement get_link_ksettings ethtool method
authorMatthias Schiffer <mschiffer@universe-factory.net>
Tue, 12 Nov 2019 21:12:24 +0000 (22:12 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 13 Nov 2019 03:52:15 +0000 (19:52 -0800)
Similar to VLAN and similar drivers, we can forward get_link_ksettings to
the lower dev if we have one to get meaningful speed/duplex data.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/vxlan.c

index 11f5776affb170ed8ee5c997e4103a6e43f6e01a..bf04bc2e68c2f96523dd8c30c746fcd28934a150 100644 (file)
@@ -3175,9 +3175,29 @@ static void vxlan_get_drvinfo(struct net_device *netdev,
        strlcpy(drvinfo->driver, "vxlan", sizeof(drvinfo->driver));
 }
 
+static int vxlan_get_link_ksettings(struct net_device *dev,
+                                   struct ethtool_link_ksettings *cmd)
+{
+       struct vxlan_dev *vxlan = netdev_priv(dev);
+       struct vxlan_rdst *dst = &vxlan->default_dst;
+       struct net_device *lowerdev = __dev_get_by_index(vxlan->net,
+                                                        dst->remote_ifindex);
+
+       if (!lowerdev) {
+               cmd->base.duplex = DUPLEX_UNKNOWN;
+               cmd->base.port = PORT_OTHER;
+               cmd->base.speed = SPEED_UNKNOWN;
+
+               return 0;
+       }
+
+       return __ethtool_get_link_ksettings(lowerdev, cmd);
+}
+
 static const struct ethtool_ops vxlan_ethtool_ops = {
-       .get_drvinfo    = vxlan_get_drvinfo,
-       .get_link       = ethtool_op_get_link,
+       .get_drvinfo            = vxlan_get_drvinfo,
+       .get_link               = ethtool_op_get_link,
+       .get_link_ksettings     = vxlan_get_link_ksettings,
 };
 
 static struct socket *vxlan_create_sock(struct net *net, bool ipv6,