toops: Sync tools/include/uapi/linux/bpf.h with the kernel

The way we're using kernel headers in tools/ now, with a copy that is
made to the same path prefixed by "tools/" plus checking if that copy
got stale, i.e. if the kernel counterpart changed, helps in keeping
track with new features that may be useful for tools to exploit.

For instance, looking at all the changes to bpf.h since it was last
copied to tools/include brings this to toolers' attention:

Need to investigate this one to check how to run a program via perf, setting up
a BPF event, that will take advantage of the way perf already calls clang/LLVM,
sets up the event and runs the workload in a single command line, helping in
debugging such semi cooperative programs:

  96ae5227 ("bpf: Add bpf_probe_write_user BPF helper to be called in tracers")

This one needs further investigation about using the feature it improves
in 'perf trace' to do some tcpdumpin' mixed with syscalls, tracepoints,
probe points, callgraphs, etc:

  555c8a86 ("bpf: avoid stack copy and use skb ctx for event output")

Add tracing just packets that are related to some container to that mix:

  4a482f34 ("cgroup: bpf: Add bpf_skb_in_cgroup_proto")
  4ed8ec52 ("cgroup: bpf: Add BPF_MAP_TYPE_CGROUP_ARRAY")

Definetely needs to have example programs accessing task_struct from a bpf proggie
started from 'perf trace':

  606274c5 ("bpf: introduce bpf_get_current_task() helper")

Core networking related, XDP:

  6ce96ca3 ("bpf: add XDP_TX xdp_action for direct forwarding")
  6a773a15 ("bpf: add XDP prog type for early driver filter")
  13c5c240 ("bpf: add bpf_get_hash_recalc helper")
  d2485c42 ("bpf: add bpf_skb_change_type helper")
  6578171a ("bpf: add bpf_skb_change_proto helper")

Changes detected by the tools build system:

  $ make -C tools/perf O=/tmp/build/perf install-bin
  make: Entering directory '/home/acme/git/linux/tools/perf'
    BUILD:   Doing 'make -j4' parallel build
  Warning: tools/include/uapi/linux/bpf.h differs from kernel
    CC       /tmp/build/perf/bench/mem-memcpy-x86-64-asm.o

Cc: Adrian Hunter <>
Cc: Alexei Starovoitov <>
Cc: Brenden Blanco <>
Cc: Daniel Borkmann <>
Cc: David Ahern <>
Cc: David S. Miller <>
Cc: Jiri Olsa <>
Cc: Martin KaFai Lau <>
Cc: Namhyung Kim <>
Cc: Sargun Dhillon <>
Cc: Wang Nan <>
Link: default avatarArnaldo Carvalho de Melo <>
parent bebfb730
......@@ -84,6 +84,7 @@ enum bpf_map_type {
enum bpf_prog_type {
......@@ -93,6 +94,7 @@ enum bpf_prog_type {
......@@ -313,6 +315,66 @@ enum bpf_func_id {
* bpf_skb_change_proto(skb, proto, flags)
* Change protocol of the skb. Currently supported is
* v4 -> v6, v6 -> v4 transitions. The helper will also
* resize the skb. eBPF program is expected to fill the
* new headers via skb_store_bytes and lX_csum_replace.
* @skb: pointer to skb
* @proto: new skb->protocol type
* @flags: reserved
* Return: 0 on success or negative error
* bpf_skb_change_type(skb, type)
* Change packet type of skb.
* @skb: pointer to skb
* @type: new skb->pkt_type type
* Return: 0 on success or negative error
* bpf_skb_in_cgroup(skb, map, index) - Check cgroup2 membership of skb
* @skb: pointer to skb
* @map: pointer to bpf_map in BPF_MAP_TYPE_CGROUP_ARRAY type
* @index: index of the cgroup in the bpf_map
* Return:
* == 0 skb failed the cgroup2 descendant test
* == 1 skb succeeded the cgroup2 descendant test
* < 0 error
* bpf_get_hash_recalc(skb)
* Retrieve and possibly recalculate skb->hash.
* @skb: pointer to skb
* Return: hash
* u64 bpf_get_current_task(void)
* Returns current task_struct
* Return: current
* bpf_probe_write_user(void *dst, void *src, int len)
* safely attempt to write to a location
* @dst: destination address in userspace
* @src: source address on stack
* @len: number of bytes to copy
* Return: 0 on success or negative error
......@@ -347,9 +409,11 @@ enum bpf_func_id {
#define BPF_F_ZERO_CSUM_TX (1ULL << 1)
#define BPF_F_DONT_FRAGMENT (1ULL << 2)
/* BPF_FUNC_perf_event_output flags. */
/* BPF_FUNC_perf_event_output and BPF_FUNC_perf_event_read flags. */
#define BPF_F_INDEX_MASK 0xffffffffULL
/* BPF_FUNC_perf_event_output for sk_buff input context. */
#define BPF_F_CTXLEN_MASK (0xfffffULL << 32)
/* user accessible mirror of in-kernel sk_buff.
* new fields can only be added to the end of this structure
......@@ -386,4 +450,24 @@ struct bpf_tunnel_key {
__u32 tunnel_label;
/* User return codes for XDP prog type.
* A valid XDP program must return one of these defined values. All other
* return codes are reserved for future use. Unknown return codes will result
* in packet drop.
enum xdp_action {
/* user accessible metadata for XDP packet hook
* new fields must be added to the end of this structure
struct xdp_md {
__u32 data;
__u32 data_end;
#endif /* _UAPI__LINUX_BPF_H__ */
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