Commit 26281e2c authored by David S. Miller's avatar David S. Miller

Merge branch 'selftests-Various-fixes'

Petr Machata says:

====================
selftests: Various fixes

This patch set contains various fixes whose common denominator is
improving quality of forwarding and mlxsw selftests.

Most of the fixes are improvements in determinism (such that timing and
latency don't impact the test performance). These were prompted by
regular runs of the test suite on a hardware emulator, the performance
of which is necessarily lower than that of the real device.

Patches #1 (from Ido), #2 and #3 make changes to ping limits.

Patches #4 and #5 add more sleep in places where things need more time
to finish.

Patches #6 and #7 fix two tests in the suite of mirror-to-gretap tests
where underlay involves a VLAN device over an 802.1q bridge.

Patches #8, #9 and #10 fix bugs in mirror-to-gretap test where underlay
involves a LAG device.

Patch #11 fixes a missed RET initialization in mirror-to-gretap flower
test.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 3fc46fc9 084fafe9
...@@ -148,9 +148,10 @@ dscp_ping_test() ...@@ -148,9 +148,10 @@ dscp_ping_test()
eval "t0s=($(dscp_fetch_stats $dev_10 10) eval "t0s=($(dscp_fetch_stats $dev_10 10)
$(dscp_fetch_stats $dev_20 20))" $(dscp_fetch_stats $dev_20 20))"
local ping_timeout=$((PING_TIMEOUT * 5))
ip vrf exec $vrf_name \ ip vrf exec $vrf_name \
${PING} -Q $dscp_10 ${sip:+-I $sip} $dip \ ${PING} -Q $dscp_10 ${sip:+-I $sip} $dip \
-c 10 -i 0.1 -w 2 &> /dev/null -c 10 -i 0.5 -w $ping_timeout &> /dev/null
local -A t1s local -A t1s
eval "t1s=($(dscp_fetch_stats $dev_10 10) eval "t1s=($(dscp_fetch_stats $dev_10 10)
......
...@@ -169,9 +169,10 @@ dscp_ping_test() ...@@ -169,9 +169,10 @@ dscp_ping_test()
eval "local -A dev1_t0s=($(dscp_fetch_stats $dev1 0))" eval "local -A dev1_t0s=($(dscp_fetch_stats $dev1 0))"
eval "local -A dev2_t0s=($(dscp_fetch_stats $dev2 0))" eval "local -A dev2_t0s=($(dscp_fetch_stats $dev2 0))"
local ping_timeout=$((PING_TIMEOUT * 5))
ip vrf exec $vrf_name \ ip vrf exec $vrf_name \
${PING} -Q $dscp ${sip:+-I $sip} $dip \ ${PING} -Q $dscp ${sip:+-I $sip} $dip \
-c 10 -i 0.1 -w 2 &> /dev/null -c 10 -i 0.5 -w $ping_timeout &> /dev/null
eval "local -A dev1_t1s=($(dscp_fetch_stats $dev1 0))" eval "local -A dev1_t1s=($(dscp_fetch_stats $dev1 0))"
eval "local -A dev2_t1s=($(dscp_fetch_stats $dev2 0))" eval "local -A dev2_t1s=($(dscp_fetch_stats $dev2 0))"
......
...@@ -33,3 +33,6 @@ PAUSE_ON_CLEANUP=no ...@@ -33,3 +33,6 @@ PAUSE_ON_CLEANUP=no
NETIF_TYPE=veth NETIF_TYPE=veth
# Whether to create virtual interfaces (veth) or not # Whether to create virtual interfaces (veth) or not
NETIF_CREATE=yes NETIF_CREATE=yes
# Timeout (in seconds) before ping exits regardless of how many packets have
# been sent or received
PING_TIMEOUT=5
...@@ -17,6 +17,7 @@ NETIF_TYPE=${NETIF_TYPE:=veth} ...@@ -17,6 +17,7 @@ NETIF_TYPE=${NETIF_TYPE:=veth}
NETIF_CREATE=${NETIF_CREATE:=yes} NETIF_CREATE=${NETIF_CREATE:=yes}
MCD=${MCD:=smcrouted} MCD=${MCD:=smcrouted}
MC_CLI=${MC_CLI:=smcroutectl} MC_CLI=${MC_CLI:=smcroutectl}
PING_TIMEOUT=${PING_TIMEOUT:=5}
relative_path="${BASH_SOURCE%/*}" relative_path="${BASH_SOURCE%/*}"
if [[ "$relative_path" == "${BASH_SOURCE}" ]]; then if [[ "$relative_path" == "${BASH_SOURCE}" ]]; then
...@@ -820,7 +821,8 @@ ping_do() ...@@ -820,7 +821,8 @@ ping_do()
local vrf_name local vrf_name
vrf_name=$(master_name_get $if_name) vrf_name=$(master_name_get $if_name)
ip vrf exec $vrf_name $PING $args $dip -c 10 -i 0.1 -w 2 &> /dev/null ip vrf exec $vrf_name \
$PING $args $dip -c 10 -i 0.1 -w $PING_TIMEOUT &> /dev/null
} }
ping_test() ping_test()
...@@ -840,7 +842,8 @@ ping6_do() ...@@ -840,7 +842,8 @@ ping6_do()
local vrf_name local vrf_name
vrf_name=$(master_name_get $if_name) vrf_name=$(master_name_get $if_name)
ip vrf exec $vrf_name $PING6 $args $dip -c 10 -i 0.1 -w 2 &> /dev/null ip vrf exec $vrf_name \
$PING6 $args $dip -c 10 -i 0.1 -w $PING_TIMEOUT &> /dev/null
} }
ping6_test() ping6_test()
......
...@@ -190,6 +190,8 @@ setup_prepare() ...@@ -190,6 +190,8 @@ setup_prepare()
h4_create h4_create
switch_create switch_create
forwarding_enable
trap_install $h3 ingress trap_install $h3 ingress
trap_install $h4 ingress trap_install $h4 ingress
} }
...@@ -201,6 +203,8 @@ cleanup() ...@@ -201,6 +203,8 @@ cleanup()
trap_uninstall $h4 ingress trap_uninstall $h4 ingress
trap_uninstall $h3 ingress trap_uninstall $h3 ingress
forwarding_restore
switch_destroy switch_destroy
h4_destroy h4_destroy
h3_destroy h3_destroy
...@@ -220,11 +224,15 @@ test_lag_slave() ...@@ -220,11 +224,15 @@ test_lag_slave()
RET=0 RET=0
tc filter add dev $swp1 ingress pref 999 \
proto 802.1q flower vlan_ethtype arp $tcflags \
action pass
mirror_install $swp1 ingress gt4 \ mirror_install $swp1 ingress gt4 \
"proto 802.1q flower vlan_id 333 $tcflags" "proto 802.1q flower vlan_id 333 $tcflags"
# Test connectivity through $up_dev when $down_dev is set down. # Test connectivity through $up_dev when $down_dev is set down.
ip link set dev $down_dev down ip link set dev $down_dev down
ip neigh flush dev br1
setup_wait_dev $up_dev setup_wait_dev $up_dev
setup_wait_dev $host_dev setup_wait_dev $host_dev
$ARPING -I br1 192.0.2.130 -qfc 1 $ARPING -I br1 192.0.2.130 -qfc 1
...@@ -240,6 +248,7 @@ test_lag_slave() ...@@ -240,6 +248,7 @@ test_lag_slave()
ip link set dev $up_dev up ip link set dev $up_dev up
ip link set dev $down_dev up ip link set dev $down_dev up
mirror_uninstall $swp1 ingress mirror_uninstall $swp1 ingress
tc filter del dev $swp1 ingress pref 999
log_test "$what ($tcflags)" log_test "$what ($tcflags)"
} }
......
...@@ -79,6 +79,7 @@ test_span_gre_ttl() ...@@ -79,6 +79,7 @@ test_span_gre_ttl()
mirror_test v$h1 192.0.2.1 192.0.2.2 $h3 77 0 mirror_test v$h1 192.0.2.1 192.0.2.2 $h3 77 0
ip link set dev $tundev type $type ttl 50 ip link set dev $tundev type $type ttl 50
sleep 2
mirror_test v$h1 192.0.2.1 192.0.2.2 $h3 77 10 mirror_test v$h1 192.0.2.1 192.0.2.2 $h3 77 10
ip link set dev $tundev type $type ttl 100 ip link set dev $tundev type $type ttl 100
......
...@@ -81,6 +81,8 @@ full_test_span_gre_dir_acl() ...@@ -81,6 +81,8 @@ full_test_span_gre_dir_acl()
local match_dip=$1; shift local match_dip=$1; shift
local what=$1; shift local what=$1; shift
RET=0
mirror_install $swp1 $direction $tundev \ mirror_install $swp1 $direction $tundev \
"protocol ip flower $tcflags dst_ip $match_dip" "protocol ip flower $tcflags dst_ip $match_dip"
fail_test_span_gre_dir $tundev $direction fail_test_span_gre_dir $tundev $direction
...@@ -108,8 +110,6 @@ test_ip6gretap() ...@@ -108,8 +110,6 @@ test_ip6gretap()
test_all() test_all()
{ {
RET=0
slow_path_trap_install $swp1 ingress slow_path_trap_install $swp1 ingress
slow_path_trap_install $swp1 egress slow_path_trap_install $swp1 egress
......
#!/bin/bash #!/bin/bash
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
# This test uses standard topology for testing gretap. See
# mirror_gre_topo_lib.sh for more details.
#
# Test for "tc action mirred egress mirror" when the underlay route points at a # Test for "tc action mirred egress mirror" when the underlay route points at a
# vlan device on top of a bridge device with vlan filtering (802.1q). # vlan device on top of a bridge device with vlan filtering (802.1q).
#
# +---------------------+ +---------------------+
# | H1 | | H2 |
# | + $h1 | | $h2 + |
# | | 192.0.2.1/28 | | 192.0.2.2/28 | |
# +-----|---------------+ +---------------|-----+
# | |
# +-----|-------------------------------------------------------------|-----+
# | SW o--> mirred egress mirror dev {gt4,gt6} | |
# | | | |
# | +---|-------------------------------------------------------------|---+ |
# | | + $swp1 br1 $swp2 + | |
# | | | |
# | | + $swp3 | |
# | +---|-----------------------------------------------------------------+ |
# | | | |
# | | + br1.555 |
# | | 192.0.2.130/28 |
# | | 2001:db8:2::2/64 |
# | | |
# | | + gt6 (ip6gretap) + gt4 (gretap) |
# | | : loc=2001:db8:2::1 : loc=192.0.2.129 |
# | | : rem=2001:db8:2::2 : rem=192.0.2.130 |
# | | : ttl=100 : ttl=100 |
# | | : tos=inherit : tos=inherit |
# | | : : |
# +-----|---------------------:----------------------:----------------------+
# | : :
# +-----|---------------------:----------------------:----------------------+
# | H3 + $h3 + h3-gt6 (ip6gretap) + h3-gt4 (gretap) |
# | | loc=2001:db8:2::2 loc=192.0.2.130 |
# | + $h3.555 rem=2001:db8:2::1 rem=192.0.2.129 |
# | 192.0.2.130/28 ttl=100 ttl=100 |
# | 2001:db8:2::2/64 tos=inherit tos=inherit |
# | |
# +-------------------------------------------------------------------------+
ALL_TESTS=" ALL_TESTS="
test_gretap test_gretap
...@@ -30,6 +63,15 @@ source mirror_gre_topo_lib.sh ...@@ -30,6 +63,15 @@ source mirror_gre_topo_lib.sh
require_command $ARPING require_command $ARPING
h3_addr_add_del()
{
local add_del=$1; shift
local dev=$1; shift
ip addr $add_del dev $dev 192.0.2.130/28
ip addr $add_del dev $dev 2001:db8:2::2/64
}
setup_prepare() setup_prepare()
{ {
h1=${NETIFS[p1]} h1=${NETIFS[p1]}
...@@ -55,7 +97,8 @@ setup_prepare() ...@@ -55,7 +97,8 @@ setup_prepare()
ip route rep 192.0.2.130/32 dev br1.555 ip route rep 192.0.2.130/32 dev br1.555
ip -6 route rep 2001:db8:2::2/128 dev br1.555 ip -6 route rep 2001:db8:2::2/128 dev br1.555
vlan_create $h3 555 v$h3 192.0.2.130/28 2001:db8:2::2/64 vlan_create $h3 555 v$h3
h3_addr_add_del add $h3.555
ip link set dev $swp3 master br1 ip link set dev $swp3 master br1
bridge vlan add dev $swp3 vid 555 bridge vlan add dev $swp3 vid 555
...@@ -68,6 +111,8 @@ cleanup() ...@@ -68,6 +111,8 @@ cleanup()
ip link set dev $swp2 nomaster ip link set dev $swp2 nomaster
ip link set dev $swp3 nomaster ip link set dev $swp3 nomaster
h3_addr_add_del del $h3.555
vlan_destroy $h3 555 vlan_destroy $h3 555
vlan_destroy br1 555 vlan_destroy br1 555
...@@ -182,13 +227,19 @@ test_span_gre_untagged_egress() ...@@ -182,13 +227,19 @@ test_span_gre_untagged_egress()
quick_test_span_gre_dir $tundev ingress quick_test_span_gre_dir $tundev ingress
quick_test_span_vlan_dir $h3 555 ingress quick_test_span_vlan_dir $h3 555 ingress
h3_addr_add_del del $h3.555
bridge vlan add dev $swp3 vid 555 pvid untagged bridge vlan add dev $swp3 vid 555 pvid untagged
sleep 1 h3_addr_add_del add $h3
sleep 5
quick_test_span_gre_dir $tundev ingress quick_test_span_gre_dir $tundev ingress
fail_test_span_vlan_dir $h3 555 ingress fail_test_span_vlan_dir $h3 555 ingress
h3_addr_add_del del $h3
bridge vlan add dev $swp3 vid 555 bridge vlan add dev $swp3 vid 555
sleep 1 h3_addr_add_del add $h3.555
sleep 5
quick_test_span_gre_dir $tundev ingress quick_test_span_gre_dir $tundev ingress
quick_test_span_vlan_dir $h3 555 ingress quick_test_span_vlan_dir $h3 555 ingress
...@@ -218,12 +269,25 @@ test_span_gre_fdb_roaming() ...@@ -218,12 +269,25 @@ test_span_gre_fdb_roaming()
mirror_install $swp1 ingress $tundev "matchall $tcflags" mirror_install $swp1 ingress $tundev "matchall $tcflags"
quick_test_span_gre_dir $tundev ingress quick_test_span_gre_dir $tundev ingress
bridge fdb del dev $swp3 $h3mac vlan 555 master while ((RET == 0)); do
bridge fdb del dev $swp3 $h3mac vlan 555 master 2>/dev/null
bridge fdb add dev $swp2 $h3mac vlan 555 master bridge fdb add dev $swp2 $h3mac vlan 555 master
sleep 1 sleep 1
fail_test_span_gre_dir $tundev ingress fail_test_span_gre_dir $tundev ingress
bridge fdb del dev $swp2 $h3mac vlan 555 master if ! bridge fdb sh dev $swp2 vlan 555 master \
| grep -q $h3mac; then
printf "TEST: %-60s [RETRY]\n" \
"$what: MAC roaming ($tcflags)"
# ARP or ND probably reprimed the FDB while the test
# was running. We would get a spurious failure.
RET=0
continue
fi
break
done
bridge fdb del dev $swp2 $h3mac vlan 555 master 2>/dev/null
# Re-prime FDB # Re-prime FDB
$ARPING -I br1.555 192.0.2.130 -fqc 1 $ARPING -I br1.555 192.0.2.130 -fqc 1
sleep 1 sleep 1
......
...@@ -29,9 +29,12 @@ mirror_test() ...@@ -29,9 +29,12 @@ mirror_test()
local pref=$1; shift local pref=$1; shift
local expect=$1; shift local expect=$1; shift
local ping_timeout=$((PING_TIMEOUT * 5))
local t0=$(tc_rule_stats_get $dev $pref) local t0=$(tc_rule_stats_get $dev $pref)
ip vrf exec $vrf_name \ ip vrf exec $vrf_name \
${PING} ${sip:+-I $sip} $dip -c 10 -i 0.1 -w 2 &> /dev/null ${PING} ${sip:+-I $sip} $dip -c 10 -i 0.5 -w $ping_timeout \
&> /dev/null
sleep 0.5
local t1=$(tc_rule_stats_get $dev $pref) local t1=$(tc_rule_stats_get $dev $pref)
local delta=$((t1 - t0)) local delta=$((t1 - t0))
# Tolerate a couple stray extra packets. # Tolerate a couple stray extra packets.
......
...@@ -170,7 +170,8 @@ ping_test_from() ...@@ -170,7 +170,8 @@ ping_test_from()
log_info "ping $dip, expected reply from $from" log_info "ping $dip, expected reply from $from"
ip vrf exec $(master_name_get $oif) \ ip vrf exec $(master_name_get $oif) \
$PING -I $oif $dip -c 10 -i 0.1 -w 2 -b 2>&1 | grep $from &> /dev/null $PING -I $oif $dip -c 10 -i 0.1 -w $PING_TIMEOUT -b 2>&1 \
| grep $from &> /dev/null
check_err_fail $fail $? check_err_fail $fail $?
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment