blob: 5d0cfbacec885e521e06fe002fceab4dc9d62d9f [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
2 * This file is auto-generated. Modifications will be lost.
3 *
4 * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5 * for more information.
6 */
Christopher Ferris82d75042015-01-26 10:57:07 -08007#ifndef _UAPI__LINUX_BPF_H__
8#define _UAPI__LINUX_BPF_H__
9#include <linux/types.h>
10#include <linux/bpf_common.h>
Christopher Ferris24f97eb2019-05-20 12:58:13 -070011#define BPF_JMP32 0x06
Christopher Ferris82d75042015-01-26 10:57:07 -080012#define BPF_ALU64 0x07
13#define BPF_DW 0x18
Christopher Ferris67d1e5e2023-10-31 13:36:37 -070014#define BPF_MEMSX 0x80
Christopher Ferrisa9750ed2021-05-03 14:02:49 -070015#define BPF_ATOMIC 0xc0
Christopher Ferris82d75042015-01-26 10:57:07 -080016#define BPF_XADD 0xc0
17#define BPF_MOV 0xb0
Christopher Ferris82d75042015-01-26 10:57:07 -080018#define BPF_ARSH 0xc0
19#define BPF_END 0xd0
20#define BPF_TO_LE 0x00
21#define BPF_TO_BE 0x08
Christopher Ferris82d75042015-01-26 10:57:07 -080022#define BPF_FROM_LE BPF_TO_LE
23#define BPF_FROM_BE BPF_TO_BE
24#define BPF_JNE 0x50
Christopher Ferris1308ad32017-11-14 17:32:13 -080025#define BPF_JLT 0xa0
26#define BPF_JLE 0xb0
Christopher Ferris82d75042015-01-26 10:57:07 -080027#define BPF_JSGT 0x60
Christopher Ferris82d75042015-01-26 10:57:07 -080028#define BPF_JSGE 0x70
Christopher Ferris1308ad32017-11-14 17:32:13 -080029#define BPF_JSLT 0xc0
30#define BPF_JSLE 0xd0
Christopher Ferris82d75042015-01-26 10:57:07 -080031#define BPF_CALL 0x80
32#define BPF_EXIT 0x90
Christopher Ferrisa9750ed2021-05-03 14:02:49 -070033#define BPF_FETCH 0x01
34#define BPF_XCHG (0xe0 | BPF_FETCH)
35#define BPF_CMPXCHG (0xf0 | BPF_FETCH)
Christopher Ferris82d75042015-01-26 10:57:07 -080036enum {
Tao Baod7db5942015-01-28 10:07:51 -080037 BPF_REG_0 = 0,
38 BPF_REG_1,
39 BPF_REG_2,
40 BPF_REG_3,
Tao Baod7db5942015-01-28 10:07:51 -080041 BPF_REG_4,
42 BPF_REG_5,
43 BPF_REG_6,
44 BPF_REG_7,
Tao Baod7db5942015-01-28 10:07:51 -080045 BPF_REG_8,
46 BPF_REG_9,
47 BPF_REG_10,
48 __MAX_BPF_REG,
Christopher Ferris82d75042015-01-26 10:57:07 -080049};
50#define MAX_BPF_REG __MAX_BPF_REG
51struct bpf_insn {
Tao Baod7db5942015-01-28 10:07:51 -080052 __u8 code;
Tao Baod7db5942015-01-28 10:07:51 -080053 __u8 dst_reg : 4;
54 __u8 src_reg : 4;
55 __s16 off;
56 __s32 imm;
Christopher Ferris82d75042015-01-26 10:57:07 -080057};
Christopher Ferris525ce912017-07-26 13:12:53 -070058struct bpf_lpm_trie_key {
59 __u32 prefixlen;
60 __u8 data[0];
61};
Christopher Ferris9ce28842018-10-25 12:11:39 -070062struct bpf_cgroup_storage_key {
63 __u64 cgroup_inode_id;
64 __u32 attach_type;
65};
Christopher Ferris6cd53a52022-12-12 23:39:16 +000066enum bpf_cgroup_iter_order {
67 BPF_CGROUP_ITER_ORDER_UNSPEC = 0,
68 BPF_CGROUP_ITER_SELF_ONLY,
69 BPF_CGROUP_ITER_DESCENDANTS_PRE,
70 BPF_CGROUP_ITER_DESCENDANTS_POST,
71 BPF_CGROUP_ITER_ANCESTORS_UP,
72};
Christopher Ferris25c18d42020-10-14 17:42:58 -070073union bpf_iter_link_info {
74 struct {
75 __u32 map_fd;
76 } map;
Christopher Ferris6cd53a52022-12-12 23:39:16 +000077 struct {
78 enum bpf_cgroup_iter_order order;
79 __u32 cgroup_fd;
80 __u64 cgroup_id;
81 } cgroup;
82 struct {
83 __u32 tid;
84 __u32 pid;
85 __u32 pid_fd;
86 } task;
Christopher Ferris25c18d42020-10-14 17:42:58 -070087};
Christopher Ferris82d75042015-01-26 10:57:07 -080088enum bpf_cmd {
Tao Baod7db5942015-01-28 10:07:51 -080089 BPF_MAP_CREATE,
90 BPF_MAP_LOOKUP_ELEM,
Tao Baod7db5942015-01-28 10:07:51 -080091 BPF_MAP_UPDATE_ELEM,
92 BPF_MAP_DELETE_ELEM,
93 BPF_MAP_GET_NEXT_KEY,
94 BPF_PROG_LOAD,
Christopher Ferris05d08e92016-02-04 13:16:38 -080095 BPF_OBJ_PIN,
96 BPF_OBJ_GET,
Christopher Ferris48af7cb2017-02-21 12:35:09 -080097 BPF_PROG_ATTACH,
98 BPF_PROG_DETACH,
Christopher Ferris525ce912017-07-26 13:12:53 -070099 BPF_PROG_TEST_RUN,
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000100 BPF_PROG_RUN = BPF_PROG_TEST_RUN,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800101 BPF_PROG_GET_NEXT_ID,
102 BPF_MAP_GET_NEXT_ID,
103 BPF_PROG_GET_FD_BY_ID,
104 BPF_MAP_GET_FD_BY_ID,
105 BPF_OBJ_GET_INFO_BY_FD,
Christopher Ferris934ec942018-01-31 15:29:16 -0800106 BPF_PROG_QUERY,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700107 BPF_RAW_TRACEPOINT_OPEN,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700108 BPF_BTF_LOAD,
109 BPF_BTF_GET_FD_BY_ID,
110 BPF_TASK_FD_QUERY,
Christopher Ferris86a48372019-01-10 14:14:59 -0800111 BPF_MAP_LOOKUP_AND_DELETE_ELEM,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700112 BPF_MAP_FREEZE,
Christopher Ferris9584fa42019-12-09 15:36:13 -0800113 BPF_BTF_GET_NEXT_ID,
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700114 BPF_MAP_LOOKUP_BATCH,
115 BPF_MAP_LOOKUP_AND_DELETE_BATCH,
116 BPF_MAP_UPDATE_BATCH,
117 BPF_MAP_DELETE_BATCH,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700118 BPF_LINK_CREATE,
119 BPF_LINK_UPDATE,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700120 BPF_LINK_GET_FD_BY_ID,
121 BPF_LINK_GET_NEXT_ID,
122 BPF_ENABLE_STATS,
123 BPF_ITER_CREATE,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700124 BPF_LINK_DETACH,
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800125 BPF_PROG_BIND_MAP,
Christopher Ferris82d75042015-01-26 10:57:07 -0800126};
127enum bpf_map_type {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800128 BPF_MAP_TYPE_UNSPEC,
129 BPF_MAP_TYPE_HASH,
130 BPF_MAP_TYPE_ARRAY,
131 BPF_MAP_TYPE_PROG_ARRAY,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800132 BPF_MAP_TYPE_PERF_EVENT_ARRAY,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700133 BPF_MAP_TYPE_PERCPU_HASH,
134 BPF_MAP_TYPE_PERCPU_ARRAY,
135 BPF_MAP_TYPE_STACK_TRACE,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800136 BPF_MAP_TYPE_CGROUP_ARRAY,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800137 BPF_MAP_TYPE_LRU_HASH,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800138 BPF_MAP_TYPE_LRU_PERCPU_HASH,
Christopher Ferris525ce912017-07-26 13:12:53 -0700139 BPF_MAP_TYPE_LPM_TRIE,
140 BPF_MAP_TYPE_ARRAY_OF_MAPS,
141 BPF_MAP_TYPE_HASH_OF_MAPS,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800142 BPF_MAP_TYPE_DEVMAP,
143 BPF_MAP_TYPE_SOCKMAP,
Christopher Ferris934ec942018-01-31 15:29:16 -0800144 BPF_MAP_TYPE_CPUMAP,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700145 BPF_MAP_TYPE_XSKMAP,
146 BPF_MAP_TYPE_SOCKHASH,
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800147 BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED,
148 BPF_MAP_TYPE_CGROUP_STORAGE = BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700149 BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,
Christopher Ferris86a48372019-01-10 14:14:59 -0800150 BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,
151 BPF_MAP_TYPE_QUEUE,
152 BPF_MAP_TYPE_STACK,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700153 BPF_MAP_TYPE_SK_STORAGE,
Christopher Ferris9584fa42019-12-09 15:36:13 -0800154 BPF_MAP_TYPE_DEVMAP_HASH,
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700155 BPF_MAP_TYPE_STRUCT_OPS,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700156 BPF_MAP_TYPE_RINGBUF,
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800157 BPF_MAP_TYPE_INODE_STORAGE,
Christopher Ferris05667cd2021-02-16 16:01:34 -0800158 BPF_MAP_TYPE_TASK_STORAGE,
Christopher Ferrisa4792612022-01-10 13:51:15 -0800159 BPF_MAP_TYPE_BLOOM_FILTER,
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000160 BPF_MAP_TYPE_USER_RINGBUF,
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800161 BPF_MAP_TYPE_CGRP_STORAGE,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800162};
Christopher Ferris82d75042015-01-26 10:57:07 -0800163enum bpf_prog_type {
Tao Baod7db5942015-01-28 10:07:51 -0800164 BPF_PROG_TYPE_UNSPEC,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800165 BPF_PROG_TYPE_SOCKET_FILTER,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800166 BPF_PROG_TYPE_KPROBE,
167 BPF_PROG_TYPE_SCHED_CLS,
168 BPF_PROG_TYPE_SCHED_ACT,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800169 BPF_PROG_TYPE_TRACEPOINT,
170 BPF_PROG_TYPE_XDP,
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800171 BPF_PROG_TYPE_PERF_EVENT,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800172 BPF_PROG_TYPE_CGROUP_SKB,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800173 BPF_PROG_TYPE_CGROUP_SOCK,
174 BPF_PROG_TYPE_LWT_IN,
175 BPF_PROG_TYPE_LWT_OUT,
176 BPF_PROG_TYPE_LWT_XMIT,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800177 BPF_PROG_TYPE_SOCK_OPS,
178 BPF_PROG_TYPE_SK_SKB,
Christopher Ferris934ec942018-01-31 15:29:16 -0800179 BPF_PROG_TYPE_CGROUP_DEVICE,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700180 BPF_PROG_TYPE_SK_MSG,
181 BPF_PROG_TYPE_RAW_TRACEPOINT,
182 BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700183 BPF_PROG_TYPE_LWT_SEG6LOCAL,
184 BPF_PROG_TYPE_LIRC_MODE2,
185 BPF_PROG_TYPE_SK_REUSEPORT,
Christopher Ferris86a48372019-01-10 14:14:59 -0800186 BPF_PROG_TYPE_FLOW_DISSECTOR,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700187 BPF_PROG_TYPE_CGROUP_SYSCTL,
188 BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE,
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700189 BPF_PROG_TYPE_CGROUP_SOCKOPT,
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800190 BPF_PROG_TYPE_TRACING,
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700191 BPF_PROG_TYPE_STRUCT_OPS,
192 BPF_PROG_TYPE_EXT,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700193 BPF_PROG_TYPE_LSM,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700194 BPF_PROG_TYPE_SK_LOOKUP,
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000195 BPF_PROG_TYPE_SYSCALL,
Christopher Ferris37c3f3c2023-07-10 10:59:05 -0700196 BPF_PROG_TYPE_NETFILTER,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800197};
198enum bpf_attach_type {
199 BPF_CGROUP_INET_INGRESS,
200 BPF_CGROUP_INET_EGRESS,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800201 BPF_CGROUP_INET_SOCK_CREATE,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800202 BPF_CGROUP_SOCK_OPS,
203 BPF_SK_SKB_STREAM_PARSER,
204 BPF_SK_SKB_STREAM_VERDICT,
Christopher Ferris934ec942018-01-31 15:29:16 -0800205 BPF_CGROUP_DEVICE,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700206 BPF_SK_MSG_VERDICT,
207 BPF_CGROUP_INET4_BIND,
208 BPF_CGROUP_INET6_BIND,
209 BPF_CGROUP_INET4_CONNECT,
210 BPF_CGROUP_INET6_CONNECT,
211 BPF_CGROUP_INET4_POST_BIND,
212 BPF_CGROUP_INET6_POST_BIND,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700213 BPF_CGROUP_UDP4_SENDMSG,
214 BPF_CGROUP_UDP6_SENDMSG,
215 BPF_LIRC_MODE2,
Christopher Ferris86a48372019-01-10 14:14:59 -0800216 BPF_FLOW_DISSECTOR,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700217 BPF_CGROUP_SYSCTL,
218 BPF_CGROUP_UDP4_RECVMSG,
219 BPF_CGROUP_UDP6_RECVMSG,
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700220 BPF_CGROUP_GETSOCKOPT,
221 BPF_CGROUP_SETSOCKOPT,
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800222 BPF_TRACE_RAW_TP,
223 BPF_TRACE_FENTRY,
224 BPF_TRACE_FEXIT,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700225 BPF_MODIFY_RETURN,
226 BPF_LSM_MAC,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700227 BPF_TRACE_ITER,
228 BPF_CGROUP_INET4_GETPEERNAME,
229 BPF_CGROUP_INET6_GETPEERNAME,
230 BPF_CGROUP_INET4_GETSOCKNAME,
231 BPF_CGROUP_INET6_GETSOCKNAME,
232 BPF_XDP_DEVMAP,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700233 BPF_CGROUP_INET_SOCK_RELEASE,
234 BPF_XDP_CPUMAP,
235 BPF_SK_LOOKUP,
236 BPF_XDP,
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000237 BPF_SK_SKB_VERDICT,
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000238 BPF_SK_REUSEPORT_SELECT,
239 BPF_SK_REUSEPORT_SELECT_OR_MIGRATE,
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700240 BPF_PERF_EVENT,
Christopher Ferris10a76e62022-06-08 13:31:52 -0700241 BPF_TRACE_KPROBE_MULTI,
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700242 BPF_LSM_CGROUP,
Christopher Ferris37c3f3c2023-07-10 10:59:05 -0700243 BPF_STRUCT_OPS,
244 BPF_NETFILTER,
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700245 BPF_TCX_INGRESS,
246 BPF_TCX_EGRESS,
247 BPF_TRACE_UPROBE_MULTI,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800248 __MAX_BPF_ATTACH_TYPE
249};
250#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700251enum bpf_link_type {
252 BPF_LINK_TYPE_UNSPEC = 0,
253 BPF_LINK_TYPE_RAW_TRACEPOINT = 1,
254 BPF_LINK_TYPE_TRACING = 2,
255 BPF_LINK_TYPE_CGROUP = 3,
256 BPF_LINK_TYPE_ITER = 4,
257 BPF_LINK_TYPE_NETNS = 5,
Christopher Ferris25c18d42020-10-14 17:42:58 -0700258 BPF_LINK_TYPE_XDP = 6,
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700259 BPF_LINK_TYPE_PERF_EVENT = 7,
Christopher Ferris10a76e62022-06-08 13:31:52 -0700260 BPF_LINK_TYPE_KPROBE_MULTI = 8,
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700261 BPF_LINK_TYPE_STRUCT_OPS = 9,
Christopher Ferris37c3f3c2023-07-10 10:59:05 -0700262 BPF_LINK_TYPE_NETFILTER = 10,
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700263 BPF_LINK_TYPE_TCX = 11,
264 BPF_LINK_TYPE_UPROBE_MULTI = 12,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700265 MAX_BPF_LINK_TYPE,
266};
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700267enum bpf_perf_event_type {
268 BPF_PERF_EVENT_UNSPEC = 0,
269 BPF_PERF_EVENT_UPROBE = 1,
270 BPF_PERF_EVENT_URETPROBE = 2,
271 BPF_PERF_EVENT_KPROBE = 3,
272 BPF_PERF_EVENT_KRETPROBE = 4,
273 BPF_PERF_EVENT_TRACEPOINT = 5,
274 BPF_PERF_EVENT_EVENT = 6,
275};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800276#define BPF_F_ALLOW_OVERRIDE (1U << 0)
Christopher Ferris934ec942018-01-31 15:29:16 -0800277#define BPF_F_ALLOW_MULTI (1U << 1)
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700278#define BPF_F_REPLACE (1U << 2)
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700279#define BPF_F_BEFORE (1U << 3)
280#define BPF_F_AFTER (1U << 4)
281#define BPF_F_ID (1U << 5)
282#define BPF_F_LINK BPF_F_LINK
Christopher Ferris525ce912017-07-26 13:12:53 -0700283#define BPF_F_STRICT_ALIGNMENT (1U << 0)
Christopher Ferrisd842e432019-03-07 10:21:59 -0800284#define BPF_F_ANY_ALIGNMENT (1U << 1)
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700285#define BPF_F_TEST_RND_HI32 (1U << 2)
Christopher Ferris9584fa42019-12-09 15:36:13 -0800286#define BPF_F_TEST_STATE_FREQ (1U << 3)
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800287#define BPF_F_SLEEPABLE (1U << 4)
Christopher Ferris10a76e62022-06-08 13:31:52 -0700288#define BPF_F_XDP_HAS_FRAGS (1U << 5)
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000289#define BPF_F_XDP_DEV_BOUND_ONLY (1U << 6)
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700290enum {
291 BPF_F_KPROBE_MULTI_RETURN = (1U << 0)
292};
293enum {
294 BPF_F_UPROBE_MULTI_RETURN = (1U << 0)
295};
296#define BPF_F_NETFILTER_IP_DEFRAG (1U << 0)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800297#define BPF_PSEUDO_MAP_FD 1
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000298#define BPF_PSEUDO_MAP_IDX 5
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700299#define BPF_PSEUDO_MAP_VALUE 2
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000300#define BPF_PSEUDO_MAP_IDX_VALUE 6
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800301#define BPF_PSEUDO_BTF_ID 3
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000302#define BPF_PSEUDO_FUNC 4
Christopher Ferris76a1d452018-06-27 14:12:29 -0700303#define BPF_PSEUDO_CALL 1
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000304#define BPF_PSEUDO_KFUNC_CALL 2
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700305enum {
306 BPF_ANY = 0,
307 BPF_NOEXIST = 1,
308 BPF_EXIST = 2,
309 BPF_F_LOCK = 4,
310};
311enum {
312 BPF_F_NO_PREALLOC = (1U << 0),
313 BPF_F_NO_COMMON_LRU = (1U << 1),
314 BPF_F_NUMA_NODE = (1U << 2),
315 BPF_F_RDONLY = (1U << 3),
316 BPF_F_WRONLY = (1U << 4),
317 BPF_F_STACK_BUILD_ID = (1U << 5),
318 BPF_F_ZERO_SEED = (1U << 6),
319 BPF_F_RDONLY_PROG = (1U << 7),
320 BPF_F_WRONLY_PROG = (1U << 8),
321 BPF_F_CLONE = (1U << 9),
322 BPF_F_MMAPABLE = (1U << 10),
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800323 BPF_F_PRESERVE_ELEMS = (1U << 11),
324 BPF_F_INNER_MAP = (1U << 12),
Christopher Ferris37c3f3c2023-07-10 10:59:05 -0700325 BPF_F_LINK = (1U << 13),
Christopher Ferris8666d042023-09-06 14:55:31 -0700326 BPF_F_PATH_FD = (1U << 14),
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700327};
Christopher Ferrisd842e432019-03-07 10:21:59 -0800328#define BPF_F_QUERY_EFFECTIVE (1U << 0)
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800329#define BPF_F_TEST_RUN_ON_CPU (1U << 0)
Christopher Ferris10a76e62022-06-08 13:31:52 -0700330#define BPF_F_TEST_XDP_LIVE_FRAMES (1U << 1)
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700331enum bpf_stats_type {
332 BPF_STATS_RUN_TIME = 0,
333};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700334enum bpf_stack_build_id_status {
335 BPF_STACK_BUILD_ID_EMPTY = 0,
336 BPF_STACK_BUILD_ID_VALID = 1,
337 BPF_STACK_BUILD_ID_IP = 2,
338};
339#define BPF_BUILD_ID_SIZE 20
340struct bpf_stack_build_id {
341 __s32 status;
342 unsigned char build_id[BPF_BUILD_ID_SIZE];
343 union {
344 __u64 offset;
345 __u64 ip;
346 };
347};
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700348#define BPF_OBJ_NAME_LEN 16U
Christopher Ferris05d08e92016-02-04 13:16:38 -0800349union bpf_attr {
Tao Baod7db5942015-01-28 10:07:51 -0800350 struct {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700351 __u32 map_type;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800352 __u32 key_size;
Tao Baod7db5942015-01-28 10:07:51 -0800353 __u32 value_size;
Tao Baod7db5942015-01-28 10:07:51 -0800354 __u32 max_entries;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700355 __u32 map_flags;
Christopher Ferris525ce912017-07-26 13:12:53 -0700356 __u32 inner_map_fd;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800357 __u32 numa_node;
Christopher Ferris934ec942018-01-31 15:29:16 -0800358 char map_name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700359 __u32 map_ifindex;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700360 __u32 btf_fd;
361 __u32 btf_key_type_id;
362 __u32 btf_value_type_id;
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700363 __u32 btf_vmlinux_value_type_id;
Christopher Ferrisa4792612022-01-10 13:51:15 -0800364 __u64 map_extra;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800365 };
Tao Baod7db5942015-01-28 10:07:51 -0800366 struct {
367 __u32 map_fd;
Tao Baod7db5942015-01-28 10:07:51 -0800368 __aligned_u64 key;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800369 union {
Tao Baod7db5942015-01-28 10:07:51 -0800370 __aligned_u64 value;
371 __aligned_u64 next_key;
Tao Baod7db5942015-01-28 10:07:51 -0800372 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800373 __u64 flags;
Tao Baod7db5942015-01-28 10:07:51 -0800374 };
375 struct {
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700376 __aligned_u64 in_batch;
377 __aligned_u64 out_batch;
378 __aligned_u64 keys;
379 __aligned_u64 values;
380 __u32 count;
381 __u32 map_fd;
382 __u64 elem_flags;
383 __u64 flags;
384 } batch;
385 struct {
Tao Baod7db5942015-01-28 10:07:51 -0800386 __u32 prog_type;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800387 __u32 insn_cnt;
Tao Baod7db5942015-01-28 10:07:51 -0800388 __aligned_u64 insns;
389 __aligned_u64 license;
390 __u32 log_level;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800391 __u32 log_size;
Tao Baod7db5942015-01-28 10:07:51 -0800392 __aligned_u64 log_buf;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800393 __u32 kern_version;
Christopher Ferris525ce912017-07-26 13:12:53 -0700394 __u32 prog_flags;
Christopher Ferris934ec942018-01-31 15:29:16 -0800395 char prog_name[BPF_OBJ_NAME_LEN];
396 __u32 prog_ifindex;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700397 __u32 expected_attach_type;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800398 __u32 prog_btf_fd;
399 __u32 func_info_rec_size;
400 __aligned_u64 func_info;
401 __u32 func_info_cnt;
402 __u32 line_info_rec_size;
403 __aligned_u64 line_info;
404 __u32 line_info_cnt;
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800405 __u32 attach_btf_id;
Christopher Ferris05667cd2021-02-16 16:01:34 -0800406 union {
407 __u32 attach_prog_fd;
408 __u32 attach_btf_obj_fd;
409 };
Christopher Ferris1ed55342022-03-22 16:06:25 -0700410 __u32 core_relo_cnt;
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000411 __aligned_u64 fd_array;
Christopher Ferris1ed55342022-03-22 16:06:25 -0700412 __aligned_u64 core_relos;
413 __u32 core_relo_rec_size;
Christopher Ferris37c3f3c2023-07-10 10:59:05 -0700414 __u32 log_true_size;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800415 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800416 struct {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800417 __aligned_u64 pathname;
418 __u32 bpf_fd;
Christopher Ferris934ec942018-01-31 15:29:16 -0800419 __u32 file_flags;
Christopher Ferris8666d042023-09-06 14:55:31 -0700420 __s32 path_fd;
Tao Baod7db5942015-01-28 10:07:51 -0800421 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800422 struct {
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700423 union {
424 __u32 target_fd;
425 __u32 target_ifindex;
426 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800427 __u32 attach_bpf_fd;
428 __u32 attach_type;
429 __u32 attach_flags;
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700430 __u32 replace_bpf_fd;
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700431 union {
432 __u32 relative_fd;
433 __u32 relative_id;
434 };
435 __u64 expected_revision;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800436 };
Christopher Ferris525ce912017-07-26 13:12:53 -0700437 struct {
438 __u32 prog_fd;
439 __u32 retval;
440 __u32 data_size_in;
441 __u32 data_size_out;
442 __aligned_u64 data_in;
443 __aligned_u64 data_out;
444 __u32 repeat;
445 __u32 duration;
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700446 __u32 ctx_size_in;
447 __u32 ctx_size_out;
448 __aligned_u64 ctx_in;
449 __aligned_u64 ctx_out;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800450 __u32 flags;
451 __u32 cpu;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700452 __u32 batch_size;
Christopher Ferris525ce912017-07-26 13:12:53 -0700453 } test;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800454 struct {
455 union {
456 __u32 start_id;
457 __u32 prog_id;
458 __u32 map_id;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700459 __u32 btf_id;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700460 __u32 link_id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800461 };
462 __u32 next_id;
Christopher Ferris934ec942018-01-31 15:29:16 -0800463 __u32 open_flags;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800464 };
465 struct {
466 __u32 bpf_fd;
467 __u32 info_len;
468 __aligned_u64 info;
469 } info;
Christopher Ferris934ec942018-01-31 15:29:16 -0800470 struct {
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700471 union {
472 __u32 target_fd;
473 __u32 target_ifindex;
474 };
Christopher Ferris934ec942018-01-31 15:29:16 -0800475 __u32 attach_type;
476 __u32 query_flags;
477 __u32 attach_flags;
478 __aligned_u64 prog_ids;
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700479 union {
480 __u32 prog_cnt;
481 __u32 count;
482 };
483 __u32 : 32;
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700484 __aligned_u64 prog_attach_flags;
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700485 __aligned_u64 link_ids;
486 __aligned_u64 link_attach_flags;
487 __u64 revision;
Christopher Ferris934ec942018-01-31 15:29:16 -0800488 } query;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700489 struct {
490 __u64 name;
491 __u32 prog_fd;
492 } raw_tracepoint;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700493 struct {
494 __aligned_u64 btf;
495 __aligned_u64 btf_log_buf;
496 __u32 btf_size;
497 __u32 btf_log_size;
498 __u32 btf_log_level;
Christopher Ferris37c3f3c2023-07-10 10:59:05 -0700499 __u32 btf_log_true_size;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700500 };
501 struct {
502 __u32 pid;
503 __u32 fd;
504 __u32 flags;
505 __u32 buf_len;
506 __aligned_u64 buf;
507 __u32 prog_id;
508 __u32 fd_type;
509 __u64 probe_offset;
510 __u64 probe_addr;
511 } task_fd_query;
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700512 struct {
Christopher Ferris37c3f3c2023-07-10 10:59:05 -0700513 union {
514 __u32 prog_fd;
515 __u32 map_fd;
516 };
Christopher Ferris25c18d42020-10-14 17:42:58 -0700517 union {
518 __u32 target_fd;
519 __u32 target_ifindex;
520 };
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700521 __u32 attach_type;
522 __u32 flags;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800523 union {
524 __u32 target_btf_id;
525 struct {
526 __aligned_u64 iter_info;
527 __u32 iter_info_len;
528 };
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700529 struct {
530 __u64 bpf_cookie;
531 } perf_event;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700532 struct {
533 __u32 flags;
534 __u32 cnt;
535 __aligned_u64 syms;
536 __aligned_u64 addrs;
537 __aligned_u64 cookies;
538 } kprobe_multi;
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700539 struct {
540 __u32 target_btf_id;
541 __u64 cookie;
542 } tracing;
Christopher Ferris37c3f3c2023-07-10 10:59:05 -0700543 struct {
544 __u32 pf;
545 __u32 hooknum;
546 __s32 priority;
547 __u32 flags;
548 } netfilter;
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700549 struct {
550 union {
551 __u32 relative_fd;
552 __u32 relative_id;
553 };
554 __u64 expected_revision;
555 } tcx;
556 struct {
557 __aligned_u64 path;
558 __aligned_u64 offsets;
559 __aligned_u64 ref_ctr_offsets;
560 __aligned_u64 cookies;
561 __u32 cnt;
562 __u32 flags;
563 __u32 pid;
564 } uprobe_multi;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800565 };
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700566 } link_create;
567 struct {
568 __u32 link_fd;
Christopher Ferris37c3f3c2023-07-10 10:59:05 -0700569 union {
570 __u32 new_prog_fd;
571 __u32 new_map_fd;
572 };
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700573 __u32 flags;
Christopher Ferris37c3f3c2023-07-10 10:59:05 -0700574 union {
575 __u32 old_prog_fd;
576 __u32 old_map_fd;
577 };
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700578 } link_update;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700579 struct {
Christopher Ferris25c18d42020-10-14 17:42:58 -0700580 __u32 link_fd;
581 } link_detach;
582 struct {
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700583 __u32 type;
584 } enable_stats;
585 struct {
586 __u32 link_fd;
587 __u32 flags;
588 } iter_create;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800589 struct {
590 __u32 prog_fd;
591 __u32 map_fd;
592 __u32 flags;
593 } prog_bind_map;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800594} __attribute__((aligned(8)));
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800595#define ___BPF_FUNC_MAPPER(FN,ctx...) FN(unspec, 0, ##ctx) FN(map_lookup_elem, 1, ##ctx) FN(map_update_elem, 2, ##ctx) FN(map_delete_elem, 3, ##ctx) FN(probe_read, 4, ##ctx) FN(ktime_get_ns, 5, ##ctx) FN(trace_printk, 6, ##ctx) FN(get_prandom_u32, 7, ##ctx) FN(get_smp_processor_id, 8, ##ctx) FN(skb_store_bytes, 9, ##ctx) FN(l3_csum_replace, 10, ##ctx) FN(l4_csum_replace, 11, ##ctx) FN(tail_call, 12, ##ctx) FN(clone_redirect, 13, ##ctx) FN(get_current_pid_tgid, 14, ##ctx) FN(get_current_uid_gid, 15, ##ctx) FN(get_current_comm, 16, ##ctx) FN(get_cgroup_classid, 17, ##ctx) FN(skb_vlan_push, 18, ##ctx) FN(skb_vlan_pop, 19, ##ctx) FN(skb_get_tunnel_key, 20, ##ctx) FN(skb_set_tunnel_key, 21, ##ctx) FN(perf_event_read, 22, ##ctx) FN(redirect, 23, ##ctx) FN(get_route_realm, 24, ##ctx) FN(perf_event_output, 25, ##ctx) FN(skb_load_bytes, 26, ##ctx) FN(get_stackid, 27, ##ctx) FN(csum_diff, 28, ##ctx) FN(skb_get_tunnel_opt, 29, ##ctx) FN(skb_set_tunnel_opt, 30, ##ctx) FN(skb_change_proto, 31, ##ctx) FN(skb_change_type, 32, ##ctx) FN(skb_under_cgroup, 33, ##ctx) FN(get_hash_recalc, 34, ##ctx) FN(get_current_task, 35, ##ctx) FN(probe_write_user, 36, ##ctx) FN(current_task_under_cgroup, 37, ##ctx) FN(skb_change_tail, 38, ##ctx) FN(skb_pull_data, 39, ##ctx) FN(csum_update, 40, ##ctx) FN(set_hash_invalid, 41, ##ctx) FN(get_numa_node_id, 42, ##ctx) FN(skb_change_head, 43, ##ctx) FN(xdp_adjust_head, 44, ##ctx) FN(probe_read_str, 45, ##ctx) FN(get_socket_cookie, 46, ##ctx) FN(get_socket_uid, 47, ##ctx) FN(set_hash, 48, ##ctx) FN(setsockopt, 49, ##ctx) FN(skb_adjust_room, 50, ##ctx) FN(redirect_map, 51, ##ctx) FN(sk_redirect_map, 52, ##ctx) FN(sock_map_update, 53, ##ctx) FN(xdp_adjust_meta, 54, ##ctx) FN(perf_event_read_value, 55, ##ctx) FN(perf_prog_read_value, 56, ##ctx) FN(getsockopt, 57, ##ctx) FN(override_return, 58, ##ctx) FN(sock_ops_cb_flags_set, 59, ##ctx) FN(msg_redirect_map, 60, ##ctx) FN(msg_apply_bytes, 61, ##ctx) FN(msg_cork_bytes, 62, ##ctx) FN(msg_pull_data, 63, ##ctx) FN(bind, 64, ##ctx) FN(xdp_adjust_tail, 65, ##ctx) FN(skb_get_xfrm_state, 66, ##ctx) FN(get_stack, 67, ##ctx) FN(skb_load_bytes_relative, 68, ##ctx) FN(fib_lookup, 69, ##ctx) FN(sock_hash_update, 70, ##ctx) FN(msg_redirect_hash, 71, ##ctx) FN(sk_redirect_hash, 72, ##ctx) FN(lwt_push_encap, 73, ##ctx) FN(lwt_seg6_store_bytes, 74, ##ctx) FN(lwt_seg6_adjust_srh, 75, ##ctx) FN(lwt_seg6_action, 76, ##ctx) FN(rc_repeat, 77, ##ctx) FN(rc_keydown, 78, ##ctx) FN(skb_cgroup_id, 79, ##ctx) FN(get_current_cgroup_id, 80, ##ctx) FN(get_local_storage, 81, ##ctx) FN(sk_select_reuseport, 82, ##ctx) FN(skb_ancestor_cgroup_id, 83, ##ctx) FN(sk_lookup_tcp, 84, ##ctx) FN(sk_lookup_udp, 85, ##ctx) FN(sk_release, 86, ##ctx) FN(map_push_elem, 87, ##ctx) FN(map_pop_elem, 88, ##ctx) FN(map_peek_elem, 89, ##ctx) FN(msg_push_data, 90, ##ctx) FN(msg_pop_data, 91, ##ctx) FN(rc_pointer_rel, 92, ##ctx) FN(spin_lock, 93, ##ctx) FN(spin_unlock, 94, ##ctx) FN(sk_fullsock, 95, ##ctx) FN(tcp_sock, 96, ##ctx) FN(skb_ecn_set_ce, 97, ##ctx) FN(get_listener_sock, 98, ##ctx) FN(skc_lookup_tcp, 99, ##ctx) FN(tcp_check_syncookie, 100, ##ctx) FN(sysctl_get_name, 101, ##ctx) FN(sysctl_get_current_value, 102, ##ctx) FN(sysctl_get_new_value, 103, ##ctx) FN(sysctl_set_new_value, 104, ##ctx) FN(strtol, 105, ##ctx) FN(strtoul, 106, ##ctx) FN(sk_storage_get, 107, ##ctx) FN(sk_storage_delete, 108, ##ctx) FN(send_signal, 109, ##ctx) FN(tcp_gen_syncookie, 110, ##ctx) FN(skb_output, 111, ##ctx) FN(probe_read_user, 112, ##ctx) FN(probe_read_kernel, 113, ##ctx) FN(probe_read_user_str, 114, ##ctx) FN(probe_read_kernel_str, 115, ##ctx) FN(tcp_send_ack, 116, ##ctx) FN(send_signal_thread, 117, ##ctx) FN(jiffies64, 118, ##ctx) FN(read_branch_records, 119, ##ctx) FN(get_ns_current_pid_tgid, 120, ##ctx) FN(xdp_output, 121, ##ctx) FN(get_netns_cookie, 122, ##ctx) FN(get_current_ancestor_cgroup_id, 123, ##ctx) FN(sk_assign, 124, ##ctx) FN(ktime_get_boot_ns, 125, ##ctx) FN(seq_printf, 126, ##ctx) FN(seq_write, 127, ##ctx) FN(sk_cgroup_id, 128, ##ctx) FN(sk_ancestor_cgroup_id, 129, ##ctx) FN(ringbuf_output, 130, ##ctx) FN(ringbuf_reserve, 131, ##ctx) FN(ringbuf_submit, 132, ##ctx) FN(ringbuf_discard, 133, ##ctx) FN(ringbuf_query, 134, ##ctx) FN(csum_level, 135, ##ctx) FN(skc_to_tcp6_sock, 136, ##ctx) FN(skc_to_tcp_sock, 137, ##ctx) FN(skc_to_tcp_timewait_sock, 138, ##ctx) FN(skc_to_tcp_request_sock, 139, ##ctx) FN(skc_to_udp6_sock, 140, ##ctx) FN(get_task_stack, 141, ##ctx) FN(load_hdr_opt, 142, ##ctx) FN(store_hdr_opt, 143, ##ctx) FN(reserve_hdr_opt, 144, ##ctx) FN(inode_storage_get, 145, ##ctx) FN(inode_storage_delete, 146, ##ctx) FN(d_path, 147, ##ctx) FN(copy_from_user, 148, ##ctx) FN(snprintf_btf, 149, ##ctx) FN(seq_printf_btf, 150, ##ctx) FN(skb_cgroup_classid, 151, ##ctx) FN(redirect_neigh, 152, ##ctx) FN(per_cpu_ptr, 153, ##ctx) FN(this_cpu_ptr, 154, ##ctx) FN(redirect_peer, 155, ##ctx) FN(task_storage_get, 156, ##ctx) FN(task_storage_delete, 157, ##ctx) FN(get_current_task_btf, 158, ##ctx) FN(bprm_opts_set, 159, ##ctx) FN(ktime_get_coarse_ns, 160, ##ctx) FN(ima_inode_hash, 161, ##ctx) FN(sock_from_file, 162, ##ctx) FN(check_mtu, 163, ##ctx) FN(for_each_map_elem, 164, ##ctx) FN(snprintf, 165, ##ctx) FN(sys_bpf, 166, ##ctx) FN(btf_find_by_name_kind, 167, ##ctx) FN(sys_close, 168, ##ctx) FN(timer_init, 169, ##ctx) FN(timer_set_callback, 170, ##ctx) FN(timer_start, 171, ##ctx) FN(timer_cancel, 172, ##ctx) FN(get_func_ip, 173, ##ctx) FN(get_attach_cookie, 174, ##ctx) FN(task_pt_regs, 175, ##ctx) FN(get_branch_snapshot, 176, ##ctx) FN(trace_vprintk, 177, ##ctx) FN(skc_to_unix_sock, 178, ##ctx) FN(kallsyms_lookup_name, 179, ##ctx) FN(find_vma, 180, ##ctx) FN(loop, 181, ##ctx) FN(strncmp, 182, ##ctx) FN(get_func_arg, 183, ##ctx) FN(get_func_ret, 184, ##ctx) FN(get_func_arg_cnt, 185, ##ctx) FN(get_retval, 186, ##ctx) FN(set_retval, 187, ##ctx) FN(xdp_get_buff_len, 188, ##ctx) FN(xdp_load_bytes, 189, ##ctx) FN(xdp_store_bytes, 190, ##ctx) FN(copy_from_user_task, 191, ##ctx) FN(skb_set_tstamp, 192, ##ctx) FN(ima_file_hash, 193, ##ctx) FN(kptr_xchg, 194, ##ctx) FN(map_lookup_percpu_elem, 195, ##ctx) FN(skc_to_mptcp_sock, 196, ##ctx) FN(dynptr_from_mem, 197, ##ctx) FN(ringbuf_reserve_dynptr, 198, ##ctx) FN(ringbuf_submit_dynptr, 199, ##ctx) FN(ringbuf_discard_dynptr, 200, ##ctx) FN(dynptr_read, 201, ##ctx) FN(dynptr_write, 202, ##ctx) FN(dynptr_data, 203, ##ctx) FN(tcp_raw_gen_syncookie_ipv4, 204, ##ctx) FN(tcp_raw_gen_syncookie_ipv6, 205, ##ctx) FN(tcp_raw_check_syncookie_ipv4, 206, ##ctx) FN(tcp_raw_check_syncookie_ipv6, 207, ##ctx) FN(ktime_get_tai_ns, 208, ##ctx) FN(user_ringbuf_drain, 209, ##ctx) FN(cgrp_storage_get, 210, ##ctx) FN(cgrp_storage_delete, 211, ##ctx)
596#define __BPF_FUNC_MAPPER_APPLY(name,value,FN) FN(name),
597#define __BPF_FUNC_MAPPER(FN) ___BPF_FUNC_MAPPER(__BPF_FUNC_MAPPER_APPLY, FN)
598#define __BPF_ENUM_FN(x,y) BPF_FUNC_ ##x = y,
Christopher Ferris82d75042015-01-26 10:57:07 -0800599enum bpf_func_id {
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800600 ___BPF_FUNC_MAPPER(__BPF_ENUM_FN) __BPF_FUNC_MAX_ID,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800601};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800602#undef __BPF_ENUM_FN
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700603enum {
604 BPF_F_RECOMPUTE_CSUM = (1ULL << 0),
605 BPF_F_INVALIDATE_HASH = (1ULL << 1),
606};
607enum {
608 BPF_F_HDR_FIELD_MASK = 0xfULL,
609};
610enum {
611 BPF_F_PSEUDO_HDR = (1ULL << 4),
612 BPF_F_MARK_MANGLED_0 = (1ULL << 5),
613 BPF_F_MARK_ENFORCE = (1ULL << 6),
614};
615enum {
616 BPF_F_INGRESS = (1ULL << 0),
617};
618enum {
619 BPF_F_TUNINFO_IPV6 = (1ULL << 0),
620};
621enum {
622 BPF_F_SKIP_FIELD_MASK = 0xffULL,
623 BPF_F_USER_STACK = (1ULL << 8),
624 BPF_F_FAST_STACK_CMP = (1ULL << 9),
625 BPF_F_REUSE_STACKID = (1ULL << 10),
626 BPF_F_USER_BUILD_ID = (1ULL << 11),
627};
628enum {
629 BPF_F_ZERO_CSUM_TX = (1ULL << 1),
630 BPF_F_DONT_FRAGMENT = (1ULL << 2),
631 BPF_F_SEQ_NUMBER = (1ULL << 3),
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000632 BPF_F_NO_TUNNEL_KEY = (1ULL << 4),
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700633};
634enum {
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000635 BPF_F_TUNINFO_FLAGS = (1ULL << 4),
636};
637enum {
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700638 BPF_F_INDEX_MASK = 0xffffffffULL,
639 BPF_F_CURRENT_CPU = BPF_F_INDEX_MASK,
640 BPF_F_CTXLEN_MASK = (0xfffffULL << 32),
641};
642enum {
643 BPF_F_CURRENT_NETNS = (- 1L),
644};
645enum {
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700646 BPF_CSUM_LEVEL_QUERY,
647 BPF_CSUM_LEVEL_INC,
648 BPF_CSUM_LEVEL_DEC,
649 BPF_CSUM_LEVEL_RESET,
650};
651enum {
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700652 BPF_F_ADJ_ROOM_FIXED_GSO = (1ULL << 0),
653 BPF_F_ADJ_ROOM_ENCAP_L3_IPV4 = (1ULL << 1),
654 BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 = (1ULL << 2),
655 BPF_F_ADJ_ROOM_ENCAP_L4_GRE = (1ULL << 3),
656 BPF_F_ADJ_ROOM_ENCAP_L4_UDP = (1ULL << 4),
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700657 BPF_F_ADJ_ROOM_NO_CSUM_RESET = (1ULL << 5),
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000658 BPF_F_ADJ_ROOM_ENCAP_L2_ETH = (1ULL << 6),
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000659 BPF_F_ADJ_ROOM_DECAP_L3_IPV4 = (1ULL << 7),
660 BPF_F_ADJ_ROOM_DECAP_L3_IPV6 = (1ULL << 8),
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700661};
662enum {
663 BPF_ADJ_ROOM_ENCAP_L2_MASK = 0xff,
664 BPF_ADJ_ROOM_ENCAP_L2_SHIFT = 56,
665};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700666#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 -0700667enum {
668 BPF_F_SYSCTL_BASE_NAME = (1ULL << 0),
669};
670enum {
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800671 BPF_LOCAL_STORAGE_GET_F_CREATE = (1ULL << 0),
672 BPF_SK_STORAGE_GET_F_CREATE = BPF_LOCAL_STORAGE_GET_F_CREATE,
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700673};
674enum {
675 BPF_F_GET_BRANCH_RECORDS_SIZE = (1ULL << 0),
676};
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700677enum {
678 BPF_RB_NO_WAKEUP = (1ULL << 0),
679 BPF_RB_FORCE_WAKEUP = (1ULL << 1),
680};
681enum {
682 BPF_RB_AVAIL_DATA = 0,
683 BPF_RB_RING_SIZE = 1,
684 BPF_RB_CONS_POS = 2,
685 BPF_RB_PROD_POS = 3,
686};
687enum {
688 BPF_RINGBUF_BUSY_BIT = (1U << 31),
689 BPF_RINGBUF_DISCARD_BIT = (1U << 30),
690 BPF_RINGBUF_HDR_SZ = 8,
691};
Christopher Ferris25c18d42020-10-14 17:42:58 -0700692enum {
693 BPF_SK_LOOKUP_F_REPLACE = (1ULL << 0),
694 BPF_SK_LOOKUP_F_NO_REUSEPORT = (1ULL << 1),
695};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800696enum bpf_adj_room_mode {
697 BPF_ADJ_ROOM_NET,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700698 BPF_ADJ_ROOM_MAC,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800699};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700700enum bpf_hdr_start_off {
701 BPF_HDR_START_MAC,
702 BPF_HDR_START_NET,
703};
704enum bpf_lwt_encap_mode {
705 BPF_LWT_ENCAP_SEG6,
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700706 BPF_LWT_ENCAP_SEG6_INLINE,
707 BPF_LWT_ENCAP_IP,
Christopher Ferris9ce28842018-10-25 12:11:39 -0700708};
Christopher Ferris05667cd2021-02-16 16:01:34 -0800709enum {
710 BPF_F_BPRM_SECUREEXEC = (1ULL << 0),
711};
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000712enum {
713 BPF_F_BROADCAST = (1ULL << 3),
714 BPF_F_EXCLUDE_INGRESS = (1ULL << 4),
715};
Christopher Ferris86a48372019-01-10 14:14:59 -0800716#define __bpf_md_ptr(type,name) union { type name; __u64 : 64; \
717} __attribute__((aligned(8)))
Christopher Ferris10a76e62022-06-08 13:31:52 -0700718enum {
719 BPF_SKB_TSTAMP_UNSPEC,
720 BPF_SKB_TSTAMP_DELIVERY_MONO,
721};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800722struct __sk_buff {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800723 __u32 len;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800724 __u32 pkt_type;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800725 __u32 mark;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800726 __u32 queue_mapping;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800727 __u32 protocol;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800728 __u32 vlan_present;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800729 __u32 vlan_tci;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800730 __u32 vlan_proto;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800731 __u32 priority;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800732 __u32 ingress_ifindex;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800733 __u32 ifindex;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800734 __u32 tc_index;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800735 __u32 cb[5];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800736 __u32 hash;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800737 __u32 tc_classid;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800738 __u32 data;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800739 __u32 data_end;
Christopher Ferris525ce912017-07-26 13:12:53 -0700740 __u32 napi_id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800741 __u32 family;
742 __u32 remote_ip4;
743 __u32 local_ip4;
744 __u32 remote_ip6[4];
745 __u32 local_ip6[4];
746 __u32 remote_port;
747 __u32 local_port;
Christopher Ferris934ec942018-01-31 15:29:16 -0800748 __u32 data_meta;
Christopher Ferris86a48372019-01-10 14:14:59 -0800749 __bpf_md_ptr(struct bpf_flow_keys *, flow_keys);
Christopher Ferrisd842e432019-03-07 10:21:59 -0800750 __u64 tstamp;
751 __u32 wire_len;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700752 __u32 gso_segs;
753 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700754 __u32 gso_size;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700755 __u8 tstamp_type;
756 __u32 : 24;
Christopher Ferrisa4792612022-01-10 13:51:15 -0800757 __u64 hwtstamp;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800758};
759struct bpf_tunnel_key {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800760 __u32 tunnel_id;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800761 union {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700762 __u32 remote_ipv4;
763 __u32 remote_ipv6[4];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800764 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800765 __u8 tunnel_tos;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700766 __u8 tunnel_ttl;
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000767 union {
768 __u16 tunnel_ext;
769 __be16 tunnel_flags;
770 };
Christopher Ferris49f525c2016-12-12 14:55:36 -0800771 __u32 tunnel_label;
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700772 union {
773 __u32 local_ipv4;
774 __u32 local_ipv6[4];
775 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800776};
Christopher Ferris9ce28842018-10-25 12:11:39 -0700777struct bpf_xfrm_state {
778 __u32 reqid;
779 __u32 spi;
780 __u16 family;
781 __u16 ext;
782 union {
783 __u32 remote_ipv4;
784 __u32 remote_ipv6[4];
785 };
786};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800787enum bpf_ret_code {
788 BPF_OK = 0,
789 BPF_DROP = 2,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800790 BPF_REDIRECT = 7,
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700791 BPF_LWT_REROUTE = 128,
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000792 BPF_FLOW_DISSECTOR_CONTINUE = 129,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800793};
794struct bpf_sock {
795 __u32 bound_dev_if;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800796 __u32 family;
797 __u32 type;
798 __u32 protocol;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800799 __u32 mark;
800 __u32 priority;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700801 __u32 src_ip4;
802 __u32 src_ip6[4];
803 __u32 src_port;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700804 __be16 dst_port;
805 __u16 : 16;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700806 __u32 dst_ip4;
807 __u32 dst_ip6[4];
808 __u32 state;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700809 __s32 rx_queue_mapping;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700810};
811struct bpf_tcp_sock {
812 __u32 snd_cwnd;
813 __u32 srtt_us;
814 __u32 rtt_min;
815 __u32 snd_ssthresh;
816 __u32 rcv_nxt;
817 __u32 snd_nxt;
818 __u32 snd_una;
819 __u32 mss_cache;
820 __u32 ecn_flags;
821 __u32 rate_delivered;
822 __u32 rate_interval_us;
823 __u32 packets_out;
824 __u32 retrans_out;
825 __u32 total_retrans;
826 __u32 segs_in;
827 __u32 data_segs_in;
828 __u32 segs_out;
829 __u32 data_segs_out;
830 __u32 lost_out;
831 __u32 sacked_out;
832 __u64 bytes_received;
833 __u64 bytes_acked;
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700834 __u32 dsack_dups;
835 __u32 delivered;
836 __u32 delivered_ce;
837 __u32 icsk_retransmits;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800838};
Christopher Ferris86a48372019-01-10 14:14:59 -0800839struct bpf_sock_tuple {
840 union {
841 struct {
842 __be32 saddr;
843 __be32 daddr;
844 __be16 sport;
845 __be16 dport;
846 } ipv4;
847 struct {
848 __be32 saddr[4];
849 __be32 daddr[4];
850 __be16 sport;
851 __be16 dport;
852 } ipv6;
853 };
854};
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700855enum tcx_action_base {
856 TCX_NEXT = - 1,
857 TCX_PASS = 0,
858 TCX_DROP = 2,
859 TCX_REDIRECT = 7,
860};
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700861struct bpf_xdp_sock {
862 __u32 queue_id;
863};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800864#define XDP_PACKET_HEADROOM 256
Christopher Ferris49f525c2016-12-12 14:55:36 -0800865enum xdp_action {
866 XDP_ABORTED = 0,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800867 XDP_DROP,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800868 XDP_PASS,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800869 XDP_TX,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800870 XDP_REDIRECT,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800871};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800872struct xdp_md {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800873 __u32 data;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800874 __u32 data_end;
Christopher Ferris934ec942018-01-31 15:29:16 -0800875 __u32 data_meta;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700876 __u32 ingress_ifindex;
877 __u32 rx_queue_index;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700878 __u32 egress_ifindex;
879};
880struct bpf_devmap_val {
881 __u32 ifindex;
882 union {
883 int fd;
884 __u32 id;
885 } bpf_prog;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800886};
Christopher Ferris25c18d42020-10-14 17:42:58 -0700887struct bpf_cpumap_val {
888 __u32 qsize;
889 union {
890 int fd;
891 __u32 id;
892 } bpf_prog;
893};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800894enum sk_action {
895 SK_DROP = 0,
896 SK_PASS,
897};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700898struct sk_msg_md {
Christopher Ferris86a48372019-01-10 14:14:59 -0800899 __bpf_md_ptr(void *, data);
900 __bpf_md_ptr(void *, data_end);
Christopher Ferris9ce28842018-10-25 12:11:39 -0700901 __u32 family;
902 __u32 remote_ip4;
903 __u32 local_ip4;
904 __u32 remote_ip6[4];
905 __u32 local_ip6[4];
906 __u32 remote_port;
907 __u32 local_port;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800908 __u32 size;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700909 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferris9ce28842018-10-25 12:11:39 -0700910};
911struct sk_reuseport_md {
Christopher Ferris86a48372019-01-10 14:14:59 -0800912 __bpf_md_ptr(void *, data);
913 __bpf_md_ptr(void *, data_end);
Christopher Ferris9ce28842018-10-25 12:11:39 -0700914 __u32 len;
915 __u32 eth_protocol;
916 __u32 ip_protocol;
917 __u32 bind_inany;
918 __u32 hash;
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000919 __bpf_md_ptr(struct bpf_sock *, sk);
920 __bpf_md_ptr(struct bpf_sock *, migrating_sk);
Christopher Ferris76a1d452018-06-27 14:12:29 -0700921};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800922#define BPF_TAG_SIZE 8
923struct bpf_prog_info {
924 __u32 type;
925 __u32 id;
926 __u8 tag[BPF_TAG_SIZE];
927 __u32 jited_prog_len;
928 __u32 xlated_prog_len;
929 __aligned_u64 jited_prog_insns;
930 __aligned_u64 xlated_prog_insns;
Christopher Ferris934ec942018-01-31 15:29:16 -0800931 __u64 load_time;
932 __u32 created_by_uid;
933 __u32 nr_map_ids;
934 __aligned_u64 map_ids;
935 char name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700936 __u32 ifindex;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700937 __u32 gpl_compatible : 1;
Christopher Ferrisfa59a102019-08-05 12:58:49 -0700938 __u32 : 31;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700939 __u64 netns_dev;
940 __u64 netns_ino;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700941 __u32 nr_jited_ksyms;
942 __u32 nr_jited_func_lens;
943 __aligned_u64 jited_ksyms;
944 __aligned_u64 jited_func_lens;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800945 __u32 btf_id;
946 __u32 func_info_rec_size;
947 __aligned_u64 func_info;
948 __u32 nr_func_info;
949 __u32 nr_line_info;
950 __aligned_u64 line_info;
951 __aligned_u64 jited_line_info;
952 __u32 nr_jited_line_info;
953 __u32 line_info_rec_size;
954 __u32 jited_line_info_rec_size;
955 __u32 nr_prog_tags;
956 __aligned_u64 prog_tags;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700957 __u64 run_time_ns;
958 __u64 run_cnt;
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700959 __u64 recursion_misses;
Christopher Ferrisa4792612022-01-10 13:51:15 -0800960 __u32 verified_insns;
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700961 __u32 attach_btf_obj_id;
962 __u32 attach_btf_id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800963} __attribute__((aligned(8)));
964struct bpf_map_info {
965 __u32 type;
966 __u32 id;
967 __u32 key_size;
968 __u32 value_size;
969 __u32 max_entries;
970 __u32 map_flags;
Christopher Ferris934ec942018-01-31 15:29:16 -0800971 char name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700972 __u32 ifindex;
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700973 __u32 btf_vmlinux_value_type_id;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700974 __u64 netns_dev;
975 __u64 netns_ino;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700976 __u32 btf_id;
977 __u32 btf_key_type_id;
978 __u32 btf_value_type_id;
Christopher Ferrisa4792612022-01-10 13:51:15 -0800979 __u32 : 32;
980 __u64 map_extra;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700981} __attribute__((aligned(8)));
982struct bpf_btf_info {
983 __aligned_u64 btf;
984 __u32 btf_size;
985 __u32 id;
Christopher Ferris05667cd2021-02-16 16:01:34 -0800986 __aligned_u64 name;
987 __u32 name_len;
988 __u32 kernel_btf;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800989} __attribute__((aligned(8)));
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700990struct bpf_link_info {
991 __u32 type;
992 __u32 id;
993 __u32 prog_id;
994 union {
995 struct {
996 __aligned_u64 tp_name;
997 __u32 tp_name_len;
998 } raw_tracepoint;
999 struct {
1000 __u32 attach_type;
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +00001001 __u32 target_obj_id;
1002 __u32 target_btf_id;
Christopher Ferris8177cdf2020-08-03 11:53:55 -07001003 } tracing;
1004 struct {
1005 __u64 cgroup_id;
1006 __u32 attach_type;
1007 } cgroup;
1008 struct {
Christopher Ferris32ff3f82020-12-14 13:10:04 -08001009 __aligned_u64 target_name;
1010 __u32 target_name_len;
1011 union {
1012 struct {
1013 __u32 map_id;
1014 } map;
1015 };
Christopher Ferris6cd53a52022-12-12 23:39:16 +00001016 union {
1017 struct {
1018 __u64 cgroup_id;
1019 __u32 order;
1020 } cgroup;
1021 struct {
1022 __u32 tid;
1023 __u32 pid;
1024 } task;
1025 };
Christopher Ferris32ff3f82020-12-14 13:10:04 -08001026 } iter;
1027 struct {
Christopher Ferris8177cdf2020-08-03 11:53:55 -07001028 __u32 netns_ino;
1029 __u32 attach_type;
1030 } netns;
Christopher Ferris25c18d42020-10-14 17:42:58 -07001031 struct {
1032 __u32 ifindex;
1033 } xdp;
Christopher Ferris37c3f3c2023-07-10 10:59:05 -07001034 struct {
1035 __u32 map_id;
1036 } struct_ops;
1037 struct {
1038 __u32 pf;
1039 __u32 hooknum;
1040 __s32 priority;
1041 __u32 flags;
1042 } netfilter;
Christopher Ferris67d1e5e2023-10-31 13:36:37 -07001043 struct {
1044 __aligned_u64 addrs;
1045 __u32 count;
1046 __u32 flags;
1047 } kprobe_multi;
1048 struct {
1049 __u32 type;
1050 __u32 : 32;
1051 union {
1052 struct {
1053 __aligned_u64 file_name;
1054 __u32 name_len;
1055 __u32 offset;
1056 } uprobe;
1057 struct {
1058 __aligned_u64 func_name;
1059 __u32 name_len;
1060 __u32 offset;
1061 __u64 addr;
1062 } kprobe;
1063 struct {
1064 __aligned_u64 tp_name;
1065 __u32 name_len;
1066 } tracepoint;
1067 struct {
1068 __u64 config;
1069 __u32 type;
1070 } event;
1071 };
1072 } perf_event;
1073 struct {
1074 __u32 ifindex;
1075 __u32 attach_type;
1076 } tcx;
Christopher Ferris8177cdf2020-08-03 11:53:55 -07001077 };
1078} __attribute__((aligned(8)));
Christopher Ferris76a1d452018-06-27 14:12:29 -07001079struct bpf_sock_addr {
1080 __u32 user_family;
1081 __u32 user_ip4;
1082 __u32 user_ip6[4];
1083 __u32 user_port;
1084 __u32 family;
1085 __u32 type;
1086 __u32 protocol;
Christopher Ferris9ce28842018-10-25 12:11:39 -07001087 __u32 msg_src_ip4;
1088 __u32 msg_src_ip6[4];
Christopher Ferrisb8a95e22019-10-02 18:29:20 -07001089 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferris76a1d452018-06-27 14:12:29 -07001090};
Christopher Ferris1308ad32017-11-14 17:32:13 -08001091struct bpf_sock_ops {
1092 __u32 op;
1093 union {
Christopher Ferris76a1d452018-06-27 14:12:29 -07001094 __u32 args[4];
Christopher Ferris1308ad32017-11-14 17:32:13 -08001095 __u32 reply;
1096 __u32 replylong[4];
1097 };
1098 __u32 family;
1099 __u32 remote_ip4;
1100 __u32 local_ip4;
1101 __u32 remote_ip6[4];
1102 __u32 local_ip6[4];
1103 __u32 remote_port;
1104 __u32 local_port;
Christopher Ferris76a1d452018-06-27 14:12:29 -07001105 __u32 is_fullsock;
1106 __u32 snd_cwnd;
1107 __u32 srtt_us;
1108 __u32 bpf_sock_ops_cb_flags;
1109 __u32 state;
1110 __u32 rtt_min;
1111 __u32 snd_ssthresh;
1112 __u32 rcv_nxt;
1113 __u32 snd_nxt;
1114 __u32 snd_una;
1115 __u32 mss_cache;
1116 __u32 ecn_flags;
1117 __u32 rate_delivered;
1118 __u32 rate_interval_us;
1119 __u32 packets_out;
1120 __u32 retrans_out;
1121 __u32 total_retrans;
1122 __u32 segs_in;
1123 __u32 data_segs_in;
1124 __u32 segs_out;
1125 __u32 data_segs_out;
1126 __u32 lost_out;
1127 __u32 sacked_out;
1128 __u32 sk_txhash;
1129 __u64 bytes_received;
1130 __u64 bytes_acked;
Christopher Ferrisb8a95e22019-10-02 18:29:20 -07001131 __bpf_md_ptr(struct bpf_sock *, sk);
Christopher Ferris32ff3f82020-12-14 13:10:04 -08001132 __bpf_md_ptr(void *, skb_data);
1133 __bpf_md_ptr(void *, skb_data_end);
1134 __u32 skb_len;
1135 __u32 skb_tcp_flags;
Christopher Ferris8b7fdc92023-02-21 13:36:32 -08001136 __u64 skb_hwtstamp;
Christopher Ferris1308ad32017-11-14 17:32:13 -08001137};
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001138enum {
1139 BPF_SOCK_OPS_RTO_CB_FLAG = (1 << 0),
1140 BPF_SOCK_OPS_RETRANS_CB_FLAG = (1 << 1),
1141 BPF_SOCK_OPS_STATE_CB_FLAG = (1 << 2),
1142 BPF_SOCK_OPS_RTT_CB_FLAG = (1 << 3),
Christopher Ferris32ff3f82020-12-14 13:10:04 -08001143 BPF_SOCK_OPS_PARSE_ALL_HDR_OPT_CB_FLAG = (1 << 4),
1144 BPF_SOCK_OPS_PARSE_UNKNOWN_HDR_OPT_CB_FLAG = (1 << 5),
1145 BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG = (1 << 6),
1146 BPF_SOCK_OPS_ALL_CB_FLAGS = 0x7F,
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001147};
Christopher Ferris1308ad32017-11-14 17:32:13 -08001148enum {
1149 BPF_SOCK_OPS_VOID,
1150 BPF_SOCK_OPS_TIMEOUT_INIT,
1151 BPF_SOCK_OPS_RWND_INIT,
1152 BPF_SOCK_OPS_TCP_CONNECT_CB,
1153 BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB,
1154 BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB,
1155 BPF_SOCK_OPS_NEEDS_ECN,
Christopher Ferris934ec942018-01-31 15:29:16 -08001156 BPF_SOCK_OPS_BASE_RTT,
Christopher Ferris76a1d452018-06-27 14:12:29 -07001157 BPF_SOCK_OPS_RTO_CB,
1158 BPF_SOCK_OPS_RETRANS_CB,
1159 BPF_SOCK_OPS_STATE_CB,
Christopher Ferris9ce28842018-10-25 12:11:39 -07001160 BPF_SOCK_OPS_TCP_LISTEN_CB,
Christopher Ferrisb8a95e22019-10-02 18:29:20 -07001161 BPF_SOCK_OPS_RTT_CB,
Christopher Ferris32ff3f82020-12-14 13:10:04 -08001162 BPF_SOCK_OPS_PARSE_HDR_OPT_CB,
1163 BPF_SOCK_OPS_HDR_OPT_LEN_CB,
1164 BPF_SOCK_OPS_WRITE_HDR_OPT_CB,
Christopher Ferris76a1d452018-06-27 14:12:29 -07001165};
1166enum {
1167 BPF_TCP_ESTABLISHED = 1,
1168 BPF_TCP_SYN_SENT,
1169 BPF_TCP_SYN_RECV,
1170 BPF_TCP_FIN_WAIT1,
1171 BPF_TCP_FIN_WAIT2,
1172 BPF_TCP_TIME_WAIT,
1173 BPF_TCP_CLOSE,
1174 BPF_TCP_CLOSE_WAIT,
1175 BPF_TCP_LAST_ACK,
1176 BPF_TCP_LISTEN,
1177 BPF_TCP_CLOSING,
1178 BPF_TCP_NEW_SYN_RECV,
1179 BPF_TCP_MAX_STATES
Christopher Ferris1308ad32017-11-14 17:32:13 -08001180};
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001181enum {
1182 TCP_BPF_IW = 1001,
1183 TCP_BPF_SNDCWND_CLAMP = 1002,
Christopher Ferris32ff3f82020-12-14 13:10:04 -08001184 TCP_BPF_DELACK_MAX = 1003,
1185 TCP_BPF_RTO_MIN = 1004,
1186 TCP_BPF_SYN = 1005,
1187 TCP_BPF_SYN_IP = 1006,
1188 TCP_BPF_SYN_MAC = 1007,
1189};
1190enum {
1191 BPF_LOAD_HDR_OPT_TCP_SYN = (1ULL << 0),
1192};
1193enum {
1194 BPF_WRITE_HDR_TCP_CURRENT_MSS = 1,
1195 BPF_WRITE_HDR_TCP_SYNACK_COOKIE = 2,
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001196};
Christopher Ferris934ec942018-01-31 15:29:16 -08001197struct bpf_perf_event_value {
1198 __u64 counter;
1199 __u64 enabled;
1200 __u64 running;
1201};
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001202enum {
1203 BPF_DEVCG_ACC_MKNOD = (1ULL << 0),
1204 BPF_DEVCG_ACC_READ = (1ULL << 1),
1205 BPF_DEVCG_ACC_WRITE = (1ULL << 2),
1206};
1207enum {
1208 BPF_DEVCG_DEV_BLOCK = (1ULL << 0),
1209 BPF_DEVCG_DEV_CHAR = (1ULL << 1),
1210};
Christopher Ferris934ec942018-01-31 15:29:16 -08001211struct bpf_cgroup_dev_ctx {
1212 __u32 access_type;
1213 __u32 major;
1214 __u32 minor;
1215};
Christopher Ferris76a1d452018-06-27 14:12:29 -07001216struct bpf_raw_tracepoint_args {
1217 __u64 args[0];
1218};
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001219enum {
1220 BPF_FIB_LOOKUP_DIRECT = (1U << 0),
1221 BPF_FIB_LOOKUP_OUTPUT = (1U << 1),
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +00001222 BPF_FIB_LOOKUP_SKIP_NEIGH = (1U << 2),
Christopher Ferris8666d042023-09-06 14:55:31 -07001223 BPF_FIB_LOOKUP_TBID = (1U << 3),
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001224};
Christopher Ferris9ce28842018-10-25 12:11:39 -07001225enum {
1226 BPF_FIB_LKUP_RET_SUCCESS,
1227 BPF_FIB_LKUP_RET_BLACKHOLE,
1228 BPF_FIB_LKUP_RET_UNREACHABLE,
1229 BPF_FIB_LKUP_RET_PROHIBIT,
1230 BPF_FIB_LKUP_RET_NOT_FWDED,
1231 BPF_FIB_LKUP_RET_FWD_DISABLED,
1232 BPF_FIB_LKUP_RET_UNSUPP_LWT,
1233 BPF_FIB_LKUP_RET_NO_NEIGH,
1234 BPF_FIB_LKUP_RET_FRAG_NEEDED,
1235};
1236struct bpf_fib_lookup {
1237 __u8 family;
1238 __u8 l4_protocol;
1239 __be16 sport;
1240 __be16 dport;
Christopher Ferrisa9750ed2021-05-03 14:02:49 -07001241 union {
1242 __u16 tot_len;
1243 __u16 mtu_result;
1244 };
Christopher Ferris9ce28842018-10-25 12:11:39 -07001245 __u32 ifindex;
1246 union {
1247 __u8 tos;
1248 __be32 flowinfo;
1249 __u32 rt_metric;
1250 };
1251 union {
1252 __be32 ipv4_src;
1253 __u32 ipv6_src[4];
1254 };
1255 union {
1256 __be32 ipv4_dst;
1257 __u32 ipv6_dst[4];
1258 };
Christopher Ferris8666d042023-09-06 14:55:31 -07001259 union {
1260 struct {
1261 __be16 h_vlan_proto;
1262 __be16 h_vlan_TCI;
1263 };
1264 __u32 tbid;
1265 };
Christopher Ferris9ce28842018-10-25 12:11:39 -07001266 __u8 smac[6];
1267 __u8 dmac[6];
1268};
Christopher Ferris32ff3f82020-12-14 13:10:04 -08001269struct bpf_redir_neigh {
1270 __u32 nh_family;
1271 union {
1272 __be32 ipv4_nh;
1273 __u32 ipv6_nh[4];
1274 };
1275};
Christopher Ferrisa9750ed2021-05-03 14:02:49 -07001276enum bpf_check_mtu_flags {
1277 BPF_MTU_CHK_SEGS = (1U << 0),
1278};
1279enum bpf_check_mtu_ret {
1280 BPF_MTU_CHK_RET_SUCCESS,
1281 BPF_MTU_CHK_RET_FRAG_NEEDED,
1282 BPF_MTU_CHK_RET_SEGS_TOOBIG,
1283};
Christopher Ferris9ce28842018-10-25 12:11:39 -07001284enum bpf_task_fd_type {
1285 BPF_FD_TYPE_RAW_TRACEPOINT,
1286 BPF_FD_TYPE_TRACEPOINT,
1287 BPF_FD_TYPE_KPROBE,
1288 BPF_FD_TYPE_KRETPROBE,
1289 BPF_FD_TYPE_UPROBE,
1290 BPF_FD_TYPE_URETPROBE,
1291};
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001292enum {
1293 BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG = (1U << 0),
1294 BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL = (1U << 1),
1295 BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP = (1U << 2),
1296};
Christopher Ferris86a48372019-01-10 14:14:59 -08001297struct bpf_flow_keys {
1298 __u16 nhoff;
1299 __u16 thoff;
1300 __u16 addr_proto;
1301 __u8 is_frag;
1302 __u8 is_first_frag;
1303 __u8 is_encap;
1304 __u8 ip_proto;
1305 __be16 n_proto;
1306 __be16 sport;
1307 __be16 dport;
1308 union {
1309 struct {
1310 __be32 ipv4_src;
1311 __be32 ipv4_dst;
1312 };
1313 struct {
1314 __u32 ipv6_src[4];
1315 __u32 ipv6_dst[4];
1316 };
1317 };
Christopher Ferris9584fa42019-12-09 15:36:13 -08001318 __u32 flags;
1319 __be32 flow_label;
Christopher Ferris86a48372019-01-10 14:14:59 -08001320};
Christopher Ferrisd842e432019-03-07 10:21:59 -08001321struct bpf_func_info {
1322 __u32 insn_off;
1323 __u32 type_id;
1324};
1325#define BPF_LINE_INFO_LINE_NUM(line_col) ((line_col) >> 10)
1326#define BPF_LINE_INFO_LINE_COL(line_col) ((line_col) & 0x3ff)
1327struct bpf_line_info {
1328 __u32 insn_off;
1329 __u32 file_name_off;
1330 __u32 line_off;
1331 __u32 line_col;
1332};
Christopher Ferris24f97eb2019-05-20 12:58:13 -07001333struct bpf_spin_lock {
1334 __u32 val;
1335};
Christopher Ferris2abfa9e2021-11-01 16:26:06 -07001336struct bpf_timer {
1337 __u64 : 64;
1338 __u64 : 64;
1339} __attribute__((aligned(8)));
Christopher Ferris80ae69d2022-08-02 16:32:21 -07001340struct bpf_dynptr {
1341 __u64 : 64;
1342 __u64 : 64;
1343} __attribute__((aligned(8)));
Christopher Ferris8b7fdc92023-02-21 13:36:32 -08001344struct bpf_list_head {
1345 __u64 : 64;
1346 __u64 : 64;
1347} __attribute__((aligned(8)));
1348struct bpf_list_node {
1349 __u64 : 64;
1350 __u64 : 64;
Christopher Ferris67d1e5e2023-10-31 13:36:37 -07001351 __u64 : 64;
Christopher Ferris8b7fdc92023-02-21 13:36:32 -08001352} __attribute__((aligned(8)));
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +00001353struct bpf_rb_root {
1354 __u64 : 64;
1355 __u64 : 64;
1356} __attribute__((aligned(8)));
1357struct bpf_rb_node {
1358 __u64 : 64;
1359 __u64 : 64;
1360 __u64 : 64;
Christopher Ferris67d1e5e2023-10-31 13:36:37 -07001361 __u64 : 64;
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +00001362} __attribute__((aligned(8)));
Christopher Ferris37c3f3c2023-07-10 10:59:05 -07001363struct bpf_refcount {
1364 __u32 : 32;
1365} __attribute__((aligned(4)));
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -07001366struct bpf_sysctl {
1367 __u32 write;
1368 __u32 file_pos;
1369};
Christopher Ferrisb8a95e22019-10-02 18:29:20 -07001370struct bpf_sockopt {
1371 __bpf_md_ptr(struct bpf_sock *, sk);
1372 __bpf_md_ptr(void *, optval);
1373 __bpf_md_ptr(void *, optval_end);
1374 __s32 level;
1375 __s32 optname;
1376 __s32 optlen;
1377 __s32 retval;
1378};
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001379struct bpf_pidns_info {
1380 __u32 pid;
1381 __u32 tgid;
1382};
Christopher Ferris25c18d42020-10-14 17:42:58 -07001383struct bpf_sk_lookup {
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +00001384 union {
1385 __bpf_md_ptr(struct bpf_sock *, sk);
1386 __u64 cookie;
1387 };
Christopher Ferris25c18d42020-10-14 17:42:58 -07001388 __u32 family;
1389 __u32 protocol;
1390 __u32 remote_ip4;
1391 __u32 remote_ip6[4];
Christopher Ferris10a76e62022-06-08 13:31:52 -07001392 __be16 remote_port;
1393 __u16 : 16;
Christopher Ferris25c18d42020-10-14 17:42:58 -07001394 __u32 local_ip4;
1395 __u32 local_ip6[4];
1396 __u32 local_port;
Christopher Ferris1ed55342022-03-22 16:06:25 -07001397 __u32 ingress_ifindex;
Christopher Ferris25c18d42020-10-14 17:42:58 -07001398};
Christopher Ferris32ff3f82020-12-14 13:10:04 -08001399struct btf_ptr {
1400 void * ptr;
1401 __u32 type_id;
1402 __u32 flags;
1403};
1404enum {
1405 BTF_F_COMPACT = (1ULL << 0),
1406 BTF_F_NONAME = (1ULL << 1),
1407 BTF_F_PTR_RAW = (1ULL << 2),
1408 BTF_F_ZERO = (1ULL << 3),
1409};
Christopher Ferris1ed55342022-03-22 16:06:25 -07001410enum bpf_core_relo_kind {
1411 BPF_CORE_FIELD_BYTE_OFFSET = 0,
1412 BPF_CORE_FIELD_BYTE_SIZE = 1,
1413 BPF_CORE_FIELD_EXISTS = 2,
1414 BPF_CORE_FIELD_SIGNED = 3,
1415 BPF_CORE_FIELD_LSHIFT_U64 = 4,
1416 BPF_CORE_FIELD_RSHIFT_U64 = 5,
1417 BPF_CORE_TYPE_ID_LOCAL = 6,
1418 BPF_CORE_TYPE_ID_TARGET = 7,
1419 BPF_CORE_TYPE_EXISTS = 8,
1420 BPF_CORE_TYPE_SIZE = 9,
1421 BPF_CORE_ENUMVAL_EXISTS = 10,
1422 BPF_CORE_ENUMVAL_VALUE = 11,
Christopher Ferris7447a1c2022-10-04 18:24:44 -07001423 BPF_CORE_TYPE_MATCHES = 12,
Christopher Ferris1ed55342022-03-22 16:06:25 -07001424};
1425struct bpf_core_relo {
1426 __u32 insn_off;
1427 __u32 type_id;
1428 __u32 access_str_off;
1429 enum bpf_core_relo_kind kind;
1430};
Christopher Ferris37c3f3c2023-07-10 10:59:05 -07001431enum {
1432 BPF_F_TIMER_ABS = (1ULL << 0),
1433};
1434struct bpf_iter_num {
1435 __u64 __opaque[1];
1436} __attribute__((aligned(8)));
Christopher Ferris82d75042015-01-26 10:57:07 -08001437#endif