blob: a1879135a19752a879365502c4cc4ebe2fd958d0 [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
Christopher Ferris1308ad32017-11-14 17:32:13 -080034#define BPF_JLT 0xa0
35#define BPF_JLE 0xb0
Christopher Ferris82d75042015-01-26 10:57:07 -080036#define BPF_JSGT 0x60
Christopher Ferris82d75042015-01-26 10:57:07 -080037#define BPF_JSGE 0x70
Christopher Ferris1308ad32017-11-14 17:32:13 -080038#define BPF_JSLT 0xc0
39#define BPF_JSLE 0xd0
Christopher Ferris82d75042015-01-26 10:57:07 -080040#define BPF_CALL 0x80
41#define BPF_EXIT 0x90
42enum {
Tao Baod7db5942015-01-28 10:07:51 -080043 BPF_REG_0 = 0,
44 BPF_REG_1,
45 BPF_REG_2,
46 BPF_REG_3,
Tao Baod7db5942015-01-28 10:07:51 -080047 BPF_REG_4,
48 BPF_REG_5,
49 BPF_REG_6,
50 BPF_REG_7,
Tao Baod7db5942015-01-28 10:07:51 -080051 BPF_REG_8,
52 BPF_REG_9,
53 BPF_REG_10,
54 __MAX_BPF_REG,
Christopher Ferris82d75042015-01-26 10:57:07 -080055};
56#define MAX_BPF_REG __MAX_BPF_REG
57struct bpf_insn {
Tao Baod7db5942015-01-28 10:07:51 -080058 __u8 code;
Tao Baod7db5942015-01-28 10:07:51 -080059 __u8 dst_reg : 4;
60 __u8 src_reg : 4;
61 __s16 off;
62 __s32 imm;
Christopher Ferris82d75042015-01-26 10:57:07 -080063};
Christopher Ferris525ce912017-07-26 13:12:53 -070064struct bpf_lpm_trie_key {
65 __u32 prefixlen;
66 __u8 data[0];
67};
Christopher Ferris9ce28842018-10-25 12:11:39 -070068struct bpf_cgroup_storage_key {
69 __u64 cgroup_inode_id;
70 __u32 attach_type;
71};
Christopher Ferris82d75042015-01-26 10:57:07 -080072enum bpf_cmd {
Tao Baod7db5942015-01-28 10:07:51 -080073 BPF_MAP_CREATE,
74 BPF_MAP_LOOKUP_ELEM,
Tao Baod7db5942015-01-28 10:07:51 -080075 BPF_MAP_UPDATE_ELEM,
76 BPF_MAP_DELETE_ELEM,
77 BPF_MAP_GET_NEXT_KEY,
78 BPF_PROG_LOAD,
Christopher Ferris05d08e92016-02-04 13:16:38 -080079 BPF_OBJ_PIN,
80 BPF_OBJ_GET,
Christopher Ferris48af7cb2017-02-21 12:35:09 -080081 BPF_PROG_ATTACH,
82 BPF_PROG_DETACH,
Christopher Ferris525ce912017-07-26 13:12:53 -070083 BPF_PROG_TEST_RUN,
Christopher Ferris1308ad32017-11-14 17:32:13 -080084 BPF_PROG_GET_NEXT_ID,
85 BPF_MAP_GET_NEXT_ID,
86 BPF_PROG_GET_FD_BY_ID,
87 BPF_MAP_GET_FD_BY_ID,
88 BPF_OBJ_GET_INFO_BY_FD,
Christopher Ferris934ec942018-01-31 15:29:16 -080089 BPF_PROG_QUERY,
Christopher Ferris76a1d452018-06-27 14:12:29 -070090 BPF_RAW_TRACEPOINT_OPEN,
Christopher Ferris9ce28842018-10-25 12:11:39 -070091 BPF_BTF_LOAD,
92 BPF_BTF_GET_FD_BY_ID,
93 BPF_TASK_FD_QUERY,
Christopher Ferris82d75042015-01-26 10:57:07 -080094};
95enum bpf_map_type {
Christopher Ferris05d08e92016-02-04 13:16:38 -080096 BPF_MAP_TYPE_UNSPEC,
97 BPF_MAP_TYPE_HASH,
98 BPF_MAP_TYPE_ARRAY,
99 BPF_MAP_TYPE_PROG_ARRAY,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800100 BPF_MAP_TYPE_PERF_EVENT_ARRAY,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700101 BPF_MAP_TYPE_PERCPU_HASH,
102 BPF_MAP_TYPE_PERCPU_ARRAY,
103 BPF_MAP_TYPE_STACK_TRACE,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800104 BPF_MAP_TYPE_CGROUP_ARRAY,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800105 BPF_MAP_TYPE_LRU_HASH,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800106 BPF_MAP_TYPE_LRU_PERCPU_HASH,
Christopher Ferris525ce912017-07-26 13:12:53 -0700107 BPF_MAP_TYPE_LPM_TRIE,
108 BPF_MAP_TYPE_ARRAY_OF_MAPS,
109 BPF_MAP_TYPE_HASH_OF_MAPS,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800110 BPF_MAP_TYPE_DEVMAP,
111 BPF_MAP_TYPE_SOCKMAP,
Christopher Ferris934ec942018-01-31 15:29:16 -0800112 BPF_MAP_TYPE_CPUMAP,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700113 BPF_MAP_TYPE_XSKMAP,
114 BPF_MAP_TYPE_SOCKHASH,
115 BPF_MAP_TYPE_CGROUP_STORAGE,
116 BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800117};
Christopher Ferris82d75042015-01-26 10:57:07 -0800118enum bpf_prog_type {
Tao Baod7db5942015-01-28 10:07:51 -0800119 BPF_PROG_TYPE_UNSPEC,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800120 BPF_PROG_TYPE_SOCKET_FILTER,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800121 BPF_PROG_TYPE_KPROBE,
122 BPF_PROG_TYPE_SCHED_CLS,
123 BPF_PROG_TYPE_SCHED_ACT,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800124 BPF_PROG_TYPE_TRACEPOINT,
125 BPF_PROG_TYPE_XDP,
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800126 BPF_PROG_TYPE_PERF_EVENT,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800127 BPF_PROG_TYPE_CGROUP_SKB,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800128 BPF_PROG_TYPE_CGROUP_SOCK,
129 BPF_PROG_TYPE_LWT_IN,
130 BPF_PROG_TYPE_LWT_OUT,
131 BPF_PROG_TYPE_LWT_XMIT,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800132 BPF_PROG_TYPE_SOCK_OPS,
133 BPF_PROG_TYPE_SK_SKB,
Christopher Ferris934ec942018-01-31 15:29:16 -0800134 BPF_PROG_TYPE_CGROUP_DEVICE,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700135 BPF_PROG_TYPE_SK_MSG,
136 BPF_PROG_TYPE_RAW_TRACEPOINT,
137 BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700138 BPF_PROG_TYPE_LWT_SEG6LOCAL,
139 BPF_PROG_TYPE_LIRC_MODE2,
140 BPF_PROG_TYPE_SK_REUSEPORT,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800141};
142enum bpf_attach_type {
143 BPF_CGROUP_INET_INGRESS,
144 BPF_CGROUP_INET_EGRESS,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800145 BPF_CGROUP_INET_SOCK_CREATE,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800146 BPF_CGROUP_SOCK_OPS,
147 BPF_SK_SKB_STREAM_PARSER,
148 BPF_SK_SKB_STREAM_VERDICT,
Christopher Ferris934ec942018-01-31 15:29:16 -0800149 BPF_CGROUP_DEVICE,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700150 BPF_SK_MSG_VERDICT,
151 BPF_CGROUP_INET4_BIND,
152 BPF_CGROUP_INET6_BIND,
153 BPF_CGROUP_INET4_CONNECT,
154 BPF_CGROUP_INET6_CONNECT,
155 BPF_CGROUP_INET4_POST_BIND,
156 BPF_CGROUP_INET6_POST_BIND,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700157 BPF_CGROUP_UDP4_SENDMSG,
158 BPF_CGROUP_UDP6_SENDMSG,
159 BPF_LIRC_MODE2,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800160 __MAX_BPF_ATTACH_TYPE
161};
162#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800163#define BPF_F_ALLOW_OVERRIDE (1U << 0)
Christopher Ferris934ec942018-01-31 15:29:16 -0800164#define BPF_F_ALLOW_MULTI (1U << 1)
Christopher Ferris525ce912017-07-26 13:12:53 -0700165#define BPF_F_STRICT_ALIGNMENT (1U << 0)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800166#define BPF_PSEUDO_MAP_FD 1
Christopher Ferris76a1d452018-06-27 14:12:29 -0700167#define BPF_PSEUDO_CALL 1
Christopher Ferris05d08e92016-02-04 13:16:38 -0800168#define BPF_ANY 0
169#define BPF_NOEXIST 1
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800170#define BPF_EXIST 2
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800171#define BPF_F_NO_PREALLOC (1U << 0)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800172#define BPF_F_NO_COMMON_LRU (1U << 1)
Christopher Ferris1308ad32017-11-14 17:32:13 -0800173#define BPF_F_NUMA_NODE (1U << 2)
Christopher Ferris934ec942018-01-31 15:29:16 -0800174#define BPF_F_QUERY_EFFECTIVE (1U << 0)
175#define BPF_OBJ_NAME_LEN 16U
176#define BPF_F_RDONLY (1U << 3)
177#define BPF_F_WRONLY (1U << 4)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700178#define BPF_F_STACK_BUILD_ID (1U << 5)
179enum bpf_stack_build_id_status {
180 BPF_STACK_BUILD_ID_EMPTY = 0,
181 BPF_STACK_BUILD_ID_VALID = 1,
182 BPF_STACK_BUILD_ID_IP = 2,
183};
184#define BPF_BUILD_ID_SIZE 20
185struct bpf_stack_build_id {
186 __s32 status;
187 unsigned char build_id[BPF_BUILD_ID_SIZE];
188 union {
189 __u64 offset;
190 __u64 ip;
191 };
192};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800193union bpf_attr {
Tao Baod7db5942015-01-28 10:07:51 -0800194 struct {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700195 __u32 map_type;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800196 __u32 key_size;
Tao Baod7db5942015-01-28 10:07:51 -0800197 __u32 value_size;
Tao Baod7db5942015-01-28 10:07:51 -0800198 __u32 max_entries;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700199 __u32 map_flags;
Christopher Ferris525ce912017-07-26 13:12:53 -0700200 __u32 inner_map_fd;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800201 __u32 numa_node;
Christopher Ferris934ec942018-01-31 15:29:16 -0800202 char map_name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700203 __u32 map_ifindex;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700204 __u32 btf_fd;
205 __u32 btf_key_type_id;
206 __u32 btf_value_type_id;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800207 };
Tao Baod7db5942015-01-28 10:07:51 -0800208 struct {
209 __u32 map_fd;
Tao Baod7db5942015-01-28 10:07:51 -0800210 __aligned_u64 key;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800211 union {
Tao Baod7db5942015-01-28 10:07:51 -0800212 __aligned_u64 value;
213 __aligned_u64 next_key;
Tao Baod7db5942015-01-28 10:07:51 -0800214 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800215 __u64 flags;
Tao Baod7db5942015-01-28 10:07:51 -0800216 };
217 struct {
218 __u32 prog_type;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800219 __u32 insn_cnt;
Tao Baod7db5942015-01-28 10:07:51 -0800220 __aligned_u64 insns;
221 __aligned_u64 license;
222 __u32 log_level;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800223 __u32 log_size;
Tao Baod7db5942015-01-28 10:07:51 -0800224 __aligned_u64 log_buf;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800225 __u32 kern_version;
Christopher Ferris525ce912017-07-26 13:12:53 -0700226 __u32 prog_flags;
Christopher Ferris934ec942018-01-31 15:29:16 -0800227 char prog_name[BPF_OBJ_NAME_LEN];
228 __u32 prog_ifindex;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700229 __u32 expected_attach_type;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800230 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800231 struct {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800232 __aligned_u64 pathname;
233 __u32 bpf_fd;
Christopher Ferris934ec942018-01-31 15:29:16 -0800234 __u32 file_flags;
Tao Baod7db5942015-01-28 10:07:51 -0800235 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800236 struct {
237 __u32 target_fd;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800238 __u32 attach_bpf_fd;
239 __u32 attach_type;
240 __u32 attach_flags;
241 };
Christopher Ferris525ce912017-07-26 13:12:53 -0700242 struct {
243 __u32 prog_fd;
244 __u32 retval;
245 __u32 data_size_in;
246 __u32 data_size_out;
247 __aligned_u64 data_in;
248 __aligned_u64 data_out;
249 __u32 repeat;
250 __u32 duration;
251 } test;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800252 struct {
253 union {
254 __u32 start_id;
255 __u32 prog_id;
256 __u32 map_id;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700257 __u32 btf_id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800258 };
259 __u32 next_id;
Christopher Ferris934ec942018-01-31 15:29:16 -0800260 __u32 open_flags;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800261 };
262 struct {
263 __u32 bpf_fd;
264 __u32 info_len;
265 __aligned_u64 info;
266 } info;
Christopher Ferris934ec942018-01-31 15:29:16 -0800267 struct {
268 __u32 target_fd;
269 __u32 attach_type;
270 __u32 query_flags;
271 __u32 attach_flags;
272 __aligned_u64 prog_ids;
273 __u32 prog_cnt;
274 } query;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700275 struct {
276 __u64 name;
277 __u32 prog_fd;
278 } raw_tracepoint;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700279 struct {
280 __aligned_u64 btf;
281 __aligned_u64 btf_log_buf;
282 __u32 btf_size;
283 __u32 btf_log_size;
284 __u32 btf_log_level;
285 };
286 struct {
287 __u32 pid;
288 __u32 fd;
289 __u32 flags;
290 __u32 buf_len;
291 __aligned_u64 buf;
292 __u32 prog_id;
293 __u32 fd_type;
294 __u64 probe_offset;
295 __u64 probe_addr;
296 } task_fd_query;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800297} __attribute__((aligned(8)));
Christopher Ferris9ce28842018-10-25 12:11:39 -0700298#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), FN(probe_read_str), FN(get_socket_cookie), FN(get_socket_uid), FN(set_hash), FN(setsockopt), FN(skb_adjust_room), FN(redirect_map), FN(sk_redirect_map), FN(sock_map_update), FN(xdp_adjust_meta), FN(perf_event_read_value), FN(perf_prog_read_value), FN(getsockopt), FN(override_return), FN(sock_ops_cb_flags_set), FN(msg_redirect_map), FN(msg_apply_bytes), FN(msg_cork_bytes), FN(msg_pull_data), FN(bind), FN(xdp_adjust_tail), FN(skb_get_xfrm_state), FN(get_stack), FN(skb_load_bytes_relative), FN(fib_lookup), FN(sock_hash_update), FN(msg_redirect_hash), FN(sk_redirect_hash), FN(lwt_push_encap), FN(lwt_seg6_store_bytes), FN(lwt_seg6_adjust_srh), FN(lwt_seg6_action), FN(rc_repeat), FN(rc_keydown), FN(skb_cgroup_id), FN(get_current_cgroup_id), FN(get_local_storage), FN(sk_select_reuseport), FN(skb_ancestor_cgroup_id),
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800299#define __BPF_ENUM_FN(x) BPF_FUNC_ ##x
Christopher Ferris82d75042015-01-26 10:57:07 -0800300enum bpf_func_id {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800301 __BPF_FUNC_MAPPER(__BPF_ENUM_FN) __BPF_FUNC_MAX_ID,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800302};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800303#undef __BPF_ENUM_FN
Christopher Ferris106b3a82016-08-24 12:15:38 -0700304#define BPF_F_RECOMPUTE_CSUM (1ULL << 0)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800305#define BPF_F_INVALIDATE_HASH (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700306#define BPF_F_HDR_FIELD_MASK 0xfULL
307#define BPF_F_PSEUDO_HDR (1ULL << 4)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700308#define BPF_F_MARK_MANGLED_0 (1ULL << 5)
Christopher Ferris525ce912017-07-26 13:12:53 -0700309#define BPF_F_MARK_ENFORCE (1ULL << 6)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800310#define BPF_F_INGRESS (1ULL << 0)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700311#define BPF_F_TUNINFO_IPV6 (1ULL << 0)
312#define BPF_F_SKIP_FIELD_MASK 0xffULL
Christopher Ferris106b3a82016-08-24 12:15:38 -0700313#define BPF_F_USER_STACK (1ULL << 8)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800314#define BPF_F_FAST_STACK_CMP (1ULL << 9)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700315#define BPF_F_REUSE_STACKID (1ULL << 10)
Christopher Ferris9ce28842018-10-25 12:11:39 -0700316#define BPF_F_USER_BUILD_ID (1ULL << 11)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700317#define BPF_F_ZERO_CSUM_TX (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700318#define BPF_F_DONT_FRAGMENT (1ULL << 2)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700319#define BPF_F_SEQ_NUMBER (1ULL << 3)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800320#define BPF_F_INDEX_MASK 0xffffffffULL
Christopher Ferris106b3a82016-08-24 12:15:38 -0700321#define BPF_F_CURRENT_CPU BPF_F_INDEX_MASK
Christopher Ferris49f525c2016-12-12 14:55:36 -0800322#define BPF_F_CTXLEN_MASK (0xfffffULL << 32)
Christopher Ferris1308ad32017-11-14 17:32:13 -0800323enum bpf_adj_room_mode {
324 BPF_ADJ_ROOM_NET,
325};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700326enum bpf_hdr_start_off {
327 BPF_HDR_START_MAC,
328 BPF_HDR_START_NET,
329};
330enum bpf_lwt_encap_mode {
331 BPF_LWT_ENCAP_SEG6,
332 BPF_LWT_ENCAP_SEG6_INLINE
333};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800334struct __sk_buff {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800335 __u32 len;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800336 __u32 pkt_type;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800337 __u32 mark;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800338 __u32 queue_mapping;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800339 __u32 protocol;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800340 __u32 vlan_present;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800341 __u32 vlan_tci;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800342 __u32 vlan_proto;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800343 __u32 priority;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800344 __u32 ingress_ifindex;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800345 __u32 ifindex;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800346 __u32 tc_index;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800347 __u32 cb[5];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800348 __u32 hash;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800349 __u32 tc_classid;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800350 __u32 data;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800351 __u32 data_end;
Christopher Ferris525ce912017-07-26 13:12:53 -0700352 __u32 napi_id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800353 __u32 family;
354 __u32 remote_ip4;
355 __u32 local_ip4;
356 __u32 remote_ip6[4];
357 __u32 local_ip6[4];
358 __u32 remote_port;
359 __u32 local_port;
Christopher Ferris934ec942018-01-31 15:29:16 -0800360 __u32 data_meta;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800361};
362struct bpf_tunnel_key {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800363 __u32 tunnel_id;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800364 union {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700365 __u32 remote_ipv4;
366 __u32 remote_ipv6[4];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800367 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800368 __u8 tunnel_tos;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700369 __u8 tunnel_ttl;
370 __u16 tunnel_ext;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800371 __u32 tunnel_label;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800372};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700373struct bpf_xfrm_state {
374 __u32 reqid;
375 __u32 spi;
376 __u16 family;
377 __u16 ext;
378 union {
379 __u32 remote_ipv4;
380 __u32 remote_ipv6[4];
381 };
382};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800383enum bpf_ret_code {
384 BPF_OK = 0,
385 BPF_DROP = 2,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800386 BPF_REDIRECT = 7,
387};
388struct bpf_sock {
389 __u32 bound_dev_if;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800390 __u32 family;
391 __u32 type;
392 __u32 protocol;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800393 __u32 mark;
394 __u32 priority;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700395 __u32 src_ip4;
396 __u32 src_ip6[4];
397 __u32 src_port;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800398};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800399#define XDP_PACKET_HEADROOM 256
Christopher Ferris49f525c2016-12-12 14:55:36 -0800400enum xdp_action {
401 XDP_ABORTED = 0,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800402 XDP_DROP,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800403 XDP_PASS,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800404 XDP_TX,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800405 XDP_REDIRECT,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800406};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800407struct xdp_md {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800408 __u32 data;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800409 __u32 data_end;
Christopher Ferris934ec942018-01-31 15:29:16 -0800410 __u32 data_meta;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700411 __u32 ingress_ifindex;
412 __u32 rx_queue_index;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800413};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800414enum sk_action {
415 SK_DROP = 0,
416 SK_PASS,
417};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700418struct sk_msg_md {
419 void * data;
420 void * data_end;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700421 __u32 family;
422 __u32 remote_ip4;
423 __u32 local_ip4;
424 __u32 remote_ip6[4];
425 __u32 local_ip6[4];
426 __u32 remote_port;
427 __u32 local_port;
428};
429struct sk_reuseport_md {
430 void * data;
431 void * data_end;
432 __u32 len;
433 __u32 eth_protocol;
434 __u32 ip_protocol;
435 __u32 bind_inany;
436 __u32 hash;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700437};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800438#define BPF_TAG_SIZE 8
439struct bpf_prog_info {
440 __u32 type;
441 __u32 id;
442 __u8 tag[BPF_TAG_SIZE];
443 __u32 jited_prog_len;
444 __u32 xlated_prog_len;
445 __aligned_u64 jited_prog_insns;
446 __aligned_u64 xlated_prog_insns;
Christopher Ferris934ec942018-01-31 15:29:16 -0800447 __u64 load_time;
448 __u32 created_by_uid;
449 __u32 nr_map_ids;
450 __aligned_u64 map_ids;
451 char name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700452 __u32 ifindex;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700453 __u32 gpl_compatible : 1;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700454 __u64 netns_dev;
455 __u64 netns_ino;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700456 __u32 nr_jited_ksyms;
457 __u32 nr_jited_func_lens;
458 __aligned_u64 jited_ksyms;
459 __aligned_u64 jited_func_lens;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800460} __attribute__((aligned(8)));
461struct bpf_map_info {
462 __u32 type;
463 __u32 id;
464 __u32 key_size;
465 __u32 value_size;
466 __u32 max_entries;
467 __u32 map_flags;
Christopher Ferris934ec942018-01-31 15:29:16 -0800468 char name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700469 __u32 ifindex;
470 __u32 : 32;
471 __u64 netns_dev;
472 __u64 netns_ino;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700473 __u32 btf_id;
474 __u32 btf_key_type_id;
475 __u32 btf_value_type_id;
476} __attribute__((aligned(8)));
477struct bpf_btf_info {
478 __aligned_u64 btf;
479 __u32 btf_size;
480 __u32 id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800481} __attribute__((aligned(8)));
Christopher Ferris76a1d452018-06-27 14:12:29 -0700482struct bpf_sock_addr {
483 __u32 user_family;
484 __u32 user_ip4;
485 __u32 user_ip6[4];
486 __u32 user_port;
487 __u32 family;
488 __u32 type;
489 __u32 protocol;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700490 __u32 msg_src_ip4;
491 __u32 msg_src_ip6[4];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700492};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800493struct bpf_sock_ops {
494 __u32 op;
495 union {
Christopher Ferris76a1d452018-06-27 14:12:29 -0700496 __u32 args[4];
Christopher Ferris1308ad32017-11-14 17:32:13 -0800497 __u32 reply;
498 __u32 replylong[4];
499 };
500 __u32 family;
501 __u32 remote_ip4;
502 __u32 local_ip4;
503 __u32 remote_ip6[4];
504 __u32 local_ip6[4];
505 __u32 remote_port;
506 __u32 local_port;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700507 __u32 is_fullsock;
508 __u32 snd_cwnd;
509 __u32 srtt_us;
510 __u32 bpf_sock_ops_cb_flags;
511 __u32 state;
512 __u32 rtt_min;
513 __u32 snd_ssthresh;
514 __u32 rcv_nxt;
515 __u32 snd_nxt;
516 __u32 snd_una;
517 __u32 mss_cache;
518 __u32 ecn_flags;
519 __u32 rate_delivered;
520 __u32 rate_interval_us;
521 __u32 packets_out;
522 __u32 retrans_out;
523 __u32 total_retrans;
524 __u32 segs_in;
525 __u32 data_segs_in;
526 __u32 segs_out;
527 __u32 data_segs_out;
528 __u32 lost_out;
529 __u32 sacked_out;
530 __u32 sk_txhash;
531 __u64 bytes_received;
532 __u64 bytes_acked;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800533};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700534#define BPF_SOCK_OPS_RTO_CB_FLAG (1 << 0)
535#define BPF_SOCK_OPS_RETRANS_CB_FLAG (1 << 1)
536#define BPF_SOCK_OPS_STATE_CB_FLAG (1 << 2)
537#define BPF_SOCK_OPS_ALL_CB_FLAGS 0x7
Christopher Ferris1308ad32017-11-14 17:32:13 -0800538enum {
539 BPF_SOCK_OPS_VOID,
540 BPF_SOCK_OPS_TIMEOUT_INIT,
541 BPF_SOCK_OPS_RWND_INIT,
542 BPF_SOCK_OPS_TCP_CONNECT_CB,
543 BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB,
544 BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB,
545 BPF_SOCK_OPS_NEEDS_ECN,
Christopher Ferris934ec942018-01-31 15:29:16 -0800546 BPF_SOCK_OPS_BASE_RTT,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700547 BPF_SOCK_OPS_RTO_CB,
548 BPF_SOCK_OPS_RETRANS_CB,
549 BPF_SOCK_OPS_STATE_CB,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700550 BPF_SOCK_OPS_TCP_LISTEN_CB,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700551};
552enum {
553 BPF_TCP_ESTABLISHED = 1,
554 BPF_TCP_SYN_SENT,
555 BPF_TCP_SYN_RECV,
556 BPF_TCP_FIN_WAIT1,
557 BPF_TCP_FIN_WAIT2,
558 BPF_TCP_TIME_WAIT,
559 BPF_TCP_CLOSE,
560 BPF_TCP_CLOSE_WAIT,
561 BPF_TCP_LAST_ACK,
562 BPF_TCP_LISTEN,
563 BPF_TCP_CLOSING,
564 BPF_TCP_NEW_SYN_RECV,
565 BPF_TCP_MAX_STATES
Christopher Ferris1308ad32017-11-14 17:32:13 -0800566};
567#define TCP_BPF_IW 1001
568#define TCP_BPF_SNDCWND_CLAMP 1002
Christopher Ferris934ec942018-01-31 15:29:16 -0800569struct bpf_perf_event_value {
570 __u64 counter;
571 __u64 enabled;
572 __u64 running;
573};
574#define BPF_DEVCG_ACC_MKNOD (1ULL << 0)
575#define BPF_DEVCG_ACC_READ (1ULL << 1)
576#define BPF_DEVCG_ACC_WRITE (1ULL << 2)
577#define BPF_DEVCG_DEV_BLOCK (1ULL << 0)
578#define BPF_DEVCG_DEV_CHAR (1ULL << 1)
579struct bpf_cgroup_dev_ctx {
580 __u32 access_type;
581 __u32 major;
582 __u32 minor;
583};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700584struct bpf_raw_tracepoint_args {
585 __u64 args[0];
586};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700587#define BPF_FIB_LOOKUP_DIRECT BIT(0)
588#define BPF_FIB_LOOKUP_OUTPUT BIT(1)
589enum {
590 BPF_FIB_LKUP_RET_SUCCESS,
591 BPF_FIB_LKUP_RET_BLACKHOLE,
592 BPF_FIB_LKUP_RET_UNREACHABLE,
593 BPF_FIB_LKUP_RET_PROHIBIT,
594 BPF_FIB_LKUP_RET_NOT_FWDED,
595 BPF_FIB_LKUP_RET_FWD_DISABLED,
596 BPF_FIB_LKUP_RET_UNSUPP_LWT,
597 BPF_FIB_LKUP_RET_NO_NEIGH,
598 BPF_FIB_LKUP_RET_FRAG_NEEDED,
599};
600struct bpf_fib_lookup {
601 __u8 family;
602 __u8 l4_protocol;
603 __be16 sport;
604 __be16 dport;
605 __u16 tot_len;
606 __u32 ifindex;
607 union {
608 __u8 tos;
609 __be32 flowinfo;
610 __u32 rt_metric;
611 };
612 union {
613 __be32 ipv4_src;
614 __u32 ipv6_src[4];
615 };
616 union {
617 __be32 ipv4_dst;
618 __u32 ipv6_dst[4];
619 };
620 __be16 h_vlan_proto;
621 __be16 h_vlan_TCI;
622 __u8 smac[6];
623 __u8 dmac[6];
624};
625enum bpf_task_fd_type {
626 BPF_FD_TYPE_RAW_TRACEPOINT,
627 BPF_FD_TYPE_TRACEPOINT,
628 BPF_FD_TYPE_KPROBE,
629 BPF_FD_TYPE_KRETPROBE,
630 BPF_FD_TYPE_UPROBE,
631 BPF_FD_TYPE_URETPROBE,
632};
Christopher Ferris82d75042015-01-26 10:57:07 -0800633#endif