diff options
author | Petr Machata <petrm@mellanox.com> | 2018-05-24 16:27:35 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-05-24 22:26:19 -0400 |
commit | 87c0c046e80293af001af95a66c46491ee43130a (patch) | |
tree | a00995d0755bc1dcb78605b344bbefb5264be48a /tools | |
parent | 1893150fd531a1dfacef36e4f43be6cc795c6f50 (diff) |
selftests: forwarding: lib: Extract trap_{, un}install()
A mirror-to-vlan test that's coming next needs to install the trap
unconditionally. Therefore extract from slow_path_trap_{,un}install()
a more generic functions trap_install() and trap_uninstall(), and covert
the former two to conditional wrappers around these.
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/net/forwarding/lib.sh | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 63641ad55074..89ba4cdd4392 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -448,26 +448,35 @@ tc_offload_check() return 0 } -slow_path_trap_install() +trap_install() { local dev=$1; shift local direction=$1; shift - if [ "${tcflags/skip_hw}" != "$tcflags" ]; then - # For slow-path testing, we need to install a trap to get to - # slow path the packets that would otherwise be switched in HW. - tc filter add dev $dev $direction pref 1 \ - flower skip_sw action trap - fi + # For slow-path testing, we need to install a trap to get to + # slow path the packets that would otherwise be switched in HW. + tc filter add dev $dev $direction pref 1 flower skip_sw action trap } -slow_path_trap_uninstall() +trap_uninstall() { local dev=$1; shift local direction=$1; shift + tc filter del dev $dev $direction pref 1 flower skip_sw +} + +slow_path_trap_install() +{ + if [ "${tcflags/skip_hw}" != "$tcflags" ]; then + trap_install "$@" + fi +} + +slow_path_trap_uninstall() +{ if [ "${tcflags/skip_hw}" != "$tcflags" ]; then - tc filter del dev $dev $direction pref 1 flower skip_sw + trap_uninstall "$@" fi } |