selftests: tc_flower: Add TOS matching test

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jiri Pirko 2019-06-11 10:19:44 +03:00 committed by David S. Miller
parent e49f9adffb
commit 0b0c009834

View File

@ -2,7 +2,8 @@
# SPDX-License-Identifier: GPL-2.0
ALL_TESTS="match_dst_mac_test match_src_mac_test match_dst_ip_test \
match_src_ip_test match_ip_flags_test match_pcp_test match_vlan_test"
match_src_ip_test match_ip_flags_test match_pcp_test match_vlan_test \
match_ip_tos_test"
NUM_NETIFS=2
source tc_common.sh
source lib.sh
@ -276,6 +277,39 @@ match_vlan_test()
log_test "VLAN match ($tcflags)"
}
match_ip_tos_test()
{
RET=0
tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \
$tcflags dst_ip 192.0.2.2 ip_tos 0x20 action drop
tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \
$tcflags dst_ip 192.0.2.2 ip_tos 0x18 action drop
$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
-t ip tos=18 -q
tc_check_packets "dev $h2 ingress" 101 1
check_fail $? "Matched on a wrong filter (0x18)"
tc_check_packets "dev $h2 ingress" 102 1
check_err $? "Did not match on correct filter (0x18)"
$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
-t ip tos=20 -q
tc_check_packets "dev $h2 ingress" 102 2
check_fail $? "Matched on a wrong filter (0x20)"
tc_check_packets "dev $h2 ingress" 101 1
check_err $? "Did not match on correct filter (0x20)"
tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower
tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower
log_test "ip_tos match ($tcflags)"
}
setup_prepare()
{
h1=${NETIFS[p1]}