107e5c751SJiri Pirko#!/bin/bash 207e5c751SJiri Pirko# SPDX-License-Identifier: GPL-2.0 307e5c751SJiri Pirko 40eb8053cSIdo SchimmelALL_TESTS="match_dst_mac_test match_src_mac_test match_dst_ip_test \ 50b0c0098SJiri Pirko match_src_ip_test match_ip_flags_test match_pcp_test match_vlan_test \ 6b646acd5SJakub Kicinski match_ip_tos_test match_indev_test match_ip_ttl_test 7b646acd5SJakub Kicinski match_mpls_label_test \ 8c09bfd9aSGuillaume Nault match_mpls_tc_test match_mpls_bos_test match_mpls_ttl_test \ 9c09bfd9aSGuillaume Nault match_mpls_lse_test" 1007e5c751SJiri PirkoNUM_NETIFS=2 1107e5c751SJiri Pirkosource tc_common.sh 12198979beSDavid Ahernsource lib.sh 1307e5c751SJiri Pirko 1407e5c751SJiri Pirkotcflags="skip_hw" 1507e5c751SJiri Pirko 1607e5c751SJiri Pirkoh1_create() 1707e5c751SJiri Pirko{ 1807e5c751SJiri Pirko simple_if_init $h1 192.0.2.1/24 198.51.100.1/24 1907e5c751SJiri Pirko} 2007e5c751SJiri Pirko 2107e5c751SJiri Pirkoh1_destroy() 2207e5c751SJiri Pirko{ 2307e5c751SJiri Pirko simple_if_fini $h1 192.0.2.1/24 198.51.100.1/24 2407e5c751SJiri Pirko} 2507e5c751SJiri Pirko 2607e5c751SJiri Pirkoh2_create() 2707e5c751SJiri Pirko{ 2807e5c751SJiri Pirko simple_if_init $h2 192.0.2.2/24 198.51.100.2/24 2907e5c751SJiri Pirko tc qdisc add dev $h2 clsact 3007e5c751SJiri Pirko} 3107e5c751SJiri Pirko 3207e5c751SJiri Pirkoh2_destroy() 3307e5c751SJiri Pirko{ 3407e5c751SJiri Pirko tc qdisc del dev $h2 clsact 3507e5c751SJiri Pirko simple_if_fini $h2 192.0.2.2/24 198.51.100.2/24 3607e5c751SJiri Pirko} 3707e5c751SJiri Pirko 3807e5c751SJiri Pirkomatch_dst_mac_test() 3907e5c751SJiri Pirko{ 4007e5c751SJiri Pirko local dummy_mac=de:ad:be:ef:aa:aa 4107e5c751SJiri Pirko 4207e5c751SJiri Pirko RET=0 4307e5c751SJiri Pirko 4407e5c751SJiri Pirko tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ 4507e5c751SJiri Pirko $tcflags dst_mac $dummy_mac action drop 4607e5c751SJiri Pirko tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ 4707e5c751SJiri Pirko $tcflags dst_mac $h2mac action drop 4807e5c751SJiri Pirko 4907e5c751SJiri Pirko $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ 5007e5c751SJiri Pirko -t ip -q 5107e5c751SJiri Pirko 5207e5c751SJiri Pirko tc_check_packets "dev $h2 ingress" 101 1 5307e5c751SJiri Pirko check_fail $? "Matched on a wrong filter" 5407e5c751SJiri Pirko 55*9ee37e53SIdo Schimmel tc_check_packets "dev $h2 ingress" 102 0 56*9ee37e53SIdo Schimmel check_fail $? "Did not match on correct filter" 5707e5c751SJiri Pirko 5807e5c751SJiri Pirko tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower 5907e5c751SJiri Pirko tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower 6007e5c751SJiri Pirko 6107e5c751SJiri Pirko log_test "dst_mac match ($tcflags)" 6207e5c751SJiri Pirko} 6307e5c751SJiri Pirko 6407e5c751SJiri Pirkomatch_src_mac_test() 6507e5c751SJiri Pirko{ 6607e5c751SJiri Pirko local dummy_mac=de:ad:be:ef:aa:aa 6707e5c751SJiri Pirko 6807e5c751SJiri Pirko RET=0 6907e5c751SJiri Pirko 7007e5c751SJiri Pirko tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ 7107e5c751SJiri Pirko $tcflags src_mac $dummy_mac action drop 7207e5c751SJiri Pirko tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ 7307e5c751SJiri Pirko $tcflags src_mac $h1mac action drop 7407e5c751SJiri Pirko 7507e5c751SJiri Pirko $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ 7607e5c751SJiri Pirko -t ip -q 7707e5c751SJiri Pirko 7807e5c751SJiri Pirko tc_check_packets "dev $h2 ingress" 101 1 7907e5c751SJiri Pirko check_fail $? "Matched on a wrong filter" 8007e5c751SJiri Pirko 81*9ee37e53SIdo Schimmel tc_check_packets "dev $h2 ingress" 102 0 82*9ee37e53SIdo Schimmel check_fail $? "Did not match on correct filter" 8307e5c751SJiri Pirko 8407e5c751SJiri Pirko tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower 8507e5c751SJiri Pirko tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower 8607e5c751SJiri Pirko 8707e5c751SJiri Pirko log_test "src_mac match ($tcflags)" 8807e5c751SJiri Pirko} 8907e5c751SJiri Pirko 9007e5c751SJiri Pirkomatch_dst_ip_test() 9107e5c751SJiri Pirko{ 9207e5c751SJiri Pirko RET=0 9307e5c751SJiri Pirko 9407e5c751SJiri Pirko tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ 9507e5c751SJiri Pirko $tcflags dst_ip 198.51.100.2 action drop 9607e5c751SJiri Pirko tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ 9707e5c751SJiri Pirko $tcflags dst_ip 192.0.2.2 action drop 9807e5c751SJiri Pirko tc filter add dev $h2 ingress protocol ip pref 3 handle 103 flower \ 9907e5c751SJiri Pirko $tcflags dst_ip 192.0.2.0/24 action drop 10007e5c751SJiri Pirko 10107e5c751SJiri Pirko $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ 10207e5c751SJiri Pirko -t ip -q 10307e5c751SJiri Pirko 10407e5c751SJiri Pirko tc_check_packets "dev $h2 ingress" 101 1 10507e5c751SJiri Pirko check_fail $? "Matched on a wrong filter" 10607e5c751SJiri Pirko 10707e5c751SJiri Pirko tc_check_packets "dev $h2 ingress" 102 1 10807e5c751SJiri Pirko check_err $? "Did not match on correct filter" 10907e5c751SJiri Pirko 11007e5c751SJiri Pirko tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower 11107e5c751SJiri Pirko 11207e5c751SJiri Pirko $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ 11307e5c751SJiri Pirko -t ip -q 11407e5c751SJiri Pirko 11507e5c751SJiri Pirko tc_check_packets "dev $h2 ingress" 103 1 11607e5c751SJiri Pirko check_err $? "Did not match on correct filter with mask" 11707e5c751SJiri Pirko 11807e5c751SJiri Pirko tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower 11907e5c751SJiri Pirko tc filter del dev $h2 ingress protocol ip pref 3 handle 103 flower 12007e5c751SJiri Pirko 12107e5c751SJiri Pirko log_test "dst_ip match ($tcflags)" 12207e5c751SJiri Pirko} 12307e5c751SJiri Pirko 12407e5c751SJiri Pirkomatch_src_ip_test() 12507e5c751SJiri Pirko{ 12607e5c751SJiri Pirko RET=0 12707e5c751SJiri Pirko 12807e5c751SJiri Pirko tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ 12907e5c751SJiri Pirko $tcflags src_ip 198.51.100.1 action drop 13007e5c751SJiri Pirko tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ 13107e5c751SJiri Pirko $tcflags src_ip 192.0.2.1 action drop 13207e5c751SJiri Pirko tc filter add dev $h2 ingress protocol ip pref 3 handle 103 flower \ 13307e5c751SJiri Pirko $tcflags src_ip 192.0.2.0/24 action drop 13407e5c751SJiri Pirko 13507e5c751SJiri Pirko $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ 13607e5c751SJiri Pirko -t ip -q 13707e5c751SJiri Pirko 13807e5c751SJiri Pirko tc_check_packets "dev $h2 ingress" 101 1 13907e5c751SJiri Pirko check_fail $? "Matched on a wrong filter" 14007e5c751SJiri Pirko 14107e5c751SJiri Pirko tc_check_packets "dev $h2 ingress" 102 1 14207e5c751SJiri Pirko check_err $? "Did not match on correct filter" 14307e5c751SJiri Pirko 14407e5c751SJiri Pirko tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower 14507e5c751SJiri Pirko 14607e5c751SJiri Pirko $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ 14707e5c751SJiri Pirko -t ip -q 14807e5c751SJiri Pirko 14907e5c751SJiri Pirko tc_check_packets "dev $h2 ingress" 103 1 15007e5c751SJiri Pirko check_err $? "Did not match on correct filter with mask" 15107e5c751SJiri Pirko 15207e5c751SJiri Pirko tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower 15307e5c751SJiri Pirko tc filter del dev $h2 ingress protocol ip pref 3 handle 103 flower 15407e5c751SJiri Pirko 15507e5c751SJiri Pirko log_test "src_ip match ($tcflags)" 15607e5c751SJiri Pirko} 15707e5c751SJiri Pirko 158e3c1917eSDavide Carattimatch_ip_flags_test() 159e3c1917eSDavide Caratti{ 160e3c1917eSDavide Caratti RET=0 161e3c1917eSDavide Caratti 162e3c1917eSDavide Caratti tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ 163e3c1917eSDavide Caratti $tcflags ip_flags frag action continue 164e3c1917eSDavide Caratti tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ 165e3c1917eSDavide Caratti $tcflags ip_flags firstfrag action continue 166e3c1917eSDavide Caratti tc filter add dev $h2 ingress protocol ip pref 3 handle 103 flower \ 167e3c1917eSDavide Caratti $tcflags ip_flags nofirstfrag action continue 168e3c1917eSDavide Caratti tc filter add dev $h2 ingress protocol ip pref 4 handle 104 flower \ 169e3c1917eSDavide Caratti $tcflags ip_flags nofrag action drop 170e3c1917eSDavide Caratti 171e3c1917eSDavide Caratti $MZ $h1 -c 1 -p 1000 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ 172e3c1917eSDavide Caratti -t ip "frag=0" -q 173e3c1917eSDavide Caratti 174e3c1917eSDavide Caratti tc_check_packets "dev $h2 ingress" 101 1 175e3c1917eSDavide Caratti check_fail $? "Matched on wrong frag filter (nofrag)" 176e3c1917eSDavide Caratti 177e3c1917eSDavide Caratti tc_check_packets "dev $h2 ingress" 102 1 178e3c1917eSDavide Caratti check_fail $? "Matched on wrong firstfrag filter (nofrag)" 179e3c1917eSDavide Caratti 180e3c1917eSDavide Caratti tc_check_packets "dev $h2 ingress" 103 1 181e3c1917eSDavide Caratti check_err $? "Did not match on nofirstfrag filter (nofrag) " 182e3c1917eSDavide Caratti 183e3c1917eSDavide Caratti tc_check_packets "dev $h2 ingress" 104 1 184e3c1917eSDavide Caratti check_err $? "Did not match on nofrag filter (nofrag)" 185e3c1917eSDavide Caratti 186e3c1917eSDavide Caratti $MZ $h1 -c 1 -p 1000 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ 187e3c1917eSDavide Caratti -t ip "frag=0,mf" -q 188e3c1917eSDavide Caratti 189e3c1917eSDavide Caratti tc_check_packets "dev $h2 ingress" 101 1 190e3c1917eSDavide Caratti check_err $? "Did not match on frag filter (1stfrag)" 191e3c1917eSDavide Caratti 192e3c1917eSDavide Caratti tc_check_packets "dev $h2 ingress" 102 1 193e3c1917eSDavide Caratti check_err $? "Did not match fistfrag filter (1stfrag)" 194e3c1917eSDavide Caratti 195e3c1917eSDavide Caratti tc_check_packets "dev $h2 ingress" 103 1 196e3c1917eSDavide Caratti check_err $? "Matched on wrong nofirstfrag filter (1stfrag)" 197e3c1917eSDavide Caratti 198e3c1917eSDavide Caratti tc_check_packets "dev $h2 ingress" 104 1 199e3c1917eSDavide Caratti check_err $? "Match on wrong nofrag filter (1stfrag)" 200e3c1917eSDavide Caratti 201e3c1917eSDavide Caratti $MZ $h1 -c 1 -p 1000 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ 202e3c1917eSDavide Caratti -t ip "frag=256,mf" -q 203e3c1917eSDavide Caratti $MZ $h1 -c 1 -p 1000 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ 204e3c1917eSDavide Caratti -t ip "frag=256" -q 205e3c1917eSDavide Caratti 206e3c1917eSDavide Caratti tc_check_packets "dev $h2 ingress" 101 3 207e3c1917eSDavide Caratti check_err $? "Did not match on frag filter (no1stfrag)" 208e3c1917eSDavide Caratti 209e3c1917eSDavide Caratti tc_check_packets "dev $h2 ingress" 102 1 210e3c1917eSDavide Caratti check_err $? "Matched on wrong firstfrag filter (no1stfrag)" 211e3c1917eSDavide Caratti 212e3c1917eSDavide Caratti tc_check_packets "dev $h2 ingress" 103 3 213e3c1917eSDavide Caratti check_err $? "Did not match on nofirstfrag filter (no1stfrag)" 214e3c1917eSDavide Caratti 215e3c1917eSDavide Caratti tc_check_packets "dev $h2 ingress" 104 1 216e3c1917eSDavide Caratti check_err $? "Matched on nofrag filter (no1stfrag)" 217e3c1917eSDavide Caratti 218e3c1917eSDavide Caratti tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower 219e3c1917eSDavide Caratti tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower 220e3c1917eSDavide Caratti tc filter del dev $h2 ingress protocol ip pref 3 handle 103 flower 221e3c1917eSDavide Caratti tc filter del dev $h2 ingress protocol ip pref 4 handle 104 flower 222e3c1917eSDavide Caratti 223e3c1917eSDavide Caratti log_test "ip_flags match ($tcflags)" 224e3c1917eSDavide Caratti} 225e3c1917eSDavide Caratti 2260637e1f8SAmit Cohenmatch_pcp_test() 2270637e1f8SAmit Cohen{ 2280637e1f8SAmit Cohen RET=0 2290637e1f8SAmit Cohen 2300637e1f8SAmit Cohen vlan_create $h2 85 v$h2 192.0.2.11/24 2310637e1f8SAmit Cohen 2320637e1f8SAmit Cohen tc filter add dev $h2 ingress protocol 802.1q pref 1 handle 101 \ 2330637e1f8SAmit Cohen flower vlan_prio 6 $tcflags dst_mac $h2mac action drop 2340637e1f8SAmit Cohen tc filter add dev $h2 ingress protocol 802.1q pref 2 handle 102 \ 2350637e1f8SAmit Cohen flower vlan_prio 7 $tcflags dst_mac $h2mac action drop 2360637e1f8SAmit Cohen 2370637e1f8SAmit Cohen $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -B 192.0.2.11 -Q 7:85 -t ip -q 2380637e1f8SAmit Cohen $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -B 192.0.2.11 -Q 0:85 -t ip -q 2390637e1f8SAmit Cohen 2400637e1f8SAmit Cohen tc_check_packets "dev $h2 ingress" 101 0 2410637e1f8SAmit Cohen check_err $? "Matched on specified PCP when should not" 2420637e1f8SAmit Cohen 2430637e1f8SAmit Cohen tc_check_packets "dev $h2 ingress" 102 1 2440637e1f8SAmit Cohen check_err $? "Did not match on specified PCP" 2450637e1f8SAmit Cohen 2460637e1f8SAmit Cohen tc filter del dev $h2 ingress protocol 802.1q pref 2 handle 102 flower 2470637e1f8SAmit Cohen tc filter del dev $h2 ingress protocol 802.1q pref 1 handle 101 flower 2480637e1f8SAmit Cohen 2490637e1f8SAmit Cohen vlan_destroy $h2 85 2500637e1f8SAmit Cohen 2510637e1f8SAmit Cohen log_test "PCP match ($tcflags)" 2520637e1f8SAmit Cohen} 2530637e1f8SAmit Cohen 2540637e1f8SAmit Cohenmatch_vlan_test() 2550637e1f8SAmit Cohen{ 2560637e1f8SAmit Cohen RET=0 2570637e1f8SAmit Cohen 2580637e1f8SAmit Cohen vlan_create $h2 85 v$h2 192.0.2.11/24 2590637e1f8SAmit Cohen vlan_create $h2 75 v$h2 192.0.2.10/24 2600637e1f8SAmit Cohen 2610637e1f8SAmit Cohen tc filter add dev $h2 ingress protocol 802.1q pref 1 handle 101 \ 2620637e1f8SAmit Cohen flower vlan_id 75 $tcflags action drop 2630637e1f8SAmit Cohen tc filter add dev $h2 ingress protocol 802.1q pref 2 handle 102 \ 2640637e1f8SAmit Cohen flower vlan_id 85 $tcflags action drop 2650637e1f8SAmit Cohen 2660637e1f8SAmit Cohen $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -B 192.0.2.11 -Q 0:85 -t ip -q 2670637e1f8SAmit Cohen 2680637e1f8SAmit Cohen tc_check_packets "dev $h2 ingress" 101 0 2690637e1f8SAmit Cohen check_err $? "Matched on specified VLAN when should not" 2700637e1f8SAmit Cohen 2710637e1f8SAmit Cohen tc_check_packets "dev $h2 ingress" 102 1 2720637e1f8SAmit Cohen check_err $? "Did not match on specified VLAN" 2730637e1f8SAmit Cohen 2740637e1f8SAmit Cohen tc filter del dev $h2 ingress protocol 802.1q pref 2 handle 102 flower 2750637e1f8SAmit Cohen tc filter del dev $h2 ingress protocol 802.1q pref 1 handle 101 flower 2760637e1f8SAmit Cohen 2770637e1f8SAmit Cohen vlan_destroy $h2 75 2780637e1f8SAmit Cohen vlan_destroy $h2 85 2790637e1f8SAmit Cohen 2800637e1f8SAmit Cohen log_test "VLAN match ($tcflags)" 2810637e1f8SAmit Cohen} 2820637e1f8SAmit Cohen 2830b0c0098SJiri Pirkomatch_ip_tos_test() 2840b0c0098SJiri Pirko{ 2850b0c0098SJiri Pirko RET=0 2860b0c0098SJiri Pirko 2870b0c0098SJiri Pirko tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ 2880b0c0098SJiri Pirko $tcflags dst_ip 192.0.2.2 ip_tos 0x20 action drop 2890b0c0098SJiri Pirko tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ 2900b0c0098SJiri Pirko $tcflags dst_ip 192.0.2.2 ip_tos 0x18 action drop 2910b0c0098SJiri Pirko 2920b0c0098SJiri Pirko $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ 2930b0c0098SJiri Pirko -t ip tos=18 -q 2940b0c0098SJiri Pirko 2950b0c0098SJiri Pirko tc_check_packets "dev $h2 ingress" 101 1 2960b0c0098SJiri Pirko check_fail $? "Matched on a wrong filter (0x18)" 2970b0c0098SJiri Pirko 2980b0c0098SJiri Pirko tc_check_packets "dev $h2 ingress" 102 1 2990b0c0098SJiri Pirko check_err $? "Did not match on correct filter (0x18)" 3000b0c0098SJiri Pirko 3010b0c0098SJiri Pirko $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ 3020b0c0098SJiri Pirko -t ip tos=20 -q 3030b0c0098SJiri Pirko 3040b0c0098SJiri Pirko tc_check_packets "dev $h2 ingress" 102 2 3050b0c0098SJiri Pirko check_fail $? "Matched on a wrong filter (0x20)" 3060b0c0098SJiri Pirko 3070b0c0098SJiri Pirko tc_check_packets "dev $h2 ingress" 101 1 3080b0c0098SJiri Pirko check_err $? "Did not match on correct filter (0x20)" 3090b0c0098SJiri Pirko 3100b0c0098SJiri Pirko tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower 3110b0c0098SJiri Pirko tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower 3120b0c0098SJiri Pirko 3130b0c0098SJiri Pirko log_test "ip_tos match ($tcflags)" 3140b0c0098SJiri Pirko} 3150b0c0098SJiri Pirko 316d2126838SDavide Carattimatch_ip_ttl_test() 317d2126838SDavide Caratti{ 318d2126838SDavide Caratti RET=0 319d2126838SDavide Caratti 320d2126838SDavide Caratti tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ 321d2126838SDavide Caratti $tcflags dst_ip 192.0.2.2 ip_ttl 63 action drop 322d2126838SDavide Caratti tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ 323d2126838SDavide Caratti $tcflags dst_ip 192.0.2.2 action drop 324d2126838SDavide Caratti 325d2126838SDavide Caratti $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ 326d2126838SDavide Caratti -t ip "ttl=63" -q 327d2126838SDavide Caratti 328d2126838SDavide Caratti $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ 329d2126838SDavide Caratti -t ip "ttl=63,mf,frag=256" -q 330d2126838SDavide Caratti 331d2126838SDavide Caratti tc_check_packets "dev $h2 ingress" 102 1 332d2126838SDavide Caratti check_fail $? "Matched on the wrong filter (no check on ttl)" 333d2126838SDavide Caratti 334d2126838SDavide Caratti tc_check_packets "dev $h2 ingress" 101 2 335d2126838SDavide Caratti check_err $? "Did not match on correct filter (ttl=63)" 336d2126838SDavide Caratti 337d2126838SDavide Caratti $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ 338d2126838SDavide Caratti -t ip "ttl=255" -q 339d2126838SDavide Caratti 340d2126838SDavide Caratti tc_check_packets "dev $h2 ingress" 101 3 341d2126838SDavide Caratti check_fail $? "Matched on a wrong filter (ttl=63)" 342d2126838SDavide Caratti 343d2126838SDavide Caratti tc_check_packets "dev $h2 ingress" 102 1 344d2126838SDavide Caratti check_err $? "Did not match on correct filter (no check on ttl)" 345d2126838SDavide Caratti 346d2126838SDavide Caratti tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower 347d2126838SDavide Caratti tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower 348d2126838SDavide Caratti 349d2126838SDavide Caratti log_test "ip_ttl match ($tcflags)" 350d2126838SDavide Caratti} 351d2126838SDavide Caratti 352dcc5e1f9SJiri Pirkomatch_indev_test() 353dcc5e1f9SJiri Pirko{ 354dcc5e1f9SJiri Pirko RET=0 355dcc5e1f9SJiri Pirko 356dcc5e1f9SJiri Pirko tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ 357dcc5e1f9SJiri Pirko $tcflags indev $h1 dst_mac $h2mac action drop 358dcc5e1f9SJiri Pirko tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ 359dcc5e1f9SJiri Pirko $tcflags indev $h2 dst_mac $h2mac action drop 360dcc5e1f9SJiri Pirko 361dcc5e1f9SJiri Pirko $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ 362dcc5e1f9SJiri Pirko -t ip -q 363dcc5e1f9SJiri Pirko 364dcc5e1f9SJiri Pirko tc_check_packets "dev $h2 ingress" 101 1 365dcc5e1f9SJiri Pirko check_fail $? "Matched on a wrong filter" 366dcc5e1f9SJiri Pirko 367dcc5e1f9SJiri Pirko tc_check_packets "dev $h2 ingress" 102 1 368dcc5e1f9SJiri Pirko check_err $? "Did not match on correct filter" 369dcc5e1f9SJiri Pirko 370dcc5e1f9SJiri Pirko tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower 371dcc5e1f9SJiri Pirko tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower 372dcc5e1f9SJiri Pirko 373dcc5e1f9SJiri Pirko log_test "indev match ($tcflags)" 374dcc5e1f9SJiri Pirko} 375dcc5e1f9SJiri Pirko 376203ee5cdSGuillaume Nault# Unfortunately, mausezahn can't build MPLS headers when used in L2 377203ee5cdSGuillaume Nault# mode, so we have this function to build Label Stack Entries. 378203ee5cdSGuillaume Naultmpls_lse() 379203ee5cdSGuillaume Nault{ 380203ee5cdSGuillaume Nault local label=$1 381203ee5cdSGuillaume Nault local tc=$2 382203ee5cdSGuillaume Nault local bos=$3 383203ee5cdSGuillaume Nault local ttl=$4 384203ee5cdSGuillaume Nault 385203ee5cdSGuillaume Nault printf "%02x %02x %02x %02x" \ 386203ee5cdSGuillaume Nault $((label >> 12)) \ 387203ee5cdSGuillaume Nault $((label >> 4 & 0xff)) \ 388203ee5cdSGuillaume Nault $((((label & 0xf) << 4) + (tc << 1) + bos)) \ 389203ee5cdSGuillaume Nault $ttl 390203ee5cdSGuillaume Nault} 391203ee5cdSGuillaume Nault 392203ee5cdSGuillaume Naultmatch_mpls_label_test() 393203ee5cdSGuillaume Nault{ 394203ee5cdSGuillaume Nault local ethtype="88 47"; readonly ethtype 395203ee5cdSGuillaume Nault local pkt 396203ee5cdSGuillaume Nault 397203ee5cdSGuillaume Nault RET=0 398203ee5cdSGuillaume Nault 399203ee5cdSGuillaume Nault check_tc_mpls_support $h2 || return 0 400203ee5cdSGuillaume Nault 401203ee5cdSGuillaume Nault tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \ 402203ee5cdSGuillaume Nault flower $tcflags mpls_label 0 action drop 403203ee5cdSGuillaume Nault tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \ 404203ee5cdSGuillaume Nault flower $tcflags mpls_label 1048575 action drop 405203ee5cdSGuillaume Nault 406203ee5cdSGuillaume Nault pkt="$ethtype $(mpls_lse 1048575 0 1 255)" 407203ee5cdSGuillaume Nault $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q 408203ee5cdSGuillaume Nault 409203ee5cdSGuillaume Nault tc_check_packets "dev $h2 ingress" 101 1 410203ee5cdSGuillaume Nault check_fail $? "Matched on a wrong filter (1048575)" 411203ee5cdSGuillaume Nault 412203ee5cdSGuillaume Nault tc_check_packets "dev $h2 ingress" 102 1 413203ee5cdSGuillaume Nault check_err $? "Did not match on correct filter (1048575)" 414203ee5cdSGuillaume Nault 415203ee5cdSGuillaume Nault pkt="$ethtype $(mpls_lse 0 0 1 255)" 416203ee5cdSGuillaume Nault $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q 417203ee5cdSGuillaume Nault 418203ee5cdSGuillaume Nault tc_check_packets "dev $h2 ingress" 102 2 419203ee5cdSGuillaume Nault check_fail $? "Matched on a wrong filter (0)" 420203ee5cdSGuillaume Nault 421203ee5cdSGuillaume Nault tc_check_packets "dev $h2 ingress" 101 1 422203ee5cdSGuillaume Nault check_err $? "Did not match on correct filter (0)" 423203ee5cdSGuillaume Nault 424203ee5cdSGuillaume Nault tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower 425203ee5cdSGuillaume Nault tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower 426203ee5cdSGuillaume Nault 427203ee5cdSGuillaume Nault log_test "mpls_label match ($tcflags)" 428203ee5cdSGuillaume Nault} 429203ee5cdSGuillaume Nault 430203ee5cdSGuillaume Naultmatch_mpls_tc_test() 431203ee5cdSGuillaume Nault{ 432203ee5cdSGuillaume Nault local ethtype="88 47"; readonly ethtype 433203ee5cdSGuillaume Nault local pkt 434203ee5cdSGuillaume Nault 435203ee5cdSGuillaume Nault RET=0 436203ee5cdSGuillaume Nault 437203ee5cdSGuillaume Nault check_tc_mpls_support $h2 || return 0 438203ee5cdSGuillaume Nault 439203ee5cdSGuillaume Nault tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \ 440203ee5cdSGuillaume Nault flower $tcflags mpls_tc 0 action drop 441203ee5cdSGuillaume Nault tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \ 442203ee5cdSGuillaume Nault flower $tcflags mpls_tc 7 action drop 443203ee5cdSGuillaume Nault 444203ee5cdSGuillaume Nault pkt="$ethtype $(mpls_lse 0 7 1 255)" 445203ee5cdSGuillaume Nault $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q 446203ee5cdSGuillaume Nault 447203ee5cdSGuillaume Nault tc_check_packets "dev $h2 ingress" 101 1 448203ee5cdSGuillaume Nault check_fail $? "Matched on a wrong filter (7)" 449203ee5cdSGuillaume Nault 450203ee5cdSGuillaume Nault tc_check_packets "dev $h2 ingress" 102 1 451203ee5cdSGuillaume Nault check_err $? "Did not match on correct filter (7)" 452203ee5cdSGuillaume Nault 453203ee5cdSGuillaume Nault pkt="$ethtype $(mpls_lse 0 0 1 255)" 454203ee5cdSGuillaume Nault $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q 455203ee5cdSGuillaume Nault 456203ee5cdSGuillaume Nault tc_check_packets "dev $h2 ingress" 102 2 457203ee5cdSGuillaume Nault check_fail $? "Matched on a wrong filter (0)" 458203ee5cdSGuillaume Nault 459203ee5cdSGuillaume Nault tc_check_packets "dev $h2 ingress" 101 1 460203ee5cdSGuillaume Nault check_err $? "Did not match on correct filter (0)" 461203ee5cdSGuillaume Nault 462203ee5cdSGuillaume Nault tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower 463203ee5cdSGuillaume Nault tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower 464203ee5cdSGuillaume Nault 465203ee5cdSGuillaume Nault log_test "mpls_tc match ($tcflags)" 466203ee5cdSGuillaume Nault} 467203ee5cdSGuillaume Nault 468203ee5cdSGuillaume Naultmatch_mpls_bos_test() 469203ee5cdSGuillaume Nault{ 470203ee5cdSGuillaume Nault local ethtype="88 47"; readonly ethtype 471203ee5cdSGuillaume Nault local pkt 472203ee5cdSGuillaume Nault 473203ee5cdSGuillaume Nault RET=0 474203ee5cdSGuillaume Nault 475203ee5cdSGuillaume Nault check_tc_mpls_support $h2 || return 0 476203ee5cdSGuillaume Nault 477203ee5cdSGuillaume Nault tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \ 478203ee5cdSGuillaume Nault flower $tcflags mpls_bos 0 action drop 479203ee5cdSGuillaume Nault tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \ 480203ee5cdSGuillaume Nault flower $tcflags mpls_bos 1 action drop 481203ee5cdSGuillaume Nault 482203ee5cdSGuillaume Nault pkt="$ethtype $(mpls_lse 0 0 1 255)" 483203ee5cdSGuillaume Nault $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q 484203ee5cdSGuillaume Nault 485203ee5cdSGuillaume Nault tc_check_packets "dev $h2 ingress" 101 1 486203ee5cdSGuillaume Nault check_fail $? "Matched on a wrong filter (1)" 487203ee5cdSGuillaume Nault 488203ee5cdSGuillaume Nault tc_check_packets "dev $h2 ingress" 102 1 489203ee5cdSGuillaume Nault check_err $? "Did not match on correct filter (1)" 490203ee5cdSGuillaume Nault 491203ee5cdSGuillaume Nault # Need to add a second label to properly mark the Bottom of Stack 492203ee5cdSGuillaume Nault pkt="$ethtype $(mpls_lse 0 0 0 255) $(mpls_lse 0 0 1 255)" 493203ee5cdSGuillaume Nault $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q 494203ee5cdSGuillaume Nault 495203ee5cdSGuillaume Nault tc_check_packets "dev $h2 ingress" 102 2 496203ee5cdSGuillaume Nault check_fail $? "Matched on a wrong filter (0)" 497203ee5cdSGuillaume Nault 498203ee5cdSGuillaume Nault tc_check_packets "dev $h2 ingress" 101 1 499203ee5cdSGuillaume Nault check_err $? "Did not match on correct filter (0)" 500203ee5cdSGuillaume Nault 501203ee5cdSGuillaume Nault tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower 502203ee5cdSGuillaume Nault tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower 503203ee5cdSGuillaume Nault 504203ee5cdSGuillaume Nault log_test "mpls_bos match ($tcflags)" 505203ee5cdSGuillaume Nault} 506203ee5cdSGuillaume Nault 507203ee5cdSGuillaume Naultmatch_mpls_ttl_test() 508203ee5cdSGuillaume Nault{ 509203ee5cdSGuillaume Nault local ethtype="88 47"; readonly ethtype 510203ee5cdSGuillaume Nault local pkt 511203ee5cdSGuillaume Nault 512203ee5cdSGuillaume Nault RET=0 513203ee5cdSGuillaume Nault 514203ee5cdSGuillaume Nault check_tc_mpls_support $h2 || return 0 515203ee5cdSGuillaume Nault 516203ee5cdSGuillaume Nault tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \ 517203ee5cdSGuillaume Nault flower $tcflags mpls_ttl 0 action drop 518203ee5cdSGuillaume Nault tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \ 519203ee5cdSGuillaume Nault flower $tcflags mpls_ttl 255 action drop 520203ee5cdSGuillaume Nault 521203ee5cdSGuillaume Nault pkt="$ethtype $(mpls_lse 0 0 1 255)" 522203ee5cdSGuillaume Nault $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q 523203ee5cdSGuillaume Nault 524203ee5cdSGuillaume Nault tc_check_packets "dev $h2 ingress" 101 1 525203ee5cdSGuillaume Nault check_fail $? "Matched on a wrong filter (255)" 526203ee5cdSGuillaume Nault 527203ee5cdSGuillaume Nault tc_check_packets "dev $h2 ingress" 102 1 528203ee5cdSGuillaume Nault check_err $? "Did not match on correct filter (255)" 529203ee5cdSGuillaume Nault 530203ee5cdSGuillaume Nault pkt="$ethtype $(mpls_lse 0 0 1 0)" 531203ee5cdSGuillaume Nault $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q 532203ee5cdSGuillaume Nault 533203ee5cdSGuillaume Nault tc_check_packets "dev $h2 ingress" 102 2 534203ee5cdSGuillaume Nault check_fail $? "Matched on a wrong filter (0)" 535203ee5cdSGuillaume Nault 536203ee5cdSGuillaume Nault tc_check_packets "dev $h2 ingress" 101 1 537203ee5cdSGuillaume Nault check_err $? "Did not match on correct filter (0)" 538203ee5cdSGuillaume Nault 539203ee5cdSGuillaume Nault tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower 540203ee5cdSGuillaume Nault tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower 541203ee5cdSGuillaume Nault 542203ee5cdSGuillaume Nault log_test "mpls_ttl match ($tcflags)" 543203ee5cdSGuillaume Nault} 544203ee5cdSGuillaume Nault 545c09bfd9aSGuillaume Naultmatch_mpls_lse_test() 546c09bfd9aSGuillaume Nault{ 547c09bfd9aSGuillaume Nault local ethtype="88 47"; readonly ethtype 548c09bfd9aSGuillaume Nault local pkt 549c09bfd9aSGuillaume Nault 550c09bfd9aSGuillaume Nault RET=0 551c09bfd9aSGuillaume Nault 552c09bfd9aSGuillaume Nault check_tc_mpls_lse_stats $h2 || return 0 553c09bfd9aSGuillaume Nault 554c09bfd9aSGuillaume Nault # Match on first LSE (minimal values for each field) 555c09bfd9aSGuillaume Nault tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \ 556c09bfd9aSGuillaume Nault flower $tcflags mpls lse depth 1 label 0 action continue 557c09bfd9aSGuillaume Nault tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \ 558c09bfd9aSGuillaume Nault flower $tcflags mpls lse depth 1 tc 0 action continue 559c09bfd9aSGuillaume Nault tc filter add dev $h2 ingress protocol mpls_uc pref 3 handle 103 \ 560c09bfd9aSGuillaume Nault flower $tcflags mpls lse depth 1 bos 0 action continue 561c09bfd9aSGuillaume Nault tc filter add dev $h2 ingress protocol mpls_uc pref 4 handle 104 \ 562c09bfd9aSGuillaume Nault flower $tcflags mpls lse depth 1 ttl 0 action continue 563c09bfd9aSGuillaume Nault 564c09bfd9aSGuillaume Nault # Match on second LSE (maximal values for each field) 565c09bfd9aSGuillaume Nault tc filter add dev $h2 ingress protocol mpls_uc pref 5 handle 105 \ 566c09bfd9aSGuillaume Nault flower $tcflags mpls lse depth 2 label 1048575 action continue 567c09bfd9aSGuillaume Nault tc filter add dev $h2 ingress protocol mpls_uc pref 6 handle 106 \ 568c09bfd9aSGuillaume Nault flower $tcflags mpls lse depth 2 tc 7 action continue 569c09bfd9aSGuillaume Nault tc filter add dev $h2 ingress protocol mpls_uc pref 7 handle 107 \ 570c09bfd9aSGuillaume Nault flower $tcflags mpls lse depth 2 bos 1 action continue 571c09bfd9aSGuillaume Nault tc filter add dev $h2 ingress protocol mpls_uc pref 8 handle 108 \ 572c09bfd9aSGuillaume Nault flower $tcflags mpls lse depth 2 ttl 255 action continue 573c09bfd9aSGuillaume Nault 574c09bfd9aSGuillaume Nault # Match on LSE depth 575c09bfd9aSGuillaume Nault tc filter add dev $h2 ingress protocol mpls_uc pref 9 handle 109 \ 576c09bfd9aSGuillaume Nault flower $tcflags mpls lse depth 1 action continue 577c09bfd9aSGuillaume Nault tc filter add dev $h2 ingress protocol mpls_uc pref 10 handle 110 \ 578c09bfd9aSGuillaume Nault flower $tcflags mpls lse depth 2 action continue 579c09bfd9aSGuillaume Nault tc filter add dev $h2 ingress protocol mpls_uc pref 11 handle 111 \ 580c09bfd9aSGuillaume Nault flower $tcflags mpls lse depth 3 action continue 581c09bfd9aSGuillaume Nault 582c09bfd9aSGuillaume Nault # Base packet, matched by all filters (except for stack depth 3) 583c09bfd9aSGuillaume Nault pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048575 7 1 255)" 584c09bfd9aSGuillaume Nault $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q 585c09bfd9aSGuillaume Nault 586c09bfd9aSGuillaume Nault # Make a variant of the above packet, with a non-matching value 587c09bfd9aSGuillaume Nault # for each LSE field 588c09bfd9aSGuillaume Nault 589c09bfd9aSGuillaume Nault # Wrong label at depth 1 590c09bfd9aSGuillaume Nault pkt="$ethtype $(mpls_lse 1 0 0 0) $(mpls_lse 1048575 7 1 255)" 591c09bfd9aSGuillaume Nault $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q 592c09bfd9aSGuillaume Nault 593c09bfd9aSGuillaume Nault # Wrong TC at depth 1 594c09bfd9aSGuillaume Nault pkt="$ethtype $(mpls_lse 0 1 0 0) $(mpls_lse 1048575 7 1 255)" 595c09bfd9aSGuillaume Nault $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q 596c09bfd9aSGuillaume Nault 597c09bfd9aSGuillaume Nault # Wrong BOS at depth 1 (not adding a second LSE here since BOS is set 598c09bfd9aSGuillaume Nault # in the first label, so anything that'd follow wouldn't be considered) 599c09bfd9aSGuillaume Nault pkt="$ethtype $(mpls_lse 0 0 1 0)" 600c09bfd9aSGuillaume Nault $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q 601c09bfd9aSGuillaume Nault 602c09bfd9aSGuillaume Nault # Wrong TTL at depth 1 603c09bfd9aSGuillaume Nault pkt="$ethtype $(mpls_lse 0 0 0 1) $(mpls_lse 1048575 7 1 255)" 604c09bfd9aSGuillaume Nault $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q 605c09bfd9aSGuillaume Nault 606c09bfd9aSGuillaume Nault # Wrong label at depth 2 607c09bfd9aSGuillaume Nault pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048574 7 1 255)" 608c09bfd9aSGuillaume Nault $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q 609c09bfd9aSGuillaume Nault 610c09bfd9aSGuillaume Nault # Wrong TC at depth 2 611c09bfd9aSGuillaume Nault pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048575 6 1 255)" 612c09bfd9aSGuillaume Nault $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q 613c09bfd9aSGuillaume Nault 614c09bfd9aSGuillaume Nault # Wrong BOS at depth 2 (adding a third LSE here since BOS isn't set in 615c09bfd9aSGuillaume Nault # the second label) 616c09bfd9aSGuillaume Nault pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048575 7 0 255)" 617c09bfd9aSGuillaume Nault pkt="$pkt $(mpls_lse 0 0 1 255)" 618c09bfd9aSGuillaume Nault $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q 619c09bfd9aSGuillaume Nault 620c09bfd9aSGuillaume Nault # Wrong TTL at depth 2 621c09bfd9aSGuillaume Nault pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048575 7 1 254)" 622c09bfd9aSGuillaume Nault $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q 623c09bfd9aSGuillaume Nault 624c09bfd9aSGuillaume Nault # Filters working at depth 1 should match all packets but one 625c09bfd9aSGuillaume Nault 626c09bfd9aSGuillaume Nault tc_check_packets "dev $h2 ingress" 101 8 627c09bfd9aSGuillaume Nault check_err $? "Did not match on correct filter" 628c09bfd9aSGuillaume Nault 629c09bfd9aSGuillaume Nault tc_check_packets "dev $h2 ingress" 102 8 630c09bfd9aSGuillaume Nault check_err $? "Did not match on correct filter" 631c09bfd9aSGuillaume Nault 632c09bfd9aSGuillaume Nault tc_check_packets "dev $h2 ingress" 103 8 633c09bfd9aSGuillaume Nault check_err $? "Did not match on correct filter" 634c09bfd9aSGuillaume Nault 635c09bfd9aSGuillaume Nault tc_check_packets "dev $h2 ingress" 104 8 636c09bfd9aSGuillaume Nault check_err $? "Did not match on correct filter" 637c09bfd9aSGuillaume Nault 638c09bfd9aSGuillaume Nault # Filters working at depth 2 should match all packets but two (because 639c09bfd9aSGuillaume Nault # of the test packet where the label stack depth is just one) 640c09bfd9aSGuillaume Nault 641c09bfd9aSGuillaume Nault tc_check_packets "dev $h2 ingress" 105 7 642c09bfd9aSGuillaume Nault check_err $? "Did not match on correct filter" 643c09bfd9aSGuillaume Nault 644c09bfd9aSGuillaume Nault tc_check_packets "dev $h2 ingress" 106 7 645c09bfd9aSGuillaume Nault check_err $? "Did not match on correct filter" 646c09bfd9aSGuillaume Nault 647c09bfd9aSGuillaume Nault tc_check_packets "dev $h2 ingress" 107 7 648c09bfd9aSGuillaume Nault check_err $? "Did not match on correct filter" 649c09bfd9aSGuillaume Nault 650c09bfd9aSGuillaume Nault tc_check_packets "dev $h2 ingress" 108 7 651c09bfd9aSGuillaume Nault check_err $? "Did not match on correct filter" 652c09bfd9aSGuillaume Nault 653c09bfd9aSGuillaume Nault # Finally, verify the filters that only match on LSE depth 654c09bfd9aSGuillaume Nault 655c09bfd9aSGuillaume Nault tc_check_packets "dev $h2 ingress" 109 9 656c09bfd9aSGuillaume Nault check_err $? "Did not match on correct filter" 657c09bfd9aSGuillaume Nault 658c09bfd9aSGuillaume Nault tc_check_packets "dev $h2 ingress" 110 8 659c09bfd9aSGuillaume Nault check_err $? "Did not match on correct filter" 660c09bfd9aSGuillaume Nault 661c09bfd9aSGuillaume Nault tc_check_packets "dev $h2 ingress" 111 1 662c09bfd9aSGuillaume Nault check_err $? "Did not match on correct filter" 663c09bfd9aSGuillaume Nault 664c09bfd9aSGuillaume Nault tc filter del dev $h2 ingress protocol mpls_uc pref 11 handle 111 flower 665c09bfd9aSGuillaume Nault tc filter del dev $h2 ingress protocol mpls_uc pref 10 handle 110 flower 666c09bfd9aSGuillaume Nault tc filter del dev $h2 ingress protocol mpls_uc pref 9 handle 109 flower 667c09bfd9aSGuillaume Nault tc filter del dev $h2 ingress protocol mpls_uc pref 8 handle 108 flower 668c09bfd9aSGuillaume Nault tc filter del dev $h2 ingress protocol mpls_uc pref 7 handle 107 flower 669c09bfd9aSGuillaume Nault tc filter del dev $h2 ingress protocol mpls_uc pref 6 handle 106 flower 670c09bfd9aSGuillaume Nault tc filter del dev $h2 ingress protocol mpls_uc pref 5 handle 105 flower 671c09bfd9aSGuillaume Nault tc filter del dev $h2 ingress protocol mpls_uc pref 4 handle 104 flower 672c09bfd9aSGuillaume Nault tc filter del dev $h2 ingress protocol mpls_uc pref 3 handle 103 flower 673c09bfd9aSGuillaume Nault tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower 674c09bfd9aSGuillaume Nault tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower 675c09bfd9aSGuillaume Nault 676c09bfd9aSGuillaume Nault log_test "mpls lse match ($tcflags)" 677c09bfd9aSGuillaume Nault} 678c09bfd9aSGuillaume Nault 67907e5c751SJiri Pirkosetup_prepare() 68007e5c751SJiri Pirko{ 68107e5c751SJiri Pirko h1=${NETIFS[p1]} 68207e5c751SJiri Pirko h2=${NETIFS[p2]} 68307e5c751SJiri Pirko h1mac=$(mac_get $h1) 68407e5c751SJiri Pirko h2mac=$(mac_get $h2) 68507e5c751SJiri Pirko 68607e5c751SJiri Pirko vrf_prepare 68707e5c751SJiri Pirko 68807e5c751SJiri Pirko h1_create 68907e5c751SJiri Pirko h2_create 69007e5c751SJiri Pirko} 69107e5c751SJiri Pirko 69207e5c751SJiri Pirkocleanup() 69307e5c751SJiri Pirko{ 69407e5c751SJiri Pirko pre_cleanup 69507e5c751SJiri Pirko 69607e5c751SJiri Pirko h2_destroy 69707e5c751SJiri Pirko h1_destroy 69807e5c751SJiri Pirko 69907e5c751SJiri Pirko vrf_cleanup 70007e5c751SJiri Pirko} 70107e5c751SJiri Pirko 70207e5c751SJiri Pirkotrap cleanup EXIT 70307e5c751SJiri Pirko 70407e5c751SJiri Pirkosetup_prepare 70507e5c751SJiri Pirkosetup_wait 70607e5c751SJiri Pirko 7070eb8053cSIdo Schimmeltests_run 70807e5c751SJiri Pirko 70907e5c751SJiri Pirkotc_offload_check 71007e5c751SJiri Pirkoif [[ $? -ne 0 ]]; then 71107e5c751SJiri Pirko log_info "Could not test offloaded functionality" 71207e5c751SJiri Pirkoelse 71307e5c751SJiri Pirko tcflags="skip_sw" 7140eb8053cSIdo Schimmel tests_run 71507e5c751SJiri Pirkofi 71607e5c751SJiri Pirko 71707e5c751SJiri Pirkoexit $EXIT_STATUS 718