WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / net / forwarding / mirror_gre_bound.sh
blob360ca133bead6e6cea2bbdc712e062a391d81c82
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # +---------------------+ +---------------------+
5 # | H1 | | H2 |
6 # | + $h1 | | $h2 + |
7 # | | 192.0.2.1/28 | | 192.0.2.2/28 | |
8 # +-----|---------------+ +---------------|-----+
9 # | |
10 # +-----|-------------------------------------------------------------|-----+
11 # | SW o--> mirror | |
12 # | +---|-------------------------------------------------------------|---+ |
13 # | | + $swp1 BR $swp2 + | |
14 # | +---------------------------------------------------------------------+ |
15 # | |
16 # | +---------------------------------------------------------------------+ |
17 # | | OL + gt6 (ip6gretap) + gt4 (gretap) | |
18 # | | : loc=2001:db8:2::1 : loc=192.0.2.129 | |
19 # | | : rem=2001:db8:2::2 : rem=192.0.2.130 | |
20 # | | : ttl=100 : ttl=100 | |
21 # | | : tos=inherit : tos=inherit | |
22 # | +-------------------------:--|-------------------:--|-----------------+ |
23 # | : | : | |
24 # | +-------------------------:--|-------------------:--|-----------------+ |
25 # | | UL : |,---------------------' | |
26 # | | + $swp3 : || : | |
27 # | | | 192.0.2.129/28 : vv : | |
28 # | | | 2001:db8:2::1/64 : + ul (dummy) : | |
29 # | +---|---------------------:----------------------:--------------------+ |
30 # +-----|---------------------:----------------------:----------------------+
31 # | : :
32 # +-----|---------------------:----------------------:----------------------+
33 # | H3 + $h3 + h3-gt6 (ip6gretap) + h3-gt4 (gretap) |
34 # | 192.0.2.130/28 loc=2001:db8:2::2 loc=192.0.2.130 |
35 # | 2001:db8:2::2/64 rem=2001:db8:2::1 rem=192.0.2.129 |
36 # | ttl=100 ttl=100 |
37 # | tos=inherit tos=inherit |
38 # | |
39 # +-------------------------------------------------------------------------+
41 # This tests mirroring to gretap and ip6gretap configured in an overlay /
42 # underlay manner, i.e. with a bound dummy device that marks underlay VRF where
43 # the encapsulated packed should be routed.
45 ALL_TESTS="
46 test_gretap
47 test_ip6gretap
50 NUM_NETIFS=6
51 source lib.sh
52 source mirror_lib.sh
53 source mirror_gre_lib.sh
55 h1_create()
57 simple_if_init $h1 192.0.2.1/28
60 h1_destroy()
62 simple_if_fini $h1 192.0.2.1/28
65 h2_create()
67 simple_if_init $h2 192.0.2.2/28
70 h2_destroy()
72 simple_if_fini $h2 192.0.2.2/28
75 h3_create()
77 simple_if_init $h3 192.0.2.130/28 2001:db8:2::2/64
79 tunnel_create h3-gt4 gretap 192.0.2.130 192.0.2.129
80 ip link set h3-gt4 vrf v$h3
81 matchall_sink_create h3-gt4
83 tunnel_create h3-gt6 ip6gretap 2001:db8:2::2 2001:db8:2::1
84 ip link set h3-gt6 vrf v$h3
85 matchall_sink_create h3-gt6
88 h3_destroy()
90 tunnel_destroy h3-gt6
91 tunnel_destroy h3-gt4
93 simple_if_fini $h3 192.0.2.130/28 2001:db8:2::2/64
96 switch_create()
98 # Bridge between H1 and H2.
100 ip link add name br1 type bridge vlan_filtering 1
101 ip link set dev br1 up
103 ip link set dev $swp1 master br1
104 ip link set dev $swp1 up
106 ip link set dev $swp2 master br1
107 ip link set dev $swp2 up
109 tc qdisc add dev $swp1 clsact
111 # Underlay.
113 simple_if_init $swp3 192.0.2.129/28 2001:db8:2::1/64
115 ip link add name ul type dummy
116 ip link set dev ul master v$swp3
117 ip link set dev ul up
119 # Overlay.
121 vrf_create vrf-ol
122 ip link set dev vrf-ol up
124 tunnel_create gt4 gretap 192.0.2.129 192.0.2.130 \
125 ttl 100 tos inherit dev ul
126 ip link set dev gt4 master vrf-ol
127 ip link set dev gt4 up
129 tunnel_create gt6 ip6gretap 2001:db8:2::1 2001:db8:2::2 \
130 ttl 100 tos inherit dev ul allow-localremote
131 ip link set dev gt6 master vrf-ol
132 ip link set dev gt6 up
135 switch_destroy()
137 vrf_destroy vrf-ol
139 tunnel_destroy gt6
140 tunnel_destroy gt4
142 simple_if_fini $swp3 192.0.2.129/28 2001:db8:2::1/64
144 ip link del dev ul
146 tc qdisc del dev $swp1 clsact
148 ip link set dev $swp1 down
149 ip link set dev $swp2 down
150 ip link del dev br1
153 setup_prepare()
155 h1=${NETIFS[p1]}
156 swp1=${NETIFS[p2]}
158 swp2=${NETIFS[p3]}
159 h2=${NETIFS[p4]}
161 swp3=${NETIFS[p5]}
162 h3=${NETIFS[p6]}
164 vrf_prepare
166 h1_create
167 h2_create
168 h3_create
170 switch_create
173 cleanup()
175 pre_cleanup
177 switch_destroy
179 h3_destroy
180 h2_destroy
181 h1_destroy
183 vrf_cleanup
186 test_gretap()
188 full_test_span_gre_dir gt4 ingress 8 0 "mirror to gretap w/ UL"
189 full_test_span_gre_dir gt4 egress 0 8 "mirror to gretap w/ UL"
192 test_ip6gretap()
194 full_test_span_gre_dir gt6 ingress 8 0 "mirror to ip6gretap w/ UL"
195 full_test_span_gre_dir gt6 egress 0 8 "mirror to ip6gretap w/ UL"
198 test_all()
200 RET=0
202 slow_path_trap_install $swp1 ingress
203 slow_path_trap_install $swp1 egress
205 tests_run
207 slow_path_trap_uninstall $swp1 egress
208 slow_path_trap_uninstall $swp1 ingress
211 trap cleanup EXIT
213 setup_prepare
214 setup_wait
216 tcflags="skip_hw"
217 test_all
219 if ! tc_offload_check; then
220 echo "WARN: Could not test offloaded functionality"
221 else
222 tcflags="skip_sw"
223 test_all
226 exit $EXIT_STATUS