From a1611eb01dd117d9dce6571cb27bac94481fa753 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 10 Nov 2019 22:35:45 +0100 Subject: 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. --- python/vyos/ifconfig.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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( -- cgit v1.2.3