mirror of
https://github.com/torvalds/linux.git
synced 2026-03-13 22:36:17 +01:00
selftests/bpf: Add cookies check for tracing fill_link_info test
Adding tests for getting cookie with fill_link_info for tracing. Signed-off-by: Tao Chen <chen.dylane@linux.dev> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20250606165818.3394397-2-chen.dylane@linux.dev
This commit is contained in:
parent
c7beb48344
commit
d77efc0ef5
1 changed files with 23 additions and 1 deletions
|
|
@ -489,10 +489,28 @@ cleanup:
|
|||
bpf_link__destroy(link);
|
||||
}
|
||||
|
||||
static int verify_tracing_link_info(int fd, u64 cookie)
|
||||
{
|
||||
struct bpf_link_info info;
|
||||
int err;
|
||||
u32 len = sizeof(info);
|
||||
|
||||
err = bpf_link_get_info_by_fd(fd, &info, &len);
|
||||
if (!ASSERT_OK(err, "get_link_info"))
|
||||
return -1;
|
||||
|
||||
if (!ASSERT_EQ(info.type, BPF_LINK_TYPE_TRACING, "link_type"))
|
||||
return -1;
|
||||
|
||||
ASSERT_EQ(info.tracing.cookie, cookie, "tracing_cookie");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void tracing_subtest(struct test_bpf_cookie *skel)
|
||||
{
|
||||
__u64 cookie;
|
||||
int prog_fd;
|
||||
int prog_fd, err;
|
||||
int fentry_fd = -1, fexit_fd = -1, fmod_ret_fd = -1;
|
||||
LIBBPF_OPTS(bpf_test_run_opts, opts);
|
||||
LIBBPF_OPTS(bpf_link_create_opts, link_opts);
|
||||
|
|
@ -507,6 +525,10 @@ static void tracing_subtest(struct test_bpf_cookie *skel)
|
|||
if (!ASSERT_GE(fentry_fd, 0, "fentry.link_create"))
|
||||
goto cleanup;
|
||||
|
||||
err = verify_tracing_link_info(fentry_fd, cookie);
|
||||
if (!ASSERT_OK(err, "verify_tracing_link_info"))
|
||||
goto cleanup;
|
||||
|
||||
cookie = 0x20000000000000L;
|
||||
prog_fd = bpf_program__fd(skel->progs.fexit_test1);
|
||||
link_opts.tracing.cookie = cookie;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue