WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / net / forwarding / tc_flower_router.sh
blob4aee9c9e69f696b245bb68f1e60952295d95ff56
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 ALL_TESTS="match_indev_egress_test"
5 NUM_NETIFS=6
6 source tc_common.sh
7 source lib.sh
9 h1_create()
11 simple_if_init $h1 192.0.1.1/24
13 ip route add 192.0.2.0/24 vrf v$h1 nexthop via 192.0.1.2
14 ip route add 192.0.3.0/24 vrf v$h1 nexthop via 192.0.1.2
17 h1_destroy()
19 ip route del 192.0.3.0/24 vrf v$h1
20 ip route del 192.0.2.0/24 vrf v$h1
22 simple_if_fini $h1 192.0.1.1/24
25 h2_create()
27 simple_if_init $h2 192.0.2.1/24
29 ip route add 192.0.1.0/24 vrf v$h2 nexthop via 192.0.2.2
30 ip route add 192.0.3.0/24 vrf v$h2 nexthop via 192.0.2.2
33 h2_destroy()
35 ip route del 192.0.3.0/24 vrf v$h2
36 ip route del 192.0.1.0/24 vrf v$h2
38 simple_if_fini $h2 192.0.2.1/24
41 h3_create()
43 simple_if_init $h3 192.0.3.1/24
45 ip route add 192.0.1.0/24 vrf v$h3 nexthop via 192.0.3.2
46 ip route add 192.0.2.0/24 vrf v$h3 nexthop via 192.0.3.2
49 h3_destroy()
51 ip route del 192.0.2.0/24 vrf v$h3
52 ip route del 192.0.1.0/24 vrf v$h3
54 simple_if_fini $h3 192.0.3.1/24
58 router_create()
60 ip link set dev $rp1 up
61 ip link set dev $rp2 up
62 ip link set dev $rp3 up
64 tc qdisc add dev $rp3 clsact
66 ip address add 192.0.1.2/24 dev $rp1
67 ip address add 192.0.2.2/24 dev $rp2
68 ip address add 192.0.3.2/24 dev $rp3
71 router_destroy()
73 ip address del 192.0.3.2/24 dev $rp3
74 ip address del 192.0.2.2/24 dev $rp2
75 ip address del 192.0.1.2/24 dev $rp1
77 tc qdisc del dev $rp3 clsact
79 ip link set dev $rp3 down
80 ip link set dev $rp2 down
81 ip link set dev $rp1 down
84 match_indev_egress_test()
86 RET=0
88 tc filter add dev $rp3 egress protocol ip pref 1 handle 101 flower \
89 $tcflags indev $rp1 dst_ip 192.0.3.1 action drop
90 tc filter add dev $rp3 egress protocol ip pref 2 handle 102 flower \
91 $tcflags indev $rp2 dst_ip 192.0.3.1 action drop
93 $MZ $h1 -c 1 -p 64 -a $h1mac -b $rp1mac -A 192.0.1.1 -B 192.0.3.1 \
94 -t ip -q
96 tc_check_packets "dev $rp3 egress" 102 1
97 check_fail $? "Matched on a wrong filter"
99 tc_check_packets "dev $rp3 egress" 101 1
100 check_err $? "Did not match on correct filter"
102 $MZ $h2 -c 1 -p 64 -a $h2mac -b $rp2mac -A 192.0.2.1 -B 192.0.3.1 \
103 -t ip -q
105 tc_check_packets "dev $rp3 egress" 101 2
106 check_fail $? "Matched on a wrong filter"
108 tc_check_packets "dev $rp3 egress" 102 1
109 check_err $? "Did not match on correct filter"
111 tc filter del dev $rp3 egress protocol ip pref 2 handle 102 flower
112 tc filter del dev $rp3 egress protocol ip pref 1 handle 101 flower
114 log_test "indev egress match ($tcflags)"
117 setup_prepare()
119 h1=${NETIFS[p1]}
120 rp1=${NETIFS[p2]}
122 h2=${NETIFS[p3]}
123 rp2=${NETIFS[p4]}
125 h3=${NETIFS[p5]}
126 rp3=${NETIFS[p6]}
128 h1mac=$(mac_get $h1)
129 rp1mac=$(mac_get $rp1)
130 h2mac=$(mac_get $h2)
131 rp2mac=$(mac_get $rp2)
133 vrf_prepare
135 h1_create
136 h2_create
137 h3_create
139 router_create
141 forwarding_enable
144 cleanup()
146 pre_cleanup
148 forwarding_restore
150 router_destroy
152 h3_destroy
153 h2_destroy
154 h1_destroy
156 vrf_cleanup
159 trap cleanup EXIT
161 setup_prepare
162 setup_wait
164 tc_offload_check
165 if [[ $? -ne 0 ]]; then
166 log_info "Could not test offloaded functionality"
167 else
168 tcflags="skip_sw"
169 tests_run
172 exit $EXIT_STATUS