Skip to content

Commit

Permalink
selftests/bpf: remove bpf_util.h from BPF C progs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Hechao Li authored and Daniel Borkmann committed Jun 11, 2019
1 parent 6446b31 commit ebb8860
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions tools/testing/selftests/bpf/bpf_endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tools/testing/selftests/bpf/progs/sockmap_parse_prog.c
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/bpf/progs/sockmap_tcp_msg_prog.c
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 0 additions & 1 deletion tools/testing/selftests/bpf/progs/sockmap_verdict_prog.c
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
5 changes: 4 additions & 1 deletion tools/testing/selftests/bpf/progs/test_sysctl_prog.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
#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";
Expand Down

0 comments on commit ebb8860

Please sign in to comment.