Skip to content

Commit

Permalink
Merge branch 'BPF selftests misc fixes'
Browse files Browse the repository at this point in the history
Geliang Tang says:

====================
v2:
 - only check the first "link" (link_nl) in test_mixed_links().
 - Drop patch 2 in v1.

This patchset fixes a segfault and a bpf object leak in test_progs.

It is a resend patch 1 out of "skip ENOTSUPP BPF selftests" set as Eduard
suggested. Together with another fix for xdp_adjust_tail.
====================

Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
  • Loading branch information
Martin KaFai Lau committed Jul 10, 2024
2 parents ec5b8c7 + 52b49ec commit 18a8a4c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,8 @@ static void test_update_ca(void)
return;

link = bpf_map__attach_struct_ops(skel->maps.ca_update_1);
ASSERT_OK_PTR(link, "attach_struct_ops");
if (!ASSERT_OK_PTR(link, "attach_struct_ops"))
goto out;

do_test(&opts);
saved_ca1_cnt = skel->bss->ca1_cnt;
Expand All @@ -425,6 +426,7 @@ static void test_update_ca(void)
ASSERT_GT(skel->bss->ca2_cnt, 0, "ca2_ca2_cnt");

bpf_link__destroy(link);
out:
tcp_ca_update__destroy(skel);
}

Expand All @@ -447,7 +449,8 @@ static void test_update_wrong(void)
return;

link = bpf_map__attach_struct_ops(skel->maps.ca_update_1);
ASSERT_OK_PTR(link, "attach_struct_ops");
if (!ASSERT_OK_PTR(link, "attach_struct_ops"))
goto out;

do_test(&opts);
saved_ca1_cnt = skel->bss->ca1_cnt;
Expand All @@ -460,6 +463,7 @@ static void test_update_wrong(void)
ASSERT_GT(skel->bss->ca1_cnt, saved_ca1_cnt, "ca2_ca1_cnt");

bpf_link__destroy(link);
out:
tcp_ca_update__destroy(skel);
}

Expand All @@ -481,7 +485,8 @@ static void test_mixed_links(void)
return;

link_nl = bpf_map__attach_struct_ops(skel->maps.ca_no_link);
ASSERT_OK_PTR(link_nl, "attach_struct_ops_nl");
if (!ASSERT_OK_PTR(link_nl, "attach_struct_ops_nl"))
goto out;

link = bpf_map__attach_struct_ops(skel->maps.ca_update_1);
ASSERT_OK_PTR(link, "attach_struct_ops");
Expand All @@ -494,6 +499,7 @@ static void test_mixed_links(void)

bpf_link__destroy(link);
bpf_link__destroy(link_nl);
out:
tcp_ca_update__destroy(skel);
}

Expand Down Expand Up @@ -536,7 +542,8 @@ static void test_link_replace(void)
bpf_link__destroy(link);

link = bpf_map__attach_struct_ops(skel->maps.ca_update_2);
ASSERT_OK_PTR(link, "attach_struct_ops_2nd");
if (!ASSERT_OK_PTR(link, "attach_struct_ops_2nd"))
goto out;

/* BPF_F_REPLACE with a wrong old map Fd. It should fail!
*
Expand All @@ -559,6 +566,7 @@ static void test_link_replace(void)

bpf_link__destroy(link);

out:
tcp_ca_update__destroy(skel);
}

Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ static void test_xdp_adjust_frags_tail_grow(void)

prog = bpf_object__next_program(obj, NULL);
if (bpf_object__load(obj))
return;
goto out;

prog_fd = bpf_program__fd(prog);

Expand Down

0 comments on commit 18a8a4c

Please sign in to comment.