]> asedeno.scripts.mit.edu Git - linux.git/blob - tools/testing/selftests/net/forwarding/mirror_gre_flower.sh
Merge ath-next from git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git
[linux.git] / tools / testing / selftests / net / forwarding / mirror_gre_flower.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 # This tests flower-triggered mirroring to gretap and ip6gretap netdevices. The
8 # interfaces on H1 and H2 have two addresses each. Flower match on one of the
9 # addresses is configured with mirror action. It is expected that when pinging
10 # this address, mirroring takes place, whereas when pinging the other one,
11 # there's no mirroring.
12
13 ALL_TESTS="
14         test_gretap
15         test_ip6gretap
16 "
17
18 NUM_NETIFS=6
19 source lib.sh
20 source mirror_lib.sh
21 source mirror_gre_lib.sh
22 source mirror_gre_topo_lib.sh
23
24 setup_prepare()
25 {
26         h1=${NETIFS[p1]}
27         swp1=${NETIFS[p2]}
28
29         swp2=${NETIFS[p3]}
30         h2=${NETIFS[p4]}
31
32         swp3=${NETIFS[p5]}
33         h3=${NETIFS[p6]}
34
35         vrf_prepare
36         mirror_gre_topo_create
37
38         ip address add dev $swp3 192.0.2.129/28
39         ip address add dev $h3 192.0.2.130/28
40
41         ip address add dev $swp3 2001:db8:2::1/64
42         ip address add dev $h3 2001:db8:2::2/64
43
44         ip address add dev $h1 192.0.2.3/28
45         ip address add dev $h2 192.0.2.4/28
46 }
47
48 cleanup()
49 {
50         pre_cleanup
51
52         ip address del dev $h2 192.0.2.4/28
53         ip address del dev $h1 192.0.2.3/28
54
55         ip address del dev $h3 2001:db8:2::2/64
56         ip address del dev $swp3 2001:db8:2::1/64
57
58         ip address del dev $h3 192.0.2.130/28
59         ip address del dev $swp3 192.0.2.129/28
60
61         mirror_gre_topo_destroy
62         vrf_cleanup
63 }
64
65 test_span_gre_dir_acl()
66 {
67         test_span_gre_dir_ips "$@" 192.0.2.3 192.0.2.4
68 }
69
70 full_test_span_gre_dir_acl()
71 {
72         local tundev=$1; shift
73         local direction=$1; shift
74         local forward_type=$1; shift
75         local backward_type=$1; shift
76         local match_dip=$1; shift
77         local what=$1; shift
78
79         mirror_install $swp1 $direction $tundev \
80                        "protocol ip flower $tcflags dst_ip $match_dip"
81         fail_test_span_gre_dir $tundev $direction
82         test_span_gre_dir_acl "$tundev" "$direction" \
83                           "$forward_type" "$backward_type"
84         mirror_uninstall $swp1 $direction
85
86         log_test "$direction $what ($tcflags)"
87 }
88
89 test_gretap()
90 {
91         full_test_span_gre_dir_acl gt4 ingress 8 0 192.0.2.4 "ACL mirror to gretap"
92         full_test_span_gre_dir_acl gt4 egress 0 8 192.0.2.3 "ACL mirror to gretap"
93 }
94
95 test_ip6gretap()
96 {
97         full_test_span_gre_dir_acl gt6 ingress 8 0 192.0.2.4 "ACL mirror to ip6gretap"
98         full_test_span_gre_dir_acl gt6 egress 0 8 192.0.2.3 "ACL mirror to ip6gretap"
99 }
100
101 test_all()
102 {
103         RET=0
104
105         slow_path_trap_install $swp1 ingress
106         slow_path_trap_install $swp1 egress
107
108         tests_run
109
110         slow_path_trap_uninstall $swp1 egress
111         slow_path_trap_uninstall $swp1 ingress
112 }
113
114 trap cleanup EXIT
115
116 setup_prepare
117 setup_wait
118
119 tcflags="skip_hw"
120 test_all
121
122 if ! tc_offload_check; then
123         echo "WARN: Could not test offloaded functionality"
124 else
125         tcflags="skip_sw"
126         test_all
127 fi
128
129 exit $EXIT_STATUS