brintos

brintos / linux-shallow public Read only

0
0
Text · 21.2 KiB · b1daad1 Raw
718 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03 4ALL_TESTS="match_dst_mac_test match_src_mac_test match_dst_ip_test \5	match_src_ip_test match_ip_flags_test match_pcp_test match_vlan_test \6	match_ip_tos_test match_indev_test match_ip_ttl_test7	match_mpls_label_test \8	match_mpls_tc_test match_mpls_bos_test match_mpls_ttl_test \9	match_mpls_lse_test"10NUM_NETIFS=211source tc_common.sh12source lib.sh13 14tcflags="skip_hw"15 16h1_create()17{18	simple_if_init $h1 192.0.2.1/24 198.51.100.1/2419}20 21h1_destroy()22{23	simple_if_fini $h1 192.0.2.1/24 198.51.100.1/2424}25 26h2_create()27{28	simple_if_init $h2 192.0.2.2/24 198.51.100.2/2429	tc qdisc add dev $h2 clsact30}31 32h2_destroy()33{34	tc qdisc del dev $h2 clsact35	simple_if_fini $h2 192.0.2.2/24 198.51.100.2/2436}37 38match_dst_mac_test()39{40	local dummy_mac=de:ad:be:ef:aa:aa41 42	RET=043 44	tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \45		$tcflags dst_mac $dummy_mac action drop46	tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \47		$tcflags dst_mac $h2mac action drop48 49	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \50		-t ip -q51 52	tc_check_packets "dev $h2 ingress" 101 153	check_fail $? "Matched on a wrong filter"54 55	tc_check_packets "dev $h2 ingress" 102 056	check_fail $? "Did not match on correct filter"57 58	tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower59	tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower60 61	log_test "dst_mac match ($tcflags)"62}63 64match_src_mac_test()65{66	local dummy_mac=de:ad:be:ef:aa:aa67 68	RET=069 70	tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \71		$tcflags src_mac $dummy_mac action drop72	tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \73		$tcflags src_mac $h1mac action drop74 75	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \76		-t ip -q77 78	tc_check_packets "dev $h2 ingress" 101 179	check_fail $? "Matched on a wrong filter"80 81	tc_check_packets "dev $h2 ingress" 102 082	check_fail $? "Did not match on correct filter"83 84	tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower85	tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower86 87	log_test "src_mac match ($tcflags)"88}89 90match_dst_ip_test()91{92	RET=093 94	tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \95		$tcflags dst_ip 198.51.100.2 action drop96	tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \97		$tcflags dst_ip 192.0.2.2 action drop98	tc filter add dev $h2 ingress protocol ip pref 3 handle 103 flower \99		$tcflags dst_ip 192.0.2.0/24 action drop100 101	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \102		-t ip -q103 104	tc_check_packets "dev $h2 ingress" 101 1105	check_fail $? "Matched on a wrong filter"106 107	tc_check_packets "dev $h2 ingress" 102 1108	check_err $? "Did not match on correct filter"109 110	tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower111 112	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \113		-t ip -q114 115	tc_check_packets "dev $h2 ingress" 103 1116	check_err $? "Did not match on correct filter with mask"117 118	tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower119	tc filter del dev $h2 ingress protocol ip pref 3 handle 103 flower120 121	log_test "dst_ip match ($tcflags)"122}123 124match_src_ip_test()125{126	RET=0127 128	tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \129		$tcflags src_ip 198.51.100.1 action drop130	tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \131		$tcflags src_ip 192.0.2.1 action drop132	tc filter add dev $h2 ingress protocol ip pref 3 handle 103 flower \133		$tcflags src_ip 192.0.2.0/24 action drop134 135	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \136		-t ip -q137 138	tc_check_packets "dev $h2 ingress" 101 1139	check_fail $? "Matched on a wrong filter"140 141	tc_check_packets "dev $h2 ingress" 102 1142	check_err $? "Did not match on correct filter"143 144	tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower145 146	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \147		-t ip -q148 149	tc_check_packets "dev $h2 ingress" 103 1150	check_err $? "Did not match on correct filter with mask"151 152	tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower153	tc filter del dev $h2 ingress protocol ip pref 3 handle 103 flower154 155	log_test "src_ip match ($tcflags)"156}157 158match_ip_flags_test()159{160	RET=0161 162	tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \163		$tcflags ip_flags frag action continue164	tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \165		$tcflags ip_flags firstfrag action continue166	tc filter add dev $h2 ingress protocol ip pref 3 handle 103 flower \167		$tcflags ip_flags nofirstfrag action continue168	tc filter add dev $h2 ingress protocol ip pref 4 handle 104 flower \169		$tcflags ip_flags nofrag action drop170 171	$MZ $h1 -c 1 -p 1000 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \172		-t ip "frag=0" -q173 174	tc_check_packets "dev $h2 ingress" 101 1175	check_fail $? "Matched on wrong frag filter (nofrag)"176 177	tc_check_packets "dev $h2 ingress" 102 1178	check_fail $? "Matched on wrong firstfrag filter (nofrag)"179 180	tc_check_packets "dev $h2 ingress" 103 1181	check_err $? "Did not match on nofirstfrag filter (nofrag) "182 183	tc_check_packets "dev $h2 ingress" 104 1184	check_err $? "Did not match on nofrag filter (nofrag)"185 186	$MZ $h1 -c 1 -p 1000 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \187		-t ip "frag=0,mf" -q188 189	tc_check_packets "dev $h2 ingress" 101 1190	check_err $? "Did not match on frag filter (1stfrag)"191 192	tc_check_packets "dev $h2 ingress" 102 1193	check_err $? "Did not match fistfrag filter (1stfrag)"194 195	tc_check_packets "dev $h2 ingress" 103 1196	check_err $? "Matched on wrong nofirstfrag filter (1stfrag)"197 198	tc_check_packets "dev $h2 ingress" 104 1199	check_err $? "Match on wrong nofrag filter (1stfrag)"200 201	$MZ $h1 -c 1 -p 1000 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \202		-t ip "frag=256,mf" -q203	$MZ $h1 -c 1 -p 1000 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \204		-t ip "frag=256" -q205 206	tc_check_packets "dev $h2 ingress" 101 3207	check_err $? "Did not match on frag filter (no1stfrag)"208 209	tc_check_packets "dev $h2 ingress" 102 1210	check_err $? "Matched on wrong firstfrag filter (no1stfrag)"211 212	tc_check_packets "dev $h2 ingress" 103 3213	check_err $? "Did not match on nofirstfrag filter (no1stfrag)"214 215	tc_check_packets "dev $h2 ingress" 104 1216	check_err $? "Matched on nofrag filter (no1stfrag)"217 218	tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower219	tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower220	tc filter del dev $h2 ingress protocol ip pref 3 handle 103 flower221	tc filter del dev $h2 ingress protocol ip pref 4 handle 104 flower222 223	log_test "ip_flags match ($tcflags)"224}225 226match_pcp_test()227{228	RET=0229 230	vlan_create $h2 85 v$h2 192.0.2.11/24231 232	tc filter add dev $h2 ingress protocol 802.1q pref 1 handle 101 \233		flower vlan_prio 6 $tcflags dst_mac $h2mac action drop234	tc filter add dev $h2 ingress protocol 802.1q pref 2 handle 102 \235		flower vlan_prio 7 $tcflags dst_mac $h2mac action drop236 237	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -B 192.0.2.11 -Q 7:85 -t ip -q238	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -B 192.0.2.11 -Q 0:85 -t ip -q239 240	tc_check_packets "dev $h2 ingress" 101 0241	check_err $? "Matched on specified PCP when should not"242 243	tc_check_packets "dev $h2 ingress" 102 1244	check_err $? "Did not match on specified PCP"245 246	tc filter del dev $h2 ingress protocol 802.1q pref 2 handle 102 flower247	tc filter del dev $h2 ingress protocol 802.1q pref 1 handle 101 flower248 249	vlan_destroy $h2 85250 251	log_test "PCP match ($tcflags)"252}253 254match_vlan_test()255{256	RET=0257 258	vlan_create $h2 85 v$h2 192.0.2.11/24259	vlan_create $h2 75 v$h2 192.0.2.10/24260 261	tc filter add dev $h2 ingress protocol 802.1q pref 1 handle 101 \262		flower vlan_id 75 $tcflags action drop263	tc filter add dev $h2 ingress protocol 802.1q pref 2 handle 102 \264		flower vlan_id 85 $tcflags action drop265 266	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -B 192.0.2.11 -Q 0:85 -t ip -q267 268	tc_check_packets "dev $h2 ingress" 101 0269	check_err $? "Matched on specified VLAN when should not"270 271	tc_check_packets "dev $h2 ingress" 102 1272	check_err $? "Did not match on specified VLAN"273 274	tc filter del dev $h2 ingress protocol 802.1q pref 2 handle 102 flower275	tc filter del dev $h2 ingress protocol 802.1q pref 1 handle 101 flower276 277	vlan_destroy $h2 75278	vlan_destroy $h2 85279 280	log_test "VLAN match ($tcflags)"281}282 283match_ip_tos_test()284{285	RET=0286 287	tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \288		$tcflags dst_ip 192.0.2.2 ip_tos 0x20 action drop289	tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \290		$tcflags dst_ip 192.0.2.2 ip_tos 0x18 action drop291 292	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \293		-t ip tos=18 -q294 295	tc_check_packets "dev $h2 ingress" 101 1296	check_fail $? "Matched on a wrong filter (0x18)"297 298	tc_check_packets "dev $h2 ingress" 102 1299	check_err $? "Did not match on correct filter (0x18)"300 301	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \302		-t ip tos=20 -q303 304	tc_check_packets "dev $h2 ingress" 102 2305	check_fail $? "Matched on a wrong filter (0x20)"306 307	tc_check_packets "dev $h2 ingress" 101 1308	check_err $? "Did not match on correct filter (0x20)"309 310	tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower311	tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower312 313	log_test "ip_tos match ($tcflags)"314}315 316match_ip_ttl_test()317{318	RET=0319 320	tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \321		$tcflags dst_ip 192.0.2.2 ip_ttl 63 action drop322	tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \323		$tcflags dst_ip 192.0.2.2 action drop324 325	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \326		-t ip "ttl=63" -q327 328	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \329		-t ip "ttl=63,mf,frag=256" -q330 331	tc_check_packets "dev $h2 ingress" 102 1332	check_fail $? "Matched on the wrong filter (no check on ttl)"333 334	tc_check_packets "dev $h2 ingress" 101 2335	check_err $? "Did not match on correct filter (ttl=63)"336 337	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \338		-t ip "ttl=255" -q339 340	tc_check_packets "dev $h2 ingress" 101 3341	check_fail $? "Matched on a wrong filter (ttl=63)"342 343	tc_check_packets "dev $h2 ingress" 102 1344	check_err $? "Did not match on correct filter (no check on ttl)"345 346	tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower347	tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower348 349	log_test "ip_ttl match ($tcflags)"350}351 352match_indev_test()353{354	RET=0355 356	tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \357		$tcflags indev $h1 dst_mac $h2mac action drop358	tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \359		$tcflags indev $h2 dst_mac $h2mac action drop360 361	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \362		-t ip -q363 364	tc_check_packets "dev $h2 ingress" 101 1365	check_fail $? "Matched on a wrong filter"366 367	tc_check_packets "dev $h2 ingress" 102 1368	check_err $? "Did not match on correct filter"369 370	tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower371	tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower372 373	log_test "indev match ($tcflags)"374}375 376# Unfortunately, mausezahn can't build MPLS headers when used in L2377# mode, so we have this function to build Label Stack Entries.378mpls_lse()379{380	local label=$1381	local tc=$2382	local bos=$3383	local ttl=$4384 385	printf "%02x %02x %02x %02x"                        \386		$((label >> 12))                            \387		$((label >> 4 & 0xff))                      \388		$((((label & 0xf) << 4) + (tc << 1) + bos)) \389		$ttl390}391 392match_mpls_label_test()393{394	local ethtype="88 47"; readonly ethtype395	local pkt396 397	RET=0398 399	check_tc_mpls_support $h2 || return 0400 401	tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \402		flower $tcflags mpls_label 0 action drop403	tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \404		flower $tcflags mpls_label 1048575 action drop405 406	pkt="$ethtype $(mpls_lse 1048575 0 1 255)"407	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q408 409	tc_check_packets "dev $h2 ingress" 101 1410	check_fail $? "Matched on a wrong filter (1048575)"411 412	tc_check_packets "dev $h2 ingress" 102 1413	check_err $? "Did not match on correct filter (1048575)"414 415	pkt="$ethtype $(mpls_lse 0 0 1 255)"416	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q417 418	tc_check_packets "dev $h2 ingress" 102 2419	check_fail $? "Matched on a wrong filter (0)"420 421	tc_check_packets "dev $h2 ingress" 101 1422	check_err $? "Did not match on correct filter (0)"423 424	tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower425	tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower426 427	log_test "mpls_label match ($tcflags)"428}429 430match_mpls_tc_test()431{432	local ethtype="88 47"; readonly ethtype433	local pkt434 435	RET=0436 437	check_tc_mpls_support $h2 || return 0438 439	tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \440		flower $tcflags mpls_tc 0 action drop441	tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \442		flower $tcflags mpls_tc 7 action drop443 444	pkt="$ethtype $(mpls_lse 0 7 1 255)"445	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q446 447	tc_check_packets "dev $h2 ingress" 101 1448	check_fail $? "Matched on a wrong filter (7)"449 450	tc_check_packets "dev $h2 ingress" 102 1451	check_err $? "Did not match on correct filter (7)"452 453	pkt="$ethtype $(mpls_lse 0 0 1 255)"454	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q455 456	tc_check_packets "dev $h2 ingress" 102 2457	check_fail $? "Matched on a wrong filter (0)"458 459	tc_check_packets "dev $h2 ingress" 101 1460	check_err $? "Did not match on correct filter (0)"461 462	tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower463	tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower464 465	log_test "mpls_tc match ($tcflags)"466}467 468match_mpls_bos_test()469{470	local ethtype="88 47"; readonly ethtype471	local pkt472 473	RET=0474 475	check_tc_mpls_support $h2 || return 0476 477	tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \478		flower $tcflags mpls_bos 0 action drop479	tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \480		flower $tcflags mpls_bos 1 action drop481 482	pkt="$ethtype $(mpls_lse 0 0 1 255)"483	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q484 485	tc_check_packets "dev $h2 ingress" 101 1486	check_fail $? "Matched on a wrong filter (1)"487 488	tc_check_packets "dev $h2 ingress" 102 1489	check_err $? "Did not match on correct filter (1)"490 491	# Need to add a second label to properly mark the Bottom of Stack492	pkt="$ethtype $(mpls_lse 0 0 0 255) $(mpls_lse 0 0 1 255)"493	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q494 495	tc_check_packets "dev $h2 ingress" 102 2496	check_fail $? "Matched on a wrong filter (0)"497 498	tc_check_packets "dev $h2 ingress" 101 1499	check_err $? "Did not match on correct filter (0)"500 501	tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower502	tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower503 504	log_test "mpls_bos match ($tcflags)"505}506 507match_mpls_ttl_test()508{509	local ethtype="88 47"; readonly ethtype510	local pkt511 512	RET=0513 514	check_tc_mpls_support $h2 || return 0515 516	tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \517		flower $tcflags mpls_ttl 0 action drop518	tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \519		flower $tcflags mpls_ttl 255 action drop520 521	pkt="$ethtype $(mpls_lse 0 0 1 255)"522	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q523 524	tc_check_packets "dev $h2 ingress" 101 1525	check_fail $? "Matched on a wrong filter (255)"526 527	tc_check_packets "dev $h2 ingress" 102 1528	check_err $? "Did not match on correct filter (255)"529 530	pkt="$ethtype $(mpls_lse 0 0 1 0)"531	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q532 533	tc_check_packets "dev $h2 ingress" 102 2534	check_fail $? "Matched on a wrong filter (0)"535 536	tc_check_packets "dev $h2 ingress" 101 1537	check_err $? "Did not match on correct filter (0)"538 539	tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower540	tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower541 542	log_test "mpls_ttl match ($tcflags)"543}544 545match_mpls_lse_test()546{547	local ethtype="88 47"; readonly ethtype548	local pkt549 550	RET=0551 552	check_tc_mpls_lse_stats $h2 || return 0553 554	# Match on first LSE (minimal values for each field)555	tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \556		flower $tcflags mpls lse depth 1 label 0 action continue557	tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \558		flower $tcflags mpls lse depth 1 tc 0 action continue559	tc filter add dev $h2 ingress protocol mpls_uc pref 3 handle 103 \560		flower $tcflags mpls lse depth 1 bos 0 action continue561	tc filter add dev $h2 ingress protocol mpls_uc pref 4 handle 104 \562		flower $tcflags mpls lse depth 1 ttl 0 action continue563 564	# Match on second LSE (maximal values for each field)565	tc filter add dev $h2 ingress protocol mpls_uc pref 5 handle 105 \566		flower $tcflags mpls lse depth 2 label 1048575 action continue567	tc filter add dev $h2 ingress protocol mpls_uc pref 6 handle 106 \568		flower $tcflags mpls lse depth 2 tc 7 action continue569	tc filter add dev $h2 ingress protocol mpls_uc pref 7 handle 107 \570		flower $tcflags mpls lse depth 2 bos 1 action continue571	tc filter add dev $h2 ingress protocol mpls_uc pref 8 handle 108 \572		flower $tcflags mpls lse depth 2 ttl 255 action continue573 574	# Match on LSE depth575	tc filter add dev $h2 ingress protocol mpls_uc pref 9 handle 109 \576		flower $tcflags mpls lse depth 1 action continue577	tc filter add dev $h2 ingress protocol mpls_uc pref 10 handle 110 \578		flower $tcflags mpls lse depth 2 action continue579	tc filter add dev $h2 ingress protocol mpls_uc pref 11 handle 111 \580		flower $tcflags mpls lse depth 3 action continue581 582	# Base packet, matched by all filters (except for stack depth 3)583	pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048575 7 1 255)"584	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q585 586	# Make a variant of the above packet, with a non-matching value587	# for each LSE field588 589	# Wrong label at depth 1590	pkt="$ethtype $(mpls_lse 1 0 0 0) $(mpls_lse 1048575 7 1 255)"591	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q592 593	# Wrong TC at depth 1594	pkt="$ethtype $(mpls_lse 0 1 0 0) $(mpls_lse 1048575 7 1 255)"595	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q596 597	# Wrong BOS at depth 1 (not adding a second LSE here since BOS is set598	# in the first label, so anything that'd follow wouldn't be considered)599	pkt="$ethtype $(mpls_lse 0 0 1 0)"600	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q601 602	# Wrong TTL at depth 1603	pkt="$ethtype $(mpls_lse 0 0 0 1) $(mpls_lse 1048575 7 1 255)"604	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q605 606	# Wrong label at depth 2607	pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048574 7 1 255)"608	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q609 610	# Wrong TC at depth 2611	pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048575 6 1 255)"612	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q613 614	# Wrong BOS at depth 2 (adding a third LSE here since BOS isn't set in615	# the second label)616	pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048575 7 0 255)"617	pkt="$pkt $(mpls_lse 0 0 1 255)"618	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q619 620	# Wrong TTL at depth 2621	pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048575 7 1 254)"622	$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q623 624	# Filters working at depth 1 should match all packets but one625 626	tc_check_packets "dev $h2 ingress" 101 8627	check_err $? "Did not match on correct filter"628 629	tc_check_packets "dev $h2 ingress" 102 8630	check_err $? "Did not match on correct filter"631 632	tc_check_packets "dev $h2 ingress" 103 8633	check_err $? "Did not match on correct filter"634 635	tc_check_packets "dev $h2 ingress" 104 8636	check_err $? "Did not match on correct filter"637 638	# Filters working at depth 2 should match all packets but two (because639	# of the test packet where the label stack depth is just one)640 641	tc_check_packets "dev $h2 ingress" 105 7642	check_err $? "Did not match on correct filter"643 644	tc_check_packets "dev $h2 ingress" 106 7645	check_err $? "Did not match on correct filter"646 647	tc_check_packets "dev $h2 ingress" 107 7648	check_err $? "Did not match on correct filter"649 650	tc_check_packets "dev $h2 ingress" 108 7651	check_err $? "Did not match on correct filter"652 653	# Finally, verify the filters that only match on LSE depth654 655	tc_check_packets "dev $h2 ingress" 109 9656	check_err $? "Did not match on correct filter"657 658	tc_check_packets "dev $h2 ingress" 110 8659	check_err $? "Did not match on correct filter"660 661	tc_check_packets "dev $h2 ingress" 111 1662	check_err $? "Did not match on correct filter"663 664	tc filter del dev $h2 ingress protocol mpls_uc pref 11 handle 111 flower665	tc filter del dev $h2 ingress protocol mpls_uc pref 10 handle 110 flower666	tc filter del dev $h2 ingress protocol mpls_uc pref 9 handle 109 flower667	tc filter del dev $h2 ingress protocol mpls_uc pref 8 handle 108 flower668	tc filter del dev $h2 ingress protocol mpls_uc pref 7 handle 107 flower669	tc filter del dev $h2 ingress protocol mpls_uc pref 6 handle 106 flower670	tc filter del dev $h2 ingress protocol mpls_uc pref 5 handle 105 flower671	tc filter del dev $h2 ingress protocol mpls_uc pref 4 handle 104 flower672	tc filter del dev $h2 ingress protocol mpls_uc pref 3 handle 103 flower673	tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower674	tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower675 676	log_test "mpls lse match ($tcflags)"677}678 679setup_prepare()680{681	h1=${NETIFS[p1]}682	h2=${NETIFS[p2]}683	h1mac=$(mac_get $h1)684	h2mac=$(mac_get $h2)685 686	vrf_prepare687 688	h1_create689	h2_create690}691 692cleanup()693{694	pre_cleanup695 696	h2_destroy697	h1_destroy698 699	vrf_cleanup700}701 702trap cleanup EXIT703 704setup_prepare705setup_wait706 707tests_run708 709tc_offload_check710if [[ $? -ne 0 ]]; then711	log_info "Could not test offloaded functionality"712else713	tcflags="skip_sw"714	tests_run715fi716 717exit $EXIT_STATUS718