summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-11-10 22:44:32 +0100
committerChristian Poessinger <christian@poessinger.com>2019-11-10 22:44:49 +0100
commit9e49477700647a390bebc18c02e6ce735d740e0c (patch)
tree64b75f36d06fe52fafa81ae0620e2f0967032f7a /python/vyos
parenta1611eb01dd117d9dce6571cb27bac94481fa753 (diff)
downloadvyos-1x-9e49477700647a390bebc18c02e6ce735d740e0c.tar.gz
vyos-1x-9e49477700647a390bebc18c02e6ce735d740e0c.zip
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.
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/ifconfig.py8
1 files changed, 8 insertions, 0 deletions
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':