As for the kernel commit 7a335adad8b0 ("net/sched: cls_matchall: Dump the
classifier flags"), the output format of the "tc filter show" command has
changed to includes the flags identification. Due to the fact that the
switchdev-span recipe parses the tc output, it failed to parse correctly
the output of that command.
Remove the tc output parsing as it can be avoided. This makes the test
more robust and not depend on the specific tc output format.
Signed-off-by: Yotam Gigi <yotamg(a)mellanox.com>
---
recipes/switchdev/l2-021-span.py | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/recipes/switchdev/l2-021-span.py b/recipes/switchdev/l2-021-span.py
index 1d68cd4..251c5e9 100644
--- a/recipes/switchdev/l2-021-span.py
+++ b/recipes/switchdev/l2-021-span.py
@@ -23,6 +23,7 @@ class MirredPort:
mach.run("tc qdisc replace dev %s handle 0: root prio" % devname)
mach.run("tc qdisc add dev %s handle ffff: ingress" % devname)
+ self.pref = [1, 1]
def create_mirror(self, to_port, ingress = False):
ingress_str = "ingress" if ingress else ""
@@ -30,26 +31,17 @@ class MirredPort:
from_dev = self.mirred_port.get_devname()
to_dev = to_port.get_devname()
- self.mach.run("tc filter add dev %s parent %s: matchall skip_sw action \
- mirred egress mirror dev %s" % (from_dev, qdisc_handle,
- to_dev))
-
- def get_mirrors(self, to_port, ingress = False):
- ingress_str = "ingress" if ingress else ""
- from_dev = self.mirred_port.get_devname()
- cmd = self.mach.run("tc filter show dev %s %s" % (from_dev,
- ingress_str))
- output = cmd.out()
- return re.findall("pref (\\d+) .* handle .*\n.* device %s" %
- to_port.get_devname(), output, re.M)
+ self.mach.run("tc filter add dev %s parent %s: pref %d matchall \
+ skip_sw action mirred egress mirror dev %s" % (from_dev,
+ qdisc_handle, self.pref[ingress], to_dev))
+ self.pref[ingress] += 1
def remove_mirror(self, to_port, ingress = False):
- prefs = self.get_mirrors(to_port, ingress)
from_dev = self.mirred_port.get_devname()
ingress_str = "ingress" if ingress else ""
- for pref in prefs:
- self.mach.run("tc filter del dev %s pref %s %s" % (from_dev, pref,
- ingress_str))
+ self.pref[ingress] -= 1
+ self.mach.run("tc filter del dev %s pref %d %s" % (from_dev,
+ self.pref[ingress], ingress_str))
def run_packet_assert(num, main_if, from_if=None, to_if=None):
mach = main_if.get_host()
--
2.4.11