selftests/bpf: Drop struct post_socket_opts
authorGeliang Tang <tanggeliang@kylinos.cn>
Sat, 25 May 2024 12:08:15 +0000 (20:08 +0800)
committerMartin KaFai Lau <martin.lau@kernel.org>
Wed, 29 May 2024 00:53:03 +0000 (17:53 -0700)
It's not possible to have one generic/common "struct post_socket_opts"
for all tests. It's better to have the individual test define its own
callback opts struct.

So this patch drops struct post_socket_opts, and changes the second
parameter of post_socket_cb as "void *" type.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Link: https://lore.kernel.org/r/f8bda41c7cb9cb6979b2779f89fb3a684234304f.1716638248.git.tanggeliang@kylinos.cn
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
tools/testing/selftests/bpf/network_helpers.c
tools/testing/selftests/bpf/network_helpers.h
tools/testing/selftests/bpf/prog_tests/sockopt_inherit.c
tools/testing/selftests/bpf/test_tcp_check_syncookie_user.c

index 35250e6..4d776b7 100644 (file)
@@ -133,7 +133,7 @@ int start_server(int family, int type, const char *addr_str, __u16 port,
        return __start_server(type, (struct sockaddr *)&addr, addrlen, &opts);
 }
 
-static int reuseport_cb(int fd, const struct post_socket_opts *opts)
+static int reuseport_cb(int fd, void *opts)
 {
        int on = 1;
 
index 883c7ea..40011e0 100644 (file)
@@ -21,8 +21,6 @@ typedef __u16 __sum16;
 #define VIP_NUM 5
 #define MAGIC_BYTES 123
 
-struct post_socket_opts {};
-
 struct network_helper_opts {
        const char *cc;
        int timeout_ms;
@@ -30,7 +28,7 @@ struct network_helper_opts {
        bool noconnect;
        int type;
        int proto;
-       int (*post_socket_cb)(int fd, const struct post_socket_opts *opts);
+       int (*post_socket_cb)(int fd, void *opts);
 };
 
 /* ipv4 test vector */
index 1d3a20f..7cd8be2 100644 (file)
@@ -70,7 +70,7 @@ static void *server_thread(void *arg)
        return (void *)(long)err;
 }
 
-static int custom_cb(int fd, const struct post_socket_opts *opts)
+static int custom_cb(int fd, void *opts)
 {
        char buf;
        int err;
index 7b5fc98..aebc58c 100644 (file)
@@ -139,14 +139,14 @@ out:
        return ret;
 }
 
-static int v6only_true(int fd, const struct post_socket_opts *opts)
+static int v6only_true(int fd, void *opts)
 {
        int mode = true;
 
        return setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &mode, sizeof(mode));
 }
 
-static int v6only_false(int fd, const struct post_socket_opts *opts)
+static int v6only_false(int fd, void *opts)
 {
        int mode = false;