summaryrefslogtreecommitdiff
path: root/python/vyos/qos/trafficshaper.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-02-01 20:14:42 +0100
committerGitHub <noreply@github.com>2024-02-01 20:14:42 +0100
commitc7e01e3e9b6b4a598e85f709ebcb8118e50494c3 (patch)
tree53b66074b5487b21323af601a8f013941229ed80 /python/vyos/qos/trafficshaper.py
parent7f17daba3575463d0f5be1761d801a8376716be0 (diff)
parent050b2eb42b0356ff446fe6fed1be4bad1f754f77 (diff)
downloadvyos-1x-c7e01e3e9b6b4a598e85f709ebcb8118e50494c3.tar.gz
vyos-1x-c7e01e3e9b6b4a598e85f709ebcb8118e50494c3.zip
Merge pull request #2919 from vyos/mergify/bp/sagitta/pr-2883
T5974: Fix QoS shape bandwidth and ceil calculation for default (backport #2883)
Diffstat (limited to 'python/vyos/qos/trafficshaper.py')
-rw-r--r--python/vyos/qos/trafficshaper.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/python/vyos/qos/trafficshaper.py b/python/vyos/qos/trafficshaper.py
index 1f3b03680..d6705cc77 100644
--- a/python/vyos/qos/trafficshaper.py
+++ b/python/vyos/qos/trafficshaper.py
@@ -99,7 +99,11 @@ class TrafficShaper(QoSBase):
self._cmd(tmp)
if 'default' in config:
- rate = self._rate_convert(config['default']['bandwidth'])
+ if config['default']['bandwidth'].endswith('%'):
+ percent = config['default']['bandwidth'].rstrip('%')
+ rate = self._rate_convert(config['bandwidth']) * int(percent) // 100
+ else:
+ rate = self._rate_convert(config['default']['bandwidth'])
burst = config['default']['burst']
quantum = config['default']['codel_quantum']
tmp = f'tc class replace dev {self._interface} parent {self._parent:x}:1 classid {self._parent:x}:{default_minor_id:x} htb rate {rate} burst {burst} quantum {quantum}'
@@ -107,7 +111,11 @@ class TrafficShaper(QoSBase):
priority = config['default']['priority']
tmp += f' prio {priority}'
if 'ceiling' in config['default']:
- f_ceil = self._rate_convert(config['default']['ceiling'])
+ if config['default']['ceiling'].endswith('%'):
+ percent = config['default']['ceiling'].rstrip('%')
+ f_ceil = self._rate_convert(config['bandwidth']) * int(percent) // 100
+ else:
+ f_ceil = self._rate_convert(config['default']['ceiling'])
tmp += f' ceil {f_ceil}'
self._cmd(tmp)