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.

Merge branch 'selftests-net-improve-error-handling-in-passive-tfo-test'

Yohei Kojima says:

====================
selftests: net: improve error handling in passive TFO test

This series improves error handling in the passive TFO test by (1)
fixing a broken behavior when the child processes failed (or timed out),
and (2) adding more error handlng code in the test program.

The first patch fixes the behavior that the test didn't report failure
even if the server or the client process exited with non-zero status.
The second patch adds error handling code in the test program to improve
reliability of the test.
====================

Link: https://patch.msgid.link/cover.1768312014.git.yk@y-koj.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+21 -5
+9 -4
tools/testing/selftests/net/tfo.c
··· 82 82 error(1, errno, "getsockopt(SO_INCOMING_NAPI_ID)"); 83 83 84 84 if (read(connfd, buf, 64) < 0) 85 - perror("read()"); 86 - fprintf(outfile, "%d\n", opt); 85 + error(1, errno, "read()"); 86 + 87 + if (fprintf(outfile, "%d\n", opt) < 0) 88 + error(1, errno, "fprintf()"); 87 89 88 90 fclose(outfile); 89 91 close(connfd); ··· 94 92 95 93 static void run_client(void) 96 94 { 97 - int fd; 95 + int fd, ret; 98 96 char *msg = "Hello, world!"; 99 97 100 98 fd = socket(AF_INET6, SOCK_STREAM, 0); 101 99 if (fd == -1) 102 100 error(1, errno, "socket()"); 103 101 104 - sendto(fd, msg, strlen(msg), MSG_FASTOPEN, (struct sockaddr *)&cfg_addr, sizeof(cfg_addr)); 102 + ret = sendto(fd, msg, strlen(msg), MSG_FASTOPEN, 103 + (struct sockaddr *)&cfg_addr, sizeof(cfg_addr)); 104 + if (ret < 0) 105 + error(1, errno, "sendto()"); 105 106 106 107 close(fd); 107 108 }
+12 -1
tools/testing/selftests/net/tfo_passive.sh
··· 85 85 -s \ 86 86 -p ${SERVER_PORT} \ 87 87 -o ${out_file}& 88 + server_pid="$!" 88 89 89 90 wait_local_port_listen nssv ${SERVER_PORT} tcp 90 91 91 92 ip netns exec nscl ./tfo -c -h ${SERVER_IP} -p ${SERVER_PORT} 93 + client_exit_status="$?" 92 94 93 - wait 95 + wait "$server_pid" 96 + server_exit_status="$?" 94 97 95 98 res=$(cat $out_file) 96 99 rm $out_file 97 100 98 101 if [ "$res" = "0" ]; then 99 102 echo "got invalid NAPI ID from passive TFO socket" 103 + cleanup_ns 104 + exit 1 105 + fi 106 + 107 + if [ "$client_exit_status" -ne 0 ] || [ "$server_exit_status" -ne 0 ]; then 108 + # Note: timeout(1) exits with 124 if it timed out 109 + echo "client exited with ${client_exit_status}" 110 + echo "server exited with ${server_exit_status}" 100 111 cleanup_ns 101 112 exit 1 102 113 fi