Linux-libre 5.3.12-gnu
[librecmc/linux-libre.git] / tools / testing / selftests / net / forwarding / mirror_gre_vlan.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3
4 # This test uses standard topology for testing gretap. See
5 # mirror_gre_topo_lib.sh for more details.
6 #
7 # Test for "tc action mirred egress mirror" that mirrors to a gretap netdevice
8 # whose underlay route points at a vlan device.
9
10 ALL_TESTS="
11         test_gretap
12 "
13
14 NUM_NETIFS=6
15 source lib.sh
16 source mirror_lib.sh
17 source mirror_gre_lib.sh
18 source mirror_gre_topo_lib.sh
19
20 setup_prepare()
21 {
22         h1=${NETIFS[p1]}
23         swp1=${NETIFS[p2]}
24
25         swp2=${NETIFS[p3]}
26         h2=${NETIFS[p4]}
27
28         swp3=${NETIFS[p5]}
29         h3=${NETIFS[p6]}
30
31         vrf_prepare
32         mirror_gre_topo_create
33
34         ip link add name $swp3.555 link $swp3 type vlan id 555
35         ip address add dev $swp3.555 192.0.2.129/32
36         ip address add dev $swp3.555 2001:db8:2::1/128
37         ip link set dev $swp3.555 up
38
39         ip route add 192.0.2.130/32 dev $swp3.555
40         ip -6 route add 2001:db8:2::2/128 dev $swp3.555
41
42         ip link add name $h3.555 link $h3 type vlan id 555
43         ip link set dev $h3.555 master v$h3
44         ip address add dev $h3.555 192.0.2.130/28
45         ip address add dev $h3.555 2001:db8:2::2/64
46         ip link set dev $h3.555 up
47 }
48
49 cleanup()
50 {
51         pre_cleanup
52
53         ip link del dev $h3.555
54         ip link del dev $swp3.555
55
56         mirror_gre_topo_destroy
57         vrf_cleanup
58 }
59
60 test_gretap()
61 {
62         full_test_span_gre_dir gt4 ingress 8 0 "mirror to gretap"
63         full_test_span_gre_dir gt4 egress 0 8 "mirror to gretap"
64 }
65
66 test_all()
67 {
68         slow_path_trap_install $swp1 ingress
69         slow_path_trap_install $swp1 egress
70
71         tests_run
72
73         slow_path_trap_uninstall $swp1 egress
74         slow_path_trap_uninstall $swp1 ingress
75 }
76
77 trap cleanup EXIT
78
79 setup_prepare
80 setup_wait
81
82 tcflags="skip_hw"
83 test_all
84
85 if ! tc_offload_check; then
86         echo "WARN: Could not test offloaded functionality"
87 else
88         tcflags="skip_sw"
89         test_all
90 fi
91
92 exit $EXIT_STATUS