[PATCH bpf-next v2 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 2a389e8c2503..227ed132b84a 100644
--- a/tools/testing/selftests/bpf/network_helpers.c
+++ b/tools/testing/selftests/bpf/network_helpers.c
@@ -194,6 +194,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 Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux