blob: bebab62fe728e082c4b688a852d765bacbf292e3 [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 Ferrisaeddbcf2019-07-08 12:45:46 -070096 BPF_MAP_FREEZE,
Christopher Ferris9584fa42019-12-09 15:36:13 -080097 BPF_BTF_GET_NEXT_ID,
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -070098 BPF_MAP_LOOKUP_BATCH,
99 BPF_MAP_LOOKUP_AND_DELETE_BATCH,
100 BPF_MAP_UPDATE_BATCH,
101 BPF_MAP_DELETE_BATCH,
Christopher Ferris82d75042015-01-26 10:57:07 -0800102};
103enum bpf_map_type {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800104 BPF_MAP_TYPE_UNSPEC,
105 BPF_MAP_TYPE_HASH,
106 BPF_MAP_TYPE_ARRAY,
107 BPF_MAP_TYPE_PROG_ARRAY,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800108 BPF_MAP_TYPE_PERF_EVENT_ARRAY,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700109 BPF_MAP_TYPE_PERCPU_HASH,
110 BPF_MAP_TYPE_PERCPU_ARRAY,
111 BPF_MAP_TYPE_STACK_TRACE,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800112 BPF_MAP_TYPE_CGROUP_ARRAY,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800113 BPF_MAP_TYPE_LRU_HASH,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800114 BPF_MAP_TYPE_LRU_PERCPU_HASH,
Christopher Ferris525ce912017-07-26 13:12:53 -0700115 BPF_MAP_TYPE_LPM_TRIE,
116 BPF_MAP_TYPE_ARRAY_OF_MAPS,
117 BPF_MAP_TYPE_HASH_OF_MAPS,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800118 BPF_MAP_TYPE_DEVMAP,
119 BPF_MAP_TYPE_SOCKMAP,
Christopher Ferris934ec942018-01-31 15:29:16 -0800120 BPF_MAP_TYPE_CPUMAP,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700121 BPF_MAP_TYPE_XSKMAP,
122 BPF_MAP_TYPE_SOCKHASH,
123 BPF_MAP_TYPE_CGROUP_STORAGE,
124 BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,
Christopher Ferris86a48372019-01-10 14:14:59 -0800125 BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,
126 BPF_MAP_TYPE_QUEUE,
127 BPF_MAP_TYPE_STACK,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700128 BPF_MAP_TYPE_SK_STORAGE,
Christopher Ferris9584fa42019-12-09 15:36:13 -0800129 BPF_MAP_TYPE_DEVMAP_HASH,
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700130 BPF_MAP_TYPE_STRUCT_OPS,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800131};
Christopher Ferris82d75042015-01-26 10:57:07 -0800132enum bpf_prog_type {
Tao Baod7db5942015-01-28 10:07:51 -0800133 BPF_PROG_TYPE_UNSPEC,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800134 BPF_PROG_TYPE_SOCKET_FILTER,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800135 BPF_PROG_TYPE_KPROBE,
136 BPF_PROG_TYPE_SCHED_CLS,
137 BPF_PROG_TYPE_SCHED_ACT,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800138 BPF_PROG_TYPE_TRACEPOINT,
139 BPF_PROG_TYPE_XDP,
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800140 BPF_PROG_TYPE_PERF_EVENT,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800141 BPF_PROG_TYPE_CGROUP_SKB,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800142 BPF_PROG_TYPE_CGROUP_SOCK,
143 BPF_PROG_TYPE_LWT_IN,
144 BPF_PROG_TYPE_LWT_OUT,
145 BPF_PROG_TYPE_LWT_XMIT,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800146 BPF_PROG_TYPE_SOCK_OPS,
147 BPF_PROG_TYPE_SK_SKB,
Christopher Ferris934ec942018-01-31 15:29:16 -0800148 BPF_PROG_TYPE_CGROUP_DEVICE,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700149 BPF_PROG_TYPE_SK_MSG,
150 BPF_PROG_TYPE_RAW_TRACEPOINT,
151 BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700152 BPF_PROG_TYPE_LWT_SEG6LOCAL,
153 BPF_PROG_TYPE_LIRC_MODE2,
154 BPF_PROG_TYPE_SK_REUSEPORT,
Christopher Ferris86a48372019-01-10 14:14:59 -0800155 BPF_PROG_TYPE_FLOW_DISSECTOR,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700156 BPF_PROG_TYPE_CGROUP_SYSCTL,
157 BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE,
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700158 BPF_PROG_TYPE_CGROUP_SOCKOPT,
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800159 BPF_PROG_TYPE_TRACING,
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700160 BPF_PROG_TYPE_STRUCT_OPS,
161 BPF_PROG_TYPE_EXT,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800162};
163enum bpf_attach_type {
164 BPF_CGROUP_INET_INGRESS,
165 BPF_CGROUP_INET_EGRESS,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800166 BPF_CGROUP_INET_SOCK_CREATE,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800167 BPF_CGROUP_SOCK_OPS,
168 BPF_SK_SKB_STREAM_PARSER,
169 BPF_SK_SKB_STREAM_VERDICT,
Christopher Ferris934ec942018-01-31 15:29:16 -0800170 BPF_CGROUP_DEVICE,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700171 BPF_SK_MSG_VERDICT,
172 BPF_CGROUP_INET4_BIND,
173 BPF_CGROUP_INET6_BIND,
174 BPF_CGROUP_INET4_CONNECT,
175 BPF_CGROUP_INET6_CONNECT,
176 BPF_CGROUP_INET4_POST_BIND,
177 BPF_CGROUP_INET6_POST_BIND,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700178 BPF_CGROUP_UDP4_SENDMSG,
179 BPF_CGROUP_UDP6_SENDMSG,
180 BPF_LIRC_MODE2,
Christopher Ferris86a48372019-01-10 14:14:59 -0800181 BPF_FLOW_DISSECTOR,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700182 BPF_CGROUP_SYSCTL,
183 BPF_CGROUP_UDP4_RECVMSG,
184 BPF_CGROUP_UDP6_RECVMSG,
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700185 BPF_CGROUP_GETSOCKOPT,
186 BPF_CGROUP_SETSOCKOPT,
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800187 BPF_TRACE_RAW_TP,
188 BPF_TRACE_FENTRY,
189 BPF_TRACE_FEXIT,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800190 __MAX_BPF_ATTACH_TYPE
191};
192#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800193#define BPF_F_ALLOW_OVERRIDE (1U << 0)
Christopher Ferris934ec942018-01-31 15:29:16 -0800194#define BPF_F_ALLOW_MULTI (1U << 1)
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700195#define BPF_F_REPLACE (1U << 2)
Christopher Ferris525ce912017-07-26 13:12:53 -0700196#define BPF_F_STRICT_ALIGNMENT (1U << 0)
Christopher Ferrisd842e432019-03-07 10:21:59 -0800197#define BPF_F_ANY_ALIGNMENT (1U << 1)
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700198#define BPF_F_TEST_RND_HI32 (1U << 2)
Christopher Ferris9584fa42019-12-09 15:36:13 -0800199#define BPF_F_TEST_STATE_FREQ (1U << 3)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800200#define BPF_PSEUDO_MAP_FD 1
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700201#define BPF_PSEUDO_MAP_VALUE 2
Christopher Ferris76a1d452018-06-27 14:12:29 -0700202#define BPF_PSEUDO_CALL 1
Christopher Ferris05d08e92016-02-04 13:16:38 -0800203#define BPF_ANY 0
204#define BPF_NOEXIST 1
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800205#define BPF_EXIST 2
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700206#define BPF_F_LOCK 4
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800207#define BPF_F_NO_PREALLOC (1U << 0)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800208#define BPF_F_NO_COMMON_LRU (1U << 1)
Christopher Ferris1308ad32017-11-14 17:32:13 -0800209#define BPF_F_NUMA_NODE (1U << 2)
Christopher Ferris934ec942018-01-31 15:29:16 -0800210#define BPF_OBJ_NAME_LEN 16U
211#define BPF_F_RDONLY (1U << 3)
212#define BPF_F_WRONLY (1U << 4)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700213#define BPF_F_STACK_BUILD_ID (1U << 5)
Christopher Ferrisd842e432019-03-07 10:21:59 -0800214#define BPF_F_ZERO_SEED (1U << 6)
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700215#define BPF_F_RDONLY_PROG (1U << 7)
216#define BPF_F_WRONLY_PROG (1U << 8)
Christopher Ferris9584fa42019-12-09 15:36:13 -0800217#define BPF_F_CLONE (1U << 9)
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800218#define BPF_F_MMAPABLE (1U << 10)
Christopher Ferrisd842e432019-03-07 10:21:59 -0800219#define BPF_F_QUERY_EFFECTIVE (1U << 0)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700220enum bpf_stack_build_id_status {
221 BPF_STACK_BUILD_ID_EMPTY = 0,
222 BPF_STACK_BUILD_ID_VALID = 1,
223 BPF_STACK_BUILD_ID_IP = 2,
224};
225#define BPF_BUILD_ID_SIZE 20
226struct bpf_stack_build_id {
227 __s32 status;
228 unsigned char build_id[BPF_BUILD_ID_SIZE];
229 union {
230 __u64 offset;
231 __u64 ip;
232 };
233};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800234union bpf_attr {
Tao Baod7db5942015-01-28 10:07:51 -0800235 struct {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700236 __u32 map_type;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800237 __u32 key_size;
Tao Baod7db5942015-01-28 10:07:51 -0800238 __u32 value_size;
Tao Baod7db5942015-01-28 10:07:51 -0800239 __u32 max_entries;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700240 __u32 map_flags;
Christopher Ferris525ce912017-07-26 13:12:53 -0700241 __u32 inner_map_fd;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800242 __u32 numa_node;
Christopher Ferris934ec942018-01-31 15:29:16 -0800243 char map_name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700244 __u32 map_ifindex;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700245 __u32 btf_fd;
246 __u32 btf_key_type_id;
247 __u32 btf_value_type_id;
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700248 __u32 btf_vmlinux_value_type_id;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800249 };
Tao Baod7db5942015-01-28 10:07:51 -0800250 struct {
251 __u32 map_fd;
Tao Baod7db5942015-01-28 10:07:51 -0800252 __aligned_u64 key;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800253 union {
Tao Baod7db5942015-01-28 10:07:51 -0800254 __aligned_u64 value;
255 __aligned_u64 next_key;
Tao Baod7db5942015-01-28 10:07:51 -0800256 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800257 __u64 flags;
Tao Baod7db5942015-01-28 10:07:51 -0800258 };
259 struct {
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700260 __aligned_u64 in_batch;
261 __aligned_u64 out_batch;
262 __aligned_u64 keys;
263 __aligned_u64 values;
264 __u32 count;
265 __u32 map_fd;
266 __u64 elem_flags;
267 __u64 flags;
268 } batch;
269 struct {
Tao Baod7db5942015-01-28 10:07:51 -0800270 __u32 prog_type;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800271 __u32 insn_cnt;
Tao Baod7db5942015-01-28 10:07:51 -0800272 __aligned_u64 insns;
273 __aligned_u64 license;
274 __u32 log_level;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800275 __u32 log_size;
Tao Baod7db5942015-01-28 10:07:51 -0800276 __aligned_u64 log_buf;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800277 __u32 kern_version;
Christopher Ferris525ce912017-07-26 13:12:53 -0700278 __u32 prog_flags;
Christopher Ferris934ec942018-01-31 15:29:16 -0800279 char prog_name[BPF_OBJ_NAME_LEN];
280 __u32 prog_ifindex;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700281 __u32 expected_attach_type;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800282 __u32 prog_btf_fd;
283 __u32 func_info_rec_size;
284 __aligned_u64 func_info;
285 __u32 func_info_cnt;
286 __u32 line_info_rec_size;
287 __aligned_u64 line_info;
288 __u32 line_info_cnt;
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800289 __u32 attach_btf_id;
290 __u32 attach_prog_fd;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800291 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800292 struct {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800293 __aligned_u64 pathname;
294 __u32 bpf_fd;
Christopher Ferris934ec942018-01-31 15:29:16 -0800295 __u32 file_flags;
Tao Baod7db5942015-01-28 10:07:51 -0800296 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800297 struct {
298 __u32 target_fd;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800299 __u32 attach_bpf_fd;
300 __u32 attach_type;
301 __u32 attach_flags;
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700302 __u32 replace_bpf_fd;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800303 };
Christopher Ferris525ce912017-07-26 13:12:53 -0700304 struct {
305 __u32 prog_fd;
306 __u32 retval;
307 __u32 data_size_in;
308 __u32 data_size_out;
309 __aligned_u64 data_in;
310 __aligned_u64 data_out;
311 __u32 repeat;
312 __u32 duration;
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700313 __u32 ctx_size_in;
314 __u32 ctx_size_out;
315 __aligned_u64 ctx_in;
316 __aligned_u64 ctx_out;
Christopher Ferris525ce912017-07-26 13:12:53 -0700317 } test;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800318 struct {
319 union {
320 __u32 start_id;
321 __u32 prog_id;
322 __u32 map_id;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700323 __u32 btf_id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800324 };
325 __u32 next_id;
Christopher Ferris934ec942018-01-31 15:29:16 -0800326 __u32 open_flags;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800327 };
328 struct {
329 __u32 bpf_fd;
330 __u32 info_len;
331 __aligned_u64 info;
332 } info;
Christopher Ferris934ec942018-01-31 15:29:16 -0800333 struct {
334 __u32 target_fd;
335 __u32 attach_type;
336 __u32 query_flags;
337 __u32 attach_flags;
338 __aligned_u64 prog_ids;
339 __u32 prog_cnt;
340 } query;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700341 struct {
342 __u64 name;
343 __u32 prog_fd;
344 } raw_tracepoint;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700345 struct {
346 __aligned_u64 btf;
347 __aligned_u64 btf_log_buf;
348 __u32 btf_size;
349 __u32 btf_log_size;
350 __u32 btf_log_level;
351 };
352 struct {
353 __u32 pid;
354 __u32 fd;
355 __u32 flags;
356 __u32 buf_len;
357 __aligned_u64 buf;
358 __u32 prog_id;
359 __u32 fd_type;
360 __u64 probe_offset;
361 __u64 probe_addr;
362 } task_fd_query;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800363} __attribute__((aligned(8)));
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700364#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), FN(skc_lookup_tcp), FN(tcp_check_syncookie), FN(sysctl_get_name), FN(sysctl_get_current_value), FN(sysctl_get_new_value), FN(sysctl_set_new_value), FN(strtol), FN(strtoul), FN(sk_storage_get), FN(sk_storage_delete), FN(send_signal), FN(tcp_gen_syncookie), FN(skb_output), FN(probe_read_user), FN(probe_read_kernel), FN(probe_read_user_str), FN(probe_read_kernel_str), FN(tcp_send_ack), FN(send_signal_thread), FN(jiffies64),
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800365#define __BPF_ENUM_FN(x) BPF_FUNC_ ##x
Christopher Ferris82d75042015-01-26 10:57:07 -0800366enum bpf_func_id {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800367 __BPF_FUNC_MAPPER(__BPF_ENUM_FN) __BPF_FUNC_MAX_ID,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800368};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800369#undef __BPF_ENUM_FN
Christopher Ferris106b3a82016-08-24 12:15:38 -0700370#define BPF_F_RECOMPUTE_CSUM (1ULL << 0)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800371#define BPF_F_INVALIDATE_HASH (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700372#define BPF_F_HDR_FIELD_MASK 0xfULL
373#define BPF_F_PSEUDO_HDR (1ULL << 4)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700374#define BPF_F_MARK_MANGLED_0 (1ULL << 5)
Christopher Ferris525ce912017-07-26 13:12:53 -0700375#define BPF_F_MARK_ENFORCE (1ULL << 6)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800376#define BPF_F_INGRESS (1ULL << 0)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700377#define BPF_F_TUNINFO_IPV6 (1ULL << 0)
378#define BPF_F_SKIP_FIELD_MASK 0xffULL
Christopher Ferris106b3a82016-08-24 12:15:38 -0700379#define BPF_F_USER_STACK (1ULL << 8)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800380#define BPF_F_FAST_STACK_CMP (1ULL << 9)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700381#define BPF_F_REUSE_STACKID (1ULL << 10)
Christopher Ferris9ce28842018-10-25 12:11:39 -0700382#define BPF_F_USER_BUILD_ID (1ULL << 11)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700383#define BPF_F_ZERO_CSUM_TX (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700384#define BPF_F_DONT_FRAGMENT (1ULL << 2)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700385#define BPF_F_SEQ_NUMBER (1ULL << 3)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800386#define BPF_F_INDEX_MASK 0xffffffffULL
Christopher Ferris106b3a82016-08-24 12:15:38 -0700387#define BPF_F_CURRENT_CPU BPF_F_INDEX_MASK
Christopher Ferris49f525c2016-12-12 14:55:36 -0800388#define BPF_F_CTXLEN_MASK (0xfffffULL << 32)
Christopher Ferris86a48372019-01-10 14:14:59 -0800389#define BPF_F_CURRENT_NETNS (- 1L)
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700390#define BPF_F_ADJ_ROOM_FIXED_GSO (1ULL << 0)
391#define BPF_ADJ_ROOM_ENCAP_L2_MASK 0xff
392#define BPF_ADJ_ROOM_ENCAP_L2_SHIFT 56
393#define BPF_F_ADJ_ROOM_ENCAP_L3_IPV4 (1ULL << 1)
394#define BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 (1ULL << 2)
395#define BPF_F_ADJ_ROOM_ENCAP_L4_GRE (1ULL << 3)
396#define BPF_F_ADJ_ROOM_ENCAP_L4_UDP (1ULL << 4)
397#define BPF_F_ADJ_ROOM_ENCAP_L2(len) (((__u64) len & BPF_ADJ_ROOM_ENCAP_L2_MASK) << BPF_ADJ_ROOM_ENCAP_L2_SHIFT)
398#define BPF_F_SYSCTL_BASE_NAME (1ULL << 0)
399#define BPF_SK_STORAGE_GET_F_CREATE (1ULL << 0)
Christopher Ferris1308ad32017-11-14 17:32:13 -0800400enum bpf_adj_room_mode {
401 BPF_ADJ_ROOM_NET,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700402 BPF_ADJ_ROOM_MAC,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800403};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700404enum bpf_hdr_start_off {
405 BPF_HDR_START_MAC,
406 BPF_HDR_START_NET,
407};
408enum bpf_lwt_encap_mode {
409 BPF_LWT_ENCAP_SEG6,
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700410 BPF_LWT_ENCAP_SEG6_INLINE,
411 BPF_LWT_ENCAP_IP,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700412};
Christopher Ferris86a48372019-01-10 14:14:59 -0800413#define __bpf_md_ptr(type,name) union { type name; __u64 : 64; \
414} __attribute__((aligned(8)))
Christopher Ferris49f525c2016-12-12 14:55:36 -0800415struct __sk_buff {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800416 __u32 len;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800417 __u32 pkt_type;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800418 __u32 mark;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800419 __u32 queue_mapping;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800420 __u32 protocol;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800421 __u32 vlan_present;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800422 __u32 vlan_tci;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800423 __u32 vlan_proto;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800424 __u32 priority;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800425 __u32 ingress_ifindex;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800426 __u32 ifindex;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800427 __u32 tc_index;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800428 __u32 cb[5];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800429 __u32 hash;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800430 __u32 tc_classid;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800431 __u32 data;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800432 __u32 data_end;
Christopher Ferris525ce912017-07-26 13:12:53 -0700433 __u32 napi_id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800434 __u32 family;
435 __u32 remote_ip4;
436 __u32 local_ip4;
437 __u32 remote_ip6[4];
438 __u32 local_ip6[4];
439 __u32 remote_port;
440 __u32 local_port;
Christopher Ferris934ec942018-01-31 15:29:16 -0800441 __u32 data_meta;
Christopher Ferris86a48372019-01-10 14:14:59 -0800442 __bpf_md_ptr(struct bpf_flow_keys *, flow_keys);
Christopher Ferrisd842e432019-03-07 10:21:59 -0800443 __u64 tstamp;
444 __u32 wire_len;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700445 __u32 gso_segs;
446 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferris05d08e92016-02-04 13:16:38 -0800447};
448struct bpf_tunnel_key {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800449 __u32 tunnel_id;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800450 union {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700451 __u32 remote_ipv4;
452 __u32 remote_ipv6[4];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800453 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800454 __u8 tunnel_tos;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700455 __u8 tunnel_ttl;
456 __u16 tunnel_ext;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800457 __u32 tunnel_label;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800458};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700459struct bpf_xfrm_state {
460 __u32 reqid;
461 __u32 spi;
462 __u16 family;
463 __u16 ext;
464 union {
465 __u32 remote_ipv4;
466 __u32 remote_ipv6[4];
467 };
468};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800469enum bpf_ret_code {
470 BPF_OK = 0,
471 BPF_DROP = 2,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800472 BPF_REDIRECT = 7,
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700473 BPF_LWT_REROUTE = 128,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800474};
475struct bpf_sock {
476 __u32 bound_dev_if;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800477 __u32 family;
478 __u32 type;
479 __u32 protocol;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800480 __u32 mark;
481 __u32 priority;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700482 __u32 src_ip4;
483 __u32 src_ip6[4];
484 __u32 src_port;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700485 __u32 dst_port;
486 __u32 dst_ip4;
487 __u32 dst_ip6[4];
488 __u32 state;
489};
490struct bpf_tcp_sock {
491 __u32 snd_cwnd;
492 __u32 srtt_us;
493 __u32 rtt_min;
494 __u32 snd_ssthresh;
495 __u32 rcv_nxt;
496 __u32 snd_nxt;
497 __u32 snd_una;
498 __u32 mss_cache;
499 __u32 ecn_flags;
500 __u32 rate_delivered;
501 __u32 rate_interval_us;
502 __u32 packets_out;
503 __u32 retrans_out;
504 __u32 total_retrans;
505 __u32 segs_in;
506 __u32 data_segs_in;
507 __u32 segs_out;
508 __u32 data_segs_out;
509 __u32 lost_out;
510 __u32 sacked_out;
511 __u64 bytes_received;
512 __u64 bytes_acked;
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700513 __u32 dsack_dups;
514 __u32 delivered;
515 __u32 delivered_ce;
516 __u32 icsk_retransmits;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800517};
Christopher Ferris86a48372019-01-10 14:14:59 -0800518struct bpf_sock_tuple {
519 union {
520 struct {
521 __be32 saddr;
522 __be32 daddr;
523 __be16 sport;
524 __be16 dport;
525 } ipv4;
526 struct {
527 __be32 saddr[4];
528 __be32 daddr[4];
529 __be16 sport;
530 __be16 dport;
531 } ipv6;
532 };
533};
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700534struct bpf_xdp_sock {
535 __u32 queue_id;
536};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800537#define XDP_PACKET_HEADROOM 256
Christopher Ferris49f525c2016-12-12 14:55:36 -0800538enum xdp_action {
539 XDP_ABORTED = 0,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800540 XDP_DROP,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800541 XDP_PASS,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800542 XDP_TX,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800543 XDP_REDIRECT,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800544};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800545struct xdp_md {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800546 __u32 data;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800547 __u32 data_end;
Christopher Ferris934ec942018-01-31 15:29:16 -0800548 __u32 data_meta;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700549 __u32 ingress_ifindex;
550 __u32 rx_queue_index;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800551};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800552enum sk_action {
553 SK_DROP = 0,
554 SK_PASS,
555};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700556struct sk_msg_md {
Christopher Ferris86a48372019-01-10 14:14:59 -0800557 __bpf_md_ptr(void *, data);
558 __bpf_md_ptr(void *, data_end);
Christopher Ferris9ce28842018-10-25 12:11:39 -0700559 __u32 family;
560 __u32 remote_ip4;
561 __u32 local_ip4;
562 __u32 remote_ip6[4];
563 __u32 local_ip6[4];
564 __u32 remote_port;
565 __u32 local_port;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800566 __u32 size;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700567};
568struct sk_reuseport_md {
Christopher Ferris86a48372019-01-10 14:14:59 -0800569 __bpf_md_ptr(void *, data);
570 __bpf_md_ptr(void *, data_end);
Christopher Ferris9ce28842018-10-25 12:11:39 -0700571 __u32 len;
572 __u32 eth_protocol;
573 __u32 ip_protocol;
574 __u32 bind_inany;
575 __u32 hash;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700576};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800577#define BPF_TAG_SIZE 8
578struct bpf_prog_info {
579 __u32 type;
580 __u32 id;
581 __u8 tag[BPF_TAG_SIZE];
582 __u32 jited_prog_len;
583 __u32 xlated_prog_len;
584 __aligned_u64 jited_prog_insns;
585 __aligned_u64 xlated_prog_insns;
Christopher Ferris934ec942018-01-31 15:29:16 -0800586 __u64 load_time;
587 __u32 created_by_uid;
588 __u32 nr_map_ids;
589 __aligned_u64 map_ids;
590 char name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700591 __u32 ifindex;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700592 __u32 gpl_compatible : 1;
Christopher Ferrisfa59a102019-08-05 12:58:49 -0700593 __u32 : 31;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700594 __u64 netns_dev;
595 __u64 netns_ino;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700596 __u32 nr_jited_ksyms;
597 __u32 nr_jited_func_lens;
598 __aligned_u64 jited_ksyms;
599 __aligned_u64 jited_func_lens;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800600 __u32 btf_id;
601 __u32 func_info_rec_size;
602 __aligned_u64 func_info;
603 __u32 nr_func_info;
604 __u32 nr_line_info;
605 __aligned_u64 line_info;
606 __aligned_u64 jited_line_info;
607 __u32 nr_jited_line_info;
608 __u32 line_info_rec_size;
609 __u32 jited_line_info_rec_size;
610 __u32 nr_prog_tags;
611 __aligned_u64 prog_tags;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700612 __u64 run_time_ns;
613 __u64 run_cnt;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800614} __attribute__((aligned(8)));
615struct bpf_map_info {
616 __u32 type;
617 __u32 id;
618 __u32 key_size;
619 __u32 value_size;
620 __u32 max_entries;
621 __u32 map_flags;
Christopher Ferris934ec942018-01-31 15:29:16 -0800622 char name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700623 __u32 ifindex;
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700624 __u32 btf_vmlinux_value_type_id;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700625 __u64 netns_dev;
626 __u64 netns_ino;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700627 __u32 btf_id;
628 __u32 btf_key_type_id;
629 __u32 btf_value_type_id;
630} __attribute__((aligned(8)));
631struct bpf_btf_info {
632 __aligned_u64 btf;
633 __u32 btf_size;
634 __u32 id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800635} __attribute__((aligned(8)));
Christopher Ferris76a1d452018-06-27 14:12:29 -0700636struct bpf_sock_addr {
637 __u32 user_family;
638 __u32 user_ip4;
639 __u32 user_ip6[4];
640 __u32 user_port;
641 __u32 family;
642 __u32 type;
643 __u32 protocol;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700644 __u32 msg_src_ip4;
645 __u32 msg_src_ip6[4];
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700646 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferris76a1d452018-06-27 14:12:29 -0700647};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800648struct bpf_sock_ops {
649 __u32 op;
650 union {
Christopher Ferris76a1d452018-06-27 14:12:29 -0700651 __u32 args[4];
Christopher Ferris1308ad32017-11-14 17:32:13 -0800652 __u32 reply;
653 __u32 replylong[4];
654 };
655 __u32 family;
656 __u32 remote_ip4;
657 __u32 local_ip4;
658 __u32 remote_ip6[4];
659 __u32 local_ip6[4];
660 __u32 remote_port;
661 __u32 local_port;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700662 __u32 is_fullsock;
663 __u32 snd_cwnd;
664 __u32 srtt_us;
665 __u32 bpf_sock_ops_cb_flags;
666 __u32 state;
667 __u32 rtt_min;
668 __u32 snd_ssthresh;
669 __u32 rcv_nxt;
670 __u32 snd_nxt;
671 __u32 snd_una;
672 __u32 mss_cache;
673 __u32 ecn_flags;
674 __u32 rate_delivered;
675 __u32 rate_interval_us;
676 __u32 packets_out;
677 __u32 retrans_out;
678 __u32 total_retrans;
679 __u32 segs_in;
680 __u32 data_segs_in;
681 __u32 segs_out;
682 __u32 data_segs_out;
683 __u32 lost_out;
684 __u32 sacked_out;
685 __u32 sk_txhash;
686 __u64 bytes_received;
687 __u64 bytes_acked;
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700688 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferris1308ad32017-11-14 17:32:13 -0800689};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700690#define BPF_SOCK_OPS_RTO_CB_FLAG (1 << 0)
691#define BPF_SOCK_OPS_RETRANS_CB_FLAG (1 << 1)
692#define BPF_SOCK_OPS_STATE_CB_FLAG (1 << 2)
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700693#define BPF_SOCK_OPS_RTT_CB_FLAG (1 << 3)
694#define BPF_SOCK_OPS_ALL_CB_FLAGS 0xF
Christopher Ferris1308ad32017-11-14 17:32:13 -0800695enum {
696 BPF_SOCK_OPS_VOID,
697 BPF_SOCK_OPS_TIMEOUT_INIT,
698 BPF_SOCK_OPS_RWND_INIT,
699 BPF_SOCK_OPS_TCP_CONNECT_CB,
700 BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB,
701 BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB,
702 BPF_SOCK_OPS_NEEDS_ECN,
Christopher Ferris934ec942018-01-31 15:29:16 -0800703 BPF_SOCK_OPS_BASE_RTT,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700704 BPF_SOCK_OPS_RTO_CB,
705 BPF_SOCK_OPS_RETRANS_CB,
706 BPF_SOCK_OPS_STATE_CB,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700707 BPF_SOCK_OPS_TCP_LISTEN_CB,
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700708 BPF_SOCK_OPS_RTT_CB,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700709};
710enum {
711 BPF_TCP_ESTABLISHED = 1,
712 BPF_TCP_SYN_SENT,
713 BPF_TCP_SYN_RECV,
714 BPF_TCP_FIN_WAIT1,
715 BPF_TCP_FIN_WAIT2,
716 BPF_TCP_TIME_WAIT,
717 BPF_TCP_CLOSE,
718 BPF_TCP_CLOSE_WAIT,
719 BPF_TCP_LAST_ACK,
720 BPF_TCP_LISTEN,
721 BPF_TCP_CLOSING,
722 BPF_TCP_NEW_SYN_RECV,
723 BPF_TCP_MAX_STATES
Christopher Ferris1308ad32017-11-14 17:32:13 -0800724};
725#define TCP_BPF_IW 1001
726#define TCP_BPF_SNDCWND_CLAMP 1002
Christopher Ferris934ec942018-01-31 15:29:16 -0800727struct bpf_perf_event_value {
728 __u64 counter;
729 __u64 enabled;
730 __u64 running;
731};
732#define BPF_DEVCG_ACC_MKNOD (1ULL << 0)
733#define BPF_DEVCG_ACC_READ (1ULL << 1)
734#define BPF_DEVCG_ACC_WRITE (1ULL << 2)
735#define BPF_DEVCG_DEV_BLOCK (1ULL << 0)
736#define BPF_DEVCG_DEV_CHAR (1ULL << 1)
737struct bpf_cgroup_dev_ctx {
738 __u32 access_type;
739 __u32 major;
740 __u32 minor;
741};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700742struct bpf_raw_tracepoint_args {
743 __u64 args[0];
744};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700745#define BPF_FIB_LOOKUP_DIRECT (1U << 0)
746#define BPF_FIB_LOOKUP_OUTPUT (1U << 1)
Christopher Ferris9ce28842018-10-25 12:11:39 -0700747enum {
748 BPF_FIB_LKUP_RET_SUCCESS,
749 BPF_FIB_LKUP_RET_BLACKHOLE,
750 BPF_FIB_LKUP_RET_UNREACHABLE,
751 BPF_FIB_LKUP_RET_PROHIBIT,
752 BPF_FIB_LKUP_RET_NOT_FWDED,
753 BPF_FIB_LKUP_RET_FWD_DISABLED,
754 BPF_FIB_LKUP_RET_UNSUPP_LWT,
755 BPF_FIB_LKUP_RET_NO_NEIGH,
756 BPF_FIB_LKUP_RET_FRAG_NEEDED,
757};
758struct bpf_fib_lookup {
759 __u8 family;
760 __u8 l4_protocol;
761 __be16 sport;
762 __be16 dport;
763 __u16 tot_len;
764 __u32 ifindex;
765 union {
766 __u8 tos;
767 __be32 flowinfo;
768 __u32 rt_metric;
769 };
770 union {
771 __be32 ipv4_src;
772 __u32 ipv6_src[4];
773 };
774 union {
775 __be32 ipv4_dst;
776 __u32 ipv6_dst[4];
777 };
778 __be16 h_vlan_proto;
779 __be16 h_vlan_TCI;
780 __u8 smac[6];
781 __u8 dmac[6];
782};
783enum bpf_task_fd_type {
784 BPF_FD_TYPE_RAW_TRACEPOINT,
785 BPF_FD_TYPE_TRACEPOINT,
786 BPF_FD_TYPE_KPROBE,
787 BPF_FD_TYPE_KRETPROBE,
788 BPF_FD_TYPE_UPROBE,
789 BPF_FD_TYPE_URETPROBE,
790};
Christopher Ferris9584fa42019-12-09 15:36:13 -0800791#define BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG (1U << 0)
792#define BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL (1U << 1)
793#define BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP (1U << 2)
Christopher Ferris86a48372019-01-10 14:14:59 -0800794struct bpf_flow_keys {
795 __u16 nhoff;
796 __u16 thoff;
797 __u16 addr_proto;
798 __u8 is_frag;
799 __u8 is_first_frag;
800 __u8 is_encap;
801 __u8 ip_proto;
802 __be16 n_proto;
803 __be16 sport;
804 __be16 dport;
805 union {
806 struct {
807 __be32 ipv4_src;
808 __be32 ipv4_dst;
809 };
810 struct {
811 __u32 ipv6_src[4];
812 __u32 ipv6_dst[4];
813 };
814 };
Christopher Ferris9584fa42019-12-09 15:36:13 -0800815 __u32 flags;
816 __be32 flow_label;
Christopher Ferris86a48372019-01-10 14:14:59 -0800817};
Christopher Ferrisd842e432019-03-07 10:21:59 -0800818struct bpf_func_info {
819 __u32 insn_off;
820 __u32 type_id;
821};
822#define BPF_LINE_INFO_LINE_NUM(line_col) ((line_col) >> 10)
823#define BPF_LINE_INFO_LINE_COL(line_col) ((line_col) & 0x3ff)
824struct bpf_line_info {
825 __u32 insn_off;
826 __u32 file_name_off;
827 __u32 line_off;
828 __u32 line_col;
829};
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700830struct bpf_spin_lock {
831 __u32 val;
832};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700833struct bpf_sysctl {
834 __u32 write;
835 __u32 file_pos;
836};
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700837struct bpf_sockopt {
838 __bpf_md_ptr(struct bpf_sock *, sk);
839 __bpf_md_ptr(void *, optval);
840 __bpf_md_ptr(void *, optval_end);
841 __s32 level;
842 __s32 optname;
843 __s32 optlen;
844 __s32 retval;
845};
Christopher Ferris82d75042015-01-26 10:57:07 -0800846#endif