diff options
author | Christian Poessinger <christian@poessinger.com> | 2019-09-08 19:52:18 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2019-09-20 21:28:53 +0200 |
commit | 78c0fc6050d05c03bd35c7d4beacef9da432deb3 (patch) | |
tree | 6277aeda58a4f15886ec42b0e03b04dadb01d4e2 /python/vyos | |
parent | eb48a7fde5c37f1c905d1c85aca7d0518f65e652 (diff) | |
download | vyos-1x-78c0fc6050d05c03bd35c7d4beacef9da432deb3.tar.gz vyos-1x-78c0fc6050d05c03bd35c7d4beacef9da432deb3.zip |
Python/ifconfig: T1557: ethernet: support changing flow control
Ethernet flow control can be set by set_flow_control() which enables/disables
generation of pause frames.
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/ifconfig.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index 9b37fdbff..9310ee278 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -1073,6 +1073,25 @@ class EthernetIf(VLANIf): def remove(self): raise OSError('Ethernet interfaces can not be removed') + def set_flow_control(self, enable): + """ + Changes the pause parameters of the specified Ethernet device. + + @param enable: true -> enable pause frames, false -> disable pause frames + """ + if enable not in ['on', 'off']: + raise ValueError("Value out of range") + + # Assemble command executed on system. Unfortunately there is no way + # to change this setting via sysfs + cmd = 'ethtool --pause {0} autoneg {1} tx {1} rx {1}'.format( + self._ifname, enable) + try: + # An exception will be thrown if the settings are not changed + self._cmd(cmd) + except CalledProcessError: + pass + class BondIf(VLANIf): """ |