Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: forwarding: lib: Avoid trapping soft devices

There are several cases where traffic that would normally be forwarded
in silicon needs to be observed in slow path. That's achieved by
trapping such traffic, and the functions trap_install() and
trap_uninstall() realize that. However, such treatment is obviously
wrong if the device in question is actually a soft device not backed by
an ASIC.

Therefore try to trap if possible, but fall back to inserting a continue
if not.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Petr Machata and committed by
David S. Miller
ac0fcadf 010079ba

+12 -4
+12 -4
tools/testing/selftests/net/forwarding/lib.sh
··· 479 479 local dev=$1; shift 480 480 local direction=$1; shift 481 481 482 - # For slow-path testing, we need to install a trap to get to 483 - # slow path the packets that would otherwise be switched in HW. 484 - tc filter add dev $dev $direction pref 1 flower skip_sw action trap 482 + # Some devices may not support or need in-hardware trapping of traffic 483 + # (e.g. the veth pairs that this library creates for non-existent 484 + # loopbacks). Use continue instead, so that there is a filter in there 485 + # (some tests check counters), and so that other filters are still 486 + # processed. 487 + tc filter add dev $dev $direction pref 1 \ 488 + flower skip_sw action trap 2>/dev/null \ 489 + || tc filter add dev $dev $direction pref 1 \ 490 + flower action continue 485 491 } 486 492 487 493 trap_uninstall() ··· 495 489 local dev=$1; shift 496 490 local direction=$1; shift 497 491 498 - tc filter del dev $dev $direction pref 1 flower skip_sw 492 + tc filter del dev $dev $direction pref 1 flower 499 493 } 500 494 501 495 slow_path_trap_install() 502 496 { 497 + # For slow-path testing, we need to install a trap to get to 498 + # slow path the packets that would otherwise be switched in HW. 503 499 if [ "${tcflags/skip_hw}" != "$tcflags" ]; then 504 500 trap_install "$@" 505 501 fi