From 04bdcbc8c271ef0286518bc8183a0f911beb16d5 Mon Sep 17 00:00:00 2001 From: Viacheslav Hletenko Date: Sat, 17 Jun 2023 10:55:33 +0000 Subject: 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 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 --- python/vyos/qos/trafficshaper.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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'] -- cgit v1.2.3