summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-09-15 14:46:03 +0200
committerChristian Poessinger <christian@poessinger.com>2019-09-20 21:28:53 +0200
commit2e210396036ffc769d941104729f67a5f64a0b24 (patch)
tree4b0cac43cf058b7cc3c7fd234b80aa95f4a3cb28 /python
parentf2ca377c2a92e1036c4ff942bd61d3e4bb4f4a18 (diff)
downloadvyos-1x-2e210396036ffc769d941104729f67a5f64a0b24.tar.gz
vyos-1x-2e210396036ffc769d941104729f67a5f64a0b24.zip
Python/ifconfig: T1557: query driver if it supports auto negotiation
Diffstat (limited to 'python')
-rw-r--r--python/vyos/ifconfig.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py
index 9e6c27430..cbedcc86e 100644
--- a/python/vyos/ifconfig.py
+++ b/python/vyos/ifconfig.py
@@ -1085,6 +1085,24 @@ class EthernetIf(VLANIf):
link = os.readlink('/sys/class/net/{}/device/driver/module'.format(self._ifname))
return os.path.basename(link)
+ def has_autoneg(self):
+ """
+ Not all drivers support autonegotiation.
+
+ returns True -> Autonegotiation is supported by driver
+ False -> Autonegotiation is not supported by driver
+ """
+ regex = 'Supports auto-negotiation:[ ]\w+'
+ tmp = self._cmd('/sbin/ethtool {}'.format(self._ifname))
+ tmp = re.search(regex, tmp.decode())
+
+ # Output is either 'Supports auto-negotiation: Yes' or
+ # 'Supports auto-negotiation: No'
+ if tmp.group().split(':')[1].lstrip() == "Yes":
+ return True
+ else:
+ return False
+
def set_flow_control(self, enable):
"""
Changes the pause parameters of the specified Ethernet device.