diff options
author | 2018-05-24 16:27:16 +0200 | |
---|---|---|
committer | 2018-05-24 22:26:19 -0400 | |
commit | d5ea2bfc806a92bdeeed9a16e6dddfe44ebc37ec (patch) | |
tree | c706bb13409b86687687c5dcff5424efcba4fb9d /tools/testing/selftests/net/forwarding/mirror_lib.sh | |
parent | selftests: forwarding: Split mirror_gre_topo_lib.sh (diff) | |
download | wireguard-linux-d5ea2bfc806a92bdeeed9a16e6dddfe44ebc37ec.tar.xz wireguard-linux-d5ea2bfc806a92bdeeed9a16e6dddfe44ebc37ec.zip |
selftests: forwarding: mirror_gre_lib: Extract generic functions
For non-GRE mirroring tests, a functions along the lines of
do_test_span_gre_dir_ips() and test_span_gre_dir_ips() are necessary,
but such that they don't assume tunnels are involved. Extract the code
from mirror_gre_lib.sh to mirror_lib.sh and convert to just use a given
device without assuming it's named "h3-$tundev". Convert the two
above-mentioned functions to wrappers that pass along the correct device
name.
Add test_span_dir() and fail_test_span_dir() to round up the API for use
by following patches.
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing/selftests/net/forwarding/mirror_lib.sh')
-rw-r--r-- | tools/testing/selftests/net/forwarding/mirror_lib.sh | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tools/testing/selftests/net/forwarding/mirror_lib.sh b/tools/testing/selftests/net/forwarding/mirror_lib.sh index e5028a5725e3..04cbc38e71a2 100644 --- a/tools/testing/selftests/net/forwarding/mirror_lib.sh +++ b/tools/testing/selftests/net/forwarding/mirror_lib.sh @@ -38,3 +38,57 @@ mirror_test() ((expect <= delta && delta <= expect + 2)) check_err $? "Expected to capture $expect packets, got $delta." } + +do_test_span_dir_ips() +{ + local expect=$1; shift + local dev=$1; shift + local direction=$1; shift + local ip1=$1; shift + local ip2=$1; shift + + icmp_capture_install $dev + mirror_test v$h1 $ip1 $ip2 $dev 100 $expect + mirror_test v$h2 $ip2 $ip1 $dev 100 $expect + icmp_capture_uninstall $dev +} + +quick_test_span_dir_ips() +{ + do_test_span_dir_ips 10 "$@" +} + +fail_test_span_dir_ips() +{ + do_test_span_dir_ips 0 "$@" +} + +test_span_dir_ips() +{ + local dev=$1; shift + local direction=$1; shift + local forward_type=$1; shift + local backward_type=$1; shift + local ip1=$1; shift + local ip2=$1; shift + + quick_test_span_dir_ips "$dev" "$direction" "$ip1" "$ip2" + + icmp_capture_install $dev "type $forward_type" + mirror_test v$h1 $ip1 $ip2 $dev 100 10 + icmp_capture_uninstall $dev + + icmp_capture_install $dev "type $backward_type" + mirror_test v$h2 $ip2 $ip1 $dev 100 10 + icmp_capture_uninstall $dev +} + +fail_test_span_dir() +{ + fail_test_span_dir_ips "$@" 192.0.2.1 192.0.2.2 +} + +test_span_dir() +{ + test_span_dir_ips "$@" 192.0.2.1 192.0.2.2 +} |