blob: 4e81cd0d901e0c8af997941c2f358defc2155efd [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 Ferris32ff3f82020-12-14 13:10:04 -0800114 BPF_PROG_BIND_MAP,
Christopher Ferris82d75042015-01-26 10:57:07 -0800115};
116enum bpf_map_type {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800117 BPF_MAP_TYPE_UNSPEC,
118 BPF_MAP_TYPE_HASH,
119 BPF_MAP_TYPE_ARRAY,
120 BPF_MAP_TYPE_PROG_ARRAY,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800121 BPF_MAP_TYPE_PERF_EVENT_ARRAY,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700122 BPF_MAP_TYPE_PERCPU_HASH,
123 BPF_MAP_TYPE_PERCPU_ARRAY,
124 BPF_MAP_TYPE_STACK_TRACE,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800125 BPF_MAP_TYPE_CGROUP_ARRAY,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800126 BPF_MAP_TYPE_LRU_HASH,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800127 BPF_MAP_TYPE_LRU_PERCPU_HASH,
Christopher Ferris525ce912017-07-26 13:12:53 -0700128 BPF_MAP_TYPE_LPM_TRIE,
129 BPF_MAP_TYPE_ARRAY_OF_MAPS,
130 BPF_MAP_TYPE_HASH_OF_MAPS,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800131 BPF_MAP_TYPE_DEVMAP,
132 BPF_MAP_TYPE_SOCKMAP,
Christopher Ferris934ec942018-01-31 15:29:16 -0800133 BPF_MAP_TYPE_CPUMAP,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700134 BPF_MAP_TYPE_XSKMAP,
135 BPF_MAP_TYPE_SOCKHASH,
136 BPF_MAP_TYPE_CGROUP_STORAGE,
137 BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,
Christopher Ferris86a48372019-01-10 14:14:59 -0800138 BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,
139 BPF_MAP_TYPE_QUEUE,
140 BPF_MAP_TYPE_STACK,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700141 BPF_MAP_TYPE_SK_STORAGE,
Christopher Ferris9584fa42019-12-09 15:36:13 -0800142 BPF_MAP_TYPE_DEVMAP_HASH,
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700143 BPF_MAP_TYPE_STRUCT_OPS,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700144 BPF_MAP_TYPE_RINGBUF,
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800145 BPF_MAP_TYPE_INODE_STORAGE,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800146};
Christopher Ferris82d75042015-01-26 10:57:07 -0800147enum bpf_prog_type {
Tao Baod7db5942015-01-28 10:07:51 -0800148 BPF_PROG_TYPE_UNSPEC,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800149 BPF_PROG_TYPE_SOCKET_FILTER,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800150 BPF_PROG_TYPE_KPROBE,
151 BPF_PROG_TYPE_SCHED_CLS,
152 BPF_PROG_TYPE_SCHED_ACT,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800153 BPF_PROG_TYPE_TRACEPOINT,
154 BPF_PROG_TYPE_XDP,
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800155 BPF_PROG_TYPE_PERF_EVENT,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800156 BPF_PROG_TYPE_CGROUP_SKB,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800157 BPF_PROG_TYPE_CGROUP_SOCK,
158 BPF_PROG_TYPE_LWT_IN,
159 BPF_PROG_TYPE_LWT_OUT,
160 BPF_PROG_TYPE_LWT_XMIT,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800161 BPF_PROG_TYPE_SOCK_OPS,
162 BPF_PROG_TYPE_SK_SKB,
Christopher Ferris934ec942018-01-31 15:29:16 -0800163 BPF_PROG_TYPE_CGROUP_DEVICE,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700164 BPF_PROG_TYPE_SK_MSG,
165 BPF_PROG_TYPE_RAW_TRACEPOINT,
166 BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700167 BPF_PROG_TYPE_LWT_SEG6LOCAL,
168 BPF_PROG_TYPE_LIRC_MODE2,
169 BPF_PROG_TYPE_SK_REUSEPORT,
Christopher Ferris86a48372019-01-10 14:14:59 -0800170 BPF_PROG_TYPE_FLOW_DISSECTOR,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700171 BPF_PROG_TYPE_CGROUP_SYSCTL,
172 BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE,
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700173 BPF_PROG_TYPE_CGROUP_SOCKOPT,
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800174 BPF_PROG_TYPE_TRACING,
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700175 BPF_PROG_TYPE_STRUCT_OPS,
176 BPF_PROG_TYPE_EXT,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700177 BPF_PROG_TYPE_LSM,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700178 BPF_PROG_TYPE_SK_LOOKUP,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800179};
180enum bpf_attach_type {
181 BPF_CGROUP_INET_INGRESS,
182 BPF_CGROUP_INET_EGRESS,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800183 BPF_CGROUP_INET_SOCK_CREATE,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800184 BPF_CGROUP_SOCK_OPS,
185 BPF_SK_SKB_STREAM_PARSER,
186 BPF_SK_SKB_STREAM_VERDICT,
Christopher Ferris934ec942018-01-31 15:29:16 -0800187 BPF_CGROUP_DEVICE,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700188 BPF_SK_MSG_VERDICT,
189 BPF_CGROUP_INET4_BIND,
190 BPF_CGROUP_INET6_BIND,
191 BPF_CGROUP_INET4_CONNECT,
192 BPF_CGROUP_INET6_CONNECT,
193 BPF_CGROUP_INET4_POST_BIND,
194 BPF_CGROUP_INET6_POST_BIND,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700195 BPF_CGROUP_UDP4_SENDMSG,
196 BPF_CGROUP_UDP6_SENDMSG,
197 BPF_LIRC_MODE2,
Christopher Ferris86a48372019-01-10 14:14:59 -0800198 BPF_FLOW_DISSECTOR,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700199 BPF_CGROUP_SYSCTL,
200 BPF_CGROUP_UDP4_RECVMSG,
201 BPF_CGROUP_UDP6_RECVMSG,
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700202 BPF_CGROUP_GETSOCKOPT,
203 BPF_CGROUP_SETSOCKOPT,
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800204 BPF_TRACE_RAW_TP,
205 BPF_TRACE_FENTRY,
206 BPF_TRACE_FEXIT,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700207 BPF_MODIFY_RETURN,
208 BPF_LSM_MAC,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700209 BPF_TRACE_ITER,
210 BPF_CGROUP_INET4_GETPEERNAME,
211 BPF_CGROUP_INET6_GETPEERNAME,
212 BPF_CGROUP_INET4_GETSOCKNAME,
213 BPF_CGROUP_INET6_GETSOCKNAME,
214 BPF_XDP_DEVMAP,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700215 BPF_CGROUP_INET_SOCK_RELEASE,
216 BPF_XDP_CPUMAP,
217 BPF_SK_LOOKUP,
218 BPF_XDP,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800219 __MAX_BPF_ATTACH_TYPE
220};
221#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700222enum bpf_link_type {
223 BPF_LINK_TYPE_UNSPEC = 0,
224 BPF_LINK_TYPE_RAW_TRACEPOINT = 1,
225 BPF_LINK_TYPE_TRACING = 2,
226 BPF_LINK_TYPE_CGROUP = 3,
227 BPF_LINK_TYPE_ITER = 4,
228 BPF_LINK_TYPE_NETNS = 5,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700229 BPF_LINK_TYPE_XDP = 6,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700230 MAX_BPF_LINK_TYPE,
231};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800232#define BPF_F_ALLOW_OVERRIDE (1U << 0)
Christopher Ferris934ec942018-01-31 15:29:16 -0800233#define BPF_F_ALLOW_MULTI (1U << 1)
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700234#define BPF_F_REPLACE (1U << 2)
Christopher Ferris525ce912017-07-26 13:12:53 -0700235#define BPF_F_STRICT_ALIGNMENT (1U << 0)
Christopher Ferrisd842e432019-03-07 10:21:59 -0800236#define BPF_F_ANY_ALIGNMENT (1U << 1)
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700237#define BPF_F_TEST_RND_HI32 (1U << 2)
Christopher Ferris9584fa42019-12-09 15:36:13 -0800238#define BPF_F_TEST_STATE_FREQ (1U << 3)
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800239#define BPF_F_SLEEPABLE (1U << 4)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800240#define BPF_PSEUDO_MAP_FD 1
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700241#define BPF_PSEUDO_MAP_VALUE 2
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800242#define BPF_PSEUDO_BTF_ID 3
Christopher Ferris76a1d452018-06-27 14:12:29 -0700243#define BPF_PSEUDO_CALL 1
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700244enum {
245 BPF_ANY = 0,
246 BPF_NOEXIST = 1,
247 BPF_EXIST = 2,
248 BPF_F_LOCK = 4,
249};
250enum {
251 BPF_F_NO_PREALLOC = (1U << 0),
252 BPF_F_NO_COMMON_LRU = (1U << 1),
253 BPF_F_NUMA_NODE = (1U << 2),
254 BPF_F_RDONLY = (1U << 3),
255 BPF_F_WRONLY = (1U << 4),
256 BPF_F_STACK_BUILD_ID = (1U << 5),
257 BPF_F_ZERO_SEED = (1U << 6),
258 BPF_F_RDONLY_PROG = (1U << 7),
259 BPF_F_WRONLY_PROG = (1U << 8),
260 BPF_F_CLONE = (1U << 9),
261 BPF_F_MMAPABLE = (1U << 10),
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800262 BPF_F_PRESERVE_ELEMS = (1U << 11),
263 BPF_F_INNER_MAP = (1U << 12),
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700264};
Christopher Ferrisd842e432019-03-07 10:21:59 -0800265#define BPF_F_QUERY_EFFECTIVE (1U << 0)
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800266#define BPF_F_TEST_RUN_ON_CPU (1U << 0)
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700267enum bpf_stats_type {
268 BPF_STATS_RUN_TIME = 0,
269};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700270enum bpf_stack_build_id_status {
271 BPF_STACK_BUILD_ID_EMPTY = 0,
272 BPF_STACK_BUILD_ID_VALID = 1,
273 BPF_STACK_BUILD_ID_IP = 2,
274};
275#define BPF_BUILD_ID_SIZE 20
276struct bpf_stack_build_id {
277 __s32 status;
278 unsigned char build_id[BPF_BUILD_ID_SIZE];
279 union {
280 __u64 offset;
281 __u64 ip;
282 };
283};
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700284#define BPF_OBJ_NAME_LEN 16U
Christopher Ferris05d08e92016-02-04 13:16:38 -0800285union bpf_attr {
Tao Baod7db5942015-01-28 10:07:51 -0800286 struct {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700287 __u32 map_type;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800288 __u32 key_size;
Tao Baod7db5942015-01-28 10:07:51 -0800289 __u32 value_size;
Tao Baod7db5942015-01-28 10:07:51 -0800290 __u32 max_entries;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700291 __u32 map_flags;
Christopher Ferris525ce912017-07-26 13:12:53 -0700292 __u32 inner_map_fd;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800293 __u32 numa_node;
Christopher Ferris934ec942018-01-31 15:29:16 -0800294 char map_name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700295 __u32 map_ifindex;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700296 __u32 btf_fd;
297 __u32 btf_key_type_id;
298 __u32 btf_value_type_id;
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700299 __u32 btf_vmlinux_value_type_id;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800300 };
Tao Baod7db5942015-01-28 10:07:51 -0800301 struct {
302 __u32 map_fd;
Tao Baod7db5942015-01-28 10:07:51 -0800303 __aligned_u64 key;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800304 union {
Tao Baod7db5942015-01-28 10:07:51 -0800305 __aligned_u64 value;
306 __aligned_u64 next_key;
Tao Baod7db5942015-01-28 10:07:51 -0800307 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800308 __u64 flags;
Tao Baod7db5942015-01-28 10:07:51 -0800309 };
310 struct {
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700311 __aligned_u64 in_batch;
312 __aligned_u64 out_batch;
313 __aligned_u64 keys;
314 __aligned_u64 values;
315 __u32 count;
316 __u32 map_fd;
317 __u64 elem_flags;
318 __u64 flags;
319 } batch;
320 struct {
Tao Baod7db5942015-01-28 10:07:51 -0800321 __u32 prog_type;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800322 __u32 insn_cnt;
Tao Baod7db5942015-01-28 10:07:51 -0800323 __aligned_u64 insns;
324 __aligned_u64 license;
325 __u32 log_level;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800326 __u32 log_size;
Tao Baod7db5942015-01-28 10:07:51 -0800327 __aligned_u64 log_buf;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800328 __u32 kern_version;
Christopher Ferris525ce912017-07-26 13:12:53 -0700329 __u32 prog_flags;
Christopher Ferris934ec942018-01-31 15:29:16 -0800330 char prog_name[BPF_OBJ_NAME_LEN];
331 __u32 prog_ifindex;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700332 __u32 expected_attach_type;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800333 __u32 prog_btf_fd;
334 __u32 func_info_rec_size;
335 __aligned_u64 func_info;
336 __u32 func_info_cnt;
337 __u32 line_info_rec_size;
338 __aligned_u64 line_info;
339 __u32 line_info_cnt;
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800340 __u32 attach_btf_id;
341 __u32 attach_prog_fd;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800342 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800343 struct {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800344 __aligned_u64 pathname;
345 __u32 bpf_fd;
Christopher Ferris934ec942018-01-31 15:29:16 -0800346 __u32 file_flags;
Tao Baod7db5942015-01-28 10:07:51 -0800347 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800348 struct {
349 __u32 target_fd;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800350 __u32 attach_bpf_fd;
351 __u32 attach_type;
352 __u32 attach_flags;
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700353 __u32 replace_bpf_fd;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800354 };
Christopher Ferris525ce912017-07-26 13:12:53 -0700355 struct {
356 __u32 prog_fd;
357 __u32 retval;
358 __u32 data_size_in;
359 __u32 data_size_out;
360 __aligned_u64 data_in;
361 __aligned_u64 data_out;
362 __u32 repeat;
363 __u32 duration;
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700364 __u32 ctx_size_in;
365 __u32 ctx_size_out;
366 __aligned_u64 ctx_in;
367 __aligned_u64 ctx_out;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800368 __u32 flags;
369 __u32 cpu;
Christopher Ferris525ce912017-07-26 13:12:53 -0700370 } test;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800371 struct {
372 union {
373 __u32 start_id;
374 __u32 prog_id;
375 __u32 map_id;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700376 __u32 btf_id;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700377 __u32 link_id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800378 };
379 __u32 next_id;
Christopher Ferris934ec942018-01-31 15:29:16 -0800380 __u32 open_flags;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800381 };
382 struct {
383 __u32 bpf_fd;
384 __u32 info_len;
385 __aligned_u64 info;
386 } info;
Christopher Ferris934ec942018-01-31 15:29:16 -0800387 struct {
388 __u32 target_fd;
389 __u32 attach_type;
390 __u32 query_flags;
391 __u32 attach_flags;
392 __aligned_u64 prog_ids;
393 __u32 prog_cnt;
394 } query;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700395 struct {
396 __u64 name;
397 __u32 prog_fd;
398 } raw_tracepoint;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700399 struct {
400 __aligned_u64 btf;
401 __aligned_u64 btf_log_buf;
402 __u32 btf_size;
403 __u32 btf_log_size;
404 __u32 btf_log_level;
405 };
406 struct {
407 __u32 pid;
408 __u32 fd;
409 __u32 flags;
410 __u32 buf_len;
411 __aligned_u64 buf;
412 __u32 prog_id;
413 __u32 fd_type;
414 __u64 probe_offset;
415 __u64 probe_addr;
416 } task_fd_query;
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700417 struct {
418 __u32 prog_fd;
Christopher Ferris25c18d42020-10-14 17:42:58 -0700419 union {
420 __u32 target_fd;
421 __u32 target_ifindex;
422 };
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700423 __u32 attach_type;
424 __u32 flags;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800425 union {
426 __u32 target_btf_id;
427 struct {
428 __aligned_u64 iter_info;
429 __u32 iter_info_len;
430 };
431 };
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700432 } link_create;
433 struct {
434 __u32 link_fd;
435 __u32 new_prog_fd;
436 __u32 flags;
437 __u32 old_prog_fd;
438 } link_update;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700439 struct {
Christopher Ferris25c18d42020-10-14 17:42:58 -0700440 __u32 link_fd;
441 } link_detach;
442 struct {
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700443 __u32 type;
444 } enable_stats;
445 struct {
446 __u32 link_fd;
447 __u32 flags;
448 } iter_create;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800449 struct {
450 __u32 prog_fd;
451 __u32 map_fd;
452 __u32 flags;
453 } prog_bind_map;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800454} __attribute__((aligned(8)));
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800455#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), FN(load_hdr_opt), FN(store_hdr_opt), FN(reserve_hdr_opt), FN(inode_storage_get), FN(inode_storage_delete), FN(d_path), FN(copy_from_user), FN(snprintf_btf), FN(seq_printf_btf), FN(skb_cgroup_classid), FN(redirect_neigh), FN(per_cpu_ptr), FN(this_cpu_ptr), FN(redirect_peer),
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800456#define __BPF_ENUM_FN(x) BPF_FUNC_ ##x
Christopher Ferris82d75042015-01-26 10:57:07 -0800457enum bpf_func_id {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800458 __BPF_FUNC_MAPPER(__BPF_ENUM_FN) __BPF_FUNC_MAX_ID,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800459};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800460#undef __BPF_ENUM_FN
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700461enum {
462 BPF_F_RECOMPUTE_CSUM = (1ULL << 0),
463 BPF_F_INVALIDATE_HASH = (1ULL << 1),
464};
465enum {
466 BPF_F_HDR_FIELD_MASK = 0xfULL,
467};
468enum {
469 BPF_F_PSEUDO_HDR = (1ULL << 4),
470 BPF_F_MARK_MANGLED_0 = (1ULL << 5),
471 BPF_F_MARK_ENFORCE = (1ULL << 6),
472};
473enum {
474 BPF_F_INGRESS = (1ULL << 0),
475};
476enum {
477 BPF_F_TUNINFO_IPV6 = (1ULL << 0),
478};
479enum {
480 BPF_F_SKIP_FIELD_MASK = 0xffULL,
481 BPF_F_USER_STACK = (1ULL << 8),
482 BPF_F_FAST_STACK_CMP = (1ULL << 9),
483 BPF_F_REUSE_STACKID = (1ULL << 10),
484 BPF_F_USER_BUILD_ID = (1ULL << 11),
485};
486enum {
487 BPF_F_ZERO_CSUM_TX = (1ULL << 1),
488 BPF_F_DONT_FRAGMENT = (1ULL << 2),
489 BPF_F_SEQ_NUMBER = (1ULL << 3),
490};
491enum {
492 BPF_F_INDEX_MASK = 0xffffffffULL,
493 BPF_F_CURRENT_CPU = BPF_F_INDEX_MASK,
494 BPF_F_CTXLEN_MASK = (0xfffffULL << 32),
495};
496enum {
497 BPF_F_CURRENT_NETNS = (- 1L),
498};
499enum {
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700500 BPF_CSUM_LEVEL_QUERY,
501 BPF_CSUM_LEVEL_INC,
502 BPF_CSUM_LEVEL_DEC,
503 BPF_CSUM_LEVEL_RESET,
504};
505enum {
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700506 BPF_F_ADJ_ROOM_FIXED_GSO = (1ULL << 0),
507 BPF_F_ADJ_ROOM_ENCAP_L3_IPV4 = (1ULL << 1),
508 BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 = (1ULL << 2),
509 BPF_F_ADJ_ROOM_ENCAP_L4_GRE = (1ULL << 3),
510 BPF_F_ADJ_ROOM_ENCAP_L4_UDP = (1ULL << 4),
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700511 BPF_F_ADJ_ROOM_NO_CSUM_RESET = (1ULL << 5),
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700512};
513enum {
514 BPF_ADJ_ROOM_ENCAP_L2_MASK = 0xff,
515 BPF_ADJ_ROOM_ENCAP_L2_SHIFT = 56,
516};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700517#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 -0700518enum {
519 BPF_F_SYSCTL_BASE_NAME = (1ULL << 0),
520};
521enum {
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800522 BPF_LOCAL_STORAGE_GET_F_CREATE = (1ULL << 0),
523 BPF_SK_STORAGE_GET_F_CREATE = BPF_LOCAL_STORAGE_GET_F_CREATE,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700524};
525enum {
526 BPF_F_GET_BRANCH_RECORDS_SIZE = (1ULL << 0),
527};
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700528enum {
529 BPF_RB_NO_WAKEUP = (1ULL << 0),
530 BPF_RB_FORCE_WAKEUP = (1ULL << 1),
531};
532enum {
533 BPF_RB_AVAIL_DATA = 0,
534 BPF_RB_RING_SIZE = 1,
535 BPF_RB_CONS_POS = 2,
536 BPF_RB_PROD_POS = 3,
537};
538enum {
539 BPF_RINGBUF_BUSY_BIT = (1U << 31),
540 BPF_RINGBUF_DISCARD_BIT = (1U << 30),
541 BPF_RINGBUF_HDR_SZ = 8,
542};
Christopher Ferris25c18d42020-10-14 17:42:58 -0700543enum {
544 BPF_SK_LOOKUP_F_REPLACE = (1ULL << 0),
545 BPF_SK_LOOKUP_F_NO_REUSEPORT = (1ULL << 1),
546};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800547enum bpf_adj_room_mode {
548 BPF_ADJ_ROOM_NET,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700549 BPF_ADJ_ROOM_MAC,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800550};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700551enum bpf_hdr_start_off {
552 BPF_HDR_START_MAC,
553 BPF_HDR_START_NET,
554};
555enum bpf_lwt_encap_mode {
556 BPF_LWT_ENCAP_SEG6,
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700557 BPF_LWT_ENCAP_SEG6_INLINE,
558 BPF_LWT_ENCAP_IP,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700559};
Christopher Ferris86a48372019-01-10 14:14:59 -0800560#define __bpf_md_ptr(type,name) union { type name; __u64 : 64; \
561} __attribute__((aligned(8)))
Christopher Ferris49f525c2016-12-12 14:55:36 -0800562struct __sk_buff {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800563 __u32 len;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800564 __u32 pkt_type;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800565 __u32 mark;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800566 __u32 queue_mapping;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800567 __u32 protocol;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800568 __u32 vlan_present;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800569 __u32 vlan_tci;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800570 __u32 vlan_proto;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800571 __u32 priority;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800572 __u32 ingress_ifindex;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800573 __u32 ifindex;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800574 __u32 tc_index;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800575 __u32 cb[5];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800576 __u32 hash;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800577 __u32 tc_classid;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800578 __u32 data;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800579 __u32 data_end;
Christopher Ferris525ce912017-07-26 13:12:53 -0700580 __u32 napi_id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800581 __u32 family;
582 __u32 remote_ip4;
583 __u32 local_ip4;
584 __u32 remote_ip6[4];
585 __u32 local_ip6[4];
586 __u32 remote_port;
587 __u32 local_port;
Christopher Ferris934ec942018-01-31 15:29:16 -0800588 __u32 data_meta;
Christopher Ferris86a48372019-01-10 14:14:59 -0800589 __bpf_md_ptr(struct bpf_flow_keys *, flow_keys);
Christopher Ferrisd842e432019-03-07 10:21:59 -0800590 __u64 tstamp;
591 __u32 wire_len;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700592 __u32 gso_segs;
593 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700594 __u32 gso_size;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800595};
596struct bpf_tunnel_key {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800597 __u32 tunnel_id;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800598 union {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700599 __u32 remote_ipv4;
600 __u32 remote_ipv6[4];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800601 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800602 __u8 tunnel_tos;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700603 __u8 tunnel_ttl;
604 __u16 tunnel_ext;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800605 __u32 tunnel_label;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800606};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700607struct bpf_xfrm_state {
608 __u32 reqid;
609 __u32 spi;
610 __u16 family;
611 __u16 ext;
612 union {
613 __u32 remote_ipv4;
614 __u32 remote_ipv6[4];
615 };
616};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800617enum bpf_ret_code {
618 BPF_OK = 0,
619 BPF_DROP = 2,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800620 BPF_REDIRECT = 7,
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700621 BPF_LWT_REROUTE = 128,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800622};
623struct bpf_sock {
624 __u32 bound_dev_if;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800625 __u32 family;
626 __u32 type;
627 __u32 protocol;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800628 __u32 mark;
629 __u32 priority;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700630 __u32 src_ip4;
631 __u32 src_ip6[4];
632 __u32 src_port;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700633 __u32 dst_port;
634 __u32 dst_ip4;
635 __u32 dst_ip6[4];
636 __u32 state;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700637 __s32 rx_queue_mapping;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700638};
639struct bpf_tcp_sock {
640 __u32 snd_cwnd;
641 __u32 srtt_us;
642 __u32 rtt_min;
643 __u32 snd_ssthresh;
644 __u32 rcv_nxt;
645 __u32 snd_nxt;
646 __u32 snd_una;
647 __u32 mss_cache;
648 __u32 ecn_flags;
649 __u32 rate_delivered;
650 __u32 rate_interval_us;
651 __u32 packets_out;
652 __u32 retrans_out;
653 __u32 total_retrans;
654 __u32 segs_in;
655 __u32 data_segs_in;
656 __u32 segs_out;
657 __u32 data_segs_out;
658 __u32 lost_out;
659 __u32 sacked_out;
660 __u64 bytes_received;
661 __u64 bytes_acked;
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700662 __u32 dsack_dups;
663 __u32 delivered;
664 __u32 delivered_ce;
665 __u32 icsk_retransmits;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800666};
Christopher Ferris86a48372019-01-10 14:14:59 -0800667struct bpf_sock_tuple {
668 union {
669 struct {
670 __be32 saddr;
671 __be32 daddr;
672 __be16 sport;
673 __be16 dport;
674 } ipv4;
675 struct {
676 __be32 saddr[4];
677 __be32 daddr[4];
678 __be16 sport;
679 __be16 dport;
680 } ipv6;
681 };
682};
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700683struct bpf_xdp_sock {
684 __u32 queue_id;
685};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800686#define XDP_PACKET_HEADROOM 256
Christopher Ferris49f525c2016-12-12 14:55:36 -0800687enum xdp_action {
688 XDP_ABORTED = 0,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800689 XDP_DROP,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800690 XDP_PASS,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800691 XDP_TX,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800692 XDP_REDIRECT,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800693};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800694struct xdp_md {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800695 __u32 data;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800696 __u32 data_end;
Christopher Ferris934ec942018-01-31 15:29:16 -0800697 __u32 data_meta;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700698 __u32 ingress_ifindex;
699 __u32 rx_queue_index;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700700 __u32 egress_ifindex;
701};
702struct bpf_devmap_val {
703 __u32 ifindex;
704 union {
705 int fd;
706 __u32 id;
707 } bpf_prog;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800708};
Christopher Ferris25c18d42020-10-14 17:42:58 -0700709struct bpf_cpumap_val {
710 __u32 qsize;
711 union {
712 int fd;
713 __u32 id;
714 } bpf_prog;
715};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800716enum sk_action {
717 SK_DROP = 0,
718 SK_PASS,
719};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700720struct sk_msg_md {
Christopher Ferris86a48372019-01-10 14:14:59 -0800721 __bpf_md_ptr(void *, data);
722 __bpf_md_ptr(void *, data_end);
Christopher Ferris9ce28842018-10-25 12:11:39 -0700723 __u32 family;
724 __u32 remote_ip4;
725 __u32 local_ip4;
726 __u32 remote_ip6[4];
727 __u32 local_ip6[4];
728 __u32 remote_port;
729 __u32 local_port;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800730 __u32 size;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700731 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferris9ce28842018-10-25 12:11:39 -0700732};
733struct sk_reuseport_md {
Christopher Ferris86a48372019-01-10 14:14:59 -0800734 __bpf_md_ptr(void *, data);
735 __bpf_md_ptr(void *, data_end);
Christopher Ferris9ce28842018-10-25 12:11:39 -0700736 __u32 len;
737 __u32 eth_protocol;
738 __u32 ip_protocol;
739 __u32 bind_inany;
740 __u32 hash;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700741};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800742#define BPF_TAG_SIZE 8
743struct bpf_prog_info {
744 __u32 type;
745 __u32 id;
746 __u8 tag[BPF_TAG_SIZE];
747 __u32 jited_prog_len;
748 __u32 xlated_prog_len;
749 __aligned_u64 jited_prog_insns;
750 __aligned_u64 xlated_prog_insns;
Christopher Ferris934ec942018-01-31 15:29:16 -0800751 __u64 load_time;
752 __u32 created_by_uid;
753 __u32 nr_map_ids;
754 __aligned_u64 map_ids;
755 char name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700756 __u32 ifindex;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700757 __u32 gpl_compatible : 1;
Christopher Ferrisfa59a102019-08-05 12:58:49 -0700758 __u32 : 31;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700759 __u64 netns_dev;
760 __u64 netns_ino;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700761 __u32 nr_jited_ksyms;
762 __u32 nr_jited_func_lens;
763 __aligned_u64 jited_ksyms;
764 __aligned_u64 jited_func_lens;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800765 __u32 btf_id;
766 __u32 func_info_rec_size;
767 __aligned_u64 func_info;
768 __u32 nr_func_info;
769 __u32 nr_line_info;
770 __aligned_u64 line_info;
771 __aligned_u64 jited_line_info;
772 __u32 nr_jited_line_info;
773 __u32 line_info_rec_size;
774 __u32 jited_line_info_rec_size;
775 __u32 nr_prog_tags;
776 __aligned_u64 prog_tags;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700777 __u64 run_time_ns;
778 __u64 run_cnt;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800779} __attribute__((aligned(8)));
780struct bpf_map_info {
781 __u32 type;
782 __u32 id;
783 __u32 key_size;
784 __u32 value_size;
785 __u32 max_entries;
786 __u32 map_flags;
Christopher Ferris934ec942018-01-31 15:29:16 -0800787 char name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700788 __u32 ifindex;
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700789 __u32 btf_vmlinux_value_type_id;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700790 __u64 netns_dev;
791 __u64 netns_ino;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700792 __u32 btf_id;
793 __u32 btf_key_type_id;
794 __u32 btf_value_type_id;
795} __attribute__((aligned(8)));
796struct bpf_btf_info {
797 __aligned_u64 btf;
798 __u32 btf_size;
799 __u32 id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800800} __attribute__((aligned(8)));
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700801struct bpf_link_info {
802 __u32 type;
803 __u32 id;
804 __u32 prog_id;
805 union {
806 struct {
807 __aligned_u64 tp_name;
808 __u32 tp_name_len;
809 } raw_tracepoint;
810 struct {
811 __u32 attach_type;
812 } tracing;
813 struct {
814 __u64 cgroup_id;
815 __u32 attach_type;
816 } cgroup;
817 struct {
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800818 __aligned_u64 target_name;
819 __u32 target_name_len;
820 union {
821 struct {
822 __u32 map_id;
823 } map;
824 };
825 } iter;
826 struct {
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700827 __u32 netns_ino;
828 __u32 attach_type;
829 } netns;
Christopher Ferris25c18d42020-10-14 17:42:58 -0700830 struct {
831 __u32 ifindex;
832 } xdp;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700833 };
834} __attribute__((aligned(8)));
Christopher Ferris76a1d452018-06-27 14:12:29 -0700835struct bpf_sock_addr {
836 __u32 user_family;
837 __u32 user_ip4;
838 __u32 user_ip6[4];
839 __u32 user_port;
840 __u32 family;
841 __u32 type;
842 __u32 protocol;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700843 __u32 msg_src_ip4;
844 __u32 msg_src_ip6[4];
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700845 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferris76a1d452018-06-27 14:12:29 -0700846};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800847struct bpf_sock_ops {
848 __u32 op;
849 union {
Christopher Ferris76a1d452018-06-27 14:12:29 -0700850 __u32 args[4];
Christopher Ferris1308ad32017-11-14 17:32:13 -0800851 __u32 reply;
852 __u32 replylong[4];
853 };
854 __u32 family;
855 __u32 remote_ip4;
856 __u32 local_ip4;
857 __u32 remote_ip6[4];
858 __u32 local_ip6[4];
859 __u32 remote_port;
860 __u32 local_port;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700861 __u32 is_fullsock;
862 __u32 snd_cwnd;
863 __u32 srtt_us;
864 __u32 bpf_sock_ops_cb_flags;
865 __u32 state;
866 __u32 rtt_min;
867 __u32 snd_ssthresh;
868 __u32 rcv_nxt;
869 __u32 snd_nxt;
870 __u32 snd_una;
871 __u32 mss_cache;
872 __u32 ecn_flags;
873 __u32 rate_delivered;
874 __u32 rate_interval_us;
875 __u32 packets_out;
876 __u32 retrans_out;
877 __u32 total_retrans;
878 __u32 segs_in;
879 __u32 data_segs_in;
880 __u32 segs_out;
881 __u32 data_segs_out;
882 __u32 lost_out;
883 __u32 sacked_out;
884 __u32 sk_txhash;
885 __u64 bytes_received;
886 __u64 bytes_acked;
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700887 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800888 __bpf_md_ptr(void *, skb_data);
889 __bpf_md_ptr(void *, skb_data_end);
890 __u32 skb_len;
891 __u32 skb_tcp_flags;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800892};
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700893enum {
894 BPF_SOCK_OPS_RTO_CB_FLAG = (1 << 0),
895 BPF_SOCK_OPS_RETRANS_CB_FLAG = (1 << 1),
896 BPF_SOCK_OPS_STATE_CB_FLAG = (1 << 2),
897 BPF_SOCK_OPS_RTT_CB_FLAG = (1 << 3),
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800898 BPF_SOCK_OPS_PARSE_ALL_HDR_OPT_CB_FLAG = (1 << 4),
899 BPF_SOCK_OPS_PARSE_UNKNOWN_HDR_OPT_CB_FLAG = (1 << 5),
900 BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG = (1 << 6),
901 BPF_SOCK_OPS_ALL_CB_FLAGS = 0x7F,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700902};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800903enum {
904 BPF_SOCK_OPS_VOID,
905 BPF_SOCK_OPS_TIMEOUT_INIT,
906 BPF_SOCK_OPS_RWND_INIT,
907 BPF_SOCK_OPS_TCP_CONNECT_CB,
908 BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB,
909 BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB,
910 BPF_SOCK_OPS_NEEDS_ECN,
Christopher Ferris934ec942018-01-31 15:29:16 -0800911 BPF_SOCK_OPS_BASE_RTT,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700912 BPF_SOCK_OPS_RTO_CB,
913 BPF_SOCK_OPS_RETRANS_CB,
914 BPF_SOCK_OPS_STATE_CB,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700915 BPF_SOCK_OPS_TCP_LISTEN_CB,
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700916 BPF_SOCK_OPS_RTT_CB,
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800917 BPF_SOCK_OPS_PARSE_HDR_OPT_CB,
918 BPF_SOCK_OPS_HDR_OPT_LEN_CB,
919 BPF_SOCK_OPS_WRITE_HDR_OPT_CB,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700920};
921enum {
922 BPF_TCP_ESTABLISHED = 1,
923 BPF_TCP_SYN_SENT,
924 BPF_TCP_SYN_RECV,
925 BPF_TCP_FIN_WAIT1,
926 BPF_TCP_FIN_WAIT2,
927 BPF_TCP_TIME_WAIT,
928 BPF_TCP_CLOSE,
929 BPF_TCP_CLOSE_WAIT,
930 BPF_TCP_LAST_ACK,
931 BPF_TCP_LISTEN,
932 BPF_TCP_CLOSING,
933 BPF_TCP_NEW_SYN_RECV,
934 BPF_TCP_MAX_STATES
Christopher Ferris1308ad32017-11-14 17:32:13 -0800935};
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700936enum {
937 TCP_BPF_IW = 1001,
938 TCP_BPF_SNDCWND_CLAMP = 1002,
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800939 TCP_BPF_DELACK_MAX = 1003,
940 TCP_BPF_RTO_MIN = 1004,
941 TCP_BPF_SYN = 1005,
942 TCP_BPF_SYN_IP = 1006,
943 TCP_BPF_SYN_MAC = 1007,
944};
945enum {
946 BPF_LOAD_HDR_OPT_TCP_SYN = (1ULL << 0),
947};
948enum {
949 BPF_WRITE_HDR_TCP_CURRENT_MSS = 1,
950 BPF_WRITE_HDR_TCP_SYNACK_COOKIE = 2,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700951};
Christopher Ferris934ec942018-01-31 15:29:16 -0800952struct bpf_perf_event_value {
953 __u64 counter;
954 __u64 enabled;
955 __u64 running;
956};
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700957enum {
958 BPF_DEVCG_ACC_MKNOD = (1ULL << 0),
959 BPF_DEVCG_ACC_READ = (1ULL << 1),
960 BPF_DEVCG_ACC_WRITE = (1ULL << 2),
961};
962enum {
963 BPF_DEVCG_DEV_BLOCK = (1ULL << 0),
964 BPF_DEVCG_DEV_CHAR = (1ULL << 1),
965};
Christopher Ferris934ec942018-01-31 15:29:16 -0800966struct bpf_cgroup_dev_ctx {
967 __u32 access_type;
968 __u32 major;
969 __u32 minor;
970};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700971struct bpf_raw_tracepoint_args {
972 __u64 args[0];
973};
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700974enum {
975 BPF_FIB_LOOKUP_DIRECT = (1U << 0),
976 BPF_FIB_LOOKUP_OUTPUT = (1U << 1),
977};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700978enum {
979 BPF_FIB_LKUP_RET_SUCCESS,
980 BPF_FIB_LKUP_RET_BLACKHOLE,
981 BPF_FIB_LKUP_RET_UNREACHABLE,
982 BPF_FIB_LKUP_RET_PROHIBIT,
983 BPF_FIB_LKUP_RET_NOT_FWDED,
984 BPF_FIB_LKUP_RET_FWD_DISABLED,
985 BPF_FIB_LKUP_RET_UNSUPP_LWT,
986 BPF_FIB_LKUP_RET_NO_NEIGH,
987 BPF_FIB_LKUP_RET_FRAG_NEEDED,
988};
989struct bpf_fib_lookup {
990 __u8 family;
991 __u8 l4_protocol;
992 __be16 sport;
993 __be16 dport;
994 __u16 tot_len;
995 __u32 ifindex;
996 union {
997 __u8 tos;
998 __be32 flowinfo;
999 __u32 rt_metric;
1000 };
1001 union {
1002 __be32 ipv4_src;
1003 __u32 ipv6_src[4];
1004 };
1005 union {
1006 __be32 ipv4_dst;
1007 __u32 ipv6_dst[4];
1008 };
1009 __be16 h_vlan_proto;
1010 __be16 h_vlan_TCI;
1011 __u8 smac[6];
1012 __u8 dmac[6];
1013};
Christopher Ferris32ff3f82020-12-14 13:10:04 -08001014struct bpf_redir_neigh {
1015 __u32 nh_family;
1016 union {
1017 __be32 ipv4_nh;
1018 __u32 ipv6_nh[4];
1019 };
1020};
Christopher Ferris9ce28842018-10-25 12:11:39 -07001021enum bpf_task_fd_type {
1022 BPF_FD_TYPE_RAW_TRACEPOINT,
1023 BPF_FD_TYPE_TRACEPOINT,
1024 BPF_FD_TYPE_KPROBE,
1025 BPF_FD_TYPE_KRETPROBE,
1026 BPF_FD_TYPE_UPROBE,
1027 BPF_FD_TYPE_URETPROBE,
1028};
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001029enum {
1030 BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG = (1U << 0),
1031 BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL = (1U << 1),
1032 BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP = (1U << 2),
1033};
Christopher Ferris86a48372019-01-10 14:14:59 -08001034struct bpf_flow_keys {
1035 __u16 nhoff;
1036 __u16 thoff;
1037 __u16 addr_proto;
1038 __u8 is_frag;
1039 __u8 is_first_frag;
1040 __u8 is_encap;
1041 __u8 ip_proto;
1042 __be16 n_proto;
1043 __be16 sport;
1044 __be16 dport;
1045 union {
1046 struct {
1047 __be32 ipv4_src;
1048 __be32 ipv4_dst;
1049 };
1050 struct {
1051 __u32 ipv6_src[4];
1052 __u32 ipv6_dst[4];
1053 };
1054 };
Christopher Ferris9584fa42019-12-09 15:36:13 -08001055 __u32 flags;
1056 __be32 flow_label;
Christopher Ferris86a48372019-01-10 14:14:59 -08001057};
Christopher Ferrisd842e432019-03-07 10:21:59 -08001058struct bpf_func_info {
1059 __u32 insn_off;
1060 __u32 type_id;
1061};
1062#define BPF_LINE_INFO_LINE_NUM(line_col) ((line_col) >> 10)
1063#define BPF_LINE_INFO_LINE_COL(line_col) ((line_col) & 0x3ff)
1064struct bpf_line_info {
1065 __u32 insn_off;
1066 __u32 file_name_off;
1067 __u32 line_off;
1068 __u32 line_col;
1069};
Christopher Ferris24f97eb2019-05-20 12:58:13 -07001070struct bpf_spin_lock {
1071 __u32 val;
1072};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -07001073struct bpf_sysctl {
1074 __u32 write;
1075 __u32 file_pos;
1076};
Christopher Ferrisb8a95e22019-10-02 18:29:20 -07001077struct bpf_sockopt {
1078 __bpf_md_ptr(struct bpf_sock *, sk);
1079 __bpf_md_ptr(void *, optval);
1080 __bpf_md_ptr(void *, optval_end);
1081 __s32 level;
1082 __s32 optname;
1083 __s32 optlen;
1084 __s32 retval;
1085};
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001086struct bpf_pidns_info {
1087 __u32 pid;
1088 __u32 tgid;
1089};
Christopher Ferris25c18d42020-10-14 17:42:58 -07001090struct bpf_sk_lookup {
1091 __bpf_md_ptr(struct bpf_sock *, sk);
1092 __u32 family;
1093 __u32 protocol;
1094 __u32 remote_ip4;
1095 __u32 remote_ip6[4];
1096 __u32 remote_port;
1097 __u32 local_ip4;
1098 __u32 local_ip6[4];
1099 __u32 local_port;
1100};
Christopher Ferris32ff3f82020-12-14 13:10:04 -08001101struct btf_ptr {
1102 void * ptr;
1103 __u32 type_id;
1104 __u32 flags;
1105};
1106enum {
1107 BTF_F_COMPACT = (1ULL << 0),
1108 BTF_F_NONAME = (1ULL << 1),
1109 BTF_F_PTR_RAW = (1ULL << 2),
1110 BTF_F_ZERO = (1ULL << 3),
1111};
Christopher Ferris82d75042015-01-26 10:57:07 -08001112#endif