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
This commit is contained in:
Rodolfo Alonso Hernandez 2019-04-26 14:39:01 +00:00
parent c24c85c441
commit dbe8d33072
3 changed files with 8 additions and 10 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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)