aboutsummaryrefslogtreecommitdiffstats
path: root/samples
diff options
context:
space:
mode:
authorDaniel T. Lee <danieltimlee@gmail.com>2023-01-15 16:16:12 +0900
committerAlexei Starovoitov <ast@kernel.org>2023-01-15 13:32:45 -0800
commite8acf8f47a5d58a00fbfa0f3592bbaaff557cec3 (patch)
tree526e205b4251f0c2705cbf7d5c7204c63fabc8d0 /samples
parentc2f4f5593e6ae8014b277b46f5f9a8227f11d69c (diff)
downloadlinux-e8acf8f47a5d58a00fbfa0f3592bbaaff557cec3.tar.gz
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>
Diffstat (limited to 'samples')
-rw-r--r--samples/bpf/lwt_len_hist_kern.c5
-rw-r--r--samples/bpf/sock_flags_kern.c6
-rw-r--r--samples/bpf/test_cgrp2_tc_kern.c3
-rw-r--r--samples/bpf/test_lwt_bpf.c11
-rw-r--r--samples/bpf/test_map_in_map_kern.c7
-rw-r--r--samples/bpf/test_overhead_kprobe_kern.c4
-rw-r--r--samples/bpf/test_overhead_raw_tp_kern.c2
-rw-r--r--samples/bpf/test_overhead_tp_kern.c3
8 files changed, 12 insertions, 29 deletions
diff --git a/samples/bpf/lwt_len_hist_kern.c b/samples/bpf/lwt_len_hist_kern.c
index 44ea7b56760e2..dbab80e813fec 100644
--- a/samples/bpf/lwt_len_hist_kern.c
+++ b/samples/bpf/lwt_len_hist_kern.c
@@ -10,10 +10,7 @@
* General Public License for more details.
*/
-#include <uapi/linux/bpf.h>
-#include <uapi/linux/if_ether.h>
-#include <uapi/linux/ip.h>
-#include <uapi/linux/in.h>
+#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
struct {
diff --git a/samples/bpf/sock_flags_kern.c b/samples/bpf/sock_flags_kern.c
index 84837ed48eb38..0da749f6a9e10 100644
--- a/samples/bpf/sock_flags_kern.c
+++ b/samples/bpf/sock_flags_kern.c
@@ -1,8 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "vmlinux.h"
#include "net_shared.h"
-#include <uapi/linux/bpf.h>
-#include <linux/net.h>
-#include <uapi/linux/in.h>
-#include <uapi/linux/in6.h>
#include <bpf/bpf_helpers.h>
SEC("cgroup/sock")
diff --git a/samples/bpf/test_cgrp2_tc_kern.c b/samples/bpf/test_cgrp2_tc_kern.c
index 45a2f01d20293..c7d2291d676f6 100644
--- a/samples/bpf/test_cgrp2_tc_kern.c
+++ b/samples/bpf/test_cgrp2_tc_kern.c
@@ -5,9 +5,8 @@
* License as published by the Free Software Foundation.
*/
#define KBUILD_MODNAME "foo"
+#include "vmlinux.h"
#include "net_shared.h"
-#include <uapi/linux/ipv6.h>
-#include <uapi/linux/bpf.h>
#include <bpf/bpf_helpers.h>
/* copy of 'struct ethhdr' without __packed */
diff --git a/samples/bpf/test_lwt_bpf.c b/samples/bpf/test_lwt_bpf.c
index fc093fbc760a7..9a13dbb81847a 100644
--- a/samples/bpf/test_lwt_bpf.c
+++ b/samples/bpf/test_lwt_bpf.c
@@ -10,17 +10,8 @@
* General Public License for more details.
*/
+#include "vmlinux.h"
#include "net_shared.h"
-#include <stdint.h>
-#include <stddef.h>
-#include <linux/bpf.h>
-#include <linux/ip.h>
-#include <linux/in.h>
-#include <linux/in6.h>
-#include <linux/tcp.h>
-#include <linux/udp.h>
-#include <linux/icmpv6.h>
-#include <linux/if_ether.h>
#include <bpf/bpf_helpers.h>
#include <string.h>
diff --git a/samples/bpf/test_map_in_map_kern.c b/samples/bpf/test_map_in_map_kern.c
index 0e17f9ade5c56..1883559e59772 100644
--- a/samples/bpf/test_map_in_map_kern.c
+++ b/samples/bpf/test_map_in_map_kern.c
@@ -6,16 +6,17 @@
* License as published by the Free Software Foundation.
*/
#define KBUILD_MODNAME "foo"
-#include <linux/ptrace.h>
+#include "vmlinux.h"
#include <linux/version.h>
-#include <uapi/linux/bpf.h>
-#include <uapi/linux/in6.h>
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
#include <bpf/bpf_core_read.h>
#define MAX_NR_PORTS 65536
+#define EINVAL 22
+#define ENOENT 2
+
/* map #0 */
struct inner_a {
__uint(type, BPF_MAP_TYPE_ARRAY);
diff --git a/samples/bpf/test_overhead_kprobe_kern.c b/samples/bpf/test_overhead_kprobe_kern.c
index ba82949338c27..c3528731e0e1c 100644
--- a/samples/bpf/test_overhead_kprobe_kern.c
+++ b/samples/bpf/test_overhead_kprobe_kern.c
@@ -4,10 +4,8 @@
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*/
+#include "vmlinux.h"
#include <linux/version.h>
-#include <linux/ptrace.h>
-#include <linux/sched.h>
-#include <uapi/linux/bpf.h>
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
diff --git a/samples/bpf/test_overhead_raw_tp_kern.c b/samples/bpf/test_overhead_raw_tp_kern.c
index 3e29de0eca98d..6af39fe3f8dd0 100644
--- a/samples/bpf/test_overhead_raw_tp_kern.c
+++ b/samples/bpf/test_overhead_raw_tp_kern.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2018 Facebook */
-#include <uapi/linux/bpf.h>
+#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
SEC("raw_tracepoint/task_rename")
diff --git a/samples/bpf/test_overhead_tp_kern.c b/samples/bpf/test_overhead_tp_kern.c
index f170e9b1ea214..67cab38819698 100644
--- a/samples/bpf/test_overhead_tp_kern.c
+++ b/samples/bpf/test_overhead_tp_kern.c
@@ -4,8 +4,7 @@
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*/
-#include <linux/sched.h>
-#include <uapi/linux/bpf.h>
+#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
/* from /sys/kernel/debug/tracing/events/task/task_rename/format */