Call the "tc qdisc" command for ingress qdisc without parent
The "tc qdisc" command to create an ingress qdisc does not require to define a parent qdisc [1]. The ingress qdisc "differs from other qdiscs in that it does not occupy the root of a device". The previous command was replacing the default root egress qdisc: root@dev20:~# ip netns exec ns01 tc qdisc show qdisc noqueue 0: dev dummy root refcnt 2 This operation is now not permitted with the new kernel. This patch is also changing how the TC funtional tests interact with the namespace interface created. Now the interface is set to UP before the test starts. That changes the "tc qdisc show" command because now the default qdisc (see the aforementioned CLI output) is now present, as it should be in a live environment (where the interfaces are UP). Closes-Bug: #2034540 [1]https://tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.adv-qdisc.ingress.html Conflicts: neutron/tests/functional/privileged/agent/linux/test_tc_lib.py Change-Id: I2f8130dc3cf3244be2a44a4ecbdbaa9c7f865731 (cherry picked from commit8cba9a2ee8
) (cherry picked from commit37d09f95cd
)
This commit is contained in:
parent
d350db3087
commit
2179c6978d
@ -33,6 +33,7 @@ class TcQdiscTestCase(functional_base.BaseSudoTestCase):
|
|||||||
self.addCleanup(self._remove_ns, self.namespace)
|
self.addCleanup(self._remove_ns, self.namespace)
|
||||||
self.device = 'int_dummy'
|
self.device = 'int_dummy'
|
||||||
priv_ip_lib.create_interface(self.device, self.namespace, 'dummy')
|
priv_ip_lib.create_interface(self.device, self.namespace, 'dummy')
|
||||||
|
priv_ip_lib.set_link_attribute(self.device, self.namespace, state='up')
|
||||||
|
|
||||||
def _remove_ns(self, namespace):
|
def _remove_ns(self, namespace):
|
||||||
priv_ip_lib.remove_netns(namespace)
|
priv_ip_lib.remove_netns(namespace)
|
||||||
@ -52,7 +53,8 @@ class TcQdiscTestCase(functional_base.BaseSudoTestCase):
|
|||||||
namespace=self.namespace)
|
namespace=self.namespace)
|
||||||
qdiscs = priv_tc_lib.list_tc_qdiscs(self.device,
|
qdiscs = priv_tc_lib.list_tc_qdiscs(self.device,
|
||||||
namespace=self.namespace)
|
namespace=self.namespace)
|
||||||
self.assertEqual(0, len(qdiscs))
|
self.assertEqual(1, len(qdiscs))
|
||||||
|
self.assertEqual('noqueue', tc_lib._get_attr(qdiscs[0], 'TCA_KIND'))
|
||||||
|
|
||||||
def test_add_tc_qdisc_htb_no_handle(self):
|
def test_add_tc_qdisc_htb_no_handle(self):
|
||||||
priv_tc_lib.add_tc_qdisc(
|
priv_tc_lib.add_tc_qdisc(
|
||||||
@ -69,7 +71,8 @@ class TcQdiscTestCase(functional_base.BaseSudoTestCase):
|
|||||||
namespace=self.namespace)
|
namespace=self.namespace)
|
||||||
qdiscs = priv_tc_lib.list_tc_qdiscs(self.device,
|
qdiscs = priv_tc_lib.list_tc_qdiscs(self.device,
|
||||||
namespace=self.namespace)
|
namespace=self.namespace)
|
||||||
self.assertEqual(0, len(qdiscs))
|
self.assertEqual(1, len(qdiscs))
|
||||||
|
self.assertEqual('noqueue', tc_lib._get_attr(qdiscs[0], 'TCA_KIND'))
|
||||||
|
|
||||||
def test_add_tc_qdisc_tbf(self):
|
def test_add_tc_qdisc_tbf(self):
|
||||||
burst = 192000
|
burst = 192000
|
||||||
@ -95,23 +98,26 @@ class TcQdiscTestCase(functional_base.BaseSudoTestCase):
|
|||||||
namespace=self.namespace)
|
namespace=self.namespace)
|
||||||
qdiscs = priv_tc_lib.list_tc_qdiscs(self.device,
|
qdiscs = priv_tc_lib.list_tc_qdiscs(self.device,
|
||||||
namespace=self.namespace)
|
namespace=self.namespace)
|
||||||
self.assertEqual(0, len(qdiscs))
|
self.assertEqual(1, len(qdiscs))
|
||||||
|
self.assertEqual('noqueue', tc_lib._get_attr(qdiscs[0], 'TCA_KIND'))
|
||||||
|
|
||||||
def test_add_tc_qdisc_ingress(self):
|
def test_add_tc_qdisc_ingress(self):
|
||||||
priv_tc_lib.add_tc_qdisc(self.device, kind='ingress',
|
priv_tc_lib.add_tc_qdisc(self.device, kind='ingress',
|
||||||
namespace=self.namespace)
|
namespace=self.namespace)
|
||||||
qdiscs = priv_tc_lib.list_tc_qdiscs(self.device,
|
qdiscs = priv_tc_lib.list_tc_qdiscs(self.device,
|
||||||
namespace=self.namespace)
|
namespace=self.namespace)
|
||||||
self.assertEqual(1, len(qdiscs))
|
self.assertEqual(2, len(qdiscs))
|
||||||
self.assertEqual('ingress', tc_lib._get_attr(qdiscs[0], 'TCA_KIND'))
|
self.assertEqual('noqueue', tc_lib._get_attr(qdiscs[0], 'TCA_KIND'))
|
||||||
self.assertEqual(rtnl.TC_H_INGRESS, qdiscs[0]['parent'])
|
self.assertEqual('ingress', tc_lib._get_attr(qdiscs[1], 'TCA_KIND'))
|
||||||
self.assertEqual(0xffff0000, qdiscs[0]['handle'])
|
self.assertEqual(rtnl.TC_H_INGRESS, qdiscs[1]['parent'])
|
||||||
|
self.assertEqual(0xffff0000, qdiscs[1]['handle'])
|
||||||
|
|
||||||
priv_tc_lib.delete_tc_qdisc(self.device, kind='ingress',
|
priv_tc_lib.delete_tc_qdisc(self.device, kind='ingress',
|
||||||
namespace=self.namespace)
|
namespace=self.namespace)
|
||||||
qdiscs = priv_tc_lib.list_tc_qdiscs(self.device,
|
qdiscs = priv_tc_lib.list_tc_qdiscs(self.device,
|
||||||
namespace=self.namespace)
|
namespace=self.namespace)
|
||||||
self.assertEqual(0, len(qdiscs))
|
self.assertEqual(1, len(qdiscs))
|
||||||
|
self.assertEqual('noqueue', tc_lib._get_attr(qdiscs[0], 'TCA_KIND'))
|
||||||
|
|
||||||
def test_delete_tc_qdisc_no_device(self):
|
def test_delete_tc_qdisc_no_device(self):
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
@ -138,14 +144,16 @@ class TcQdiscTestCase(functional_base.BaseSudoTestCase):
|
|||||||
namespace=self.namespace)
|
namespace=self.namespace)
|
||||||
qdiscs = priv_tc_lib.list_tc_qdiscs(self.device,
|
qdiscs = priv_tc_lib.list_tc_qdiscs(self.device,
|
||||||
namespace=self.namespace)
|
namespace=self.namespace)
|
||||||
self.assertEqual(1, len(qdiscs))
|
self.assertEqual(2, len(qdiscs))
|
||||||
self.assertEqual('ingress', tc_lib._get_attr(qdiscs[0], 'TCA_KIND'))
|
self.assertEqual('noqueue', tc_lib._get_attr(qdiscs[0], 'TCA_KIND'))
|
||||||
|
self.assertEqual('ingress', tc_lib._get_attr(qdiscs[1], 'TCA_KIND'))
|
||||||
self.assertIsNone(
|
self.assertIsNone(
|
||||||
priv_tc_lib.delete_tc_qdisc(self.device, kind='ingress',
|
priv_tc_lib.delete_tc_qdisc(self.device, kind='ingress',
|
||||||
namespace=self.namespace))
|
namespace=self.namespace))
|
||||||
qdiscs = priv_tc_lib.list_tc_qdiscs(self.device,
|
qdiscs = priv_tc_lib.list_tc_qdiscs(self.device,
|
||||||
namespace=self.namespace)
|
namespace=self.namespace)
|
||||||
self.assertEqual(0, len(qdiscs))
|
self.assertEqual(1, len(qdiscs))
|
||||||
|
self.assertEqual('noqueue', tc_lib._get_attr(qdiscs[0], 'TCA_KIND'))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
errno.EINVAL,
|
errno.EINVAL,
|
||||||
priv_tc_lib.delete_tc_qdisc(self.device, kind='ingress',
|
priv_tc_lib.delete_tc_qdisc(self.device, kind='ingress',
|
||||||
@ -167,6 +175,7 @@ class TcPolicyClassTestCase(functional_base.BaseSudoTestCase):
|
|||||||
self.addCleanup(self._remove_ns, self.namespace)
|
self.addCleanup(self._remove_ns, self.namespace)
|
||||||
self.device = 'int_dummy'
|
self.device = 'int_dummy'
|
||||||
priv_ip_lib.create_interface('int_dummy', self.namespace, 'dummy')
|
priv_ip_lib.create_interface('int_dummy', self.namespace, 'dummy')
|
||||||
|
priv_ip_lib.set_link_attribute(self.device, self.namespace, state='up')
|
||||||
|
|
||||||
def _remove_ns(self, namespace):
|
def _remove_ns(self, namespace):
|
||||||
priv_ip_lib.remove_netns(namespace)
|
priv_ip_lib.remove_netns(namespace)
|
||||||
@ -248,6 +257,7 @@ class TcFilterClassTestCase(functional_base.BaseSudoTestCase):
|
|||||||
self.addCleanup(self._remove_ns, self.namespace)
|
self.addCleanup(self._remove_ns, self.namespace)
|
||||||
self.device = 'int_dummy'
|
self.device = 'int_dummy'
|
||||||
priv_ip_lib.create_interface('int_dummy', self.namespace, 'dummy')
|
priv_ip_lib.create_interface('int_dummy', self.namespace, 'dummy')
|
||||||
|
priv_ip_lib.set_link_attribute(self.device, self.namespace, state='up')
|
||||||
|
|
||||||
def _remove_ns(self, namespace):
|
def _remove_ns(self, namespace):
|
||||||
priv_ip_lib.remove_netns(namespace)
|
priv_ip_lib.remove_netns(namespace)
|
||||||
@ -274,9 +284,8 @@ class TcFilterClassTestCase(functional_base.BaseSudoTestCase):
|
|||||||
self.assertEqual(value, filter_keys[index])
|
self.assertEqual(value, filter_keys[index])
|
||||||
|
|
||||||
def test_add_tc_filter_policy(self):
|
def test_add_tc_filter_policy(self):
|
||||||
priv_tc_lib.add_tc_qdisc(
|
priv_tc_lib.add_tc_qdisc(self.device, kind='ingress',
|
||||||
self.device, parent=rtnl.TC_H_ROOT, kind='ingress',
|
namespace=self.namespace)
|
||||||
namespace=self.namespace)
|
|
||||||
|
|
||||||
# NOTE(ralonsoh):
|
# NOTE(ralonsoh):
|
||||||
# - rate: 320000 bytes/sec (pyroute2 units) = 2560 kbits/sec (OS units)
|
# - rate: 320000 bytes/sec (pyroute2 units) = 2560 kbits/sec (OS units)
|
||||||
|
Loading…
Reference in New Issue
Block a user