summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Böh <contact@martb.dev>2023-01-27 01:03:28 +0100
committerGitHub <noreply@github.com>2023-01-27 01:03:28 +0100
commit2270a115e2bdb58369a4d1e61378dfb38a4de510 (patch)
treeaeeec2dea809fa71f114e7d3ac5084a0498a82f5
parent0f00cb45f01b1fc90aead2f06d6aa5ac7a02364b (diff)
downloadvyos-1x-2270a115e2bdb58369a4d1e61378dfb38a4de510.tar.gz
vyos-1x-2270a115e2bdb58369a4d1e61378dfb38a4de510.zip
vyos.ethtool: T4963: improve driver name detection
The previous solution did not work for drivers that were no modules. e.g compiled with a kernel config set to CONFIG_VIRTIO_NET=y
-rw-r--r--python/vyos/ethtool.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/python/vyos/ethtool.py b/python/vyos/ethtool.py
index 2b6012a73..abf8de688 100644
--- a/python/vyos/ethtool.py
+++ b/python/vyos/ethtool.py
@@ -56,10 +56,10 @@ class Ethtool:
def __init__(self, ifname):
# Get driver used for interface
- sysfs_file = f'/sys/class/net/{ifname}/device/driver/module'
- if os.path.exists(sysfs_file):
- link = os.readlink(sysfs_file)
- self._driver_name = os.path.basename(link)
+ out, err = popen(f'ethtool --driver {ifname}')
+ driver = re.search(r'driver:\s(\w+)', out)
+ if driver:
+ self._driver_name = driver.group(1)
# Build a dictinary of supported link-speed and dupley settings.
out, err = popen(f'ethtool {ifname}')