[PATCH RFC/RFT net-next v2 5/5] selftests: no_forwarding: test VLAN uppers on VLAN-unaware bridged ports

Jonas Gorski
2025-12-01T10:28:54Z

A VLAN upper on a bridged port consumes the VLAN on this port and
inhibits forwarding of it.

Add a test that for VLAN-unaware bridges a single VLAN upper prevents
forwarding of that VLAN from that port. This is asymmetric "blocking",
as other ports' traffic can still be forwarded to this port. This is not
tested, as this is a no-forward test, not a forward test.

Since we are testing VLAN uppers, skip checking untagged traffic in
those cases.

Disallowing VLAN uppers on bridge ports is a valid choice for switchdev
drivers, so test if we can create them first and skip the tests if not.

Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
v1 -> v2:
* new patch

.../selftests/net/forwarding/no_forwarding.sh | 20 ++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/forwarding/no_forwarding.sh b/tools/testing/selftests/net/forwarding/no_forwarding.sh
index c8adf04e1328..d223b5b79a4f 100755
--- a/tools/testing/selftests/net/forwarding/no_forwarding.sh
+++ b/tools/testing/selftests/net/forwarding/no_forwarding.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

-ALL_TESTS="standalone two_bridges one_bridge_two_pvids bridge_aware_vlan_uppers"
+ALL_TESTS="standalone two_bridges one_bridge_two_pvids bridge_unaware_vlan_upper bridge_aware_vlan_uppers"
NUM_NETIFS=4

source lib.sh
@@ -226,6 +226,24 @@ one_bridge_two_pvids()
ip link del br0
}

+bridge_unaware_vlan_upper()
+{
+ ip link add br0 type bridge && ip link set br0 up
+ ip link set $swp1 master br0
+ ip link set $swp2 master br0
+
+ if ! ip link add name $swp1.10 link $swp1 type vlan id 10 2>/dev/null; then
+ ip link del br0
+ echo "SKIP: bridge does not allow vlan uppers on bridge ports"
+ exit "$ksft_skip"
+ fi
+ vlan_destroy $swp1 10
+
+ run_test "Switch ports in VLAN-unaware bridge with VLAN upper" 1
+
+ ip link del br0
+}
+
bridge_aware_vlan_uppers()
{
ip link add br0 type bridge vlan_filtering 1 vlan_default_pvid 0
--
2.43.0