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 BPF test program

This commit applies vmlinux.h to BPF functionality testing program.
Macros that were not defined despite migration to "vmlinux.h" were
defined separately in individual files.

Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
Link: https://lore.kernel.org/r/20230115071613.125791-10-danieltimlee@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Daniel T. Lee and committed by
Alexei Starovoitov
e8acf8f4 c2f4f559

+12 -29
+1 -4
samples/bpf/lwt_len_hist_kern.c
··· 10 10 * General Public License for more details. 11 11 */ 12 12 13 - #include <uapi/linux/bpf.h> 14 - #include <uapi/linux/if_ether.h> 15 - #include <uapi/linux/ip.h> 16 - #include <uapi/linux/in.h> 13 + #include "vmlinux.h" 17 14 #include <bpf/bpf_helpers.h> 18 15 19 16 struct {
+2 -4
samples/bpf/sock_flags_kern.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include "vmlinux.h" 1 3 #include "net_shared.h" 2 - #include <uapi/linux/bpf.h> 3 - #include <linux/net.h> 4 - #include <uapi/linux/in.h> 5 - #include <uapi/linux/in6.h> 6 4 #include <bpf/bpf_helpers.h> 7 5 8 6 SEC("cgroup/sock")
+1 -2
samples/bpf/test_cgrp2_tc_kern.c
··· 5 5 * License as published by the Free Software Foundation. 6 6 */ 7 7 #define KBUILD_MODNAME "foo" 8 + #include "vmlinux.h" 8 9 #include "net_shared.h" 9 - #include <uapi/linux/ipv6.h> 10 - #include <uapi/linux/bpf.h> 11 10 #include <bpf/bpf_helpers.h> 12 11 13 12 /* copy of 'struct ethhdr' without __packed */
+1 -10
samples/bpf/test_lwt_bpf.c
··· 10 10 * General Public License for more details. 11 11 */ 12 12 13 + #include "vmlinux.h" 13 14 #include "net_shared.h" 14 - #include <stdint.h> 15 - #include <stddef.h> 16 - #include <linux/bpf.h> 17 - #include <linux/ip.h> 18 - #include <linux/in.h> 19 - #include <linux/in6.h> 20 - #include <linux/tcp.h> 21 - #include <linux/udp.h> 22 - #include <linux/icmpv6.h> 23 - #include <linux/if_ether.h> 24 15 #include <bpf/bpf_helpers.h> 25 16 #include <string.h> 26 17
+4 -3
samples/bpf/test_map_in_map_kern.c
··· 6 6 * License as published by the Free Software Foundation. 7 7 */ 8 8 #define KBUILD_MODNAME "foo" 9 - #include <linux/ptrace.h> 9 + #include "vmlinux.h" 10 10 #include <linux/version.h> 11 - #include <uapi/linux/bpf.h> 12 - #include <uapi/linux/in6.h> 13 11 #include <bpf/bpf_helpers.h> 14 12 #include <bpf/bpf_tracing.h> 15 13 #include <bpf/bpf_core_read.h> 16 14 17 15 #define MAX_NR_PORTS 65536 16 + 17 + #define EINVAL 22 18 + #define ENOENT 2 18 19 19 20 /* map #0 */ 20 21 struct inner_a {
+1 -3
samples/bpf/test_overhead_kprobe_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 "vmlinux.h" 7 8 #include <linux/version.h> 8 - #include <linux/ptrace.h> 9 - #include <linux/sched.h> 10 - #include <uapi/linux/bpf.h> 11 9 #include <bpf/bpf_helpers.h> 12 10 #include <bpf/bpf_tracing.h> 13 11
+1 -1
samples/bpf/test_overhead_raw_tp_kern.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* Copyright (c) 2018 Facebook */ 3 - #include <uapi/linux/bpf.h> 3 + #include "vmlinux.h" 4 4 #include <bpf/bpf_helpers.h> 5 5 6 6 SEC("raw_tracepoint/task_rename")
+1 -2
samples/bpf/test_overhead_tp_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/sched.h> 8 - #include <uapi/linux/bpf.h> 7 + #include "vmlinux.h" 9 8 #include <bpf/bpf_helpers.h> 10 9 11 10 /* from /sys/kernel/debug/tracing/events/task/task_rename/format */