diff mbox series

[bpf-next,01/14] selftests/bpf: Add start_server_addr helper

Message ID 6f45dd890878de4eeb4d6b3a657f51e4eb60aff2.1712733999.git.tanggeliang@kylinos.cn (mailing list archive)
State New
Headers show
Series use start_server and connect_to helpers | expand

Commit Message

Geliang Tang April 10, 2024, 7:29 a.m. UTC
From: Geliang Tang <tanggeliang@kylinos.cn>

In order to pair up with connect_to addr(), this patch adds a new helper
start_server_addr(), which is a wrapper of __start_server(), and accepts an
argument 'addr' of 'struct sockaddr' type instead of a string type argument
like start_server().

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 tools/testing/selftests/bpf/network_helpers.c | 5 +++++
 tools/testing/selftests/bpf/network_helpers.h | 1 +
 2 files changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c
index ca16ef2b648e..7ddeb6698ec7 100644
--- a/tools/testing/selftests/bpf/network_helpers.c
+++ b/tools/testing/selftests/bpf/network_helpers.c
@@ -185,6 +185,11 @@  int *start_reuseport_server(int family, int type, const char *addr_str,
 	return NULL;
 }
 
+int start_server_addr(const struct sockaddr *addr, socklen_t addrlen, int type)
+{
+	return __start_server(type, 0, addr, addrlen, 0, 0);
+}
+
 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 70f4e4c92733..89f59b65ce76 100644
--- a/tools/testing/selftests/bpf/network_helpers.h
+++ b/tools/testing/selftests/bpf/network_helpers.h
@@ -53,6 +53,7 @@  int start_mptcp_server(int family, const char *addr, __u16 port,
 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);
 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);