@@ -9,7 +9,7 @@ lib_dir=$(dirname $0)/../../../../net/forwarding
9
9
10
10
ALL_TESTS=" single_mask_test identical_filters_test two_masks_test \
11
11
multiple_masks_test ctcam_edge_cases_test delta_simple_test \
12
- bloom_simple_test"
12
+ bloom_simple_test bloom_complex_test "
13
13
NUM_NETIFS=2
14
14
source $lib_dir /tc_common.sh
15
15
source $lib_dir /lib.sh
@@ -459,6 +459,89 @@ bloom_simple_test()
459
459
log_test " bloom simple test ($tcflags )"
460
460
}
461
461
462
+ bloom_complex_test ()
463
+ {
464
+ # Bloom filter index computation is affected from region ID, eRP
465
+ # ID and from the region key size. In order to excercise those parts
466
+ # of the Bloom filter code, use a series of regions, each with a
467
+ # different key size and send packet that should hit all of them.
468
+ local index
469
+
470
+ RET=0
471
+ NUM_CHAINS=4
472
+ BASE_INDEX=100
473
+
474
+ # Create chain with up to 2 key blocks (ip_proto only)
475
+ tc chain add dev $h2 ingress chain 1 protocol ip flower \
476
+ ip_proto tcp & > /dev/null
477
+ # Create chain with 2-4 key blocks (ip_proto, src MAC)
478
+ tc chain add dev $h2 ingress chain 2 protocol ip flower \
479
+ ip_proto tcp \
480
+ src_mac 00:00:00:00:00:00/FF:FF:FF:FF:FF:FF & > /dev/null
481
+ # Create chain with 4-8 key blocks (ip_proto, src & dst MAC, IPv4 dest)
482
+ tc chain add dev $h2 ingress chain 3 protocol ip flower \
483
+ ip_proto tcp \
484
+ dst_mac 00:00:00:00:00:00/FF:FF:FF:FF:FF:FF \
485
+ src_mac 00:00:00:00:00:00/FF:FF:FF:FF:FF:FF \
486
+ dst_ip 0.0.0.0/32 & > /dev/null
487
+ # Default chain contains all fields and therefore is 8-12 key blocks
488
+ tc chain add dev $h2 ingress chain 4
489
+
490
+ # We need at least 2 rules in every region to have eRP table active
491
+ # so create a dummy rule per chain using a different pattern
492
+ for i in $( eval echo {0..$NUM_CHAINS }) ; do
493
+ index=$(( BASE_INDEX - 1 - i))
494
+ tc filter add dev $h2 ingress chain $i protocol ip \
495
+ pref 2 handle $index flower \
496
+ $tcflags ip_proto tcp action drop
497
+ done
498
+
499
+ # Add rules to test Bloom filter, each in a different chain
500
+ index=$BASE_INDEX
501
+ tc filter add dev $h2 ingress protocol ip \
502
+ pref 1 handle $(( ++ index)) flower \
503
+ $tcflags dst_ip 192.0.0.0/16 action goto chain 1
504
+ tc filter add dev $h2 ingress chain 1 protocol ip \
505
+ pref 1 handle $(( ++ index)) flower \
506
+ $tcflags action goto chain 2
507
+ tc filter add dev $h2 ingress chain 2 protocol ip \
508
+ pref 1 handle $(( ++ index)) flower \
509
+ $tcflags src_mac $h1mac action goto chain 3
510
+ tc filter add dev $h2 ingress chain 3 protocol ip \
511
+ pref 1 handle $(( ++ index)) flower \
512
+ $tcflags dst_ip 192.0.0.0/8 action goto chain 4
513
+ tc filter add dev $h2 ingress chain 4 protocol ip \
514
+ pref 1 handle $(( ++ index)) flower \
515
+ $tcflags src_ip 192.0.2.0/24 action drop
516
+
517
+ # Send a packet that is supposed to hit all chains
518
+ $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
519
+ -t ip -q
520
+
521
+ for i in $( eval echo {0..$NUM_CHAINS }) ; do
522
+ index=$(( BASE_INDEX + i + 1 ))
523
+ tc_check_packets " dev $h2 ingress" $index 1
524
+ check_err $? " Did not match chain $i "
525
+ done
526
+
527
+ # Rules cleanup
528
+ for i in $( eval echo {$NUM_CHAINS ..0}) ; do
529
+ index=$(( BASE_INDEX - i - 1 ))
530
+ tc filter del dev $h2 ingress chain $i \
531
+ pref 2 handle $index flower
532
+ index=$(( BASE_INDEX + i + 1 ))
533
+ tc filter del dev $h2 ingress chain $i \
534
+ pref 1 handle $index flower
535
+ done
536
+
537
+ # Chains cleanup
538
+ for i in $( eval echo {$NUM_CHAINS ..1}) ; do
539
+ tc chain del dev $h2 ingress chain $i
540
+ done
541
+
542
+ log_test " bloom complex test ($tcflags )"
543
+ }
544
+
462
545
setup_prepare ()
463
546
{
464
547
h1=${NETIFS[p1]}
0 commit comments