Skip to content

Commit e29b82e

Browse files
vladimirolteandavem330
authored andcommitted
selftests: net: bridge_vlan_aware: test that other TPIDs are seen as untagged
The bridge VLAN implementation w.r.t. VLAN protocol is described in merge commit 1a0b20b ("Merge branch 'bridge-next'"). We are only sensitive to those VLAN tags whose TPID is equal to the bridge's vlan_protocol. Thus, an 802.1ad VLAN should be treated as 802.1Q-untagged. Add 3 tests which validate that: - 802.1ad-tagged traffic is learned into the PVID of an 802.1Q-aware bridge - Double-tagged traffic is forwarded when just the PVID of the port is present in the VLAN group of the ports - Double-tagged traffic is not forwarded when the PVID of the port is absent from the VLAN group of the ports The test passes with both veth and ocelot. Signed-off-by: Vladimir Oltean <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Tested-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2379795 commit e29b82e

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

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

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# SPDX-License-Identifier: GPL-2.0
33

4-
ALL_TESTS="ping_ipv4 ping_ipv6 learning flooding vlan_deletion extern_learn"
4+
ALL_TESTS="ping_ipv4 ping_ipv6 learning flooding vlan_deletion extern_learn other_tpid"
55
NUM_NETIFS=4
66
CHECK_TC="yes"
77
source lib.sh
@@ -142,6 +142,58 @@ extern_learn()
142142
bridge fdb del de:ad:be:ef:13:37 dev $swp1 master vlan 1 &> /dev/null
143143
}
144144

145+
other_tpid()
146+
{
147+
local mac=de:ad:be:ef:13:37
148+
149+
# Test that packets with TPID 802.1ad VID 3 + TPID 802.1Q VID 5 are
150+
# classified as untagged by a bridge with vlan_protocol 802.1Q, and
151+
# are processed in the PVID of the ingress port (here 1). Not VID 3,
152+
# and not VID 5.
153+
RET=0
154+
155+
tc qdisc add dev $h2 clsact
156+
tc filter add dev $h2 ingress protocol all pref 1 handle 101 \
157+
flower dst_mac $mac action drop
158+
ip link set $h2 promisc on
159+
ethtool -K $h2 rx-vlan-filter off rx-vlan-stag-filter off
160+
161+
$MZ -q $h1 -c 1 -b $mac -a own "88:a8 00:03 81:00 00:05 08:00 aa-aa-aa-aa-aa-aa-aa-aa-aa"
162+
sleep 1
163+
164+
# Match on 'self' addresses as well, for those drivers which
165+
# do not push their learned addresses to the bridge software
166+
# database
167+
bridge -j fdb show $swp1 | \
168+
jq -e ".[] | select(.mac == \"$(mac_get $h1)\") | select(.vlan == 1)" &> /dev/null
169+
check_err $? "FDB entry was not learned when it should"
170+
171+
log_test "FDB entry in PVID for VLAN-tagged with other TPID"
172+
173+
RET=0
174+
tc -j -s filter show dev $h2 ingress \
175+
| jq -e ".[] | select(.options.handle == 101) \
176+
| select(.options.actions[0].stats.packets == 1)" &> /dev/null
177+
check_err $? "Packet was not forwarded when it should"
178+
log_test "Reception of VLAN with other TPID as untagged"
179+
180+
bridge vlan del dev $swp1 vid 1
181+
182+
$MZ -q $h1 -c 1 -b $mac -a own "88:a8 00:03 81:00 00:05 08:00 aa-aa-aa-aa-aa-aa-aa-aa-aa"
183+
sleep 1
184+
185+
RET=0
186+
tc -j -s filter show dev $h2 ingress \
187+
| jq -e ".[] | select(.options.handle == 101) \
188+
| select(.options.actions[0].stats.packets == 1)" &> /dev/null
189+
check_err $? "Packet was forwarded when should not"
190+
log_test "Reception of VLAN with other TPID as untagged (no PVID)"
191+
192+
bridge vlan add dev $swp1 vid 1 pvid untagged
193+
ip link set $h2 promisc off
194+
tc qdisc del dev $h2 clsact
195+
}
196+
145197
trap cleanup EXIT
146198

147199
setup_prepare

0 commit comments

Comments
 (0)