2 # SPDX-License-Identifier: GPL-2.0
4 # This test uses standard topology for testing gretap. See
5 # mirror_gre_topo_lib.sh for more details.
7 # Test how mirrors to gretap and ip6gretap react to changes to relevant
22 source mirror_gre_lib.sh
23 source mirror_gre_topo_lib.sh
37 mirror_gre_topo_create
39 # This test downs $swp3, which deletes the configured IPv6 address
40 # unless this sysctl is set.
41 sysctl_set net.ipv6.conf.
$swp3.keep_addr_on_down
1
43 ip address add dev
$swp3 192.0.2.129/28
44 ip address add dev
$h3 192.0.2.130/28
46 ip address add dev
$swp3 2001:db8
:2::1/64
47 ip address add dev
$h3 2001:db8
:2::2/64
54 ip address del dev
$h3 2001:db8
:2::2/64
55 ip address del dev
$swp3 2001:db8
:2::1/64
57 ip address del dev
$h3 192.0.2.130/28
58 ip address del dev
$swp3 192.0.2.129/28
60 sysctl_restore net.ipv6.conf.
$swp3.keep_addr_on_down
62 mirror_gre_topo_destroy
68 local tundev
=$1; shift
75 mirror_install
$swp1 ingress
$tundev "matchall $tcflags"
76 tc filter add dev
$h3 ingress pref
77 prot
$prot \
77 flower ip_ttl
50 action pass
79 mirror_test v
$h1 192.0.2.1 192.0.2.2 $h3 77 0
81 ip link
set dev
$tundev type $type ttl
50
83 mirror_test v
$h1 192.0.2.1 192.0.2.2 $h3 77 10
85 ip link
set dev
$tundev type $type ttl
100
86 tc filter del dev
$h3 ingress pref
77
87 mirror_uninstall
$swp1 ingress
89 log_test
"$what: TTL change ($tcflags)"
92 test_span_gre_tun_up
()
94 local tundev
=$1; shift
99 ip link
set dev
$tundev down
100 mirror_install
$swp1 ingress
$tundev "matchall $tcflags"
101 fail_test_span_gre_dir
$tundev ingress
103 ip link
set dev
$tundev up
105 quick_test_span_gre_dir
$tundev ingress
106 mirror_uninstall
$swp1 ingress
108 log_test
"$what: tunnel down/up ($tcflags)"
111 test_span_gre_egress_up
()
113 local tundev
=$1; shift
114 local remote_ip
=$1; shift
119 ip link
set dev
$swp3 down
120 mirror_install
$swp1 ingress
$tundev "matchall $tcflags"
121 fail_test_span_gre_dir
$tundev ingress
123 # After setting the device up, wait for neighbor to get resolved so that
124 # we can expect mirroring to work.
125 ip link
set dev
$swp3 up
127 ping -c 1 -I $swp3 $remote_ip &>/dev
/null
129 quick_test_span_gre_dir
$tundev ingress
130 mirror_uninstall
$swp1 ingress
132 log_test
"$what: egress down/up ($tcflags)"
135 test_span_gre_remote_ip
()
137 local tundev
=$1; shift
139 local correct_ip
=$1; shift
140 local wrong_ip
=$1; shift
145 ip link
set dev
$tundev type $type remote
$wrong_ip
146 mirror_install
$swp1 ingress
$tundev "matchall $tcflags"
147 fail_test_span_gre_dir
$tundev ingress
149 ip link
set dev
$tundev type $type remote
$correct_ip
150 quick_test_span_gre_dir
$tundev ingress
151 mirror_uninstall
$swp1 ingress
153 log_test
"$what: remote address change ($tcflags)"
156 test_span_gre_tun_del
()
158 local tundev
=$1; shift
160 local flags
=$1; shift
161 local local_ip
=$1; shift
162 local remote_ip
=$1; shift
167 mirror_install
$swp1 ingress
$tundev "matchall $tcflags"
168 quick_test_span_gre_dir
$tundev ingress
169 ip link del dev
$tundev
170 fail_test_span_gre_dir
$tundev ingress
172 tunnel_create
$tundev $type $local_ip $remote_ip \
173 ttl
100 tos inherit
$flags
175 # Recreating the tunnel doesn't reestablish mirroring, so reinstall it
176 # and verify it works for the follow-up tests.
177 mirror_uninstall
$swp1 ingress
178 mirror_install
$swp1 ingress
$tundev "matchall $tcflags"
179 quick_test_span_gre_dir
$tundev ingress
180 mirror_uninstall
$swp1 ingress
182 log_test
"$what: tunnel deleted ($tcflags)"
185 test_span_gre_route_del
()
187 local tundev
=$1; shift
189 local route
=$1; shift
194 mirror_install
$swp1 ingress
$tundev "matchall $tcflags"
195 quick_test_span_gre_dir
$tundev ingress
197 ip route del
$route dev
$edev
198 fail_test_span_gre_dir
$tundev ingress
200 ip route add
$route dev
$edev
201 quick_test_span_gre_dir
$tundev ingress
203 mirror_uninstall
$swp1 ingress
205 log_test
"$what: underlay route removal ($tcflags)"
210 test_span_gre_ttl gt4 gretap ip
"mirror to gretap"
211 test_span_gre_ttl gt6 ip6gretap ipv6
"mirror to ip6gretap"
216 test_span_gre_tun_up gt4
"mirror to gretap"
217 test_span_gre_tun_up gt6
"mirror to ip6gretap"
222 test_span_gre_egress_up gt4
192.0.2.130 "mirror to gretap"
223 test_span_gre_egress_up gt6
2001:db8
:2::2 "mirror to ip6gretap"
228 test_span_gre_remote_ip gt4 gretap
192.0.2.130 192.0.2.132 "mirror to gretap"
229 test_span_gre_remote_ip gt6 ip6gretap
2001:db8
:2::2 2001:db8
:2::4 "mirror to ip6gretap"
234 test_span_gre_tun_del gt4 gretap
"" \
235 192.0.2.129 192.0.2.130 "mirror to gretap"
236 test_span_gre_tun_del gt6 ip6gretap allow-localremote \
237 2001:db8
:2::1 2001:db8
:2::2 "mirror to ip6gretap"
242 test_span_gre_route_del gt4
$swp3 192.0.2.128/28 "mirror to gretap"
243 test_span_gre_route_del gt6
$swp3 2001:db8
:2::/64 "mirror to ip6gretap"
248 slow_path_trap_install
$swp1 ingress
249 slow_path_trap_install
$swp1 egress
253 slow_path_trap_uninstall
$swp1 egress
254 slow_path_trap_uninstall
$swp1 ingress
265 if ! tc_offload_check
; then
266 echo "WARN: Could not test offloaded functionality"