Skip to content

Commit

Permalink
selftests: forwarding: vxlan_bridge_1d: Add flood test
Browse files Browse the repository at this point in the history
Test that when sending traffic to an unlearned MAC address, the traffic
is flooded to both remote VXLAN endpoints.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Petr Machata authored and David S. Miller committed Nov 20, 2018
1 parent 5852fd0 commit edaa117
Showing 1 changed file with 105 additions and 0 deletions.
105 changes: 105 additions & 0 deletions tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export VXPORT

: ${ALL_TESTS:="
ping_ipv4
test_flood
"}

NUM_NETIFS=6
Expand Down Expand Up @@ -289,6 +290,110 @@ ping_ipv4()
ping_test $h1 192.0.2.4 ": local->remote 2"
}

maybe_in_ns()
{
echo ${1:+in_ns} $1
}

__flood_counter_add_del()
{
local add_del=$1; shift
local dev=$1; shift
local ns=$1; shift

# Putting the ICMP capture both to HW and to SW will end up
# double-counting the packets that are trapped to slow path, such as for
# the unicast test. Adding either skip_hw or skip_sw fixes this problem,
# but with skip_hw, the flooded packets are not counted at all, because
# those are dropped due to MAC address mismatch; and skip_sw is a no-go
# for veth-based topologies.
#
# So try to install with skip_sw and fall back to skip_sw if that fails.

$(maybe_in_ns $ns) __icmp_capture_add_del \
$add_del 100 "" $dev skip_sw 2>/dev/null || \
$(maybe_in_ns $ns) __icmp_capture_add_del \
$add_del 100 "" $dev skip_hw
}

flood_counter_install()
{
__flood_counter_add_del add "$@"
}

flood_counter_uninstall()
{
__flood_counter_add_del del "$@"
}

flood_fetch_stat()
{
local dev=$1; shift
local ns=$1; shift

$(maybe_in_ns $ns) tc_rule_stats_get $dev 100 ingress
}

flood_fetch_stats()
{
local counters=("${@}")
local counter

for counter in "${counters[@]}"; do
flood_fetch_stat $counter
done
}

vxlan_flood_test()
{
local mac=$1; shift
local dst=$1; shift
local -a expects=("${@}")

local -a counters=($h2 "vx2 ns1" "vx2 ns2")
local counter
local key

for counter in "${counters[@]}"; do
flood_counter_install $counter
done

local -a t0s=($(flood_fetch_stats "${counters[@]}"))
$MZ $h1 -c 10 -d 100msec -p 64 -b $mac -B $dst -t icmp -q
sleep 1
local -a t1s=($(flood_fetch_stats "${counters[@]}"))

for key in ${!t0s[@]}; do
local delta=$((t1s[$key] - t0s[$key]))
local expect=${expects[$key]}

((expect == delta))
check_err $? "${counters[$key]}: Expected to capture $expect packets, got $delta."
done

for counter in "${counters[@]}"; do
flood_counter_uninstall $counter
done
}

__test_flood()
{
local mac=$1; shift
local dst=$1; shift
local what=$1; shift

RET=0

vxlan_flood_test $mac $dst 10 10 10

log_test "VXLAN: $what"
}

test_flood()
{
__test_flood de:ad:be:ef:13:37 192.0.2.100 "flood"
}

test_all()
{
echo "Running tests with UDP port $VXPORT"
Expand Down

0 comments on commit edaa117

Please sign in to comment.