Skip to content

Commit

Permalink
selftests: tc_flower: Add TOS matching test
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jiri Pirko authored and David S. Miller committed Jun 12, 2019
1 parent e49f9ad commit 0b0c009
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion tools/testing/selftests/net/forwarding/tc_flower.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]}
Expand Down

0 comments on commit 0b0c009

Please sign in to comment.