Skip to content

Commit

Permalink
samples/bpf: Use consistent include paths for libbpf
Browse files Browse the repository at this point in the history
Fix all files in samples/bpf to include libbpf header files with the bpf/
prefix, to be consistent with external users of the library. Also ensure
that all includes of exported libbpf header files (those that are exported
on 'make install' of the library) use bracketed includes instead of quoted.

To make sure no new files are introduced that doesn't include the bpf/
prefix in its include, remove tools/lib/bpf from the include path entirely,
and use tools/lib instead.

Fixes: 6910d7d ("selftests/bpf: Ensure bpf_helper_defs.h are taken from selftests dir")
Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
Acked-by: Jesper Dangaard Brouer <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
tohojo authored and Alexei Starovoitov committed Jan 21, 2020
1 parent 521fe8b commit 7cf245a
Show file tree
Hide file tree
Showing 83 changed files with 112 additions and 113 deletions.
3 changes: 1 addition & 2 deletions samples/bpf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ TPROGS_CFLAGS += -Wmissing-prototypes
TPROGS_CFLAGS += -Wstrict-prototypes

TPROGS_CFLAGS += -I$(objtree)/usr/include
TPROGS_CFLAGS += -I$(srctree)/tools/lib/bpf/
TPROGS_CFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
TPROGS_CFLAGS += -I$(srctree)/tools/lib/
TPROGS_CFLAGS += -I$(srctree)/tools/include
Expand Down Expand Up @@ -305,7 +304,7 @@ $(obj)/%.o: $(src)/%.c
@echo " CLANG-bpf " $@
$(Q)$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(BPF_EXTRA_CFLAGS) \
-I$(obj) -I$(srctree)/tools/testing/selftests/bpf/ \
-I$(srctree)/tools/lib/bpf/ \
-I$(srctree)/tools/lib/ \
-D__KERNEL__ -D__BPF_TRACING__ -Wno-unused-value -Wno-pointer-sign \
-D__TARGET_ARCH_$(SRCARCH) -Wno-compare-distinct-pointer-types \
-Wno-gnu-variable-sized-type-not-at-end \
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/cpustat_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <linux/version.h>
#include <linux/ptrace.h>
#include <uapi/linux/bpf.h>
#include "bpf_helpers.h"
#include <bpf/bpf_helpers.h>

/*
* The CPU number, cstate number and pstate number are based
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/fds_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include <bpf/bpf.h>

#include "libbpf.h"
#include <bpf/libbpf.h>
#include "bpf_insn.h"
#include "sock_example.h"

Expand Down
4 changes: 2 additions & 2 deletions samples/bpf/hbm.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
#include "cgroup_helpers.h"
#include "hbm.h"
#include "bpf_util.h"
#include "bpf.h"
#include "libbpf.h"
#include <bpf/bpf.h>
#include <bpf/libbpf.h>

bool outFlag = true;
int minRate = 1000; /* cgroup rate limit in Mbps */
Expand Down
4 changes: 2 additions & 2 deletions samples/bpf/hbm_kern.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#include <uapi/linux/pkt_cls.h>
#include <net/ipv6.h>
#include <net/inet_ecn.h>
#include "bpf_endian.h"
#include "bpf_helpers.h"
#include <bpf/bpf_endian.h>
#include <bpf/bpf_helpers.h>
#include "hbm.h"

#define DROP_PKT 0
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/ibumad_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define KBUILD_MODNAME "ibumad_count_pkts_by_class"
#include <uapi/linux/bpf.h>

#include "bpf_helpers.h"
#include <bpf/bpf_helpers.h>


