From dbe8d330727ec3ed4822124c454e00e8e3055b7d Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Fri, 26 Apr 2019 14:39:01 +0000 Subject: [PATCH] Only TC class "htb" is supported In tc_lib.add_tc_policy_class [1], only "htb" type is supported. [1]https://opendev.org/openstack/neutron/src/branch/stable/stein/neutron/agent/linux/tc_lib.py#L379 Change-Id: I2cb809c069c0e8cdd289b9977cb335ef3e2e3931 Closes-Bug: #1826557 --- neutron/agent/linux/tc_lib.py | 8 +++----- neutron/privileged/agent/linux/tc_lib.py | 4 ++-- neutron/tests/unit/agent/linux/test_tc_lib.py | 6 +++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/neutron/agent/linux/tc_lib.py b/neutron/agent/linux/tc_lib.py index 54876903393..20bccb4a7bc 100644 --- a/neutron/agent/linux/tc_lib.py +++ b/neutron/agent/linux/tc_lib.py @@ -376,15 +376,13 @@ def delete_tc_qdisc(device, parent=None, is_ingress=False, raise_qdisc_not_found=raise_qdisc_not_found, namespace=namespace) -def add_tc_policy_class(device, parent, classid, qdisc_type, - min_kbps=None, max_kbps=None, burst_kb=None, - namespace=None): +def add_tc_policy_class(device, parent, classid, min_kbps=None, max_kbps=None, + burst_kb=None, namespace=None): """Add a TC policy class :param device: (string) device name :param parent: (string) qdisc parent class ('root', 'ingress', '2:10') :param classid: (string) major:minor handler identifier ('10:20') - :param qdisc_type: (string) qdisc type ("sfq", "htb", "u32", etc) :param min_kbps: (int) (optional) minimum bandwidth in kbps :param max_kbps: (int) (optional) maximum bandwidth in kbps :param burst_kb: (int) (optional) burst size in kb @@ -404,7 +402,7 @@ def add_tc_policy_class(device, parent, classid, qdisc_type, args['ceil'] = int(max_kbps * 1024 / 8) if burst_kb: args['burst'] = int(burst_kb * 1024 / 8) - priv_tc_lib.add_tc_policy_class(device, parent, classid, qdisc_type, + priv_tc_lib.add_tc_policy_class(device, parent, classid, 'htb', namespace=namespace, **args) diff --git a/neutron/privileged/agent/linux/tc_lib.py b/neutron/privileged/agent/linux/tc_lib.py index b36fde389f0..54752382508 100644 --- a/neutron/privileged/agent/linux/tc_lib.py +++ b/neutron/privileged/agent/linux/tc_lib.py @@ -98,13 +98,13 @@ def delete_tc_qdisc(device, parent=None, kind=None, namespace=None, @privileged.default.entrypoint -def add_tc_policy_class(device, parent, classid, qdisc_type, namespace=None, +def add_tc_policy_class(device, parent, classid, class_type, namespace=None, **kwargs): """Add/replace TC policy class""" try: index = ip_lib.get_link_id(device, namespace) with ip_lib.get_iproute(namespace) as ip: - ip.tc('replace-class', kind=qdisc_type, index=index, + ip.tc('replace-class', kind=class_type, index=index, handle=classid, parent=parent, **kwargs) except OSError as e: if e.errno == errno.ENOENT: diff --git a/neutron/tests/unit/agent/linux/test_tc_lib.py b/neutron/tests/unit/agent/linux/test_tc_lib.py index 435eef2bb9a..3ad99844a96 100644 --- a/neutron/tests/unit/agent/linux/test_tc_lib.py +++ b/neutron/tests/unit/agent/linux/test_tc_lib.py @@ -330,10 +330,10 @@ class TcPolicyClassTestCase(base.BaseTestCase): def test_add_tc_policy_class(self): tc_lib.add_tc_policy_class( - 'device', 'root', '1:10', 'qdisc_type', min_kbps=1000, - max_kbps=2000, burst_kb=1600, namespace=self.namespace) + 'device', 'root', '1:10', min_kbps=1000, max_kbps=2000, + burst_kb=1600, namespace=self.namespace) self.mock_add_tc_policy_class.assert_called_once_with( - 'device', rtnl.TC_H_ROOT, '1:10', 'qdisc_type', rate=1000 * 128, + 'device', rtnl.TC_H_ROOT, '1:10', 'htb', rate=1000 * 128, ceil=2000 * 128, burst=1600 * 128, namespace=self.namespace) @mock.patch('pyroute2.netlink.rtnl.tcmsg.common.tick_in_usec', 15.625)