History

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: 96ae52279594 ("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: 555c8a8623a3 ("bpf: avoid stack copy and use skb ctx for event output") Add tracing just packets that are related to some container to that mix: 4a482f34afcc ("cgroup: bpf: Add bpf_skb_in_cgroup_proto") 4ed8ec521ed5 ("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': 606274c5abd8 ("bpf: introduce bpf_get_current_task() helper") Core networking related, XDP: 6ce96ca348a9 ("bpf: add XDP_TX xdp_action for direct forwarding") 6a773a15a1e8 ("bpf: add XDP prog type for early driver filter") 13c5c240f789 ("bpf: add bpf_get_hash_recalc helper") d2485c4242a8 ("bpf: add bpf_skb_change_type helper") 6578171a7ff0 ("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 INSTALL GTK UI CC /tmp/build/perf/bench/mem-memcpy-x86-64-asm.o <SNIP> $

Arnaldo Carvalho de Melo committed 10 years ago

Commit 791cceb1 parent bebfb731 file · +85 −1Browse files

Showing the changes to tools/include/uapi/linux (1 of 1 file). Show all

Unified · Split

tools/include/uapi/linux/bpf.h+85−1
@@ -84,6 +84,7 @@ enum bpf_map_type { · 83 unmodified lines
8484 BPF_MAP_TYPE_PERCPU_HASH,
8585 BPF_MAP_TYPE_PERCPU_ARRAY,
8686 BPF_MAP_TYPE_STACK_TRACE,
87+ BPF_MAP_TYPE_CGROUP_ARRAY,
8788 };
8889
8990 enum bpf_prog_type {
@@ -93,6 +94,7 @@ enum bpf_prog_type { · 3 unmodified lines
9394 BPF_PROG_TYPE_SCHED_CLS,
9495 BPF_PROG_TYPE_SCHED_ACT,
9596 BPF_PROG_TYPE_TRACEPOINT,
97+ BPF_PROG_TYPE_XDP,
9698 };
9799
98100 #define BPF_PSEUDO_MAP_FD 1
@@ -313,6 +315,66 @@ enum bpf_func_id { · 214 unmodified lines
313315 */
314316 BPF_FUNC_skb_get_tunnel_opt,
315317 BPF_FUNC_skb_set_tunnel_opt,
318+
319+ /**
320+ * bpf_skb_change_proto(skb, proto, flags)
321+ * Change protocol of the skb. Currently supported is
322+ * v4 -> v6, v6 -> v4 transitions. The helper will also
323+ * resize the skb. eBPF program is expected to fill the
324+ * new headers via skb_store_bytes and lX_csum_replace.
325+ * @skb: pointer to skb
326+ * @proto: new skb->protocol type
327+ * @flags: reserved
328+ * Return: 0 on success or negative error
329+ */
330+ BPF_FUNC_skb_change_proto,
331+
332+ /**
333+ * bpf_skb_change_type(skb, type)
334+ * Change packet type of skb.
335+ * @skb: pointer to skb
336+ * @type: new skb->pkt_type type
337+ * Return: 0 on success or negative error
338+ */
339+ BPF_FUNC_skb_change_type,
340+
341+ /**
342+ * bpf_skb_in_cgroup(skb, map, index) - Check cgroup2 membership of skb
343+ * @skb: pointer to skb
344+ * @map: pointer to bpf_map in BPF_MAP_TYPE_CGROUP_ARRAY type
345+ * @index: index of the cgroup in the bpf_map
346+ * Return:
347+ * == 0 skb failed the cgroup2 descendant test
348+ * == 1 skb succeeded the cgroup2 descendant test
349+ * < 0 error
350+ */
351+ BPF_FUNC_skb_in_cgroup,
352+
353+ /**
354+ * bpf_get_hash_recalc(skb)
355+ * Retrieve and possibly recalculate skb->hash.
356+ * @skb: pointer to skb
357+ * Return: hash
358+ */
359+ BPF_FUNC_get_hash_recalc,
360+
361+ /**
362+ * u64 bpf_get_current_task(void)
363+ * Returns current task_struct
364+ * Return: current
365+ */
366+ BPF_FUNC_get_current_task,
367+
368+ /**
369+ * bpf_probe_write_user(void *dst, void *src, int len)
370+ * safely attempt to write to a location
371+ * @dst: destination address in userspace
372+ * @src: source address on stack
373+ * @len: number of bytes to copy
374+ * Return: 0 on success or negative error
375+ */
376+ BPF_FUNC_probe_write_user,
377+
316378 __BPF_FUNC_MAX_ID,
317379 };
318380
@@ -347,9 +409,11 @@ enum bpf_func_id { · 28 unmodified lines
347409 #define BPF_F_ZERO_CSUM_TX (1ULL << 1)
348410 #define BPF_F_DONT_FRAGMENT (1ULL << 2)
349411
350−/* BPF_FUNC_perf_event_output flags. */
412+/* BPF_FUNC_perf_event_output and BPF_FUNC_perf_event_read flags. */
351413 #define BPF_F_INDEX_MASK 0xffffffffULL
352414 #define BPF_F_CURRENT_CPU BPF_F_INDEX_MASK
415+/* BPF_FUNC_perf_event_output for sk_buff input context. */
416+#define BPF_F_CTXLEN_MASK (0xfffffULL << 32)
353417
354418 /* user accessible mirror of in-kernel sk_buff.
355419 * new fields can only be added to the end of this structure
@@ -386,4 +450,24 @@ struct bpf_tunnel_key { · 30 unmodified lines
386450 __u32 tunnel_label;
387451 };
388452
453+/* User return codes for XDP prog type.
454+ * A valid XDP program must return one of these defined values. All other
455+ * return codes are reserved for future use. Unknown return codes will result
456+ * in packet drop.
457+ */
458+enum xdp_action {
459+ XDP_ABORTED = 0,
460+ XDP_DROP,
461+ XDP_PASS,
462+ XDP_TX,
463+};
464+
465+/* user accessible metadata for XDP packet hook
466+ * new fields must be added to the end of this structure
467+ */
468+struct xdp_md {
469+ __u32 data;
470+ __u32 data_end;
471+};
472+
389473 #endif /* _UAPI__LINUX_BPF_H__ */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t