Skip to content

Commit 748e3bb

Browse files
committed
Merge branch 'net-selftests-mirroring-cleanup' into main
Petr Machata says: ==================== selftest: Clean-up and stabilize mirroring tests The mirroring selftests work by sending ICMP traffic between two hosts. Along the way, this traffic is mirrored to a gretap netdevice, and counter taps are then installed strategically along the path of the mirrored traffic to verify the mirroring took place. The problem with this is that besides mirroring the primary traffic, any other service traffic is mirrored as well. At the same time, because the tests need to work in HW-offloaded scenarios, the ability of the device to do arbitrary packet inspection should not be taken for granted. Most tests therefore simply use matchall, one uses flower to match on IP address. As a result, the selftests are noisy. mirror_test() accommodated this noisiness by giving the counters an allowance of several packets. But that only works up to a point, and on busy systems won't be always enough. In this patch set, clean up and stabilize the mirroring selftests. The original intention was to port the tests over to UDP, but the logic of ICMP ends up being so entangled in the mirroring selftests that the changes feel overly invasive. Instead, ICMP is kept, but where possible, we match on ICMP message type, thus filtering out hits by other ICMP messages. Where this is not practical (where the counter tap is put on a device that carries encapsulated packets), switch the counter condition to _at least_ X observed packets. This is less robust, but barely so -- probably the only scenario that this would not catch is something like erroneous packet duplication, which would hopefully get caught by the numerous other tests in this extensive suite. - Patches #1 to #3 clean up parameters at various helpers. - Patches #4 to #6 stabilize the mirroring selftests as described above. - Mirroring tests currently allow testing SW datapath even on HW netdevices by trapping traffic to the SW datapath. This complicates the tests a bit without a good reason: to test SW datapath, just run the selftests on the veth topology. Thus in patch #7, drop support for this dual SW/HW testing. - At this point, some cleanups were either made possible by the previous patches, or were always possible. In patches #8 to #11, realize these cleanups. - In patch #12, fix mlxsw mirror_gre selftest to respect setting TESTS. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents c977ac4 + 098ba97 commit 748e3bb

20 files changed

+355
-538
lines changed

tools/testing/selftests/drivers/net/mlxsw/mirror_gre.sh

Lines changed: 28 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ source $lib_dir/mirror_lib.sh
1515
source $lib_dir/mirror_gre_lib.sh
1616
source $lib_dir/mirror_gre_topo_lib.sh
1717

18+
ALL_TESTS="
19+
test_keyful
20+
test_soft
21+
test_tos_fixed
22+
test_ttl_inherit
23+
"
24+
1825
setup_keyful()
1926
{
2027
tunnel_create gt6-key ip6gretap 2001:db8:3::1 2001:db8:3::2 \
@@ -118,15 +125,15 @@ test_span_gre_ttl_inherit()
118125
RET=0
119126

120127
ip link set dev $tundev type $type ttl inherit
121-
mirror_install $swp1 ingress $tundev "matchall $tcflags"
122-
fail_test_span_gre_dir $tundev ingress
128+
mirror_install $swp1 ingress $tundev "matchall"
129+
fail_test_span_gre_dir $tundev
123130

124131
ip link set dev $tundev type $type ttl 100
125132

126-
quick_test_span_gre_dir $tundev ingress
133+
quick_test_span_gre_dir $tundev
127134
mirror_uninstall $swp1 ingress
128135

129-
log_test "$what: no offload on TTL of inherit ($tcflags)"
136+
log_test "$what: no offload on TTL of inherit"
130137
}
131138

132139
test_span_gre_tos_fixed()
@@ -138,61 +145,49 @@ test_span_gre_tos_fixed()
138145
RET=0
139146

140147
ip link set dev $tundev type $type tos 0x10
141-
mirror_install $swp1 ingress $tundev "matchall $tcflags"
142-
fail_test_span_gre_dir $tundev ingress
148+
mirror_install $swp1 ingress $tundev "matchall"
149+
fail_test_span_gre_dir $tundev
143150

144151
ip link set dev $tundev type $type tos inherit
145-
quick_test_span_gre_dir $tundev ingress
152+
quick_test_span_gre_dir $tundev
146153
mirror_uninstall $swp1 ingress
147154

148-
log_test "$what: no offload on a fixed TOS ($tcflags)"
155+
log_test "$what: no offload on a fixed TOS"
149156
}
150157

