Skip to content

Commit 11d5245

Browse files
mmhalborkmann
authored andcommitted
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
1 parent ed1fc5d commit 11d5245

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tools/testing/selftests/bpf/prog_tests/sockmap_basic.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -934,8 +934,10 @@ static void test_sockmap_same_sock(void)
934934

935935
err = socketpair(AF_UNIX, SOCK_STREAM, 0, stream);
936936
ASSERT_OK(err, "socketpair(af_unix, sock_stream)");
937-
if (err)
937+
if (err) {
938+
close(tcp);
938939
goto out;
940+
}
939941

940942
for (i = 0; i < 2; i++) {
941943
err = bpf_map_update_elem(map, &zero, &stream[0], BPF_ANY);
@@ -954,14 +956,14 @@ static void test_sockmap_same_sock(void)
954956
ASSERT_OK(err, "bpf_map_update_elem(tcp)");
955957
}
956958

959+
close(tcp);
957960
err = bpf_map_delete_elem(map, &zero);
958-
ASSERT_OK(err, "bpf_map_delete_elem(entry)");
961+
ASSERT_ERR(err, "bpf_map_delete_elem(entry)");
959962

960963
close(stream[0]);
961964
close(stream[1]);
962965
out:
963966
close(dgram);
964-
close(tcp);
965967
close(udp);
966968
test_sockmap_pass_prog__destroy(skel);
967969
}

0 commit comments

Comments
 (0)