Skip to content

Commit 2bf1259

Browse files
idoschkuba-moo
authored andcommitted
selftests: fib_rule_tests: Add DSCP selector connect tests
Test 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 DSCP. Add negative tests to verify that the rule is not it when it should not. Test with both IPv4 and IPv6 and with both TCP and UDP sockets. Signed-off-by: Ido Schimmel <idosch@nvidia.com> Reviewed-by: Guillaume Nault <gnault@redhat.com> Reviewed-by: David Ahern <dsahern@kernel.org> Link: https://patch.msgid.link/20240911093748.3662015-7-idosch@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent ac6ad3f commit 2bf1259

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

tools/testing/selftests/net/fib_rule_tests.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,34 @@ fib_rule6_connect_test()
336336
log_test $? 1 "rule6 dsfield tcp no connect (dsfield 0x20)"
337337

338338
$IP -6 rule del dsfield 0x04 table $RTABLE_PEER
339+
340+
ip rule help 2>&1 | grep -q dscp
341+
if [ $? -ne 0 ]; then
342+
echo "SKIP: iproute2 iprule too old, missing dscp match"
343+
cleanup_peer
344+
return
345+
fi
346+
347+
$IP -6 rule add dscp 0x3f table $RTABLE_PEER
348+
349+
nettest -q -6 -B -t 5 -N $testns -O $peerns -U -D -Q 0xfc \
350+
-l 2001:db8::1:11 -r 2001:db8::1:11
351+
log_test $? 0 "rule6 dscp udp connect"
352+
353+
nettest -q -6 -B -t 5 -N $testns -O $peerns -Q 0xfc \
354+
-l 2001:db8::1:11 -r 2001:db8::1:11
355+
log_test $? 0 "rule6 dscp tcp connect"
356+
357+
nettest -q -6 -B -t 5 -N $testns -O $peerns -U -D -Q 0xf4 \
358+
-l 2001:db8::1:11 -r 2001:db8::1:11
359+
log_test $? 1 "rule6 dscp udp no connect"
360+
361+
nettest -q -6 -B -t 5 -N $testns -O $peerns -Q 0xf4 \
362+
-l 2001:db8::1:11 -r 2001:db8::1:11
363+
log_test $? 1 "rule6 dscp tcp no connect"
364+
365+
$IP -6 rule del dscp 0x3f table $RTABLE_PEER
366+
339367
cleanup_peer
340368
}
341369

@@ -547,6 +575,34 @@ fib_rule4_connect_test()
547575
log_test $? 1 "rule4 dsfield tcp no connect (dsfield 0x20)"
548576

549577
$IP -4 rule del dsfield 0x04 table $RTABLE_PEER
578+
579+
ip rule help 2>&1 | grep -q dscp
580+
if [ $? -ne 0 ]; then
581+
echo "SKIP: iproute2 iprule too old, missing dscp match"
582+
cleanup_peer
583+
return
584+
fi
585+
586+
$IP -4 rule add dscp 0x3f table $RTABLE_PEER
587+
588+
nettest -q -B -t 5 -N $testns -O $peerns -D -U -Q 0xfc \
589+
-l 198.51.100.11 -r 198.51.100.11
590+
log_test $? 0 "rule4 dscp udp connect"
591+
592+
nettest -q -B -t 5 -N $testns -O $peerns -Q 0xfc \
593+
-l 198.51.100.11 -r 198.51.100.11
594+
log_test $? 0 "rule4 dscp tcp connect"
595+
596+
nettest -q -B -t 5 -N $testns -O $peerns -D -U -Q 0xf4 \
597+
-l 198.51.100.11 -r 198.51.100.11
598+
log_test $? 1 "rule4 dscp udp no connect"
599+
600+
nettest -q -B -t 5 -N $testns -O $peerns -Q 0xf4 \
601+
-l 198.51.100.11 -r 198.51.100.11
602+
log_test $? 1 "rule4 dscp tcp no connect"
603+
604+
$IP -4 rule del dscp 0x3f table $RTABLE_PEER
605+
550606
cleanup_peer
551607
}
552608
################################################################################

0 commit comments

Comments
 (0)