summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-11-11 19:42:11 +0100
committerChristian Poessinger <christian@poessinger.com>2019-11-11 20:03:49 +0100
commitc9c8cd50f4165c7f86e71a6723f0ebb3a2cbdaf5 (patch)
tree7efbf4df605c097770d2b595c422fa37ceff3299
parentb8ea719ba035e52879b65157d01b60f67ca73868 (diff)
downloadvyos-1x-c9c8cd50f4165c7f86e71a6723f0ebb3a2cbdaf5.tar.gz
vyos-1x-c9c8cd50f4165c7f86e71a6723f0ebb3a2cbdaf5.zip
ifconfig: T1793: extend set_speed_duplex() delta check
Commit 9e4947770064 ("ifconfig: T1793: add delta check on set_speed_duplex()") was wave1 of reducing the amount of switch-port flaps and BGP session resets. The delta check now also handles the case of fixed speed and duplex settings.
-rw-r--r--python/vyos/ifconfig.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py
index 24a718e73..279d948b7 100644
--- a/python/vyos/ifconfig.py
+++ b/python/vyos/ifconfig.py
@@ -1144,7 +1144,24 @@ class EthernetIf(VLANIf):
tmp = self._cmd(cmd)
if re.search("\tAuto-negotiation: on", tmp):
- if speed == 'auto' or duplex == 'auto':
+ if speed == 'auto' and duplex == 'auto':
+ # bail out early as nothing is to change
+ return
+ else:
+ # read in current speed and duplex settings
+ cur_speed = 0
+ cur_duplex = ''
+ for line in tmp.splitlines():
+ if line.lstrip().startswith("Speed:"):
+ non_decimal = re.compile(r'[^\d.]+')
+ cur_speed = non_decimal.sub('', line)
+ continue
+
+ if line.lstrip().startswith("Duplex:"):
+ cur_duplex = line.split()[-1].lower()
+ break
+
+ if (cur_speed == speed) and (cur_duplex == duplex):
# bail out early as nothing is to change
return