diff options
author | Viacheslav Hletenko <v.gletenko@vyos.io> | 2024-02-07 16:34:27 +0000 |
---|---|---|
committer | Mergify <37929162+mergify[bot]@users.noreply.github.com> | 2024-02-07 17:02:13 +0000 |
commit | 6c3c5389bdd3f6b9d40e53596f9f22a2a36bfee9 (patch) | |
tree | fbbea1173c1c929379fecc4b0d08988a11e23d1b /python | |
parent | a0a18c4fa02c9d8aae30950720362d599a8ba6cd (diff) | |
download | vyos-1x-6c3c5389bdd3f6b9d40e53596f9f22a2a36bfee9.tar.gz vyos-1x-6c3c5389bdd3f6b9d40e53596f9f22a2a36bfee9.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
>>>
```
(cherry picked from commit ce1035e1e8642bf740e2a21693a72fe2127b8f72)
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/qos/trafficshaper.py | 2 |
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: |