From 9e49477700647a390bebc18c02e6ce735d740e0c Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 10 Nov 2019 22:44:32 +0100 Subject: ifconfig: T1793: add delta check on set_speed_duplex() The speend and duplex settings should only be changed when they need to. Always configuring this setting will make the kernel disable and re-enable the physical interface. This will not only let the switchport flap but it will also reset e.g. BGP sessions. This is the first part of this fix for speed/duplex auto settings. In addition - this also reduces the config commit time. --- python/vyos/ifconfig.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'python') diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index cc63482de..24a718e73 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -1139,6 +1139,14 @@ class EthernetIf(VLANIf): .format(self.get_driver_name())) return + # Get current speed and duplex settings: + cmd = '/sbin/ethtool {0}'.format(self._ifname) + tmp = self._cmd(cmd) + + if re.search("\tAuto-negotiation: on", tmp): + if speed == 'auto' or duplex == 'auto': + # bail out early as nothing is to change + return cmd = '/sbin/ethtool -s {}'.format(self._ifname) if speed == 'auto' or duplex == 'auto': -- cgit v1.2.3