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

samples/bpf: Use vmlinux.h instead of implicit headers in syscall tracing program

This commit applies vmlinux.h to syscall tracing program. This change
allows the bpf program to refer to the internal structure as a single
"vmlinux.h" instead of including each header referenced by the bpf
program.

Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20221224071527.2292-3-danieltimlee@gmail.com

authored by

Daniel T. Lee and committed by
Andrii Nakryiko
8a4dd0bc 1d0c5f6f

+7 -14
+2 -3
samples/bpf/map_perf_test_kern.c
··· 4 4 * modify it under the terms of version 2 of the GNU General Public 5 5 * License as published by the Free Software Foundation. 6 6 */ 7 - #include <linux/skbuff.h> 8 - #include <linux/netdevice.h> 7 + #include "vmlinux.h" 8 + #include <errno.h> 9 9 #include <linux/version.h> 10 - #include <uapi/linux/bpf.h> 11 10 #include <bpf/bpf_helpers.h> 12 11 #include <bpf/bpf_tracing.h> 13 12 #include <bpf/bpf_core_read.h>
+1 -3
samples/bpf/test_current_task_under_cgroup_kern.c
··· 5 5 * License as published by the Free Software Foundation. 6 6 */ 7 7 8 - #include <linux/ptrace.h> 9 - #include <uapi/linux/bpf.h> 8 + #include "vmlinux.h" 10 9 #include <linux/version.h> 11 10 #include <bpf/bpf_helpers.h> 12 - #include <uapi/linux/utsname.h> 13 11 14 12 struct { 15 13 __uint(type, BPF_MAP_TYPE_CGROUP_ARRAY);
+2 -3
samples/bpf/test_probe_write_user_kern.c
··· 4 4 * modify it under the terms of version 2 of the GNU General Public 5 5 * License as published by the Free Software Foundation. 6 6 */ 7 - #include <linux/skbuff.h> 8 - #include <linux/netdevice.h> 9 - #include <uapi/linux/bpf.h> 7 + #include "vmlinux.h" 8 + #include <string.h> 10 9 #include <linux/version.h> 11 10 #include <bpf/bpf_helpers.h> 12 11 #include <bpf/bpf_tracing.h>
+1 -2
samples/bpf/trace_output_kern.c
··· 1 - #include <linux/ptrace.h> 1 + #include "vmlinux.h" 2 2 #include <linux/version.h> 3 - #include <uapi/linux/bpf.h> 4 3 #include <bpf/bpf_helpers.h> 5 4 6 5 struct {
+1 -3
samples/bpf/tracex2_kern.c
··· 4 4 * modify it under the terms of version 2 of the GNU General Public 5 5 * License as published by the Free Software Foundation. 6 6 */ 7 - #include <linux/skbuff.h> 8 - #include <linux/netdevice.h> 7 + #include "vmlinux.h" 9 8 #include <linux/version.h> 10 - #include <uapi/linux/bpf.h> 11 9 #include <bpf/bpf_helpers.h> 12 10 #include <bpf/bpf_tracing.h> 13 11