mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-27 04:22:58 +00:00
selftests/bpf: Extend test for sockmap update with same
Verify that the sockmap link was not severed, and socket's entry is indeed removed from the map when the corresponding descriptor gets closed. Signed-off-by: Michal Luczaj <mhal@rbox.co> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: John Fastabend <john.fastabend@gmail.com> Link: https://lore.kernel.org/bpf/20241202-sockmap-replace-v1-2-1e88579e7bd5@rbox.co
This commit is contained in:
committed by
Daniel Borkmann
parent
ed1fc5d76b
commit
11d5245f60
@@ -934,8 +934,10 @@ static void test_sockmap_same_sock(void)
|
||||
|
||||
err = socketpair(AF_UNIX, SOCK_STREAM, 0, stream);
|
||||
ASSERT_OK(err, "socketpair(af_unix, sock_stream)");
|
||||
if (err)
|
||||
if (err) {
|
||||
close(tcp);
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
err = bpf_map_update_elem(map, &zero, &stream[0], BPF_ANY);
|
||||
@@ -954,14 +956,14 @@ static void test_sockmap_same_sock(void)
|
||||
ASSERT_OK(err, "bpf_map_update_elem(tcp)");
|
||||
}
|
||||
|
||||
close(tcp);
|
||||
err = bpf_map_delete_elem(map, &zero);
|
||||
ASSERT_OK(err, "bpf_map_delete_elem(entry)");
|
||||
ASSERT_ERR(err, "bpf_map_delete_elem(entry)");
|
||||
|
||||
close(stream[0]);
|
||||
close(stream[1]);
|
||||
out:
|
||||
close(dgram);
|
||||
close(tcp);
|
||||
close(udp);
|
||||
test_sockmap_pass_prog__destroy(skel);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user