Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 1a0b20b25732 ("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 <vladimir.oltean@nxp.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Tested-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vladimir Oltean and committed by
David S. Miller
e29b82ef 23797950

+53 -1
+53 -1
tools/testing/selftests/net/forwarding/bridge_vlan_aware.sh
··· 1 1 #!/bin/bash 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 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" 5 5 NUM_NETIFS=4 6 6 CHECK_TC="yes" 7 7 source lib.sh ··· 140 140 141 141 bridge fdb del de:ad:be:ef:13:37 dev $swp2 master vlan 1 &> /dev/null 142 142 bridge fdb del de:ad:be:ef:13:37 dev $swp1 master vlan 1 &> /dev/null 143 + } 144 + 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 143 195 } 144 196 145 197 trap cleanup EXIT