blob: 9da6b441d97e3b722581bb6301fe807898ffd925 [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
Christopher Ferrisa9750ed2021-05-03 14:02:49 -070026#define BPF_ATOMIC 0xc0
Christopher Ferris82d75042015-01-26 10:57:07 -080027#define BPF_XADD 0xc0
28#define BPF_MOV 0xb0
Christopher Ferris82d75042015-01-26 10:57:07 -080029#define BPF_ARSH 0xc0
30#define BPF_END 0xd0
31#define BPF_TO_LE 0x00
32#define BPF_TO_BE 0x08
Christopher Ferris82d75042015-01-26 10:57:07 -080033#define BPF_FROM_LE BPF_TO_LE
34#define BPF_FROM_BE BPF_TO_BE
35#define BPF_JNE 0x50
Christopher Ferris1308ad32017-11-14 17:32:13 -080036#define BPF_JLT 0xa0
37#define BPF_JLE 0xb0
Christopher Ferris82d75042015-01-26 10:57:07 -080038#define BPF_JSGT 0x60
Christopher Ferris82d75042015-01-26 10:57:07 -080039#define BPF_JSGE 0x70
Christopher Ferris1308ad32017-11-14 17:32:13 -080040#define BPF_JSLT 0xc0
41#define BPF_JSLE 0xd0
Christopher Ferris82d75042015-01-26 10:57:07 -080042#define BPF_CALL 0x80
43#define BPF_EXIT 0x90
Christopher Ferrisa9750ed2021-05-03 14:02:49 -070044#define BPF_FETCH 0x01
45#define BPF_XCHG (0xe0 | BPF_FETCH)
46#define BPF_CMPXCHG (0xf0 | BPF_FETCH)
Christopher Ferris82d75042015-01-26 10:57:07 -080047enum {
Tao Baod7db5942015-01-28 10:07:51 -080048 BPF_REG_0 = 0,
49 BPF_REG_1,
50 BPF_REG_2,
51 BPF_REG_3,
Tao Baod7db5942015-01-28 10:07:51 -080052 BPF_REG_4,
53 BPF_REG_5,
54 BPF_REG_6,
55 BPF_REG_7,
Tao Baod7db5942015-01-28 10:07:51 -080056 BPF_REG_8,
57 BPF_REG_9,
58 BPF_REG_10,
59 __MAX_BPF_REG,
Christopher Ferris82d75042015-01-26 10:57:07 -080060};
61#define MAX_BPF_REG __MAX_BPF_REG
62struct bpf_insn {
Tao Baod7db5942015-01-28 10:07:51 -080063 __u8 code;
Tao Baod7db5942015-01-28 10:07:51 -080064 __u8 dst_reg : 4;
65 __u8 src_reg : 4;
66 __s16 off;
67 __s32 imm;
Christopher Ferris82d75042015-01-26 10:57:07 -080068};
Christopher Ferris525ce912017-07-26 13:12:53 -070069struct bpf_lpm_trie_key {
70 __u32 prefixlen;
71 __u8 data[0];
72};
Christopher Ferris9ce28842018-10-25 12:11:39 -070073struct bpf_cgroup_storage_key {
74 __u64 cgroup_inode_id;
75 __u32 attach_type;
76};
Christopher Ferris25c18d42020-10-14 17:42:58 -070077union bpf_iter_link_info {
78 struct {
79 __u32 map_fd;
80 } map;
81};
Christopher Ferris82d75042015-01-26 10:57:07 -080082enum bpf_cmd {
Tao Baod7db5942015-01-28 10:07:51 -080083 BPF_MAP_CREATE,
84 BPF_MAP_LOOKUP_ELEM,
Tao Baod7db5942015-01-28 10:07:51 -080085 BPF_MAP_UPDATE_ELEM,
86 BPF_MAP_DELETE_ELEM,
87 BPF_MAP_GET_NEXT_KEY,
88 BPF_PROG_LOAD,
Christopher Ferris05d08e92016-02-04 13:16:38 -080089 BPF_OBJ_PIN,
90 BPF_OBJ_GET,
Christopher Ferris48af7cb2017-02-21 12:35:09 -080091 BPF_PROG_ATTACH,
92 BPF_PROG_DETACH,
Christopher Ferris525ce912017-07-26 13:12:53 -070093 BPF_PROG_TEST_RUN,
Christopher Ferris1308ad32017-11-14 17:32:13 -080094 BPF_PROG_GET_NEXT_ID,
95 BPF_MAP_GET_NEXT_ID,
96 BPF_PROG_GET_FD_BY_ID,
97 BPF_MAP_GET_FD_BY_ID,
98 BPF_OBJ_GET_INFO_BY_FD,
Christopher Ferris934ec942018-01-31 15:29:16 -080099 BPF_PROG_QUERY,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700100 BPF_RAW_TRACEPOINT_OPEN,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700101 BPF_BTF_LOAD,
102 BPF_BTF_GET_FD_BY_ID,
103 BPF_TASK_FD_QUERY,
Christopher Ferris86a48372019-01-10 14:14:59 -0800104 BPF_MAP_LOOKUP_AND_DELETE_ELEM,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700105 BPF_MAP_FREEZE,
Christopher Ferris9584fa42019-12-09 15:36:13 -0800106 BPF_BTF_GET_NEXT_ID,
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700107 BPF_MAP_LOOKUP_BATCH,
108 BPF_MAP_LOOKUP_AND_DELETE_BATCH,
109 BPF_MAP_UPDATE_BATCH,
110 BPF_MAP_DELETE_BATCH,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700111 BPF_LINK_CREATE,
112 BPF_LINK_UPDATE,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700113 BPF_LINK_GET_FD_BY_ID,
114 BPF_LINK_GET_NEXT_ID,
115 BPF_ENABLE_STATS,
116 BPF_ITER_CREATE,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700117 BPF_LINK_DETACH,
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800118 BPF_PROG_BIND_MAP,
Christopher Ferris82d75042015-01-26 10:57:07 -0800119};
120enum bpf_map_type {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800121 BPF_MAP_TYPE_UNSPEC,
122 BPF_MAP_TYPE_HASH,
123 BPF_MAP_TYPE_ARRAY,
124 BPF_MAP_TYPE_PROG_ARRAY,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800125 BPF_MAP_TYPE_PERF_EVENT_ARRAY,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700126 BPF_MAP_TYPE_PERCPU_HASH,
127 BPF_MAP_TYPE_PERCPU_ARRAY,
128 BPF_MAP_TYPE_STACK_TRACE,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800129 BPF_MAP_TYPE_CGROUP_ARRAY,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800130 BPF_MAP_TYPE_LRU_HASH,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800131 BPF_MAP_TYPE_LRU_PERCPU_HASH,
Christopher Ferris525ce912017-07-26 13:12:53 -0700132 BPF_MAP_TYPE_LPM_TRIE,
133 BPF_MAP_TYPE_ARRAY_OF_MAPS,
134 BPF_MAP_TYPE_HASH_OF_MAPS,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800135 BPF_MAP_TYPE_DEVMAP,
136 BPF_MAP_TYPE_SOCKMAP,
Christopher Ferris934ec942018-01-31 15:29:16 -0800137 BPF_MAP_TYPE_CPUMAP,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700138 BPF_MAP_TYPE_XSKMAP,
139 BPF_MAP_TYPE_SOCKHASH,
140 BPF_MAP_TYPE_CGROUP_STORAGE,
141 BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,
Christopher Ferris86a48372019-01-10 14:14:59 -0800142 BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,
143 BPF_MAP_TYPE_QUEUE,
144 BPF_MAP_TYPE_STACK,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700145 BPF_MAP_TYPE_SK_STORAGE,
Christopher Ferris9584fa42019-12-09 15:36:13 -0800146 BPF_MAP_TYPE_DEVMAP_HASH,
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700147 BPF_MAP_TYPE_STRUCT_OPS,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700148 BPF_MAP_TYPE_RINGBUF,
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800149 BPF_MAP_TYPE_INODE_STORAGE,
Christopher Ferris05667cd2021-02-16 16:01:34 -0800150 BPF_MAP_TYPE_TASK_STORAGE,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800151};
Christopher Ferris82d75042015-01-26 10:57:07 -0800152enum bpf_prog_type {
Tao Baod7db5942015-01-28 10:07:51 -0800153 BPF_PROG_TYPE_UNSPEC,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800154 BPF_PROG_TYPE_SOCKET_FILTER,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800155 BPF_PROG_TYPE_KPROBE,
156 BPF_PROG_TYPE_SCHED_CLS,
157 BPF_PROG_TYPE_SCHED_ACT,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800158 BPF_PROG_TYPE_TRACEPOINT,
159 BPF_PROG_TYPE_XDP,
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800160 BPF_PROG_TYPE_PERF_EVENT,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800161 BPF_PROG_TYPE_CGROUP_SKB,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800162 BPF_PROG_TYPE_CGROUP_SOCK,
163 BPF_PROG_TYPE_LWT_IN,
164 BPF_PROG_TYPE_LWT_OUT,
165 BPF_PROG_TYPE_LWT_XMIT,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800166 BPF_PROG_TYPE_SOCK_OPS,
167 BPF_PROG_TYPE_SK_SKB,
Christopher Ferris934ec942018-01-31 15:29:16 -0800168 BPF_PROG_TYPE_CGROUP_DEVICE,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700169 BPF_PROG_TYPE_SK_MSG,
170 BPF_PROG_TYPE_RAW_TRACEPOINT,
171 BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700172 BPF_PROG_TYPE_LWT_SEG6LOCAL,
173 BPF_PROG_TYPE_LIRC_MODE2,
174 BPF_PROG_TYPE_SK_REUSEPORT,
Christopher Ferris86a48372019-01-10 14:14:59 -0800175 BPF_PROG_TYPE_FLOW_DISSECTOR,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700176 BPF_PROG_TYPE_CGROUP_SYSCTL,
177 BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE,
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700178 BPF_PROG_TYPE_CGROUP_SOCKOPT,
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800179 BPF_PROG_TYPE_TRACING,
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700180 BPF_PROG_TYPE_STRUCT_OPS,
181 BPF_PROG_TYPE_EXT,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700182 BPF_PROG_TYPE_LSM,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700183 BPF_PROG_TYPE_SK_LOOKUP,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800184};
185enum bpf_attach_type {
186 BPF_CGROUP_INET_INGRESS,
187 BPF_CGROUP_INET_EGRESS,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800188 BPF_CGROUP_INET_SOCK_CREATE,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800189 BPF_CGROUP_SOCK_OPS,
190 BPF_SK_SKB_STREAM_PARSER,
191 BPF_SK_SKB_STREAM_VERDICT,
Christopher Ferris934ec942018-01-31 15:29:16 -0800192 BPF_CGROUP_DEVICE,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700193 BPF_SK_MSG_VERDICT,
194 BPF_CGROUP_INET4_BIND,
195 BPF_CGROUP_INET6_BIND,
196 BPF_CGROUP_INET4_CONNECT,
197 BPF_CGROUP_INET6_CONNECT,
198 BPF_CGROUP_INET4_POST_BIND,
199 BPF_CGROUP_INET6_POST_BIND,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700200 BPF_CGROUP_UDP4_SENDMSG,
201 BPF_CGROUP_UDP6_SENDMSG,
202 BPF_LIRC_MODE2,
Christopher Ferris86a48372019-01-10 14:14:59 -0800203 BPF_FLOW_DISSECTOR,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700204 BPF_CGROUP_SYSCTL,
205 BPF_CGROUP_UDP4_RECVMSG,
206 BPF_CGROUP_UDP6_RECVMSG,
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700207 BPF_CGROUP_GETSOCKOPT,
208 BPF_CGROUP_SETSOCKOPT,
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800209 BPF_TRACE_RAW_TP,
210 BPF_TRACE_FENTRY,
211 BPF_TRACE_FEXIT,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700212 BPF_MODIFY_RETURN,
213 BPF_LSM_MAC,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700214 BPF_TRACE_ITER,
215 BPF_CGROUP_INET4_GETPEERNAME,
216 BPF_CGROUP_INET6_GETPEERNAME,
217 BPF_CGROUP_INET4_GETSOCKNAME,
218 BPF_CGROUP_INET6_GETSOCKNAME,
219 BPF_XDP_DEVMAP,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700220 BPF_CGROUP_INET_SOCK_RELEASE,
221 BPF_XDP_CPUMAP,
222 BPF_SK_LOOKUP,
223 BPF_XDP,
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000224 BPF_SK_SKB_VERDICT,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800225 __MAX_BPF_ATTACH_TYPE
226};
227#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700228enum bpf_link_type {
229 BPF_LINK_TYPE_UNSPEC = 0,
230 BPF_LINK_TYPE_RAW_TRACEPOINT = 1,
231 BPF_LINK_TYPE_TRACING = 2,
232 BPF_LINK_TYPE_CGROUP = 3,
233 BPF_LINK_TYPE_ITER = 4,
234 BPF_LINK_TYPE_NETNS = 5,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700235 BPF_LINK_TYPE_XDP = 6,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700236 MAX_BPF_LINK_TYPE,
237};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800238#define BPF_F_ALLOW_OVERRIDE (1U << 0)
Christopher Ferris934ec942018-01-31 15:29:16 -0800239#define BPF_F_ALLOW_MULTI (1U << 1)
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700240#define BPF_F_REPLACE (1U << 2)
Christopher Ferris525ce912017-07-26 13:12:53 -0700241#define BPF_F_STRICT_ALIGNMENT (1U << 0)
Christopher Ferrisd842e432019-03-07 10:21:59 -0800242#define BPF_F_ANY_ALIGNMENT (1U << 1)
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700243#define BPF_F_TEST_RND_HI32 (1U << 2)
Christopher Ferris9584fa42019-12-09 15:36:13 -0800244#define BPF_F_TEST_STATE_FREQ (1U << 3)
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800245#define BPF_F_SLEEPABLE (1U << 4)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800246#define BPF_PSEUDO_MAP_FD 1
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700247#define BPF_PSEUDO_MAP_VALUE 2
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800248#define BPF_PSEUDO_BTF_ID 3
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000249#define BPF_PSEUDO_FUNC 4
Christopher Ferris76a1d452018-06-27 14:12:29 -0700250#define BPF_PSEUDO_CALL 1
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000251#define BPF_PSEUDO_KFUNC_CALL 2
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700252enum {
253 BPF_ANY = 0,
254 BPF_NOEXIST = 1,
255 BPF_EXIST = 2,
256 BPF_F_LOCK = 4,
257};
258enum {
259 BPF_F_NO_PREALLOC = (1U << 0),
260 BPF_F_NO_COMMON_LRU = (1U << 1),
261 BPF_F_NUMA_NODE = (1U << 2),
262 BPF_F_RDONLY = (1U << 3),
263 BPF_F_WRONLY = (1U << 4),
264 BPF_F_STACK_BUILD_ID = (1U << 5),
265 BPF_F_ZERO_SEED = (1U << 6),
266 BPF_F_RDONLY_PROG = (1U << 7),
267 BPF_F_WRONLY_PROG = (1U << 8),
268 BPF_F_CLONE = (1U << 9),
269 BPF_F_MMAPABLE = (1U << 10),
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800270 BPF_F_PRESERVE_ELEMS = (1U << 11),
271 BPF_F_INNER_MAP = (1U << 12),
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700272};
Christopher Ferrisd842e432019-03-07 10:21:59 -0800273#define BPF_F_QUERY_EFFECTIVE (1U << 0)
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800274#define BPF_F_TEST_RUN_ON_CPU (1U << 0)
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700275enum bpf_stats_type {
276 BPF_STATS_RUN_TIME = 0,
277};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700278enum bpf_stack_build_id_status {
279 BPF_STACK_BUILD_ID_EMPTY = 0,
280 BPF_STACK_BUILD_ID_VALID = 1,
281 BPF_STACK_BUILD_ID_IP = 2,
282};
283#define BPF_BUILD_ID_SIZE 20
284struct bpf_stack_build_id {
285 __s32 status;
286 unsigned char build_id[BPF_BUILD_ID_SIZE];
287 union {
288 __u64 offset;
289 __u64 ip;
290 };
291};
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700292#define BPF_OBJ_NAME_LEN 16U
Christopher Ferris05d08e92016-02-04 13:16:38 -0800293union bpf_attr {
Tao Baod7db5942015-01-28 10:07:51 -0800294 struct {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700295 __u32 map_type;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800296 __u32 key_size;
Tao Baod7db5942015-01-28 10:07:51 -0800297 __u32 value_size;
Tao Baod7db5942015-01-28 10:07:51 -0800298 __u32 max_entries;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700299 __u32 map_flags;
Christopher Ferris525ce912017-07-26 13:12:53 -0700300 __u32 inner_map_fd;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800301 __u32 numa_node;
Christopher Ferris934ec942018-01-31 15:29:16 -0800302 char map_name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700303 __u32 map_ifindex;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700304 __u32 btf_fd;
305 __u32 btf_key_type_id;
306 __u32 btf_value_type_id;
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700307 __u32 btf_vmlinux_value_type_id;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800308 };
Tao Baod7db5942015-01-28 10:07:51 -0800309 struct {
310 __u32 map_fd;
Tao Baod7db5942015-01-28 10:07:51 -0800311 __aligned_u64 key;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800312 union {
Tao Baod7db5942015-01-28 10:07:51 -0800313 __aligned_u64 value;
314 __aligned_u64 next_key;
Tao Baod7db5942015-01-28 10:07:51 -0800315 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800316 __u64 flags;
Tao Baod7db5942015-01-28 10:07:51 -0800317 };
318 struct {
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700319 __aligned_u64 in_batch;
320 __aligned_u64 out_batch;
321 __aligned_u64 keys;
322 __aligned_u64 values;
323 __u32 count;
324 __u32 map_fd;
325 __u64 elem_flags;
326 __u64 flags;
327 } batch;
328 struct {
Tao Baod7db5942015-01-28 10:07:51 -0800329 __u32 prog_type;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800330 __u32 insn_cnt;
Tao Baod7db5942015-01-28 10:07:51 -0800331 __aligned_u64 insns;
332 __aligned_u64 license;
333 __u32 log_level;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800334 __u32 log_size;
Tao Baod7db5942015-01-28 10:07:51 -0800335 __aligned_u64 log_buf;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800336 __u32 kern_version;
Christopher Ferris525ce912017-07-26 13:12:53 -0700337 __u32 prog_flags;
Christopher Ferris934ec942018-01-31 15:29:16 -0800338 char prog_name[BPF_OBJ_NAME_LEN];
339 __u32 prog_ifindex;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700340 __u32 expected_attach_type;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800341 __u32 prog_btf_fd;
342 __u32 func_info_rec_size;
343 __aligned_u64 func_info;
344 __u32 func_info_cnt;
345 __u32 line_info_rec_size;
346 __aligned_u64 line_info;
347 __u32 line_info_cnt;
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800348 __u32 attach_btf_id;
Christopher Ferris05667cd2021-02-16 16:01:34 -0800349 union {
350 __u32 attach_prog_fd;
351 __u32 attach_btf_obj_fd;
352 };
Christopher Ferris05d08e92016-02-04 13:16:38 -0800353 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800354 struct {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800355 __aligned_u64 pathname;
356 __u32 bpf_fd;
Christopher Ferris934ec942018-01-31 15:29:16 -0800357 __u32 file_flags;
Tao Baod7db5942015-01-28 10:07:51 -0800358 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800359 struct {
360 __u32 target_fd;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800361 __u32 attach_bpf_fd;
362 __u32 attach_type;
363 __u32 attach_flags;
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700364 __u32 replace_bpf_fd;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800365 };
Christopher Ferris525ce912017-07-26 13:12:53 -0700366 struct {
367 __u32 prog_fd;
368 __u32 retval;
369 __u32 data_size_in;
370 __u32 data_size_out;
371 __aligned_u64 data_in;
372 __aligned_u64 data_out;
373 __u32 repeat;
374 __u32 duration;
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700375 __u32 ctx_size_in;
376 __u32 ctx_size_out;
377 __aligned_u64 ctx_in;
378 __aligned_u64 ctx_out;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800379 __u32 flags;
380 __u32 cpu;
Christopher Ferris525ce912017-07-26 13:12:53 -0700381 } test;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800382 struct {
383 union {
384 __u32 start_id;
385 __u32 prog_id;
386 __u32 map_id;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700387 __u32 btf_id;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700388 __u32 link_id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800389 };
390 __u32 next_id;
Christopher Ferris934ec942018-01-31 15:29:16 -0800391 __u32 open_flags;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800392 };
393 struct {
394 __u32 bpf_fd;
395 __u32 info_len;
396 __aligned_u64 info;
397 } info;
Christopher Ferris934ec942018-01-31 15:29:16 -0800398 struct {
399 __u32 target_fd;
400 __u32 attach_type;
401 __u32 query_flags;
402 __u32 attach_flags;
403 __aligned_u64 prog_ids;
404 __u32 prog_cnt;
405 } query;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700406 struct {
407 __u64 name;
408 __u32 prog_fd;
409 } raw_tracepoint;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700410 struct {
411 __aligned_u64 btf;
412 __aligned_u64 btf_log_buf;
413 __u32 btf_size;
414 __u32 btf_log_size;
415 __u32 btf_log_level;
416 };
417 struct {
418 __u32 pid;
419 __u32 fd;
420 __u32 flags;
421 __u32 buf_len;
422 __aligned_u64 buf;
423 __u32 prog_id;
424 __u32 fd_type;
425 __u64 probe_offset;
426 __u64 probe_addr;
427 } task_fd_query;
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700428 struct {
429 __u32 prog_fd;
Christopher Ferris25c18d42020-10-14 17:42:58 -0700430 union {
431 __u32 target_fd;
432 __u32 target_ifindex;
433 };
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700434 __u32 attach_type;
435 __u32 flags;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800436 union {
437 __u32 target_btf_id;
438 struct {
439 __aligned_u64 iter_info;
440 __u32 iter_info_len;
441 };
442 };
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700443 } link_create;
444 struct {
445 __u32 link_fd;
446 __u32 new_prog_fd;
447 __u32 flags;
448 __u32 old_prog_fd;
449 } link_update;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700450 struct {
Christopher Ferris25c18d42020-10-14 17:42:58 -0700451 __u32 link_fd;
452 } link_detach;
453 struct {
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700454 __u32 type;
455 } enable_stats;
456 struct {
457 __u32 link_fd;
458 __u32 flags;
459 } iter_create;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800460 struct {
461 __u32 prog_fd;
462 __u32 map_fd;
463 __u32 flags;
464 } prog_bind_map;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800465} __attribute__((aligned(8)));
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000466#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), FN(task_storage_get), FN(task_storage_delete), FN(get_current_task_btf), FN(bprm_opts_set), FN(ktime_get_coarse_ns), FN(ima_inode_hash), FN(sock_from_file), FN(check_mtu), FN(for_each_map_elem), FN(snprintf),
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800467#define __BPF_ENUM_FN(x) BPF_FUNC_ ##x
Christopher Ferris82d75042015-01-26 10:57:07 -0800468enum bpf_func_id {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800469 __BPF_FUNC_MAPPER(__BPF_ENUM_FN) __BPF_FUNC_MAX_ID,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800470};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800471#undef __BPF_ENUM_FN
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700472enum {
473 BPF_F_RECOMPUTE_CSUM = (1ULL << 0),
474 BPF_F_INVALIDATE_HASH = (1ULL << 1),
475};
476enum {
477 BPF_F_HDR_FIELD_MASK = 0xfULL,
478};
479enum {
480 BPF_F_PSEUDO_HDR = (1ULL << 4),
481 BPF_F_MARK_MANGLED_0 = (1ULL << 5),
482 BPF_F_MARK_ENFORCE = (1ULL << 6),
483};
484enum {
485 BPF_F_INGRESS = (1ULL << 0),
486};
487enum {
488 BPF_F_TUNINFO_IPV6 = (1ULL << 0),
489};
490enum {
491 BPF_F_SKIP_FIELD_MASK = 0xffULL,
492 BPF_F_USER_STACK = (1ULL << 8),
493 BPF_F_FAST_STACK_CMP = (1ULL << 9),
494 BPF_F_REUSE_STACKID = (1ULL << 10),
495 BPF_F_USER_BUILD_ID = (1ULL << 11),
496};
497enum {
498 BPF_F_ZERO_CSUM_TX = (1ULL << 1),
499 BPF_F_DONT_FRAGMENT = (1ULL << 2),
500 BPF_F_SEQ_NUMBER = (1ULL << 3),
501};
502enum {
503 BPF_F_INDEX_MASK = 0xffffffffULL,
504 BPF_F_CURRENT_CPU = BPF_F_INDEX_MASK,
505 BPF_F_CTXLEN_MASK = (0xfffffULL << 32),
506};
507enum {
508 BPF_F_CURRENT_NETNS = (- 1L),
509};
510enum {
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700511 BPF_CSUM_LEVEL_QUERY,
512 BPF_CSUM_LEVEL_INC,
513 BPF_CSUM_LEVEL_DEC,
514 BPF_CSUM_LEVEL_RESET,
515};
516enum {
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700517 BPF_F_ADJ_ROOM_FIXED_GSO = (1ULL << 0),
518 BPF_F_ADJ_ROOM_ENCAP_L3_IPV4 = (1ULL << 1),
519 BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 = (1ULL << 2),
520 BPF_F_ADJ_ROOM_ENCAP_L4_GRE = (1ULL << 3),
521 BPF_F_ADJ_ROOM_ENCAP_L4_UDP = (1ULL << 4),
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700522 BPF_F_ADJ_ROOM_NO_CSUM_RESET = (1ULL << 5),
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000523 BPF_F_ADJ_ROOM_ENCAP_L2_ETH = (1ULL << 6),
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700524};
525enum {
526 BPF_ADJ_ROOM_ENCAP_L2_MASK = 0xff,
527 BPF_ADJ_ROOM_ENCAP_L2_SHIFT = 56,
528};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700529#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 -0700530enum {
531 BPF_F_SYSCTL_BASE_NAME = (1ULL << 0),
532};
533enum {
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800534 BPF_LOCAL_STORAGE_GET_F_CREATE = (1ULL << 0),
535 BPF_SK_STORAGE_GET_F_CREATE = BPF_LOCAL_STORAGE_GET_F_CREATE,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700536};
537enum {
538 BPF_F_GET_BRANCH_RECORDS_SIZE = (1ULL << 0),
539};
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700540enum {
541 BPF_RB_NO_WAKEUP = (1ULL << 0),
542 BPF_RB_FORCE_WAKEUP = (1ULL << 1),
543};
544enum {
545 BPF_RB_AVAIL_DATA = 0,
546 BPF_RB_RING_SIZE = 1,
547 BPF_RB_CONS_POS = 2,
548 BPF_RB_PROD_POS = 3,
549};
550enum {
551 BPF_RINGBUF_BUSY_BIT = (1U << 31),
552 BPF_RINGBUF_DISCARD_BIT = (1U << 30),
553 BPF_RINGBUF_HDR_SZ = 8,
554};
Christopher Ferris25c18d42020-10-14 17:42:58 -0700555enum {
556 BPF_SK_LOOKUP_F_REPLACE = (1ULL << 0),
557 BPF_SK_LOOKUP_F_NO_REUSEPORT = (1ULL << 1),
558};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800559enum bpf_adj_room_mode {
560 BPF_ADJ_ROOM_NET,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700561 BPF_ADJ_ROOM_MAC,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800562};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700563enum bpf_hdr_start_off {
564 BPF_HDR_START_MAC,
565 BPF_HDR_START_NET,
566};
567enum bpf_lwt_encap_mode {
568 BPF_LWT_ENCAP_SEG6,
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700569 BPF_LWT_ENCAP_SEG6_INLINE,
570 BPF_LWT_ENCAP_IP,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700571};
Christopher Ferris05667cd2021-02-16 16:01:34 -0800572enum {
573 BPF_F_BPRM_SECUREEXEC = (1ULL << 0),
574};
Christopher Ferris86a48372019-01-10 14:14:59 -0800575#define __bpf_md_ptr(type,name) union { type name; __u64 : 64; \
576} __attribute__((aligned(8)))
Christopher Ferris49f525c2016-12-12 14:55:36 -0800577struct __sk_buff {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800578 __u32 len;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800579 __u32 pkt_type;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800580 __u32 mark;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800581 __u32 queue_mapping;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800582 __u32 protocol;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800583 __u32 vlan_present;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800584 __u32 vlan_tci;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800585 __u32 vlan_proto;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800586 __u32 priority;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800587 __u32 ingress_ifindex;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800588 __u32 ifindex;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800589 __u32 tc_index;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800590 __u32 cb[5];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800591 __u32 hash;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800592 __u32 tc_classid;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800593 __u32 data;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800594 __u32 data_end;
Christopher Ferris525ce912017-07-26 13:12:53 -0700595 __u32 napi_id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800596 __u32 family;
597 __u32 remote_ip4;
598 __u32 local_ip4;
599 __u32 remote_ip6[4];
600 __u32 local_ip6[4];
601 __u32 remote_port;
602 __u32 local_port;
Christopher Ferris934ec942018-01-31 15:29:16 -0800603 __u32 data_meta;
Christopher Ferris86a48372019-01-10 14:14:59 -0800604 __bpf_md_ptr(struct bpf_flow_keys *, flow_keys);
Christopher Ferrisd842e432019-03-07 10:21:59 -0800605 __u64 tstamp;
606 __u32 wire_len;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700607 __u32 gso_segs;
608 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700609 __u32 gso_size;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800610};
611struct bpf_tunnel_key {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800612 __u32 tunnel_id;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800613 union {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700614 __u32 remote_ipv4;
615 __u32 remote_ipv6[4];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800616 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800617 __u8 tunnel_tos;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700618 __u8 tunnel_ttl;
619 __u16 tunnel_ext;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800620 __u32 tunnel_label;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800621};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700622struct bpf_xfrm_state {
623 __u32 reqid;
624 __u32 spi;
625 __u16 family;
626 __u16 ext;
627 union {
628 __u32 remote_ipv4;
629 __u32 remote_ipv6[4];
630 };
631};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800632enum bpf_ret_code {
633 BPF_OK = 0,
634 BPF_DROP = 2,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800635 BPF_REDIRECT = 7,
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700636 BPF_LWT_REROUTE = 128,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800637};
638struct bpf_sock {
639 __u32 bound_dev_if;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800640 __u32 family;
641 __u32 type;
642 __u32 protocol;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800643 __u32 mark;
644 __u32 priority;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700645 __u32 src_ip4;
646 __u32 src_ip6[4];
647 __u32 src_port;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700648 __u32 dst_port;
649 __u32 dst_ip4;
650 __u32 dst_ip6[4];
651 __u32 state;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700652 __s32 rx_queue_mapping;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700653};
654struct bpf_tcp_sock {
655 __u32 snd_cwnd;
656 __u32 srtt_us;
657 __u32 rtt_min;
658 __u32 snd_ssthresh;
659 __u32 rcv_nxt;
660 __u32 snd_nxt;
661 __u32 snd_una;
662 __u32 mss_cache;
663 __u32 ecn_flags;
664 __u32 rate_delivered;
665 __u32 rate_interval_us;
666 __u32 packets_out;
667 __u32 retrans_out;
668 __u32 total_retrans;
669 __u32 segs_in;
670 __u32 data_segs_in;
671 __u32 segs_out;
672 __u32 data_segs_out;
673 __u32 lost_out;
674 __u32 sacked_out;
675 __u64 bytes_received;
676 __u64 bytes_acked;
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700677 __u32 dsack_dups;
678 __u32 delivered;
679 __u32 delivered_ce;
680 __u32 icsk_retransmits;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800681};
Christopher Ferris86a48372019-01-10 14:14:59 -0800682struct bpf_sock_tuple {
683 union {
684 struct {
685 __be32 saddr;
686 __be32 daddr;
687 __be16 sport;
688 __be16 dport;
689 } ipv4;
690 struct {
691 __be32 saddr[4];
692 __be32 daddr[4];
693 __be16 sport;
694 __be16 dport;
695 } ipv6;
696 };
697};
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700698struct bpf_xdp_sock {
699 __u32 queue_id;
700};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800701#define XDP_PACKET_HEADROOM 256
Christopher Ferris49f525c2016-12-12 14:55:36 -0800702enum xdp_action {
703 XDP_ABORTED = 0,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800704 XDP_DROP,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800705 XDP_PASS,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800706 XDP_TX,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800707 XDP_REDIRECT,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800708};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800709struct xdp_md {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800710 __u32 data;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800711 __u32 data_end;
Christopher Ferris934ec942018-01-31 15:29:16 -0800712 __u32 data_meta;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700713 __u32 ingress_ifindex;
714 __u32 rx_queue_index;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700715 __u32 egress_ifindex;
716};
717struct bpf_devmap_val {
718 __u32 ifindex;
719 union {
720 int fd;
721 __u32 id;
722 } bpf_prog;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800723};
Christopher Ferris25c18d42020-10-14 17:42:58 -0700724struct bpf_cpumap_val {
725 __u32 qsize;
726 union {
727 int fd;
728 __u32 id;
729 } bpf_prog;
730};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800731enum sk_action {
732 SK_DROP = 0,
733 SK_PASS,
734};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700735struct sk_msg_md {
Christopher Ferris86a48372019-01-10 14:14:59 -0800736 __bpf_md_ptr(void *, data);
737 __bpf_md_ptr(void *, data_end);
Christopher Ferris9ce28842018-10-25 12:11:39 -0700738 __u32 family;
739 __u32 remote_ip4;
740 __u32 local_ip4;
741 __u32 remote_ip6[4];
742 __u32 local_ip6[4];
743 __u32 remote_port;
744 __u32 local_port;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800745 __u32 size;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700746 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferris9ce28842018-10-25 12:11:39 -0700747};
748struct sk_reuseport_md {
Christopher Ferris86a48372019-01-10 14:14:59 -0800749 __bpf_md_ptr(void *, data);
750 __bpf_md_ptr(void *, data_end);
Christopher Ferris9ce28842018-10-25 12:11:39 -0700751 __u32 len;
752 __u32 eth_protocol;
753 __u32 ip_protocol;
754 __u32 bind_inany;
755 __u32 hash;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700756};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800757#define BPF_TAG_SIZE 8
758struct bpf_prog_info {
759 __u32 type;
760 __u32 id;
761 __u8 tag[BPF_TAG_SIZE];
762 __u32 jited_prog_len;
763 __u32 xlated_prog_len;
764 __aligned_u64 jited_prog_insns;
765 __aligned_u64 xlated_prog_insns;
Christopher Ferris934ec942018-01-31 15:29:16 -0800766 __u64 load_time;
767 __u32 created_by_uid;
768 __u32 nr_map_ids;
769 __aligned_u64 map_ids;
770 char name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700771 __u32 ifindex;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700772 __u32 gpl_compatible : 1;
Christopher Ferrisfa59a102019-08-05 12:58:49 -0700773 __u32 : 31;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700774 __u64 netns_dev;
775 __u64 netns_ino;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700776 __u32 nr_jited_ksyms;
777 __u32 nr_jited_func_lens;
778 __aligned_u64 jited_ksyms;
779 __aligned_u64 jited_func_lens;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800780 __u32 btf_id;
781 __u32 func_info_rec_size;
782 __aligned_u64 func_info;
783 __u32 nr_func_info;
784 __u32 nr_line_info;
785 __aligned_u64 line_info;
786 __aligned_u64 jited_line_info;
787 __u32 nr_jited_line_info;
788 __u32 line_info_rec_size;
789 __u32 jited_line_info_rec_size;
790 __u32 nr_prog_tags;
791 __aligned_u64 prog_tags;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700792 __u64 run_time_ns;
793 __u64 run_cnt;
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700794 __u64 recursion_misses;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800795} __attribute__((aligned(8)));
796struct bpf_map_info {
797 __u32 type;
798 __u32 id;
799 __u32 key_size;
800 __u32 value_size;
801 __u32 max_entries;
802 __u32 map_flags;
Christopher Ferris934ec942018-01-31 15:29:16 -0800803 char name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700804 __u32 ifindex;
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700805 __u32 btf_vmlinux_value_type_id;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700806 __u64 netns_dev;
807 __u64 netns_ino;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700808 __u32 btf_id;
809 __u32 btf_key_type_id;
810 __u32 btf_value_type_id;
811} __attribute__((aligned(8)));
812struct bpf_btf_info {
813 __aligned_u64 btf;
814 __u32 btf_size;
815 __u32 id;
Christopher Ferris05667cd2021-02-16 16:01:34 -0800816 __aligned_u64 name;
817 __u32 name_len;
818 __u32 kernel_btf;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800819} __attribute__((aligned(8)));
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700820struct bpf_link_info {
821 __u32 type;
822 __u32 id;
823 __u32 prog_id;
824 union {
825 struct {
826 __aligned_u64 tp_name;
827 __u32 tp_name_len;
828 } raw_tracepoint;
829 struct {
830 __u32 attach_type;
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000831 __u32 target_obj_id;
832 __u32 target_btf_id;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700833 } tracing;
834 struct {
835 __u64 cgroup_id;
836 __u32 attach_type;
837 } cgroup;
838 struct {
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800839 __aligned_u64 target_name;
840 __u32 target_name_len;
841 union {
842 struct {
843 __u32 map_id;
844 } map;
845 };
846 } iter;
847 struct {
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700848 __u32 netns_ino;
849 __u32 attach_type;
850 } netns;
Christopher Ferris25c18d42020-10-14 17:42:58 -0700851 struct {
852 __u32 ifindex;
853 } xdp;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700854 };
855} __attribute__((aligned(8)));
Christopher Ferris76a1d452018-06-27 14:12:29 -0700856struct bpf_sock_addr {
857 __u32 user_family;
858 __u32 user_ip4;
859 __u32 user_ip6[4];
860 __u32 user_port;
861 __u32 family;
862 __u32 type;
863 __u32 protocol;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700864 __u32 msg_src_ip4;
865 __u32 msg_src_ip6[4];
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700866 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferris76a1d452018-06-27 14:12:29 -0700867};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800868struct bpf_sock_ops {
869 __u32 op;
870 union {
Christopher Ferris76a1d452018-06-27 14:12:29 -0700871 __u32 args[4];
Christopher Ferris1308ad32017-11-14 17:32:13 -0800872 __u32 reply;
873 __u32 replylong[4];
874 };
875 __u32 family;
876 __u32 remote_ip4;
877 __u32 local_ip4;
878 __u32 remote_ip6[4];
879 __u32 local_ip6[4];
880 __u32 remote_port;
881 __u32 local_port;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700882 __u32 is_fullsock;
883 __u32 snd_cwnd;
884 __u32 srtt_us;
885 __u32 bpf_sock_ops_cb_flags;
886 __u32 state;
887 __u32 rtt_min;
888 __u32 snd_ssthresh;
889 __u32 rcv_nxt;
890 __u32 snd_nxt;
891 __u32 snd_una;
892 __u32 mss_cache;
893 __u32 ecn_flags;
894 __u32 rate_delivered;
895 __u32 rate_interval_us;
896 __u32 packets_out;
897 __u32 retrans_out;
898 __u32 total_retrans;
899 __u32 segs_in;
900 __u32 data_segs_in;
901 __u32 segs_out;
902 __u32 data_segs_out;
903 __u32 lost_out;
904 __u32 sacked_out;
905 __u32 sk_txhash;
906 __u64 bytes_received;
907 __u64 bytes_acked;
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700908 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800909 __bpf_md_ptr(void *, skb_data);
910 __bpf_md_ptr(void *, skb_data_end);
911 __u32 skb_len;
912 __u32 skb_tcp_flags;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800913};
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700914enum {
915 BPF_SOCK_OPS_RTO_CB_FLAG = (1 << 0),
916 BPF_SOCK_OPS_RETRANS_CB_FLAG = (1 << 1),
917 BPF_SOCK_OPS_STATE_CB_FLAG = (1 << 2),
918 BPF_SOCK_OPS_RTT_CB_FLAG = (1 << 3),
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800919 BPF_SOCK_OPS_PARSE_ALL_HDR_OPT_CB_FLAG = (1 << 4),
920 BPF_SOCK_OPS_PARSE_UNKNOWN_HDR_OPT_CB_FLAG = (1 << 5),
921 BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG = (1 << 6),
922 BPF_SOCK_OPS_ALL_CB_FLAGS = 0x7F,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700923};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800924enum {
925 BPF_SOCK_OPS_VOID,
926 BPF_SOCK_OPS_TIMEOUT_INIT,
927 BPF_SOCK_OPS_RWND_INIT,
928 BPF_SOCK_OPS_TCP_CONNECT_CB,
929 BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB,
930 BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB,
931 BPF_SOCK_OPS_NEEDS_ECN,
Christopher Ferris934ec942018-01-31 15:29:16 -0800932 BPF_SOCK_OPS_BASE_RTT,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700933 BPF_SOCK_OPS_RTO_CB,
934 BPF_SOCK_OPS_RETRANS_CB,
935 BPF_SOCK_OPS_STATE_CB,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700936 BPF_SOCK_OPS_TCP_LISTEN_CB,
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700937 BPF_SOCK_OPS_RTT_CB,
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800938 BPF_SOCK_OPS_PARSE_HDR_OPT_CB,
939 BPF_SOCK_OPS_HDR_OPT_LEN_CB,
940 BPF_SOCK_OPS_WRITE_HDR_OPT_CB,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700941};
942enum {
943 BPF_TCP_ESTABLISHED = 1,
944 BPF_TCP_SYN_SENT,
945 BPF_TCP_SYN_RECV,
946 BPF_TCP_FIN_WAIT1,
947 BPF_TCP_FIN_WAIT2,
948 BPF_TCP_TIME_WAIT,
949 BPF_TCP_CLOSE,
950 BPF_TCP_CLOSE_WAIT,
951 BPF_TCP_LAST_ACK,
952 BPF_TCP_LISTEN,
953 BPF_TCP_CLOSING,
954 BPF_TCP_NEW_SYN_RECV,
955 BPF_TCP_MAX_STATES
Christopher Ferris1308ad32017-11-14 17:32:13 -0800956};
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700957enum {
958 TCP_BPF_IW = 1001,
959 TCP_BPF_SNDCWND_CLAMP = 1002,
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800960 TCP_BPF_DELACK_MAX = 1003,
961 TCP_BPF_RTO_MIN = 1004,
962 TCP_BPF_SYN = 1005,
963 TCP_BPF_SYN_IP = 1006,
964 TCP_BPF_SYN_MAC = 1007,
965};
966enum {
967 BPF_LOAD_HDR_OPT_TCP_SYN = (1ULL << 0),
968};
969enum {
970 BPF_WRITE_HDR_TCP_CURRENT_MSS = 1,
971 BPF_WRITE_HDR_TCP_SYNACK_COOKIE = 2,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700972};
Christopher Ferris934ec942018-01-31 15:29:16 -0800973struct bpf_perf_event_value {
974 __u64 counter;
975 __u64 enabled;
976 __u64 running;
977};
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700978enum {
979 BPF_DEVCG_ACC_MKNOD = (1ULL << 0),
980 BPF_DEVCG_ACC_READ = (1ULL << 1),
981 BPF_DEVCG_ACC_WRITE = (1ULL << 2),
982};
983enum {
984 BPF_DEVCG_DEV_BLOCK = (1ULL << 0),
985 BPF_DEVCG_DEV_CHAR = (1ULL << 1),
986};
Christopher Ferris934ec942018-01-31 15:29:16 -0800987struct bpf_cgroup_dev_ctx {
988 __u32 access_type;
989 __u32 major;
990 __u32 minor;
991};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700992struct bpf_raw_tracepoint_args {
993 __u64 args[0];
994};
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700995enum {
996 BPF_FIB_LOOKUP_DIRECT = (1U << 0),
997 BPF_FIB_LOOKUP_OUTPUT = (1U << 1),
998};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700999enum {
1000 BPF_FIB_LKUP_RET_SUCCESS,
1001 BPF_FIB_LKUP_RET_BLACKHOLE,
1002 BPF_FIB_LKUP_RET_UNREACHABLE,
1003 BPF_FIB_LKUP_RET_PROHIBIT,
1004 BPF_FIB_LKUP_RET_NOT_FWDED,
1005 BPF_FIB_LKUP_RET_FWD_DISABLED,
1006 BPF_FIB_LKUP_RET_UNSUPP_LWT,
1007 BPF_FIB_LKUP_RET_NO_NEIGH,
1008 BPF_FIB_LKUP_RET_FRAG_NEEDED,
1009};
1010struct bpf_fib_lookup {
1011 __u8 family;
1012 __u8 l4_protocol;
1013 __be16 sport;
1014 __be16 dport;
Christopher Ferrisa9750ed2021-05-03 14:02:49 -07001015 union {
1016 __u16 tot_len;
1017 __u16 mtu_result;
1018 };
Christopher Ferris9ce28842018-10-25 12:11:39 -07001019 __u32 ifindex;
1020 union {
1021 __u8 tos;
1022 __be32 flowinfo;
1023 __u32 rt_metric;
1024 };
1025 union {
1026 __be32 ipv4_src;
1027 __u32 ipv6_src[4];
1028 };
1029 union {
1030 __be32 ipv4_dst;
1031 __u32 ipv6_dst[4];
1032 };
1033 __be16 h_vlan_proto;
1034 __be16 h_vlan_TCI;
1035 __u8 smac[6];
1036 __u8 dmac[6];
1037};
Christopher Ferris32ff3f82020-12-14 13:10:04 -08001038struct bpf_redir_neigh {
1039 __u32 nh_family;
1040 union {
1041 __be32 ipv4_nh;
1042 __u32 ipv6_nh[4];
1043 };
1044};
Christopher Ferrisa9750ed2021-05-03 14:02:49 -07001045enum bpf_check_mtu_flags {
1046 BPF_MTU_CHK_SEGS = (1U << 0),
1047};
1048enum bpf_check_mtu_ret {
1049 BPF_MTU_CHK_RET_SUCCESS,
1050 BPF_MTU_CHK_RET_FRAG_NEEDED,
1051 BPF_MTU_CHK_RET_SEGS_TOOBIG,
1052};
Christopher Ferris9ce28842018-10-25 12:11:39 -07001053enum bpf_task_fd_type {
1054 BPF_FD_TYPE_RAW_TRACEPOINT,
1055 BPF_FD_TYPE_TRACEPOINT,
1056 BPF_FD_TYPE_KPROBE,
1057 BPF_FD_TYPE_KRETPROBE,
1058 BPF_FD_TYPE_UPROBE,
1059 BPF_FD_TYPE_URETPROBE,
1060};
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001061enum {
1062 BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG = (1U << 0),
1063 BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL = (1U << 1),
1064 BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP = (1U << 2),
1065};
Christopher Ferris86a48372019-01-10 14:14:59 -08001066struct bpf_flow_keys {
1067 __u16 nhoff;
1068 __u16 thoff;
1069 __u16 addr_proto;
1070 __u8 is_frag;
1071 __u8 is_first_frag;
1072 __u8 is_encap;
1073 __u8 ip_proto;
1074 __be16 n_proto;
1075 __be16 sport;
1076 __be16 dport;
1077 union {
1078 struct {
1079 __be32 ipv4_src;
1080 __be32 ipv4_dst;
1081 };
1082 struct {
1083 __u32 ipv6_src[4];
1084 __u32 ipv6_dst[4];
1085 };
1086 };
Christopher Ferris9584fa42019-12-09 15:36:13 -08001087 __u32 flags;
1088 __be32 flow_label;
Christopher Ferris86a48372019-01-10 14:14:59 -08001089};
Christopher Ferrisd842e432019-03-07 10:21:59 -08001090struct bpf_func_info {
1091 __u32 insn_off;
1092 __u32 type_id;
1093};
1094#define BPF_LINE_INFO_LINE_NUM(line_col) ((line_col) >> 10)
1095#define BPF_LINE_INFO_LINE_COL(line_col) ((line_col) & 0x3ff)
1096struct bpf_line_info {
1097 __u32 insn_off;
1098 __u32 file_name_off;
1099 __u32 line_off;
1100 __u32 line_col;
1101};
Christopher Ferris24f97eb2019-05-20 12:58:13 -07001102struct bpf_spin_lock {
1103 __u32 val;
1104};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -07001105struct bpf_sysctl {
1106 __u32 write;
1107 __u32 file_pos;
1108};
Christopher Ferrisb8a95e22019-10-02 18:29:20 -07001109struct bpf_sockopt {
1110 __bpf_md_ptr(struct bpf_sock *, sk);
1111 __bpf_md_ptr(void *, optval);
1112 __bpf_md_ptr(void *, optval_end);
1113 __s32 level;
1114 __s32 optname;
1115 __s32 optlen;
1116 __s32 retval;
1117};
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001118struct bpf_pidns_info {
1119 __u32 pid;
1120 __u32 tgid;
1121};
Christopher Ferris25c18d42020-10-14 17:42:58 -07001122struct bpf_sk_lookup {
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +00001123 union {
1124 __bpf_md_ptr(struct bpf_sock *, sk);
1125 __u64 cookie;
1126 };
Christopher Ferris25c18d42020-10-14 17:42:58 -07001127 __u32 family;
1128 __u32 protocol;
1129 __u32 remote_ip4;
1130 __u32 remote_ip6[4];
1131 __u32 remote_port;
1132 __u32 local_ip4;
1133 __u32 local_ip6[4];
1134 __u32 local_port;
1135};
Christopher Ferris32ff3f82020-12-14 13:10:04 -08001136struct btf_ptr {
1137 void * ptr;
1138 __u32 type_id;
1139 __u32 flags;
1140};
1141enum {
1142 BTF_F_COMPACT = (1ULL << 0),
1143 BTF_F_NONAME = (1ULL << 1),
1144 BTF_F_PTR_RAW = (1ULL << 2),
1145 BTF_F_ZERO = (1ULL << 3),
1146};
Christopher Ferris82d75042015-01-26 10:57:07 -08001147#endif