Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Ido Schimmel and committed by
Jakub Kicinski
2bf1259a ac6ad3f3

+56
+56
tools/testing/selftests/net/fib_rule_tests.sh
··· 336 336 log_test $? 1 "rule6 dsfield tcp no connect (dsfield 0x20)" 337 337 338 338 $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 + 339 367 cleanup_peer 340 368 } 341 369 ··· 575 547 log_test $? 1 "rule4 dsfield tcp no connect (dsfield 0x20)" 576 548 577 549 $IP -4 rule del dsfield 0x04 table $RTABLE_PEER 550 + 551 + ip rule help 2>&1 | grep -q dscp 552 + if [ $? -ne 0 ]; then 553 + echo "SKIP: iproute2 iprule too old, missing dscp match" 554 + cleanup_peer 555 + return 556 + fi 557 + 558 + $IP -4 rule add dscp 0x3f table $RTABLE_PEER 559 + 560 + nettest -q -B -t 5 -N $testns -O $peerns -D -U -Q 0xfc \ 561 + -l 198.51.100.11 -r 198.51.100.11 562 + log_test $? 0 "rule4 dscp udp connect" 563 + 564 + nettest -q -B -t 5 -N $testns -O $peerns -Q 0xfc \ 565 + -l 198.51.100.11 -r 198.51.100.11 566 + log_test $? 0 "rule4 dscp tcp connect" 567 + 568 + nettest -q -B -t 5 -N $testns -O $peerns -D -U -Q 0xf4 \ 569 + -l 198.51.100.11 -r 198.51.100.11 570 + log_test $? 1 "rule4 dscp udp no connect" 571 + 572 + nettest -q -B -t 5 -N $testns -O $peerns -Q 0xf4 \ 573 + -l 198.51.100.11 -r 198.51.100.11 574 + log_test $? 1 "rule4 dscp tcp no connect" 575 + 576 + $IP -4 rule del dscp 0x3f table $RTABLE_PEER 577 + 578 578 cleanup_peer 579 579 } 580 580 ################################################################################