struct bpf_map_def SEC("maps") read_count = {
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/ibumad_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include "bpf_load.h"
#include "bpf_util.h"
#include "libbpf.h"
#include <bpf/libbpf.h>

static void dump_counts(int fd)
{
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/lathist_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <linux/version.h>
#include <linux/ptrace.h>
#include <uapi/linux/bpf.h>
#include "bpf_helpers.h"
#include <bpf/bpf_helpers.h>

#define MAX_ENTRIES 20
#define MAX_CPU 4
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/lwt_len_hist_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <uapi/linux/if_ether.h>
#include <uapi/linux/ip.h>
#include <uapi/linux/in.h>
#include "bpf_helpers.h"
#include <bpf/bpf_helpers.h>

# define printk(fmt, ...) \
({ \
Expand Down
4 changes: 2 additions & 2 deletions samples/bpf/map_perf_test_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#include <linux/netdevice.h>
#include <linux/version.h>
#include <uapi/linux/bpf.h>
#include "bpf_helpers.h"
#include <bpf/bpf_helpers.h>
#include "bpf_legacy.h"
#include "bpf_tracing.h"
#include <bpf/bpf_tracing.h>

#define MAX_ENTRIES 1000
#define MAX_NR_CPUS 1024
Expand Down
4 changes: 2 additions & 2 deletions samples/bpf/offwaketime_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* License as published by the Free Software Foundation.
*/
#include <uapi/linux/bpf.h>
#include "bpf_helpers.h"
#include "bpf_tracing.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
#include <uapi/linux/ptrace.h>
#include <uapi/linux/perf_event.h>
#include <linux/version.h>
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/offwaketime_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <assert.h>
#include <stdbool.h>
#include <sys/resource.h>
#include "libbpf.h"
#include <bpf/libbpf.h>
#include "bpf_load.h"
#include "trace_helpers.h"

Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/parse_ldabs.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <linux/tcp.h>
#include <linux/udp.h>
#include <uapi/linux/bpf.h>
#include "bpf_helpers.h"
#include <bpf/bpf_helpers.h>
#include "bpf_legacy.h"

#define DEFAULT_PKTGEN_UDP_PORT 9
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/parse_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <linux/udp.h>
#include <uapi/linux/bpf.h>
#include <net/ip.h>
#include "bpf_helpers.h"
#include <bpf/bpf_helpers.h>

#define DEFAULT_PKTGEN_UDP_PORT 9

Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/parse_varlen.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <linux/udp.h>
#include <uapi/linux/bpf.h>
#include <net/ip.h>
#include "bpf_helpers.h"
#include <bpf/bpf_helpers.h>

#define DEFAULT_PKTGEN_UDP_PORT 9
#define DEBUG 0
Expand Down
4 changes: 2 additions & 2 deletions samples/bpf/sampleip_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <linux/ptrace.h>
#include <uapi/linux/bpf.h>
#include <uapi/linux/bpf_perf_event.h>
#include "bpf_helpers.h"
#include "bpf_tracing.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>

#define MAX_IPS 8192

Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/sampleip_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <linux/ptrace.h>
#include <linux/bpf.h>
#include <sys/ioctl.h>
#include "libbpf.h"
#include <bpf/libbpf.h>
#include "bpf_load.h"
#include "perf-sys.h"
#include "trace_helpers.h"
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/sock_flags_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <linux/net.h>
#include <uapi/linux/in.h>
#include <uapi/linux/in6.h>
#include "bpf_helpers.h"
#include <bpf/bpf_helpers.h>

SEC("cgroup/sock1")
int bpf_prog1(struct bpf_sock *sk)
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/sockex1_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <uapi/linux/if_ether.h>
#include <uapi/linux/if_packet.h>
#include <uapi/linux/ip.h>
#include "bpf_helpers.h"
#include <bpf/bpf_helpers.h>
#include "bpf_legacy.h"

struct {
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/sockex1_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <assert.h>
#include <linux/bpf.h>
#include <bpf/bpf.h>
#include "libbpf.h"
#include <bpf/libbpf.h>
#include "sock_example.h"
#include <unistd.h>
#include <arpa/inet.h>
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/sockex2_kern.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <uapi/linux/bpf.h>
#include "bpf_helpers.h"
#include <bpf/bpf_helpers.h>
#include "bpf_legacy.h"
#include <uapi/linux/in.h>
#include <uapi/linux/if.h>
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/sockex2_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <assert.h>
#include <linux/bpf.h>
#include <bpf/bpf.h>
#include "libbpf.h"
#include <bpf/libbpf.h>
#include "sock_example.h"
#include <unistd.h>
#include <arpa/inet.h>
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/sockex3_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* License as published by the Free Software Foundation.
*/
#include <uapi/linux/bpf.h>
#include "bpf_helpers.h"
#include <bpf/bpf_helpers.h>
#include "bpf_legacy.h"
#include <uapi/linux/in.h>
#include <uapi/linux/if.h>
Expand Down
4 changes: 2 additions & 2 deletions samples/bpf/spintest_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include <linux/version.h>
#include <uapi/linux/bpf.h>
#include <uapi/linux/perf_event.h>
#include "bpf_helpers.h"
#include "bpf_tracing.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>

struct bpf_map_def SEC("maps") my_map = {
.type = BPF_MAP_TYPE_HASH,
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/spintest_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <string.h>
#include <assert.h>
#include <sys/resource.h>
#include "libbpf.h"
#include <bpf/libbpf.h>
#include "bpf_load.h"
#include "trace_helpers.h"

Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/syscall_tp_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* Copyright (c) 2017 Facebook
*/
#include <uapi/linux/bpf.h>
#include "bpf_helpers.h"
#include <bpf/bpf_helpers.h>

struct syscalls_enter_open_args {
unsigned long long unused;
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/task_fd_query_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <linux/version.h>
#include <linux/ptrace.h>
#include <uapi/linux/bpf.h>
#include "bpf_helpers.h"
#include <bpf/bpf_helpers.h>

SEC("kprobe/blk_mq_start_request")
int bpf_prog1(struct pt_regs *ctx)
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/task_fd_query_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <sys/stat.h>
#include <linux/perf_event.h>

#include "libbpf.h"
#include <bpf/libbpf.h>
#include "bpf_load.h"
#include "bpf_util.h"
#include "perf-sys.h"
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/tc_l2_redirect_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <uapi/linux/filter.h>
#include <uapi/linux/pkt_cls.h>
#include <net/ipv6.h>
#include "bpf_helpers.h"
#include <bpf/bpf_helpers.h>

#define _htonl __builtin_bswap32

Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/tcbpf1_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <uapi/linux/tcp.h>
#include <uapi/linux/filter.h>
#include <uapi/linux/pkt_cls.h>
#include "bpf_helpers.h"
#include <bpf/bpf_helpers.h>
#include "bpf_legacy.h"

/* compiler workaround */
Expand Down
4 changes: 2 additions & 2 deletions samples/bpf/tcp_basertt_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#include <uapi/linux/if_packet.h>
#include <uapi/linux/ip.h>
#include <linux/socket.h>
#include "bpf_helpers.h"
#include "bpf_endian.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h>

#define DEBUG 1

Expand Down
4 changes: 2 additions & 2 deletions samples/bpf/tcp_bufs_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include <uapi/linux/if_packet.h>
#include <uapi/linux/ip.h>
#include <linux/socket.h>
#include "bpf_helpers.h"
#include "bpf_endian.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h>

#define DEBUG 1

Expand Down
4 changes: 2 additions & 2 deletions samples/bpf/tcp_clamp_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include <uapi/linux/if_packet.h>
#include <uapi/linux/ip.h>
#include <linux/socket.h>
#include "bpf_helpers.h"
#include "bpf_endian.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h>

#define DEBUG 1

Expand Down
4 changes: 2 additions & 2 deletions samples/bpf/tcp_cong_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#include <uapi/linux/if_packet.h>
#include <uapi/linux/ip.h>
#include <linux/socket.h>
#include "bpf_helpers.h"
#include "bpf_endian.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h>

#define DEBUG 1

Expand Down
4 changes: 2 additions & 2 deletions samples/bpf/tcp_dumpstats_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/
#include <linux/bpf.h>

#include "bpf_helpers.h"
#include "bpf_endian.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h>

#define INTERVAL 1000000000ULL

Expand Down
4 changes: 2 additions & 2 deletions samples/bpf/tcp_iw_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include <uapi/linux/if_packet.h>
#include <uapi/linux/ip.h>
#include <linux/socket.h>
#include "bpf_helpers.h"
#include "bpf_endian.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h>

#define DEBUG 1

Expand Down
4 changes: 2 additions & 2 deletions samples/bpf/tcp_rwnd_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#include <uapi/linux/if_packet.h>
#include <uapi/linux/ip.h>
#include <linux/socket.h>
#include "bpf_helpers.h"
#include "bpf_endian.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h>

#define DEBUG 1

Expand Down
4 changes: 2 additions & 2 deletions samples/bpf/tcp_synrto_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#include <uapi/linux/if_packet.h>
#include <uapi/linux/ip.h>
#include <linux/socket.h>
#include "bpf_helpers.h"
#include "bpf_endian.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h>

#define DEBUG 1

Expand Down
4 changes: 2 additions & 2 deletions samples/bpf/tcp_tos_reflect_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include <uapi/linux/ipv6.h>
#include <uapi/linux/in.h>
#include <linux/socket.h>
#include "bpf_helpers.h"
#include "bpf_endian.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h>

#define DEBUG 1

Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/test_cgrp2_tc_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <uapi/linux/ipv6.h>
#include <uapi/linux/pkt_cls.h>
#include <uapi/linux/bpf.h>
#include "bpf_helpers.h"
#include <bpf/bpf_helpers.h>

/* copy of 'struct ethhdr' without __packed */
struct eth_hdr {
Expand Down
Loading

0 comments on commit 7cf245a

Please sign in to comment.