From 7dd917def1e250e63b097f6fd8958b9b07a7d57e Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Mon, 11 Apr 2022 04:44:19 -0400 Subject: 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. --- python/vyos/ifconfig/ethernet.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'python') 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): """ -- cgit v1.2.3