summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2024-01-19 13:21:56 +0000
committerViacheslav Hletenko <v.gletenko@vyos.io>2024-01-19 13:30:14 +0000
commita7fe02e989cf7034609cb833c86143660eb609d5 (patch)
treec7bd182b7a4c3021c30e17d7d5b7f6417dda43ce
parent7f07227a24666195dd268a7a340e9e8b5ed69e0e (diff)
downloadvyos-1x-a7fe02e989cf7034609cb833c86143660eb609d5.tar.gz
vyos-1x-a7fe02e989cf7034609cb833c86143660eb609d5.zip
T5963: Fix QoS shaper rate calculations and set defaul 1Gbit
It is impossible to detect interface speed for some devices for exmaple virtio interfaces: ``` vyos@r4:~$ cat /sys/class/net/eth1/speed -1 ``` It causes wrong negative calcultaions like: - bandwidth: -1000000 - 4% of bandwidth: -40000 tc class replace dev eth1 parent 1: classid 1:1 htb rate -1000000 tc class replace dev eth1 parent 1:1 classid 1:a htb rate -40000 Fix this with checking negative value. Add default interface speed to 1000 Mbit if we cannot detect the interface speed, the current default value 10 Mbit is too low for nowadays
-rw-r--r--python/vyos/qos/base.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/python/vyos/qos/base.py b/python/vyos/qos/base.py
index d8bbfe970..27045043e 100644
--- a/python/vyos/qos/base.py
+++ b/python/vyos/qos/base.py
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 VyOS maintainers and contributors <maintainers@vyos.io>
+# Copyright 2022-2024 VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -166,14 +166,17 @@ class QoSBase:
}
if rate == 'auto' or rate.endswith('%'):
- speed = 10
+ speed = 1000
+ default_speed = speed
# Not all interfaces have valid entries in the speed file. PPPoE
# interfaces have the appropriate speed file, but you can not read it:
# cat: /sys/class/net/pppoe7/speed: Invalid argument
try:
speed = read_file(f'/sys/class/net/{self._interface}/speed')
if not speed.isnumeric():
- Warning('Interface speed cannot be determined (assuming 10 Mbit/s)')
+ Warning('Interface speed cannot be determined (assuming 1000 Mbit/s)')
+ if int(speed) < 1:
+ speed = default_speed
if rate.endswith('%'):
percent = rate.rstrip('%')
speed = int(speed) * int(percent) // 100