From 1978abbe9d35571bbf57695f04f4a89550a35b1f Mon Sep 17 00:00:00 2001
From: Christian Poessinger <christian@poessinger.com>
Date: Sun, 15 Sep 2019 13:57:31 +0200
Subject: Python/ifconfig: T1557: add ethernet interface get_driver_name()

---
 python/vyos/ifconfig.py | 8 ++++++++
 1 file changed, 8 insertions(+)

(limited to 'python')

diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py
index 398f2ee8f..de53f8b25 100644
--- a/python/vyos/ifconfig.py
+++ b/python/vyos/ifconfig.py
@@ -1076,6 +1076,14 @@ class EthernetIf(VLANIf):
     def remove(self):
         raise OSError('Ethernet interfaces can not be removed')
 
+    def get_driver_name(self):
+        """
+        Return the driver name used by NIC. Some NICs don't support all
+        features e.g. changing link-speed, duplex
+        """
+        link = os.readlink('/sys/class/net/{}/device/driver/module'.format(self._ifname))
+        return os.path.basename(link)
+
     def set_flow_control(self, enable):
         """
         Changes the pause parameters of the specified Ethernet device.
-- 
cgit v1.2.3