Skip to content

Commit 0b0c009

Browse files
jpirkodavem330
authored andcommitted
selftests: tc_flower: Add TOS matching test
Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e49f9ad commit 0b0c009

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

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

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# SPDX-License-Identifier: GPL-2.0
33

44
ALL_TESTS="match_dst_mac_test match_src_mac_test match_dst_ip_test \
5-
match_src_ip_test match_ip_flags_test match_pcp_test match_vlan_test"
5+
match_src_ip_test match_ip_flags_test match_pcp_test match_vlan_test \
6+
match_ip_tos_test"
67
NUM_NETIFS=2
78
source tc_common.sh
89
source lib.sh
@@ -276,6 +277,39 @@ match_vlan_test()
276277
log_test "VLAN match ($tcflags)"
277278
}
278279

280+
match_ip_tos_test()
281+
{
282+
RET=0
283+
284+
tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \
285+
$tcflags dst_ip 192.0.2.2 ip_tos 0x20 action drop
286+
tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \
287+
$tcflags dst_ip 192.0.2.2 ip_tos 0x18 action drop
288+
289+
$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
290+
-t ip tos=18 -q
291+
292+
tc_check_packets "dev $h2 ingress" 101 1
293+
check_fail $? "Matched on a wrong filter (0x18)"
294+
295+
tc_check_packets "dev $h2 ingress" 102 1
296+
check_err $? "Did not match on correct filter (0x18)"
297+
298+
$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
299+
-t ip tos=20 -q
300+
301+
tc_check_packets "dev $h2 ingress" 102 2
302+
check_fail $? "Matched on a wrong filter (0x20)"
303+
304+
tc_check_packets "dev $h2 ingress" 101 1
305+
check_err $? "Did not match on correct filter (0x20)"
306+
307+
tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower
308+
tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower
309+
310+
log_test "ip_tos match ($tcflags)"
311+
}
312+
279313
setup_prepare()
280314
{
281315
h1=${NETIFS[p1]}

0 commit comments

Comments
 (0)