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#