|
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 other_tpid" |
| 4 | +ALL_TESTS="ping_ipv4 ping_ipv6 learning flooding vlan_deletion extern_learn other_tpid 8021p drop_untagged" |
5 | 5 | NUM_NETIFS=4
|
6 | 6 | CHECK_TC="yes"
|
7 | 7 | source lib.sh
|
@@ -194,6 +194,100 @@ other_tpid()
|
194 | 194 | tc qdisc del dev $h2 clsact
|
195 | 195 | }
|
196 | 196 |
|
| 197 | +8021p_do() |
| 198 | +{ |
| 199 | + local should_fail=$1; shift |
| 200 | + local mac=de:ad:be:ef:13:37 |
| 201 | + |
| 202 | + tc filter add dev $h2 ingress protocol all pref 1 handle 101 \ |
| 203 | + flower dst_mac $mac action drop |
| 204 | + |
| 205 | + $MZ -q $h1 -c 1 -b $mac -a own "81:00 00:00 08:00 aa-aa-aa-aa-aa-aa-aa-aa-aa" |
| 206 | + sleep 1 |
| 207 | + |
| 208 | + tc -j -s filter show dev $h2 ingress \ |
| 209 | + | jq -e ".[] | select(.options.handle == 101) \ |
| 210 | + | select(.options.actions[0].stats.packets == 1)" &> /dev/null |
| 211 | + check_err_fail $should_fail $? "802.1p-tagged reception" |
| 212 | + |
| 213 | + tc filter del dev $h2 ingress pref 1 |
| 214 | +} |
| 215 | + |
| 216 | +8021p() |
| 217 | +{ |
| 218 | + RET=0 |
| 219 | + |
| 220 | + tc qdisc add dev $h2 clsact |
| 221 | + ip link set $h2 promisc on |
| 222 | + |
| 223 | + # Test that with the default_pvid, 1, packets tagged with VID 0 are |
| 224 | + # accepted. |
| 225 | + 8021p_do 0 |
| 226 | + |
| 227 | + # Test that packets tagged with VID 0 are still accepted after changing |
| 228 | + # the default_pvid. |
| 229 | + ip link set br0 type bridge vlan_default_pvid 10 |
| 230 | + 8021p_do 0 |
| 231 | + |
| 232 | + log_test "Reception of 802.1p-tagged traffic" |
| 233 | + |
| 234 | + ip link set $h2 promisc off |
| 235 | + tc qdisc del dev $h2 clsact |
| 236 | +} |
| 237 | + |
| 238 | +send_untagged_and_8021p() |
| 239 | +{ |
| 240 | + ping_do $h1 192.0.2.2 |
| 241 | + check_fail $? |
| 242 | + |
| 243 | + 8021p_do 1 |
| 244 | +} |
| 245 | + |
| 246 | +drop_untagged() |
| 247 | +{ |
| 248 | + RET=0 |
| 249 | + |
| 250 | + tc qdisc add dev $h2 clsact |
| 251 | + ip link set $h2 promisc on |
| 252 | + |
| 253 | + # Test that with no PVID, untagged and 802.1p-tagged traffic is |
| 254 | + # dropped. |
| 255 | + ip link set br0 type bridge vlan_default_pvid 1 |
| 256 | + |
| 257 | + # First we reconfigure the default_pvid, 1, as a non-PVID VLAN. |
| 258 | + bridge vlan add dev $swp1 vid 1 untagged |
| 259 | + send_untagged_and_8021p |
| 260 | + bridge vlan add dev $swp1 vid 1 pvid untagged |
| 261 | + |
| 262 | + # Next we try to delete VID 1 altogether |
| 263 | + bridge vlan del dev $swp1 vid 1 |
| 264 | + send_untagged_and_8021p |
| 265 | + bridge vlan add dev $swp1 vid 1 pvid untagged |
| 266 | + |
| 267 | + # Set up the bridge without a default_pvid, then check that the 8021q |
| 268 | + # module, when the bridge port goes down and then up again, does not |
| 269 | + # accidentally re-enable untagged packet reception. |
| 270 | + ip link set br0 type bridge vlan_default_pvid 0 |
| 271 | + ip link set $swp1 down |
| 272 | + ip link set $swp1 up |
| 273 | + setup_wait |
| 274 | + send_untagged_and_8021p |
| 275 | + |
| 276 | + # Remove swp1 as a bridge port and let it rejoin the bridge while it |
| 277 | + # has no default_pvid. |
| 278 | + ip link set $swp1 nomaster |
| 279 | + ip link set $swp1 master br0 |
| 280 | + send_untagged_and_8021p |
| 281 | + |
| 282 | + # Restore settings |
| 283 | + ip link set br0 type bridge vlan_default_pvid 1 |
| 284 | + |
| 285 | + log_test "Dropping of untagged and 802.1p-tagged traffic with no PVID" |
| 286 | + |
| 287 | + ip link set $h2 promisc off |
| 288 | + tc qdisc del dev $h2 clsact |
| 289 | +} |
| 290 | + |
197 | 291 | trap cleanup EXIT
|
198 | 292 |
|
199 | 293 | setup_prepare
|
|
0 commit comments