2 # SPDX-License-Identifier: GPL-2.0
4 ALL_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_test
7 match_mpls_label_test \
8 match_mpls_tc_test match_mpls_bos_test match_mpls_ttl_test \
18 simple_if_init
$h1 192.0.2.1/24 198.51.100.1/24
23 simple_if_fini
$h1 192.0.2.1/24 198.51.100.1/24
28 simple_if_init
$h2 192.0.2.2/24 198.51.100.2/24
29 tc qdisc add dev
$h2 clsact
34 tc qdisc del dev
$h2 clsact
35 simple_if_fini
$h2 192.0.2.2/24 198.51.100.2/24
40 local dummy_mac
=de
:ad
:be
:ef
:aa
:aa
44 tc filter add dev
$h2 ingress protocol ip pref
1 handle
101 flower \
45 $tcflags dst_mac
$dummy_mac action drop
46 tc filter add dev
$h2 ingress protocol ip pref
2 handle
102 flower \
47 $tcflags dst_mac
$h2mac action drop
49 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
52 tc_check_packets
"dev $h2 ingress" 101 1
53 check_fail $?
"Matched on a wrong filter"
55 tc_check_packets
"dev $h2 ingress" 102 0
56 check_fail $?
"Did not match on correct filter"
58 tc filter del dev
$h2 ingress protocol ip pref
1 handle
101 flower
59 tc filter del dev
$h2 ingress protocol ip pref
2 handle
102 flower
61 log_test
"dst_mac match ($tcflags)"
66 local dummy_mac
=de
:ad
:be
:ef
:aa
:aa
70 tc filter add dev
$h2 ingress protocol ip pref
1 handle
101 flower \
71 $tcflags src_mac
$dummy_mac action drop
72 tc filter add dev
$h2 ingress protocol ip pref
2 handle
102 flower \
73 $tcflags src_mac
$h1mac action drop
75 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
78 tc_check_packets
"dev $h2 ingress" 101 1
79 check_fail $?
"Matched on a wrong filter"
81 tc_check_packets
"dev $h2 ingress" 102 0
82 check_fail $?
"Did not match on correct filter"
84 tc filter del dev
$h2 ingress protocol ip pref
1 handle
101 flower
85 tc filter del dev
$h2 ingress protocol ip pref
2 handle
102 flower
87 log_test
"src_mac match ($tcflags)"
94 tc filter add dev
$h2 ingress protocol ip pref
1 handle
101 flower \
95 $tcflags dst_ip
198.51.100.2 action drop
96 tc filter add dev
$h2 ingress protocol ip pref
2 handle
102 flower \
97 $tcflags dst_ip
192.0.2.2 action drop
98 tc filter add dev
$h2 ingress protocol ip pref
3 handle
103 flower \
99 $tcflags dst_ip
192.0.2.0/24 action drop
101 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
104 tc_check_packets
"dev $h2 ingress" 101 1
105 check_fail $?
"Matched on a wrong filter"
107 tc_check_packets
"dev $h2 ingress" 102 1
108 check_err $?
"Did not match on correct filter"
110 tc filter del dev
$h2 ingress protocol ip pref
2 handle
102 flower
112 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
115 tc_check_packets
"dev $h2 ingress" 103 1
116 check_err $?
"Did not match on correct filter with mask"
118 tc filter del dev
$h2 ingress protocol ip pref
1 handle
101 flower
119 tc filter del dev
$h2 ingress protocol ip pref
3 handle
103 flower
121 log_test
"dst_ip match ($tcflags)"
128 tc filter add dev
$h2 ingress protocol ip pref
1 handle
101 flower \
129 $tcflags src_ip
198.51.100.1 action drop
130 tc filter add dev
$h2 ingress protocol ip pref
2 handle
102 flower \
131 $tcflags src_ip
192.0.2.1 action drop
132 tc filter add dev
$h2 ingress protocol ip pref
3 handle
103 flower \
133 $tcflags src_ip
192.0.2.0/24 action drop
135 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
138 tc_check_packets
"dev $h2 ingress" 101 1
139 check_fail $?
"Matched on a wrong filter"
141 tc_check_packets
"dev $h2 ingress" 102 1
142 check_err $?
"Did not match on correct filter"
144 tc filter del dev
$h2 ingress protocol ip pref
2 handle
102 flower
146 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
149 tc_check_packets
"dev $h2 ingress" 103 1
150 check_err $?
"Did not match on correct filter with mask"
152 tc filter del dev
$h2 ingress protocol ip pref
1 handle
101 flower
153 tc filter del dev
$h2 ingress protocol ip pref
3 handle
103 flower
155 log_test
"src_ip match ($tcflags)"
158 match_ip_flags_test
()
162 tc filter add dev
$h2 ingress protocol ip pref
1 handle
101 flower \
163 $tcflags ip_flags frag action
continue
164 tc filter add dev
$h2 ingress protocol ip pref
2 handle
102 flower \
165 $tcflags ip_flags firstfrag action
continue
166 tc filter add dev
$h2 ingress protocol ip pref
3 handle
103 flower \
167 $tcflags ip_flags nofirstfrag action
continue
168 tc filter add dev
$h2 ingress protocol ip pref
4 handle
104 flower \
169 $tcflags ip_flags nofrag action drop
171 $MZ $h1 -c 1 -p 1000 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
174 tc_check_packets
"dev $h2 ingress" 101 1
175 check_fail $?
"Matched on wrong frag filter (nofrag)"
177 tc_check_packets
"dev $h2 ingress" 102 1
178 check_fail $?
"Matched on wrong firstfrag filter (nofrag)"
180 tc_check_packets
"dev $h2 ingress" 103 1
181 check_err $?
"Did not match on nofirstfrag filter (nofrag) "
183 tc_check_packets
"dev $h2 ingress" 104 1
184 check_err $?
"Did not match on nofrag filter (nofrag)"
186 $MZ $h1 -c 1 -p 1000 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
189 tc_check_packets
"dev $h2 ingress" 101 1
190 check_err $?
"Did not match on frag filter (1stfrag)"
192 tc_check_packets
"dev $h2 ingress" 102 1
193 check_err $?
"Did not match fistfrag filter (1stfrag)"
195 tc_check_packets
"dev $h2 ingress" 103 1
196 check_err $?
"Matched on wrong nofirstfrag filter (1stfrag)"
198 tc_check_packets
"dev $h2 ingress" 104 1
199 check_err $?
"Match on wrong nofrag filter (1stfrag)"
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" -q
203 $MZ $h1 -c 1 -p 1000 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
206 tc_check_packets
"dev $h2 ingress" 101 3
207 check_err $?
"Did not match on frag filter (no1stfrag)"
209 tc_check_packets
"dev $h2 ingress" 102 1
210 check_err $?
"Matched on wrong firstfrag filter (no1stfrag)"
212 tc_check_packets
"dev $h2 ingress" 103 3
213 check_err $?
"Did not match on nofirstfrag filter (no1stfrag)"
215 tc_check_packets
"dev $h2 ingress" 104 1
216 check_err $?
"Matched on nofrag filter (no1stfrag)"
218 tc filter del dev
$h2 ingress protocol ip pref
1 handle
101 flower
219 tc filter del dev
$h2 ingress protocol ip pref
2 handle
102 flower
220 tc filter del dev
$h2 ingress protocol ip pref
3 handle
103 flower
221 tc filter del dev
$h2 ingress protocol ip pref
4 handle
104 flower
223 log_test
"ip_flags match ($tcflags)"
230 vlan_create
$h2 85 v
$h2 192.0.2.11/24
232 tc filter add dev
$h2 ingress protocol
802.1q pref
1 handle
101 \
233 flower vlan_prio
6 $tcflags dst_mac
$h2mac action drop
234 tc filter add dev
$h2 ingress protocol
802.1q pref
2 handle
102 \
235 flower vlan_prio
7 $tcflags dst_mac
$h2mac action drop
237 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -B 192.0.2.11 -Q 7:85 -t ip
-q
238 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -B 192.0.2.11 -Q 0:85 -t ip
-q
240 tc_check_packets
"dev $h2 ingress" 101 0
241 check_err $?
"Matched on specified PCP when should not"
243 tc_check_packets
"dev $h2 ingress" 102 1
244 check_err $?
"Did not match on specified PCP"
246 tc filter del dev
$h2 ingress protocol
802.1q pref
2 handle
102 flower
247 tc filter del dev
$h2 ingress protocol
802.1q pref
1 handle
101 flower
251 log_test
"PCP match ($tcflags)"
258 vlan_create
$h2 85 v
$h2 192.0.2.11/24
259 vlan_create
$h2 75 v
$h2 192.0.2.10/24
261 tc filter add dev
$h2 ingress protocol
802.1q pref
1 handle
101 \
262 flower vlan_id
75 $tcflags action drop
263 tc filter add dev
$h2 ingress protocol
802.1q pref
2 handle
102 \
264 flower vlan_id
85 $tcflags action drop
266 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -B 192.0.2.11 -Q 0:85 -t ip
-q
268 tc_check_packets
"dev $h2 ingress" 101 0
269 check_err $?
"Matched on specified VLAN when should not"
271 tc_check_packets
"dev $h2 ingress" 102 1
272 check_err $?
"Did not match on specified VLAN"
274 tc filter del dev
$h2 ingress protocol
802.1q pref
2 handle
102 flower
275 tc filter del dev
$h2 ingress protocol
802.1q pref
1 handle
101 flower
280 log_test
"VLAN match ($tcflags)"
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 drop
289 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 drop
292 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
295 tc_check_packets
"dev $h2 ingress" 101 1
296 check_fail $?
"Matched on a wrong filter (0x18)"
298 tc_check_packets
"dev $h2 ingress" 102 1
299 check_err $?
"Did not match on correct filter (0x18)"
301 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
304 tc_check_packets
"dev $h2 ingress" 102 2
305 check_fail $?
"Matched on a wrong filter (0x20)"
307 tc_check_packets
"dev $h2 ingress" 101 1
308 check_err $?
"Did not match on correct filter (0x20)"
310 tc filter del dev
$h2 ingress protocol ip pref
2 handle
102 flower
311 tc filter del dev
$h2 ingress protocol ip pref
1 handle
101 flower
313 log_test
"ip_tos match ($tcflags)"
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 drop
322 tc filter add dev
$h2 ingress protocol ip pref
2 handle
102 flower \
323 $tcflags dst_ip
192.0.2.2 action drop
325 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
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" -q
331 tc_check_packets
"dev $h2 ingress" 102 1
332 check_fail $?
"Matched on the wrong filter (no check on ttl)"
334 tc_check_packets
"dev $h2 ingress" 101 2
335 check_err $?
"Did not match on correct filter (ttl=63)"
337 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
340 tc_check_packets
"dev $h2 ingress" 101 3
341 check_fail $?
"Matched on a wrong filter (ttl=63)"
343 tc_check_packets
"dev $h2 ingress" 102 1
344 check_err $?
"Did not match on correct filter (no check on ttl)"
346 tc filter del dev
$h2 ingress protocol ip pref
2 handle
102 flower
347 tc filter del dev
$h2 ingress protocol ip pref
1 handle
101 flower
349 log_test
"ip_ttl match ($tcflags)"
356 tc filter add dev
$h2 ingress protocol ip pref
1 handle
101 flower \
357 $tcflags indev
$h1 dst_mac
$h2mac action drop
358 tc filter add dev
$h2 ingress protocol ip pref
2 handle
102 flower \
359 $tcflags indev
$h2 dst_mac
$h2mac action drop
361 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
364 tc_check_packets
"dev $h2 ingress" 101 1
365 check_fail $?
"Matched on a wrong filter"
367 tc_check_packets
"dev $h2 ingress" 102 1
368 check_err $?
"Did not match on correct filter"
370 tc filter del dev
$h2 ingress protocol ip pref
2 handle
102 flower
371 tc filter del dev
$h2 ingress protocol ip pref
1 handle
101 flower
373 log_test
"indev match ($tcflags)"
376 # Unfortunately, mausezahn can't build MPLS headers when used in L2
377 # mode, so we have this function to build Label Stack Entries.
385 printf "%02x %02x %02x %02x" \
387 $
((label
>> 4 & 0xff)) \
388 $
((((label
& 0xf) << 4) + (tc << 1) + bos)) \
392 match_mpls_label_test()
394 local ethtype="88 47"; readonly ethtype
399 check_tc_mpls_support $h2 || return 0
401 tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \
402 flower $tcflags mpls_label 0 action drop
403 tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \
404 flower $tcflags mpls_label 1048575 action drop
406 pkt="$ethtype $(mpls_lse 1048575 0 1 255)"
407 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
409 tc_check_packets "dev $h2 ingress" 101 1
410 check_fail $? "Matched on a wrong filter (1048575)"
412 tc_check_packets "dev $h2 ingress" 102 1
413 check_err $? "Did not match on correct filter (1048575)"
415 pkt="$ethtype $(mpls_lse 0 0 1 255)"
416 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
418 tc_check_packets "dev $h2 ingress" 102 2
419 check_fail $? "Matched on a wrong filter (0)"
421 tc_check_packets "dev $h2 ingress" 101 1
422 check_err $? "Did not match on correct filter (0)"
424 tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower
425 tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower
427 log_test "mpls_label match ($tcflags)"
432 local ethtype="88 47"; readonly ethtype
437 check_tc_mpls_support $h2 || return 0
439 tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \
440 flower $tcflags mpls_tc 0 action drop
441 tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \
442 flower $tcflags mpls_tc 7 action drop
444 pkt="$ethtype $(mpls_lse 0 7 1 255)"
445 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
447 tc_check_packets "dev $h2 ingress" 101 1
448 check_fail $? "Matched on a wrong filter (7)"
450 tc_check_packets "dev $h2 ingress" 102 1
451 check_err $? "Did not match on correct filter (7)"
453 pkt="$ethtype $(mpls_lse 0 0 1 255)"
454 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
456 tc_check_packets "dev $h2 ingress" 102 2
457 check_fail $? "Matched on a wrong filter (0)"
459 tc_check_packets "dev $h2 ingress" 101 1
460 check_err $? "Did not match on correct filter (0)"
462 tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower
463 tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower
465 log_test "mpls_tc match ($tcflags)"
468 match_mpls_bos_test()
470 local ethtype="88 47"; readonly ethtype
475 check_tc_mpls_support $h2 || return 0
477 tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \
478 flower $tcflags mpls_bos 0 action drop
479 tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \
480 flower $tcflags mpls_bos 1 action drop
482 pkt="$ethtype $(mpls_lse 0 0 1 255)"
483 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
485 tc_check_packets "dev $h2 ingress" 101 1
486 check_fail $? "Matched on a wrong filter (1)"
488 tc_check_packets "dev $h2 ingress" 102 1
489 check_err $? "Did not match on correct filter (1)"
491 # Need to add a second label to properly mark the Bottom of Stack
492 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" -q
495 tc_check_packets "dev $h2 ingress" 102 2
496 check_fail $? "Matched on a wrong filter (0)"
498 tc_check_packets "dev $h2 ingress" 101 1
499 check_err $? "Did not match on correct filter (0)"
501 tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower
502 tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower
504 log_test "mpls_bos match ($tcflags)"
507 match_mpls_ttl_test()
509 local ethtype="88 47"; readonly ethtype
514 check_tc_mpls_support $h2 || return 0
516 tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \
517 flower $tcflags mpls_ttl 0 action drop
518 tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \
519 flower $tcflags mpls_ttl 255 action drop
521 pkt="$ethtype $(mpls_lse 0 0 1 255)"
522 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
524 tc_check_packets "dev $h2 ingress" 101 1
525 check_fail $? "Matched on a wrong filter (255)"
527 tc_check_packets "dev $h2 ingress" 102 1
528 check_err $? "Did not match on correct filter (255)"
530 pkt="$ethtype $(mpls_lse 0 0 1 0)"
531 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
533 tc_check_packets "dev $h2 ingress" 102 2
534 check_fail $? "Matched on a wrong filter (0)"
536 tc_check_packets "dev $h2 ingress" 101 1
537 check_err $? "Did not match on correct filter (0)"
539 tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower
540 tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower
542 log_test "mpls_ttl match ($tcflags)"
545 match_mpls_lse_test()
547 local ethtype="88 47"; readonly ethtype
552 check_tc_mpls_lse_stats $h2 || return 0
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 continue
557 tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \
558 flower $tcflags mpls lse depth 1 tc 0 action continue
559 tc filter add dev $h2 ingress protocol mpls_uc pref 3 handle 103 \
560 flower $tcflags mpls lse depth 1 bos 0 action continue
561 tc filter add dev $h2 ingress protocol mpls_uc pref 4 handle
104 \
562 flower
$tcflags mpls lse depth
1 ttl
0 action
continue
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
continue
567 tc filter add dev
$h2 ingress protocol mpls_uc pref
6 handle
106 \
568 flower
$tcflags mpls lse depth
2 tc
7 action
continue
569 tc filter add dev
$h2 ingress protocol mpls_uc pref
7 handle
107 \
570 flower
$tcflags mpls lse depth
2 bos
1 action
continue
571 tc filter add dev
$h2 ingress protocol mpls_uc pref
8 handle
108 \
572 flower
$tcflags mpls lse depth
2 ttl
255 action
continue
575 tc filter add dev
$h2 ingress protocol mpls_uc pref
9 handle
109 \
576 flower
$tcflags mpls lse depth
1 action
continue
577 tc filter add dev
$h2 ingress protocol mpls_uc pref
10 handle
110 \
578 flower
$tcflags mpls lse depth
2 action
continue
579 tc filter add dev
$h2 ingress protocol mpls_uc pref
11 handle
111 \
580 flower
$tcflags mpls lse depth
3 action
continue
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" -q
586 # Make a variant of the above packet, with a non-matching value
589 # Wrong label at depth 1
590 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" -q
593 # Wrong TC at depth 1
594 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" -q
597 # Wrong BOS at depth 1 (not adding a second LSE here since BOS is set
598 # 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" -q
602 # Wrong TTL at depth 1
603 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" -q
606 # Wrong label at depth 2
607 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" -q
610 # Wrong TC at depth 2
611 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" -q
614 # Wrong BOS at depth 2 (adding a third LSE here since BOS isn't set in
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" -q
620 # Wrong TTL at depth 2
621 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" -q
624 # Filters working at depth 1 should match all packets but one
626 tc_check_packets
"dev $h2 ingress" 101 8
627 check_err $?
"Did not match on correct filter"
629 tc_check_packets
"dev $h2 ingress" 102 8
630 check_err $?
"Did not match on correct filter"
632 tc_check_packets
"dev $h2 ingress" 103 8
633 check_err $?
"Did not match on correct filter"
635 tc_check_packets
"dev $h2 ingress" 104 8
636 check_err $?
"Did not match on correct filter"
638 # Filters working at depth 2 should match all packets but two (because
639 # of the test packet where the label stack depth is just one)
641 tc_check_packets
"dev $h2 ingress" 105 7
642 check_err $?
"Did not match on correct filter"
644 tc_check_packets
"dev $h2 ingress" 106 7
645 check_err $?
"Did not match on correct filter"
647 tc_check_packets
"dev $h2 ingress" 107 7
648 check_err $?
"Did not match on correct filter"
650 tc_check_packets
"dev $h2 ingress" 108 7
651 check_err $?
"Did not match on correct filter"
653 # Finally, verify the filters that only match on LSE depth
655 tc_check_packets
"dev $h2 ingress" 109 9
656 check_err $?
"Did not match on correct filter"
658 tc_check_packets
"dev $h2 ingress" 110 8
659 check_err $?
"Did not match on correct filter"
661 tc_check_packets
"dev $h2 ingress" 111 1
662 check_err $?
"Did not match on correct filter"
664 tc filter del dev
$h2 ingress protocol mpls_uc pref
11 handle
111 flower
665 tc filter del dev
$h2 ingress protocol mpls_uc pref
10 handle
110 flower
666 tc filter del dev
$h2 ingress protocol mpls_uc pref
9 handle
109 flower
667 tc filter del dev
$h2 ingress protocol mpls_uc pref
8 handle
108 flower
668 tc filter del dev
$h2 ingress protocol mpls_uc pref
7 handle
107 flower
669 tc filter del dev
$h2 ingress protocol mpls_uc pref
6 handle
106 flower
670 tc filter del dev
$h2 ingress protocol mpls_uc pref
5 handle
105 flower
671 tc filter del dev
$h2 ingress protocol mpls_uc pref
4 handle
104 flower
672 tc filter del dev
$h2 ingress protocol mpls_uc pref
3 handle
103 flower
673 tc filter del dev
$h2 ingress protocol mpls_uc pref
2 handle
102 flower
674 tc filter del dev
$h2 ingress protocol mpls_uc pref
1 handle
101 flower
676 log_test
"mpls lse match ($tcflags)"
710 if [[ $?
-ne 0 ]]; then
711 log_info
"Could not test offloaded functionality"