[PATCH bpf-next v2 1/7] selftests/bpf: Use start_server in sockmap_ktls

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

 



From: Geliang Tang <tanggeliang@xxxxxxxxxx>

Include network_helpers.h in prog_tests/sockmap_ktls.c, use public network
helper start_server() instead of the local defined function tcp_server().
This can avoid duplicate code.

Technically, this is not a one-for-one replacement, as start_server() also
does bind() and it's listen backlog is 1, not SOMAXCONN. But the difference
does not seem to matter.

Acked-by: Eduard Zingerman <eddyz87@xxxxxxxxx>
Signed-off-by: Geliang Tang <tanggeliang@xxxxxxxxxx>
---
 .../selftests/bpf/prog_tests/sockmap_ktls.c    | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c b/tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c
index 2d0796314862..9cc881b38669 100644
--- a/tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c
+++ b/tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c
@@ -6,25 +6,11 @@
 
 #include <netinet/tcp.h>
 #include "test_progs.h"
+#include "network_helpers.h"
 
 #define MAX_TEST_NAME 80
 #define TCP_ULP 31
 
-static int tcp_server(int family)
-{
-	int err, s;
-
-	s = socket(family, SOCK_STREAM, 0);
-	if (!ASSERT_GE(s, 0, "socket"))
-		return -1;
-
-	err = listen(s, SOMAXCONN);
-	if (!ASSERT_OK(err, "listen"))
-		return -1;
-
-	return s;
-}
-
 static int disconnect(int fd)
 {
 	struct sockaddr unspec = { AF_UNSPEC };
@@ -39,7 +25,7 @@ static void test_sockmap_ktls_disconnect_after_delete(int family, int map)
 	socklen_t len = sizeof(addr);
 	int err, cli, srv, zero = 0;
 
-	srv = tcp_server(family);
+	srv = start_server(family, SOCK_STREAM, NULL, 0, 0);
 	if (srv == -1)
 		return;
 
-- 
2.43.0





[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