|
4 | 4 | ALL_TESTS="match_dst_mac_test match_src_mac_test match_dst_ip_test \
|
5 | 5 | match_src_ip_test match_ip_flags_test match_pcp_test match_vlan_test \
|
6 | 6 | match_ip_tos_test match_indev_test match_mpls_label_test \
|
7 |
| - match_mpls_tc_test match_mpls_bos_test match_mpls_ttl_test" |
| 7 | + match_mpls_tc_test match_mpls_bos_test match_mpls_ttl_test \ |
| 8 | + match_mpls_lse_test" |
8 | 9 | NUM_NETIFS=2
|
9 | 10 | source tc_common.sh
|
10 | 11 | source lib.sh
|
@@ -504,6 +505,140 @@ match_mpls_ttl_test()
|
504 | 505 | log_test "mpls_ttl match ($tcflags)"
|
505 | 506 | }
|
506 | 507 |
|
| 508 | +match_mpls_lse_test() |
| 509 | +{ |
| 510 | + local ethtype="88 47"; readonly ethtype |
| 511 | + local pkt |
| 512 | + |
| 513 | + RET=0 |
| 514 | + |
| 515 | + check_tc_mpls_lse_stats $h2 || return 0 |
| 516 | + |
| 517 | + # Match on first LSE (minimal values for each field) |
| 518 | + tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \ |
| 519 | + flower $tcflags mpls lse depth 1 label 0 action continue |
| 520 | + tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \ |
| 521 | + flower $tcflags mpls lse depth 1 tc 0 action continue |
| 522 | + tc filter add dev $h2 ingress protocol mpls_uc pref 3 handle 103 \ |
| 523 | + flower $tcflags mpls lse depth 1 bos 0 action continue |
| 524 | + tc filter add dev $h2 ingress protocol mpls_uc pref 4 handle 104 \ |
| 525 | + flower $tcflags mpls lse depth 1 ttl 0 action continue |
| 526 | + |
| 527 | + # Match on second LSE (maximal values for each field) |
| 528 | + tc filter add dev $h2 ingress protocol mpls_uc pref 5 handle 105 \ |
| 529 | + flower $tcflags mpls lse depth 2 label 1048575 action continue |
| 530 | + tc filter add dev $h2 ingress protocol mpls_uc pref 6 handle 106 \ |
| 531 | + flower $tcflags mpls lse depth 2 tc 7 action continue |
| 532 | + tc filter add dev $h2 ingress protocol mpls_uc pref 7 handle 107 \ |
| 533 | + flower $tcflags mpls lse depth 2 bos 1 action continue |
| 534 | + tc filter add dev $h2 ingress protocol mpls_uc pref 8 handle 108 \ |
| 535 | + flower $tcflags mpls lse depth 2 ttl 255 action continue |
| 536 | + |
| 537 | + # Match on LSE depth |
| 538 | + tc filter add dev $h2 ingress protocol mpls_uc pref 9 handle 109 \ |
| 539 | + flower $tcflags mpls lse depth 1 action continue |
| 540 | + tc filter add dev $h2 ingress protocol mpls_uc pref 10 handle 110 \ |
| 541 | + flower $tcflags mpls lse depth 2 action continue |
| 542 | + tc filter add dev $h2 ingress protocol mpls_uc pref 11 handle 111 \ |
| 543 | + flower $tcflags mpls lse depth 3 action continue |
| 544 | + |
| 545 | + # Base packet, matched by all filters (except for stack depth 3) |
| 546 | + pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048575 7 1 255)" |
| 547 | + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q |
| 548 | + |
| 549 | + # Make a variant of the above packet, with a non-matching value |
| 550 | + # for each LSE field |
| 551 | + |
| 552 | + # Wrong label at depth 1 |
| 553 | + pkt="$ethtype $(mpls_lse 1 0 0 0) $(mpls_lse 1048575 7 1 255)" |
| 554 | + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q |
| 555 | + |
| 556 | + # Wrong TC at depth 1 |
| 557 | + pkt="$ethtype $(mpls_lse 0 1 0 0) $(mpls_lse 1048575 7 1 255)" |
| 558 | + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q |
| 559 | + |
| 560 | + # Wrong BOS at depth 1 (not adding a second LSE here since BOS is set |
| 561 | + # in the first label, so anything that'd follow wouldn't be considered) |
| 562 | + pkt="$ethtype $(mpls_lse 0 0 1 0)" |
| 563 | + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q |
| 564 | + |
| 565 | + # Wrong TTL at depth 1 |
| 566 | + pkt="$ethtype $(mpls_lse 0 0 0 1) $(mpls_lse 1048575 7 1 255)" |
| 567 | + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q |
| 568 | + |
| 569 | + # Wrong label at depth 2 |
| 570 | + pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048574 7 1 255)" |
| 571 | + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q |
| 572 | + |
| 573 | + # Wrong TC at depth 2 |
| 574 | + pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048575 6 1 255)" |
| 575 | + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q |
| 576 | + |
| 577 | + # Wrong BOS at depth 2 (adding a third LSE here since BOS isn't set in |
| 578 | + # the second label) |
| 579 | + pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048575 7 0 255)" |
| 580 | + pkt="$pkt $(mpls_lse 0 0 1 255)" |
| 581 | + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q |
| 582 | + |
| 583 | + # Wrong TTL at depth 2 |
| 584 | + pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048575 7 1 254)" |
| 585 | + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q |
| 586 | + |
| 587 | + # Filters working at depth 1 should match all packets but one |
| 588 | + |
| 589 | + tc_check_packets "dev $h2 ingress" 101 8 |
| 590 | + check_err $? "Did not match on correct filter" |
| 591 | + |
| 592 | + tc_check_packets "dev $h2 ingress" 102 8 |
| 593 | + check_err $? "Did not match on correct filter" |
| 594 | + |
| 595 | + tc_check_packets "dev $h2 ingress" 103 8 |
| 596 | + check_err $? "Did not match on correct filter" |
| 597 | + |
| 598 | + tc_check_packets "dev $h2 ingress" 104 8 |
| 599 | + check_err $? "Did not match on correct filter" |
| 600 | + |
| 601 | + # Filters working at depth 2 should match all packets but two (because |
| 602 | + # of the test packet where the label stack depth is just one) |
| 603 | + |
| 604 | + tc_check_packets "dev $h2 ingress" 105 7 |
| 605 | + check_err $? "Did not match on correct filter" |
| 606 | + |
| 607 | + tc_check_packets "dev $h2 ingress" 106 7 |
| 608 | + check_err $? "Did not match on correct filter" |
| 609 | + |
| 610 | + tc_check_packets "dev $h2 ingress" 107 7 |
| 611 | + check_err $? "Did not match on correct filter" |
| 612 | + |
| 613 | + tc_check_packets "dev $h2 ingress" 108 7 |
| 614 | + check_err $? "Did not match on correct filter" |
| 615 | + |
| 616 | + # Finally, verify the filters that only match on LSE depth |
| 617 | + |
| 618 | + tc_check_packets "dev $h2 ingress" 109 9 |
| 619 | + check_err $? "Did not match on correct filter" |
| 620 | + |
| 621 | + tc_check_packets "dev $h2 ingress" 110 8 |
| 622 | + check_err $? "Did not match on correct filter" |
| 623 | + |
| 624 | + tc_check_packets "dev $h2 ingress" 111 1 |
| 625 | + check_err $? "Did not match on correct filter" |
| 626 | + |
| 627 | + tc filter del dev $h2 ingress protocol mpls_uc pref 11 handle 111 flower |
| 628 | + tc filter del dev $h2 ingress protocol mpls_uc pref 10 handle 110 flower |
| 629 | + tc filter del dev $h2 ingress protocol mpls_uc pref 9 handle 109 flower |
| 630 | + tc filter del dev $h2 ingress protocol mpls_uc pref 8 handle 108 flower |
| 631 | + tc filter del dev $h2 ingress protocol mpls_uc pref 7 handle 107 flower |
| 632 | + tc filter del dev $h2 ingress protocol mpls_uc pref 6 handle 106 flower |
| 633 | + tc filter del dev $h2 ingress protocol mpls_uc pref 5 handle 105 flower |
| 634 | + tc filter del dev $h2 ingress protocol mpls_uc pref 4 handle 104 flower |
| 635 | + tc filter del dev $h2 ingress protocol mpls_uc pref 3 handle 103 flower |
| 636 | + tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower |
| 637 | + tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower |
| 638 | + |
| 639 | + log_test "mpls lse match ($tcflags)" |
| 640 | +} |
| 641 | + |
507 | 642 | setup_prepare()
|
508 | 643 | {
|
509 | 644 | h1=${NETIFS[p1]}
|
|
0 commit comments