Commit b0402f01 authored by David S. Miller's avatar David S. Miller

Merge branch 'Fixes-for-running-mirror-to-gretap-tests-on-veth'

Petr Machata says:

====================
Fixes for running mirror-to-gretap tests on veth

The forwarding selftests infrastructure makes it possible to run the
individual tests on a purely software netdevices. Names of interfaces to
run the test with can be passed as command line arguments to a test.
lib.sh then creates veth pairs backing the interfaces if none exist in
the system.

However, the tests need to recognize that they might be run on a soft
device. Many mirror-to-gretap tests are buggy in this regard. This patch
set aims to fix the problems in running mirror-to-gretap tests on veth
devices.

In patch #1, a service function is split out of setup_wait().
In patch #2, installing a trap is made optional.
In patch #3, tc filters in several tests are tweaked to work with veth.
In patch #4, the logic for waiting for neighbor is fixed for veth.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents b330219c 4e74cc7c
...@@ -185,11 +185,12 @@ log_info() ...@@ -185,11 +185,12 @@ log_info()
echo "INFO: $msg" echo "INFO: $msg"
} }
setup_wait() setup_wait_dev()
{ {
for i in $(eval echo {1..$NUM_NETIFS}); do local dev=$1; shift
while true; do while true; do
ip link show dev ${NETIFS[p$i]} up \ ip link show dev $dev up \
| grep 'state UP' &> /dev/null | grep 'state UP' &> /dev/null
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
sleep 1 sleep 1
...@@ -197,6 +198,12 @@ setup_wait() ...@@ -197,6 +198,12 @@ setup_wait()
break break
fi fi
done done
}
setup_wait()
{
for i in $(eval echo {1..$NUM_NETIFS}); do
setup_wait_dev ${NETIFS[p$i]}
done done
# Make sure links are ready. # Make sure links are ready.
...@@ -472,9 +479,15 @@ trap_install() ...@@ -472,9 +479,15 @@ trap_install()
local dev=$1; shift local dev=$1; shift
local direction=$1; shift local direction=$1; shift
# For slow-path testing, we need to install a trap to get to # Some devices may not support or need in-hardware trapping of traffic
# slow path the packets that would otherwise be switched in HW. # (e.g. the veth pairs that this library creates for non-existent
tc filter add dev $dev $direction pref 1 flower skip_sw action trap # loopbacks). Use continue instead, so that there is a filter in there
# (some tests check counters), and so that other filters are still
# processed.
tc filter add dev $dev $direction pref 1 \
flower skip_sw action trap 2>/dev/null \
|| tc filter add dev $dev $direction pref 1 \
flower action continue
} }
trap_uninstall() trap_uninstall()
...@@ -482,11 +495,13 @@ trap_uninstall() ...@@ -482,11 +495,13 @@ trap_uninstall()
local dev=$1; shift local dev=$1; shift
local direction=$1; shift local direction=$1; shift
tc filter del dev $dev $direction pref 1 flower skip_sw tc filter del dev $dev $direction pref 1 flower
} }
slow_path_trap_install() slow_path_trap_install()
{ {
# For slow-path testing, we need to install a trap to get to
# slow path the packets that would otherwise be switched in HW.
if [ "${tcflags/skip_hw}" != "$tcflags" ]; then if [ "${tcflags/skip_hw}" != "$tcflags" ]; then
trap_install "$@" trap_install "$@"
fi fi
......
...@@ -74,12 +74,14 @@ test_vlan_match() ...@@ -74,12 +74,14 @@ test_vlan_match()
test_gretap() test_gretap()
{ {
test_vlan_match gt4 'vlan_id 555 vlan_ethtype ip' "mirror to gretap" test_vlan_match gt4 'skip_hw vlan_id 555 vlan_ethtype ip' \
"mirror to gretap"
} }
test_ip6gretap() test_ip6gretap()
{ {
test_vlan_match gt6 'vlan_id 555 vlan_ethtype ipv6' "mirror to ip6gretap" test_vlan_match gt6 'skip_hw vlan_id 555 vlan_ethtype ip' \
"mirror to ip6gretap"
} }
test_gretap_stp() test_gretap_stp()
......
...@@ -122,15 +122,8 @@ test_span_gre_egress_up() ...@@ -122,15 +122,8 @@ test_span_gre_egress_up()
# After setting the device up, wait for neighbor to get resolved so that # After setting the device up, wait for neighbor to get resolved so that
# we can expect mirroring to work. # we can expect mirroring to work.
ip link set dev $swp3 up ip link set dev $swp3 up
while true; do setup_wait_dev $swp3
ip neigh sh dev $swp3 $remote_ip nud reachable | ping -c 1 -I $swp3 $remote_ip &>/dev/null
grep -q ^
if [[ $? -ne 0 ]]; then
sleep 1
else
break
fi
done
quick_test_span_gre_dir $tundev ingress quick_test_span_gre_dir $tundev ingress
mirror_uninstall $swp1 ingress mirror_uninstall $swp1 ingress
......
...@@ -62,7 +62,7 @@ full_test_span_gre_dir_vlan_ips() ...@@ -62,7 +62,7 @@ full_test_span_gre_dir_vlan_ips()
"$backward_type" "$ip1" "$ip2" "$backward_type" "$ip1" "$ip2"
tc filter add dev $h3 ingress pref 77 prot 802.1q \ tc filter add dev $h3 ingress pref 77 prot 802.1q \
flower $vlan_match ip_proto 0x2f \ flower $vlan_match \
action pass action pass
mirror_test v$h1 $ip1 $ip2 $h3 77 10 mirror_test v$h1 $ip1 $ip2 $h3 77 10
tc filter del dev $h3 ingress pref 77 tc filter del dev $h3 ingress pref 77
......
...@@ -88,12 +88,14 @@ test_vlan_match() ...@@ -88,12 +88,14 @@ test_vlan_match()
test_gretap() test_gretap()
{ {
test_vlan_match gt4 'vlan_id 555 vlan_ethtype ip' "mirror to gretap" test_vlan_match gt4 'skip_hw vlan_id 555 vlan_ethtype ip' \
"mirror to gretap"
} }
test_ip6gretap() test_ip6gretap()
{ {
test_vlan_match gt6 'vlan_id 555 vlan_ethtype ipv6' "mirror to ip6gretap" test_vlan_match gt6 'skip_hw vlan_id 555 vlan_ethtype ip' \
"mirror to ip6gretap"
} }
test_span_gre_forbidden_cpu() test_span_gre_forbidden_cpu()
......
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