1 #!/bin/bash 2 # SPDX-License-Identifier: GPL-2.0 3 4 # This test uses standard topology for testing gretap. See 5 # ../../../net/forwarding/mirror_gre_topo_lib.sh for more details. 6 # 7 # Test offloading various features of offloading gretap mirrors specific to 8 # mlxsw. 9 10 lib_dir=$(dirname $0)/../../../net/forwarding 11 12 NUM_NETIFS=6 13 source $lib_dir/lib.sh 14 source $lib_dir/mirror_lib.sh 15 source $lib_dir/mirror_gre_lib.sh 16 source $lib_dir/mirror_gre_topo_lib.sh 17 18 ALL_TESTS=" 19 test_keyful 20 test_soft 21 test_tos_fixed 22 test_ttl_inherit 23 " 24 25 setup_keyful() 26 { 27 tunnel_create gt6-key ip6gretap 2001:db8:3::1 2001:db8:3::2 \ 28 ttl 100 tos inherit allow-localremote \ 29 key 1234 30 31 tunnel_create h3-gt6-key ip6gretap 2001:db8:3::2 2001:db8:3::1 \ 32 key 1234 33 ip link set h3-gt6-key vrf v$h3 34 matchall_sink_create h3-gt6-key 35 36 ip address add dev $swp3 2001:db8:3::1/64 37 ip address add dev $h3 2001:db8:3::2/64 38 } 39 40 cleanup_keyful() 41 { 42 ip address del dev $h3 2001:db8:3::2/64 43 ip address del dev $swp3 2001:db8:3::1/64 44 45 tunnel_destroy h3-gt6-key 46 tunnel_destroy gt6-key 47 } 48 49 setup_soft() 50 { 51 # Set up a topology for testing underlay routes that point at an 52 # unsupported soft device. 53 54 tunnel_create gt6-soft ip6gretap 2001:db8:4::1 2001:db8:4::2 \ 55 ttl 100 tos inherit allow-localremote 56 57 tunnel_create h3-gt6-soft ip6gretap 2001:db8:4::2 2001:db8:4::1 58 ip link set h3-gt6-soft vrf v$h3 59 matchall_sink_create h3-gt6-soft 60 61 ip link add name v1 type veth peer name v2 62 ip link set dev v1 up 63 ip address add dev v1 2001:db8:4::1/64 64 65 ip link set dev v2 vrf v$h3 66 ip link set dev v2 up 67 ip address add dev v2 2001:db8:4::2/64 68 } 69 70 cleanup_soft() 71 { 72 ip link del dev v1 73 74 tunnel_destroy h3-gt6-soft 75 tunnel_destroy gt6-soft 76 } 77 78 setup_prepare() 79 { 80 h1=${NETIFS[p1]} 81 swp1=${NETIFS[p2]} 82 83 swp2=${NETIFS[p3]} 84 h2=${NETIFS[p4]} 85 86 swp3=${NETIFS[p5]} 87 h3=${NETIFS[p6]} 88 89 vrf_prepare 90 mirror_gre_topo_create 91 92 ip address add dev $swp3 2001:db8:2::1/64 93 ip address add dev $h3 2001:db8:2::2/64 94 95 ip address add dev $swp3 192.0.2.129/28 96 ip address add dev $h3 192.0.2.130/28 97 98 setup_keyful 99 setup_soft 100 } 101 102 cleanup() 103 { 104 pre_cleanup 105 106 cleanup_soft 107 cleanup_keyful 108 109 ip address del dev $h3 2001:db8:2::2/64 110 ip address del dev $swp3 2001:db8:2::1/64 111 112 ip address del dev $h3 192.0.2.130/28 113 ip address del dev $swp3 192.0.2.129/28 114 115 mirror_gre_topo_destroy 116 vrf_cleanup 117 } 118 119 test_span_gre_ttl_inherit() 120 { 121 local tundev=$1; shift 122 local type=$1; shift 123 local what=$1; shift 124 125 RET=0 126 127 ip link set dev $tundev type $type ttl inherit 128 mirror_install $swp1 ingress $tundev "matchall" 129 fail_test_span_gre_dir $tundev 130 131 ip link set dev $tundev type $type ttl 100 132 133 quick_test_span_gre_dir $tundev 134 mirror_uninstall $swp1 ingress 135 136 log_test "$what: no offload on TTL of inherit" 137 } 138 139 test_span_gre_tos_fixed() 140 { 141 local tundev=$1; shift 142 local type=$1; shift 143 local what=$1; shift 144 145 RET=0 146 147 ip link set dev $tundev type $type tos 0x10 148 mirror_install $swp1 ingress $tundev "matchall" 149 fail_test_span_gre_dir $tundev 150 151 ip link set dev $tundev type $type tos inherit 152 quick_test_span_gre_dir $tundev 153 mirror_uninstall $swp1 ingress 154 155 log_test "$what: no offload on a fixed TOS" 156 } 157 158 test_span_failable() 159 { 160 local tundev=$1; shift 161 local what=$1; shift 162 163 RET=0 164 165 mirror_install $swp1 ingress $tundev "matchall" 166 fail_test_span_gre_dir $tundev 167 mirror_uninstall $swp1 ingress 168 169 log_test "fail $what" 170 } 171 172 test_keyful() 173 { 174 test_span_failable gt6-key "mirror to keyful gretap" 175 } 176 177 test_soft() 178 { 179 test_span_failable gt6-soft "mirror to gretap w/ soft underlay" 180 } 181 182 test_tos_fixed() 183 { 184 test_span_gre_tos_fixed gt4 gretap "mirror to gretap" 185 test_span_gre_tos_fixed gt6 ip6gretap "mirror to ip6gretap" 186 } 187 188 189 test_ttl_inherit() 190 { 191 test_span_gre_ttl_inherit gt4 gretap "mirror to gretap" 192 test_span_gre_ttl_inherit gt6 ip6gretap "mirror to ip6gretap" 193 } 194 195 trap cleanup EXIT 196 197 setup_prepare 198 setup_wait 199 200 tests_run 201 202 exit $EXIT_STATUS
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.