summaryrefslogtreecommitdiff
path: root/python/vyos/qos/trafficshaper.py
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2023-06-17 10:55:33 +0000
committerViacheslav Hletenko <v.gletenko@vyos.io>2023-06-17 11:02:27 +0000
commit04bdcbc8c271ef0286518bc8183a0f911beb16d5 (patch)
tree10e506d616b85e26482c87353c782984d05eaf5e /python/vyos/qos/trafficshaper.py
parent49e2822e9775c1c38a067bdc2e92ab5fd69eac95 (diff)
downloadvyos-1x-04bdcbc8c271ef0286518bc8183a0f911beb16d5.tar.gz
vyos-1x-04bdcbc8c271ef0286518bc8183a0f911beb16d5.zip
T5296: Fix QoS class bandwidth calculation for auto and percent
There are wrong bandwidth calculations for the class We shouldn't rely on interface speed but we should get this value from 'shaper <tag> bandwidth xxx' if configured 'auto' or bandwidth with '%' Otherwise we can get unexpected rate for the class % sudo cat /sys/class/net/eth0/speed % -1 generated rate: classid 1:17 htb rate -1000000 Fix this
Diffstat (limited to 'python/vyos/qos/trafficshaper.py')
-rw-r--r--python/vyos/qos/trafficshaper.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/python/vyos/qos/trafficshaper.py b/python/vyos/qos/trafficshaper.py
index f42f4d022..573283833 100644
--- a/python/vyos/qos/trafficshaper.py
+++ b/python/vyos/qos/trafficshaper.py
@@ -70,7 +70,17 @@ class TrafficShaper(QoSBase):
cls = int(cls)
# bandwidth is a mandatory CLI node
- rate = self._rate_convert(cls_config['bandwidth'])
+ # T5296 if bandwidth 'auto' or 'xx%' get value from config shaper total "bandwidth"
+ # i.e from set shaper test bandwidth '300mbit'
+ # without it, it tries to get value from qos.base /sys/class/net/{self._interface}/speed
+ if cls_config['bandwidth'] == 'auto':
+ rate = self._rate_convert(config['bandwidth'])
+ elif cls_config['bandwidth'].endswith('%'):
+ percent = cls_config['bandwidth'].rstrip('%')
+ rate = self._rate_convert(config['bandwidth']) * int(percent) // 100
+ else:
+ rate = self._rate_convert(cls_config['bandwidth'])
+
burst = cls_config['burst']
quantum = cls_config['codel_quantum']