151158
test_span_failable()
152159
{
153-
local should_fail=$1; shift
154160
local tundev=$1; shift
155161
local what=$1; shift
156162

157163
RET=0
158164

159-
mirror_install $swp1 ingress $tundev "matchall $tcflags"
160-
if ((should_fail)); then
161-
fail_test_span_gre_dir $tundev ingress
162-
else
163-
quick_test_span_gre_dir $tundev ingress
164-
fi
165+
mirror_install $swp1 ingress $tundev "matchall"
166+
fail_test_span_gre_dir $tundev
165167
mirror_uninstall $swp1 ingress
166168

167-
log_test "$what: should_fail=$should_fail ($tcflags)"
169+
log_test "fail $what"
168170
}
169171

170-
test_failable()
172+
test_keyful()
171173
{
172-
local should_fail=$1; shift
173-
174-
test_span_failable $should_fail gt6-key "mirror to keyful gretap"
175-
test_span_failable $should_fail gt6-soft "mirror to gretap w/ soft underlay"
174+
test_span_failable gt6-key "mirror to keyful gretap"
176175
}
177176

178-
test_sw()
177+
test_soft()
179178
{
180-
slow_path_trap_install $swp1 ingress
181-
slow_path_trap_install $swp1 egress
182-
183-
test_failable 0
184-
185-
slow_path_trap_uninstall $swp1 egress
186-
slow_path_trap_uninstall $swp1 ingress
179+
test_span_failable gt6-soft "mirror to gretap w/ soft underlay"
187180
}
188181

189-
test_hw()
182+
test_tos_fixed()
190183
{
191-
test_failable 1
192-
193184
test_span_gre_tos_fixed gt4 gretap "mirror to gretap"
194185
test_span_gre_tos_fixed gt6 ip6gretap "mirror to ip6gretap"
186+
}
187+
195188

189+
test_ttl_inherit()
190+
{
196191
test_span_gre_ttl_inherit gt4 gretap "mirror to gretap"
197192
test_span_gre_ttl_inherit gt6 ip6gretap "mirror to ip6gretap"
198193
}
@@ -202,16 +197,6 @@ trap cleanup EXIT
202197
setup_prepare
203198
setup_wait
204199

205-
if ! tc_offload_check; then
206-
check_err 1 "Could not test offloaded functionality"
207-
log_test "mlxsw-specific tests for mirror to gretap"
208-
exit
209-
fi
210-
211-
tcflags="skip_hw"
212-
test_sw
213-
214-
tcflags="skip_sw"
215-
test_hw
200+
tests_run
216201

217202
exit $EXIT_STATUS

tools/testing/selftests/drivers/net/mlxsw/mirror_gre_scale.sh

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ mirror_gre_tunnels_create()
7979
cat >> $MIRROR_GRE_BATCH_FILE <<-EOF
8080
filter add dev $swp1 ingress pref 1000 \
8181
protocol ipv6 \
82-
flower $tcflags dst_ip $match_dip \
82+
flower skip_sw dst_ip $match_dip \
8383
action mirred egress mirror dev $tun
8484
EOF
8585
done
@@ -107,7 +107,7 @@ mirror_gre_tunnels_destroy()
107107
done
108108
}
109109

110-
__mirror_gre_test()
110+
mirror_gre_test()
111111
{
112112
local count=$1; shift
113113
local should_fail=$1; shift
@@ -131,20 +131,6 @@ __mirror_gre_test()
131131
done
132132
}
133133

134-
mirror_gre_test()
135-
{
136-
local count=$1; shift
137-
local should_fail=$1; shift
138-
139-
if ! tc_offload_check $TC_FLOWER_NUM_NETIFS; then
140-
check_err 1 "Could not test offloaded functionality"
141-
return
142-
fi
143-
144-
tcflags="skip_sw"
145-
__mirror_gre_test $count $should_fail
146-
}
147-
148134
mirror_gre_setup_prepare()
149135
{
150136
h1=${NETIFS[p1]}

tools/testing/selftests/net/forwarding/lib.sh

Lines changed: 56 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,22 +1225,6 @@ trap_uninstall()
12251225
tc filter del dev $dev $direction pref 1 flower
12261226
}
12271227

