Skip to content

Commit

Permalink
Merge branch 'mirror-to-gretap-tests'
Browse files Browse the repository at this point in the history
Petr Machata says:

====================
Test mirror-to-gretap with bridge in UL

This patchset adds more tests to the mirror-to-gretap suite where bridge
is present in the underlay. Specifically it adds tests for bridge VLAN
handling, FDB, and bridge port STP status.

In patches #1-#3, the codebase is refactored to support the new tests.

In patch #4, an STP test is added to the mirroring library, that will
later be called from bridge tests.

In patches #5-#8, the test for mirror-to-gretap with an 802.1q bridge in
underlay is adapted and more tests are added.

In patch #9, an STP test is added to the test suite for mirror-to-gretap
with an 802.1d bridge in underlay.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jun 1, 2018
2 parents db9d7d3 + b5b0293 commit 07f7ee6
Show file tree
Hide file tree
Showing 6 changed files with 244 additions and 47 deletions.
23 changes: 23 additions & 0 deletions tools/testing/selftests/net/forwarding/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,29 @@ icmp6_capture_uninstall()
__icmp_capture_add_del del 100 v6 "$@"
}

__vlan_capture_add_del()
{
local add_del=$1; shift
local pref=$1; shift
local dev=$1; shift
local filter=$1; shift

tc filter $add_del dev "$dev" ingress \
proto 802.1q pref $pref \
flower $filter \
action pass
}

vlan_capture_install()
{
__vlan_capture_add_del add 100 "$@"
}

vlan_capture_uninstall()
{
__vlan_capture_add_del del 100 "$@"
}

matchall_sink_create()
{
local dev=$1; shift
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
ALL_TESTS="
test_gretap
test_ip6gretap
test_gretap_stp
test_ip6gretap_stp
"

NUM_NETIFS=6
Expand Down Expand Up @@ -80,6 +82,16 @@ test_ip6gretap()
test_vlan_match gt6 'vlan_id 555 vlan_ethtype ipv6' "mirror to ip6gretap"
}

test_gretap_stp()
{
full_test_span_gre_stp gt4 $swp3.555 "mirror to gretap"
}

test_ip6gretap_stp()
{
full_test_span_gre_stp gt6 $swp3.555 "mirror to ip6gretap"
}

test_all()
{
slow_path_trap_install $swp1 ingress
Expand Down
32 changes: 32 additions & 0 deletions tools/testing/selftests/net/forwarding/mirror_gre_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,35 @@ full_test_span_gre_dir_vlan()
{
full_test_span_gre_dir_vlan_ips "$@" 192.0.2.1 192.0.2.2
}

full_test_span_gre_stp_ips()
{
local tundev=$1; shift
local nbpdev=$1; shift
local what=$1; shift
local ip1=$1; shift
local ip2=$1; shift
local h3mac=$(mac_get $h3)

RET=0

mirror_install $swp1 ingress $tundev "matchall $tcflags"
quick_test_span_gre_dir_ips $tundev ingress $ip1 $ip2

bridge link set dev $nbpdev state disabled
sleep 1
fail_test_span_gre_dir_ips $tundev ingress $ip1 $ip2

bridge link set dev $nbpdev state forwarding
sleep 1
quick_test_span_gre_dir_ips $tundev ingress $ip1 $ip2

mirror_uninstall $swp1 ingress

log_test "$what: STP state ($tcflags)"
}

full_test_span_gre_stp()
{
full_test_span_gre_stp_ips "$@" 192.0.2.1 192.0.2.2
}
148 changes: 139 additions & 9 deletions tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@
ALL_TESTS="
test_gretap
test_ip6gretap
test_gretap_forbidden
test_ip6gretap_forbidden
test_gretap_forbidden_cpu
test_ip6gretap_forbidden_cpu
test_gretap_forbidden_egress
test_ip6gretap_forbidden_egress
test_gretap_untagged_egress
test_ip6gretap_untagged_egress
test_gretap_fdb_roaming
test_ip6gretap_fdb_roaming
test_gretap_stp
test_ip6gretap_stp
"

NUM_NETIFS=6
Expand Down Expand Up @@ -43,12 +51,14 @@ setup_prepare()

ip link set dev $swp3 master br1
bridge vlan add dev $swp3 vid 555
bridge vlan add dev $swp2 vid 555
}

