summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-11-10 22:35:45 +0100
committerChristian Poessinger <christian@poessinger.com>2019-11-10 22:41:13 +0100
commita1611eb01dd117d9dce6571cb27bac94481fa753 (patch)
treec8d371ba9defaf1cdd10821a6e1b7f56d1b54527 /python/vyos
parent1a20fbccfccce7fa47c2028ccbb1403182739c3e (diff)
downloadvyos-1x-a1611eb01dd117d9dce6571cb27bac94481fa753.tar.gz
vyos-1x-a1611eb01dd117d9dce6571cb27bac94481fa753.zip
ifconfig: T1793: add delta check on set_flow_control()
The flow control settings should only be changed when they need to. If flow control is altered, the kernel will disable and re-enable the interface. This will not only let the switchport flap but it will also reset e.g. BGP sessions. In addition - this also reduces the config commit time.
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/ifconfig.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py
index 8a4ad6ffc..cc63482de 100644
--- a/python/vyos/ifconfig.py
+++ b/python/vyos/ifconfig.py
@@ -21,6 +21,7 @@ import glob
import time
import vyos.interfaces
+
from vyos.validate import *
from vyos.config import Config
from vyos import ConfigError
@@ -1085,6 +1086,24 @@ class EthernetIf(VLANIf):
.format(self.get_driver_name()))
return
+ # Get current flow control settings:
+ cmd = '/sbin/ethtool --show-pause {0}'.format(self._ifname)
+ tmp = self._cmd(cmd)
+
+ # The above command returns - with tabs:
+ #
+ # Pause parameters for eth0:
+ # Autonegotiate: on
+ # RX: off
+ # TX: off
+ if re.search("Autonegotiate:\ton", tmp):
+ if enable == "on":
+ # flowcontrol is already enabled - no need to re-enable it again
+ # this will prevent the interface from flapping as applying the
+ # flow-control settings will take the interface down and bring
+ # it back up every time.
+ return
+
# Assemble command executed on system. Unfortunately there is no way
# to change this setting via sysfs
cmd = '/sbin/ethtool --pause {0} autoneg {1} tx {1} rx {1}'.format(