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
82 mirror_test v
$h1 192.0.2.1 192.0.2.2 $h3 77 10
84 ip link
set dev
$tundev type $type ttl
100
85 tc filter del dev
$h3 ingress pref
77
86 mirror_uninstall
$swp1 ingress
88 log_test
"$what: TTL change ($tcflags)"
91 test_span_gre_tun_up
()
93 local tundev
=$1; shift
98 ip link
set dev
$tundev down
99 mirror_install
$swp1 ingress
$tundev "matchall $tcflags"
100 fail_test_span_gre_dir
$tundev ingress
102 ip link
set dev
$tundev up
104 quick_test_span_gre_dir
$tundev ingress
105 mirror_uninstall
$swp1 ingress
107 log_test
"$what: tunnel down/up ($tcflags)"
110 test_span_gre_egress_up
()
112 local tundev
=$1; shift
113 local remote_ip
=$1; shift
118 ip link
set dev
$swp3 down
119 mirror_install
$swp1 ingress
$tundev "matchall $tcflags"
120 fail_test_span_gre_dir
$tundev ingress
122 # After setting the device up, wait for neighbor to get resolved so that
123 # we can expect mirroring to work.
124 ip link
set dev
$swp3 up
126 ping -c 1 -I $swp3 $remote_ip &>/dev
/null
128 quick_test_span_gre_dir
$tundev ingress
129 mirror_uninstall
$swp1 ingress
131 log_test
"$what: egress down/up ($tcflags)"
134 test_span_gre_remote_ip
()
136 local tundev
=$1; shift
138 local correct_ip
=$1; shift
139 local wrong_ip
=$1; shift
144 ip link
set dev
$tundev type $type remote
$wrong_ip
145 mirror_install
$swp1 ingress
$tundev "matchall $tcflags"
146 fail_test_span_gre_dir
$tundev ingress
148 ip link
set dev
$tundev type $type remote
$correct_ip
149 quick_test_span_gre_dir
$tundev ingress
150 mirror_uninstall
$swp1 ingress
152 log_test
"$what: remote address change ($tcflags)"
155 test_span_gre_tun_del
()
157 local tundev
=$1; shift
159 local flags
=$1; shift
160 local local_ip
=$1; shift
161 local remote_ip
=$1; shift
166 mirror_install
$swp1 ingress
$tundev "matchall $tcflags"
167 quick_test_span_gre_dir
$tundev ingress
168 ip link del dev
$tundev
169 fail_test_span_gre_dir
$tundev ingress
171 tunnel_create
$tundev $type $local_ip $remote_ip \
172 ttl
100 tos inherit
$flags
174 # Recreating the tunnel doesn't reestablish mirroring, so reinstall it
175 # and verify it works for the follow-up tests.
176 mirror_uninstall
$swp1 ingress
177 mirror_install
$swp1 ingress
$tundev "matchall $tcflags"
178 quick_test_span_gre_dir
$tundev ingress
179 mirror_uninstall
$swp1 ingress
181 log_test
"$what: tunnel deleted ($tcflags)"
184 test_span_gre_route_del
()
186 local tundev
=$1; shift
188 local route
=$1; shift
193 mirror_install
$swp1 ingress
$tundev "matchall $tcflags"
194 quick_test_span_gre_dir
$tundev ingress
196 ip route del
$route dev
$edev
197 fail_test_span_gre_dir
$tundev ingress
199 ip route add
$route dev
$edev
200 quick_test_span_gre_dir
$tundev ingress
202 mirror_uninstall
$swp1 ingress
204 log_test
"$what: underlay route removal ($tcflags)"
209 test_span_gre_ttl gt4 gretap ip
"mirror to gretap"
210 test_span_gre_ttl gt6 ip6gretap ipv6
"mirror to ip6gretap"
215 test_span_gre_tun_up gt4
"mirror to gretap"
216 test_span_gre_tun_up gt6
"mirror to ip6gretap"
221 test_span_gre_egress_up gt4
192.0.2.130 "mirror to gretap"
222 test_span_gre_egress_up gt6
2001:db8
:2::2 "mirror to ip6gretap"
227 test_span_gre_remote_ip gt4 gretap
192.0.2.130 192.0.2.132 "mirror to gretap"
228 test_span_gre_remote_ip gt6 ip6gretap
2001:db8
:2::2 2001:db8
:2::4 "mirror to ip6gretap"
233 test_span_gre_tun_del gt4 gretap
"" \
234 192.0.2.129 192.0.2.130 "mirror to gretap"
235 test_span_gre_tun_del gt6 ip6gretap allow-localremote \
236 2001:db8
:2::1 2001:db8
:2::2 "mirror to ip6gretap"
241 test_span_gre_route_del gt4
$swp3 192.0.2.128/28 "mirror to gretap"
242 test_span_gre_route_del gt6
$swp3 2001:db8
:2::/64 "mirror to ip6gretap"
247 slow_path_trap_install
$swp1 ingress
248 slow_path_trap_install
$swp1 egress
252 slow_path_trap_uninstall
$swp1 egress
253 slow_path_trap_uninstall
$swp1 ingress
264 if ! tc_offload_check
; then
265 echo "WARN: Could not test offloaded functionality"