WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / drivers / net / mlxsw / mirror_gre.sh
blob76f1ab4898d96e09d1c52dfd44cc085a965fba6c
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # This test uses standard topology for testing gretap. See
5 # ../../../net/forwarding/mirror_gre_topo_lib.sh for more details.
7 # Test offloading various features of offloading gretap mirrors specific to
8 # mlxsw.
10 lib_dir=$(dirname $0)/../../../net/forwarding
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
18 setup_keyful()
20 tunnel_create gt6-key ip6gretap 2001:db8:3::1 2001:db8:3::2 \
21 ttl 100 tos inherit allow-localremote \
22 key 1234
24 tunnel_create h3-gt6-key ip6gretap 2001:db8:3::2 2001:db8:3::1 \
25 key 1234
26 ip link set h3-gt6-key vrf v$h3
27 matchall_sink_create h3-gt6-key
29 ip address add dev $swp3 2001:db8:3::1/64
30 ip address add dev $h3 2001:db8:3::2/64
33 cleanup_keyful()
35 ip address del dev $h3 2001:db8:3::2/64
36 ip address del dev $swp3 2001:db8:3::1/64
38 tunnel_destroy h3-gt6-key
39 tunnel_destroy gt6-key
42 setup_soft()
44 # Set up a topology for testing underlay routes that point at an
45 # unsupported soft device.
47 tunnel_create gt6-soft ip6gretap 2001:db8:4::1 2001:db8:4::2 \
48 ttl 100 tos inherit allow-localremote
50 tunnel_create h3-gt6-soft ip6gretap 2001:db8:4::2 2001:db8:4::1
51 ip link set h3-gt6-soft vrf v$h3
52 matchall_sink_create h3-gt6-soft
54 ip link add name v1 type veth peer name v2
55 ip link set dev v1 up
56 ip address add dev v1 2001:db8:4::1/64
58 ip link set dev v2 vrf v$h3
59 ip link set dev v2 up
60 ip address add dev v2 2001:db8:4::2/64
63 cleanup_soft()
65 ip link del dev v1
67 tunnel_destroy h3-gt6-soft
68 tunnel_destroy gt6-soft
71 setup_prepare()
73 h1=${NETIFS[p1]}
74 swp1=${NETIFS[p2]}
76 swp2=${NETIFS[p3]}
77 h2=${NETIFS[p4]}
79 swp3=${NETIFS[p5]}
80 h3=${NETIFS[p6]}
82 vrf_prepare
83 mirror_gre_topo_create
85 ip address add dev $swp3 2001:db8:2::1/64
86 ip address add dev $h3 2001:db8:2::2/64
88 ip address add dev $swp3 192.0.2.129/28
89 ip address add dev $h3 192.0.2.130/28
91 setup_keyful
92 setup_soft
95 cleanup()
97 pre_cleanup
99 cleanup_soft
100 cleanup_keyful
102 ip address del dev $h3 2001:db8:2::2/64
103 ip address del dev $swp3 2001:db8:2::1/64
105 ip address del dev $h3 192.0.2.130/28
106 ip address del dev $swp3 192.0.2.129/28
108 mirror_gre_topo_destroy
109 vrf_cleanup
112 test_span_gre_ttl_inherit()
114 local tundev=$1; shift
115 local type=$1; shift
116 local what=$1; shift
118 RET=0
120 ip link set dev $tundev type $type ttl inherit
121 mirror_install $swp1 ingress $tundev "matchall $tcflags"
122 fail_test_span_gre_dir $tundev ingress
124 ip link set dev $tundev type $type ttl 100
126 quick_test_span_gre_dir $tundev ingress
127 mirror_uninstall $swp1 ingress
129 log_test "$what: no offload on TTL of inherit ($tcflags)"
132 test_span_gre_tos_fixed()
134 local tundev=$1; shift
135 local type=$1; shift
136 local what=$1; shift
138 RET=0
140 ip link set dev $tundev type $type tos 0x10
141 mirror_install $swp1 ingress $tundev "matchall $tcflags"
142 fail_test_span_gre_dir $tundev ingress
144 ip link set dev $tundev type $type tos inherit
145 quick_test_span_gre_dir $tundev ingress
146 mirror_uninstall $swp1 ingress
148 log_test "$what: no offload on a fixed TOS ($tcflags)"
151 test_span_failable()
153 local should_fail=$1; shift
154 local tundev=$1; shift
155 local what=$1; shift
157 RET=0
159 mirror_install $swp1 ingress $tundev "matchall $tcflags"
160 if ((should_fail)); then
161 fail_test_span_gre_dir $tundev ingress
162 else
163 quick_test_span_gre_dir $tundev ingress
165 mirror_uninstall $swp1 ingress
167 log_test "$what: should_fail=$should_fail ($tcflags)"
170 test_failable()
172 local should_fail=$1; shift
174 test_span_failable $should_fail gt6-key "mirror to keyful gretap"
175 test_span_failable $should_fail gt6-soft "mirror to gretap w/ soft underlay"
178 test_sw()
180 slow_path_trap_install $swp1 ingress
181 slow_path_trap_install $swp1 egress
183 test_failable 0
185 slow_path_trap_uninstall $swp1 egress
186 slow_path_trap_uninstall $swp1 ingress
189 test_hw()
191 test_failable 1
193 test_span_gre_tos_fixed gt4 gretap "mirror to gretap"
194 test_span_gre_tos_fixed gt6 ip6gretap "mirror to ip6gretap"
196 test_span_gre_ttl_inherit gt4 gretap "mirror to gretap"
197 test_span_gre_ttl_inherit gt6 ip6gretap "mirror to ip6gretap"
200 trap cleanup EXIT
202 setup_prepare
203 setup_wait
205 if ! tc_offload_check; then
206 check_err 1 "Could not test offloaded functionality"
207 log_test "mlxsw-specific tests for mirror to gretap"
208 exit
211 tcflags="skip_hw"
212 test_sw
214 tcflags="skip_sw"
215 test_hw
217 exit $EXIT_STATUS