blob: edae89389408099f608a345171c52858b73fc638 [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 Ferris24f97eb2019-05-20 12:58:13 -070023#define BPF_JMP32 0x06
Christopher Ferris82d75042015-01-26 10:57:07 -080024#define BPF_ALU64 0x07
25#define BPF_DW 0x18
26#define BPF_XADD 0xc0
27#define BPF_MOV 0xb0
Christopher Ferris82d75042015-01-26 10:57:07 -080028#define BPF_ARSH 0xc0
29#define BPF_END 0xd0
30#define BPF_TO_LE 0x00
31#define BPF_TO_BE 0x08
Christopher Ferris82d75042015-01-26 10:57:07 -080032#define BPF_FROM_LE BPF_TO_LE
33#define BPF_FROM_BE BPF_TO_BE
34#define BPF_JNE 0x50
Christopher Ferris1308ad32017-11-14 17:32:13 -080035#define BPF_JLT 0xa0
36#define BPF_JLE 0xb0
Christopher Ferris82d75042015-01-26 10:57:07 -080037#define BPF_JSGT 0x60
Christopher Ferris82d75042015-01-26 10:57:07 -080038#define BPF_JSGE 0x70
Christopher Ferris1308ad32017-11-14 17:32:13 -080039#define BPF_JSLT 0xc0
40#define BPF_JSLE 0xd0
Christopher Ferris82d75042015-01-26 10:57:07 -080041#define BPF_CALL 0x80
42#define BPF_EXIT 0x90
43enum {
Tao Baod7db5942015-01-28 10:07:51 -080044 BPF_REG_0 = 0,
45 BPF_REG_1,
46 BPF_REG_2,
47 BPF_REG_3,
Tao Baod7db5942015-01-28 10:07:51 -080048 BPF_REG_4,
49 BPF_REG_5,
50 BPF_REG_6,
51 BPF_REG_7,
Tao Baod7db5942015-01-28 10:07:51 -080052 BPF_REG_8,
53 BPF_REG_9,
54 BPF_REG_10,
55 __MAX_BPF_REG,
Christopher Ferris82d75042015-01-26 10:57:07 -080056};
57#define MAX_BPF_REG __MAX_BPF_REG
58struct bpf_insn {
Tao Baod7db5942015-01-28 10:07:51 -080059 __u8 code;
Tao Baod7db5942015-01-28 10:07:51 -080060 __u8 dst_reg : 4;
61 __u8 src_reg : 4;
62 __s16 off;
63 __s32 imm;
Christopher Ferris82d75042015-01-26 10:57:07 -080064};
Christopher Ferris525ce912017-07-26 13:12:53 -070065struct bpf_lpm_trie_key {
66 __u32 prefixlen;
67 __u8 data[0];
68};
Christopher Ferris9ce28842018-10-25 12:11:39 -070069struct bpf_cgroup_storage_key {
70 __u64 cgroup_inode_id;
71 __u32 attach_type;
72};
Christopher Ferris82d75042015-01-26 10:57:07 -080073enum bpf_cmd {
Tao Baod7db5942015-01-28 10:07:51 -080074 BPF_MAP_CREATE,
75 BPF_MAP_LOOKUP_ELEM,
Tao Baod7db5942015-01-28 10:07:51 -080076 BPF_MAP_UPDATE_ELEM,
77 BPF_MAP_DELETE_ELEM,
78 BPF_MAP_GET_NEXT_KEY,
79 BPF_PROG_LOAD,
Christopher Ferris05d08e92016-02-04 13:16:38 -080080 BPF_OBJ_PIN,
81 BPF_OBJ_GET,
Christopher Ferris48af7cb2017-02-21 12:35:09 -080082 BPF_PROG_ATTACH,
83 BPF_PROG_DETACH,
Christopher Ferris525ce912017-07-26 13:12:53 -070084 BPF_PROG_TEST_RUN,
Christopher Ferris1308ad32017-11-14 17:32:13 -080085 BPF_PROG_GET_NEXT_ID,
86 BPF_MAP_GET_NEXT_ID,
87 BPF_PROG_GET_FD_BY_ID,
88 BPF_MAP_GET_FD_BY_ID,
89 BPF_OBJ_GET_INFO_BY_FD,
Christopher Ferris934ec942018-01-31 15:29:16 -080090 BPF_PROG_QUERY,
Christopher Ferris76a1d452018-06-27 14:12:29 -070091 BPF_RAW_TRACEPOINT_OPEN,
Christopher Ferris9ce28842018-10-25 12:11:39 -070092 BPF_BTF_LOAD,
93 BPF_BTF_GET_FD_BY_ID,
94 BPF_TASK_FD_QUERY,
Christopher Ferris86a48372019-01-10 14:14:59 -080095 BPF_MAP_LOOKUP_AND_DELETE_ELEM,
Christopher Ferris82d75042015-01-26 10:57:07 -080096};
97enum bpf_map_type {
Christopher Ferris05d08e92016-02-04 13:16:38 -080098 BPF_MAP_TYPE_UNSPEC,
99 BPF_MAP_TYPE_HASH,
100 BPF_MAP_TYPE_ARRAY,
101 BPF_MAP_TYPE_PROG_ARRAY,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800102 BPF_MAP_TYPE_PERF_EVENT_ARRAY,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700103 BPF_MAP_TYPE_PERCPU_HASH,
104 BPF_MAP_TYPE_PERCPU_ARRAY,
105 BPF_MAP_TYPE_STACK_TRACE,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800106 BPF_MAP_TYPE_CGROUP_ARRAY,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800107 BPF_MAP_TYPE_LRU_HASH,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800108 BPF_MAP_TYPE_LRU_PERCPU_HASH,
Christopher Ferris525ce912017-07-26 13:12:53 -0700109 BPF_MAP_TYPE_LPM_TRIE,
110 BPF_MAP_TYPE_ARRAY_OF_MAPS,
111 BPF_MAP_TYPE_HASH_OF_MAPS,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800112 BPF_MAP_TYPE_DEVMAP,
113 BPF_MAP_TYPE_SOCKMAP,
Christopher Ferris934ec942018-01-31 15:29:16 -0800114 BPF_MAP_TYPE_CPUMAP,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700115 BPF_MAP_TYPE_XSKMAP,
116 BPF_MAP_TYPE_SOCKHASH,
117 BPF_MAP_TYPE_CGROUP_STORAGE,
118 BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,
Christopher Ferris86a48372019-01-10 14:14:59 -0800119 BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,
120 BPF_MAP_TYPE_QUEUE,
121 BPF_MAP_TYPE_STACK,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800122};
Christopher Ferris82d75042015-01-26 10:57:07 -0800123enum bpf_prog_type {
Tao Baod7db5942015-01-28 10:07:51 -0800124 BPF_PROG_TYPE_UNSPEC,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800125 BPF_PROG_TYPE_SOCKET_FILTER,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800126 BPF_PROG_TYPE_KPROBE,
127 BPF_PROG_TYPE_SCHED_CLS,
128 BPF_PROG_TYPE_SCHED_ACT,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800129 BPF_PROG_TYPE_TRACEPOINT,
130 BPF_PROG_TYPE_XDP,
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800131 BPF_PROG_TYPE_PERF_EVENT,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800132 BPF_PROG_TYPE_CGROUP_SKB,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800133 BPF_PROG_TYPE_CGROUP_SOCK,
134 BPF_PROG_TYPE_LWT_IN,
135 BPF_PROG_TYPE_LWT_OUT,
136 BPF_PROG_TYPE_LWT_XMIT,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800137 BPF_PROG_TYPE_SOCK_OPS,
138 BPF_PROG_TYPE_SK_SKB,
Christopher Ferris934ec942018-01-31 15:29:16 -0800139 BPF_PROG_TYPE_CGROUP_DEVICE,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700140 BPF_PROG_TYPE_SK_MSG,
141 BPF_PROG_TYPE_RAW_TRACEPOINT,
142 BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700143 BPF_PROG_TYPE_LWT_SEG6LOCAL,
144 BPF_PROG_TYPE_LIRC_MODE2,
145 BPF_PROG_TYPE_SK_REUSEPORT,
Christopher Ferris86a48372019-01-10 14:14:59 -0800146 BPF_PROG_TYPE_FLOW_DISSECTOR,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800147};
148enum bpf_attach_type {
149 BPF_CGROUP_INET_INGRESS,
150 BPF_CGROUP_INET_EGRESS,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800151 BPF_CGROUP_INET_SOCK_CREATE,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800152 BPF_CGROUP_SOCK_OPS,
153 BPF_SK_SKB_STREAM_PARSER,
154 BPF_SK_SKB_STREAM_VERDICT,
Christopher Ferris934ec942018-01-31 15:29:16 -0800155 BPF_CGROUP_DEVICE,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700156 BPF_SK_MSG_VERDICT,
157 BPF_CGROUP_INET4_BIND,
158 BPF_CGROUP_INET6_BIND,
159 BPF_CGROUP_INET4_CONNECT,
160 BPF_CGROUP_INET6_CONNECT,
161 BPF_CGROUP_INET4_POST_BIND,
162 BPF_CGROUP_INET6_POST_BIND,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700163 BPF_CGROUP_UDP4_SENDMSG,
164 BPF_CGROUP_UDP6_SENDMSG,
165 BPF_LIRC_MODE2,
Christopher Ferris86a48372019-01-10 14:14:59 -0800166 BPF_FLOW_DISSECTOR,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800167 __MAX_BPF_ATTACH_TYPE
168};
169#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800170#define BPF_F_ALLOW_OVERRIDE (1U << 0)
Christopher Ferris934ec942018-01-31 15:29:16 -0800171#define BPF_F_ALLOW_MULTI (1U << 1)
Christopher Ferris525ce912017-07-26 13:12:53 -0700172#define BPF_F_STRICT_ALIGNMENT (1U << 0)
Christopher Ferrisd842e432019-03-07 10:21:59 -0800173#define BPF_F_ANY_ALIGNMENT (1U << 1)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800174#define BPF_PSEUDO_MAP_FD 1
Christopher Ferris76a1d452018-06-27 14:12:29 -0700175#define BPF_PSEUDO_CALL 1
Christopher Ferris05d08e92016-02-04 13:16:38 -0800176#define BPF_ANY 0
177#define BPF_NOEXIST 1
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800178#define BPF_EXIST 2
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700179#define BPF_F_LOCK 4
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800180#define BPF_F_NO_PREALLOC (1U << 0)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800181#define BPF_F_NO_COMMON_LRU (1U << 1)
Christopher Ferris1308ad32017-11-14 17:32:13 -0800182#define BPF_F_NUMA_NODE (1U << 2)
Christopher Ferris934ec942018-01-31 15:29:16 -0800183#define BPF_OBJ_NAME_LEN 16U
184#define BPF_F_RDONLY (1U << 3)
185#define BPF_F_WRONLY (1U << 4)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700186#define BPF_F_STACK_BUILD_ID (1U << 5)
Christopher Ferrisd842e432019-03-07 10:21:59 -0800187#define BPF_F_ZERO_SEED (1U << 6)
188#define BPF_F_QUERY_EFFECTIVE (1U << 0)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700189enum bpf_stack_build_id_status {
190 BPF_STACK_BUILD_ID_EMPTY = 0,
191 BPF_STACK_BUILD_ID_VALID = 1,
192 BPF_STACK_BUILD_ID_IP = 2,
193};
194#define BPF_BUILD_ID_SIZE 20
195struct bpf_stack_build_id {
196 __s32 status;
197 unsigned char build_id[BPF_BUILD_ID_SIZE];
198 union {
199 __u64 offset;
200 __u64 ip;
201 };
202};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800203union bpf_attr {
Tao Baod7db5942015-01-28 10:07:51 -0800204 struct {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700205 __u32 map_type;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800206 __u32 key_size;
Tao Baod7db5942015-01-28 10:07:51 -0800207 __u32 value_size;
Tao Baod7db5942015-01-28 10:07:51 -0800208 __u32 max_entries;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700209 __u32 map_flags;
Christopher Ferris525ce912017-07-26 13:12:53 -0700210 __u32 inner_map_fd;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800211 __u32 numa_node;
Christopher Ferris934ec942018-01-31 15:29:16 -0800212 char map_name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700213 __u32 map_ifindex;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700214 __u32 btf_fd;
215 __u32 btf_key_type_id;
216 __u32 btf_value_type_id;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800217 };
Tao Baod7db5942015-01-28 10:07:51 -0800218 struct {
219 __u32 map_fd;
Tao Baod7db5942015-01-28 10:07:51 -0800220 __aligned_u64 key;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800221 union {
Tao Baod7db5942015-01-28 10:07:51 -0800222 __aligned_u64 value;
223 __aligned_u64 next_key;
Tao Baod7db5942015-01-28 10:07:51 -0800224 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800225 __u64 flags;
Tao Baod7db5942015-01-28 10:07:51 -0800226 };
227 struct {
228 __u32 prog_type;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800229 __u32 insn_cnt;
Tao Baod7db5942015-01-28 10:07:51 -0800230 __aligned_u64 insns;
231 __aligned_u64 license;
232 __u32 log_level;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800233 __u32 log_size;
Tao Baod7db5942015-01-28 10:07:51 -0800234 __aligned_u64 log_buf;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800235 __u32 kern_version;
Christopher Ferris525ce912017-07-26 13:12:53 -0700236 __u32 prog_flags;
Christopher Ferris934ec942018-01-31 15:29:16 -0800237 char prog_name[BPF_OBJ_NAME_LEN];
238 __u32 prog_ifindex;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700239 __u32 expected_attach_type;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800240 __u32 prog_btf_fd;
241 __u32 func_info_rec_size;
242 __aligned_u64 func_info;
243 __u32 func_info_cnt;
244 __u32 line_info_rec_size;
245 __aligned_u64 line_info;
246 __u32 line_info_cnt;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800247 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800248 struct {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800249 __aligned_u64 pathname;
250 __u32 bpf_fd;
Christopher Ferris934ec942018-01-31 15:29:16 -0800251 __u32 file_flags;
Tao Baod7db5942015-01-28 10:07:51 -0800252 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800253 struct {
254 __u32 target_fd;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800255 __u32 attach_bpf_fd;
256 __u32 attach_type;
257 __u32 attach_flags;
258 };
Christopher Ferris525ce912017-07-26 13:12:53 -0700259 struct {
260 __u32 prog_fd;
261 __u32 retval;
262 __u32 data_size_in;
263 __u32 data_size_out;
264 __aligned_u64 data_in;
265 __aligned_u64 data_out;
266 __u32 repeat;
267 __u32 duration;
268 } test;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800269 struct {
270 union {
271 __u32 start_id;
272 __u32 prog_id;
273 __u32 map_id;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700274 __u32 btf_id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800275 };
276 __u32 next_id;
Christopher Ferris934ec942018-01-31 15:29:16 -0800277 __u32 open_flags;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800278 };
279 struct {
280 __u32 bpf_fd;
281 __u32 info_len;
282 __aligned_u64 info;
283 } info;
Christopher Ferris934ec942018-01-31 15:29:16 -0800284 struct {
285 __u32 target_fd;
286 __u32 attach_type;
287 __u32 query_flags;
288 __u32 attach_flags;
289 __aligned_u64 prog_ids;
290 __u32 prog_cnt;
291 } query;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700292 struct {
293 __u64 name;
294 __u32 prog_fd;
295 } raw_tracepoint;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700296 struct {
297 __aligned_u64 btf;
298 __aligned_u64 btf_log_buf;
299 __u32 btf_size;
300 __u32 btf_log_size;
301 __u32 btf_log_level;
302 };
303 struct {
304 __u32 pid;
305 __u32 fd;
306 __u32 flags;
307 __u32 buf_len;
308 __aligned_u64 buf;
309 __u32 prog_id;
310 __u32 fd_type;
311 __u64 probe_offset;
312 __u64 probe_addr;
313 } task_fd_query;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800314} __attribute__((aligned(8)));
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700315#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), FN(sk_lookup_tcp), FN(sk_lookup_udp), FN(sk_release), FN(map_push_elem), FN(map_pop_elem), FN(map_peek_elem), FN(msg_push_data), FN(msg_pop_data), FN(rc_pointer_rel), FN(spin_lock), FN(spin_unlock), FN(sk_fullsock), FN(tcp_sock), FN(skb_ecn_set_ce), FN(get_listener_sock),
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800316#define __BPF_ENUM_FN(x) BPF_FUNC_ ##x
Christopher Ferris82d75042015-01-26 10:57:07 -0800317enum bpf_func_id {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800318 __BPF_FUNC_MAPPER(__BPF_ENUM_FN) __BPF_FUNC_MAX_ID,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800319};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800320#undef __BPF_ENUM_FN
Christopher Ferris106b3a82016-08-24 12:15:38 -0700321#define BPF_F_RECOMPUTE_CSUM (1ULL << 0)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800322#define BPF_F_INVALIDATE_HASH (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700323#define BPF_F_HDR_FIELD_MASK 0xfULL
324#define BPF_F_PSEUDO_HDR (1ULL << 4)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700325#define BPF_F_MARK_MANGLED_0 (1ULL << 5)
Christopher Ferris525ce912017-07-26 13:12:53 -0700326#define BPF_F_MARK_ENFORCE (1ULL << 6)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800327#define BPF_F_INGRESS (1ULL << 0)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700328#define BPF_F_TUNINFO_IPV6 (1ULL << 0)
329#define BPF_F_SKIP_FIELD_MASK 0xffULL
Christopher Ferris106b3a82016-08-24 12:15:38 -0700330#define BPF_F_USER_STACK (1ULL << 8)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800331#define BPF_F_FAST_STACK_CMP (1ULL << 9)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700332#define BPF_F_REUSE_STACKID (1ULL << 10)
Christopher Ferris9ce28842018-10-25 12:11:39 -0700333#define BPF_F_USER_BUILD_ID (1ULL << 11)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700334#define BPF_F_ZERO_CSUM_TX (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700335#define BPF_F_DONT_FRAGMENT (1ULL << 2)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700336#define BPF_F_SEQ_NUMBER (1ULL << 3)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800337#define BPF_F_INDEX_MASK 0xffffffffULL
Christopher Ferris106b3a82016-08-24 12:15:38 -0700338#define BPF_F_CURRENT_CPU BPF_F_INDEX_MASK
Christopher Ferris49f525c2016-12-12 14:55:36 -0800339#define BPF_F_CTXLEN_MASK (0xfffffULL << 32)
Christopher Ferris86a48372019-01-10 14:14:59 -0800340#define BPF_F_CURRENT_NETNS (- 1L)
Christopher Ferris1308ad32017-11-14 17:32:13 -0800341enum bpf_adj_room_mode {
342 BPF_ADJ_ROOM_NET,
343};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700344enum bpf_hdr_start_off {
345 BPF_HDR_START_MAC,
346 BPF_HDR_START_NET,
347};
348enum bpf_lwt_encap_mode {
349 BPF_LWT_ENCAP_SEG6,
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700350 BPF_LWT_ENCAP_SEG6_INLINE,
351 BPF_LWT_ENCAP_IP,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700352};
Christopher Ferris86a48372019-01-10 14:14:59 -0800353#define __bpf_md_ptr(type,name) union { type name; __u64 : 64; \
354} __attribute__((aligned(8)))
Christopher Ferris49f525c2016-12-12 14:55:36 -0800355struct __sk_buff {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800356 __u32 len;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800357 __u32 pkt_type;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800358 __u32 mark;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800359 __u32 queue_mapping;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800360 __u32 protocol;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800361 __u32 vlan_present;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800362 __u32 vlan_tci;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800363 __u32 vlan_proto;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800364 __u32 priority;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800365 __u32 ingress_ifindex;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800366 __u32 ifindex;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800367 __u32 tc_index;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800368 __u32 cb[5];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800369 __u32 hash;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800370 __u32 tc_classid;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800371 __u32 data;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800372 __u32 data_end;
Christopher Ferris525ce912017-07-26 13:12:53 -0700373 __u32 napi_id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800374 __u32 family;
375 __u32 remote_ip4;
376 __u32 local_ip4;
377 __u32 remote_ip6[4];
378 __u32 local_ip6[4];
379 __u32 remote_port;
380 __u32 local_port;
Christopher Ferris934ec942018-01-31 15:29:16 -0800381 __u32 data_meta;
Christopher Ferris86a48372019-01-10 14:14:59 -0800382 __bpf_md_ptr(struct bpf_flow_keys *, flow_keys);
Christopher Ferrisd842e432019-03-07 10:21:59 -0800383 __u64 tstamp;
384 __u32 wire_len;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700385 __u32 gso_segs;
386 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferris05d08e92016-02-04 13:16:38 -0800387};
388struct bpf_tunnel_key {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800389 __u32 tunnel_id;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800390 union {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700391 __u32 remote_ipv4;
392 __u32 remote_ipv6[4];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800393 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800394 __u8 tunnel_tos;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700395 __u8 tunnel_ttl;
396 __u16 tunnel_ext;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800397 __u32 tunnel_label;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800398};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700399struct bpf_xfrm_state {
400 __u32 reqid;
401 __u32 spi;
402 __u16 family;
403 __u16 ext;
404 union {
405 __u32 remote_ipv4;
406 __u32 remote_ipv6[4];
407 };
408};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800409enum bpf_ret_code {
410 BPF_OK = 0,
411 BPF_DROP = 2,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800412 BPF_REDIRECT = 7,
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700413 BPF_LWT_REROUTE = 128,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800414};
415struct bpf_sock {
416 __u32 bound_dev_if;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800417 __u32 family;
418 __u32 type;
419 __u32 protocol;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800420 __u32 mark;
421 __u32 priority;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700422 __u32 src_ip4;
423 __u32 src_ip6[4];
424 __u32 src_port;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700425 __u32 dst_port;
426 __u32 dst_ip4;
427 __u32 dst_ip6[4];
428 __u32 state;
429};
430struct bpf_tcp_sock {
431 __u32 snd_cwnd;
432 __u32 srtt_us;
433 __u32 rtt_min;
434 __u32 snd_ssthresh;
435 __u32 rcv_nxt;
436 __u32 snd_nxt;
437 __u32 snd_una;
438 __u32 mss_cache;
439 __u32 ecn_flags;
440 __u32 rate_delivered;
441 __u32 rate_interval_us;
442 __u32 packets_out;
443 __u32 retrans_out;
444 __u32 total_retrans;
445 __u32 segs_in;
446 __u32 data_segs_in;
447 __u32 segs_out;
448 __u32 data_segs_out;
449 __u32 lost_out;
450 __u32 sacked_out;
451 __u64 bytes_received;
452 __u64 bytes_acked;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800453};
Christopher Ferris86a48372019-01-10 14:14:59 -0800454struct bpf_sock_tuple {
455 union {
456 struct {
457 __be32 saddr;
458 __be32 daddr;
459 __be16 sport;
460 __be16 dport;
461 } ipv4;
462 struct {
463 __be32 saddr[4];
464 __be32 daddr[4];
465 __be16 sport;
466 __be16 dport;
467 } ipv6;
468 };
469};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800470#define XDP_PACKET_HEADROOM 256
Christopher Ferris49f525c2016-12-12 14:55:36 -0800471enum xdp_action {
472 XDP_ABORTED = 0,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800473 XDP_DROP,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800474 XDP_PASS,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800475 XDP_TX,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800476 XDP_REDIRECT,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800477};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800478struct xdp_md {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800479 __u32 data;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800480 __u32 data_end;
Christopher Ferris934ec942018-01-31 15:29:16 -0800481 __u32 data_meta;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700482 __u32 ingress_ifindex;
483 __u32 rx_queue_index;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800484};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800485enum sk_action {
486 SK_DROP = 0,
487 SK_PASS,
488};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700489struct sk_msg_md {
Christopher Ferris86a48372019-01-10 14:14:59 -0800490 __bpf_md_ptr(void *, data);
491 __bpf_md_ptr(void *, data_end);
Christopher Ferris9ce28842018-10-25 12:11:39 -0700492 __u32 family;
493 __u32 remote_ip4;
494 __u32 local_ip4;
495 __u32 remote_ip6[4];
496 __u32 local_ip6[4];
497 __u32 remote_port;
498 __u32 local_port;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800499 __u32 size;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700500};
501struct sk_reuseport_md {
Christopher Ferris86a48372019-01-10 14:14:59 -0800502 __bpf_md_ptr(void *, data);
503 __bpf_md_ptr(void *, data_end);
Christopher Ferris9ce28842018-10-25 12:11:39 -0700504 __u32 len;
505 __u32 eth_protocol;
506 __u32 ip_protocol;
507 __u32 bind_inany;
508 __u32 hash;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700509};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800510#define BPF_TAG_SIZE 8
511struct bpf_prog_info {
512 __u32 type;
513 __u32 id;
514 __u8 tag[BPF_TAG_SIZE];
515 __u32 jited_prog_len;
516 __u32 xlated_prog_len;
517 __aligned_u64 jited_prog_insns;
518 __aligned_u64 xlated_prog_insns;
Christopher Ferris934ec942018-01-31 15:29:16 -0800519 __u64 load_time;
520 __u32 created_by_uid;
521 __u32 nr_map_ids;
522 __aligned_u64 map_ids;
523 char name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700524 __u32 ifindex;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700525 __u32 gpl_compatible : 1;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700526 __u64 netns_dev;
527 __u64 netns_ino;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700528 __u32 nr_jited_ksyms;
529 __u32 nr_jited_func_lens;
530 __aligned_u64 jited_ksyms;
531 __aligned_u64 jited_func_lens;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800532 __u32 btf_id;
533 __u32 func_info_rec_size;
534 __aligned_u64 func_info;
535 __u32 nr_func_info;
536 __u32 nr_line_info;
537 __aligned_u64 line_info;
538 __aligned_u64 jited_line_info;
539 __u32 nr_jited_line_info;
540 __u32 line_info_rec_size;
541 __u32 jited_line_info_rec_size;
542 __u32 nr_prog_tags;
543 __aligned_u64 prog_tags;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700544 __u64 run_time_ns;
545 __u64 run_cnt;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800546} __attribute__((aligned(8)));
547struct bpf_map_info {
548 __u32 type;
549 __u32 id;
550 __u32 key_size;
551 __u32 value_size;
552 __u32 max_entries;
553 __u32 map_flags;
Christopher Ferris934ec942018-01-31 15:29:16 -0800554 char name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700555 __u32 ifindex;
556 __u32 : 32;
557 __u64 netns_dev;
558 __u64 netns_ino;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700559 __u32 btf_id;
560 __u32 btf_key_type_id;
561 __u32 btf_value_type_id;
562} __attribute__((aligned(8)));
563struct bpf_btf_info {
564 __aligned_u64 btf;
565 __u32 btf_size;
566 __u32 id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800567} __attribute__((aligned(8)));
Christopher Ferris76a1d452018-06-27 14:12:29 -0700568struct bpf_sock_addr {
569 __u32 user_family;
570 __u32 user_ip4;
571 __u32 user_ip6[4];
572 __u32 user_port;
573 __u32 family;
574 __u32 type;
575 __u32 protocol;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700576 __u32 msg_src_ip4;
577 __u32 msg_src_ip6[4];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700578};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800579struct bpf_sock_ops {
580 __u32 op;
581 union {
Christopher Ferris76a1d452018-06-27 14:12:29 -0700582 __u32 args[4];
Christopher Ferris1308ad32017-11-14 17:32:13 -0800583 __u32 reply;
584 __u32 replylong[4];
585 };
586 __u32 family;
587 __u32 remote_ip4;
588 __u32 local_ip4;
589 __u32 remote_ip6[4];
590 __u32 local_ip6[4];
591 __u32 remote_port;
592 __u32 local_port;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700593 __u32 is_fullsock;
594 __u32 snd_cwnd;
595 __u32 srtt_us;
596 __u32 bpf_sock_ops_cb_flags;
597 __u32 state;
598 __u32 rtt_min;
599 __u32 snd_ssthresh;
600 __u32 rcv_nxt;
601 __u32 snd_nxt;
602 __u32 snd_una;
603 __u32 mss_cache;
604 __u32 ecn_flags;
605 __u32 rate_delivered;
606 __u32 rate_interval_us;
607 __u32 packets_out;
608 __u32 retrans_out;
609 __u32 total_retrans;
610 __u32 segs_in;
611 __u32 data_segs_in;
612 __u32 segs_out;
613 __u32 data_segs_out;
614 __u32 lost_out;
615 __u32 sacked_out;
616 __u32 sk_txhash;
617 __u64 bytes_received;
618 __u64 bytes_acked;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800619};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700620#define BPF_SOCK_OPS_RTO_CB_FLAG (1 << 0)
621#define BPF_SOCK_OPS_RETRANS_CB_FLAG (1 << 1)
622#define BPF_SOCK_OPS_STATE_CB_FLAG (1 << 2)
623#define BPF_SOCK_OPS_ALL_CB_FLAGS 0x7
Christopher Ferris1308ad32017-11-14 17:32:13 -0800624enum {
625 BPF_SOCK_OPS_VOID,
626 BPF_SOCK_OPS_TIMEOUT_INIT,
627 BPF_SOCK_OPS_RWND_INIT,
628 BPF_SOCK_OPS_TCP_CONNECT_CB,
629 BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB,
630 BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB,
631 BPF_SOCK_OPS_NEEDS_ECN,
Christopher Ferris934ec942018-01-31 15:29:16 -0800632 BPF_SOCK_OPS_BASE_RTT,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700633 BPF_SOCK_OPS_RTO_CB,
634 BPF_SOCK_OPS_RETRANS_CB,
635 BPF_SOCK_OPS_STATE_CB,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700636 BPF_SOCK_OPS_TCP_LISTEN_CB,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700637};
638enum {
639 BPF_TCP_ESTABLISHED = 1,
640 BPF_TCP_SYN_SENT,
641 BPF_TCP_SYN_RECV,
642 BPF_TCP_FIN_WAIT1,
643 BPF_TCP_FIN_WAIT2,
644 BPF_TCP_TIME_WAIT,
645 BPF_TCP_CLOSE,
646 BPF_TCP_CLOSE_WAIT,
647 BPF_TCP_LAST_ACK,
648 BPF_TCP_LISTEN,
649 BPF_TCP_CLOSING,
650 BPF_TCP_NEW_SYN_RECV,
651 BPF_TCP_MAX_STATES
Christopher Ferris1308ad32017-11-14 17:32:13 -0800652};
653#define TCP_BPF_IW 1001
654#define TCP_BPF_SNDCWND_CLAMP 1002
Christopher Ferris934ec942018-01-31 15:29:16 -0800655struct bpf_perf_event_value {
656 __u64 counter;
657 __u64 enabled;
658 __u64 running;
659};
660#define BPF_DEVCG_ACC_MKNOD (1ULL << 0)
661#define BPF_DEVCG_ACC_READ (1ULL << 1)
662#define BPF_DEVCG_ACC_WRITE (1ULL << 2)
663#define BPF_DEVCG_DEV_BLOCK (1ULL << 0)
664#define BPF_DEVCG_DEV_CHAR (1ULL << 1)
665struct bpf_cgroup_dev_ctx {
666 __u32 access_type;
667 __u32 major;
668 __u32 minor;
669};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700670struct bpf_raw_tracepoint_args {
671 __u64 args[0];
672};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700673#define BPF_FIB_LOOKUP_DIRECT BIT(0)
674#define BPF_FIB_LOOKUP_OUTPUT BIT(1)
675enum {
676 BPF_FIB_LKUP_RET_SUCCESS,
677 BPF_FIB_LKUP_RET_BLACKHOLE,
678 BPF_FIB_LKUP_RET_UNREACHABLE,
679 BPF_FIB_LKUP_RET_PROHIBIT,
680 BPF_FIB_LKUP_RET_NOT_FWDED,
681 BPF_FIB_LKUP_RET_FWD_DISABLED,
682 BPF_FIB_LKUP_RET_UNSUPP_LWT,
683 BPF_FIB_LKUP_RET_NO_NEIGH,
684 BPF_FIB_LKUP_RET_FRAG_NEEDED,
685};
686struct bpf_fib_lookup {
687 __u8 family;
688 __u8 l4_protocol;
689 __be16 sport;
690 __be16 dport;
691 __u16 tot_len;
692 __u32 ifindex;
693 union {
694 __u8 tos;
695 __be32 flowinfo;
696 __u32 rt_metric;
697 };
698 union {
699 __be32 ipv4_src;
700 __u32 ipv6_src[4];
701 };
702 union {
703 __be32 ipv4_dst;
704 __u32 ipv6_dst[4];
705 };
706 __be16 h_vlan_proto;
707 __be16 h_vlan_TCI;
708 __u8 smac[6];
709 __u8 dmac[6];
710};
711enum bpf_task_fd_type {
712 BPF_FD_TYPE_RAW_TRACEPOINT,
713 BPF_FD_TYPE_TRACEPOINT,
714 BPF_FD_TYPE_KPROBE,
715 BPF_FD_TYPE_KRETPROBE,
716 BPF_FD_TYPE_UPROBE,
717 BPF_FD_TYPE_URETPROBE,
718};
Christopher Ferris86a48372019-01-10 14:14:59 -0800719struct bpf_flow_keys {
720 __u16 nhoff;
721 __u16 thoff;
722 __u16 addr_proto;
723 __u8 is_frag;
724 __u8 is_first_frag;
725 __u8 is_encap;
726 __u8 ip_proto;
727 __be16 n_proto;
728 __be16 sport;
729 __be16 dport;
730 union {
731 struct {
732 __be32 ipv4_src;
733 __be32 ipv4_dst;
734 };
735 struct {
736 __u32 ipv6_src[4];
737 __u32 ipv6_dst[4];
738 };
739 };
740};
Christopher Ferrisd842e432019-03-07 10:21:59 -0800741struct bpf_func_info {
742 __u32 insn_off;
743 __u32 type_id;
744};
745#define BPF_LINE_INFO_LINE_NUM(line_col) ((line_col) >> 10)
746#define BPF_LINE_INFO_LINE_COL(line_col) ((line_col) & 0x3ff)
747struct bpf_line_info {
748 __u32 insn_off;
749 __u32 file_name_off;
750 __u32 line_off;
751 __u32 line_col;
752};
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700753struct bpf_spin_lock {
754 __u32 val;
755};
Christopher Ferris82d75042015-01-26 10:57:07 -0800756#endif