[PATCH bpf-next 10/14] selftests/bpf: Add start_server_setsockopt helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Geliang Tang <tanggeliang@xxxxxxxxxx>

This patch adds a new helper start_server_setsockopt(), which is a wrapper
of __start_server(), and accepts a function pointer setsockopt as a
parameter.

Signed-off-by: Geliang Tang <tanggeliang@xxxxxxxxxx>
---
 tools/testing/selftests/bpf/network_helpers.c | 6 ++++++
 tools/testing/selftests/bpf/network_helpers.h | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c
index ff210f0ad3ce..42e19268cd24 100644
--- a/tools/testing/selftests/bpf/network_helpers.c
+++ b/tools/testing/selftests/bpf/network_helpers.c
@@ -195,6 +195,12 @@ int start_server_addr(const struct sockaddr *addr, socklen_t addrlen, int type)
 	return __start_server(type, 0, addr, addrlen, 0, NULL, 0);
 }
 
+int start_server_setsockopt(const struct sockaddr *addr, socklen_t addrlen, int type,
+			    int *(*setsockopt)(int fd, int val), int val)
+{
+	return __start_server(type, 0, addr, addrlen, 0, setsockopt, val);
+}
+
 void free_fds(int *fds, unsigned int nr_close_fds)
 {
 	if (fds) {
diff --git a/tools/testing/selftests/bpf/network_helpers.h b/tools/testing/selftests/bpf/network_helpers.h
index 738b1764f562..543295230062 100644
--- a/tools/testing/selftests/bpf/network_helpers.h
+++ b/tools/testing/selftests/bpf/network_helpers.h
@@ -55,6 +55,8 @@ int *start_reuseport_server(int family, int type, const char *addr_str,
 			    __u16 port, int timeout_ms,
 			    unsigned int nr_listens);
 int start_server_addr(const struct sockaddr *addr, socklen_t addrlen, int type);
+int start_server_setsockopt(const struct sockaddr *addr, socklen_t addrlen, int type,
+			    int *(*setsockopt)(int fd, int val), int val);
 void free_fds(int *fds, unsigned int nr_close_fds);
 int connect_to_addr(const struct sockaddr_storage *addr, socklen_t len, int type);
 int connect_to_fd(int server_fd, int timeout_ms);
-- 
2.40.1





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux