@@ -8,6 +8,9 @@ ALL_TESTS="
88 egress_redirect_test
99 multi_mirror_test
1010 matchall_sample_egress_test
11+ matchall_mirror_behind_flower_ingress_test
12+ matchall_sample_behind_flower_ingress_test
13+ matchall_mirror_behind_flower_egress_test
1114"
1215NUM_NETIFS=2
1316
@@ -180,6 +183,110 @@ matchall_sample_egress_test()
180183 log_test " matchall sample egress"
181184}
182185
186+ matchall_behind_flower_ingress_test ()
187+ {
188+ local action=$1
189+ local action_args=$2
190+
191+ RET=0
192+
193+ # On ingress, all matchall-mirror and matchall-sample
194+ # rules have to be in front of the flower rules
195+
196+ tc qdisc add dev $swp1 clsact
197+
198+ tc filter add dev $swp1 ingress protocol ip pref 10 handle 101 flower \
199+ skip_sw dst_ip 192.0.2.2 action drop
200+
201+ tc filter add dev $swp1 ingress protocol all pref 9 handle 102 \
202+ matchall skip_sw action $action_args
203+ check_err $? " Failed to add matchall rule in front of a flower rule"
204+
205+ tc filter del dev $swp1 ingress protocol all pref 9 handle 102 matchall
206+
207+ tc filter add dev $swp1 ingress protocol all pref 11 handle 102 \
208+ matchall skip_sw action $action_args
209+ check_fail $? " Incorrect success to add matchall rule behind a flower rule"
210+
211+ tc filter del dev $swp1 ingress protocol ip pref 10 handle 101 flower
212+
213+ tc filter add dev $swp1 ingress protocol all pref 9 handle 102 \
214+ matchall skip_sw action $action_args
215+
216+ tc filter add dev $swp1 ingress protocol ip pref 10 handle 101 flower \
217+ skip_sw dst_ip 192.0.2.2 action drop
218+ check_err $? " Failed to add flower rule behind a matchall rule"
219+
220+ tc filter del dev $swp1 ingress protocol ip pref 10 handle 101 flower
221+
222+ tc filter add dev $swp1 ingress protocol ip pref 8 handle 101 flower \
223+ skip_sw dst_ip 192.0.2.2 action drop
224+ check_fail $? " Incorrect success to add flower rule in front of a matchall rule"
225+
226+ tc qdisc del dev $swp1 clsact
227+
228+ log_test " matchall $action flower ingress"
229+ }
230+
231+ matchall_mirror_behind_flower_ingress_test ()
232+ {
233+ matchall_behind_flower_ingress_test " mirror" " mirred egress mirror dev $swp2 "
234+ }
235+
236+ matchall_sample_behind_flower_ingress_test ()
237+ {
238+ matchall_behind_flower_ingress_test " sample" " sample rate 100 group 1"
239+ }
240+
241+ matchall_behind_flower_egress_test ()
242+ {
243+ local action=$1
244+ local action_args=$2
245+
246+ RET=0
247+
248+ # On egress, all matchall-mirror rules have to be behind the flower rules
249+
250+ tc qdisc add dev $swp1 clsact
251+
252+ tc filter add dev $swp1 egress protocol ip pref 10 handle 101 flower \
253+ skip_sw dst_ip 192.0.2.2 action drop
254+
255+ tc filter add dev $swp1 egress protocol all pref 11 handle 102 \
256+ matchall skip_sw action $action_args
257+ check_err $? " Failed to add matchall rule in front of a flower rule"
258+
259+ tc filter del dev $swp1 egress protocol all pref 11 handle 102 matchall
260+
261+ tc filter add dev $swp1 egress protocol all pref 9 handle 102 \
262+ matchall skip_sw action $action_args
263+ check_fail $? " Incorrect success to add matchall rule behind a flower rule"
264+
265+ tc filter del dev $swp1 egress protocol ip pref 10 handle 101 flower
266+
267+ tc filter add dev $swp1 egress protocol all pref 11 handle 102 \
268+ matchall skip_sw action $action_args
269+
270+ tc filter add dev $swp1 egress protocol ip pref 10 handle 101 flower \
271+ skip_sw dst_ip 192.0.2.2 action drop
272+ check_err $? " Failed to add flower rule behind a matchall rule"
273+
274+ tc filter del dev $swp1 egress protocol ip pref 10 handle 101 flower
275+
276+ tc filter add dev $swp1 egress protocol ip pref 12 handle 101 flower \
277+ skip_sw dst_ip 192.0.2.2 action drop
278+ check_fail $? " Incorrect success to add flower rule in front of a matchall rule"
279+
280+ tc qdisc del dev $swp1 clsact
281+
282+ log_test " matchall $action flower egress"
283+ }
284+
285+ matchall_mirror_behind_flower_egress_test ()
286+ {
287+ matchall_behind_flower_egress_test " mirror" " mirred egress mirror dev $swp2 "
288+ }
289+
183290setup_prepare ()
184291{
185292 swp1=${NETIFS[p1]}
0 commit comments