selftests: forwarding: lib: Extract trap_{, un}install()
[linux-2.6-microblaze.git] / tools / testing / selftests / net / forwarding / lib.sh
index 63641ad..89ba4cd 100644 (file)
@@ -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
 }