diff mbox series

[bpf-next,v11,3/9] selftests/bpf: Close fd in error path in drop_on_reuseport

Message ID 86aed33b4b0ea3f04497c757845cff7e8e621a2d.1720515893.git.tanggeliang@kylinos.cn (mailing list archive)
State Accepted
Commit adae187ebedcd95d02f045bc37dfecfd5b29434b
Headers show
Series use network helpers, part 8 | expand

Commit Message

Geliang Tang July 9, 2024, 9:16 a.m. UTC
From: Geliang Tang <tanggeliang@kylinos.cn>

In the error path when update_lookup_map() fails in drop_on_reuseport in
prog_tests/sk_lookup.c, "server1", the fd of server 1, should be closed.
This patch fixes this by using "goto close_srv1" lable instead of "detach"
to close "server1" in this case.

Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 tools/testing/selftests/bpf/prog_tests/sk_lookup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Martin KaFai Lau July 10, 2024, 7:02 p.m. UTC | #1
On 7/9/24 2:16 AM, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> In the error path when update_lookup_map() fails in drop_on_reuseport in
> prog_tests/sk_lookup.c, "server1", the fd of server 1, should be closed.
> This patch fixes this by using "goto close_srv1" lable instead of "detach"
> to close "server1" in this case.
> 

A reference to the Fixes tag will be useful

Fixes: 0ab5539f8584 ("selftests/bpf: Tests for BPF_SK_LOOKUP attach point")
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/prog_tests/sk_lookup.c b/tools/testing/selftests/bpf/prog_tests/sk_lookup.c
index 597d0467a926..de2466547efe 100644
--- a/tools/testing/selftests/bpf/prog_tests/sk_lookup.c
+++ b/tools/testing/selftests/bpf/prog_tests/sk_lookup.c
@@ -994,7 +994,7 @@  static void drop_on_reuseport(const struct test *t)
 
 	err = update_lookup_map(t->sock_map, SERVER_A, server1);
 	if (err)
-		goto detach;
+		goto close_srv1;
 
 	/* second server on destination address we should never reach */
 	server2 = make_server(t->sotype, t->connect_to.ip, t->connect_to.port,