aboutsummaryrefslogtreecommitdiffstats
path: root/tools/include/uapi/linux/bpf.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/include/uapi/linux/bpf.h')
-rw-r--r--tools/include/uapi/linux/bpf.h86
1 files changed, 85 insertions, 1 deletions
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 406459b935a2..da218fec6056 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -84,6 +84,7 @@ enum bpf_map_type {
84 BPF_MAP_TYPE_PERCPU_HASH, 84 BPF_MAP_TYPE_PERCPU_HASH,
85 BPF_MAP_TYPE_PERCPU_ARRAY, 85 BPF_MAP_TYPE_PERCPU_ARRAY,
86 BPF_MAP_TYPE_STACK_TRACE, 86 BPF_MAP_TYPE_STACK_TRACE,
87 BPF_MAP_TYPE_CGROUP_ARRAY,
87}; 88};
88 89
89enum bpf_prog_type { 90enum bpf_prog_type {
@@ -93,6 +94,7 @@ enum bpf_prog_type {
93 BPF_PROG_TYPE_SCHED_CLS, 94 BPF_PROG_TYPE_SCHED_CLS,
94 BPF_PROG_TYPE_SCHED_ACT, 95 BPF_PROG_TYPE_SCHED_ACT,
95 BPF_PROG_TYPE_TRACEPOINT, 96 BPF_PROG_TYPE_TRACEPOINT,
97 BPF_PROG_TYPE_XDP,
96}; 98};
97 99
98#define BPF_PSEUDO_MAP_FD 1 100#define BPF_PSEUDO_MAP_FD 1
@@ -313,6 +315,66 @@ enum bpf_func_id {
313 */ 315 */
314 BPF_FUNC_skb_get_tunnel_opt, 316 BPF_FUNC_skb_get_tunnel_opt,
315 BPF_FUNC_skb_set_tunnel_opt, 317 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
316 __BPF_FUNC_MAX_ID, 378 __BPF_FUNC_MAX_ID,
317}; 379};
318 380
@@ -347,9 +409,11 @@ enum bpf_func_id {
347#define BPF_F_ZERO_CSUM_TX (1ULL << 1) 409#define BPF_F_ZERO_CSUM_TX (1ULL << 1)
348#define BPF_F_DONT_FRAGMENT (1ULL << 2) 410#define BPF_F_DONT_FRAGMENT (1ULL << 2)
349 411
350/* BPF_FUNC_perf_event_output flags. */ 412/* BPF_FUNC_perf_event_output and BPF_FUNC_perf_event_read flags. */
351#define BPF_F_INDEX_MASK 0xffffffffULL 413#define BPF_F_INDEX_MASK 0xffffffffULL
352#define BPF_F_CURRENT_CPU BPF_F_INDEX_MASK 414#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)
353 417
354/* user accessible mirror of in-kernel sk_buff. 418/* user accessible mirror of in-kernel sk_buff.
355 * new fields can only be added to the end of this structure 419 * new fields can only be added to the end of this structure
@@ -386,4 +450,24 @@ struct bpf_tunnel_key {
386 __u32 tunnel_label; 450 __u32 tunnel_label;
387}; 451};
388 452
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 */
458enum 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 */
468struct xdp_md {
469 __u32 data;
470 __u32 data_end;
471};
472
389#endif /* _UAPI__LINUX_BPF_H__ */ 473#endif /* _UAPI__LINUX_BPF_H__ */