staging: rtl8192u: remove redundant assignment to pointer crypt
[linux/fpc-iii.git] / tools / testing / selftests / drivers / net / mlxsw / mirror_gre_scale.sh
blob6f3a70df63bc6879a1f596184dcfa004ae5b69c7
1 # SPDX-License-Identifier: GPL-2.0
3 # Test offloading a number of mirrors-to-gretap. The test creates a number of
4 # tunnels. Then it adds one flower mirror for each of the tunnels, matching a
5 # given host IP. Then it generates traffic at each of the host IPs and checks
6 # that the traffic has been mirrored at the appropriate tunnel.
8 # +--------------------------+ +--------------------------+
9 # | H1 | | H2 |
10 # | + $h1 | | $h2 + |
11 # | | 2001:db8:1:X::1/64 | | 2001:db8:1:X::2/64 | |
12 # +-----|--------------------+ +--------------------|-----+
13 # | |
14 # +-----|-------------------------------------------------------------|-----+
15 # | SW o--> mirrors | |
16 # | +---|-------------------------------------------------------------|---+ |
17 # | | + $swp1 BR $swp2 + | |
18 # | +---------------------------------------------------------------------+ |
19 # | |
20 # | + $swp3 + gt6-<X> (ip6gretap) |
21 # | | 2001:db8:2:X::1/64 : loc=2001:db8:2:X::1 |
22 # | | : rem=2001:db8:2:X::2 |
23 # | | : ttl=100 |
24 # | | : tos=inherit |
25 # | | : |
26 # +-----|--------------------------------:----------------------------------+
27 # | :
28 # +-----|--------------------------------:----------------------------------+
29 # | H3 + $h3 + h3-gt6-<X> (ip6gretap) |
30 # | 2001:db8:2:X::2/64 loc=2001:db8:2:X::2 |
31 # | rem=2001:db8:2:X::1 |
32 # | ttl=100 |
33 # | tos=inherit |
34 # | |
35 # +-------------------------------------------------------------------------+
37 source ../../../../net/forwarding/mirror_lib.sh
39 MIRROR_NUM_NETIFS=6
41 mirror_gre_ipv6_addr()
43 local net=$1; shift
44 local num=$1; shift
46 printf "2001:db8:%x:%x" $net $num
49 mirror_gre_tunnels_create()
51 local count=$1; shift
52 local should_fail=$1; shift
54 MIRROR_GRE_BATCH_FILE="$(mktemp)"
55 for ((i=0; i < count; ++i)); do
56 local match_dip=$(mirror_gre_ipv6_addr 1 $i)::2
57 local htun=h3-gt6-$i
58 local tun=gt6-$i
60 ((mirror_gre_tunnels++))
62 ip address add dev $h1 $(mirror_gre_ipv6_addr 1 $i)::1/64
63 ip address add dev $h2 $(mirror_gre_ipv6_addr 1 $i)::2/64
65 ip address add dev $swp3 $(mirror_gre_ipv6_addr 2 $i)::1/64
66 ip address add dev $h3 $(mirror_gre_ipv6_addr 2 $i)::2/64
68 tunnel_create $tun ip6gretap \
69 $(mirror_gre_ipv6_addr 2 $i)::1 \
70 $(mirror_gre_ipv6_addr 2 $i)::2 \
71 ttl 100 tos inherit allow-localremote
73 tunnel_create $htun ip6gretap \
74 $(mirror_gre_ipv6_addr 2 $i)::2 \
75 $(mirror_gre_ipv6_addr 2 $i)::1
76 ip link set $htun vrf v$h3
77 matchall_sink_create $htun
79 cat >> $MIRROR_GRE_BATCH_FILE <<-EOF
80 filter add dev $swp1 ingress pref 1000 \
81 protocol ipv6 \
82 flower $tcflags dst_ip $match_dip \
83 action mirred egress mirror dev $tun
84 EOF
85 done
87 tc -b $MIRROR_GRE_BATCH_FILE
88 check_err_fail $should_fail $? "Mirror rule insertion"
91 mirror_gre_tunnels_destroy()
93 local count=$1; shift
95 for ((i=0; i < count; ++i)); do
96 local htun=h3-gt6-$i
97 local tun=gt6-$i
99 ip address del dev $h3 $(mirror_gre_ipv6_addr 2 $i)::2/64
100 ip address del dev $swp3 $(mirror_gre_ipv6_addr 2 $i)::1/64
102 ip address del dev $h2 $(mirror_gre_ipv6_addr 1 $i)::2/64
103 ip address del dev $h1 $(mirror_gre_ipv6_addr 1 $i)::1/64
105 tunnel_destroy $htun
106 tunnel_destroy $tun
107 done
110 __mirror_gre_test()
112 local count=$1; shift
113 local should_fail=$1; shift
115 mirror_gre_tunnels_create $count $should_fail
116 if ((should_fail)); then
117 return
120 sleep 5
122 for ((i = 0; i < count; ++i)); do
123 local dip=$(mirror_gre_ipv6_addr 1 $i)::2
124 local htun=h3-gt6-$i
125 local message
127 icmp6_capture_install $htun
128 mirror_test v$h1 "" $dip $htun 100 10
129 icmp6_capture_uninstall $htun
130 done
133 mirror_gre_test()
135 local count=$1; shift
136 local should_fail=$1; shift
138 if ! tc_offload_check $TC_FLOWER_NUM_NETIFS; then
139 check_err 1 "Could not test offloaded functionality"
140 return
143 tcflags="skip_sw"
144 __mirror_gre_test $count $should_fail
147 mirror_gre_setup_prepare()
149 h1=${NETIFS[p1]}
150 swp1=${NETIFS[p2]}
152 swp2=${NETIFS[p3]}
153 h2=${NETIFS[p4]}
155 swp3=${NETIFS[p5]}
156 h3=${NETIFS[p6]}
158 mirror_gre_tunnels=0
160 vrf_prepare
162 simple_if_init $h1
163 simple_if_init $h2
164 simple_if_init $h3
166 ip link add name br1 type bridge vlan_filtering 1
167 ip link set dev br1 up
169 ip link set dev $swp1 master br1
170 ip link set dev $swp1 up
171 tc qdisc add dev $swp1 clsact
173 ip link set dev $swp2 master br1
174 ip link set dev $swp2 up
176 ip link set dev $swp3 up
179 mirror_gre_cleanup()
181 mirror_gre_tunnels_destroy $mirror_gre_tunnels
183 ip link set dev $swp3 down
185 ip link set dev $swp2 down
187 tc qdisc del dev $swp1 clsact
188 ip link set dev $swp1 down
190 ip link del dev br1
192 simple_if_fini $h3
193 simple_if_fini $h2
194 simple_if_fini $h1
196 vrf_cleanup