Use Pyroute2 "add_tc_qdisc" function in l3_tc_lib
Change-Id: I67ddf9d9a6bb2d9d2e8ff0b6345a0118ec37d837 Related-Bug: #1492714
This commit is contained in:
parent
b6cbc95dcb
commit
fb7185bf35
@ -31,8 +31,6 @@ find: RegExpFilter, find, root, find, /sys/class/net, -maxdepth, 1, -type, l, -p
|
||||
ip_exec: IpNetnsExecFilter, ip, root
|
||||
|
||||
# l3_tc_lib
|
||||
l3_tc_add_qdisc_ingress: RegExpFilter, tc, root, tc, qdisc, add, dev, .+, ingress
|
||||
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_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, .+, mtu, 64kb, drop, flowid, :1
|
||||
|
@ -45,11 +45,11 @@ class FloatingIPTcCommandBase(ip_lib.IPDevice):
|
||||
|
||||
def _add_qdisc(self, direction):
|
||||
if direction == constants.EGRESS_DIRECTION:
|
||||
args = ['root', 'handle', '1:', 'htb']
|
||||
tc_lib.add_tc_qdisc(
|
||||
self.name, 'htb', parent='root', namespace=self.namespace)
|
||||
else:
|
||||
args = ['ingress']
|
||||
cmd = ['qdisc', 'add', 'dev', self.name] + args
|
||||
self._execute_tc_cmd(cmd)
|
||||
tc_lib.add_tc_qdisc(
|
||||
self.name, 'ingress', namespace=self.namespace)
|
||||
|
||||
def _get_filters(self, qdisc_id):
|
||||
cmd = ['-p', '-s', '-d', 'filter', 'show', 'dev', self.name,
|
||||
|
@ -149,26 +149,16 @@ class TestFloatingIPTcCommandBase(base.BaseTestCase):
|
||||
q2 = self.tc._get_qdisc_id_for_filter(constants.EGRESS_DIRECTION)
|
||||
self.assertEqual(EGRESS_QDISC_ID, q2)
|
||||
|
||||
def test__add_qdisc(self):
|
||||
@mock.patch.object(base_tc_lib, 'add_tc_qdisc')
|
||||
def test__add_qdisc(self, mock_add_tc_qdisc):
|
||||
self.tc._add_qdisc(constants.INGRESS_DIRECTION)
|
||||
self.execute.assert_called_with(
|
||||
['ip', 'netns', 'exec', FLOATING_IP_ROUTER_NAMESPACE,
|
||||
'tc', 'qdisc', 'add', 'dev', FLOATING_IP_DEVICE_NAME, 'ingress'],
|
||||
run_as_root=True,
|
||||
check_exit_code=True,
|
||||
log_fail_as_error=True,
|
||||
extra_ok_codes=None
|
||||
)
|
||||
mock_add_tc_qdisc.assert_called_once_with(
|
||||
self.tc.name, 'ingress', namespace=self.tc.namespace)
|
||||
|
||||
mock_add_tc_qdisc.reset_mock()
|
||||
self.tc._add_qdisc(constants.EGRESS_DIRECTION)
|
||||
self.execute.assert_called_with(
|
||||
['ip', 'netns', 'exec', FLOATING_IP_ROUTER_NAMESPACE,
|
||||
'tc', 'qdisc', 'add', 'dev',
|
||||
FLOATING_IP_DEVICE_NAME] + ['root', 'handle', '1:', 'htb'],
|
||||
run_as_root=True,
|
||||
check_exit_code=True,
|
||||
log_fail_as_error=True,
|
||||
extra_ok_codes=None
|
||||
)
|
||||
mock_add_tc_qdisc.assert_called_once_with(
|
||||
self.tc.name, 'htb', parent='root', namespace=self.tc.namespace)
|
||||
|
||||
def test__get_filters(self):
|
||||
self.tc._get_filters(INGRESS_QSIC_ID)
|
||||
|
Loading…
x
Reference in New Issue
Block a user