Page MenuHomeVyOS Platform

QoS policy shaper rate calculations could be wrong for some ethernet devices
Closed, ResolvedPublicBUG

Description

Tested on the virtio interfaces:

vyos@r4:~$ ethtool -i eth1
driver: virtio_net
version: 1.0.0

Trying to get the speed and get unexpected value:

vyos@r4:~$ cat /sys/class/net/eth1/speed
-1

Then this incorrect negative value calculated by this formula
i.e., we will get negative values

bandwidth: -1000000
4% of bandwidth: -40000

To reproduce:

touch /tmp/vyos.qos.debug

set qos policy shaper SHAPER class 10 bandwidth '4%'
set qos policy shaper SHAPER class 10 match lowdelay ip dscp 'lowdelay'
set qos policy shaper SHAPER default bandwidth '2mbit'

set qos interface eth1 egress SHAPER
commit

Debug commit:

{'bandwidth': 'auto',
 'class': {'10': {'bandwidth': '4%',
                  'burst': '15k',
                  'codel_quantum': '1514',
                  'flows': '1024',
                  'interval': '100',
                  'match': {'lowdelay': {'ip': {'dscp': 'lowdelay'}}},
                  'queue_type': 'fq-codel',
                  'target': '5'}},
 'default': {'bandwidth': '2mbit',
             'burst': '15k',
             'codel_quantum': '1514',
             'flows': '1024',
             'interval': '100',
             'priority': '20',
             'queue_type': 'fq-codel',
             'target': '5'}}

WARNING: Interface speed cannot be determined (assuming 10 Mbit/s)

DEBUG/QoS: tc qdisc replace dev eth1 root handle 1: htb r2q 1 default b
DEBUG/QoS: tc class replace dev eth1 parent 1: classid 1:1 htb rate -1000000
DEBUG/QoS: tc class replace dev eth1 parent 1:1 classid 1:a htb rate -40000 burst 15k quantum 1514
DEBUG/QoS: tc class replace dev eth1 parent 1:1 classid 1:b htb rate 2000000 burst 15k quantum 1514 prio 20

DEBUG/QoS: tc qdisc replace dev eth1 parent 1:a sfq
DEBUG/QoS: tc qdisc replace dev eth1 parent 1:b sfq
DEBUG/QoS: tc qdisc replace dev eth1 parent 1:a fq_codel quantum 1514 flows 1024 interval 100 interval 100 target 5 noecn
DEBUG/QoS: tc qdisc replace dev eth1 parent 1:b fq_codel quantum 1514 flows 1024 interval 100 interval 100 target 5 noecn

DEBUG/QoS: tc filter add dev eth1 parent 1: protocol all prio 1 u32 match ip dsfield 16 0xff flowid 1:a
DEBUG/QoS: tc filter add dev eth1 parent 1: protocol all prio 1 u32 match ip dsfield 16 0xff flowid 1:a action police rate -1000000 burst 15k flowid 1:a

WARNING: Interface speed cannot be determined (assuming 10 Mbit/s)

As result, we get incorrect speeds:

vyos@r4# sudo tc class show dev eth1
class htb 1:1 root rate 18446744Tbit ceil 18446744Tbit burst 0b cburst 0b
class htb 1:a parent 1:1 leaf 8003: prio 0 rate 18446744Tbit ceil 18446744Tbit burst 0b cburst 0b
class htb 1:b parent 1:1 leaf 8004: prio 7 rate 2Mbit ceil 2Mbit burst 15Kb cburst 1600b
[edit]
vyos@r4#

Details

Difficulty level
Normal (likely a few hours)
Version
VyOS 1.5-rolling-202401190024
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Unspecified (please specify)

Event Timeline

Viacheslav created this task.
Viacheslav added a project: VyOS 1.4 Sagitta.
Viacheslav renamed this task from QoS policy shaper rate calculations with percent could be wrong for some ethernet devices to QoS policy shaper rate calculations could be wrong for some ethernet devices.Jan 19 2024, 1:13 PM
Viacheslav changed the task status from Open to Needs testing.Jan 19 2024, 8:42 PM
Viacheslav claimed this task.
Viacheslav moved this task from Need Triage to Finished on the VyOS 1.5 Circinus board.
Viacheslav moved this task from Need Triage to Finished on the VyOS 1.4 Sagitta board.