Skip to content

Commit

Permalink
selftests: net: local_termination: introduce new tests which capture …
Browse files Browse the repository at this point in the history
…VLAN behavior

Add more coverage to the local termination selftest as follows:
- 8021q upper of $h2
- 8021q upper of $h2, where $h2 is a port of a VLAN-unaware bridge
- 8021q upper of $h2, where $h2 is a port of a VLAN-aware bridge
- 8021q upper of VLAN-unaware br0, which is the upper of $h2
- 8021q upper of VLAN-aware br0, which is the upper of $h2

Especially the cases with traffic sent through the VLAN upper of a
VLAN-aware bridge port will be immediately relevant when we will start
transmitting PTP packets as an additional kind of traffic.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vladimir Oltean authored and David S. Miller committed Aug 16, 2024
1 parent 5b8e741 commit 5fea8bb
Showing 1 changed file with 110 additions and 7 deletions.
117 changes: 110 additions & 7 deletions tools/testing/selftests/net/forwarding/local_termination.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

ALL_TESTS="standalone vlan_unaware_bridge vlan_aware_bridge"
ALL_TESTS="standalone vlan_unaware_bridge vlan_aware_bridge test_vlan \
vlan_over_vlan_unaware_bridged_port vlan_over_vlan_aware_bridged_port \
vlan_over_vlan_unaware_bridge vlan_over_vlan_aware_bridge"
NUM_NETIFS=2
PING_COUNT=1
REQUIRE_MTOOLS=yes
Expand Down Expand Up @@ -231,6 +233,30 @@ h2_destroy()
simple_if_fini $h2 $H2_IPV4/24 $H2_IPV6/64
}

h1_vlan_create()
{
simple_if_init $h1
vlan_create $h1 100 v$h1 $H1_IPV4/24 $H1_IPV6/64
}

h1_vlan_destroy()
{
vlan_destroy $h1 100
simple_if_fini $h1
}

h2_vlan_create()
{
simple_if_init $h2
vlan_create $h2 100 v$h2 $H2_IPV4/24 $H2_IPV6/64
}

h2_vlan_destroy()
{
vlan_destroy $h2 100
simple_if_fini $h2
}

bridge_create()
{
local vlan_filtering=$1
Expand All @@ -241,14 +267,10 @@ bridge_create()

ip link set $h2 master br0
ip link set $h2 up

simple_if_init br0 $H2_IPV4/24 $H2_IPV6/64
}

bridge_destroy()
{
simple_if_fini br0 $H2_IPV4/24 $H2_IPV6/64

ip link del br0
}

Expand All @@ -272,7 +294,7 @@ standalone()
h2_create
macvlan_create $h2

run_test $h1 $h2
run_test $h1 $h2 "$h2"

macvlan_destroy
h2_destroy
Expand All @@ -285,11 +307,13 @@ test_bridge()

h1_create
bridge_create $vlan_filtering
simple_if_init br0 $H2_IPV4/24 $H2_IPV6/64
macvlan_create br0

run_test $h1 br0
run_test $h1 br0 "vlan_filtering=$vlan_filtering bridge"

macvlan_destroy
simple_if_fini br0 $H2_IPV4/24 $H2_IPV6/64
bridge_destroy
h1_destroy
}
Expand All @@ -304,6 +328,85 @@ vlan_aware_bridge()
test_bridge 1
}

test_vlan()
{
h1_vlan_create
h2_vlan_create
macvlan_create $h2.100

run_test $h1.100 $h2.100 "VLAN upper"

macvlan_destroy
h2_vlan_destroy
h1_vlan_destroy
}

vlan_over_bridged_port()
{
local vlan_filtering=$1

h1_vlan_create
h2_vlan_create
bridge_create $vlan_filtering
macvlan_create $h2.100

run_test $h1.100 $h2.100 "VLAN over vlan_filtering=$vlan_filtering bridged port"

macvlan_destroy
bridge_destroy
h2_vlan_destroy
h1_vlan_destroy
}

vlan_over_vlan_unaware_bridged_port()
{
vlan_over_bridged_port 0
}

vlan_over_vlan_aware_bridged_port()
{
vlan_over_bridged_port 1
}

vlan_over_bridge()
{
local vlan_filtering=$1

h1_vlan_create
bridge_create $vlan_filtering
simple_if_init br0
vlan_create br0 100 vbr0 $H2_IPV4/24 $H2_IPV6/64
macvlan_create br0.100

if [ $vlan_filtering = 1 ]; then
bridge vlan add dev $h2 vid 100 master
bridge vlan add dev br0 vid 100 self
fi

run_test $h1.100 br0.100 "VLAN over vlan_filtering=$vlan_filtering bridge"

if [ $vlan_filtering = 1 ]; then
bridge vlan del dev br0 vid 100 self
bridge vlan del dev $h2 vid 100 master
fi

macvlan_destroy
vlan_destroy br0 100
simple_if_fini br0
bridge_destroy
h1_vlan_destroy
}

vlan_over_vlan_unaware_bridge()
{
vlan_over_bridge 0
}

vlan_over_vlan_aware_bridge()
{
vlan_over_bridge 1
}

cleanup()
{
pre_cleanup
Expand Down

0 comments on commit 5fea8bb

Please sign in to comment.