Skip to content

Commit a7659cc

Browse files
anakryikoAlexei Starovoitov
authored and
Alexei Starovoitov
committed
selftests/bpf: Don't use deprecated libbpf APIs
Remove all uses of bpf_program__title() and bpf_program__find_program_by_title(). Signed-off-by: Andrii Nakryiko <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent fd17e27 commit a7659cc

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

tools/testing/selftests/bpf/flow_dissector_load.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ static inline int bpf_flow_load(struct bpf_object **obj,
2323
if (ret)
2424
return ret;
2525

26-
main_prog = bpf_object__find_program_by_title(*obj, section_name);
26+
main_prog = NULL;
27+
bpf_object__for_each_program(prog, *obj) {
28+
if (strcmp(section_name, bpf_program__section_name(prog)) == 0) {
29+
main_prog = prog;
30+
break;
31+
}
32+
}
2733
if (!main_prog)
2834
return -1;
2935

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void test_reference_tracking(void)
2727
const char *title;
2828

2929
/* Ignore .text sections */
30-
title = bpf_program__title(prog, false);
30+
title = bpf_program__section_name(prog);
3131
if (strstr(title, ".text") != NULL)
3232
continue;
3333

tools/testing/selftests/bpf/test_socket_cookie.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static int run_test(int cgfd)
151151
}
152152

153153
bpf_object__for_each_program(prog, pobj) {
154-
prog_name = bpf_program__title(prog, /*needs_copy*/ false);
154+
prog_name = bpf_program__section_name(prog);
155155

156156
if (libbpf_attach_type_by_name(prog_name, &attach_type))
157157
goto err;

0 commit comments

Comments
 (0)