0001
0002
0003
0004 ALL_TESTS="match_dst_mac_test match_src_mac_test match_dst_ip_test \
0005 match_src_ip_test match_ip_flags_test match_pcp_test match_vlan_test \
0006 match_ip_tos_test match_indev_test match_ip_ttl_test
0007 match_mpls_label_test \
0008 match_mpls_tc_test match_mpls_bos_test match_mpls_ttl_test \
0009 match_mpls_lse_test"
0010 NUM_NETIFS=2
0011 source tc_common.sh
0012 source lib.sh
0013
0014 tcflags="skip_hw"
0015
0016 h1_create()
0017 {
0018 simple_if_init $h1 192.0.2.1/24 198.51.100.1/24
0019 }
0020
0021 h1_destroy()
0022 {
0023 simple_if_fini $h1 192.0.2.1/24 198.51.100.1/24
0024 }
0025
0026 h2_create()
0027 {
0028 simple_if_init $h2 192.0.2.2/24 198.51.100.2/24
0029 tc qdisc add dev $h2 clsact
0030 }
0031
0032 h2_destroy()
0033 {
0034 tc qdisc del dev $h2 clsact
0035 simple_if_fini $h2 192.0.2.2/24 198.51.100.2/24
0036 }
0037
0038 match_dst_mac_test()
0039 {
0040 local dummy_mac=de:ad:be:ef:aa:aa
0041
0042 RET=0
0043
0044 tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \
0045 $tcflags dst_mac $dummy_mac action drop
0046 tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \
0047 $tcflags dst_mac $h2mac action drop
0048
0049 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
0050 -t ip -q
0051
0052 tc_check_packets "dev $h2 ingress" 101 1
0053 check_fail $? "Matched on a wrong filter"
0054
0055 tc_check_packets "dev $h2 ingress" 102 1
0056 check_err $? "Did not match on correct filter"
0057
0058 tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower
0059 tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower
0060
0061 log_test "dst_mac match ($tcflags)"
0062 }
0063
0064 match_src_mac_test()
0065 {
0066 local dummy_mac=de:ad:be:ef:aa:aa
0067
0068 RET=0
0069
0070 tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \
0071 $tcflags src_mac $dummy_mac action drop
0072 tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \
0073 $tcflags src_mac $h1mac action drop
0074
0075 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
0076 -t ip -q
0077
0078 tc_check_packets "dev $h2 ingress" 101 1
0079 check_fail $? "Matched on a wrong filter"
0080
0081 tc_check_packets "dev $h2 ingress" 102 1
0082 check_err $? "Did not match on correct filter"
0083
0084 tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower
0085 tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower
0086
0087 log_test "src_mac match ($tcflags)"
0088 }
0089
0090 match_dst_ip_test()
0091 {
0092 RET=0
0093
0094 tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \
0095 $tcflags dst_ip 198.51.100.2 action drop
0096 tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \
0097 $tcflags dst_ip 192.0.2.2 action drop
0098 tc filter add dev $h2 ingress protocol ip pref 3 handle 103 flower \
0099 $tcflags dst_ip 192.0.2.0/24 action drop
0100
0101 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
0102 -t ip -q
0103
0104 tc_check_packets "dev $h2 ingress" 101 1
0105 check_fail $? "Matched on a wrong filter"
0106
0107 tc_check_packets "dev $h2 ingress" 102 1
0108 check_err $? "Did not match on correct filter"
0109
0110 tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower
0111
0112 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
0113 -t ip -q
0114
0115 tc_check_packets "dev $h2 ingress" 103 1
0116 check_err $? "Did not match on correct filter with mask"
0117
0118 tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower
0119 tc filter del dev $h2 ingress protocol ip pref 3 handle 103 flower
0120
0121 log_test "dst_ip match ($tcflags)"
0122 }
0123
0124 match_src_ip_test()
0125 {
0126 RET=0
0127
0128 tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \
0129 $tcflags src_ip 198.51.100.1 action drop
0130 tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \
0131 $tcflags src_ip 192.0.2.1 action drop
0132 tc filter add dev $h2 ingress protocol ip pref 3 handle 103 flower \
0133 $tcflags src_ip 192.0.2.0/24 action drop
0134
0135 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
0136 -t ip -q
0137
0138 tc_check_packets "dev $h2 ingress" 101 1
0139 check_fail $? "Matched on a wrong filter"
0140
0141 tc_check_packets "dev $h2 ingress" 102 1
0142 check_err $? "Did not match on correct filter"
0143
0144 tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower
0145
0146 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
0147 -t ip -q
0148
0149 tc_check_packets "dev $h2 ingress" 103 1
0150 check_err $? "Did not match on correct filter with mask"
0151
0152 tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower
0153 tc filter del dev $h2 ingress protocol ip pref 3 handle 103 flower
0154
0155 log_test "src_ip match ($tcflags)"
0156 }
0157
0158 match_ip_flags_test()
0159 {
0160 RET=0
0161
0162 tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \
0163 $tcflags ip_flags frag action continue
0164 tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \
0165 $tcflags ip_flags firstfrag action continue
0166 tc filter add dev $h2 ingress protocol ip pref 3 handle 103 flower \
0167 $tcflags ip_flags nofirstfrag action continue
0168 tc filter add dev $h2 ingress protocol ip pref 4 handle 104 flower \
0169 $tcflags ip_flags nofrag action drop
0170
0171 $MZ $h1 -c 1 -p 1000 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
0172 -t ip "frag=0" -q
0173
0174 tc_check_packets "dev $h2 ingress" 101 1
0175 check_fail $? "Matched on wrong frag filter (nofrag)"
0176
0177 tc_check_packets "dev $h2 ingress" 102 1
0178 check_fail $? "Matched on wrong firstfrag filter (nofrag)"
0179
0180 tc_check_packets "dev $h2 ingress" 103 1
0181 check_err $? "Did not match on nofirstfrag filter (nofrag) "
0182
0183 tc_check_packets "dev $h2 ingress" 104 1
0184 check_err $? "Did not match on nofrag filter (nofrag)"
0185
0186 $MZ $h1 -c 1 -p 1000 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
0187 -t ip "frag=0,mf" -q
0188
0189 tc_check_packets "dev $h2 ingress" 101 1
0190 check_err $? "Did not match on frag filter (1stfrag)"
0191
0192 tc_check_packets "dev $h2 ingress" 102 1
0193 check_err $? "Did not match fistfrag filter (1stfrag)"
0194
0195 tc_check_packets "dev $h2 ingress" 103 1
0196 check_err $? "Matched on wrong nofirstfrag filter (1stfrag)"
0197
0198 tc_check_packets "dev $h2 ingress" 104 1
0199 check_err $? "Match on wrong nofrag filter (1stfrag)"
0200
0201 $MZ $h1 -c 1 -p 1000 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
0202 -t ip "frag=256,mf" -q
0203 $MZ $h1 -c 1 -p 1000 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
0204 -t ip "frag=256" -q
0205
0206 tc_check_packets "dev $h2 ingress" 101 3
0207 check_err $? "Did not match on frag filter (no1stfrag)"
0208
0209 tc_check_packets "dev $h2 ingress" 102 1
0210 check_err $? "Matched on wrong firstfrag filter (no1stfrag)"
0211
0212 tc_check_packets "dev $h2 ingress" 103 3
0213 check_err $? "Did not match on nofirstfrag filter (no1stfrag)"
0214
0215 tc_check_packets "dev $h2 ingress" 104 1
0216 check_err $? "Matched on nofrag filter (no1stfrag)"
0217
0218 tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower
0219 tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower
0220 tc filter del dev $h2 ingress protocol ip pref 3 handle 103 flower
0221 tc filter del dev $h2 ingress protocol ip pref 4 handle 104 flower
0222
0223 log_test "ip_flags match ($tcflags)"
0224 }
0225
0226 match_pcp_test()
0227 {
0228 RET=0
0229
0230 vlan_create $h2 85 v$h2 192.0.2.11/24
0231
0232 tc filter add dev $h2 ingress protocol 802.1q pref 1 handle 101 \
0233 flower vlan_prio 6 $tcflags dst_mac $h2mac action drop
0234 tc filter add dev $h2 ingress protocol 802.1q pref 2 handle 102 \
0235 flower vlan_prio 7 $tcflags dst_mac $h2mac action drop
0236
0237 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -B 192.0.2.11 -Q 7:85 -t ip -q
0238 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -B 192.0.2.11 -Q 0:85 -t ip -q
0239
0240 tc_check_packets "dev $h2 ingress" 101 0
0241 check_err $? "Matched on specified PCP when should not"
0242
0243 tc_check_packets "dev $h2 ingress" 102 1
0244 check_err $? "Did not match on specified PCP"
0245
0246 tc filter del dev $h2 ingress protocol 802.1q pref 2 handle 102 flower
0247 tc filter del dev $h2 ingress protocol 802.1q pref 1 handle 101 flower
0248
0249 vlan_destroy $h2 85
0250
0251 log_test "PCP match ($tcflags)"
0252 }
0253
0254 match_vlan_test()
0255 {
0256 RET=0
0257
0258 vlan_create $h2 85 v$h2 192.0.2.11/24
0259 vlan_create $h2 75 v$h2 192.0.2.10/24
0260
0261 tc filter add dev $h2 ingress protocol 802.1q pref 1 handle 101 \
0262 flower vlan_id 75 $tcflags action drop
0263 tc filter add dev $h2 ingress protocol 802.1q pref 2 handle 102 \
0264 flower vlan_id 85 $tcflags action drop
0265
0266 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -B 192.0.2.11 -Q 0:85 -t ip -q
0267
0268 tc_check_packets "dev $h2 ingress" 101 0
0269 check_err $? "Matched on specified VLAN when should not"
0270
0271 tc_check_packets "dev $h2 ingress" 102 1
0272 check_err $? "Did not match on specified VLAN"
0273
0274 tc filter del dev $h2 ingress protocol 802.1q pref 2 handle 102 flower
0275 tc filter del dev $h2 ingress protocol 802.1q pref 1 handle 101 flower
0276
0277 vlan_destroy $h2 75
0278 vlan_destroy $h2 85
0279
0280 log_test "VLAN match ($tcflags)"
0281 }
0282
0283 match_ip_tos_test()
0284 {
0285 RET=0
0286
0287 tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \
0288 $tcflags dst_ip 192.0.2.2 ip_tos 0x20 action drop
0289 tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \
0290 $tcflags dst_ip 192.0.2.2 ip_tos 0x18 action drop
0291
0292 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
0293 -t ip tos=18 -q
0294
0295 tc_check_packets "dev $h2 ingress" 101 1
0296 check_fail $? "Matched on a wrong filter (0x18)"
0297
0298 tc_check_packets "dev $h2 ingress" 102 1
0299 check_err $? "Did not match on correct filter (0x18)"
0300
0301 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
0302 -t ip tos=20 -q
0303
0304 tc_check_packets "dev $h2 ingress" 102 2
0305 check_fail $? "Matched on a wrong filter (0x20)"
0306
0307 tc_check_packets "dev $h2 ingress" 101 1
0308 check_err $? "Did not match on correct filter (0x20)"
0309
0310 tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower
0311 tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower
0312
0313 log_test "ip_tos match ($tcflags)"
0314 }
0315
0316 match_ip_ttl_test()
0317 {
0318 RET=0
0319
0320 tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \
0321 $tcflags dst_ip 192.0.2.2 ip_ttl 63 action drop
0322 tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \
0323 $tcflags dst_ip 192.0.2.2 action drop
0324
0325 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
0326 -t ip "ttl=63" -q
0327
0328 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
0329 -t ip "ttl=63,mf,frag=256" -q
0330
0331 tc_check_packets "dev $h2 ingress" 102 1
0332 check_fail $? "Matched on the wrong filter (no check on ttl)"
0333
0334 tc_check_packets "dev $h2 ingress" 101 2
0335 check_err $? "Did not match on correct filter (ttl=63)"
0336
0337 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
0338 -t ip "ttl=255" -q
0339
0340 tc_check_packets "dev $h2 ingress" 101 3
0341 check_fail $? "Matched on a wrong filter (ttl=63)"
0342
0343 tc_check_packets "dev $h2 ingress" 102 1
0344 check_err $? "Did not match on correct filter (no check on ttl)"
0345
0346 tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower
0347 tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower
0348
0349 log_test "ip_ttl match ($tcflags)"
0350 }
0351
0352 match_indev_test()
0353 {
0354 RET=0
0355
0356 tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \
0357 $tcflags indev $h1 dst_mac $h2mac action drop
0358 tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \
0359 $tcflags indev $h2 dst_mac $h2mac action drop
0360
0361 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
0362 -t ip -q
0363
0364 tc_check_packets "dev $h2 ingress" 101 1
0365 check_fail $? "Matched on a wrong filter"
0366
0367 tc_check_packets "dev $h2 ingress" 102 1
0368 check_err $? "Did not match on correct filter"
0369
0370 tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower
0371 tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower
0372
0373 log_test "indev match ($tcflags)"
0374 }
0375
0376
0377
0378 mpls_lse()
0379 {
0380 local label=$1
0381 local tc=$2
0382 local bos=$3
0383 local ttl=$4
0384
0385 printf "%02x %02x %02x %02x" \
0386 $((label >> 12)) \
0387 $((label >> 4 & 0xff)) \
0388 $((((label & 0xf) << 4) + (tc << 1) + bos)) \
0389 $ttl
0390 }
0391
0392 match_mpls_label_test()
0393 {
0394 local ethtype="88 47"; readonly ethtype
0395 local pkt
0396
0397 RET=0
0398
0399 check_tc_mpls_support $h2 || return 0
0400
0401 tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \
0402 flower $tcflags mpls_label 0 action drop
0403 tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \
0404 flower $tcflags mpls_label 1048575 action drop
0405
0406 pkt="$ethtype $(mpls_lse 1048575 0 1 255)"
0407 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
0408
0409 tc_check_packets "dev $h2 ingress" 101 1
0410 check_fail $? "Matched on a wrong filter (1048575)"
0411
0412 tc_check_packets "dev $h2 ingress" 102 1
0413 check_err $? "Did not match on correct filter (1048575)"
0414
0415 pkt="$ethtype $(mpls_lse 0 0 1 255)"
0416 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
0417
0418 tc_check_packets "dev $h2 ingress" 102 2
0419 check_fail $? "Matched on a wrong filter (0)"
0420
0421 tc_check_packets "dev $h2 ingress" 101 1
0422 check_err $? "Did not match on correct filter (0)"
0423
0424 tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower
0425 tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower
0426
0427 log_test "mpls_label match ($tcflags)"
0428 }
0429
0430 match_mpls_tc_test()
0431 {
0432 local ethtype="88 47"; readonly ethtype
0433 local pkt
0434
0435 RET=0
0436
0437 check_tc_mpls_support $h2 || return 0
0438
0439 tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \
0440 flower $tcflags mpls_tc 0 action drop
0441 tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \
0442 flower $tcflags mpls_tc 7 action drop
0443
0444 pkt="$ethtype $(mpls_lse 0 7 1 255)"
0445 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
0446
0447 tc_check_packets "dev $h2 ingress" 101 1
0448 check_fail $? "Matched on a wrong filter (7)"
0449
0450 tc_check_packets "dev $h2 ingress" 102 1
0451 check_err $? "Did not match on correct filter (7)"
0452
0453 pkt="$ethtype $(mpls_lse 0 0 1 255)"
0454 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
0455
0456 tc_check_packets "dev $h2 ingress" 102 2
0457 check_fail $? "Matched on a wrong filter (0)"
0458
0459 tc_check_packets "dev $h2 ingress" 101 1
0460 check_err $? "Did not match on correct filter (0)"
0461
0462 tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower
0463 tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower
0464
0465 log_test "mpls_tc match ($tcflags)"
0466 }
0467
0468 match_mpls_bos_test()
0469 {
0470 local ethtype="88 47"; readonly ethtype
0471 local pkt
0472
0473 RET=0
0474
0475 check_tc_mpls_support $h2 || return 0
0476
0477 tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \
0478 flower $tcflags mpls_bos 0 action drop
0479 tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \
0480 flower $tcflags mpls_bos 1 action drop
0481
0482 pkt="$ethtype $(mpls_lse 0 0 1 255)"
0483 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
0484
0485 tc_check_packets "dev $h2 ingress" 101 1
0486 check_fail $? "Matched on a wrong filter (1)"
0487
0488 tc_check_packets "dev $h2 ingress" 102 1
0489 check_err $? "Did not match on correct filter (1)"
0490
0491
0492 pkt="$ethtype $(mpls_lse 0 0 0 255) $(mpls_lse 0 0 1 255)"
0493 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
0494
0495 tc_check_packets "dev $h2 ingress" 102 2
0496 check_fail $? "Matched on a wrong filter (0)"
0497
0498 tc_check_packets "dev $h2 ingress" 101 1
0499 check_err $? "Did not match on correct filter (0)"
0500
0501 tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower
0502 tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower
0503
0504 log_test "mpls_bos match ($tcflags)"
0505 }
0506
0507 match_mpls_ttl_test()
0508 {
0509 local ethtype="88 47"; readonly ethtype
0510 local pkt
0511
0512 RET=0
0513
0514 check_tc_mpls_support $h2 || return 0
0515
0516 tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \
0517 flower $tcflags mpls_ttl 0 action drop
0518 tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \
0519 flower $tcflags mpls_ttl 255 action drop
0520
0521 pkt="$ethtype $(mpls_lse 0 0 1 255)"
0522 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
0523
0524 tc_check_packets "dev $h2 ingress" 101 1
0525 check_fail $? "Matched on a wrong filter (255)"
0526
0527 tc_check_packets "dev $h2 ingress" 102 1
0528 check_err $? "Did not match on correct filter (255)"
0529
0530 pkt="$ethtype $(mpls_lse 0 0 1 0)"
0531 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
0532
0533 tc_check_packets "dev $h2 ingress" 102 2
0534 check_fail $? "Matched on a wrong filter (0)"
0535
0536 tc_check_packets "dev $h2 ingress" 101 1
0537 check_err $? "Did not match on correct filter (0)"
0538
0539 tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower
0540 tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower
0541
0542 log_test "mpls_ttl match ($tcflags)"
0543 }
0544
0545 match_mpls_lse_test()
0546 {
0547 local ethtype="88 47"; readonly ethtype
0548 local pkt
0549
0550 RET=0
0551
0552 check_tc_mpls_lse_stats $h2 || return 0
0553
0554
0555 tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \
0556 flower $tcflags mpls lse depth 1 label 0 action continue
0557 tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \
0558 flower $tcflags mpls lse depth 1 tc 0 action continue
0559 tc filter add dev $h2 ingress protocol mpls_uc pref 3 handle 103 \
0560 flower $tcflags mpls lse depth 1 bos 0 action continue
0561 tc filter add dev $h2 ingress protocol mpls_uc pref 4 handle 104 \
0562 flower $tcflags mpls lse depth 1 ttl 0 action continue
0563
0564
0565 tc filter add dev $h2 ingress protocol mpls_uc pref 5 handle 105 \
0566 flower $tcflags mpls lse depth 2 label 1048575 action continue
0567 tc filter add dev $h2 ingress protocol mpls_uc pref 6 handle 106 \
0568 flower $tcflags mpls lse depth 2 tc 7 action continue
0569 tc filter add dev $h2 ingress protocol mpls_uc pref 7 handle 107 \
0570 flower $tcflags mpls lse depth 2 bos 1 action continue
0571 tc filter add dev $h2 ingress protocol mpls_uc pref 8 handle 108 \
0572 flower $tcflags mpls lse depth 2 ttl 255 action continue
0573
0574
0575 tc filter add dev $h2 ingress protocol mpls_uc pref 9 handle 109 \
0576 flower $tcflags mpls lse depth 1 action continue
0577 tc filter add dev $h2 ingress protocol mpls_uc pref 10 handle 110 \
0578 flower $tcflags mpls lse depth 2 action continue
0579 tc filter add dev $h2 ingress protocol mpls_uc pref 11 handle 111 \
0580 flower $tcflags mpls lse depth 3 action continue
0581
0582
0583 pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048575 7 1 255)"
0584 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
0585
0586
0587
0588
0589
0590 pkt="$ethtype $(mpls_lse 1 0 0 0) $(mpls_lse 1048575 7 1 255)"
0591 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
0592
0593
0594 pkt="$ethtype $(mpls_lse 0 1 0 0) $(mpls_lse 1048575 7 1 255)"
0595 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
0596
0597
0598
0599 pkt="$ethtype $(mpls_lse 0 0 1 0)"
0600 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
0601
0602
0603 pkt="$ethtype $(mpls_lse 0 0 0 1) $(mpls_lse 1048575 7 1 255)"
0604 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
0605
0606
0607 pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048574 7 1 255)"
0608 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
0609
0610
0611 pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048575 6 1 255)"
0612 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
0613
0614
0615
0616 pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048575 7 0 255)"
0617 pkt="$pkt $(mpls_lse 0 0 1 255)"
0618 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
0619
0620
0621 pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048575 7 1 254)"
0622 $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
0623
0624
0625
0626 tc_check_packets "dev $h2 ingress" 101 8
0627 check_err $? "Did not match on correct filter"
0628
0629 tc_check_packets "dev $h2 ingress" 102 8
0630 check_err $? "Did not match on correct filter"
0631
0632 tc_check_packets "dev $h2 ingress" 103 8
0633 check_err $? "Did not match on correct filter"
0634
0635 tc_check_packets "dev $h2 ingress" 104 8
0636 check_err $? "Did not match on correct filter"
0637
0638
0639
0640
0641 tc_check_packets "dev $h2 ingress" 105 7
0642 check_err $? "Did not match on correct filter"
0643
0644 tc_check_packets "dev $h2 ingress" 106 7
0645 check_err $? "Did not match on correct filter"
0646
0647 tc_check_packets "dev $h2 ingress" 107 7
0648 check_err $? "Did not match on correct filter"
0649
0650 tc_check_packets "dev $h2 ingress" 108 7
0651 check_err $? "Did not match on correct filter"
0652
0653
0654
0655 tc_check_packets "dev $h2 ingress" 109 9
0656 check_err $? "Did not match on correct filter"
0657
0658 tc_check_packets "dev $h2 ingress" 110 8
0659 check_err $? "Did not match on correct filter"
0660
0661 tc_check_packets "dev $h2 ingress" 111 1
0662 check_err $? "Did not match on correct filter"
0663
0664 tc filter del dev $h2 ingress protocol mpls_uc pref 11 handle 111 flower
0665 tc filter del dev $h2 ingress protocol mpls_uc pref 10 handle 110 flower
0666 tc filter del dev $h2 ingress protocol mpls_uc pref 9 handle 109 flower
0667 tc filter del dev $h2 ingress protocol mpls_uc pref 8 handle 108 flower
0668 tc filter del dev $h2 ingress protocol mpls_uc pref 7 handle 107 flower
0669 tc filter del dev $h2 ingress protocol mpls_uc pref 6 handle 106 flower
0670 tc filter del dev $h2 ingress protocol mpls_uc pref 5 handle 105 flower
0671 tc filter del dev $h2 ingress protocol mpls_uc pref 4 handle 104 flower
0672 tc filter del dev $h2 ingress protocol mpls_uc pref 3 handle 103 flower
0673 tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower
0674 tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower
0675
0676 log_test "mpls lse match ($tcflags)"
0677 }
0678
0679 setup_prepare()
0680 {
0681 h1=${NETIFS[p1]}
0682 h2=${NETIFS[p2]}
0683 h1mac=$(mac_get $h1)
0684 h2mac=$(mac_get $h2)
0685
0686 vrf_prepare
0687
0688 h1_create
0689 h2_create
0690 }
0691
0692 cleanup()
0693 {
0694 pre_cleanup
0695
0696 h2_destroy
0697 h1_destroy
0698
0699 vrf_cleanup
0700 }
0701
0702 trap cleanup EXIT
0703
0704 setup_prepare
0705 setup_wait
0706
0707 tests_run
0708
0709 tc_offload_check
0710 if [[ $? -ne 0 ]]; then
0711 log_info "Could not test offloaded functionality"
0712 else
0713 tcflags="skip_sw"
0714 tests_run
0715 fi
0716
0717 exit $EXIT_STATUS