aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/net/forwarding/tc_common.sh
diff options
context:
space:
mode:
authorJiri Pirko <jiri@mellanox.com>2018-02-28 12:25:16 +0200
committerDavid S. Miller <davem@davemloft.net>2018-02-28 12:25:48 -0500
commit07e5c75184a11c46eddb08f2435ba4f3e7152e62 (patch)
tree483ed88588c5f49104c106b8cee8245d8ac73e7e /tools/testing/selftests/net/forwarding/tc_common.sh
parentselftests: forwarding: Allow to get netdev interfaces names from commandline (diff)
downloadlinux-dev-07e5c75184a11c46eddb08f2435ba4f3e7152e62.tar.xz
linux-dev-07e5c75184a11c46eddb08f2435ba4f3e7152e62.zip
selftests: forwarding: Introduce tc flower matching tests
Add first part of flower tests. This patch only contains dst/src ip/mac matching. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing/selftests/net/forwarding/tc_common.sh')
-rw-r--r--tools/testing/selftests/net/forwarding/tc_common.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/testing/selftests/net/forwarding/tc_common.sh b/tools/testing/selftests/net/forwarding/tc_common.sh
new file mode 100644
index 000000000000..acd0b520241c
--- /dev/null
+++ b/tools/testing/selftests/net/forwarding/tc_common.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+tc_check_packets()
+{
+ local id=$1
+ local handle=$2
+ local count=$3
+ local ret
+
+ output="$(tc -j -s filter show $id)"
+ # workaround the jq bug which causes jq to return 0 in case input is ""
+ ret=$?
+ if [[ $ret -ne 0 ]]; then
+ return $ret
+ fi
+ echo $output | \
+ jq -e ".[] \
+ | select(.options.handle == $handle) \
+ | select(.options.actions[0].stats.packets == $count)" \
+ &> /dev/null
+ return $?
+}