[PATCH bpf-next v4 6/9] selftests/bpf: Invoke attach_reuseport out of make_server

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

 



From: Geliang Tang <tanggeliang@xxxxxxxxxx>

In order to facilitate subsequent commits to drop make_server(), this patch
invokes attach_reuseport() out of make_server(), right after invoking
make_server() if the passed "reuseport_prog" argument is not NULL.

Signed-off-by: Geliang Tang <tanggeliang@xxxxxxxxxx>
---
 .../selftests/bpf/prog_tests/sk_lookup.c      | 21 +++++++++----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/sk_lookup.c b/tools/testing/selftests/bpf/prog_tests/sk_lookup.c
index de2466547efe..d87dfcf5db07 100644
--- a/tools/testing/selftests/bpf/prog_tests/sk_lookup.c
+++ b/tools/testing/selftests/bpf/prog_tests/sk_lookup.c
@@ -204,15 +204,6 @@ static int make_server(int sotype, const char *ip, int port,
 		}
 	}
 
-	/* Late attach reuseport prog so we can have one init path */
-	if (reuseport_prog) {
-		err = attach_reuseport(fd, reuseport_prog);
-		if (CHECK(err, "attach_reuseport", "failed\n")) {
-			log_err("failed to attach reuseport prog");
-			goto fail;
-		}
-	}
-
 	return fd;
 fail:
 	close(fd);
@@ -610,7 +601,8 @@ static void run_lookup_prog(const struct test *t)
 		server_fds[i] = make_server(t->sotype, t->listen_at.ip,
 					    t->listen_at.port,
 					    t->reuseport_prog);
-		if (server_fds[i] < 0)
+		if (server_fds[i] < 0 ||
+		    attach_reuseport(server_fds[i], t->reuseport_prog))
 			goto close;
 
 		err = update_lookup_map(t->sock_map, i, server_fds[i]);
@@ -636,7 +628,8 @@ static void run_lookup_prog(const struct test *t)
 		reuse_conn_fd = make_server(t->sotype, t->listen_at.ip,
 					    t->listen_at.port,
 					    t->reuseport_prog);
-		if (reuse_conn_fd < 0)
+		if (reuse_conn_fd < 0 ||
+		    attach_reuseport(reuse_conn_fd, t->reuseport_prog))
 			goto close;
 
 		/* Connect the extra socket to itself */
@@ -878,6 +871,9 @@ static void drop_on_lookup(const struct test *t)
 	if (server_fd < 0)
 		goto detach;
 
+	if (attach_reuseport(server_fd, t->reuseport_prog))
+		goto close_srv;
+
 	client_fd = make_socket(t->sotype, t->connect_to.ip,
 				t->connect_to.port, &dst);
 	if (client_fd < 0)
@@ -992,6 +988,9 @@ static void drop_on_reuseport(const struct test *t)
 	if (server1 < 0)
 		goto detach;
 
+	if (attach_reuseport(server1, t->reuseport_prog))
+		goto close_srv1;
+
 	err = update_lookup_map(t->sock_map, SERVER_A, server1);
 	if (err)
 		goto close_srv1;
-- 
2.43.0





[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