]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ovpn: add basic ethtool support
authorAntonio Quartulli <antonio@openvpn.net>
Tue, 15 Apr 2025 11:17:39 +0000 (13:17 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 17 Apr 2025 10:30:03 +0000 (12:30 +0200)
Implement support for basic ethtool functionality.

Note that ovpn is a virtual device driver, therefore
various ethtool APIs are just not meaningful and thus
not implemented.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20250415-b4-ovpn-v26-22-577f6097b964@openvpn.net
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ovpn/main.c

index 232eeb08e929230afca909bca539ef97892837f5..0acb0934c1bea49c2277aeebefe68dde660f2042 100644 (file)
@@ -7,6 +7,7 @@
  *             James Yonan <james@openvpn.net>
  */
 
+#include <linux/ethtool.h>
 #include <linux/genetlink.h>
 #include <linux/module.h>
 #include <linux/netdevice.h>
@@ -120,6 +121,19 @@ bool ovpn_dev_is_valid(const struct net_device *dev)
        return dev->netdev_ops == &ovpn_netdev_ops;
 }
 
+static void ovpn_get_drvinfo(struct net_device *dev,
+                            struct ethtool_drvinfo *info)
+{
+       strscpy(info->driver, "ovpn", sizeof(info->driver));
+       strscpy(info->bus_info, "ovpn", sizeof(info->bus_info));
+}
+
+static const struct ethtool_ops ovpn_ethtool_ops = {
+       .get_drvinfo            = ovpn_get_drvinfo,
+       .get_link               = ethtool_op_get_link,
+       .get_ts_info            = ethtool_op_get_ts_info,
+};
+
 static void ovpn_setup(struct net_device *dev)
 {
        netdev_features_t feat = NETIF_F_SG | NETIF_F_GSO |
@@ -129,6 +143,7 @@ static void ovpn_setup(struct net_device *dev)
 
        dev->pcpu_stat_type = NETDEV_PCPU_STAT_DSTATS;
 
+       dev->ethtool_ops = &ovpn_ethtool_ops;
        dev->netdev_ops = &ovpn_netdev_ops;
 
        dev->priv_destructor = ovpn_priv_free;