summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-03-03 20:24:46 +0100
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2024-03-04 14:04:44 +0000
commit09abfcbadc2ee664c674a4861d1d450de0be0c53 (patch)
tree5decc9c58254f64b26dbbee6bcce1d6fcb3f72cd /python
parent55f7ec899145279327e03c269bed89358285894b (diff)
downloadvyos-1x-09abfcbadc2ee664c674a4861d1d450de0be0c53.tar.gz
vyos-1x-09abfcbadc2ee664c674a4861d1d450de0be0c53.zip
vyos.ethtool: T6083: use JSON input data for ethernet interface flow-control settings
(cherry picked from commit 5ee89f46096626ca8aac37da9237635e3d17766a)
Diffstat (limited to 'python')
-rw-r--r--python/vyos/ethtool.py21
1 files changed, 8 insertions, 13 deletions
diff --git a/python/vyos/ethtool.py b/python/vyos/ethtool.py
index ccbb97ad4..473c98d0c 100644
--- a/python/vyos/ethtool.py
+++ b/python/vyos/ethtool.py
@@ -62,8 +62,7 @@ class Ethtool:
_driver_name = None
_auto_negotiation = False
_auto_negotiation_supported = None
- _flow_control = False
- _flow_control_enabled = None
+ _flow_control = None
_eee = False
_eee_enabled = None
@@ -115,12 +114,9 @@ class Ethtool:
# Get current flow control settings, but this is not supported by
# all NICs (e.g. vmxnet3 does not support is)
- out, _ = popen(f'ethtool --show-pause {ifname}')
- if len(out.splitlines()) > 1:
- self._flow_control = True
- # read current flow control setting, this returns:
- # ['Autonegotiate:', 'on']
- self._flow_control_enabled = out.splitlines()[1].split()[-1]
+ out, err = popen(f'ethtool --json --show-pause {ifname}')
+ if not bool(err):
+ self._flow_control = loads(out)
# Get current Energy Efficient Ethernet (EEE) settings, but this is
# not supported by all NICs (e.g. vmxnet3 does not support is)
@@ -207,15 +203,14 @@ class Ethtool:
def check_flow_control(self):
""" Check if the NIC supports flow-control """
- if self.get_driver_name() in _drivers_without_speed_duplex_flow:
- return False
- return self._flow_control
+ return bool(self._flow_control)
def get_flow_control(self):
- if self._flow_control_enabled == None:
+ if self._flow_control == None:
raise ValueError('Interface does not support changing '\
'flow-control settings!')
- return self._flow_control_enabled
+
+ return 'on' if bool(self._flow_control[0]['autonegotiate']) else 'off'
def check_eee(self):
""" Check if the NIC supports eee """