Skip to content

Commit d77efc0

Browse files
Tao Chenanakryiko
authored andcommitted
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 <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent c7beb48 commit d77efc0

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,10 +489,28 @@ static void pe_subtest(struct test_bpf_cookie *skel)
489489
bpf_link__destroy(link);
490490
}
491491

492+
static int verify_tracing_link_info(int fd, u64 cookie)
493+
{
494+
struct bpf_link_info info;
495+
int err;
496+
u32 len = sizeof(info);
497+
498+
err = bpf_link_get_info_by_fd(fd, &info, &len);
499+
if (!ASSERT_OK(err, "get_link_info"))
500+
return -1;
501+
502+
if (!ASSERT_EQ(info.type, BPF_LINK_TYPE_TRACING, "link_type"))
503+
return -1;
504+
505+
ASSERT_EQ(info.tracing.cookie, cookie, "tracing_cookie");
506+
507+
return 0;
508+
}
509+
492510
static void tracing_subtest(struct test_bpf_cookie *skel)
493511
{
494512
__u64 cookie;
495-
int prog_fd;
513+
int prog_fd, err;
496514
int fentry_fd = -1, fexit_fd = -1, fmod_ret_fd = -1;
497515
LIBBPF_OPTS(bpf_test_run_opts, opts);
498516
LIBBPF_OPTS(bpf_link_create_opts, link_opts);
@@ -507,6 +525,10 @@ static void tracing_subtest(struct test_bpf_cookie *skel)
507525
if (!ASSERT_GE(fentry_fd, 0, "fentry.link_create"))
508526
goto cleanup;
509527

528+
err = verify_tracing_link_info(fentry_fd, cookie);
529+
if (!ASSERT_OK(err, "verify_tracing_link_info"))
530+
goto cleanup;
531+
510532
cookie = 0x20000000000000L;
511533
prog_fd = bpf_program__fd(skel->progs.fexit_test1);
512534
link_opts.tracing.cookie = cookie;

0 commit comments

Comments
 (0)