Add a very lightweight helper for handling tc qdiscs.
Signed-off-by: Petr Machata <petrm(a)mellanox.com>
---
recipes/switchdev/TestLib.py | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/recipes/switchdev/TestLib.py b/recipes/switchdev/TestLib.py
index cabce0b..e34161c 100644
--- a/recipes/switchdev/TestLib.py
+++ b/recipes/switchdev/TestLib.py
@@ -1,5 +1,5 @@
"""
-Copyright 2016 Mellanox Technologies. All rights reserved.
+Copyright 2016-2017 Mellanox Technologies. All rights reserved.
Licensed under the GNU General Public License, version 2 as
published by the Free Software Foundation; see COPYING for details.
"""
@@ -469,3 +469,22 @@ class TestLib:
err_msg = "got {} packets, expected {}".format(count, expected)
return self.custom(iface.get_host(), desc, err_msg)
+
+class Qdisc:
+ def __init__(self, iface, handle, qdisc):
+ self._ifname = iface.get_devname()
+ self._machine = iface.get_host()
+ self._handle = handle
+ self.run("tc qdisc add dev %s handle %x: %s"
+ % (self._ifname, self._handle, qdisc))
+
+ def filter_add(self, f):
+ self.run("tc filter add dev %s parent %x: %s"
+ % (self._ifname, self._handle, f))
+
+ def flush(self):
+ self.run("tc filter del dev %s parent %x:"
+ % (self._ifname, self._handle))
+
+ def run(self, command):
+ self._machine.run(command)
--
2.8.4
Show replies by thread