Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T5296: Fix QoS class bandwidth calculation for auto and percent #2046

Merged
merged 1 commit into from Jun 17, 2023

Conversation

sever-sever
Copy link
Member

@sever-sever sever-sever commented Jun 17, 2023

Change Summary

There are wrong bandwidth calculations for the class
We shouldn't rely on interface speed, but we should get this value from shaper <tag> bandwidth xxx if configured auto or bandwidth with% like 50%

Otherwise, we can get an unexpected rate for the class

  % sudo cat /sys/class/net/eth0/speed
  % -1

generated rate:
classid 1:17 htb rate -1000000

Fix this

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

Component(s) name

qos, shaper

Proposed changes

How to test

VyOS configuration:

set qos interface eth0 egress 'test'
set qos policy shaper test bandwidth '300mbit'
set qos policy shaper test class 23 bandwidth '50%'
set qos policy shaper test class 23 match 10 ip destination address '192.168.122.11'
set qos policy shaper test default bandwidth '50mbit'
set qos policy shaper test default queue-type 'fair-queue'

debug before fix

DEBUG/QoS: tc qdisc replace dev eth0 root handle 1: htb r2q 187 default 18
DEBUG/QoS: tc class replace dev eth0 parent 1: classid 1:1 htb rate 300000000
DEBUG/QoS: tc class replace dev eth0 parent 1:1 classid 1:17 htb rate -1000000 burst 15k quantum 1514
DEBUG/QoS: tc qdisc replace dev eth0 parent 1:17 sfq
DEBUG/QoS: tc class replace dev eth0 parent 1:1 classid 1:18 htb rate 50000000 burst 15k quantum 1514 prio 20
DEBUG/QoS: tc qdisc replace dev eth0 parent 1:18 sfq
DEBUG/QoS: tc qdisc replace dev eth0 parent 1:17 fq_codel quantum 1514 flows 1024 interval 100 interval 100 target 5 noecn
DEBUG/QoS: tc filter replace dev eth0 parent 1: protocol all u32 match ip dst 192.168.122.11 flowid 1:17

debug after fix

DEBUG/QoS: tc qdisc replace dev eth0 root handle 1: htb r2q 187 default 18
DEBUG/QoS: tc class replace dev eth0 parent 1: classid 1:1 htb rate 300000000
DEBUG/QoS: tc class replace dev eth0 parent 1:1 classid 1:17 htb rate 150000000 burst 15k quantum 1514
DEBUG/QoS: tc qdisc replace dev eth0 parent 1:17 sfq
DEBUG/QoS: tc class replace dev eth0 parent 1:1 classid 1:18 htb rate 50000000 burst 15k quantum 1514 prio 20
DEBUG/QoS: tc qdisc replace dev eth0 parent 1:18 sfq
DEBUG/QoS: tc qdisc replace dev eth0 parent 1:17 fq_codel quantum 1514 flows 1024 interval 100 interval 100 target 5 noecn
DEBUG/QoS: tc filter replace dev eth0 parent 1: protocol all u32 match ip dst 192.168.122.11 flowid 1:17

Expected speed default 50mbit:

vyos@r14# sudo iperf3 -c 192.168.122.1 -t 5
Connecting to host 192.168.122.1, port 5201
[  5] local 192.168.122.14 port 31680 connected to 192.168.122.1 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  7.02 MBytes  58.8 Mbits/sec    0   60.8 KBytes       
[  5]   1.00-2.00   sec  6.21 MBytes  52.1 Mbits/sec    0   53.7 KBytes       
[  5]   2.00-3.00   sec  5.65 MBytes  47.4 Mbits/sec    0   56.6 KBytes       
[  5]   3.00-4.00   sec  5.16 MBytes  43.3 Mbits/sec    0   62.2 KBytes       
[  5]   4.00-5.00   sec  6.28 MBytes  52.7 Mbits/sec    0   56.6 KBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-5.00   sec  30.3 MBytes  50.9 Mbits/sec    0             sender
[  5]   0.00-5.04   sec  28.5 MBytes  47.4 Mbits/sec                  receiver

iperf Done.
[edit]

Expected speed 50% of total bandwidth, i.e. 150 Mbit

vyos@r14# sudo iperf3 -c 192.168.122.11 -t 5
Connecting to host 192.168.122.11, port 5201
[  5] local 192.168.122.14 port 8248 connected to 192.168.122.11 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  18.6 MBytes   156 Mbits/sec  1990    102 KBytes       
[  5]   1.00-2.00   sec  16.8 MBytes   141 Mbits/sec  2017    102 KBytes       
[  5]   2.00-3.00   sec  16.9 MBytes   142 Mbits/sec  2000    116 KBytes       
[  5]   3.00-4.00   sec  16.8 MBytes   141 Mbits/sec  1048   90.5 KBytes       
[  5]   4.00-5.00   sec  16.9 MBytes   142 Mbits/sec  1332   99.0 KBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-5.00   sec  86.0 MBytes   144 Mbits/sec  8387             sender
[  5]   0.00-5.04   sec  84.2 MBytes   140 Mbits/sec                  receiver

iperf Done.

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • I have run the components SMOKETESTS if applicable
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

There are wrong bandwidth calculations for the class
We shouldn't rely on interface speed but we should get this value
from 'shaper <tag> bandwidth xxx' if configured 'auto' or
bandwidth with '%'

Otherwise we can get unexpected rate for the class
  % sudo cat /sys/class/net/eth0/speed
  % -1
generated rate:
  classid 1:17 htb rate -1000000

Fix this
@vyosbot vyosbot requested review from a team, dmbaturin, sarthurdev, zdc, jestabro and c-po and removed request for a team June 17, 2023 11:06
@c-po c-po merged commit 335fff2 into vyos:current Jun 17, 2023
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants