Commit ebb88607 authored by Hechao Li's avatar Hechao Li Committed by Daniel Borkmann

selftests/bpf: remove bpf_util.h from BPF C progs

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: default avatarHechao Li <hechaol@fb.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent 6446b315
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#ifndef __BPF_ENDIAN__ #ifndef __BPF_ENDIAN__
#define __BPF_ENDIAN__ #define __BPF_ENDIAN__
#include <linux/stddef.h>
#include <linux/swab.h> #include <linux/swab.h>
/* LLVM's BPF target selects the endianness of the CPU /* LLVM's BPF target selects the endianness of the CPU
......
#include <linux/bpf.h> #include <linux/bpf.h>
#include "bpf_helpers.h" #include "bpf_helpers.h"
#include "bpf_util.h"
#include "bpf_endian.h" #include "bpf_endian.h"
int _version SEC("version") = 1; int _version SEC("version") = 1;
......
#include <linux/bpf.h> #include <linux/bpf.h>
#include "bpf_helpers.h" #include "bpf_helpers.h"
#include "bpf_util.h"
#include "bpf_endian.h" #include "bpf_endian.h"
int _version SEC("version") = 1; int _version SEC("version") = 1;
......
#include <linux/bpf.h> #include <linux/bpf.h>
#include "bpf_helpers.h" #include "bpf_helpers.h"
#include "bpf_util.h"
#include "bpf_endian.h" #include "bpf_endian.h"
int _version SEC("version") = 1; int _version SEC("version") = 1;
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <linux/bpf.h> #include <linux/bpf.h>
#include "bpf_helpers.h" #include "bpf_helpers.h"
#include "bpf_util.h"
/* Max supported length of a string with unsigned long in base 10 (pow2 - 1). */ /* Max supported length of a string with unsigned long in base 10 (pow2 - 1). */
#define MAX_ULONG_STR_LEN 0xF #define MAX_ULONG_STR_LEN 0xF
...@@ -16,6 +15,10 @@ ...@@ -16,6 +15,10 @@
/* Max supported length of sysctl value string (pow2). */ /* Max supported length of sysctl value string (pow2). */
#define MAX_VALUE_STR_LEN 0x40 #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) static __always_inline int is_tcp_mem(struct bpf_sysctl *ctx)
{ {
char tcp_mem_name[] = "net/ipv4/tcp_mem"; char tcp_mem_name[] = "net/ipv4/tcp_mem";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment