125 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03 4# This test uses standard topology for testing gretap. See5# mirror_gre_topo_lib.sh for more details.6#7# This tests flower-triggered mirroring to gretap and ip6gretap netdevices. The8# interfaces on H1 and H2 have two addresses each. Flower match on one of the9# addresses is configured with mirror action. It is expected that when pinging10# this address, mirroring takes place, whereas when pinging the other one,11# there's no mirroring.12 13ALL_TESTS="14 test_gretap15 test_ip6gretap16"17 18NUM_NETIFS=619source lib.sh20source mirror_lib.sh21source mirror_gre_lib.sh22source mirror_gre_topo_lib.sh23 24setup_prepare()25{26 h1=${NETIFS[p1]}27 swp1=${NETIFS[p2]}28 29 swp2=${NETIFS[p3]}30 h2=${NETIFS[p4]}31 32 swp3=${NETIFS[p5]}33 h3=${NETIFS[p6]}34 35 vrf_prepare36 mirror_gre_topo_create37 38 ip address add dev $swp3 192.0.2.129/2839 ip address add dev $h3 192.0.2.130/2840 41 ip address add dev $swp3 2001:db8:2::1/6442 ip address add dev $h3 2001:db8:2::2/6443 44 ip address add dev $h1 192.0.2.3/2845 ip address add dev $h2 192.0.2.4/2846}47 48cleanup()49{50 pre_cleanup51 52 ip address del dev $h2 192.0.2.4/2853 ip address del dev $h1 192.0.2.3/2854 55 ip address del dev $h3 2001:db8:2::2/6456 ip address del dev $swp3 2001:db8:2::1/6457 58 ip address del dev $h3 192.0.2.130/2859 ip address del dev $swp3 192.0.2.129/2860 61 mirror_gre_topo_destroy62 vrf_cleanup63}64 65test_span_gre_dir_acl()66{67 local tundev=$1; shift68 local forward_type=$1; shift69 local backward_type=$1; shift70 71 test_span_gre_dir_ips "$tundev" "$forward_type" \72 "$backward_type" 192.0.2.3 192.0.2.473}74 75fail_test_span_gre_dir_acl()76{77 local tundev=$1; shift78 79 fail_test_span_gre_dir_ips "$tundev" 192.0.2.3 192.0.2.480}81 82full_test_span_gre_dir_acl()83{84 local tundev=$1; shift85 local direction=$1; shift86 local forward_type=$1; shift87 local backward_type=$1; shift88 local match_dip=$1; shift89 local what=$1; shift90 91 RET=092 93 mirror_install $swp1 $direction $tundev \94 "protocol ip flower dst_ip $match_dip"95 fail_test_span_gre_dir $tundev96 test_span_gre_dir_acl "$tundev" "$forward_type" "$backward_type"97 mirror_uninstall $swp1 $direction98 99 # Test lack of mirroring after ACL mirror is uninstalled.100 fail_test_span_gre_dir_acl "$tundev"101 102 log_test "$direction $what"103}104 105test_gretap()106{107 full_test_span_gre_dir_acl gt4 ingress 8 0 192.0.2.4 "ACL mirror to gretap"108 full_test_span_gre_dir_acl gt4 egress 0 8 192.0.2.3 "ACL mirror to gretap"109}110 111test_ip6gretap()112{113 full_test_span_gre_dir_acl gt6 ingress 8 0 192.0.2.4 "ACL mirror to ip6gretap"114 full_test_span_gre_dir_acl gt6 egress 0 8 192.0.2.3 "ACL mirror to ip6gretap"115}116 117trap cleanup EXIT118 119setup_prepare120setup_wait121 122tests_run123 124exit $EXIT_STATUS125