]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
selftests: tc_flower: Add TOS matching test
authorJiri Pirko <jiri@mellanox.com>
Tue, 11 Jun 2019 07:19:44 +0000 (10:19 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 12 Jun 2019 18:08:14 +0000 (11:08 -0700)
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>
tools/testing/selftests/net/forwarding/tc_flower.sh

index 29bcfa84aec710702cc82ceb1e64c6ee098a8803..124803eea4a9d7395489f1a9eec36524009f0ecd 100755 (executable)
@@ -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]}