WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / net / forwarding / tc_shblocks.sh
blob772e00ac3230473cfedc11a60a3e1a5b026f42b5
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 ALL_TESTS="shared_block_test match_indev_test"
5 NUM_NETIFS=4
6 source tc_common.sh
7 source lib.sh
9 tcflags="skip_hw"
11 h1_create()
13 simple_if_init $h1 192.0.2.1/24
16 h1_destroy()
18 simple_if_fini $h1 192.0.2.1/24
21 h2_create()
23 simple_if_init $h2 192.0.2.1/24
26 h2_destroy()
28 simple_if_fini $h2 192.0.2.1/24
31 switch_create()
33 simple_if_init $swp1 192.0.2.2/24
34 tc qdisc add dev $swp1 ingress_block 22 egress_block 23 clsact
36 simple_if_init $swp2 192.0.2.2/24
37 tc qdisc add dev $swp2 ingress_block 22 egress_block 23 clsact
40 switch_destroy()
42 tc qdisc del dev $swp2 clsact
43 simple_if_fini $swp2 192.0.2.2/24
45 tc qdisc del dev $swp1 clsact
46 simple_if_fini $swp1 192.0.2.2/24
49 shared_block_test()
51 RET=0
53 tc filter add block 22 protocol ip pref 1 handle 101 flower \
54 $tcflags dst_ip 192.0.2.2 action drop
56 $MZ $h1 -c 1 -p 64 -a $h1mac -b $swmac -A 192.0.2.1 -B 192.0.2.2 \
57 -t ip -q
59 tc_check_packets "block 22" 101 1
60 check_err $? "Did not match first incoming packet on a block"
62 $MZ $h2 -c 1 -p 64 -a $h2mac -b $swmac -A 192.0.2.1 -B 192.0.2.2 \
63 -t ip -q
65 tc_check_packets "block 22" 101 2
66 check_err $? "Did not match second incoming packet on a block"
68 tc filter del block 22 protocol ip pref 1 handle 101 flower
70 log_test "shared block ($tcflags)"
73 match_indev_test()
75 RET=0
77 tc filter add block 22 protocol ip pref 1 handle 101 flower \
78 $tcflags indev $swp1 dst_mac $swmac action drop
79 tc filter add block 22 protocol ip pref 2 handle 102 flower \
80 $tcflags indev $swp2 dst_mac $swmac action drop
82 $MZ $h1 -c 1 -p 64 -a $h1mac -b $swmac -A 192.0.2.1 -B 192.0.2.2 \
83 -t ip -q
85 tc_check_packets "block 22" 101 1
86 check_err $? "Did not match first incoming packet on a block"
88 $MZ $h2 -c 1 -p 64 -a $h2mac -b $swmac -A 192.0.2.1 -B 192.0.2.2 \
89 -t ip -q
91 tc_check_packets "block 22" 102 1
92 check_err $? "Did not match second incoming packet on a block"
94 tc filter del block 22 protocol ip pref 1 handle 101 flower
95 tc filter del block 22 protocol ip pref 2 handle 102 flower
97 log_test "indev match ($tcflags)"
100 setup_prepare()
102 h1=${NETIFS[p1]}
103 swp1=${NETIFS[p2]}
105 swp2=${NETIFS[p3]}
106 h2=${NETIFS[p4]}
108 h1mac=$(mac_get $h1)
109 h2mac=$(mac_get $h2)
111 swmac=$(mac_get $swp1)
112 swp2origmac=$(mac_get $swp2)
113 ip link set $swp2 address $swmac
115 vrf_prepare
117 h1_create
118 h2_create
119 switch_create
122 cleanup()
124 pre_cleanup
126 switch_destroy
127 h2_destroy
128 h1_destroy
130 vrf_cleanup
132 ip link set $swp2 address $swp2origmac
135 check_tc_shblock_support
137 trap cleanup EXIT
139 setup_prepare
140 setup_wait
142 tests_run
144 tc_offload_check
145 if [[ $? -ne 0 ]]; then
146 log_info "Could not test offloaded functionality"
147 else
148 tcflags="skip_sw"
149 tests_run
152 exit $EXIT_STATUS