cleanup()
{
pre_cleanup

ip link set dev $swp2 nomaster
ip link set dev $swp3 nomaster
vlan_destroy $h3 555
vlan_destroy br1 555
Expand Down Expand Up @@ -77,7 +87,7 @@ test_ip6gretap()
test_vlan_match gt6 'vlan_id 555 vlan_ethtype ipv6' "mirror to ip6gretap"
}

test_span_gre_forbidden()
test_span_gre_forbidden_cpu()
{
local tundev=$1; shift
local what=$1; shift
Expand All @@ -91,24 +101,144 @@ test_span_gre_forbidden()
# Now forbid the VLAN at the bridge and see it fail.
bridge vlan del dev br1 vid 555 self
sleep 1

fail_test_span_gre_dir $tundev ingress
mirror_uninstall $swp1 ingress

bridge vlan add dev br1 vid 555 self
sleep 1
quick_test_span_gre_dir $tundev ingress

mirror_uninstall $swp1 ingress

log_test "$what: vlan forbidden at a bridge ($tcflags)"
}

test_gretap_forbidden()
test_gretap_forbidden_cpu()
{
test_span_gre_forbidden_cpu gt4 "mirror to gretap"
}

test_ip6gretap_forbidden_cpu()
{
test_span_gre_forbidden_cpu gt6 "mirror to ip6gretap"
}

test_span_gre_forbidden_egress()
{
local tundev=$1; shift
local what=$1; shift

RET=0

mirror_install $swp1 ingress $tundev "matchall $tcflags"
quick_test_span_gre_dir $tundev ingress

bridge vlan del dev $swp3 vid 555
sleep 1
fail_test_span_gre_dir $tundev ingress

bridge vlan add dev $swp3 vid 555
# Re-prime FDB
arping -I br1.555 192.0.2.130 -fqc 1
sleep 1
quick_test_span_gre_dir $tundev ingress

mirror_uninstall $swp1 ingress

log_test "$what: vlan forbidden at a bridge egress ($tcflags)"
}

test_gretap_forbidden_egress()
{
test_span_gre_forbidden_egress gt4 "mirror to gretap"
}

test_ip6gretap_forbidden_egress()
{
test_span_gre_forbidden_egress gt6 "mirror to ip6gretap"
}

test_span_gre_untagged_egress()
{
local tundev=$1; shift
local what=$1; shift

RET=0

mirror_install $swp1 ingress $tundev "matchall $tcflags"

quick_test_span_gre_dir $tundev ingress
quick_test_span_vlan_dir $h3 555 ingress

bridge vlan add dev $swp3 vid 555 pvid untagged
sleep 1
quick_test_span_gre_dir $tundev ingress
fail_test_span_vlan_dir $h3 555 ingress

bridge vlan add dev $swp3 vid 555
sleep 1
quick_test_span_gre_dir $tundev ingress
quick_test_span_vlan_dir $h3 555 ingress

mirror_uninstall $swp1 ingress

log_test "$what: vlan untagged at a bridge egress ($tcflags)"
}

test_gretap_untagged_egress()
{
test_span_gre_untagged_egress gt4 "mirror to gretap"
}

test_ip6gretap_untagged_egress()
{
test_span_gre_untagged_egress gt6 "mirror to ip6gretap"
}

