Skip to content

Commit 236dd50

Browse files
idoschdavem330
authored andcommitted
selftests: forwarding: Add a test for flooded traffic
Add test cases for unknown unicast and unregistered multicast flooding. For each traffic type, turn off flooding on one bridged port and inject a packet of the specified type through the second bridged port. Make sure the packet was not received by checking the ACL counters on the other end. Later, turn on flooding and make sure the packet was received. Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d4deb01 commit 236dd50

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,6 @@ setup_wait
8282
ping_test $h1 192.0.2.2
8383
ping6_test $h1 2001:db8:1::2
8484
learning_test "br0" $swp1 $h1 $h2
85+
flood_test $swp2 $h1 $h2
8586

8687
exit $EXIT_STATUS

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

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,3 +372,92 @@ learning_test()
372372

373373
log_test "FDB learning"
374374
}
375+
376+
flood_test_do()
377+
{
378+
local should_flood=$1
379+
local mac=$2
380+
local ip=$3
381+
local host1_if=$4
382+
local host2_if=$5
383+
local err=0
384+
385+
# Add an ACL on `host2_if` which will tell us whether the packet
386+
# was flooded to it or not.
387+
tc qdisc add dev $host2_if ingress
388+
tc filter add dev $host2_if ingress protocol ip pref 1 handle 101 \
389+
flower dst_mac $mac action drop
390+
391+
$MZ $host1_if -c 1 -p 64 -b $mac -B $ip -t ip -q
392+
sleep 1
393+
394+
tc -j -s filter show dev $host2_if ingress \
395+
| jq -e ".[] | select(.options.handle == 101) \
396+
| select(.options.actions[0].stats.packets == 1)" &> /dev/null
397+
if [[ $? -ne 0 && $should_flood == "true" || \
398+
$? -eq 0 && $should_flood == "false" ]]; then
399+
err=1
400+
fi
401+
402+
tc filter del dev $host2_if ingress protocol ip pref 1 handle 101 flower
403+
tc qdisc del dev $host2_if ingress
404+
405+
return $err
406+
}
407+
408+
flood_unicast_test()
409+
{
410+
local br_port=$1
411+
local host1_if=$2
412+
local host2_if=$3
413+
local mac=de:ad:be:ef:13:37
414+
local ip=192.0.2.100
415+
416+
RET=0
417+
418+
bridge link set dev $br_port flood off
419+
420+
flood_test_do false $mac $ip $host1_if $host2_if
421+
check_err $? "Packet flooded when should not"
422+
423+
bridge link set dev $br_port flood on
424+
425+
flood_test_do true $mac $ip $host1_if $host2_if
426+
check_err $? "Packet was not flooded when should"
427+
428+
log_test "Unknown unicast flood"
429+
}
430+
431+
flood_multicast_test()
432+
{
433+
local br_port=$1
434+
local host1_if=$2
435+
local host2_if=$3
436+
local mac=01:00:5e:00:00:01
437+
local ip=239.0.0.1
438+
439+
RET=0
440+
441+
bridge link set dev $br_port mcast_flood off
442+
443+
flood_test_do false $mac $ip $host1_if $host2_if
444+
check_err $? "Packet flooded when should not"
445+
446+
bridge link set dev $br_port mcast_flood on
447+
448+
flood_test_do true $mac $ip $host1_if $host2_if
449+
check_err $? "Packet was not flooded when should"
450+
451+
log_test "Unregistered multicast flood"
452+
}
453+
454+
flood_test()
455+
{
456+
# `br_port` is connected to `host2_if`
457+
local br_port=$1
458+
local host1_if=$2
459+
local host2_if=$3
460+
461+
flood_unicast_test $br_port $host1_if $host2_if
462+
flood_multicast_test $br_port $host1_if $host2_if
463+
}

0 commit comments

Comments
 (0)