[PATCH net-next mlxsw v3 08/10] selftests: forwarding: lib: Add DSCP capture
Petr Machata
petrm at mellanox.com
Sat Jul 28 05:10:33 AEST 2018
DSCP captures are TC rules intended to notice packets with a given DSCP
value. Add dscp_capture_install(), dscp_capture_uninstall() and their
helper along the lines of ICMP and VLAN captures already present in
lib.sh.
Complementary to the install and uninstall functions is a function to
collect the capture stats: dscp_fetch_stats().
Signed-off-by: Petr Machata <petrm at mellanox.com>
---
tools/testing/selftests/net/forwarding/lib.sh | 42 +++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 158d59ffee40..d396f89d864d 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -605,6 +605,48 @@ vlan_capture_uninstall()
__vlan_capture_add_del del 100 "$@"
}
+__dscp_capture_add_del()
+{
+ local add_del=$1; shift
+ local dev=$1; shift
+ local base=$1; shift
+ local dscp;
+
+ for prio in {0..7}; do
+ dscp=$((base + prio))
+ __icmp_capture_add_del $add_del $((dscp + 100)) "" $dev \
+ "skip_hw ip_tos $((dscp << 2))"
+ done
+}
+
+dscp_capture_install()
+{
+ local dev=$1; shift
+ local base=$1; shift
+
+ __dscp_capture_add_del add $dev $base
+}
+
+dscp_capture_uninstall()
+{
+ local dev=$1; shift
+ local base=$1; shift
+
+ __dscp_capture_add_del del $dev $base
+}
+
+dscp_fetch_stats()
+{
+ local dev=$1; shift
+ local base=$1; shift
+
+ for prio in {0..7}; do
+ local dscp=$((base + prio))
+ local t=$(tc_rule_stats_get $dev $((dscp + 100)))
+ echo "[$dscp]=$t "
+ done
+}
+
matchall_sink_create()
{
local dev=$1; shift
--
2.4.11
More information about the Linux-mlxsw
mailing list