Skip to content

Commit f96afa7

Browse files
qmonnetborkmann
authored andcommitted
selftests/bpf: enable (uncomment) all tests in test_libbpf.sh
libbpf is now able to load successfully test_l4lb_noinline.o and samples/bpf/tracex3_kern.o. For the test_l4lb_noinline, uncomment related tests from test_libbpf.c and remove the associated "TODO". For tracex3_kern.o, instead of loading a program from samples/bpf/ that might not have been compiled at this stage, try loading a program from BPF selftests. Since this test case is about loading a program compiled without the "-target bpf" flag, change the Makefile to compile one program accordingly (instead of passing the flag for compiling all programs). Regarding test_xdp_noinline.o: in its current shape the program fails to load because it provides no version section, but the loader needs one. The test was added to make sure that libbpf could load XDP programs even if they do not provide a version number in a dedicated section. But libbpf is already capable of doing that: in our case loading fails because the loader does not know that this is an XDP program (it does not need to, since it does not attach the program). So trying to load test_xdp_noinline.o does not bring much here: just delete this subtest. For the record, the error message obtained with tracex3_kern.o was fixed by commit e3d91b0 ("tools/libbpf: handle issues with bpf ELF objects containing .eh_frames") I have not been abled to reproduce the "libbpf: incorrect bpf_call opcode" error for test_l4lb_noinline.o, even with the version of libbpf present at the time when test_libbpf.sh and test_libbpf_open.c were created. RFC -> v1: - Compile test_xdp without the "-target bpf" flag, and try to load it instead of ../../samples/bpf/tracex3_kern.o. - Delete test_xdp_noinline.o subtest. Cc: Jesper Dangaard Brouer <brouer@redhat.com> Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com> Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com> Acked-by: Jesper Dangaard Brouer <brouer@redhat.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent f601a85 commit f96afa7

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

tools/testing/selftests/bpf/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ endif
135135
endif
136136
endif
137137

138+
# Have one program compiled without "-target bpf" to test whether libbpf loads
139+
# it successfully
140+
$(OUTPUT)/test_xdp.o: test_xdp.c
141+
$(CLANG) $(CLANG_FLAGS) \
142+
-O2 -emit-llvm -c $< -o - | \
143+
$(LLC) -march=bpf -mcpu=$(CPU) $(LLC_FLAGS) -filetype=obj -o $@
144+
ifeq ($(DWARF2BTF),y)
145+
$(BTF_PAHOLE) -J $@
146+
endif
147+
138148
$(OUTPUT)/%.o: %.c
139149
$(CLANG) $(CLANG_FLAGS) \
140150
-O2 -target bpf -emit-llvm -c $< -o - | \

tools/testing/selftests/bpf/test_libbpf.sh

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,11 @@ trap exit_handler 0 2 3 6 9
3333

3434
libbpf_open_file test_l4lb.o
3535

36-
# TODO: fix libbpf to load noinline functions
37-
# [warning] libbpf: incorrect bpf_call opcode
38-
#libbpf_open_file test_l4lb_noinline.o
36+
# Load a program with BPF-to-BPF calls
37+
libbpf_open_file test_l4lb_noinline.o
3938

40-
# TODO: fix test_xdp_meta.c to load with libbpf
41-
# [warning] libbpf: test_xdp_meta.o doesn't provide kernel version
42-
#libbpf_open_file test_xdp_meta.o
43-
44-
# TODO: fix libbpf to handle .eh_frame
45-
# [warning] libbpf: relocation failed: no section(10)
46-
#libbpf_open_file ../../../../samples/bpf/tracex3_kern.o
39+
# Load a program compiled without the "-target bpf" flag
40+
libbpf_open_file test_xdp.o
4741

4842
# Success
4943
exit 0

0 commit comments

Comments
 (0)