diff options
author | Christian Breunig <christian@breunig.cc> | 2023-03-06 08:39:30 +0100 |
---|---|---|
committer | Christian Breunig <christian@breunig.cc> | 2023-03-06 08:39:32 +0100 |
commit | 248e77aad6ca2ab663112240790bf38f48def1fb (patch) | |
tree | a0063bd68872712e846b23bcaec6d2d5f1d88a34 /python/vyos/qos | |
parent | 493af3f3417cef5c9898f242a2b885e63e3bdeef (diff) | |
download | vyos-1x-248e77aad6ca2ab663112240790bf38f48def1fb.tar.gz vyos-1x-248e77aad6ca2ab663112240790bf38f48def1fb.zip |
qos: T4989: bugfix dialer interface - speed detection
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
Diffstat (limited to 'python/vyos/qos')
-rw-r--r-- | python/vyos/qos/base.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/python/vyos/qos/base.py b/python/vyos/qos/base.py index 378e11acf..33bb8ae28 100644 --- a/python/vyos/qos/base.py +++ b/python/vyos/qos/base.py @@ -121,13 +121,20 @@ class QoSBase: } if rate == 'auto' or rate.endswith('%'): - speed = read_file(f'/sys/class/net/{self._interface}/speed') - if not speed.isnumeric(): - Warning('Interface speed cannot be determined (assuming 10 Mbit/s)') - speed = 10 - if rate.endswith('%'): - percent = rate.rstrip('%') - speed = int(speed) * int(percent) // 100 + speed = 10 + # 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)') + if rate.endswith('%'): + percent = rate.rstrip('%') + speed = int(speed) * int(percent) // 100 + except: + pass + return int(speed) *1000000 # convert to MBit/s rate_numeric = int(''.join([n for n in rate if n.isdigit()])) |