Skip to content

Commit

Permalink
selftest/bpf: Extend test for sockmap update with same
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mmhal authored and Kernel Patches Daemon committed Dec 6, 2024
1 parent 54d6b71 commit 263cd36
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down

0 comments on commit 263cd36

Please sign in to comment.