1228-
slow_path_trap_install()
1229-
{
1230-
# For slow-path testing, we need to install a trap to get to
1231-
# slow path the packets that would otherwise be switched in HW.
1232-
if [ "${tcflags/skip_hw}" != "$tcflags" ]; then
1233-
trap_install "$@"
1234-
fi
1235-
}
1236-
1237-
slow_path_trap_uninstall()
1238-
{
1239-
if [ "${tcflags/skip_hw}" != "$tcflags" ]; then
1240-
trap_uninstall "$@"
1241-
fi
1242-
}
1243-
12441228
__icmp_capture_add_del()
12451229
{
12461230
local add_del=$1; shift
@@ -1257,22 +1241,34 @@ __icmp_capture_add_del()
12571241

12581242
icmp_capture_install()
12591243
{
1260-
__icmp_capture_add_del add 100 "" "$@"
1244+
local tundev=$1; shift
1245+
local filter=$1; shift
1246+
1247+
__icmp_capture_add_del add 100 "" "$tundev" "$filter"
12611248
}
12621249

12631250
icmp_capture_uninstall()
12641251
{
1265-
__icmp_capture_add_del del 100 "" "$@"
1252+
local tundev=$1; shift
1253+
local filter=$1; shift
1254+
1255+
__icmp_capture_add_del del 100 "" "$tundev" "$filter"
12661256
}
12671257

12681258
icmp6_capture_install()
12691259
{
1270-
__icmp_capture_add_del add 100 v6 "$@"
1260+
local tundev=$1; shift
1261+
local filter=$1; shift
1262+
1263+
__icmp_capture_add_del add 100 v6 "$tundev" "$filter"
12711264
}
12721265

12731266
icmp6_capture_uninstall()
12741267
{
1275-
__icmp_capture_add_del del 100 v6 "$@"
1268+
local tundev=$1; shift
1269+
local filter=$1; shift
1270+
1271+
__icmp_capture_add_del del 100 v6 "$tundev" "$filter"
12761272
}
12771273

12781274
__vlan_capture_add_del()
@@ -1290,12 +1286,18 @@ __vlan_capture_add_del()
12901286

12911287
vlan_capture_install()
12921288
{
1293-
__vlan_capture_add_del add 100 "$@"
1289+
local dev=$1; shift
1290+
local filter=$1; shift
1291+
1292+
__vlan_capture_add_del add 100 "$dev" "$filter"
12941293
}
12951294

12961295
vlan_capture_uninstall()
12971296
{
1298-
__vlan_capture_add_del del 100 "$@"
1297+
local dev=$1; shift
1298+
local filter=$1; shift
1299+
1300+
__vlan_capture_add_del del 100 "$dev" "$filter"
12991301
}
13001302

13011303
__dscp_capture_add_del()
@@ -1655,34 +1657,61 @@ __start_traffic()
16551657
local sip=$1; shift
16561658
local dip=$1; shift
16571659
local dmac=$1; shift
1660+
local -a mz_args=("$@")
16581661

16591662
$MZ $h_in -p $pktsize -A $sip -B $dip -c 0 \
1660-
-a own -b $dmac -t "$proto" -q "$@" &
1663+
-a own -b $dmac -t "$proto" -q "${mz_args[@]}" &
16611664
sleep 1
16621665
}
16631666

16641667
start_traffic_pktsize()
16651668
{
16661669
local pktsize=$1; shift
1670+
local h_in=$1; shift
1671+
local sip=$1; shift
1672+
local dip=$1; shift
1673+
local dmac=$1; shift
1674+
local -a mz_args=("$@")
16671675

1668-
__start_traffic $pktsize udp "$@"
1676+
__start_traffic $pktsize udp "$h_in" "$sip" "$dip" "$dmac" \
1677+
"${mz_args[@]}"
16691678
}
16701679

16711680
start_tcp_traffic_pktsize()
16721681
{
16731682
local pktsize=$1; shift
1683+
local h_in=$1; shift
1684+
local sip=$1; shift
1685+
local dip=$1; shift
1686+
local dmac=$1; shift
1687+
local -a mz_args=("$@")
16741688

1675-
__start_traffic $pktsize tcp "$@"
1689+
__start_traffic $pktsize tcp "$h_in" "$sip" "$dip" "$dmac" \
1690+
"${mz_args[@]}"
16761691
}
16771692

16781693
start_traffic()
16791694
{
1680-
start_traffic_pktsize 8000 "$@"
1695+
local h_in=$1; shift
1696+
local sip=$1; shift
1697+
local dip=$1; shift
1698+
local dmac=$1; shift
1699+
local -a mz_args=("$@")
1700+
1701+
start_traffic_pktsize 8000 "$h_in" "$sip" "$dip" "$dmac" \
1702+
"${mz_args[@]}"
16811703
}
16821704

16831705
start_tcp_traffic()
16841706
{
1685-
start_tcp_traffic_pktsize 8000 "$@"
1707+
local h_in=$1; shift
1708+
local sip=$1; shift
1709+
local dip=$1; shift
1710+
local dmac=$1; shift
1711+
local -a mz_args=("$@")
1712+
1713+
start_tcp_traffic_pktsize 8000 "$h_in" "$sip" "$dip" "$dmac" \
1714+
"${mz_args[@]}"
16861715
}
16871716

16881717
stop_traffic()

0 commit comments

Comments
 (0)