blob: 816871abf4398fbb68ef3d3d59d7fd14e4f813a4 [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 Ferris25c18d42020-10-14 17:42:58 -070073union bpf_iter_link_info {
74 struct {
75 __u32 map_fd;
76 } map;
77};
Christopher Ferris82d75042015-01-26 10:57:07 -080078enum bpf_cmd {
Tao Baod7db5942015-01-28 10:07:51 -080079 BPF_MAP_CREATE,
80 BPF_MAP_LOOKUP_ELEM,
Tao Baod7db5942015-01-28 10:07:51 -080081 BPF_MAP_UPDATE_ELEM,
82 BPF_MAP_DELETE_ELEM,
83 BPF_MAP_GET_NEXT_KEY,
84 BPF_PROG_LOAD,
Christopher Ferris05d08e92016-02-04 13:16:38 -080085 BPF_OBJ_PIN,
86 BPF_OBJ_GET,
Christopher Ferris48af7cb2017-02-21 12:35:09 -080087 BPF_PROG_ATTACH,
88 BPF_PROG_DETACH,
Christopher Ferris525ce912017-07-26 13:12:53 -070089 BPF_PROG_TEST_RUN,
Christopher Ferris1308ad32017-11-14 17:32:13 -080090 BPF_PROG_GET_NEXT_ID,
91 BPF_MAP_GET_NEXT_ID,
92 BPF_PROG_GET_FD_BY_ID,
93 BPF_MAP_GET_FD_BY_ID,
94 BPF_OBJ_GET_INFO_BY_FD,
Christopher Ferris934ec942018-01-31 15:29:16 -080095 BPF_PROG_QUERY,
Christopher Ferris76a1d452018-06-27 14:12:29 -070096 BPF_RAW_TRACEPOINT_OPEN,
Christopher Ferris9ce28842018-10-25 12:11:39 -070097 BPF_BTF_LOAD,
98 BPF_BTF_GET_FD_BY_ID,
99 BPF_TASK_FD_QUERY,
Christopher Ferris86a48372019-01-10 14:14:59 -0800100 BPF_MAP_LOOKUP_AND_DELETE_ELEM,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700101 BPF_MAP_FREEZE,
Christopher Ferris9584fa42019-12-09 15:36:13 -0800102 BPF_BTF_GET_NEXT_ID,
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700103 BPF_MAP_LOOKUP_BATCH,
104 BPF_MAP_LOOKUP_AND_DELETE_BATCH,
105 BPF_MAP_UPDATE_BATCH,
106 BPF_MAP_DELETE_BATCH,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700107 BPF_LINK_CREATE,
108 BPF_LINK_UPDATE,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700109 BPF_LINK_GET_FD_BY_ID,
110 BPF_LINK_GET_NEXT_ID,
111 BPF_ENABLE_STATS,
112 BPF_ITER_CREATE,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700113 BPF_LINK_DETACH,
Christopher Ferris82d75042015-01-26 10:57:07 -0800114};
115enum bpf_map_type {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800116 BPF_MAP_TYPE_UNSPEC,
117 BPF_MAP_TYPE_HASH,
118 BPF_MAP_TYPE_ARRAY,
119 BPF_MAP_TYPE_PROG_ARRAY,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800120 BPF_MAP_TYPE_PERF_EVENT_ARRAY,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700121 BPF_MAP_TYPE_PERCPU_HASH,
122 BPF_MAP_TYPE_PERCPU_ARRAY,
123 BPF_MAP_TYPE_STACK_TRACE,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800124 BPF_MAP_TYPE_CGROUP_ARRAY,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800125 BPF_MAP_TYPE_LRU_HASH,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800126 BPF_MAP_TYPE_LRU_PERCPU_HASH,
Christopher Ferris525ce912017-07-26 13:12:53 -0700127 BPF_MAP_TYPE_LPM_TRIE,
128 BPF_MAP_TYPE_ARRAY_OF_MAPS,
129 BPF_MAP_TYPE_HASH_OF_MAPS,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800130 BPF_MAP_TYPE_DEVMAP,
131 BPF_MAP_TYPE_SOCKMAP,
Christopher Ferris934ec942018-01-31 15:29:16 -0800132 BPF_MAP_TYPE_CPUMAP,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700133 BPF_MAP_TYPE_XSKMAP,
134 BPF_MAP_TYPE_SOCKHASH,
135 BPF_MAP_TYPE_CGROUP_STORAGE,
136 BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,
Christopher Ferris86a48372019-01-10 14:14:59 -0800137 BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,
138 BPF_MAP_TYPE_QUEUE,
139 BPF_MAP_TYPE_STACK,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700140 BPF_MAP_TYPE_SK_STORAGE,
Christopher Ferris9584fa42019-12-09 15:36:13 -0800141 BPF_MAP_TYPE_DEVMAP_HASH,
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700142 BPF_MAP_TYPE_STRUCT_OPS,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700143 BPF_MAP_TYPE_RINGBUF,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800144};
Christopher Ferris82d75042015-01-26 10:57:07 -0800145enum bpf_prog_type {
Tao Baod7db5942015-01-28 10:07:51 -0800146 BPF_PROG_TYPE_UNSPEC,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800147 BPF_PROG_TYPE_SOCKET_FILTER,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800148 BPF_PROG_TYPE_KPROBE,
149 BPF_PROG_TYPE_SCHED_CLS,
150 BPF_PROG_TYPE_SCHED_ACT,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800151 BPF_PROG_TYPE_TRACEPOINT,
152 BPF_PROG_TYPE_XDP,
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800153 BPF_PROG_TYPE_PERF_EVENT,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800154 BPF_PROG_TYPE_CGROUP_SKB,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800155 BPF_PROG_TYPE_CGROUP_SOCK,
156 BPF_PROG_TYPE_LWT_IN,
157 BPF_PROG_TYPE_LWT_OUT,
158 BPF_PROG_TYPE_LWT_XMIT,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800159 BPF_PROG_TYPE_SOCK_OPS,
160 BPF_PROG_TYPE_SK_SKB,
Christopher Ferris934ec942018-01-31 15:29:16 -0800161 BPF_PROG_TYPE_CGROUP_DEVICE,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700162 BPF_PROG_TYPE_SK_MSG,
163 BPF_PROG_TYPE_RAW_TRACEPOINT,
164 BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700165 BPF_PROG_TYPE_LWT_SEG6LOCAL,
166 BPF_PROG_TYPE_LIRC_MODE2,
167 BPF_PROG_TYPE_SK_REUSEPORT,
Christopher Ferris86a48372019-01-10 14:14:59 -0800168 BPF_PROG_TYPE_FLOW_DISSECTOR,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700169 BPF_PROG_TYPE_CGROUP_SYSCTL,
170 BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE,
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700171 BPF_PROG_TYPE_CGROUP_SOCKOPT,
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800172 BPF_PROG_TYPE_TRACING,
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700173 BPF_PROG_TYPE_STRUCT_OPS,
174 BPF_PROG_TYPE_EXT,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700175 BPF_PROG_TYPE_LSM,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700176 BPF_PROG_TYPE_SK_LOOKUP,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800177};
178enum bpf_attach_type {
179 BPF_CGROUP_INET_INGRESS,
180 BPF_CGROUP_INET_EGRESS,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800181 BPF_CGROUP_INET_SOCK_CREATE,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800182 BPF_CGROUP_SOCK_OPS,
183 BPF_SK_SKB_STREAM_PARSER,
184 BPF_SK_SKB_STREAM_VERDICT,
Christopher Ferris934ec942018-01-31 15:29:16 -0800185 BPF_CGROUP_DEVICE,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700186 BPF_SK_MSG_VERDICT,
187 BPF_CGROUP_INET4_BIND,
188 BPF_CGROUP_INET6_BIND,
189 BPF_CGROUP_INET4_CONNECT,
190 BPF_CGROUP_INET6_CONNECT,
191 BPF_CGROUP_INET4_POST_BIND,
192 BPF_CGROUP_INET6_POST_BIND,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700193 BPF_CGROUP_UDP4_SENDMSG,
194 BPF_CGROUP_UDP6_SENDMSG,
195 BPF_LIRC_MODE2,
Christopher Ferris86a48372019-01-10 14:14:59 -0800196 BPF_FLOW_DISSECTOR,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700197 BPF_CGROUP_SYSCTL,
198 BPF_CGROUP_UDP4_RECVMSG,
199 BPF_CGROUP_UDP6_RECVMSG,
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700200 BPF_CGROUP_GETSOCKOPT,
201 BPF_CGROUP_SETSOCKOPT,
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800202 BPF_TRACE_RAW_TP,
203 BPF_TRACE_FENTRY,
204 BPF_TRACE_FEXIT,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700205 BPF_MODIFY_RETURN,
206 BPF_LSM_MAC,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700207 BPF_TRACE_ITER,
208 BPF_CGROUP_INET4_GETPEERNAME,
209 BPF_CGROUP_INET6_GETPEERNAME,
210 BPF_CGROUP_INET4_GETSOCKNAME,
211 BPF_CGROUP_INET6_GETSOCKNAME,
212 BPF_XDP_DEVMAP,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700213 BPF_CGROUP_INET_SOCK_RELEASE,
214 BPF_XDP_CPUMAP,
215 BPF_SK_LOOKUP,
216 BPF_XDP,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800217 __MAX_BPF_ATTACH_TYPE
218};
219#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700220enum bpf_link_type {
221 BPF_LINK_TYPE_UNSPEC = 0,
222 BPF_LINK_TYPE_RAW_TRACEPOINT = 1,
223 BPF_LINK_TYPE_TRACING = 2,
224 BPF_LINK_TYPE_CGROUP = 3,
225 BPF_LINK_TYPE_ITER = 4,
226 BPF_LINK_TYPE_NETNS = 5,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700227 BPF_LINK_TYPE_XDP = 6,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700228 MAX_BPF_LINK_TYPE,
229};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800230#define BPF_F_ALLOW_OVERRIDE (1U << 0)
Christopher Ferris934ec942018-01-31 15:29:16 -0800231#define BPF_F_ALLOW_MULTI (1U << 1)
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700232#define BPF_F_REPLACE (1U << 2)
Christopher Ferris525ce912017-07-26 13:12:53 -0700233#define BPF_F_STRICT_ALIGNMENT (1U << 0)
Christopher Ferrisd842e432019-03-07 10:21:59 -0800234#define BPF_F_ANY_ALIGNMENT (1U << 1)
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700235#define BPF_F_TEST_RND_HI32 (1U << 2)
Christopher Ferris9584fa42019-12-09 15:36:13 -0800236#define BPF_F_TEST_STATE_FREQ (1U << 3)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800237#define BPF_PSEUDO_MAP_FD 1
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700238#define BPF_PSEUDO_MAP_VALUE 2
Christopher Ferris76a1d452018-06-27 14:12:29 -0700239#define BPF_PSEUDO_CALL 1
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700240enum {
241 BPF_ANY = 0,
242 BPF_NOEXIST = 1,
243 BPF_EXIST = 2,
244 BPF_F_LOCK = 4,
245};
246enum {
247 BPF_F_NO_PREALLOC = (1U << 0),
248 BPF_F_NO_COMMON_LRU = (1U << 1),
249 BPF_F_NUMA_NODE = (1U << 2),
250 BPF_F_RDONLY = (1U << 3),
251 BPF_F_WRONLY = (1U << 4),
252 BPF_F_STACK_BUILD_ID = (1U << 5),
253 BPF_F_ZERO_SEED = (1U << 6),
254 BPF_F_RDONLY_PROG = (1U << 7),
255 BPF_F_WRONLY_PROG = (1U << 8),
256 BPF_F_CLONE = (1U << 9),
257 BPF_F_MMAPABLE = (1U << 10),
258};
Christopher Ferrisd842e432019-03-07 10:21:59 -0800259#define BPF_F_QUERY_EFFECTIVE (1U << 0)
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700260enum bpf_stats_type {
261 BPF_STATS_RUN_TIME = 0,
262};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700263enum bpf_stack_build_id_status {
264 BPF_STACK_BUILD_ID_EMPTY = 0,
265 BPF_STACK_BUILD_ID_VALID = 1,
266 BPF_STACK_BUILD_ID_IP = 2,
267};
268#define BPF_BUILD_ID_SIZE 20
269struct bpf_stack_build_id {
270 __s32 status;
271 unsigned char build_id[BPF_BUILD_ID_SIZE];
272 union {
273 __u64 offset;
274 __u64 ip;
275 };
276};
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700277#define BPF_OBJ_NAME_LEN 16U
Christopher Ferris05d08e92016-02-04 13:16:38 -0800278union bpf_attr {
Tao Baod7db5942015-01-28 10:07:51 -0800279 struct {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700280 __u32 map_type;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800281 __u32 key_size;
Tao Baod7db5942015-01-28 10:07:51 -0800282 __u32 value_size;
Tao Baod7db5942015-01-28 10:07:51 -0800283 __u32 max_entries;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700284 __u32 map_flags;
Christopher Ferris525ce912017-07-26 13:12:53 -0700285 __u32 inner_map_fd;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800286 __u32 numa_node;
Christopher Ferris934ec942018-01-31 15:29:16 -0800287 char map_name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700288 __u32 map_ifindex;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700289 __u32 btf_fd;
290 __u32 btf_key_type_id;
291 __u32 btf_value_type_id;
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700292 __u32 btf_vmlinux_value_type_id;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800293 };
Tao Baod7db5942015-01-28 10:07:51 -0800294 struct {
295 __u32 map_fd;
Tao Baod7db5942015-01-28 10:07:51 -0800296 __aligned_u64 key;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800297 union {
Tao Baod7db5942015-01-28 10:07:51 -0800298 __aligned_u64 value;
299 __aligned_u64 next_key;
Tao Baod7db5942015-01-28 10:07:51 -0800300 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800301 __u64 flags;
Tao Baod7db5942015-01-28 10:07:51 -0800302 };
303 struct {
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700304 __aligned_u64 in_batch;
305 __aligned_u64 out_batch;
306 __aligned_u64 keys;
307 __aligned_u64 values;
308 __u32 count;
309 __u32 map_fd;
310 __u64 elem_flags;
311 __u64 flags;
312 } batch;
313 struct {
Tao Baod7db5942015-01-28 10:07:51 -0800314 __u32 prog_type;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800315 __u32 insn_cnt;
Tao Baod7db5942015-01-28 10:07:51 -0800316 __aligned_u64 insns;
317 __aligned_u64 license;
318 __u32 log_level;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800319 __u32 log_size;
Tao Baod7db5942015-01-28 10:07:51 -0800320 __aligned_u64 log_buf;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800321 __u32 kern_version;
Christopher Ferris525ce912017-07-26 13:12:53 -0700322 __u32 prog_flags;
Christopher Ferris934ec942018-01-31 15:29:16 -0800323 char prog_name[BPF_OBJ_NAME_LEN];
324 __u32 prog_ifindex;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700325 __u32 expected_attach_type;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800326 __u32 prog_btf_fd;
327 __u32 func_info_rec_size;
328 __aligned_u64 func_info;
329 __u32 func_info_cnt;
330 __u32 line_info_rec_size;
331 __aligned_u64 line_info;
332 __u32 line_info_cnt;
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800333 __u32 attach_btf_id;
334 __u32 attach_prog_fd;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800335 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800336 struct {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800337 __aligned_u64 pathname;
338 __u32 bpf_fd;
Christopher Ferris934ec942018-01-31 15:29:16 -0800339 __u32 file_flags;
Tao Baod7db5942015-01-28 10:07:51 -0800340 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800341 struct {
342 __u32 target_fd;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800343 __u32 attach_bpf_fd;
344 __u32 attach_type;
345 __u32 attach_flags;
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700346 __u32 replace_bpf_fd;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800347 };
Christopher Ferris525ce912017-07-26 13:12:53 -0700348 struct {
349 __u32 prog_fd;
350 __u32 retval;
351 __u32 data_size_in;
352 __u32 data_size_out;
353 __aligned_u64 data_in;
354 __aligned_u64 data_out;
355 __u32 repeat;
356 __u32 duration;
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700357 __u32 ctx_size_in;
358 __u32 ctx_size_out;
359 __aligned_u64 ctx_in;
360 __aligned_u64 ctx_out;
Christopher Ferris525ce912017-07-26 13:12:53 -0700361 } test;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800362 struct {
363 union {
364 __u32 start_id;
365 __u32 prog_id;
366 __u32 map_id;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700367 __u32 btf_id;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700368 __u32 link_id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800369 };
370 __u32 next_id;
Christopher Ferris934ec942018-01-31 15:29:16 -0800371 __u32 open_flags;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800372 };
373 struct {
374 __u32 bpf_fd;
375 __u32 info_len;
376 __aligned_u64 info;
377 } info;
Christopher Ferris934ec942018-01-31 15:29:16 -0800378 struct {
379 __u32 target_fd;
380 __u32 attach_type;
381 __u32 query_flags;
382 __u32 attach_flags;
383 __aligned_u64 prog_ids;
384 __u32 prog_cnt;
385 } query;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700386 struct {
387 __u64 name;
388 __u32 prog_fd;
389 } raw_tracepoint;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700390 struct {
391 __aligned_u64 btf;
392 __aligned_u64 btf_log_buf;
393 __u32 btf_size;
394 __u32 btf_log_size;
395 __u32 btf_log_level;
396 };
397 struct {
398 __u32 pid;
399 __u32 fd;
400 __u32 flags;
401 __u32 buf_len;
402 __aligned_u64 buf;
403 __u32 prog_id;
404 __u32 fd_type;
405 __u64 probe_offset;
406 __u64 probe_addr;
407 } task_fd_query;
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700408 struct {
409 __u32 prog_fd;
Christopher Ferris25c18d42020-10-14 17:42:58 -0700410 union {
411 __u32 target_fd;
412 __u32 target_ifindex;
413 };
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700414 __u32 attach_type;
415 __u32 flags;
Christopher Ferris25c18d42020-10-14 17:42:58 -0700416 __aligned_u64 iter_info;
417 __u32 iter_info_len;
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700418 } link_create;
419 struct {
420 __u32 link_fd;
421 __u32 new_prog_fd;
422 __u32 flags;
423 __u32 old_prog_fd;
424 } link_update;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700425 struct {
Christopher Ferris25c18d42020-10-14 17:42:58 -0700426 __u32 link_fd;
427 } link_detach;
428 struct {
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700429 __u32 type;
430 } enable_stats;
431 struct {
432 __u32 link_fd;
433 __u32 flags;
434 } iter_create;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800435} __attribute__((aligned(8)));
Christopher Ferris25c18d42020-10-14 17:42:58 -0700436#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), FN(read_branch_records), FN(get_ns_current_pid_tgid), FN(xdp_output), FN(get_netns_cookie), FN(get_current_ancestor_cgroup_id), FN(sk_assign), FN(ktime_get_boot_ns), FN(seq_printf), FN(seq_write), FN(sk_cgroup_id), FN(sk_ancestor_cgroup_id), FN(ringbuf_output), FN(ringbuf_reserve), FN(ringbuf_submit), FN(ringbuf_discard), FN(ringbuf_query), FN(csum_level), FN(skc_to_tcp6_sock), FN(skc_to_tcp_sock), FN(skc_to_tcp_timewait_sock), FN(skc_to_tcp_request_sock), FN(skc_to_udp6_sock), FN(get_task_stack),
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800437#define __BPF_ENUM_FN(x) BPF_FUNC_ ##x
Christopher Ferris82d75042015-01-26 10:57:07 -0800438enum bpf_func_id {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800439 __BPF_FUNC_MAPPER(__BPF_ENUM_FN) __BPF_FUNC_MAX_ID,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800440};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800441#undef __BPF_ENUM_FN
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700442enum {
443 BPF_F_RECOMPUTE_CSUM = (1ULL << 0),
444 BPF_F_INVALIDATE_HASH = (1ULL << 1),
445};
446enum {
447 BPF_F_HDR_FIELD_MASK = 0xfULL,
448};
449enum {
450 BPF_F_PSEUDO_HDR = (1ULL << 4),
451 BPF_F_MARK_MANGLED_0 = (1ULL << 5),
452 BPF_F_MARK_ENFORCE = (1ULL << 6),
453};
454enum {
455 BPF_F_INGRESS = (1ULL << 0),
456};
457enum {
458 BPF_F_TUNINFO_IPV6 = (1ULL << 0),
459};
460enum {
461 BPF_F_SKIP_FIELD_MASK = 0xffULL,
462 BPF_F_USER_STACK = (1ULL << 8),
463 BPF_F_FAST_STACK_CMP = (1ULL << 9),
464 BPF_F_REUSE_STACKID = (1ULL << 10),
465 BPF_F_USER_BUILD_ID = (1ULL << 11),
466};
467enum {
468 BPF_F_ZERO_CSUM_TX = (1ULL << 1),
469 BPF_F_DONT_FRAGMENT = (1ULL << 2),
470 BPF_F_SEQ_NUMBER = (1ULL << 3),
471};
472enum {
473 BPF_F_INDEX_MASK = 0xffffffffULL,
474 BPF_F_CURRENT_CPU = BPF_F_INDEX_MASK,
475 BPF_F_CTXLEN_MASK = (0xfffffULL << 32),
476};
477enum {
478 BPF_F_CURRENT_NETNS = (- 1L),
479};
480enum {
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700481 BPF_CSUM_LEVEL_QUERY,
482 BPF_CSUM_LEVEL_INC,
483 BPF_CSUM_LEVEL_DEC,
484 BPF_CSUM_LEVEL_RESET,
485};
486enum {
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700487 BPF_F_ADJ_ROOM_FIXED_GSO = (1ULL << 0),
488 BPF_F_ADJ_ROOM_ENCAP_L3_IPV4 = (1ULL << 1),
489 BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 = (1ULL << 2),
490 BPF_F_ADJ_ROOM_ENCAP_L4_GRE = (1ULL << 3),
491 BPF_F_ADJ_ROOM_ENCAP_L4_UDP = (1ULL << 4),
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700492 BPF_F_ADJ_ROOM_NO_CSUM_RESET = (1ULL << 5),
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700493};
494enum {
495 BPF_ADJ_ROOM_ENCAP_L2_MASK = 0xff,
496 BPF_ADJ_ROOM_ENCAP_L2_SHIFT = 56,
497};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700498#define BPF_F_ADJ_ROOM_ENCAP_L2(len) (((__u64) len & BPF_ADJ_ROOM_ENCAP_L2_MASK) << BPF_ADJ_ROOM_ENCAP_L2_SHIFT)
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700499enum {
500 BPF_F_SYSCTL_BASE_NAME = (1ULL << 0),
501};
502enum {
503 BPF_SK_STORAGE_GET_F_CREATE = (1ULL << 0),
504};
505enum {
506 BPF_F_GET_BRANCH_RECORDS_SIZE = (1ULL << 0),
507};
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700508enum {
509 BPF_RB_NO_WAKEUP = (1ULL << 0),
510 BPF_RB_FORCE_WAKEUP = (1ULL << 1),
511};
512enum {
513 BPF_RB_AVAIL_DATA = 0,
514 BPF_RB_RING_SIZE = 1,
515 BPF_RB_CONS_POS = 2,
516 BPF_RB_PROD_POS = 3,
517};
518enum {
519 BPF_RINGBUF_BUSY_BIT = (1U << 31),
520 BPF_RINGBUF_DISCARD_BIT = (1U << 30),
521 BPF_RINGBUF_HDR_SZ = 8,
522};
Christopher Ferris25c18d42020-10-14 17:42:58 -0700523enum {
524 BPF_SK_LOOKUP_F_REPLACE = (1ULL << 0),
525 BPF_SK_LOOKUP_F_NO_REUSEPORT = (1ULL << 1),
526};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800527enum bpf_adj_room_mode {
528 BPF_ADJ_ROOM_NET,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700529 BPF_ADJ_ROOM_MAC,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800530};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700531enum bpf_hdr_start_off {
532 BPF_HDR_START_MAC,
533 BPF_HDR_START_NET,
534};
535enum bpf_lwt_encap_mode {
536 BPF_LWT_ENCAP_SEG6,
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700537 BPF_LWT_ENCAP_SEG6_INLINE,
538 BPF_LWT_ENCAP_IP,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700539};
Christopher Ferris86a48372019-01-10 14:14:59 -0800540#define __bpf_md_ptr(type,name) union { type name; __u64 : 64; \
541} __attribute__((aligned(8)))
Christopher Ferris49f525c2016-12-12 14:55:36 -0800542struct __sk_buff {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800543 __u32 len;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800544 __u32 pkt_type;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800545 __u32 mark;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800546 __u32 queue_mapping;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800547 __u32 protocol;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800548 __u32 vlan_present;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800549 __u32 vlan_tci;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800550 __u32 vlan_proto;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800551 __u32 priority;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800552 __u32 ingress_ifindex;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800553 __u32 ifindex;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800554 __u32 tc_index;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800555 __u32 cb[5];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800556 __u32 hash;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800557 __u32 tc_classid;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800558 __u32 data;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800559 __u32 data_end;
Christopher Ferris525ce912017-07-26 13:12:53 -0700560 __u32 napi_id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800561 __u32 family;
562 __u32 remote_ip4;
563 __u32 local_ip4;
564 __u32 remote_ip6[4];
565 __u32 local_ip6[4];
566 __u32 remote_port;
567 __u32 local_port;
Christopher Ferris934ec942018-01-31 15:29:16 -0800568 __u32 data_meta;
Christopher Ferris86a48372019-01-10 14:14:59 -0800569 __bpf_md_ptr(struct bpf_flow_keys *, flow_keys);
Christopher Ferrisd842e432019-03-07 10:21:59 -0800570 __u64 tstamp;
571 __u32 wire_len;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700572 __u32 gso_segs;
573 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700574 __u32 gso_size;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800575};
576struct bpf_tunnel_key {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800577 __u32 tunnel_id;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800578 union {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700579 __u32 remote_ipv4;
580 __u32 remote_ipv6[4];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800581 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800582 __u8 tunnel_tos;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700583 __u8 tunnel_ttl;
584 __u16 tunnel_ext;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800585 __u32 tunnel_label;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800586};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700587struct bpf_xfrm_state {
588 __u32 reqid;
589 __u32 spi;
590 __u16 family;
591 __u16 ext;
592 union {
593 __u32 remote_ipv4;
594 __u32 remote_ipv6[4];
595 };
596};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800597enum bpf_ret_code {
598 BPF_OK = 0,
599 BPF_DROP = 2,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800600 BPF_REDIRECT = 7,
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700601 BPF_LWT_REROUTE = 128,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800602};
603struct bpf_sock {
604 __u32 bound_dev_if;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800605 __u32 family;
606 __u32 type;
607 __u32 protocol;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800608 __u32 mark;
609 __u32 priority;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700610 __u32 src_ip4;
611 __u32 src_ip6[4];
612 __u32 src_port;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700613 __u32 dst_port;
614 __u32 dst_ip4;
615 __u32 dst_ip6[4];
616 __u32 state;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700617 __s32 rx_queue_mapping;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700618};
619struct bpf_tcp_sock {
620 __u32 snd_cwnd;
621 __u32 srtt_us;
622 __u32 rtt_min;
623 __u32 snd_ssthresh;
624 __u32 rcv_nxt;
625 __u32 snd_nxt;
626 __u32 snd_una;
627 __u32 mss_cache;
628 __u32 ecn_flags;
629 __u32 rate_delivered;
630 __u32 rate_interval_us;
631 __u32 packets_out;
632 __u32 retrans_out;
633 __u32 total_retrans;
634 __u32 segs_in;
635 __u32 data_segs_in;
636 __u32 segs_out;
637 __u32 data_segs_out;
638 __u32 lost_out;
639 __u32 sacked_out;
640 __u64 bytes_received;
641 __u64 bytes_acked;
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700642 __u32 dsack_dups;
643 __u32 delivered;
644 __u32 delivered_ce;
645 __u32 icsk_retransmits;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800646};
Christopher Ferris86a48372019-01-10 14:14:59 -0800647struct bpf_sock_tuple {
648 union {
649 struct {
650 __be32 saddr;
651 __be32 daddr;
652 __be16 sport;
653 __be16 dport;
654 } ipv4;
655 struct {
656 __be32 saddr[4];
657 __be32 daddr[4];
658 __be16 sport;
659 __be16 dport;
660 } ipv6;
661 };
662};
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700663struct bpf_xdp_sock {
664 __u32 queue_id;
665};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800666#define XDP_PACKET_HEADROOM 256
Christopher Ferris49f525c2016-12-12 14:55:36 -0800667enum xdp_action {
668 XDP_ABORTED = 0,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800669 XDP_DROP,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800670 XDP_PASS,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800671 XDP_TX,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800672 XDP_REDIRECT,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800673};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800674struct xdp_md {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800675 __u32 data;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800676 __u32 data_end;
Christopher Ferris934ec942018-01-31 15:29:16 -0800677 __u32 data_meta;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700678 __u32 ingress_ifindex;
679 __u32 rx_queue_index;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700680 __u32 egress_ifindex;
681};
682struct bpf_devmap_val {
683 __u32 ifindex;
684 union {
685 int fd;
686 __u32 id;
687 } bpf_prog;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800688};
Christopher Ferris25c18d42020-10-14 17:42:58 -0700689struct bpf_cpumap_val {
690 __u32 qsize;
691 union {
692 int fd;
693 __u32 id;
694 } bpf_prog;
695};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800696enum sk_action {
697 SK_DROP = 0,
698 SK_PASS,
699};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700700struct sk_msg_md {
Christopher Ferris86a48372019-01-10 14:14:59 -0800701 __bpf_md_ptr(void *, data);
702 __bpf_md_ptr(void *, data_end);
Christopher Ferris9ce28842018-10-25 12:11:39 -0700703 __u32 family;
704 __u32 remote_ip4;
705 __u32 local_ip4;
706 __u32 remote_ip6[4];
707 __u32 local_ip6[4];
708 __u32 remote_port;
709 __u32 local_port;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800710 __u32 size;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700711 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferris9ce28842018-10-25 12:11:39 -0700712};
713struct sk_reuseport_md {
Christopher Ferris86a48372019-01-10 14:14:59 -0800714 __bpf_md_ptr(void *, data);
715 __bpf_md_ptr(void *, data_end);
Christopher Ferris9ce28842018-10-25 12:11:39 -0700716 __u32 len;
717 __u32 eth_protocol;
718 __u32 ip_protocol;
719 __u32 bind_inany;
720 __u32 hash;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700721};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800722#define BPF_TAG_SIZE 8
723struct bpf_prog_info {
724 __u32 type;
725 __u32 id;
726 __u8 tag[BPF_TAG_SIZE];
727 __u32 jited_prog_len;
728 __u32 xlated_prog_len;
729 __aligned_u64 jited_prog_insns;
730 __aligned_u64 xlated_prog_insns;
Christopher Ferris934ec942018-01-31 15:29:16 -0800731 __u64 load_time;
732 __u32 created_by_uid;
733 __u32 nr_map_ids;
734 __aligned_u64 map_ids;
735 char name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700736 __u32 ifindex;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700737 __u32 gpl_compatible : 1;
Christopher Ferrisfa59a102019-08-05 12:58:49 -0700738 __u32 : 31;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700739 __u64 netns_dev;
740 __u64 netns_ino;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700741 __u32 nr_jited_ksyms;
742 __u32 nr_jited_func_lens;
743 __aligned_u64 jited_ksyms;
744 __aligned_u64 jited_func_lens;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800745 __u32 btf_id;
746 __u32 func_info_rec_size;
747 __aligned_u64 func_info;
748 __u32 nr_func_info;
749 __u32 nr_line_info;
750 __aligned_u64 line_info;
751 __aligned_u64 jited_line_info;
752 __u32 nr_jited_line_info;
753 __u32 line_info_rec_size;
754 __u32 jited_line_info_rec_size;
755 __u32 nr_prog_tags;
756 __aligned_u64 prog_tags;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700757 __u64 run_time_ns;
758 __u64 run_cnt;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800759} __attribute__((aligned(8)));
760struct bpf_map_info {
761 __u32 type;
762 __u32 id;
763 __u32 key_size;
764 __u32 value_size;
765 __u32 max_entries;
766 __u32 map_flags;
Christopher Ferris934ec942018-01-31 15:29:16 -0800767 char name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700768 __u32 ifindex;
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700769 __u32 btf_vmlinux_value_type_id;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700770 __u64 netns_dev;
771 __u64 netns_ino;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700772 __u32 btf_id;
773 __u32 btf_key_type_id;
774 __u32 btf_value_type_id;
775} __attribute__((aligned(8)));
776struct bpf_btf_info {
777 __aligned_u64 btf;
778 __u32 btf_size;
779 __u32 id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800780} __attribute__((aligned(8)));
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700781struct bpf_link_info {
782 __u32 type;
783 __u32 id;
784 __u32 prog_id;
785 union {
786 struct {
787 __aligned_u64 tp_name;
788 __u32 tp_name_len;
789 } raw_tracepoint;
790 struct {
791 __u32 attach_type;
792 } tracing;
793 struct {
794 __u64 cgroup_id;
795 __u32 attach_type;
796 } cgroup;
797 struct {
798 __u32 netns_ino;
799 __u32 attach_type;
800 } netns;
Christopher Ferris25c18d42020-10-14 17:42:58 -0700801 struct {
802 __u32 ifindex;
803 } xdp;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700804 };
805} __attribute__((aligned(8)));
Christopher Ferris76a1d452018-06-27 14:12:29 -0700806struct bpf_sock_addr {
807 __u32 user_family;
808 __u32 user_ip4;
809 __u32 user_ip6[4];
810 __u32 user_port;
811 __u32 family;
812 __u32 type;
813 __u32 protocol;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700814 __u32 msg_src_ip4;
815 __u32 msg_src_ip6[4];
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700816 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferris76a1d452018-06-27 14:12:29 -0700817};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800818struct bpf_sock_ops {
819 __u32 op;
820 union {
Christopher Ferris76a1d452018-06-27 14:12:29 -0700821 __u32 args[4];
Christopher Ferris1308ad32017-11-14 17:32:13 -0800822 __u32 reply;
823 __u32 replylong[4];
824 };
825 __u32 family;
826 __u32 remote_ip4;
827 __u32 local_ip4;
828 __u32 remote_ip6[4];
829 __u32 local_ip6[4];
830 __u32 remote_port;
831 __u32 local_port;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700832 __u32 is_fullsock;
833 __u32 snd_cwnd;
834 __u32 srtt_us;
835 __u32 bpf_sock_ops_cb_flags;
836 __u32 state;
837 __u32 rtt_min;
838 __u32 snd_ssthresh;
839 __u32 rcv_nxt;
840 __u32 snd_nxt;
841 __u32 snd_una;
842 __u32 mss_cache;
843 __u32 ecn_flags;
844 __u32 rate_delivered;
845 __u32 rate_interval_us;
846 __u32 packets_out;
847 __u32 retrans_out;
848 __u32 total_retrans;
849 __u32 segs_in;
850 __u32 data_segs_in;
851 __u32 segs_out;
852 __u32 data_segs_out;
853 __u32 lost_out;
854 __u32 sacked_out;
855 __u32 sk_txhash;
856 __u64 bytes_received;
857 __u64 bytes_acked;
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700858 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferris1308ad32017-11-14 17:32:13 -0800859};
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700860enum {
861 BPF_SOCK_OPS_RTO_CB_FLAG = (1 << 0),
862 BPF_SOCK_OPS_RETRANS_CB_FLAG = (1 << 1),
863 BPF_SOCK_OPS_STATE_CB_FLAG = (1 << 2),
864 BPF_SOCK_OPS_RTT_CB_FLAG = (1 << 3),
865 BPF_SOCK_OPS_ALL_CB_FLAGS = 0xF,
866};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800867enum {
868 BPF_SOCK_OPS_VOID,
869 BPF_SOCK_OPS_TIMEOUT_INIT,
870 BPF_SOCK_OPS_RWND_INIT,
871 BPF_SOCK_OPS_TCP_CONNECT_CB,
872 BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB,
873 BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB,
874 BPF_SOCK_OPS_NEEDS_ECN,
Christopher Ferris934ec942018-01-31 15:29:16 -0800875 BPF_SOCK_OPS_BASE_RTT,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700876 BPF_SOCK_OPS_RTO_CB,
877 BPF_SOCK_OPS_RETRANS_CB,
878 BPF_SOCK_OPS_STATE_CB,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700879 BPF_SOCK_OPS_TCP_LISTEN_CB,
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700880 BPF_SOCK_OPS_RTT_CB,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700881};
882enum {
883 BPF_TCP_ESTABLISHED = 1,
884 BPF_TCP_SYN_SENT,
885 BPF_TCP_SYN_RECV,
886 BPF_TCP_FIN_WAIT1,
887 BPF_TCP_FIN_WAIT2,
888 BPF_TCP_TIME_WAIT,
889 BPF_TCP_CLOSE,
890 BPF_TCP_CLOSE_WAIT,
891 BPF_TCP_LAST_ACK,
892 BPF_TCP_LISTEN,
893 BPF_TCP_CLOSING,
894 BPF_TCP_NEW_SYN_RECV,
895 BPF_TCP_MAX_STATES
Christopher Ferris1308ad32017-11-14 17:32:13 -0800896};
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700897enum {
898 TCP_BPF_IW = 1001,
899 TCP_BPF_SNDCWND_CLAMP = 1002,
900};
Christopher Ferris934ec942018-01-31 15:29:16 -0800901struct bpf_perf_event_value {
902 __u64 counter;
903 __u64 enabled;
904 __u64 running;
905};
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700906enum {
907 BPF_DEVCG_ACC_MKNOD = (1ULL << 0),
908 BPF_DEVCG_ACC_READ = (1ULL << 1),
909 BPF_DEVCG_ACC_WRITE = (1ULL << 2),
910};
911enum {
912 BPF_DEVCG_DEV_BLOCK = (1ULL << 0),
913 BPF_DEVCG_DEV_CHAR = (1ULL << 1),
914};
Christopher Ferris934ec942018-01-31 15:29:16 -0800915struct bpf_cgroup_dev_ctx {
916 __u32 access_type;
917 __u32 major;
918 __u32 minor;
919};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700920struct bpf_raw_tracepoint_args {
921 __u64 args[0];
922};
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700923enum {
924 BPF_FIB_LOOKUP_DIRECT = (1U << 0),
925 BPF_FIB_LOOKUP_OUTPUT = (1U << 1),
926};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700927enum {
928 BPF_FIB_LKUP_RET_SUCCESS,
929 BPF_FIB_LKUP_RET_BLACKHOLE,
930 BPF_FIB_LKUP_RET_UNREACHABLE,
931 BPF_FIB_LKUP_RET_PROHIBIT,
932 BPF_FIB_LKUP_RET_NOT_FWDED,
933 BPF_FIB_LKUP_RET_FWD_DISABLED,
934 BPF_FIB_LKUP_RET_UNSUPP_LWT,
935 BPF_FIB_LKUP_RET_NO_NEIGH,
936 BPF_FIB_LKUP_RET_FRAG_NEEDED,
937};
938struct bpf_fib_lookup {
939 __u8 family;
940 __u8 l4_protocol;
941 __be16 sport;
942 __be16 dport;
943 __u16 tot_len;
944 __u32 ifindex;
945 union {
946 __u8 tos;
947 __be32 flowinfo;
948 __u32 rt_metric;
949 };
950 union {
951 __be32 ipv4_src;
952 __u32 ipv6_src[4];
953 };
954 union {
955 __be32 ipv4_dst;
956 __u32 ipv6_dst[4];
957 };
958 __be16 h_vlan_proto;
959 __be16 h_vlan_TCI;
960 __u8 smac[6];
961 __u8 dmac[6];
962};
963enum bpf_task_fd_type {
964 BPF_FD_TYPE_RAW_TRACEPOINT,
965 BPF_FD_TYPE_TRACEPOINT,
966 BPF_FD_TYPE_KPROBE,
967 BPF_FD_TYPE_KRETPROBE,
968 BPF_FD_TYPE_UPROBE,
969 BPF_FD_TYPE_URETPROBE,
970};
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700971enum {
972 BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG = (1U << 0),
973 BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL = (1U << 1),
974 BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP = (1U << 2),
975};
Christopher Ferris86a48372019-01-10 14:14:59 -0800976struct bpf_flow_keys {
977 __u16 nhoff;
978 __u16 thoff;
979 __u16 addr_proto;
980 __u8 is_frag;
981 __u8 is_first_frag;
982 __u8 is_encap;
983 __u8 ip_proto;
984 __be16 n_proto;
985 __be16 sport;
986 __be16 dport;
987 union {
988 struct {
989 __be32 ipv4_src;
990 __be32 ipv4_dst;
991 };
992 struct {
993 __u32 ipv6_src[4];
994 __u32 ipv6_dst[4];
995 };
996 };
Christopher Ferris9584fa42019-12-09 15:36:13 -0800997 __u32 flags;
998 __be32 flow_label;
Christopher Ferris86a48372019-01-10 14:14:59 -0800999};
Christopher Ferrisd842e432019-03-07 10:21:59 -08001000struct bpf_func_info {
1001 __u32 insn_off;
1002 __u32 type_id;
1003};
1004#define BPF_LINE_INFO_LINE_NUM(line_col) ((line_col) >> 10)
1005#define BPF_LINE_INFO_LINE_COL(line_col) ((line_col) & 0x3ff)
1006struct bpf_line_info {
1007 __u32 insn_off;
1008 __u32 file_name_off;
1009 __u32 line_off;
1010 __u32 line_col;
1011};
Christopher Ferris24f97eb2019-05-20 12:58:13 -07001012struct bpf_spin_lock {
1013 __u32 val;
1014};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -07001015struct bpf_sysctl {
1016 __u32 write;
1017 __u32 file_pos;
1018};
Christopher Ferrisb8a95e22019-10-02 18:29:20 -07001019struct bpf_sockopt {
1020 __bpf_md_ptr(struct bpf_sock *, sk);
1021 __bpf_md_ptr(void *, optval);
1022 __bpf_md_ptr(void *, optval_end);
1023 __s32 level;
1024 __s32 optname;
1025 __s32 optlen;
1026 __s32 retval;
1027};
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001028struct bpf_pidns_info {
1029 __u32 pid;
1030 __u32 tgid;
1031};
Christopher Ferris25c18d42020-10-14 17:42:58 -07001032struct bpf_sk_lookup {
1033 __bpf_md_ptr(struct bpf_sock *, sk);
1034 __u32 family;
1035 __u32 protocol;
1036 __u32 remote_ip4;
1037 __u32 remote_ip6[4];
1038 __u32 remote_port;
1039 __u32 local_ip4;
1040 __u32 local_ip6[4];
1041 __u32 local_port;
1042};
Christopher Ferris82d75042015-01-26 10:57:07 -08001043#endif