]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
selftests/bpf: remove bpf_util.h from BPF C progs
authorHechao Li <hechaol@fb.com>
Tue, 11 Jun 2019 00:56:51 +0000 (17:56 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 11 Jun 2019 08:36:02 +0000 (10:36 +0200)
Though currently there is no problem including bpf_util.h in kernel
space BPF C programs, in next patch in this stack, I will reuse
libbpf_num_possible_cpus() in bpf_util.h thus include libbpf.h in it,
which will cause BPF C programs compile error. Therefore I will first
remove bpf_util.h from all test BPF programs.

This can also make it clear that bpf_util.h is a user-space utility
while bpf_helpers.h is a kernel space utility.

Signed-off-by: Hechao Li <hechaol@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/testing/selftests/bpf/bpf_endian.h
tools/testing/selftests/bpf/progs/sockmap_parse_prog.c
tools/testing/selftests/bpf/progs/sockmap_tcp_msg_prog.c
tools/testing/selftests/bpf/progs/sockmap_verdict_prog.c
tools/testing/selftests/bpf/progs/test_sysctl_prog.c

index b25595ea4a78987bbdacb2cd06c8eeaed4fb0ef6..05f036df8a4c51b7c32fd72f65b9766e13ac7689 100644 (file)
@@ -2,6 +2,7 @@
 #ifndef __BPF_ENDIAN__
 #define __BPF_ENDIAN__
 
+#include <linux/stddef.h>
 #include <linux/swab.h>
 
 /* LLVM's BPF target selects the endianness of the CPU
index ed3e4a551c57bd79eba5b4b9c4a2c70a6d44313a..9390e02442595a39ddfda628b398a91b5b78eede 100644 (file)
@@ -1,6 +1,5 @@
 #include <linux/bpf.h>
 #include "bpf_helpers.h"
-#include "bpf_util.h"
 #include "bpf_endian.h"
 
 int _version SEC("version") = 1;
index 65fbfdb6cd3a1a2c5306ec9b5a0b19c5833c0afe..e80484d98a1a52acaee62d1527353ad723de25d2 100644 (file)
@@ -1,6 +1,6 @@
 #include <linux/bpf.h>
+
 #include "bpf_helpers.h"
-#include "bpf_util.h"
 #include "bpf_endian.h"
 
 int _version SEC("version") = 1;
index bdc22be46f2efb4c5813f32c753ceb2bb9061981..d85c874ef25e736273e4fd4d11fc617ea149dcd7 100644 (file)
@@ -1,6 +1,5 @@
 #include <linux/bpf.h>
 #include "bpf_helpers.h"
-#include "bpf_util.h"
 #include "bpf_endian.h"
 
 int _version SEC("version") = 1;
index a295cad805d7d4ccdc30277376737e57718fffd3..5cbbff416998c78fb889129bf90a5f7aafc53a7c 100644 (file)
@@ -8,7 +8,6 @@
 #include <linux/bpf.h>
 
 #include "bpf_helpers.h"
-#include "bpf_util.h"
 
 /* Max supported length of a string with unsigned long in base 10 (pow2 - 1). */
 #define MAX_ULONG_STR_LEN 0xF
 /* Max supported length of sysctl value string (pow2). */
 #define MAX_VALUE_STR_LEN 0x40
 
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#endif
+
 static __always_inline int is_tcp_mem(struct bpf_sysctl *ctx)
 {
        char tcp_mem_name[] = "net/ipv4/tcp_mem";