Make L3 IP tc filter rate limit more accurate

Currently the L3 agent qos extension does not set the mtu for
tc filter rules, the default value is 2kb. Tc filter rules use
such mtu will result in an inaccurate bandwidth.

So in order to improve the precision, we set the mtu to 64kb.
For the test results, you can read the bug description.

For more information you can read the linux tc man page:
[1] https://linux.die.net/man/8/tc-tbf
[2] http://man7.org/linux/man-pages/man8/tc-police.8.html

Closes-Bug: #1777598
Change-Id: I7a167ec6139ccc55988b34f82080a182116d02a3
This commit is contained in:
LIU Yulong 2018-06-15 16:02:36 -04:00
parent abbd534fdf
commit 5ddb2a4762
3 changed files with 5 additions and 5 deletions

View File

@ -40,8 +40,8 @@ l3_tc_add_qdisc_ingress: RegExpFilter, tc, root, tc, qdisc, add, dev, .+, ingres
l3_tc_add_qdisc_egress: RegExpFilter, tc, root, tc, qdisc, add, dev, .+, root, handle, 1:, htb l3_tc_add_qdisc_egress: RegExpFilter, tc, root, tc, qdisc, add, dev, .+, root, handle, 1:, htb
l3_tc_show_filters: RegExpFilter, tc, root, tc, -p, -s, -d, filter, show, dev, .+, parent, .+, prio, 1 l3_tc_show_filters: RegExpFilter, tc, root, tc, -p, -s, -d, filter, show, dev, .+, parent, .+, prio, 1
l3_tc_delete_filters: RegExpFilter, tc, root, tc, filter, del, dev, .+, parent, .+, prio, 1, handle, .+, u32 l3_tc_delete_filters: RegExpFilter, tc, root, tc, filter, del, dev, .+, parent, .+, prio, 1, handle, .+, u32
l3_tc_add_filter_ingress: RegExpFilter, tc, root, tc, filter, add, dev, .+, parent, .+, protocol, ip, prio, 1, u32, match, ip, dst, .+, police, rate, .+, burst, .+, drop, flowid, :1 l3_tc_add_filter_ingress: RegExpFilter, tc, root, tc, filter, add, dev, .+, parent, .+, protocol, ip, prio, 1, u32, match, ip, dst, .+, police, rate, .+, burst, .+, mtu, 64kb, drop, flowid, :1
l3_tc_add_filter_egress: RegExpFilter, tc, root, tc, filter, add, dev, .+, parent, .+, protocol, ip, prio, 1, u32, match, ip, src, .+, police, rate, .+, burst, .+, drop, flowid, :1 l3_tc_add_filter_egress: RegExpFilter, tc, root, tc, filter, add, dev, .+, parent, .+, protocol, ip, prio, 1, u32, match, ip, src, .+, police, rate, .+, burst, .+, mtu, 64kb, drop, flowid, :1
# For ip monitor # For ip monitor
kill_ip_monitor: KillFilter, root, ip, -9 kill_ip_monitor: KillFilter, root, ip, -9

View File

@ -117,7 +117,7 @@ class FloatingIPTcCommandBase(ip_lib.IPDevice):
_match = 'src' if direction == constants.EGRESS_DIRECTION else 'dst' _match = 'src' if direction == constants.EGRESS_DIRECTION else 'dst'
match = ['u32', 'match', 'ip', _match, ip] match = ['u32', 'match', 'ip', _match, ip]
police = ['police', 'rate', rate_value, 'burst', burst_value, police = ['police', 'rate', rate_value, 'burst', burst_value,
'drop', 'flowid', ':1'] 'mtu', '64kb', 'drop', 'flowid', ':1']
args = protocol + prio + match + police args = protocol + prio + match + police
cmd = ['filter', 'add', 'dev', self.name, cmd = ['filter', 'add', 'dev', self.name,
'parent', qdisc_id] + args 'parent', qdisc_id] + args

View File

@ -227,7 +227,7 @@ class TestFloatingIPTcCommandBase(base.BaseTestCase):
prio = ['prio', 1] prio = ['prio', 1]
match = ['u32', 'match', 'ip', 'dst', FLOATING_IP_1] match = ['u32', 'match', 'ip', 'dst', FLOATING_IP_1]
police = ['police', 'rate', '1kbit', 'burst', '1kbit', police = ['police', 'rate', '1kbit', 'burst', '1kbit',
'drop', 'flowid', ':1'] 'mtu', '64kb', 'drop', 'flowid', ':1']
args = protocol + prio + match + police args = protocol + prio + match + police
cmd = ['tc', 'filter', 'add', 'dev', FLOATING_IP_DEVICE_NAME, cmd = ['tc', 'filter', 'add', 'dev', FLOATING_IP_DEVICE_NAME,
'parent', INGRESS_QSIC_ID] + args 'parent', INGRESS_QSIC_ID] + args
@ -329,7 +329,7 @@ class TestFloatingIPTcCommand(base.BaseTestCase):
_match = 'dst' _match = 'dst'
match = ['u32', 'match', 'ip', _match, ip] match = ['u32', 'match', 'ip', _match, ip]
police = ['police', 'rate', '1kbit', 'burst', '1kbit', police = ['police', 'rate', '1kbit', 'burst', '1kbit',
'drop', 'flowid', ':1'] 'mtu', '64kb', 'drop', 'flowid', ':1']
args = protocol + prio + match + police args = protocol + prio + match + police
self.execute.assert_called_once_with( self.execute.assert_called_once_with(