Skip to content

Commit e3c1917

Browse files
dcarattidavem330
authored andcommitted
selftest: tc_flower: add testcase for 'ip_flags'
Signed-off-by: Davide Caratti <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent bdb7cc6 commit e3c1917

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

tools/testing/selftests/net/forwarding/tc_flower.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,74 @@ match_src_ip_test()
149149
log_test "src_ip match ($tcflags)"
150150
}
151151

152+
match_ip_flags_test()
153+
{
154+
RET=0
155+
156+
tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \
157+
$tcflags ip_flags frag action continue
158+
tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \
159+
$tcflags ip_flags firstfrag action continue
160+
tc filter add dev $h2 ingress protocol ip pref 3 handle 103 flower \
161+
$tcflags ip_flags nofirstfrag action continue
162+
tc filter add dev $h2 ingress protocol ip pref 4 handle 104 flower \
163+
$tcflags ip_flags nofrag action drop
164+
165+
$MZ $h1 -c 1 -p 1000 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
166+
-t ip "frag=0" -q
167+
168+
tc_check_packets "dev $h2 ingress" 101 1
169+
check_fail $? "Matched on wrong frag filter (nofrag)"
170+
171+
tc_check_packets "dev $h2 ingress" 102 1
172+
check_fail $? "Matched on wrong firstfrag filter (nofrag)"
173+
174+
tc_check_packets "dev $h2 ingress" 103 1
175+
check_err $? "Did not match on nofirstfrag filter (nofrag) "
176+
177+
tc_check_packets "dev $h2 ingress" 104 1
178+
check_err $? "Did not match on nofrag filter (nofrag)"
179+
180+
$MZ $h1 -c 1 -p 1000 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
181+
-t ip "frag=0,mf" -q
182+
183+
tc_check_packets "dev $h2 ingress" 101 1
184+
check_err $? "Did not match on frag filter (1stfrag)"
185+
186+
tc_check_packets "dev $h2 ingress" 102 1
187+
check_err $? "Did not match fistfrag filter (1stfrag)"
188+
189+
tc_check_packets "dev $h2 ingress" 103 1
190+
check_err $? "Matched on wrong nofirstfrag filter (1stfrag)"
191+
192+
tc_check_packets "dev $h2 ingress" 104 1
193+
check_err $? "Match on wrong nofrag filter (1stfrag)"
194+
195+
$MZ $h1 -c 1 -p 1000 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
196+
-t ip "frag=256,mf" -q
197+
$MZ $h1 -c 1 -p 1000 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
198+
-t ip "frag=256" -q
199+
200+
tc_check_packets "dev $h2 ingress" 101 3
201+
check_err $? "Did not match on frag filter (no1stfrag)"
202+
203+
tc_check_packets "dev $h2 ingress" 102 1
204+
check_err $? "Matched on wrong firstfrag filter (no1stfrag)"
205+
206+
tc_check_packets "dev $h2 ingress" 103 3
207+
check_err $? "Did not match on nofirstfrag filter (no1stfrag)"
208+
209+
tc_check_packets "dev $h2 ingress" 104 1
210+
check_err $? "Matched on nofrag filter (no1stfrag)"
211+
212+
tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower
213+
tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower
214+
tc filter del dev $h2 ingress protocol ip pref 3 handle 103 flower
215+
tc filter del dev $h2 ingress protocol ip pref 4 handle 104 flower
216+
217+
log_test "ip_flags match ($tcflags)"
218+
}
219+
152220
setup_prepare()
153221
{
154222
h1=${NETIFS[p1]}
@@ -181,6 +249,7 @@ match_dst_mac_test
181249
match_src_mac_test
182250
match_dst_ip_test
183251
match_src_ip_test
252+
match_ip_flags_test
184253

185254
tc_offload_check
186255
if [[ $? -ne 0 ]]; then
@@ -191,6 +260,7 @@ else
191260
match_src_mac_test
192261
match_dst_ip_test
193262
match_src_ip_test
263+
match_ip_flags_test
194264
fi
195265

196266
exit $EXIT_STATUS

0 commit comments

Comments
 (0)