test_span_gre_fdb_roaming()
{
local tundev=$1; shift
local what=$1; shift
local h3mac=$(mac_get $h3)

RET=0

mirror_install $swp1 ingress $tundev "matchall $tcflags"
quick_test_span_gre_dir $tundev ingress

bridge fdb del dev $swp3 $h3mac vlan 555 master
bridge fdb add dev $swp2 $h3mac vlan 555 master
sleep 1
fail_test_span_gre_dir $tundev ingress

bridge fdb del dev $swp2 $h3mac vlan 555 master
# Re-prime FDB
arping -I br1.555 192.0.2.130 -fqc 1
sleep 1
quick_test_span_gre_dir $tundev ingress

mirror_uninstall $swp1 ingress

log_test "$what: MAC roaming ($tcflags)"
}

test_gretap_fdb_roaming()
{
test_span_gre_fdb_roaming gt4 "mirror to gretap"
}

test_ip6gretap_fdb_roaming()
{
test_span_gre_fdb_roaming gt6 "mirror to ip6gretap"
}

test_gretap_stp()
{
test_span_gre_forbidden gt4 "mirror to gretap"
full_test_span_gre_stp gt4 $swp3 "mirror to gretap"
}

test_ip6gretap_forbidden()
test_ip6gretap_stp()
{
test_span_gre_forbidden gt4 "mirror to ip6gretap"
full_test_span_gre_stp gt6 $swp3 "mirror to ip6gretap"
}

test_all()
Expand Down
38 changes: 38 additions & 0 deletions tools/testing/selftests/net/forwarding/mirror_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,41 @@ test_span_dir()
{
test_span_dir_ips "$@" 192.0.2.1 192.0.2.2
}

do_test_span_vlan_dir_ips()
{
local expect=$1; shift
local dev=$1; shift
local vid=$1; shift
local direction=$1; shift
local ip1=$1; shift
local ip2=$1; shift

# Install the capture as skip_hw to avoid double-counting of packets.
# The traffic is meant for local box anyway, so will be trapped to
# kernel.
vlan_capture_install $dev "skip_hw vlan_id $vid"
mirror_test v$h1 $ip1 $ip2 $dev 100 $expect
mirror_test v$h2 $ip2 $ip1 $dev 100 $expect
vlan_capture_uninstall $dev
}

quick_test_span_vlan_dir_ips()
{
do_test_span_vlan_dir_ips 10 "$@"
}

fail_test_span_vlan_dir_ips()
{
do_test_span_vlan_dir_ips 0 "$@"
}

quick_test_span_vlan_dir()
{
quick_test_span_vlan_dir_ips "$@" 192.0.2.1 192.0.2.2
}

fail_test_span_vlan_dir()
{
fail_test_span_vlan_dir_ips "$@" 192.0.2.1 192.0.2.2
}
38 changes: 0 additions & 38 deletions tools/testing/selftests/net/forwarding/mirror_vlan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,44 +76,6 @@ test_vlan()
test_vlan_dir egress 0 8
}

vlan_capture_add_del()
{
local add_del=$1; shift
local pref=$1; shift
local dev=$1; shift
local filter=$1; shift

tc filter $add_del dev "$dev" ingress \
proto 802.1q pref $pref \
flower $filter \
action pass
}

vlan_capture_install()
{
vlan_capture_add_del add 100 "$@"
}

vlan_capture_uninstall()
{
vlan_capture_add_del del 100 "$@"
}

do_test_span_vlan_dir_ips()
{
local expect=$1; shift
local dev=$1; shift
local vid=$1; shift
local direction=$1; shift
local ip1=$1; shift
local ip2=$1; shift

vlan_capture_install $dev "vlan_id $vid"
mirror_test v$h1 $ip1 $ip2 $dev 100 $expect
mirror_test v$h2 $ip2 $ip1 $dev 100 $expect
vlan_capture_uninstall $dev
}

test_tagged_vlan_dir()
{
local direction=$1; shift
Expand Down

0 comments on commit 07f7ee6

Please sign in to comment.