2 # SPDX-License-Identifier: GPL-2.0
4 # Test for "tc action mirred egress mirror" when the underlay route points at a
7 # +----------------------+ +----------------------+
9 # | + $h1.333 | | $h1.555 + |
10 # | | 192.0.2.1/28 | | 192.0.2.18/28 | |
11 # +----|-----------------+ +----------------|-----+
13 # +---------------------------------+------------------------------+
15 # +--------------------------------------|------------------------------------+
18 # | +----------------------------------+------------------------------+ |
20 # | + $swp1.333 $swp1.555 + |
21 # | 192.0.2.2/28 192.0.2.17/28 |
24 # | + gt4 (gretap) ,-> + lag1 (team) |
25 # | loc=192.0.2.129 | | 192.0.2.129/28 |
26 # | rem=192.0.2.130 --' | |
29 # | _____________________|______________________ |
33 # +---|------------------------------------------------|----------------------+
35 # +---|------------------------------------------------|----------------------+
38 # | \____________________________________________/ |
43 # +---------------------------------------------------------------------------+
46 test_mirror_gretap_first
47 test_mirror_gretap_second
53 source mirror_gre_lib.sh
55 require_command $ARPING
59 local if_name=$1; shift
61 local vrf_name=$1; shift
65 ip link set dev $vrf_name up
66 vlan_create $if_name $vid $vrf_name "${ips[@]}"
71 local if_name=$1; shift
73 local vrf_name=$1; shift
75 vlan_destroy $if_name $vid
76 ip link set dev $vrf_name down
82 vlan_host_create $h1 333 vrf-h1 192.0.2.1/28
83 ip -4 route add 192.0.2.16/28 vrf vrf-h1 nexthop via 192.0.2.2
88 ip -4 route del 192.0.2.16/28 vrf vrf-h1
89 vlan_host_destroy $h1 333 vrf-h1
94 vlan_host_create $h1 555 vrf-h2 192.0.2.18/28
95 ip -4 route add 192.0.2.0/28 vrf vrf-h2 nexthop via 192.0.2.17
100 ip -4 route del 192.0.2.0/28 vrf vrf-h2
101 vlan_host_destroy $h1 555 vrf-h2
106 team_create lag2 lacp $h3 $h4
107 __simple_if_init lag2 vrf-h3 192.0.2.130/32
108 ip -4 route add vrf vrf-h3 192.0.2.129/32 dev lag2
113 ip -4 route del vrf vrf-h3 192.0.2.129/32 dev lag2
114 __simple_if_fini lag2 192.0.2.130/32
117 ip link set dev $h3 down
118 ip link set dev $h4 down
124 ip link set dev vrf-h3 up
125 tc qdisc add dev $h3 clsact
126 tc qdisc add dev $h4 clsact
133 tc qdisc del dev $h4 clsact
134 tc qdisc del dev $h3 clsact
135 ip link set dev vrf-h3 down
141 ip link set dev $swp1 up
142 tc qdisc add dev $swp1 clsact
143 vlan_create $swp1 333 "" 192.0.2.2/28
144 vlan_create $swp1 555 "" 192.0.2.17/28
146 tunnel_create gt4 gretap 192.0.2.129 192.0.2.130 \
149 ip link set dev $swp3 up
150 ip link set dev $swp4 up
151 team_create lag1 lacp $swp3 $swp4
152 __addr_add_del lag1 add 192.0.2.129/32
153 ip -4 route add 192.0.2.130/32 dev lag1
158 ip -4 route del 192.0.2.130/32 dev lag1
159 __addr_add_del lag1 del 192.0.2.129/32
162 ip link set dev $swp4 down
163 ip link set dev $swp3 down
167 vlan_destroy $swp1 555
168 vlan_destroy $swp1 333
169 tc qdisc del dev $swp1 clsact
170 ip link set dev $swp1 down
186 ip link set dev $h1 up
192 trap_install $h3 ingress
193 trap_install $h4 ingress
200 trap_uninstall $h4 ingress
201 trap_uninstall $h3 ingress
207 ip link set dev $h1 down
214 local up_dev=$1; shift
215 local down_dev=$1; shift
220 mirror_install $swp1 ingress gt4 \
221 "proto 802.1q flower vlan_id 333 $tcflags"
223 # Move $down_dev away from the team. That will prompt change in
224 # txability of the connected device, without changing its upness. The
225 # driver should notice the txability change and move the traffic to the
227 ip link set dev $down_dev nomaster
229 mirror_test vrf-h1 192.0.2.1 192.0.2.18 $up_dev 1 10
231 # Test lack of connectivity when neither slave is txable.
232 ip link set dev $up_dev nomaster
234 mirror_test vrf-h1 192.0.2.1 192.0.2.18 $h3 1 0
235 mirror_test vrf-h1 192.0.2.1 192.0.2.18 $h4 1 0
236 mirror_uninstall $swp1 ingress
238 # Recreate H3's team device, because mlxsw, which this test is
239 # predominantly mean to test, requires a bottom-up construction and
240 # doesn't allow enslavement to a device that already has an upper.
243 # Wait for ${h,swp}{3,4}.
246 log_test "$what ($tcflags)"
249 test_mirror_gretap_first()
251 test_lag_slave $h3 $h4 "mirror to gretap: LAG first slave"
254 test_mirror_gretap_second()
256 test_lag_slave $h4 $h3 "mirror to gretap: LAG second slave"
261 slow_path_trap_install $swp1 ingress
262 slow_path_trap_install $swp1 egress
266 slow_path_trap_uninstall $swp1 egress
267 slow_path_trap_uninstall $swp1 ingress
278 if ! tc_offload_check; then
279 echo "WARN: Could not test offloaded functionality"