diff options
| -rw-r--r-- | python/vyos/vpp/control_host.py | 15 | ||||
| -rwxr-xr-x | src/conf_mode/vpp.py | 2 |
2 files changed, 10 insertions, 7 deletions
diff --git a/python/vyos/vpp/control_host.py b/python/vyos/vpp/control_host.py index 6a6b9d72f..db1a492c9 100644 --- a/python/vyos/vpp/control_host.py +++ b/python/vyos/vpp/control_host.py @@ -23,6 +23,7 @@ from time import sleep from pyroute2 import IPRoute +from vyos.ethtool import Ethtool from vyos.vpp.utils import EthtoolGDrvinfo @@ -266,14 +267,16 @@ def get_eth_driver(iface: str) -> str: Returns: str: kernel module name """ - iface_driver: str = '' driver_dir = Path(f'/sys/class/net/{iface}/device/driver/module') - if not driver_dir.exists(): - # raise error if device was not found - raise FileNotFoundError(f'PCI device {iface} not found in ethernet interfaces') + # Try to detect via sysfs (works for PCI devices) + if driver_dir.exists(): + return driver_dir.resolve().name - iface_driver: str = driver_dir.resolve().name - return iface_driver + # Fallback: use ethtool (works for veth, tun, etc.) + try: + return Ethtool(iface).get_driver_name() + except Exception as error: + raise Exception(f'Could not determine driver for "{iface}": {error}') from error def unsafe_noiommu_mode(status: bool) -> None: diff --git a/src/conf_mode/vpp.py b/src/conf_mode/vpp.py index 2d8c17e4f..204d8c6b7 100755 --- a/src/conf_mode/vpp.py +++ b/src/conf_mode/vpp.py @@ -609,7 +609,7 @@ def initialize_interface(iface, driver, iface_config) -> None: try: if control_host.get_eth_driver(f'defunct_{iface}') == 'mlx5_core': control_host.rename_iface(f'defunct_{iface}', iface) - except FileNotFoundError: + except Exception: pass # Replace a driver with original for VMBus interfaces and rename it |
