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

Configure Feed

Select the types of activity you want to include in your feed.

selftests/net: packetdrill: Support single protocol test.

Currently, we cannot write IPv4 or IPv6 specific packetdrill tests
as ksft_runner.sh runs each .pkt file for both protocols.

Let's support single protocol test by checking --ip_version in the
.pkt file.

Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20250819231527.1427361-1-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Kuniyuki Iwashima and committed by
Jakub Kicinski
a5c10aa3 a6d4f258

+28 -19
+28 -19
tools/testing/selftests/net/packetdrill/ksft_runner.sh
··· 3 3 4 4 source "$(dirname $(realpath $0))/../../kselftest/ktap_helpers.sh" 5 5 6 - readonly ipv4_args=('--ip_version=ipv4 ' 7 - '--local_ip=192.168.0.1 ' 8 - '--gateway_ip=192.168.0.1 ' 9 - '--netmask_ip=255.255.0.0 ' 10 - '--remote_ip=192.0.2.1 ' 11 - '-D CMSG_LEVEL_IP=SOL_IP ' 12 - '-D CMSG_TYPE_RECVERR=IP_RECVERR ') 13 - 14 - readonly ipv6_args=('--ip_version=ipv6 ' 15 - '--mtu=1520 ' 16 - '--local_ip=fd3d:0a0b:17d6::1 ' 17 - '--gateway_ip=fd3d:0a0b:17d6:8888::1 ' 18 - '--remote_ip=fd3d:fa7b:d17d::1 ' 19 - '-D CMSG_LEVEL_IP=SOL_IPV6 ' 20 - '-D CMSG_TYPE_RECVERR=IPV6_RECVERR ') 6 + declare -A ip_args=( 7 + [ipv4]="--ip_version=ipv4 8 + --local_ip=192.168.0.1 9 + --gateway_ip=192.168.0.1 10 + --netmask_ip=255.255.0.0 11 + --remote_ip=192.0.2.1 12 + -D CMSG_LEVEL_IP=SOL_IP 13 + -D CMSG_TYPE_RECVERR=IP_RECVERR" 14 + [ipv6]="--ip_version=ipv6 15 + --mtu=1520 16 + --local_ip=fd3d:0a0b:17d6::1 17 + --gateway_ip=fd3d:0a0b:17d6:8888::1 18 + --remote_ip=fd3d:fa7b:d17d::1 19 + -D CMSG_LEVEL_IP=SOL_IPV6 20 + -D CMSG_TYPE_RECVERR=IPV6_RECVERR" 21 + ) 21 22 22 23 if [ $# -ne 1 ]; then 23 24 ktap_exit_fail_msg "usage: $0 <script>" ··· 39 38 failfunc=ktap_test_xfail 40 39 fi 41 40 41 + ip_versions=$(grep -E '^--ip_version=' $script | cut -d '=' -f 2) 42 + if [[ -z $ip_versions ]]; then 43 + ip_versions="ipv4 ipv6" 44 + elif [[ ! "$ip_versions" =~ ^ipv[46]$ ]]; then 45 + ktap_exit_fail_msg "Too many or unsupported --ip_version: $ip_versions" 46 + exit "$KSFT_FAIL" 47 + fi 48 + 42 49 ktap_print_header 43 50 ktap_set_plan 2 44 51 45 - unshare -n packetdrill ${ipv4_args[@]} ${optargs[@]} $script > /dev/null \ 46 - && ktap_test_pass "ipv4" || $failfunc "ipv4" 47 - unshare -n packetdrill ${ipv6_args[@]} ${optargs[@]} $script > /dev/null \ 48 - && ktap_test_pass "ipv6" || $failfunc "ipv6" 52 + for ip_version in $ip_versions; do 53 + unshare -n packetdrill ${ip_args[$ip_version]} ${optargs[@]} $script > /dev/null \ 54 + && ktap_test_pass $ip_version || $failfunc $ip_version 55 + done 49 56 50 57 ktap_finished