blob: b1a6a92f56e0baf1c9bb3d9541bd78bf083b5e1c [file] [log] [blame]
Christopher Ferris82d75042015-01-26 10:57:07 -08001/****************************************************************************
2 ****************************************************************************
3 ***
4 *** This header was automatically generated from a Linux kernel header
5 *** of the same name, to make information necessary for userspace to
6 *** call into the kernel available to libc. It contains only constants,
7 *** structures, and macros generated from the original header, and thus,
8 *** contains no copyrightable information.
9 ***
10 *** To edit the content of this header, modify the corresponding
11 *** source file (e.g. under external/kernel-headers/original/) then
12 *** run bionic/libc/kernel/tools/update_all.py
13 ***
14 *** Any manual change here will be lost the next time this script will
15 *** be run. You've been warned!
16 ***
17 ****************************************************************************
18 ****************************************************************************/
19#ifndef _UAPI__LINUX_BPF_H__
20#define _UAPI__LINUX_BPF_H__
21#include <linux/types.h>
22#include <linux/bpf_common.h>
Christopher Ferris82d75042015-01-26 10:57:07 -080023#define BPF_ALU64 0x07
24#define BPF_DW 0x18
25#define BPF_XADD 0xc0
26#define BPF_MOV 0xb0
Christopher Ferris82d75042015-01-26 10:57:07 -080027#define BPF_ARSH 0xc0
28#define BPF_END 0xd0
29#define BPF_TO_LE 0x00
30#define BPF_TO_BE 0x08
Christopher Ferris82d75042015-01-26 10:57:07 -080031#define BPF_FROM_LE BPF_TO_LE
32#define BPF_FROM_BE BPF_TO_BE
33#define BPF_JNE 0x50
34#define BPF_JSGT 0x60
Christopher Ferris82d75042015-01-26 10:57:07 -080035#define BPF_JSGE 0x70
36#define BPF_CALL 0x80
37#define BPF_EXIT 0x90
38enum {
Tao Baod7db5942015-01-28 10:07:51 -080039 BPF_REG_0 = 0,
40 BPF_REG_1,
41 BPF_REG_2,
42 BPF_REG_3,
Tao Baod7db5942015-01-28 10:07:51 -080043 BPF_REG_4,
44 BPF_REG_5,
45 BPF_REG_6,
46 BPF_REG_7,
Tao Baod7db5942015-01-28 10:07:51 -080047 BPF_REG_8,
48 BPF_REG_9,
49 BPF_REG_10,
50 __MAX_BPF_REG,
Christopher Ferris82d75042015-01-26 10:57:07 -080051};
52#define MAX_BPF_REG __MAX_BPF_REG
53struct bpf_insn {
Tao Baod7db5942015-01-28 10:07:51 -080054 __u8 code;
Tao Baod7db5942015-01-28 10:07:51 -080055 __u8 dst_reg : 4;
56 __u8 src_reg : 4;
57 __s16 off;
58 __s32 imm;
Christopher Ferris82d75042015-01-26 10:57:07 -080059};
60enum bpf_cmd {
Tao Baod7db5942015-01-28 10:07:51 -080061 BPF_MAP_CREATE,
62 BPF_MAP_LOOKUP_ELEM,
Tao Baod7db5942015-01-28 10:07:51 -080063 BPF_MAP_UPDATE_ELEM,
64 BPF_MAP_DELETE_ELEM,
65 BPF_MAP_GET_NEXT_KEY,
66 BPF_PROG_LOAD,
Christopher Ferris05d08e92016-02-04 13:16:38 -080067 BPF_OBJ_PIN,
68 BPF_OBJ_GET,
Christopher Ferris48af7cb2017-02-21 12:35:09 -080069 BPF_PROG_ATTACH,
70 BPF_PROG_DETACH,
Christopher Ferris82d75042015-01-26 10:57:07 -080071};
72enum bpf_map_type {
Christopher Ferris05d08e92016-02-04 13:16:38 -080073 BPF_MAP_TYPE_UNSPEC,
74 BPF_MAP_TYPE_HASH,
75 BPF_MAP_TYPE_ARRAY,
76 BPF_MAP_TYPE_PROG_ARRAY,
Christopher Ferris05d08e92016-02-04 13:16:38 -080077 BPF_MAP_TYPE_PERF_EVENT_ARRAY,
Christopher Ferris106b3a82016-08-24 12:15:38 -070078 BPF_MAP_TYPE_PERCPU_HASH,
79 BPF_MAP_TYPE_PERCPU_ARRAY,
80 BPF_MAP_TYPE_STACK_TRACE,
Christopher Ferris49f525c2016-12-12 14:55:36 -080081 BPF_MAP_TYPE_CGROUP_ARRAY,
Christopher Ferris48af7cb2017-02-21 12:35:09 -080082 BPF_MAP_TYPE_LRU_HASH,
Christopher Ferris48af7cb2017-02-21 12:35:09 -080083 BPF_MAP_TYPE_LRU_PERCPU_HASH,
Christopher Ferris05d08e92016-02-04 13:16:38 -080084};
Christopher Ferris82d75042015-01-26 10:57:07 -080085enum bpf_prog_type {
Tao Baod7db5942015-01-28 10:07:51 -080086 BPF_PROG_TYPE_UNSPEC,
Christopher Ferris49f525c2016-12-12 14:55:36 -080087 BPF_PROG_TYPE_SOCKET_FILTER,
Christopher Ferris05d08e92016-02-04 13:16:38 -080088 BPF_PROG_TYPE_KPROBE,
89 BPF_PROG_TYPE_SCHED_CLS,
90 BPF_PROG_TYPE_SCHED_ACT,
Christopher Ferris49f525c2016-12-12 14:55:36 -080091 BPF_PROG_TYPE_TRACEPOINT,
92 BPF_PROG_TYPE_XDP,
Christopher Ferris6a9755d2017-01-13 14:09:31 -080093 BPF_PROG_TYPE_PERF_EVENT,
Christopher Ferris48af7cb2017-02-21 12:35:09 -080094 BPF_PROG_TYPE_CGROUP_SKB,
Christopher Ferris48af7cb2017-02-21 12:35:09 -080095 BPF_PROG_TYPE_CGROUP_SOCK,
96 BPF_PROG_TYPE_LWT_IN,
97 BPF_PROG_TYPE_LWT_OUT,
98 BPF_PROG_TYPE_LWT_XMIT,
Christopher Ferris48af7cb2017-02-21 12:35:09 -080099};
100enum bpf_attach_type {
101 BPF_CGROUP_INET_INGRESS,
102 BPF_CGROUP_INET_EGRESS,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800103 BPF_CGROUP_INET_SOCK_CREATE,
104 __MAX_BPF_ATTACH_TYPE
105};
106#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800107#define BPF_F_ALLOW_OVERRIDE (1U << 0)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800108#define BPF_PSEUDO_MAP_FD 1
Christopher Ferris05d08e92016-02-04 13:16:38 -0800109#define BPF_ANY 0
110#define BPF_NOEXIST 1
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800111#define BPF_EXIST 2
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800112#define BPF_F_NO_PREALLOC (1U << 0)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800113#define BPF_F_NO_COMMON_LRU (1U << 1)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800114union bpf_attr {
Tao Baod7db5942015-01-28 10:07:51 -0800115 struct {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700116 __u32 map_type;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800117 __u32 key_size;
Tao Baod7db5942015-01-28 10:07:51 -0800118 __u32 value_size;
Tao Baod7db5942015-01-28 10:07:51 -0800119 __u32 max_entries;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700120 __u32 map_flags;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800121 };
Tao Baod7db5942015-01-28 10:07:51 -0800122 struct {
123 __u32 map_fd;
Tao Baod7db5942015-01-28 10:07:51 -0800124 __aligned_u64 key;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800125 union {
Tao Baod7db5942015-01-28 10:07:51 -0800126 __aligned_u64 value;
127 __aligned_u64 next_key;
Tao Baod7db5942015-01-28 10:07:51 -0800128 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800129 __u64 flags;
Tao Baod7db5942015-01-28 10:07:51 -0800130 };
131 struct {
132 __u32 prog_type;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800133 __u32 insn_cnt;
Tao Baod7db5942015-01-28 10:07:51 -0800134 __aligned_u64 insns;
135 __aligned_u64 license;
136 __u32 log_level;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800137 __u32 log_size;
Tao Baod7db5942015-01-28 10:07:51 -0800138 __aligned_u64 log_buf;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800139 __u32 kern_version;
140 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800141 struct {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800142 __aligned_u64 pathname;
143 __u32 bpf_fd;
Tao Baod7db5942015-01-28 10:07:51 -0800144 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800145 struct {
146 __u32 target_fd;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800147 __u32 attach_bpf_fd;
148 __u32 attach_type;
149 __u32 attach_flags;
150 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800151} __attribute__((aligned(8)));
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800152#define __BPF_FUNC_MAPPER(FN) FN(unspec), FN(map_lookup_elem), FN(map_update_elem), FN(map_delete_elem), FN(probe_read), FN(ktime_get_ns), FN(trace_printk), FN(get_prandom_u32), FN(get_smp_processor_id), FN(skb_store_bytes), FN(l3_csum_replace), FN(l4_csum_replace), FN(tail_call), FN(clone_redirect), FN(get_current_pid_tgid), FN(get_current_uid_gid), FN(get_current_comm), FN(get_cgroup_classid), FN(skb_vlan_push), FN(skb_vlan_pop), FN(skb_get_tunnel_key), FN(skb_set_tunnel_key), FN(perf_event_read), FN(redirect), FN(get_route_realm), FN(perf_event_output), FN(skb_load_bytes), FN(get_stackid), FN(csum_diff), FN(skb_get_tunnel_opt), FN(skb_set_tunnel_opt), FN(skb_change_proto), FN(skb_change_type), FN(skb_under_cgroup), FN(get_hash_recalc), FN(get_current_task), FN(probe_write_user), FN(current_task_under_cgroup), FN(skb_change_tail), FN(skb_pull_data), FN(csum_update), FN(set_hash_invalid), FN(get_numa_node_id), FN(skb_change_head), FN(xdp_adjust_head),
153#define __BPF_ENUM_FN(x) BPF_FUNC_ ##x
Christopher Ferris82d75042015-01-26 10:57:07 -0800154enum bpf_func_id {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800155 __BPF_FUNC_MAPPER(__BPF_ENUM_FN) __BPF_FUNC_MAX_ID,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800156};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800157#undef __BPF_ENUM_FN
Christopher Ferris106b3a82016-08-24 12:15:38 -0700158#define BPF_F_RECOMPUTE_CSUM (1ULL << 0)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800159#define BPF_F_INVALIDATE_HASH (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700160#define BPF_F_HDR_FIELD_MASK 0xfULL
161#define BPF_F_PSEUDO_HDR (1ULL << 4)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700162#define BPF_F_MARK_MANGLED_0 (1ULL << 5)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800163#define BPF_F_INGRESS (1ULL << 0)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700164#define BPF_F_TUNINFO_IPV6 (1ULL << 0)
165#define BPF_F_SKIP_FIELD_MASK 0xffULL
Christopher Ferris106b3a82016-08-24 12:15:38 -0700166#define BPF_F_USER_STACK (1ULL << 8)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800167#define BPF_F_FAST_STACK_CMP (1ULL << 9)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700168#define BPF_F_REUSE_STACKID (1ULL << 10)
169#define BPF_F_ZERO_CSUM_TX (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700170#define BPF_F_DONT_FRAGMENT (1ULL << 2)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800171#define BPF_F_INDEX_MASK 0xffffffffULL
Christopher Ferris106b3a82016-08-24 12:15:38 -0700172#define BPF_F_CURRENT_CPU BPF_F_INDEX_MASK
Christopher Ferris49f525c2016-12-12 14:55:36 -0800173#define BPF_F_CTXLEN_MASK (0xfffffULL << 32)
Christopher Ferris49f525c2016-12-12 14:55:36 -0800174struct __sk_buff {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800175 __u32 len;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800176 __u32 pkt_type;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800177 __u32 mark;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800178 __u32 queue_mapping;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800179 __u32 protocol;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800180 __u32 vlan_present;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800181 __u32 vlan_tci;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800182 __u32 vlan_proto;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800183 __u32 priority;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800184 __u32 ingress_ifindex;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800185 __u32 ifindex;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800186 __u32 tc_index;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800187 __u32 cb[5];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800188 __u32 hash;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800189 __u32 tc_classid;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800190 __u32 data;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800191 __u32 data_end;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800192};
193struct bpf_tunnel_key {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800194 __u32 tunnel_id;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800195 union {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700196 __u32 remote_ipv4;
197 __u32 remote_ipv6[4];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800198 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800199 __u8 tunnel_tos;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700200 __u8 tunnel_ttl;
201 __u16 tunnel_ext;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800202 __u32 tunnel_label;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800203};
204enum bpf_ret_code {
205 BPF_OK = 0,
206 BPF_DROP = 2,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800207 BPF_REDIRECT = 7,
208};
209struct bpf_sock {
210 __u32 bound_dev_if;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800211 __u32 family;
212 __u32 type;
213 __u32 protocol;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800214};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800215#define XDP_PACKET_HEADROOM 256
Christopher Ferris49f525c2016-12-12 14:55:36 -0800216enum xdp_action {
217 XDP_ABORTED = 0,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800218 XDP_DROP,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800219 XDP_PASS,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800220 XDP_TX,
221};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800222struct xdp_md {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800223 __u32 data;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800224 __u32 data_end;
225};
Christopher Ferris82d75042015-01-26 10:57:07 -0800226#endif