summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2024-02-07 16:34:27 +0000
committerViacheslav Hletenko <v.gletenko@vyos.io>2024-02-07 16:34:27 +0000
commitce1035e1e8642bf740e2a21693a72fe2127b8f72 (patch)
tree87353d1fa2ebb731a832d20b199b2d7f393ef83a /python
parent9d74ae52092e97aa0ef285df4d44a5eb7ae93fbf (diff)
downloadvyos-1x-ce1035e1e8642bf740e2a21693a72fe2127b8f72.tar.gz
vyos-1x-ce1035e1e8642bf740e2a21693a72fe2127b8f72.zip
T6021: Fix QoS shaper r2q calculation
The current calculation `r2q` is wrong as it uses `Floor division` but expecting `division` This way `math.ceil` calculate wrong value as we expect round a number upward to its nearest integer For example for speed 710 mbits expected value `444` but we get `443` ``` from math import ceil MAXQUANTUM = 200000 speed = 710000000 speed_bps = int(speed) // 8 >>> speed_bps // MAXQUANTUM 443 >>> speed_bps / MAXQUANTUM 443.75 >>> >>> >>> ceil(speed_bps // MAXQUANTUM) 443 >>> ceil(speed_bps / MAXQUANTUM) 444 >>> ```
Diffstat (limited to 'python')
-rw-r--r--python/vyos/qos/trafficshaper.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/python/vyos/qos/trafficshaper.py b/python/vyos/qos/trafficshaper.py
index d6705cc77..7d580baa2 100644
--- a/python/vyos/qos/trafficshaper.py
+++ b/python/vyos/qos/trafficshaper.py
@@ -39,7 +39,7 @@ class TrafficShaper(QoSBase):
# need a bigger r2q if going fast than 16 mbits/sec
if (speed_bps // r2q) >= MAXQUANTUM: # integer division
- r2q = ceil(speed_bps // MAXQUANTUM)
+ r2q = ceil(speed_bps / MAXQUANTUM)
else:
# if there is a slow class then may need smaller value
if 'class' in config: