]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests: fib_rule_tests: Add negative connect tests
authorIdo Schimmel <idosch@nvidia.com>
Wed, 14 Aug 2024 11:10:04 +0000 (14:10 +0300)
committerJakub Kicinski <kuba@kernel.org>
Fri, 16 Aug 2024 18:04:51 +0000 (11:04 -0700)
The fib_rule{4,6}_connect tests verify that locally generated traffic
from a socket that specifies a DS Field using the IP_TOS / IPV6_TCLASS
socket options is correctly redirected using a FIB rule that matches on
the given DS Field.

Add negative tests to verify that the FIB rule is not hit when the
socket specifies a DS Field that differs from the one used by the FIB
rule.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20240814111005.955359-5-idosch@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/fib_rule_tests.sh

index 085e21ed9fc3058da8b83ce13c77f602ff465520..a3b2c833f050b95949cf9ac6ca8f7a0eedc4a3ca 100755 (executable)
@@ -325,6 +325,16 @@ fib_rule6_connect_test()
                log_test $? 0 "rule6 dsfield tcp connect (dsfield ${dsfield})"
        done
 
+       # Check that UDP and TCP connections fail when using a DS Field that
+       # does not match the previously configured FIB rule.
+       nettest -q -6 -B -t 5 -N $testns -O $peerns -U -D \
+               -Q 0x20 -l 2001:db8::1:11 -r 2001:db8::1:11
+       log_test $? 1 "rule6 dsfield udp no connect (dsfield 0x20)"
+
+       nettest -q -6 -B -t 5 -N $testns -O $peerns -Q 0x20 \
+               -l 2001:db8::1:11 -r 2001:db8::1:11
+       log_test $? 1 "rule6 dsfield tcp no connect (dsfield 0x20)"
+
        $IP -6 rule del dsfield 0x04 table $RTABLE_PEER
        cleanup_peer
 }
@@ -502,6 +512,16 @@ fib_rule4_connect_test()
                log_test $? 0 "rule4 dsfield tcp connect (dsfield ${dsfield})"
        done
 
+       # Check that UDP and TCP connections fail when using a DS Field that
+       # does not match the previously configured FIB rule.
+       nettest -q -B -t 5 -N $testns -O $peerns -D -U -Q 0x20 \
+               -l 198.51.100.11 -r 198.51.100.11
+       log_test $? 1 "rule4 dsfield udp no connect (dsfield 0x20)"
+
+       nettest -q -B -t 5 -N $testns -O $peerns -Q 0x20 \
+               -l 198.51.100.11 -r 198.51.100.11
+       log_test $? 1 "rule4 dsfield tcp no connect (dsfield 0x20)"
+
        $IP -4 rule del dsfield 0x04 table $RTABLE_PEER
        cleanup_peer
 }