0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 ALL_TESTS="
0014 test_gretap
0015 test_ip6gretap
0016 "
0017
0018 NUM_NETIFS=6
0019 source lib.sh
0020 source mirror_lib.sh
0021 source mirror_gre_lib.sh
0022 source mirror_gre_topo_lib.sh
0023
0024 setup_prepare()
0025 {
0026 h1=${NETIFS[p1]}
0027 swp1=${NETIFS[p2]}
0028
0029 swp2=${NETIFS[p3]}
0030 h2=${NETIFS[p4]}
0031
0032 swp3=${NETIFS[p5]}
0033 h3=${NETIFS[p6]}
0034
0035 vrf_prepare
0036 mirror_gre_topo_create
0037
0038 ip address add dev $swp3 192.0.2.129/28
0039 ip address add dev $h3 192.0.2.130/28
0040
0041 ip address add dev $swp3 2001:db8:2::1/64
0042 ip address add dev $h3 2001:db8:2::2/64
0043
0044 ip address add dev $h1 192.0.2.3/28
0045 ip address add dev $h2 192.0.2.4/28
0046 }
0047
0048 cleanup()
0049 {
0050 pre_cleanup
0051
0052 ip address del dev $h2 192.0.2.4/28
0053 ip address del dev $h1 192.0.2.3/28
0054
0055 ip address del dev $h3 2001:db8:2::2/64
0056 ip address del dev $swp3 2001:db8:2::1/64
0057
0058 ip address del dev $h3 192.0.2.130/28
0059 ip address del dev $swp3 192.0.2.129/28
0060
0061 mirror_gre_topo_destroy
0062 vrf_cleanup
0063 }
0064
0065 test_span_gre_dir_acl()
0066 {
0067 test_span_gre_dir_ips "$@" 192.0.2.3 192.0.2.4
0068 }
0069
0070 fail_test_span_gre_dir_acl()
0071 {
0072 fail_test_span_gre_dir_ips "$@" 192.0.2.3 192.0.2.4
0073 }
0074
0075 full_test_span_gre_dir_acl()
0076 {
0077 local tundev=$1; shift
0078 local direction=$1; shift
0079 local forward_type=$1; shift
0080 local backward_type=$1; shift
0081 local match_dip=$1; shift
0082 local what=$1; shift
0083
0084 RET=0
0085
0086 mirror_install $swp1 $direction $tundev \
0087 "protocol ip flower $tcflags dst_ip $match_dip"
0088 fail_test_span_gre_dir $tundev $direction
0089 test_span_gre_dir_acl "$tundev" "$direction" \
0090 "$forward_type" "$backward_type"
0091 mirror_uninstall $swp1 $direction
0092
0093
0094 fail_test_span_gre_dir_acl "$tundev" "$direction"
0095
0096 log_test "$direction $what ($tcflags)"
0097 }
0098
0099 test_gretap()
0100 {
0101 full_test_span_gre_dir_acl gt4 ingress 8 0 192.0.2.4 "ACL mirror to gretap"
0102 full_test_span_gre_dir_acl gt4 egress 0 8 192.0.2.3 "ACL mirror to gretap"
0103 }
0104
0105 test_ip6gretap()
0106 {
0107 full_test_span_gre_dir_acl gt6 ingress 8 0 192.0.2.4 "ACL mirror to ip6gretap"
0108 full_test_span_gre_dir_acl gt6 egress 0 8 192.0.2.3 "ACL mirror to ip6gretap"
0109 }
0110
0111 test_all()
0112 {
0113 slow_path_trap_install $swp1 ingress
0114 slow_path_trap_install $swp1 egress
0115
0116 tests_run
0117
0118 slow_path_trap_uninstall $swp1 egress
0119 slow_path_trap_uninstall $swp1 ingress
0120 }
0121
0122 trap cleanup EXIT
0123
0124 setup_prepare
0125 setup_wait
0126
0127 tcflags="skip_hw"
0128 test_all
0129
0130 if ! tc_offload_check; then
0131 echo "WARN: Could not test offloaded functionality"
0132 else
0133 tcflags="skip_sw"
0134 test_all
0135 fi
0136
0137 exit $EXIT_STATUS