blob: 807884a468d3123501b9ad2641ba2204e95fa2fb [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 Ferris6cd53a52022-12-12 23:39:16 +000077enum bpf_cgroup_iter_order {
78 BPF_CGROUP_ITER_ORDER_UNSPEC = 0,
79 BPF_CGROUP_ITER_SELF_ONLY,
80 BPF_CGROUP_ITER_DESCENDANTS_PRE,
81 BPF_CGROUP_ITER_DESCENDANTS_POST,
82 BPF_CGROUP_ITER_ANCESTORS_UP,
83};
Christopher Ferris25c18d42020-10-14 17:42:58 -070084union bpf_iter_link_info {
85 struct {
86 __u32 map_fd;
87 } map;
Christopher Ferris6cd53a52022-12-12 23:39:16 +000088 struct {
89 enum bpf_cgroup_iter_order order;
90 __u32 cgroup_fd;
91 __u64 cgroup_id;
92 } cgroup;
93 struct {
94 __u32 tid;
95 __u32 pid;
96 __u32 pid_fd;
97 } task;
Christopher Ferris25c18d42020-10-14 17:42:58 -070098};
Christopher Ferris82d75042015-01-26 10:57:07 -080099enum bpf_cmd {
Tao Baod7db5942015-01-28 10:07:51 -0800100 BPF_MAP_CREATE,
101 BPF_MAP_LOOKUP_ELEM,
Tao Baod7db5942015-01-28 10:07:51 -0800102 BPF_MAP_UPDATE_ELEM,
103 BPF_MAP_DELETE_ELEM,
104 BPF_MAP_GET_NEXT_KEY,
105 BPF_PROG_LOAD,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800106 BPF_OBJ_PIN,
107 BPF_OBJ_GET,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800108 BPF_PROG_ATTACH,
109 BPF_PROG_DETACH,
Christopher Ferris525ce912017-07-26 13:12:53 -0700110 BPF_PROG_TEST_RUN,
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000111 BPF_PROG_RUN = BPF_PROG_TEST_RUN,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800112 BPF_PROG_GET_NEXT_ID,
113 BPF_MAP_GET_NEXT_ID,
114 BPF_PROG_GET_FD_BY_ID,
115 BPF_MAP_GET_FD_BY_ID,
116 BPF_OBJ_GET_INFO_BY_FD,
Christopher Ferris934ec942018-01-31 15:29:16 -0800117 BPF_PROG_QUERY,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700118 BPF_RAW_TRACEPOINT_OPEN,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700119 BPF_BTF_LOAD,
120 BPF_BTF_GET_FD_BY_ID,
121 BPF_TASK_FD_QUERY,
Christopher Ferris86a48372019-01-10 14:14:59 -0800122 BPF_MAP_LOOKUP_AND_DELETE_ELEM,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700123 BPF_MAP_FREEZE,
Christopher Ferris9584fa42019-12-09 15:36:13 -0800124 BPF_BTF_GET_NEXT_ID,
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700125 BPF_MAP_LOOKUP_BATCH,
126 BPF_MAP_LOOKUP_AND_DELETE_BATCH,
127 BPF_MAP_UPDATE_BATCH,
128 BPF_MAP_DELETE_BATCH,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700129 BPF_LINK_CREATE,
130 BPF_LINK_UPDATE,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700131 BPF_LINK_GET_FD_BY_ID,
132 BPF_LINK_GET_NEXT_ID,
133 BPF_ENABLE_STATS,
134 BPF_ITER_CREATE,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700135 BPF_LINK_DETACH,
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800136 BPF_PROG_BIND_MAP,
Christopher Ferris82d75042015-01-26 10:57:07 -0800137};
138enum bpf_map_type {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800139 BPF_MAP_TYPE_UNSPEC,
140 BPF_MAP_TYPE_HASH,
141 BPF_MAP_TYPE_ARRAY,
142 BPF_MAP_TYPE_PROG_ARRAY,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800143 BPF_MAP_TYPE_PERF_EVENT_ARRAY,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700144 BPF_MAP_TYPE_PERCPU_HASH,
145 BPF_MAP_TYPE_PERCPU_ARRAY,
146 BPF_MAP_TYPE_STACK_TRACE,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800147 BPF_MAP_TYPE_CGROUP_ARRAY,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800148 BPF_MAP_TYPE_LRU_HASH,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800149 BPF_MAP_TYPE_LRU_PERCPU_HASH,
Christopher Ferris525ce912017-07-26 13:12:53 -0700150 BPF_MAP_TYPE_LPM_TRIE,
151 BPF_MAP_TYPE_ARRAY_OF_MAPS,
152 BPF_MAP_TYPE_HASH_OF_MAPS,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800153 BPF_MAP_TYPE_DEVMAP,
154 BPF_MAP_TYPE_SOCKMAP,
Christopher Ferris934ec942018-01-31 15:29:16 -0800155 BPF_MAP_TYPE_CPUMAP,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700156 BPF_MAP_TYPE_XSKMAP,
157 BPF_MAP_TYPE_SOCKHASH,
158 BPF_MAP_TYPE_CGROUP_STORAGE,
159 BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,
Christopher Ferris86a48372019-01-10 14:14:59 -0800160 BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,
161 BPF_MAP_TYPE_QUEUE,
162 BPF_MAP_TYPE_STACK,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700163 BPF_MAP_TYPE_SK_STORAGE,
Christopher Ferris9584fa42019-12-09 15:36:13 -0800164 BPF_MAP_TYPE_DEVMAP_HASH,
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700165 BPF_MAP_TYPE_STRUCT_OPS,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700166 BPF_MAP_TYPE_RINGBUF,
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800167 BPF_MAP_TYPE_INODE_STORAGE,
Christopher Ferris05667cd2021-02-16 16:01:34 -0800168 BPF_MAP_TYPE_TASK_STORAGE,
Christopher Ferrisa4792612022-01-10 13:51:15 -0800169 BPF_MAP_TYPE_BLOOM_FILTER,
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000170 BPF_MAP_TYPE_USER_RINGBUF,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800171};
Christopher Ferris82d75042015-01-26 10:57:07 -0800172enum bpf_prog_type {
Tao Baod7db5942015-01-28 10:07:51 -0800173 BPF_PROG_TYPE_UNSPEC,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800174 BPF_PROG_TYPE_SOCKET_FILTER,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800175 BPF_PROG_TYPE_KPROBE,
176 BPF_PROG_TYPE_SCHED_CLS,
177 BPF_PROG_TYPE_SCHED_ACT,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800178 BPF_PROG_TYPE_TRACEPOINT,
179 BPF_PROG_TYPE_XDP,
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800180 BPF_PROG_TYPE_PERF_EVENT,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800181 BPF_PROG_TYPE_CGROUP_SKB,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800182 BPF_PROG_TYPE_CGROUP_SOCK,
183 BPF_PROG_TYPE_LWT_IN,
184 BPF_PROG_TYPE_LWT_OUT,
185 BPF_PROG_TYPE_LWT_XMIT,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800186 BPF_PROG_TYPE_SOCK_OPS,
187 BPF_PROG_TYPE_SK_SKB,
Christopher Ferris934ec942018-01-31 15:29:16 -0800188 BPF_PROG_TYPE_CGROUP_DEVICE,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700189 BPF_PROG_TYPE_SK_MSG,
190 BPF_PROG_TYPE_RAW_TRACEPOINT,
191 BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700192 BPF_PROG_TYPE_LWT_SEG6LOCAL,
193 BPF_PROG_TYPE_LIRC_MODE2,
194 BPF_PROG_TYPE_SK_REUSEPORT,
Christopher Ferris86a48372019-01-10 14:14:59 -0800195 BPF_PROG_TYPE_FLOW_DISSECTOR,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700196 BPF_PROG_TYPE_CGROUP_SYSCTL,
197 BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE,
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700198 BPF_PROG_TYPE_CGROUP_SOCKOPT,
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800199 BPF_PROG_TYPE_TRACING,
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700200 BPF_PROG_TYPE_STRUCT_OPS,
201 BPF_PROG_TYPE_EXT,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700202 BPF_PROG_TYPE_LSM,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700203 BPF_PROG_TYPE_SK_LOOKUP,
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000204 BPF_PROG_TYPE_SYSCALL,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800205};
206enum bpf_attach_type {
207 BPF_CGROUP_INET_INGRESS,
208 BPF_CGROUP_INET_EGRESS,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800209 BPF_CGROUP_INET_SOCK_CREATE,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800210 BPF_CGROUP_SOCK_OPS,
211 BPF_SK_SKB_STREAM_PARSER,
212 BPF_SK_SKB_STREAM_VERDICT,
Christopher Ferris934ec942018-01-31 15:29:16 -0800213 BPF_CGROUP_DEVICE,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700214 BPF_SK_MSG_VERDICT,
215 BPF_CGROUP_INET4_BIND,
216 BPF_CGROUP_INET6_BIND,
217 BPF_CGROUP_INET4_CONNECT,
218 BPF_CGROUP_INET6_CONNECT,
219 BPF_CGROUP_INET4_POST_BIND,
220 BPF_CGROUP_INET6_POST_BIND,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700221 BPF_CGROUP_UDP4_SENDMSG,
222 BPF_CGROUP_UDP6_SENDMSG,
223 BPF_LIRC_MODE2,
Christopher Ferris86a48372019-01-10 14:14:59 -0800224 BPF_FLOW_DISSECTOR,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700225 BPF_CGROUP_SYSCTL,
226 BPF_CGROUP_UDP4_RECVMSG,
227 BPF_CGROUP_UDP6_RECVMSG,
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700228 BPF_CGROUP_GETSOCKOPT,
229 BPF_CGROUP_SETSOCKOPT,
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800230 BPF_TRACE_RAW_TP,
231 BPF_TRACE_FENTRY,
232 BPF_TRACE_FEXIT,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700233 BPF_MODIFY_RETURN,
234 BPF_LSM_MAC,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700235 BPF_TRACE_ITER,
236 BPF_CGROUP_INET4_GETPEERNAME,
237 BPF_CGROUP_INET6_GETPEERNAME,
238 BPF_CGROUP_INET4_GETSOCKNAME,
239 BPF_CGROUP_INET6_GETSOCKNAME,
240 BPF_XDP_DEVMAP,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700241 BPF_CGROUP_INET_SOCK_RELEASE,
242 BPF_XDP_CPUMAP,
243 BPF_SK_LOOKUP,
244 BPF_XDP,
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000245 BPF_SK_SKB_VERDICT,
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000246 BPF_SK_REUSEPORT_SELECT,
247 BPF_SK_REUSEPORT_SELECT_OR_MIGRATE,
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700248 BPF_PERF_EVENT,
Christopher Ferris10a76e62022-06-08 13:31:52 -0700249 BPF_TRACE_KPROBE_MULTI,
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700250 BPF_LSM_CGROUP,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800251 __MAX_BPF_ATTACH_TYPE
252};
253#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700254enum bpf_link_type {
255 BPF_LINK_TYPE_UNSPEC = 0,
256 BPF_LINK_TYPE_RAW_TRACEPOINT = 1,
257 BPF_LINK_TYPE_TRACING = 2,
258 BPF_LINK_TYPE_CGROUP = 3,
259 BPF_LINK_TYPE_ITER = 4,
260 BPF_LINK_TYPE_NETNS = 5,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700261 BPF_LINK_TYPE_XDP = 6,
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700262 BPF_LINK_TYPE_PERF_EVENT = 7,
Christopher Ferris10a76e62022-06-08 13:31:52 -0700263 BPF_LINK_TYPE_KPROBE_MULTI = 8,
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700264 BPF_LINK_TYPE_STRUCT_OPS = 9,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700265 MAX_BPF_LINK_TYPE,
266};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800267#define BPF_F_ALLOW_OVERRIDE (1U << 0)
Christopher Ferris934ec942018-01-31 15:29:16 -0800268#define BPF_F_ALLOW_MULTI (1U << 1)
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700269#define BPF_F_REPLACE (1U << 2)
Christopher Ferris525ce912017-07-26 13:12:53 -0700270#define BPF_F_STRICT_ALIGNMENT (1U << 0)
Christopher Ferrisd842e432019-03-07 10:21:59 -0800271#define BPF_F_ANY_ALIGNMENT (1U << 1)
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700272#define BPF_F_TEST_RND_HI32 (1U << 2)
Christopher Ferris9584fa42019-12-09 15:36:13 -0800273#define BPF_F_TEST_STATE_FREQ (1U << 3)
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800274#define BPF_F_SLEEPABLE (1U << 4)
Christopher Ferris10a76e62022-06-08 13:31:52 -0700275#define BPF_F_XDP_HAS_FRAGS (1U << 5)
276#define BPF_F_KPROBE_MULTI_RETURN (1U << 0)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800277#define BPF_PSEUDO_MAP_FD 1
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000278#define BPF_PSEUDO_MAP_IDX 5
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700279#define BPF_PSEUDO_MAP_VALUE 2
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000280#define BPF_PSEUDO_MAP_IDX_VALUE 6
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800281#define BPF_PSEUDO_BTF_ID 3
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000282#define BPF_PSEUDO_FUNC 4
Christopher Ferris76a1d452018-06-27 14:12:29 -0700283#define BPF_PSEUDO_CALL 1
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000284#define BPF_PSEUDO_KFUNC_CALL 2
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700285enum {
286 BPF_ANY = 0,
287 BPF_NOEXIST = 1,
288 BPF_EXIST = 2,
289 BPF_F_LOCK = 4,
290};
291enum {
292 BPF_F_NO_PREALLOC = (1U << 0),
293 BPF_F_NO_COMMON_LRU = (1U << 1),
294 BPF_F_NUMA_NODE = (1U << 2),
295 BPF_F_RDONLY = (1U << 3),
296 BPF_F_WRONLY = (1U << 4),
297 BPF_F_STACK_BUILD_ID = (1U << 5),
298 BPF_F_ZERO_SEED = (1U << 6),
299 BPF_F_RDONLY_PROG = (1U << 7),
300 BPF_F_WRONLY_PROG = (1U << 8),
301 BPF_F_CLONE = (1U << 9),
302 BPF_F_MMAPABLE = (1U << 10),
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800303 BPF_F_PRESERVE_ELEMS = (1U << 11),
304 BPF_F_INNER_MAP = (1U << 12),
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700305};
Christopher Ferrisd842e432019-03-07 10:21:59 -0800306#define BPF_F_QUERY_EFFECTIVE (1U << 0)
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800307#define BPF_F_TEST_RUN_ON_CPU (1U << 0)
Christopher Ferris10a76e62022-06-08 13:31:52 -0700308#define BPF_F_TEST_XDP_LIVE_FRAMES (1U << 1)
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700309enum bpf_stats_type {
310 BPF_STATS_RUN_TIME = 0,
311};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700312enum bpf_stack_build_id_status {
313 BPF_STACK_BUILD_ID_EMPTY = 0,
314 BPF_STACK_BUILD_ID_VALID = 1,
315 BPF_STACK_BUILD_ID_IP = 2,
316};
317#define BPF_BUILD_ID_SIZE 20
318struct bpf_stack_build_id {
319 __s32 status;
320 unsigned char build_id[BPF_BUILD_ID_SIZE];
321 union {
322 __u64 offset;
323 __u64 ip;
324 };
325};
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700326#define BPF_OBJ_NAME_LEN 16U
Christopher Ferris05d08e92016-02-04 13:16:38 -0800327union bpf_attr {
Tao Baod7db5942015-01-28 10:07:51 -0800328 struct {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700329 __u32 map_type;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800330 __u32 key_size;
Tao Baod7db5942015-01-28 10:07:51 -0800331 __u32 value_size;
Tao Baod7db5942015-01-28 10:07:51 -0800332 __u32 max_entries;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700333 __u32 map_flags;
Christopher Ferris525ce912017-07-26 13:12:53 -0700334 __u32 inner_map_fd;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800335 __u32 numa_node;
Christopher Ferris934ec942018-01-31 15:29:16 -0800336 char map_name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700337 __u32 map_ifindex;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700338 __u32 btf_fd;
339 __u32 btf_key_type_id;
340 __u32 btf_value_type_id;
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700341 __u32 btf_vmlinux_value_type_id;
Christopher Ferrisa4792612022-01-10 13:51:15 -0800342 __u64 map_extra;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800343 };
Tao Baod7db5942015-01-28 10:07:51 -0800344 struct {
345 __u32 map_fd;
Tao Baod7db5942015-01-28 10:07:51 -0800346 __aligned_u64 key;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800347 union {
Tao Baod7db5942015-01-28 10:07:51 -0800348 __aligned_u64 value;
349 __aligned_u64 next_key;
Tao Baod7db5942015-01-28 10:07:51 -0800350 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800351 __u64 flags;
Tao Baod7db5942015-01-28 10:07:51 -0800352 };
353 struct {
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700354 __aligned_u64 in_batch;
355 __aligned_u64 out_batch;
356 __aligned_u64 keys;
357 __aligned_u64 values;
358 __u32 count;
359 __u32 map_fd;
360 __u64 elem_flags;
361 __u64 flags;
362 } batch;
363 struct {
Tao Baod7db5942015-01-28 10:07:51 -0800364 __u32 prog_type;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800365 __u32 insn_cnt;
Tao Baod7db5942015-01-28 10:07:51 -0800366 __aligned_u64 insns;
367 __aligned_u64 license;
368 __u32 log_level;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800369 __u32 log_size;
Tao Baod7db5942015-01-28 10:07:51 -0800370 __aligned_u64 log_buf;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800371 __u32 kern_version;
Christopher Ferris525ce912017-07-26 13:12:53 -0700372 __u32 prog_flags;
Christopher Ferris934ec942018-01-31 15:29:16 -0800373 char prog_name[BPF_OBJ_NAME_LEN];
374 __u32 prog_ifindex;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700375 __u32 expected_attach_type;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800376 __u32 prog_btf_fd;
377 __u32 func_info_rec_size;
378 __aligned_u64 func_info;
379 __u32 func_info_cnt;
380 __u32 line_info_rec_size;
381 __aligned_u64 line_info;
382 __u32 line_info_cnt;
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800383 __u32 attach_btf_id;
Christopher Ferris05667cd2021-02-16 16:01:34 -0800384 union {
385 __u32 attach_prog_fd;
386 __u32 attach_btf_obj_fd;
387 };
Christopher Ferris1ed55342022-03-22 16:06:25 -0700388 __u32 core_relo_cnt;
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000389 __aligned_u64 fd_array;
Christopher Ferris1ed55342022-03-22 16:06:25 -0700390 __aligned_u64 core_relos;
391 __u32 core_relo_rec_size;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800392 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800393 struct {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800394 __aligned_u64 pathname;
395 __u32 bpf_fd;
Christopher Ferris934ec942018-01-31 15:29:16 -0800396 __u32 file_flags;
Tao Baod7db5942015-01-28 10:07:51 -0800397 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800398 struct {
399 __u32 target_fd;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800400 __u32 attach_bpf_fd;
401 __u32 attach_type;
402 __u32 attach_flags;
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700403 __u32 replace_bpf_fd;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800404 };
Christopher Ferris525ce912017-07-26 13:12:53 -0700405 struct {
406 __u32 prog_fd;
407 __u32 retval;
408 __u32 data_size_in;
409 __u32 data_size_out;
410 __aligned_u64 data_in;
411 __aligned_u64 data_out;
412 __u32 repeat;
413 __u32 duration;
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700414 __u32 ctx_size_in;
415 __u32 ctx_size_out;
416 __aligned_u64 ctx_in;
417 __aligned_u64 ctx_out;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800418 __u32 flags;
419 __u32 cpu;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700420 __u32 batch_size;
Christopher Ferris525ce912017-07-26 13:12:53 -0700421 } test;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800422 struct {
423 union {
424 __u32 start_id;
425 __u32 prog_id;
426 __u32 map_id;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700427 __u32 btf_id;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700428 __u32 link_id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800429 };
430 __u32 next_id;
Christopher Ferris934ec942018-01-31 15:29:16 -0800431 __u32 open_flags;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800432 };
433 struct {
434 __u32 bpf_fd;
435 __u32 info_len;
436 __aligned_u64 info;
437 } info;
Christopher Ferris934ec942018-01-31 15:29:16 -0800438 struct {
439 __u32 target_fd;
440 __u32 attach_type;
441 __u32 query_flags;
442 __u32 attach_flags;
443 __aligned_u64 prog_ids;
444 __u32 prog_cnt;
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700445 __aligned_u64 prog_attach_flags;
Christopher Ferris934ec942018-01-31 15:29:16 -0800446 } query;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700447 struct {
448 __u64 name;
449 __u32 prog_fd;
450 } raw_tracepoint;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700451 struct {
452 __aligned_u64 btf;
453 __aligned_u64 btf_log_buf;
454 __u32 btf_size;
455 __u32 btf_log_size;
456 __u32 btf_log_level;
457 };
458 struct {
459 __u32 pid;
460 __u32 fd;
461 __u32 flags;
462 __u32 buf_len;
463 __aligned_u64 buf;
464 __u32 prog_id;
465 __u32 fd_type;
466 __u64 probe_offset;
467 __u64 probe_addr;
468 } task_fd_query;
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700469 struct {
470 __u32 prog_fd;
Christopher Ferris25c18d42020-10-14 17:42:58 -0700471 union {
472 __u32 target_fd;
473 __u32 target_ifindex;
474 };
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700475 __u32 attach_type;
476 __u32 flags;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800477 union {
478 __u32 target_btf_id;
479 struct {
480 __aligned_u64 iter_info;
481 __u32 iter_info_len;
482 };
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700483 struct {
484 __u64 bpf_cookie;
485 } perf_event;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700486 struct {
487 __u32 flags;
488 __u32 cnt;
489 __aligned_u64 syms;
490 __aligned_u64 addrs;
491 __aligned_u64 cookies;
492 } kprobe_multi;
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700493 struct {
494 __u32 target_btf_id;
495 __u64 cookie;
496 } tracing;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800497 };
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700498 } link_create;
499 struct {
500 __u32 link_fd;
501 __u32 new_prog_fd;
502 __u32 flags;
503 __u32 old_prog_fd;
504 } link_update;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700505 struct {
Christopher Ferris25c18d42020-10-14 17:42:58 -0700506 __u32 link_fd;
507 } link_detach;
508 struct {
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700509 __u32 type;
510 } enable_stats;
511 struct {
512 __u32 link_fd;
513 __u32 flags;
514 } iter_create;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800515 struct {
516 __u32 prog_fd;
517 __u32 map_fd;
518 __u32 flags;
519 } prog_bind_map;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800520} __attribute__((aligned(8)));
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000521#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), FN(sys_bpf), FN(btf_find_by_name_kind), FN(sys_close), FN(timer_init), FN(timer_set_callback), FN(timer_start), FN(timer_cancel), FN(get_func_ip), FN(get_attach_cookie), FN(task_pt_regs), FN(get_branch_snapshot), FN(trace_vprintk), FN(skc_to_unix_sock), FN(kallsyms_lookup_name), FN(find_vma), FN(loop), FN(strncmp), FN(get_func_arg), FN(get_func_ret), FN(get_func_arg_cnt), FN(get_retval), FN(set_retval), FN(xdp_get_buff_len), FN(xdp_load_bytes), FN(xdp_store_bytes), FN(copy_from_user_task), FN(skb_set_tstamp), FN(ima_file_hash), FN(kptr_xchg), FN(map_lookup_percpu_elem), FN(skc_to_mptcp_sock), FN(dynptr_from_mem), FN(ringbuf_reserve_dynptr), FN(ringbuf_submit_dynptr), FN(ringbuf_discard_dynptr), FN(dynptr_read), FN(dynptr_write), FN(dynptr_data), FN(tcp_raw_gen_syncookie_ipv4), FN(tcp_raw_gen_syncookie_ipv6), FN(tcp_raw_check_syncookie_ipv4), FN(tcp_raw_check_syncookie_ipv6), FN(ktime_get_tai_ns), FN(user_ringbuf_drain),
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800522#define __BPF_ENUM_FN(x) BPF_FUNC_ ##x
Christopher Ferris82d75042015-01-26 10:57:07 -0800523enum bpf_func_id {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800524 __BPF_FUNC_MAPPER(__BPF_ENUM_FN) __BPF_FUNC_MAX_ID,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800525};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800526#undef __BPF_ENUM_FN
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700527enum {
528 BPF_F_RECOMPUTE_CSUM = (1ULL << 0),
529 BPF_F_INVALIDATE_HASH = (1ULL << 1),
530};
531enum {
532 BPF_F_HDR_FIELD_MASK = 0xfULL,
533};
534enum {
535 BPF_F_PSEUDO_HDR = (1ULL << 4),
536 BPF_F_MARK_MANGLED_0 = (1ULL << 5),
537 BPF_F_MARK_ENFORCE = (1ULL << 6),
538};
539enum {
540 BPF_F_INGRESS = (1ULL << 0),
541};
542enum {
543 BPF_F_TUNINFO_IPV6 = (1ULL << 0),
544};
545enum {
546 BPF_F_SKIP_FIELD_MASK = 0xffULL,
547 BPF_F_USER_STACK = (1ULL << 8),
548 BPF_F_FAST_STACK_CMP = (1ULL << 9),
549 BPF_F_REUSE_STACKID = (1ULL << 10),
550 BPF_F_USER_BUILD_ID = (1ULL << 11),
551};
552enum {
553 BPF_F_ZERO_CSUM_TX = (1ULL << 1),
554 BPF_F_DONT_FRAGMENT = (1ULL << 2),
555 BPF_F_SEQ_NUMBER = (1ULL << 3),
556};
557enum {
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000558 BPF_F_TUNINFO_FLAGS = (1ULL << 4),
559};
560enum {
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700561 BPF_F_INDEX_MASK = 0xffffffffULL,
562 BPF_F_CURRENT_CPU = BPF_F_INDEX_MASK,
563 BPF_F_CTXLEN_MASK = (0xfffffULL << 32),
564};
565enum {
566 BPF_F_CURRENT_NETNS = (- 1L),
567};
568enum {
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700569 BPF_CSUM_LEVEL_QUERY,
570 BPF_CSUM_LEVEL_INC,
571 BPF_CSUM_LEVEL_DEC,
572 BPF_CSUM_LEVEL_RESET,
573};
574enum {
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700575 BPF_F_ADJ_ROOM_FIXED_GSO = (1ULL << 0),
576 BPF_F_ADJ_ROOM_ENCAP_L3_IPV4 = (1ULL << 1),
577 BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 = (1ULL << 2),
578 BPF_F_ADJ_ROOM_ENCAP_L4_GRE = (1ULL << 3),
579 BPF_F_ADJ_ROOM_ENCAP_L4_UDP = (1ULL << 4),
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700580 BPF_F_ADJ_ROOM_NO_CSUM_RESET = (1ULL << 5),
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000581 BPF_F_ADJ_ROOM_ENCAP_L2_ETH = (1ULL << 6),
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700582};
583enum {
584 BPF_ADJ_ROOM_ENCAP_L2_MASK = 0xff,
585 BPF_ADJ_ROOM_ENCAP_L2_SHIFT = 56,
586};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700587#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 -0700588enum {
589 BPF_F_SYSCTL_BASE_NAME = (1ULL << 0),
590};
591enum {
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800592 BPF_LOCAL_STORAGE_GET_F_CREATE = (1ULL << 0),
593 BPF_SK_STORAGE_GET_F_CREATE = BPF_LOCAL_STORAGE_GET_F_CREATE,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700594};
595enum {
596 BPF_F_GET_BRANCH_RECORDS_SIZE = (1ULL << 0),
597};
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700598enum {
599 BPF_RB_NO_WAKEUP = (1ULL << 0),
600 BPF_RB_FORCE_WAKEUP = (1ULL << 1),
601};
602enum {
603 BPF_RB_AVAIL_DATA = 0,
604 BPF_RB_RING_SIZE = 1,
605 BPF_RB_CONS_POS = 2,
606 BPF_RB_PROD_POS = 3,
607};
608enum {
609 BPF_RINGBUF_BUSY_BIT = (1U << 31),
610 BPF_RINGBUF_DISCARD_BIT = (1U << 30),
611 BPF_RINGBUF_HDR_SZ = 8,
612};
Christopher Ferris25c18d42020-10-14 17:42:58 -0700613enum {
614 BPF_SK_LOOKUP_F_REPLACE = (1ULL << 0),
615 BPF_SK_LOOKUP_F_NO_REUSEPORT = (1ULL << 1),
616};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800617enum bpf_adj_room_mode {
618 BPF_ADJ_ROOM_NET,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700619 BPF_ADJ_ROOM_MAC,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800620};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700621enum bpf_hdr_start_off {
622 BPF_HDR_START_MAC,
623 BPF_HDR_START_NET,
624};
625enum bpf_lwt_encap_mode {
626 BPF_LWT_ENCAP_SEG6,
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700627 BPF_LWT_ENCAP_SEG6_INLINE,
628 BPF_LWT_ENCAP_IP,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700629};
Christopher Ferris05667cd2021-02-16 16:01:34 -0800630enum {
631 BPF_F_BPRM_SECUREEXEC = (1ULL << 0),
632};
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000633enum {
634 BPF_F_BROADCAST = (1ULL << 3),
635 BPF_F_EXCLUDE_INGRESS = (1ULL << 4),
636};
Christopher Ferris86a48372019-01-10 14:14:59 -0800637#define __bpf_md_ptr(type,name) union { type name; __u64 : 64; \
638} __attribute__((aligned(8)))
Christopher Ferris10a76e62022-06-08 13:31:52 -0700639enum {
640 BPF_SKB_TSTAMP_UNSPEC,
641 BPF_SKB_TSTAMP_DELIVERY_MONO,
642};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800643struct __sk_buff {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800644 __u32 len;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800645 __u32 pkt_type;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800646 __u32 mark;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800647 __u32 queue_mapping;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800648 __u32 protocol;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800649 __u32 vlan_present;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800650 __u32 vlan_tci;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800651 __u32 vlan_proto;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800652 __u32 priority;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800653 __u32 ingress_ifindex;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800654 __u32 ifindex;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800655 __u32 tc_index;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800656 __u32 cb[5];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800657 __u32 hash;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800658 __u32 tc_classid;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800659 __u32 data;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800660 __u32 data_end;
Christopher Ferris525ce912017-07-26 13:12:53 -0700661 __u32 napi_id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800662 __u32 family;
663 __u32 remote_ip4;
664 __u32 local_ip4;
665 __u32 remote_ip6[4];
666 __u32 local_ip6[4];
667 __u32 remote_port;
668 __u32 local_port;
Christopher Ferris934ec942018-01-31 15:29:16 -0800669 __u32 data_meta;
Christopher Ferris86a48372019-01-10 14:14:59 -0800670 __bpf_md_ptr(struct bpf_flow_keys *, flow_keys);
Christopher Ferrisd842e432019-03-07 10:21:59 -0800671 __u64 tstamp;
672 __u32 wire_len;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700673 __u32 gso_segs;
674 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700675 __u32 gso_size;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700676 __u8 tstamp_type;
677 __u32 : 24;
Christopher Ferrisa4792612022-01-10 13:51:15 -0800678 __u64 hwtstamp;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800679};
680struct bpf_tunnel_key {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800681 __u32 tunnel_id;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800682 union {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700683 __u32 remote_ipv4;
684 __u32 remote_ipv6[4];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800685 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800686 __u8 tunnel_tos;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700687 __u8 tunnel_ttl;
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000688 union {
689 __u16 tunnel_ext;
690 __be16 tunnel_flags;
691 };
Christopher Ferris49f525c2016-12-12 14:55:36 -0800692 __u32 tunnel_label;
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700693 union {
694 __u32 local_ipv4;
695 __u32 local_ipv6[4];
696 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800697};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700698struct bpf_xfrm_state {
699 __u32 reqid;
700 __u32 spi;
701 __u16 family;
702 __u16 ext;
703 union {
704 __u32 remote_ipv4;
705 __u32 remote_ipv6[4];
706 };
707};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800708enum bpf_ret_code {
709 BPF_OK = 0,
710 BPF_DROP = 2,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800711 BPF_REDIRECT = 7,
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700712 BPF_LWT_REROUTE = 128,
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000713 BPF_FLOW_DISSECTOR_CONTINUE = 129,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800714};
715struct bpf_sock {
716 __u32 bound_dev_if;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800717 __u32 family;
718 __u32 type;
719 __u32 protocol;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800720 __u32 mark;
721 __u32 priority;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700722 __u32 src_ip4;
723 __u32 src_ip6[4];
724 __u32 src_port;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700725 __be16 dst_port;
726 __u16 : 16;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700727 __u32 dst_ip4;
728 __u32 dst_ip6[4];
729 __u32 state;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700730 __s32 rx_queue_mapping;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700731};
732struct bpf_tcp_sock {
733 __u32 snd_cwnd;
734 __u32 srtt_us;
735 __u32 rtt_min;
736 __u32 snd_ssthresh;
737 __u32 rcv_nxt;
738 __u32 snd_nxt;
739 __u32 snd_una;
740 __u32 mss_cache;
741 __u32 ecn_flags;
742 __u32 rate_delivered;
743 __u32 rate_interval_us;
744 __u32 packets_out;
745 __u32 retrans_out;
746 __u32 total_retrans;
747 __u32 segs_in;
748 __u32 data_segs_in;
749 __u32 segs_out;
750 __u32 data_segs_out;
751 __u32 lost_out;
752 __u32 sacked_out;
753 __u64 bytes_received;
754 __u64 bytes_acked;
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700755 __u32 dsack_dups;
756 __u32 delivered;
757 __u32 delivered_ce;
758 __u32 icsk_retransmits;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800759};
Christopher Ferris86a48372019-01-10 14:14:59 -0800760struct bpf_sock_tuple {
761 union {
762 struct {
763 __be32 saddr;
764 __be32 daddr;
765 __be16 sport;
766 __be16 dport;
767 } ipv4;
768 struct {
769 __be32 saddr[4];
770 __be32 daddr[4];
771 __be16 sport;
772 __be16 dport;
773 } ipv6;
774 };
775};
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700776struct bpf_xdp_sock {
777 __u32 queue_id;
778};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800779#define XDP_PACKET_HEADROOM 256
Christopher Ferris49f525c2016-12-12 14:55:36 -0800780enum xdp_action {
781 XDP_ABORTED = 0,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800782 XDP_DROP,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800783 XDP_PASS,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800784 XDP_TX,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800785 XDP_REDIRECT,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800786};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800787struct xdp_md {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800788 __u32 data;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800789 __u32 data_end;
Christopher Ferris934ec942018-01-31 15:29:16 -0800790 __u32 data_meta;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700791 __u32 ingress_ifindex;
792 __u32 rx_queue_index;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700793 __u32 egress_ifindex;
794};
795struct bpf_devmap_val {
796 __u32 ifindex;
797 union {
798 int fd;
799 __u32 id;
800 } bpf_prog;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800801};
Christopher Ferris25c18d42020-10-14 17:42:58 -0700802struct bpf_cpumap_val {
803 __u32 qsize;
804 union {
805 int fd;
806 __u32 id;
807 } bpf_prog;
808};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800809enum sk_action {
810 SK_DROP = 0,
811 SK_PASS,
812};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700813struct sk_msg_md {
Christopher Ferris86a48372019-01-10 14:14:59 -0800814 __bpf_md_ptr(void *, data);
815 __bpf_md_ptr(void *, data_end);
Christopher Ferris9ce28842018-10-25 12:11:39 -0700816 __u32 family;
817 __u32 remote_ip4;
818 __u32 local_ip4;
819 __u32 remote_ip6[4];
820 __u32 local_ip6[4];
821 __u32 remote_port;
822 __u32 local_port;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800823 __u32 size;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700824 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferris9ce28842018-10-25 12:11:39 -0700825};
826struct sk_reuseport_md {
Christopher Ferris86a48372019-01-10 14:14:59 -0800827 __bpf_md_ptr(void *, data);
828 __bpf_md_ptr(void *, data_end);
Christopher Ferris9ce28842018-10-25 12:11:39 -0700829 __u32 len;
830 __u32 eth_protocol;
831 __u32 ip_protocol;
832 __u32 bind_inany;
833 __u32 hash;
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000834 __bpf_md_ptr(struct bpf_sock *, sk);
835 __bpf_md_ptr(struct bpf_sock *, migrating_sk);
Christopher Ferris76a1d452018-06-27 14:12:29 -0700836};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800837#define BPF_TAG_SIZE 8
838struct bpf_prog_info {
839 __u32 type;
840 __u32 id;
841 __u8 tag[BPF_TAG_SIZE];
842 __u32 jited_prog_len;
843 __u32 xlated_prog_len;
844 __aligned_u64 jited_prog_insns;
845 __aligned_u64 xlated_prog_insns;
Christopher Ferris934ec942018-01-31 15:29:16 -0800846 __u64 load_time;
847 __u32 created_by_uid;
848 __u32 nr_map_ids;
849 __aligned_u64 map_ids;
850 char name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700851 __u32 ifindex;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700852 __u32 gpl_compatible : 1;
Christopher Ferrisfa59a102019-08-05 12:58:49 -0700853 __u32 : 31;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700854 __u64 netns_dev;
855 __u64 netns_ino;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700856 __u32 nr_jited_ksyms;
857 __u32 nr_jited_func_lens;
858 __aligned_u64 jited_ksyms;
859 __aligned_u64 jited_func_lens;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800860 __u32 btf_id;
861 __u32 func_info_rec_size;
862 __aligned_u64 func_info;
863 __u32 nr_func_info;
864 __u32 nr_line_info;
865 __aligned_u64 line_info;
866 __aligned_u64 jited_line_info;
867 __u32 nr_jited_line_info;
868 __u32 line_info_rec_size;
869 __u32 jited_line_info_rec_size;
870 __u32 nr_prog_tags;
871 __aligned_u64 prog_tags;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700872 __u64 run_time_ns;
873 __u64 run_cnt;
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700874 __u64 recursion_misses;
Christopher Ferrisa4792612022-01-10 13:51:15 -0800875 __u32 verified_insns;
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700876 __u32 attach_btf_obj_id;
877 __u32 attach_btf_id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800878} __attribute__((aligned(8)));
879struct bpf_map_info {
880 __u32 type;
881 __u32 id;
882 __u32 key_size;
883 __u32 value_size;
884 __u32 max_entries;
885 __u32 map_flags;
Christopher Ferris934ec942018-01-31 15:29:16 -0800886 char name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700887 __u32 ifindex;
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700888 __u32 btf_vmlinux_value_type_id;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700889 __u64 netns_dev;
890 __u64 netns_ino;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700891 __u32 btf_id;
892 __u32 btf_key_type_id;
893 __u32 btf_value_type_id;
Christopher Ferrisa4792612022-01-10 13:51:15 -0800894 __u32 : 32;
895 __u64 map_extra;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700896} __attribute__((aligned(8)));
897struct bpf_btf_info {
898 __aligned_u64 btf;
899 __u32 btf_size;
900 __u32 id;
Christopher Ferris05667cd2021-02-16 16:01:34 -0800901 __aligned_u64 name;
902 __u32 name_len;
903 __u32 kernel_btf;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800904} __attribute__((aligned(8)));
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700905struct bpf_link_info {
906 __u32 type;
907 __u32 id;
908 __u32 prog_id;
909 union {
910 struct {
911 __aligned_u64 tp_name;
912 __u32 tp_name_len;
913 } raw_tracepoint;
914 struct {
915 __u32 attach_type;
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000916 __u32 target_obj_id;
917 __u32 target_btf_id;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700918 } tracing;
919 struct {
920 __u64 cgroup_id;
921 __u32 attach_type;
922 } cgroup;
923 struct {
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800924 __aligned_u64 target_name;
925 __u32 target_name_len;
926 union {
927 struct {
928 __u32 map_id;
929 } map;
930 };
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000931 union {
932 struct {
933 __u64 cgroup_id;
934 __u32 order;
935 } cgroup;
936 struct {
937 __u32 tid;
938 __u32 pid;
939 } task;
940 };
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800941 } iter;
942 struct {
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700943 __u32 netns_ino;
944 __u32 attach_type;
945 } netns;
Christopher Ferris25c18d42020-10-14 17:42:58 -0700946 struct {
947 __u32 ifindex;
948 } xdp;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700949 };
950} __attribute__((aligned(8)));
Christopher Ferris76a1d452018-06-27 14:12:29 -0700951struct bpf_sock_addr {
952 __u32 user_family;
953 __u32 user_ip4;
954 __u32 user_ip6[4];
955 __u32 user_port;
956 __u32 family;
957 __u32 type;
958 __u32 protocol;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700959 __u32 msg_src_ip4;
960 __u32 msg_src_ip6[4];
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700961 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferris76a1d452018-06-27 14:12:29 -0700962};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800963struct bpf_sock_ops {
964 __u32 op;
965 union {
Christopher Ferris76a1d452018-06-27 14:12:29 -0700966 __u32 args[4];
Christopher Ferris1308ad32017-11-14 17:32:13 -0800967 __u32 reply;
968 __u32 replylong[4];
969 };
970 __u32 family;
971 __u32 remote_ip4;
972 __u32 local_ip4;
973 __u32 remote_ip6[4];
974 __u32 local_ip6[4];
975 __u32 remote_port;
976 __u32 local_port;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700977 __u32 is_fullsock;
978 __u32 snd_cwnd;
979 __u32 srtt_us;
980 __u32 bpf_sock_ops_cb_flags;
981 __u32 state;
982 __u32 rtt_min;
983 __u32 snd_ssthresh;
984 __u32 rcv_nxt;
985 __u32 snd_nxt;
986 __u32 snd_una;
987 __u32 mss_cache;
988 __u32 ecn_flags;
989 __u32 rate_delivered;
990 __u32 rate_interval_us;
991 __u32 packets_out;
992 __u32 retrans_out;
993 __u32 total_retrans;
994 __u32 segs_in;
995 __u32 data_segs_in;
996 __u32 segs_out;
997 __u32 data_segs_out;
998 __u32 lost_out;
999 __u32 sacked_out;
1000 __u32 sk_txhash;
1001 __u64 bytes_received;
1002 __u64 bytes_acked;
Christopher Ferrisb8a95e22019-10-02 18:29:20 -07001003 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferris32ff3f82020-12-14 13:10:04 -08001004 __bpf_md_ptr(void *, skb_data);
1005 __bpf_md_ptr(void *, skb_data_end);
1006 __u32 skb_len;
1007 __u32 skb_tcp_flags;
Christopher Ferris1308ad32017-11-14 17:32:13 -08001008};
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001009enum {
1010 BPF_SOCK_OPS_RTO_CB_FLAG = (1 << 0),
1011 BPF_SOCK_OPS_RETRANS_CB_FLAG = (1 << 1),
1012 BPF_SOCK_OPS_STATE_CB_FLAG = (1 << 2),
1013 BPF_SOCK_OPS_RTT_CB_FLAG = (1 << 3),
Christopher Ferris32ff3f82020-12-14 13:10:04 -08001014 BPF_SOCK_OPS_PARSE_ALL_HDR_OPT_CB_FLAG = (1 << 4),
1015 BPF_SOCK_OPS_PARSE_UNKNOWN_HDR_OPT_CB_FLAG = (1 << 5),
1016 BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG = (1 << 6),
1017 BPF_SOCK_OPS_ALL_CB_FLAGS = 0x7F,
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001018};
Christopher Ferris1308ad32017-11-14 17:32:13 -08001019enum {
1020 BPF_SOCK_OPS_VOID,
1021 BPF_SOCK_OPS_TIMEOUT_INIT,
1022 BPF_SOCK_OPS_RWND_INIT,
1023 BPF_SOCK_OPS_TCP_CONNECT_CB,
1024 BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB,
1025 BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB,
1026 BPF_SOCK_OPS_NEEDS_ECN,
Christopher Ferris934ec942018-01-31 15:29:16 -08001027 BPF_SOCK_OPS_BASE_RTT,
Christopher Ferris76a1d452018-06-27 14:12:29 -07001028 BPF_SOCK_OPS_RTO_CB,
1029 BPF_SOCK_OPS_RETRANS_CB,
1030 BPF_SOCK_OPS_STATE_CB,
Christopher Ferris9ce28842018-10-25 12:11:39 -07001031 BPF_SOCK_OPS_TCP_LISTEN_CB,
Christopher Ferrisb8a95e22019-10-02 18:29:20 -07001032 BPF_SOCK_OPS_RTT_CB,
Christopher Ferris32ff3f82020-12-14 13:10:04 -08001033 BPF_SOCK_OPS_PARSE_HDR_OPT_CB,
1034 BPF_SOCK_OPS_HDR_OPT_LEN_CB,
1035 BPF_SOCK_OPS_WRITE_HDR_OPT_CB,
Christopher Ferris76a1d452018-06-27 14:12:29 -07001036};
1037enum {
1038 BPF_TCP_ESTABLISHED = 1,
1039 BPF_TCP_SYN_SENT,
1040 BPF_TCP_SYN_RECV,
1041 BPF_TCP_FIN_WAIT1,
1042 BPF_TCP_FIN_WAIT2,
1043 BPF_TCP_TIME_WAIT,
1044 BPF_TCP_CLOSE,
1045 BPF_TCP_CLOSE_WAIT,
1046 BPF_TCP_LAST_ACK,
1047 BPF_TCP_LISTEN,
1048 BPF_TCP_CLOSING,
1049 BPF_TCP_NEW_SYN_RECV,
1050 BPF_TCP_MAX_STATES
Christopher Ferris1308ad32017-11-14 17:32:13 -08001051};
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001052enum {
1053 TCP_BPF_IW = 1001,
1054 TCP_BPF_SNDCWND_CLAMP = 1002,
Christopher Ferris32ff3f82020-12-14 13:10:04 -08001055 TCP_BPF_DELACK_MAX = 1003,
1056 TCP_BPF_RTO_MIN = 1004,
1057 TCP_BPF_SYN = 1005,
1058 TCP_BPF_SYN_IP = 1006,
1059 TCP_BPF_SYN_MAC = 1007,
1060};
1061enum {
1062 BPF_LOAD_HDR_OPT_TCP_SYN = (1ULL << 0),
1063};
1064enum {
1065 BPF_WRITE_HDR_TCP_CURRENT_MSS = 1,
1066 BPF_WRITE_HDR_TCP_SYNACK_COOKIE = 2,
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001067};
Christopher Ferris934ec942018-01-31 15:29:16 -08001068struct bpf_perf_event_value {
1069 __u64 counter;
1070 __u64 enabled;
1071 __u64 running;
1072};
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001073enum {
1074 BPF_DEVCG_ACC_MKNOD = (1ULL << 0),
1075 BPF_DEVCG_ACC_READ = (1ULL << 1),
1076 BPF_DEVCG_ACC_WRITE = (1ULL << 2),
1077};
1078enum {
1079 BPF_DEVCG_DEV_BLOCK = (1ULL << 0),
1080 BPF_DEVCG_DEV_CHAR = (1ULL << 1),
1081};
Christopher Ferris934ec942018-01-31 15:29:16 -08001082struct bpf_cgroup_dev_ctx {
1083 __u32 access_type;
1084 __u32 major;
1085 __u32 minor;
1086};
Christopher Ferris76a1d452018-06-27 14:12:29 -07001087struct bpf_raw_tracepoint_args {
1088 __u64 args[0];
1089};
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001090enum {
1091 BPF_FIB_LOOKUP_DIRECT = (1U << 0),
1092 BPF_FIB_LOOKUP_OUTPUT = (1U << 1),
1093};
Christopher Ferris9ce28842018-10-25 12:11:39 -07001094enum {
1095 BPF_FIB_LKUP_RET_SUCCESS,
1096 BPF_FIB_LKUP_RET_BLACKHOLE,
1097 BPF_FIB_LKUP_RET_UNREACHABLE,
1098 BPF_FIB_LKUP_RET_PROHIBIT,
1099 BPF_FIB_LKUP_RET_NOT_FWDED,
1100 BPF_FIB_LKUP_RET_FWD_DISABLED,
1101 BPF_FIB_LKUP_RET_UNSUPP_LWT,
1102 BPF_FIB_LKUP_RET_NO_NEIGH,
1103 BPF_FIB_LKUP_RET_FRAG_NEEDED,
1104};
1105struct bpf_fib_lookup {
1106 __u8 family;
1107 __u8 l4_protocol;
1108 __be16 sport;
1109 __be16 dport;
Christopher Ferrisa9750ed2021-05-03 14:02:49 -07001110 union {
1111 __u16 tot_len;
1112 __u16 mtu_result;
1113 };
Christopher Ferris9ce28842018-10-25 12:11:39 -07001114 __u32 ifindex;
1115 union {
1116 __u8 tos;
1117 __be32 flowinfo;
1118 __u32 rt_metric;
1119 };
1120 union {
1121 __be32 ipv4_src;
1122 __u32 ipv6_src[4];
1123 };
1124 union {
1125 __be32 ipv4_dst;
1126 __u32 ipv6_dst[4];
1127 };
1128 __be16 h_vlan_proto;
1129 __be16 h_vlan_TCI;
1130 __u8 smac[6];
1131 __u8 dmac[6];
1132};
Christopher Ferris32ff3f82020-12-14 13:10:04 -08001133struct bpf_redir_neigh {
1134 __u32 nh_family;
1135 union {
1136 __be32 ipv4_nh;
1137 __u32 ipv6_nh[4];
1138 };
1139};
Christopher Ferrisa9750ed2021-05-03 14:02:49 -07001140enum bpf_check_mtu_flags {
1141 BPF_MTU_CHK_SEGS = (1U << 0),
1142};
1143enum bpf_check_mtu_ret {
1144 BPF_MTU_CHK_RET_SUCCESS,
1145 BPF_MTU_CHK_RET_FRAG_NEEDED,
1146 BPF_MTU_CHK_RET_SEGS_TOOBIG,
1147};
Christopher Ferris9ce28842018-10-25 12:11:39 -07001148enum bpf_task_fd_type {
1149 BPF_FD_TYPE_RAW_TRACEPOINT,
1150 BPF_FD_TYPE_TRACEPOINT,
1151 BPF_FD_TYPE_KPROBE,
1152 BPF_FD_TYPE_KRETPROBE,
1153 BPF_FD_TYPE_UPROBE,
1154 BPF_FD_TYPE_URETPROBE,
1155};
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001156enum {
1157 BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG = (1U << 0),
1158 BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL = (1U << 1),
1159 BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP = (1U << 2),
1160};
Christopher Ferris86a48372019-01-10 14:14:59 -08001161struct bpf_flow_keys {
1162 __u16 nhoff;
1163 __u16 thoff;
1164 __u16 addr_proto;
1165 __u8 is_frag;
1166 __u8 is_first_frag;
1167 __u8 is_encap;
1168 __u8 ip_proto;
1169 __be16 n_proto;
1170 __be16 sport;
1171 __be16 dport;
1172 union {
1173 struct {
1174 __be32 ipv4_src;
1175 __be32 ipv4_dst;
1176 };
1177 struct {
1178 __u32 ipv6_src[4];
1179 __u32 ipv6_dst[4];
1180 };
1181 };
Christopher Ferris9584fa42019-12-09 15:36:13 -08001182 __u32 flags;
1183 __be32 flow_label;
Christopher Ferris86a48372019-01-10 14:14:59 -08001184};
Christopher Ferrisd842e432019-03-07 10:21:59 -08001185struct bpf_func_info {
1186 __u32 insn_off;
1187 __u32 type_id;
1188};
1189#define BPF_LINE_INFO_LINE_NUM(line_col) ((line_col) >> 10)
1190#define BPF_LINE_INFO_LINE_COL(line_col) ((line_col) & 0x3ff)
1191struct bpf_line_info {
1192 __u32 insn_off;
1193 __u32 file_name_off;
1194 __u32 line_off;
1195 __u32 line_col;
1196};
Christopher Ferris24f97eb2019-05-20 12:58:13 -07001197struct bpf_spin_lock {
1198 __u32 val;
1199};
Christopher Ferris2abfa9e2021-11-01 16:26:06 -07001200struct bpf_timer {
1201 __u64 : 64;
1202 __u64 : 64;
1203} __attribute__((aligned(8)));
Christopher Ferris80ae69d2022-08-02 16:32:21 -07001204struct bpf_dynptr {
1205 __u64 : 64;
1206 __u64 : 64;
1207} __attribute__((aligned(8)));
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -07001208struct bpf_sysctl {
1209 __u32 write;
1210 __u32 file_pos;
1211};
Christopher Ferrisb8a95e22019-10-02 18:29:20 -07001212struct bpf_sockopt {
1213 __bpf_md_ptr(struct bpf_sock *, sk);
1214 __bpf_md_ptr(void *, optval);
1215 __bpf_md_ptr(void *, optval_end);
1216 __s32 level;
1217 __s32 optname;
1218 __s32 optlen;
1219 __s32 retval;
1220};
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001221struct bpf_pidns_info {
1222 __u32 pid;
1223 __u32 tgid;
1224};
Christopher Ferris25c18d42020-10-14 17:42:58 -07001225struct bpf_sk_lookup {
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +00001226 union {
1227 __bpf_md_ptr(struct bpf_sock *, sk);
1228 __u64 cookie;
1229 };
Christopher Ferris25c18d42020-10-14 17:42:58 -07001230 __u32 family;
1231 __u32 protocol;
1232 __u32 remote_ip4;
1233 __u32 remote_ip6[4];
Christopher Ferris10a76e62022-06-08 13:31:52 -07001234 __be16 remote_port;
1235 __u16 : 16;
Christopher Ferris25c18d42020-10-14 17:42:58 -07001236 __u32 local_ip4;
1237 __u32 local_ip6[4];
1238 __u32 local_port;
Christopher Ferris1ed55342022-03-22 16:06:25 -07001239 __u32 ingress_ifindex;
Christopher Ferris25c18d42020-10-14 17:42:58 -07001240};
Christopher Ferris32ff3f82020-12-14 13:10:04 -08001241struct btf_ptr {
1242 void * ptr;
1243 __u32 type_id;
1244 __u32 flags;
1245};
1246enum {
1247 BTF_F_COMPACT = (1ULL << 0),
1248 BTF_F_NONAME = (1ULL << 1),
1249 BTF_F_PTR_RAW = (1ULL << 2),
1250 BTF_F_ZERO = (1ULL << 3),
1251};
Christopher Ferris1ed55342022-03-22 16:06:25 -07001252enum bpf_core_relo_kind {
1253 BPF_CORE_FIELD_BYTE_OFFSET = 0,
1254 BPF_CORE_FIELD_BYTE_SIZE = 1,
1255 BPF_CORE_FIELD_EXISTS = 2,
1256 BPF_CORE_FIELD_SIGNED = 3,
1257 BPF_CORE_FIELD_LSHIFT_U64 = 4,
1258 BPF_CORE_FIELD_RSHIFT_U64 = 5,
1259 BPF_CORE_TYPE_ID_LOCAL = 6,
1260 BPF_CORE_TYPE_ID_TARGET = 7,
1261 BPF_CORE_TYPE_EXISTS = 8,
1262 BPF_CORE_TYPE_SIZE = 9,
1263 BPF_CORE_ENUMVAL_EXISTS = 10,
1264 BPF_CORE_ENUMVAL_VALUE = 11,
Christopher Ferris7447a1c2022-10-04 18:24:44 -07001265 BPF_CORE_TYPE_MATCHES = 12,
Christopher Ferris1ed55342022-03-22 16:06:25 -07001266};
1267struct bpf_core_relo {
1268 __u32 insn_off;
1269 __u32 type_id;
1270 __u32 access_str_off;
1271 enum bpf_core_relo_kind kind;
1272};
Christopher Ferris82d75042015-01-26 10:57:07 -08001273#endif