Skip to content

Commit

Permalink
Merge pull request #2861 from vyos/mergify/bp/sagitta/pr-2855
Browse files Browse the repository at this point in the history
T5963: Fix QoS shaper rate calculations and set default 1Gbit (backport #2855)
  • Loading branch information
c-po committed Jan 20, 2024
2 parents 6eb6836 + 885a633 commit a3e6414
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions python/vyos/qos/base.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -166,14 +166,17 @@ def _rate_convert(self, rate) -> int:
}

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
Expand Down

0 comments on commit a3e6414

Please sign in to comment.