From: Daniel Xu Date: Fri, 21 Jul 2023 20:22:47 +0000 (-0600) Subject: bpf: selftests: Support not connecting client socket X-Git-Tag: v6.6.17~4098^2~233^2~12^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3495e89cdc3ab71719bd88c03dbd624c49ee70d2;p=platform%2Fkernel%2Flinux-rpi.git bpf: selftests: Support not connecting client socket For connectionless protocols or raw sockets we do not want to actually connect() to the server. Signed-off-by: Daniel Xu Link: https://lore.kernel.org/r/525c13d66dac2d640a1db922546842c051c6f2e6.1689970773.git.dxu@dxuuu.xyz Signed-off-by: Alexei Starovoitov --- diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c index 8a33bce..4dcd63a2 100644 --- a/tools/testing/selftests/bpf/network_helpers.c +++ b/tools/testing/selftests/bpf/network_helpers.c @@ -301,8 +301,9 @@ int connect_to_fd_opts(int server_fd, const struct network_helper_opts *opts) strlen(opts->cc) + 1)) goto error_close; - if (connect_fd_to_addr(fd, &addr, addrlen, opts->must_fail)) - goto error_close; + if (!opts->noconnect) + if (connect_fd_to_addr(fd, &addr, addrlen, opts->must_fail)) + goto error_close; return fd; diff --git a/tools/testing/selftests/bpf/network_helpers.h b/tools/testing/selftests/bpf/network_helpers.h index 6941856..87894dc 100644 --- a/tools/testing/selftests/bpf/network_helpers.h +++ b/tools/testing/selftests/bpf/network_helpers.h @@ -21,6 +21,7 @@ struct network_helper_opts { const char *cc; int timeout_ms; bool must_fail; + bool noconnect; }; /* ipv4 test vector */