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

selftests: forwarding: Add PCP match and VLAN match tests

Send packets with VLAN and PCP set and check that TC flower filters can
match on these keys.

Signed-off-by: Amit Cohen <amitc@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Amit Cohen and committed by
David S. Miller
0637e1f8 ca059af8

+58 -1
+58 -1
tools/testing/selftests/net/forwarding/tc_flower.sh
··· 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 4 ALL_TESTS="match_dst_mac_test match_src_mac_test match_dst_ip_test \ 5 - match_src_ip_test match_ip_flags_test" 5 + match_src_ip_test match_ip_flags_test match_pcp_test match_vlan_test" 6 6 NUM_NETIFS=2 7 7 source tc_common.sh 8 8 source lib.sh ··· 217 217 tc filter del dev $h2 ingress protocol ip pref 4 handle 104 flower 218 218 219 219 log_test "ip_flags match ($tcflags)" 220 + } 221 + 222 + match_pcp_test() 223 + { 224 + RET=0 225 + 226 + vlan_create $h2 85 v$h2 192.0.2.11/24 227 + 228 + tc filter add dev $h2 ingress protocol 802.1q pref 1 handle 101 \ 229 + flower vlan_prio 6 $tcflags dst_mac $h2mac action drop 230 + tc filter add dev $h2 ingress protocol 802.1q pref 2 handle 102 \ 231 + flower vlan_prio 7 $tcflags dst_mac $h2mac action drop 232 + 233 + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -B 192.0.2.11 -Q 7:85 -t ip -q 234 + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -B 192.0.2.11 -Q 0:85 -t ip -q 235 + 236 + tc_check_packets "dev $h2 ingress" 101 0 237 + check_err $? "Matched on specified PCP when should not" 238 + 239 + tc_check_packets "dev $h2 ingress" 102 1 240 + check_err $? "Did not match on specified PCP" 241 + 242 + tc filter del dev $h2 ingress protocol 802.1q pref 2 handle 102 flower 243 + tc filter del dev $h2 ingress protocol 802.1q pref 1 handle 101 flower 244 + 245 + vlan_destroy $h2 85 246 + 247 + log_test "PCP match ($tcflags)" 248 + } 249 + 250 + match_vlan_test() 251 + { 252 + RET=0 253 + 254 + vlan_create $h2 85 v$h2 192.0.2.11/24 255 + vlan_create $h2 75 v$h2 192.0.2.10/24 256 + 257 + tc filter add dev $h2 ingress protocol 802.1q pref 1 handle 101 \ 258 + flower vlan_id 75 $tcflags action drop 259 + tc filter add dev $h2 ingress protocol 802.1q pref 2 handle 102 \ 260 + flower vlan_id 85 $tcflags action drop 261 + 262 + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -B 192.0.2.11 -Q 0:85 -t ip -q 263 + 264 + tc_check_packets "dev $h2 ingress" 101 0 265 + check_err $? "Matched on specified VLAN when should not" 266 + 267 + tc_check_packets "dev $h2 ingress" 102 1 268 + check_err $? "Did not match on specified VLAN" 269 + 270 + tc filter del dev $h2 ingress protocol 802.1q pref 2 handle 102 flower 271 + tc filter del dev $h2 ingress protocol 802.1q pref 1 handle 101 flower 272 + 273 + vlan_destroy $h2 75 274 + vlan_destroy $h2 85 275 + 276 + log_test "VLAN match ($tcflags)" 220 277 } 221 278 222 279 setup_prepare()