Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Consolidate kernel modules into common directory

The selftests build four kernel modules which use copy-pasted Makefile
targets. This is a bit messy, and doesn't scale so well when we add more
modules, so let's consolidate these rules into a single rule generated
for each module name, and move the module sources into a single
directory.

To avoid parallel builds of the different modules stepping on each
other's toes during the 'modpost' phase of the Kbuild 'make modules',
the module files should really be a grouped target. However, make only
added explicit support for grouped targets in version 4.3, which is
newer than the minimum version supported by the kernel. However, make
implicitly treats pattern matching rules with multiple targets as a
grouped target, so we can work around this by turning the rule into a
pattern matching target. We do this by replacing '.ko' with '%ko' in the
targets with subst().

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Viktor Malik <vmalik@redhat.com>
Link: https://lore.kernel.org/bpf/20241204-bpf-selftests-mod-compile-v5-1-b96231134a49@redhat.com

authored by

Toke Høiland-Jørgensen and committed by
Andrii Nakryiko
d6212d82 e10500b6

+83 -161
+21 -43
tools/testing/selftests/bpf/Makefile
··· 150 150 with_tunnels.sh ima_setup.sh verify_sig_setup.sh \ 151 151 test_xdp_vlan.sh test_bpftool.py 152 152 153 + TEST_KMODS := bpf_testmod.ko bpf_test_no_cfi.ko bpf_test_modorder_x.ko \ 154 + bpf_test_modorder_y.ko 155 + TEST_KMOD_TARGETS = $(addprefix $(OUTPUT)/,$(TEST_KMODS)) 156 + 153 157 # Compile but not part of 'make run_tests' 154 158 TEST_GEN_PROGS_EXTENDED = \ 155 159 bench \ 156 - bpf_testmod.ko \ 157 - bpf_test_modorder_x.ko \ 158 - bpf_test_modorder_y.ko \ 159 - bpf_test_no_cfi.ko \ 160 160 flow_dissector_load \ 161 161 runqslower \ 162 162 test_cpp \ ··· 182 182 $(Q)$(RM) -r $(TEST_GEN_PROGS) 183 183 $(Q)$(RM) -r $(TEST_GEN_PROGS_EXTENDED) 184 184 $(Q)$(RM) -r $(TEST_GEN_FILES) 185 + $(Q)$(RM) -r $(TEST_KMODS) 185 186 $(Q)$(RM) -r $(EXTRA_CLEAN) 186 - $(Q)$(MAKE) -C bpf_testmod clean 187 + $(Q)$(MAKE) -C test_kmods clean 187 188 $(Q)$(MAKE) docs-clean 188 189 endef 189 190 ··· 250 249 # to build individual tests. 251 250 # NOTE: Semicolon at the end is critical to override lib.mk's default static 252 251 # rule for binaries. 253 - $(notdir $(TEST_GEN_PROGS) \ 252 + $(notdir $(TEST_GEN_PROGS) $(TEST_KMODS) \ 254 253 $(TEST_GEN_PROGS_EXTENDED)): %: $(OUTPUT)/% ; 255 254 256 255 # sort removes libbpf duplicates when not cross-building ··· 304 303 $< -o $@ \ 305 304 $(shell $(PKG_CONFIG) --libs libcrypto 2> /dev/null || echo -lcrypto) 306 305 307 - $(OUTPUT)/bpf_testmod.ko: $(VMLINUX_BTF) $(RESOLVE_BTFIDS) $(wildcard bpf_testmod/Makefile bpf_testmod/*.[ch]) 308 - $(call msg,MOD,,$@) 309 - $(Q)$(RM) bpf_testmod/bpf_testmod.ko # force re-compilation 310 - $(Q)$(MAKE) $(submake_extras) -C bpf_testmod \ 311 - RESOLVE_BTFIDS=$(RESOLVE_BTFIDS) \ 306 + # This should really be a grouped target, but make versions before 4.3 don't 307 + # support that for regular rules. However, pattern matching rules are implicitly 308 + # treated as grouped even with older versions of make, so as a workaround, the 309 + # subst() turns the rule into a pattern matching rule 310 + $(addprefix test_kmods/,$(subst .ko,%ko,$(TEST_KMODS))): $(VMLINUX_BTF) $(RESOLVE_BTFIDS) $(wildcard test_kmods/Makefile test_kmods/*.[ch]) 311 + $(Q)$(RM) test_kmods/*.ko test_kmods/*.mod.o # force re-compilation 312 + $(Q)$(MAKE) $(submake_extras) -C test_kmods \ 313 + RESOLVE_BTFIDS=$(RESOLVE_BTFIDS) \ 312 314 EXTRA_CFLAGS='' EXTRA_LDFLAGS='' 313 - $(Q)cp bpf_testmod/bpf_testmod.ko $@ 314 315 315 - $(OUTPUT)/bpf_test_no_cfi.ko: $(VMLINUX_BTF) $(RESOLVE_BTFIDS) $(wildcard bpf_test_no_cfi/Makefile bpf_test_no_cfi/*.[ch]) 316 + $(TEST_KMOD_TARGETS): $(addprefix test_kmods/,$(TEST_KMODS)) 316 317 $(call msg,MOD,,$@) 317 - $(Q)$(RM) bpf_test_no_cfi/bpf_test_no_cfi.ko # force re-compilation 318 - $(Q)$(MAKE) $(submake_extras) -C bpf_test_no_cfi \ 319 - RESOLVE_BTFIDS=$(RESOLVE_BTFIDS) \ 320 - EXTRA_CFLAGS='' EXTRA_LDFLAGS='' 321 - $(Q)cp bpf_test_no_cfi/bpf_test_no_cfi.ko $@ 322 - 323 - $(OUTPUT)/bpf_test_modorder_x.ko: $(VMLINUX_BTF) $(RESOLVE_BTFIDS) $(wildcard bpf_test_modorder_x/Makefile bpf_test_modorder_x/*.[ch]) 324 - $(call msg,MOD,,$@) 325 - $(Q)$(RM) bpf_test_modorder_x/bpf_test_modorder_x.ko # force re-compilation 326 - $(Q)$(MAKE) $(submake_extras) -C bpf_test_modorder_x \ 327 - RESOLVE_BTFIDS=$(RESOLVE_BTFIDS) \ 328 - EXTRA_CFLAGS='' EXTRA_LDFLAGS='' 329 - $(Q)cp bpf_test_modorder_x/bpf_test_modorder_x.ko $@ 330 - 331 - $(OUTPUT)/bpf_test_modorder_y.ko: $(VMLINUX_BTF) $(RESOLVE_BTFIDS) $(wildcard bpf_test_modorder_y/Makefile bpf_test_modorder_y/*.[ch]) 332 - $(call msg,MOD,,$@) 333 - $(Q)$(RM) bpf_test_modorder_y/bpf_test_modorder_y.ko # force re-compilation 334 - $(Q)$(MAKE) $(submake_extras) -C bpf_test_modorder_y \ 335 - RESOLVE_BTFIDS=$(RESOLVE_BTFIDS) \ 336 - EXTRA_CFLAGS='' EXTRA_LDFLAGS='' 337 - $(Q)cp bpf_test_modorder_y/bpf_test_modorder_y.ko $@ 318 + $(Q)cp test_kmods/$(@F) $@ 338 319 339 320 340 321 DEFAULT_BPFTOOL := $(HOST_SCRATCH_DIR)/sbin/bpftool ··· 741 758 json_writer.c \ 742 759 flow_dissector_load.h \ 743 760 ip_check_defrag_frags.h 744 - TRUNNER_EXTRA_FILES := $(OUTPUT)/urandom_read $(OUTPUT)/bpf_testmod.ko \ 745 - $(OUTPUT)/bpf_test_no_cfi.ko \ 746 - $(OUTPUT)/bpf_test_modorder_x.ko \ 747 - $(OUTPUT)/bpf_test_modorder_y.ko \ 761 + TRUNNER_EXTRA_FILES := $(OUTPUT)/urandom_read \ 748 762 $(OUTPUT)/liburandom_read.so \ 749 763 $(OUTPUT)/xdp_synproxy \ 750 764 $(OUTPUT)/sign-file \ 751 765 $(OUTPUT)/uprobe_multi \ 766 + $(TEST_KMOD_TARGETS) \ 752 767 ima_setup.sh \ 753 768 verify_sig_setup.sh \ 754 769 $(wildcard progs/btf_dump_test_case_*.c) \ ··· 873 892 874 893 EXTRA_CLEAN := $(SCRATCH_DIR) $(HOST_SCRATCH_DIR) \ 875 894 prog_tests/tests.h map_tests/tests.h verifier/tests.h \ 876 - feature bpftool \ 895 + feature bpftool $(TEST_KMOD_TARGETS) \ 877 896 $(addprefix $(OUTPUT)/,*.o *.d *.skel.h *.lskel.h *.subskel.h \ 878 - no_alu32 cpuv4 bpf_gcc bpf_testmod.ko \ 879 - bpf_test_no_cfi.ko \ 880 - bpf_test_modorder_x.ko \ 881 - bpf_test_modorder_y.ko \ 897 + no_alu32 cpuv4 bpf_gcc \ 882 898 liburandom_read.so) \ 883 899 $(OUTPUT)/FEATURE-DUMP.selftests 884 900
-19
tools/testing/selftests/bpf/bpf_test_modorder_x/Makefile
··· 1 - BPF_TESTMOD_DIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) 2 - KDIR ?= $(abspath $(BPF_TESTMOD_DIR)/../../../../..) 3 - 4 - ifeq ($(V),1) 5 - Q = 6 - else 7 - Q = @ 8 - endif 9 - 10 - MODULES = bpf_test_modorder_x.ko 11 - 12 - obj-m += bpf_test_modorder_x.o 13 - 14 - all: 15 - +$(Q)make -C $(KDIR) M=$(BPF_TESTMOD_DIR) modules 16 - 17 - clean: 18 - +$(Q)make -C $(KDIR) M=$(BPF_TESTMOD_DIR) clean 19 -
tools/testing/selftests/bpf/bpf_test_modorder_x/bpf_test_modorder_x.c tools/testing/selftests/bpf/test_kmods/bpf_test_modorder_x.c
-19
tools/testing/selftests/bpf/bpf_test_modorder_y/Makefile
··· 1 - BPF_TESTMOD_DIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) 2 - KDIR ?= $(abspath $(BPF_TESTMOD_DIR)/../../../../..) 3 - 4 - ifeq ($(V),1) 5 - Q = 6 - else 7 - Q = @ 8 - endif 9 - 10 - MODULES = bpf_test_modorder_y.ko 11 - 12 - obj-m += bpf_test_modorder_y.o 13 - 14 - all: 15 - +$(Q)make -C $(KDIR) M=$(BPF_TESTMOD_DIR) modules 16 - 17 - clean: 18 - +$(Q)make -C $(KDIR) M=$(BPF_TESTMOD_DIR) clean 19 -
tools/testing/selftests/bpf/bpf_test_modorder_y/bpf_test_modorder_y.c tools/testing/selftests/bpf/test_kmods/bpf_test_modorder_y.c
-19
tools/testing/selftests/bpf/bpf_test_no_cfi/Makefile
··· 1 - BPF_TEST_NO_CFI_DIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) 2 - KDIR ?= $(abspath $(BPF_TEST_NO_CFI_DIR)/../../../../..) 3 - 4 - ifeq ($(V),1) 5 - Q = 6 - else 7 - Q = @ 8 - endif 9 - 10 - MODULES = bpf_test_no_cfi.ko 11 - 12 - obj-m += bpf_test_no_cfi.o 13 - 14 - all: 15 - +$(Q)make -C $(KDIR) M=$(BPF_TEST_NO_CFI_DIR) modules 16 - 17 - clean: 18 - +$(Q)make -C $(KDIR) M=$(BPF_TEST_NO_CFI_DIR) clean 19 -
tools/testing/selftests/bpf/bpf_test_no_cfi/bpf_test_no_cfi.c tools/testing/selftests/bpf/test_kmods/bpf_test_no_cfi.c
tools/testing/selftests/bpf/bpf_testmod/.gitignore tools/testing/selftests/bpf/test_kmods/.gitignore
-20
tools/testing/selftests/bpf/bpf_testmod/Makefile
··· 1 - BPF_TESTMOD_DIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) 2 - KDIR ?= $(abspath $(BPF_TESTMOD_DIR)/../../../../..) 3 - 4 - ifeq ($(V),1) 5 - Q = 6 - else 7 - Q = @ 8 - endif 9 - 10 - MODULES = bpf_testmod.ko 11 - 12 - obj-m += bpf_testmod.o 13 - CFLAGS_bpf_testmod.o = -I$(src) 14 - 15 - all: 16 - +$(Q)make -C $(KDIR) M=$(BPF_TESTMOD_DIR) modules 17 - 18 - clean: 19 - +$(Q)make -C $(KDIR) M=$(BPF_TESTMOD_DIR) clean 20 -
tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h tools/testing/selftests/bpf/test_kmods/bpf_testmod-events.h
tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.h tools/testing/selftests/bpf/test_kmods/bpf_testmod.h
tools/testing/selftests/bpf/bpf_testmod/bpf_testmod_kfunc.h tools/testing/selftests/bpf/test_kmods/bpf_testmod_kfunc.h
+1 -1
tools/testing/selftests/bpf/prog_tests/core_reloc.c
··· 2 2 #define _GNU_SOURCE 3 3 #include <test_progs.h> 4 4 #include "progs/core_reloc_types.h" 5 - #include "bpf_testmod/bpf_testmod.h" 5 + #include "test_kmods/bpf_testmod.h" 6 6 #include <linux/limits.h> 7 7 #include <sys/mman.h> 8 8 #include <sys/syscall.h>
+1 -1
tools/testing/selftests/bpf/progs/bad_struct_ops.c
··· 3 3 #include <vmlinux.h> 4 4 #include <bpf/bpf_helpers.h> 5 5 #include <bpf/bpf_tracing.h> 6 - #include "../bpf_testmod/bpf_testmod.h" 6 + #include "../test_kmods/bpf_testmod.h" 7 7 8 8 char _license[] SEC("license") = "GPL"; 9 9
+1 -1
tools/testing/selftests/bpf/progs/cb_refs.c
··· 2 2 #include <vmlinux.h> 3 3 #include <bpf/bpf_tracing.h> 4 4 #include <bpf/bpf_helpers.h> 5 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 5 + #include "../test_kmods/bpf_testmod_kfunc.h" 6 6 7 7 struct map_value { 8 8 struct prog_test_ref_kfunc __kptr *ptr;
+2 -2
tools/testing/selftests/bpf/progs/epilogue_exit.c
··· 4 4 #include <vmlinux.h> 5 5 #include <bpf/bpf_tracing.h> 6 6 #include "bpf_misc.h" 7 - #include "../bpf_testmod/bpf_testmod.h" 8 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 7 + #include "../test_kmods/bpf_testmod.h" 8 + #include "../test_kmods/bpf_testmod_kfunc.h" 9 9 10 10 char _license[] SEC("license") = "GPL"; 11 11
+2 -2
tools/testing/selftests/bpf/progs/epilogue_tailcall.c
··· 4 4 #include <vmlinux.h> 5 5 #include <bpf/bpf_tracing.h> 6 6 #include "bpf_misc.h" 7 - #include "../bpf_testmod/bpf_testmod.h" 8 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 7 + #include "../test_kmods/bpf_testmod.h" 8 + #include "../test_kmods/bpf_testmod_kfunc.h" 9 9 10 10 char _license[] SEC("license") = "GPL"; 11 11
+1 -1
tools/testing/selftests/bpf/progs/iters_testmod.c
··· 4 4 #include "bpf_experimental.h" 5 5 #include <bpf/bpf_helpers.h> 6 6 #include "bpf_misc.h" 7 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 7 + #include "../test_kmods/bpf_testmod_kfunc.h" 8 8 9 9 char _license[] SEC("license") = "GPL"; 10 10
+1 -1
tools/testing/selftests/bpf/progs/jit_probe_mem.c
··· 3 3 #include <vmlinux.h> 4 4 #include <bpf/bpf_tracing.h> 5 5 #include <bpf/bpf_helpers.h> 6 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 6 + #include "../test_kmods/bpf_testmod_kfunc.h" 7 7 8 8 static struct prog_test_ref_kfunc __kptr *v; 9 9 long total_sum = -1;
+1 -1
tools/testing/selftests/bpf/progs/kfunc_call_destructive.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include <vmlinux.h> 3 3 #include <bpf/bpf_helpers.h> 4 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 4 + #include "../test_kmods/bpf_testmod_kfunc.h" 5 5 6 6 SEC("tc") 7 7 int kfunc_destructive_test(void)
+1 -1
tools/testing/selftests/bpf/progs/kfunc_call_fail.c
··· 2 2 /* Copyright (c) 2021 Facebook */ 3 3 #include <vmlinux.h> 4 4 #include <bpf/bpf_helpers.h> 5 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 5 + #include "../test_kmods/bpf_testmod_kfunc.h" 6 6 7 7 struct syscall_test_args { 8 8 __u8 data[16];
+1 -1
tools/testing/selftests/bpf/progs/kfunc_call_race.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include <vmlinux.h> 3 3 #include <bpf/bpf_helpers.h> 4 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 4 + #include "../test_kmods/bpf_testmod_kfunc.h" 5 5 6 6 SEC("tc") 7 7 int kfunc_call_fail(struct __sk_buff *ctx)
+1 -1
tools/testing/selftests/bpf/progs/kfunc_call_test.c
··· 2 2 /* Copyright (c) 2021 Facebook */ 3 3 #include <vmlinux.h> 4 4 #include <bpf/bpf_helpers.h> 5 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 5 + #include "../test_kmods/bpf_testmod_kfunc.h" 6 6 7 7 SEC("tc") 8 8 int kfunc_call_test4(struct __sk_buff *skb)
+1 -1
tools/testing/selftests/bpf/progs/kfunc_call_test_subprog.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* Copyright (c) 2021 Facebook */ 3 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 3 + #include "../test_kmods/bpf_testmod_kfunc.h" 4 4 5 5 extern const int bpf_prog_active __ksym; 6 6 int active_res = -1;
+1 -1
tools/testing/selftests/bpf/progs/local_kptr_stash.c
··· 6 6 #include <bpf/bpf_helpers.h> 7 7 #include <bpf/bpf_core_read.h> 8 8 #include "../bpf_experimental.h" 9 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 9 + #include "../test_kmods/bpf_testmod_kfunc.h" 10 10 11 11 struct plain_local; 12 12
+1 -1
tools/testing/selftests/bpf/progs/map_kptr.c
··· 2 2 #include <vmlinux.h> 3 3 #include <bpf/bpf_tracing.h> 4 4 #include <bpf/bpf_helpers.h> 5 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 5 + #include "../test_kmods/bpf_testmod_kfunc.h" 6 6 7 7 struct map_value { 8 8 struct prog_test_ref_kfunc __kptr_untrusted *unref_ptr;
+1 -1
tools/testing/selftests/bpf/progs/map_kptr_fail.c
··· 4 4 #include <bpf/bpf_helpers.h> 5 5 #include <bpf/bpf_core_read.h> 6 6 #include "bpf_misc.h" 7 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 7 + #include "../test_kmods/bpf_testmod_kfunc.h" 8 8 9 9 struct map_value { 10 10 char buf[8];
+1 -1
tools/testing/selftests/bpf/progs/missed_kprobe.c
··· 2 2 #include "vmlinux.h" 3 3 #include <bpf/bpf_helpers.h> 4 4 #include <bpf/bpf_tracing.h> 5 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 5 + #include "../test_kmods/bpf_testmod_kfunc.h" 6 6 7 7 char _license[] SEC("license") = "GPL"; 8 8
+1 -1
tools/testing/selftests/bpf/progs/missed_kprobe_recursion.c
··· 2 2 #include "vmlinux.h" 3 3 #include <bpf/bpf_helpers.h> 4 4 #include <bpf/bpf_tracing.h> 5 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 5 + #include "../test_kmods/bpf_testmod_kfunc.h" 6 6 7 7 char _license[] SEC("license") = "GPL"; 8 8
+1 -1
tools/testing/selftests/bpf/progs/nested_acquire.c
··· 4 4 #include <bpf/bpf_tracing.h> 5 5 #include <bpf/bpf_helpers.h> 6 6 #include "bpf_misc.h" 7 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 7 + #include "../test_kmods/bpf_testmod_kfunc.h" 8 8 9 9 char _license[] SEC("license") = "GPL"; 10 10
+2 -2
tools/testing/selftests/bpf/progs/pro_epilogue.c
··· 4 4 #include <vmlinux.h> 5 5 #include <bpf/bpf_tracing.h> 6 6 #include "bpf_misc.h" 7 - #include "../bpf_testmod/bpf_testmod.h" 8 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 7 + #include "../test_kmods/bpf_testmod.h" 8 + #include "../test_kmods/bpf_testmod_kfunc.h" 9 9 10 10 char _license[] SEC("license") = "GPL"; 11 11
+2 -2
tools/testing/selftests/bpf/progs/pro_epilogue_goto_start.c
··· 4 4 #include <vmlinux.h> 5 5 #include <bpf/bpf_tracing.h> 6 6 #include "bpf_misc.h" 7 - #include "../bpf_testmod/bpf_testmod.h" 8 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 7 + #include "../test_kmods/bpf_testmod.h" 8 + #include "../test_kmods/bpf_testmod_kfunc.h" 9 9 10 10 char _license[] SEC("license") = "GPL"; 11 11
+1 -1
tools/testing/selftests/bpf/progs/sock_addr_kern.c
··· 2 2 /* Copyright (c) 2024 Google LLC */ 3 3 #include <vmlinux.h> 4 4 #include <bpf/bpf_helpers.h> 5 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 5 + #include "../test_kmods/bpf_testmod_kfunc.h" 6 6 7 7 SEC("syscall") 8 8 int init_sock(struct init_sock_args *args)
+1 -1
tools/testing/selftests/bpf/progs/struct_ops_detach.c
··· 2 2 /* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */ 3 3 #include <vmlinux.h> 4 4 #include <bpf/bpf_helpers.h> 5 - #include "../bpf_testmod/bpf_testmod.h" 5 + #include "../test_kmods/bpf_testmod.h" 6 6 7 7 char _license[] SEC("license") = "GPL"; 8 8
+1 -1
tools/testing/selftests/bpf/progs/struct_ops_forgotten_cb.c
··· 2 2 /* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */ 3 3 #include <vmlinux.h> 4 4 #include <bpf/bpf_tracing.h> 5 - #include "../bpf_testmod/bpf_testmod.h" 5 + #include "../test_kmods/bpf_testmod.h" 6 6 7 7 char _license[] SEC("license") = "GPL"; 8 8
+1 -1
tools/testing/selftests/bpf/progs/struct_ops_maybe_null.c
··· 2 2 /* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */ 3 3 #include <vmlinux.h> 4 4 #include <bpf/bpf_tracing.h> 5 - #include "../bpf_testmod/bpf_testmod.h" 5 + #include "../test_kmods/bpf_testmod.h" 6 6 7 7 char _license[] SEC("license") = "GPL"; 8 8
+1 -1
tools/testing/selftests/bpf/progs/struct_ops_maybe_null_fail.c
··· 2 2 /* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */ 3 3 #include <vmlinux.h> 4 4 #include <bpf/bpf_tracing.h> 5 - #include "../bpf_testmod/bpf_testmod.h" 5 + #include "../test_kmods/bpf_testmod.h" 6 6 7 7 char _license[] SEC("license") = "GPL"; 8 8
+1 -1
tools/testing/selftests/bpf/progs/struct_ops_module.c
··· 3 3 #include <vmlinux.h> 4 4 #include <bpf/bpf_helpers.h> 5 5 #include <bpf/bpf_tracing.h> 6 - #include "../bpf_testmod/bpf_testmod.h" 6 + #include "../test_kmods/bpf_testmod.h" 7 7 8 8 char _license[] SEC("license") = "GPL"; 9 9
+1 -1
tools/testing/selftests/bpf/progs/struct_ops_multi_pages.c
··· 3 3 #include <vmlinux.h> 4 4 #include <bpf/bpf_helpers.h> 5 5 #include <bpf/bpf_tracing.h> 6 - #include "../bpf_testmod/bpf_testmod.h" 6 + #include "../test_kmods/bpf_testmod.h" 7 7 8 8 char _license[] SEC("license") = "GPL"; 9 9
+1 -1
tools/testing/selftests/bpf/progs/struct_ops_nulled_out_cb.c
··· 2 2 /* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */ 3 3 #include <vmlinux.h> 4 4 #include <bpf/bpf_tracing.h> 5 - #include "../bpf_testmod/bpf_testmod.h" 5 + #include "../test_kmods/bpf_testmod.h" 6 6 7 7 char _license[] SEC("license") = "GPL"; 8 8
+1 -1
tools/testing/selftests/bpf/progs/struct_ops_private_stack.c
··· 3 3 #include <vmlinux.h> 4 4 #include <bpf/bpf_helpers.h> 5 5 #include <bpf/bpf_tracing.h> 6 - #include "../bpf_testmod/bpf_testmod.h" 6 + #include "../test_kmods/bpf_testmod.h" 7 7 8 8 char _license[] SEC("license") = "GPL"; 9 9
+1 -1
tools/testing/selftests/bpf/progs/struct_ops_private_stack_fail.c
··· 3 3 #include <vmlinux.h> 4 4 #include <bpf/bpf_helpers.h> 5 5 #include <bpf/bpf_tracing.h> 6 - #include "../bpf_testmod/bpf_testmod.h" 6 + #include "../test_kmods/bpf_testmod.h" 7 7 8 8 char _license[] SEC("license") = "GPL"; 9 9
+1 -1
tools/testing/selftests/bpf/progs/struct_ops_private_stack_recur.c
··· 3 3 #include <vmlinux.h> 4 4 #include <bpf/bpf_helpers.h> 5 5 #include <bpf/bpf_tracing.h> 6 - #include "../bpf_testmod/bpf_testmod.h" 6 + #include "../test_kmods/bpf_testmod.h" 7 7 8 8 char _license[] SEC("license") = "GPL"; 9 9
+1 -1
tools/testing/selftests/bpf/progs/test_kfunc_param_nullable.c
··· 4 4 #include <bpf/bpf_helpers.h> 5 5 #include "bpf_misc.h" 6 6 #include "bpf_kfuncs.h" 7 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 7 + #include "../test_kmods/bpf_testmod_kfunc.h" 8 8 9 9 SEC("tc") 10 10 int kfunc_dynptr_nullable_test1(struct __sk_buff *skb)
+1 -1
tools/testing/selftests/bpf/progs/test_module_attach.c
··· 5 5 #include <bpf/bpf_helpers.h> 6 6 #include <bpf/bpf_tracing.h> 7 7 #include <bpf/bpf_core_read.h> 8 - #include "../bpf_testmod/bpf_testmod.h" 8 + #include "../test_kmods/bpf_testmod.h" 9 9 10 10 __u32 raw_tp_read_sz = 0; 11 11
+1 -1
tools/testing/selftests/bpf/progs/test_tp_btf_nullable.c
··· 3 3 #include "vmlinux.h" 4 4 #include <bpf/bpf_helpers.h> 5 5 #include <bpf/bpf_tracing.h> 6 - #include "../bpf_testmod/bpf_testmod.h" 6 + #include "../test_kmods/bpf_testmod.h" 7 7 #include "bpf_misc.h" 8 8 9 9 SEC("tp_btf/bpf_testmod_test_nullable_bare")
+1 -1
tools/testing/selftests/bpf/progs/unsupported_ops.c
··· 4 4 #include <vmlinux.h> 5 5 #include <bpf/bpf_tracing.h> 6 6 #include "bpf_misc.h" 7 - #include "../bpf_testmod/bpf_testmod.h" 7 + #include "../test_kmods/bpf_testmod.h" 8 8 9 9 char _license[] SEC("license") = "GPL"; 10 10
+1 -1
tools/testing/selftests/bpf/progs/wq.c
··· 5 5 #include "bpf_experimental.h" 6 6 #include <bpf/bpf_helpers.h> 7 7 #include "bpf_misc.h" 8 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 8 + #include "../test_kmods/bpf_testmod_kfunc.h" 9 9 10 10 char _license[] SEC("license") = "GPL"; 11 11
+1 -1
tools/testing/selftests/bpf/progs/wq_failures.c
··· 5 5 #include "bpf_experimental.h" 6 6 #include <bpf/bpf_helpers.h> 7 7 #include "bpf_misc.h" 8 - #include "../bpf_testmod/bpf_testmod_kfunc.h" 8 + #include "../test_kmods/bpf_testmod_kfunc.h" 9 9 10 10 char _license[] SEC("license") = "GPL"; 11 11
+21
tools/testing/selftests/bpf/test_kmods/Makefile
··· 1 + TEST_KMOD_DIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) 2 + KDIR ?= $(abspath $(TEST_KMOD_DIR)/../../../../..) 3 + 4 + ifeq ($(V),1) 5 + Q = 6 + else 7 + Q = @ 8 + endif 9 + 10 + MODULES = bpf_testmod.ko bpf_test_no_cfi.ko bpf_test_modorder_x.ko \ 11 + bpf_test_modorder_y.ko 12 + 13 + $(foreach m,$(MODULES),$(eval obj-m += $(m:.ko=.o))) 14 + 15 + CFLAGS_bpf_testmod.o = -I$(src) 16 + 17 + all: 18 + $(Q)$(MAKE) -C $(KDIR) M=$(TEST_KMOD_DIR) modules 19 + 20 + clean: 21 + $(Q)$(MAKE) -C $(KDIR) M=$(TEST_KMOD_DIR) clean