summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2022-04-11 04:44:19 -0400
committerDaniil Baturin <daniil@vyos.io>2022-04-11 04:44:19 -0400
commit7dd917def1e250e63b097f6fd8958b9b07a7d57e (patch)
tree120a17a35bff6eb1a34465bba6c78cc2b7b42064 /python
parent4dc4bbc6ce6ab4a3a531b16619b5c34816366afc (diff)
downloadvyos-1x-7dd917def1e250e63b097f6fd8958b9b07a7d57e.tar.gz
vyos-1x-7dd917def1e250e63b097f6fd8958b9b07a7d57e.zip
T4327: ignore PermissionError caused by ethtool spee/duplex/autoneg setting
Certain NICs seem to fail to report that they don't support speed/duplex setting, so they look as if it's supported, but the command fails in practice. It's probably better to preserve a working config in that case.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/ifconfig/ethernet.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/python/vyos/ifconfig/ethernet.py b/python/vyos/ifconfig/ethernet.py
index 9d54dc78e..1280fc238 100644
--- a/python/vyos/ifconfig/ethernet.py
+++ b/python/vyos/ifconfig/ethernet.py
@@ -170,11 +170,18 @@ class EthernetIf(Interface):
return
cmd = f'ethtool --change {ifname}'
- if speed == 'auto' or duplex == 'auto':
- cmd += ' autoneg on'
- else:
- cmd += f' speed {speed} duplex {duplex} autoneg off'
- return self._cmd(cmd)
+ try:
+ if speed == 'auto' or duplex == 'auto':
+ cmd += ' autoneg on'
+ else:
+ cmd += f' speed {speed} duplex {duplex} autoneg off'
+ return self._cmd(cmd)
+ except PermissionError:
+ # Some NICs do not tell that they don't suppport settings speed/duplex,
+ # but they do not actually support it either.
+ # In that case it's probably better to ignore the error
+ # than end up with a broken config.
+ print('Warning: could not set speed/duplex settings: operation not permitted!')
def set_gro(self, state):
"""