1 /**************************************************************************** 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> 23 #define BPF_JMP32 0x06 24 #define BPF_ALU64 0x07 25 #define BPF_DW 0x18 26 #define BPF_ATOMIC 0xc0 27 #define BPF_XADD 0xc0 28 #define BPF_MOV 0xb0 29 #define BPF_ARSH 0xc0 30 #define BPF_END 0xd0 31 #define BPF_TO_LE 0x00 32 #define BPF_TO_BE 0x08 33 #define BPF_FROM_LE BPF_TO_LE 34 #define BPF_FROM_BE BPF_TO_BE 35 #define BPF_JNE 0x50 36 #define BPF_JLT 0xa0 37 #define BPF_JLE 0xb0 38 #define BPF_JSGT 0x60 39 #define BPF_JSGE 0x70 40 #define BPF_JSLT 0xc0 41 #define BPF_JSLE 0xd0 42 #define BPF_CALL 0x80 43 #define BPF_EXIT 0x90 44 #define BPF_FETCH 0x01 45 #define BPF_XCHG (0xe0 | BPF_FETCH) 46 #define BPF_CMPXCHG (0xf0 | BPF_FETCH) 47 enum { 48 BPF_REG_0 = 0, 49 BPF_REG_1, 50 BPF_REG_2, 51 BPF_REG_3, 52 BPF_REG_4, 53 BPF_REG_5, 54 BPF_REG_6, 55 BPF_REG_7, 56 BPF_REG_8, 57 BPF_REG_9, 58 BPF_REG_10, 59 __MAX_BPF_REG, 60 }; 61 #define MAX_BPF_REG __MAX_BPF_REG 62 struct bpf_insn { 63 __u8 code; 64 __u8 dst_reg : 4; 65 __u8 src_reg : 4; 66 __s16 off; 67 __s32 imm; 68 }; 69 struct bpf_lpm_trie_key { 70 __u32 prefixlen; 71 __u8 data[0]; 72 }; 73 struct bpf_cgroup_storage_key { 74 __u64 cgroup_inode_id; 75 __u32 attach_type; 76 }; 77 union bpf_iter_link_info { 78 struct { 79 __u32 map_fd; 80 } map; 81 }; 82 enum bpf_cmd { 83 BPF_MAP_CREATE, 84 BPF_MAP_LOOKUP_ELEM, 85 BPF_MAP_UPDATE_ELEM, 86 BPF_MAP_DELETE_ELEM, 87 BPF_MAP_GET_NEXT_KEY, 88 BPF_PROG_LOAD, 89 BPF_OBJ_PIN, 90 BPF_OBJ_GET, 91 BPF_PROG_ATTACH, 92 BPF_PROG_DETACH, 93 BPF_PROG_TEST_RUN, 94 BPF_PROG_GET_NEXT_ID, 95 BPF_MAP_GET_NEXT_ID, 96 BPF_PROG_GET_FD_BY_ID, 97 BPF_MAP_GET_FD_BY_ID, 98 BPF_OBJ_GET_INFO_BY_FD, 99 BPF_PROG_QUERY, 100 BPF_RAW_TRACEPOINT_OPEN, 101 BPF_BTF_LOAD, 102 BPF_BTF_GET_FD_BY_ID, 103 BPF_TASK_FD_QUERY, 104 BPF_MAP_LOOKUP_AND_DELETE_ELEM, 105 BPF_MAP_FREEZE, 106 BPF_BTF_GET_NEXT_ID, 107 BPF_MAP_LOOKUP_BATCH, 108 BPF_MAP_LOOKUP_AND_DELETE_BATCH, 109 BPF_MAP_UPDATE_BATCH, 110 BPF_MAP_DELETE_BATCH, 111 BPF_LINK_CREATE, 112 BPF_LINK_UPDATE, 113 BPF_LINK_GET_FD_BY_ID, 114 BPF_LINK_GET_NEXT_ID, 115 BPF_ENABLE_STATS, 116 BPF_ITER_CREATE, 117 BPF_LINK_DETACH, 118 BPF_PROG_BIND_MAP, 119 }; 120 enum bpf_map_type { 121 BPF_MAP_TYPE_UNSPEC, 122 BPF_MAP_TYPE_HASH, 123 BPF_MAP_TYPE_ARRAY, 124 BPF_MAP_TYPE_PROG_ARRAY, 125 BPF_MAP_TYPE_PERF_EVENT_ARRAY, 126 BPF_MAP_TYPE_PERCPU_HASH, 127 BPF_MAP_TYPE_PERCPU_ARRAY, 128 BPF_MAP_TYPE_STACK_TRACE, 129 BPF_MAP_TYPE_CGROUP_ARRAY, 130 BPF_MAP_TYPE_LRU_HASH, 131 BPF_MAP_TYPE_LRU_PERCPU_HASH, 132 BPF_MAP_TYPE_LPM_TRIE, 133 BPF_MAP_TYPE_ARRAY_OF_MAPS, 134 BPF_MAP_TYPE_HASH_OF_MAPS, 135 BPF_MAP_TYPE_DEVMAP, 136 BPF_MAP_TYPE_SOCKMAP, 137 BPF_MAP_TYPE_CPUMAP, 138 BPF_MAP_TYPE_XSKMAP, 139 BPF_MAP_TYPE_SOCKHASH, 140 BPF_MAP_TYPE_CGROUP_STORAGE, 141 BPF_MAP_TYPE_REUSEPORT_SOCKARRAY, 142 BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE, 143 BPF_MAP_TYPE_QUEUE, 144 BPF_MAP_TYPE_STACK, 145 BPF_MAP_TYPE_SK_STORAGE, 146 BPF_MAP_TYPE_DEVMAP_HASH, 147 BPF_MAP_TYPE_STRUCT_OPS, 148 BPF_MAP_TYPE_RINGBUF, 149 BPF_MAP_TYPE_INODE_STORAGE, 150 BPF_MAP_TYPE_TASK_STORAGE, 151 }; 152 enum bpf_prog_type { 153 BPF_PROG_TYPE_UNSPEC, 154 BPF_PROG_TYPE_SOCKET_FILTER, 155 BPF_PROG_TYPE_KPROBE, 156 BPF_PROG_TYPE_SCHED_CLS, 157 BPF_PROG_TYPE_SCHED_ACT, 158 BPF_PROG_TYPE_TRACEPOINT, 159 BPF_PROG_TYPE_XDP, 160 BPF_PROG_TYPE_PERF_EVENT, 161 BPF_PROG_TYPE_CGROUP_SKB, 162 BPF_PROG_TYPE_CGROUP_SOCK, 163 BPF_PROG_TYPE_LWT_IN, 164 BPF_PROG_TYPE_LWT_OUT, 165 BPF_PROG_TYPE_LWT_XMIT, 166 BPF_PROG_TYPE_SOCK_OPS, 167 BPF_PROG_TYPE_SK_SKB, 168 BPF_PROG_TYPE_CGROUP_DEVICE, 169 BPF_PROG_TYPE_SK_MSG, 170 BPF_PROG_TYPE_RAW_TRACEPOINT, 171 BPF_PROG_TYPE_CGROUP_SOCK_ADDR, 172 BPF_PROG_TYPE_LWT_SEG6LOCAL, 173 BPF_PROG_TYPE_LIRC_MODE2, 174 BPF_PROG_TYPE_SK_REUSEPORT, 175 BPF_PROG_TYPE_FLOW_DISSECTOR, 176 BPF_PROG_TYPE_CGROUP_SYSCTL, 177 BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE, 178 BPF_PROG_TYPE_CGROUP_SOCKOPT, 179 BPF_PROG_TYPE_TRACING, 180 BPF_PROG_TYPE_STRUCT_OPS, 181 BPF_PROG_TYPE_EXT, 182 BPF_PROG_TYPE_LSM, 183 BPF_PROG_TYPE_SK_LOOKUP, 184 }; 185 enum bpf_attach_type { 186 BPF_CGROUP_INET_INGRESS, 187 BPF_CGROUP_INET_EGRESS, 188 BPF_CGROUP_INET_SOCK_CREATE, 189 BPF_CGROUP_SOCK_OPS, 190 BPF_SK_SKB_STREAM_PARSER, 191 BPF_SK_SKB_STREAM_VERDICT, 192 BPF_CGROUP_DEVICE, 193 BPF_SK_MSG_VERDICT, 194 BPF_CGROUP_INET4_BIND, 195 BPF_CGROUP_INET6_BIND, 196 BPF_CGROUP_INET4_CONNECT, 197 BPF_CGROUP_INET6_CONNECT, 198 BPF_CGROUP_INET4_POST_BIND, 199 BPF_CGROUP_INET6_POST_BIND, 200 BPF_CGROUP_UDP4_SENDMSG, 201 BPF_CGROUP_UDP6_SENDMSG, 202 BPF_LIRC_MODE2, 203 BPF_FLOW_DISSECTOR, 204 BPF_CGROUP_SYSCTL, 205 BPF_CGROUP_UDP4_RECVMSG, 206 BPF_CGROUP_UDP6_RECVMSG, 207 BPF_CGROUP_GETSOCKOPT, 208 BPF_CGROUP_SETSOCKOPT, 209 BPF_TRACE_RAW_TP, 210 BPF_TRACE_FENTRY, 211 BPF_TRACE_FEXIT, 212 BPF_MODIFY_RETURN, 213 BPF_LSM_MAC, 214 BPF_TRACE_ITER, 215 BPF_CGROUP_INET4_GETPEERNAME, 216 BPF_CGROUP_INET6_GETPEERNAME, 217 BPF_CGROUP_INET4_GETSOCKNAME, 218 BPF_CGROUP_INET6_GETSOCKNAME, 219 BPF_XDP_DEVMAP, 220 BPF_CGROUP_INET_SOCK_RELEASE, 221 BPF_XDP_CPUMAP, 222 BPF_SK_LOOKUP, 223 BPF_XDP, 224 __MAX_BPF_ATTACH_TYPE 225 }; 226 #define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE 227 enum bpf_link_type { 228 BPF_LINK_TYPE_UNSPEC = 0, 229 BPF_LINK_TYPE_RAW_TRACEPOINT = 1, 230 BPF_LINK_TYPE_TRACING = 2, 231 BPF_LINK_TYPE_CGROUP = 3, 232 BPF_LINK_TYPE_ITER = 4, 233 BPF_LINK_TYPE_NETNS = 5, 234 BPF_LINK_TYPE_XDP = 6, 235 MAX_BPF_LINK_TYPE, 236 }; 237 #define BPF_F_ALLOW_OVERRIDE (1U << 0) 238 #define BPF_F_ALLOW_MULTI (1U << 1) 239 #define BPF_F_REPLACE (1U << 2) 240 #define BPF_F_STRICT_ALIGNMENT (1U << 0) 241 #define BPF_F_ANY_ALIGNMENT (1U << 1) 242 #define BPF_F_TEST_RND_HI32 (1U << 2) 243 #define BPF_F_TEST_STATE_FREQ (1U << 3) 244 #define BPF_F_SLEEPABLE (1U << 4) 245 #define BPF_PSEUDO_MAP_FD 1 246 #define BPF_PSEUDO_MAP_VALUE 2 247 #define BPF_PSEUDO_BTF_ID 3 248 #define BPF_PSEUDO_CALL 1 249 enum { 250 BPF_ANY = 0, 251 BPF_NOEXIST = 1, 252 BPF_EXIST = 2, 253 BPF_F_LOCK = 4, 254 }; 255 enum { 256 BPF_F_NO_PREALLOC = (1U << 0), 257 BPF_F_NO_COMMON_LRU = (1U << 1), 258 BPF_F_NUMA_NODE = (1U << 2), 259 BPF_F_RDONLY = (1U << 3), 260 BPF_F_WRONLY = (1U << 4), 261 BPF_F_STACK_BUILD_ID = (1U << 5), 262 BPF_F_ZERO_SEED = (1U << 6), 263 BPF_F_RDONLY_PROG = (1U << 7), 264 BPF_F_WRONLY_PROG = (1U << 8), 265 BPF_F_CLONE = (1U << 9), 266 BPF_F_MMAPABLE = (1U << 10), 267 BPF_F_PRESERVE_ELEMS = (1U << 11), 268 BPF_F_INNER_MAP = (1U << 12), 269 }; 270 #define BPF_F_QUERY_EFFECTIVE (1U << 0) 271 #define BPF_F_TEST_RUN_ON_CPU (1U << 0) 272 enum bpf_stats_type { 273 BPF_STATS_RUN_TIME = 0, 274 }; 275 enum bpf_stack_build_id_status { 276 BPF_STACK_BUILD_ID_EMPTY = 0, 277 BPF_STACK_BUILD_ID_VALID = 1, 278 BPF_STACK_BUILD_ID_IP = 2, 279 }; 280 #define BPF_BUILD_ID_SIZE 20 281 struct bpf_stack_build_id { 282 __s32 status; 283 unsigned char build_id[BPF_BUILD_ID_SIZE]; 284 union { 285 __u64 offset; 286 __u64 ip; 287 }; 288 }; 289 #define BPF_OBJ_NAME_LEN 16U 290 union bpf_attr { 291 struct { 292 __u32 map_type; 293 __u32 key_size; 294 __u32 value_size; 295 __u32 max_entries; 296 __u32 map_flags; 297 __u32 inner_map_fd; 298 __u32 numa_node; 299 char map_name[BPF_OBJ_NAME_LEN]; 300 __u32 map_ifindex; 301 __u32 btf_fd; 302 __u32 btf_key_type_id; 303 __u32 btf_value_type_id; 304 __u32 btf_vmlinux_value_type_id; 305 }; 306 struct { 307 __u32 map_fd; 308 __aligned_u64 key; 309 union { 310 __aligned_u64 value; 311 __aligned_u64 next_key; 312 }; 313 __u64 flags; 314 }; 315 struct { 316 __aligned_u64 in_batch; 317 __aligned_u64 out_batch; 318 __aligned_u64 keys; 319 __aligned_u64 values; 320 __u32 count; 321 __u32 map_fd; 322 __u64 elem_flags; 323 __u64 flags; 324 } batch; 325 struct { 326 __u32 prog_type; 327 __u32 insn_cnt; 328 __aligned_u64 insns; 329 __aligned_u64 license; 330 __u32 log_level; 331 __u32 log_size; 332 __aligned_u64 log_buf; 333 __u32 kern_version; 334 __u32 prog_flags; 335 char prog_name[BPF_OBJ_NAME_LEN]; 336 __u32 prog_ifindex; 337 __u32 expected_attach_type; 338 __u32 prog_btf_fd; 339 __u32 func_info_rec_size; 340 __aligned_u64 func_info; 341 __u32 func_info_cnt; 342 __u32 line_info_rec_size; 343 __aligned_u64 line_info; 344 __u32 line_info_cnt; 345 __u32 attach_btf_id; 346 union { 347 __u32 attach_prog_fd; 348 __u32 attach_btf_obj_fd; 349 }; 350 }; 351 struct { 352 __aligned_u64 pathname; 353 __u32 bpf_fd; 354 __u32 file_flags; 355 }; 356 struct { 357 __u32 target_fd; 358 __u32 attach_bpf_fd; 359 __u32 attach_type; 360 __u32 attach_flags; 361 __u32 replace_bpf_fd; 362 }; 363 struct { 364 __u32 prog_fd; 365 __u32 retval; 366 __u32 data_size_in; 367 __u32 data_size_out; 368 __aligned_u64 data_in; 369 __aligned_u64 data_out; 370 __u32 repeat; 371 __u32 duration; 372 __u32 ctx_size_in; 373 __u32 ctx_size_out; 374 __aligned_u64 ctx_in; 375 __aligned_u64 ctx_out; 376 __u32 flags; 377 __u32 cpu; 378 } test; 379 struct { 380 union { 381 __u32 start_id; 382 __u32 prog_id; 383 __u32 map_id; 384 __u32 btf_id; 385 __u32 link_id; 386 }; 387 __u32 next_id; 388 __u32 open_flags; 389 }; 390 struct { 391 __u32 bpf_fd; 392 __u32 info_len; 393 __aligned_u64 info; 394 } info; 395 struct { 396 __u32 target_fd; 397 __u32 attach_type; 398 __u32 query_flags; 399 __u32 attach_flags; 400 __aligned_u64 prog_ids; 401 __u32 prog_cnt; 402 } query; 403 struct { 404 __u64 name; 405 __u32 prog_fd; 406 } raw_tracepoint; 407 struct { 408 __aligned_u64 btf; 409 __aligned_u64 btf_log_buf; 410 __u32 btf_size; 411 __u32 btf_log_size; 412 __u32 btf_log_level; 413 }; 414 struct { 415 __u32 pid; 416 __u32 fd; 417 __u32 flags; 418 __u32 buf_len; 419 __aligned_u64 buf; 420 __u32 prog_id; 421 __u32 fd_type; 422 __u64 probe_offset; 423 __u64 probe_addr; 424 } task_fd_query; 425 struct { 426 __u32 prog_fd; 427 union { 428 __u32 target_fd; 429 __u32 target_ifindex; 430 }; 431 __u32 attach_type; 432 __u32 flags; 433 union { 434 __u32 target_btf_id; 435 struct { 436 __aligned_u64 iter_info; 437 __u32 iter_info_len; 438 }; 439 }; 440 } link_create; 441 struct { 442 __u32 link_fd; 443 __u32 new_prog_fd; 444 __u32 flags; 445 __u32 old_prog_fd; 446 } link_update; 447 struct { 448 __u32 link_fd; 449 } link_detach; 450 struct { 451 __u32 type; 452 } enable_stats; 453 struct { 454 __u32 link_fd; 455 __u32 flags; 456 } iter_create; 457 struct { 458 __u32 prog_fd; 459 __u32 map_fd; 460 __u32 flags; 461 } prog_bind_map; 462 } __attribute__((aligned(8))); 463 #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), 464 #define __BPF_ENUM_FN(x) BPF_FUNC_ ##x 465 enum bpf_func_id { 466 __BPF_FUNC_MAPPER(__BPF_ENUM_FN) __BPF_FUNC_MAX_ID, 467 }; 468 #undef __BPF_ENUM_FN 469 enum { 470 BPF_F_RECOMPUTE_CSUM = (1ULL << 0), 471 BPF_F_INVALIDATE_HASH = (1ULL << 1), 472 }; 473 enum { 474 BPF_F_HDR_FIELD_MASK = 0xfULL, 475 }; 476 enum { 477 BPF_F_PSEUDO_HDR = (1ULL << 4), 478 BPF_F_MARK_MANGLED_0 = (1ULL << 5), 479 BPF_F_MARK_ENFORCE = (1ULL << 6), 480 }; 481 enum { 482 BPF_F_INGRESS = (1ULL << 0), 483 }; 484 enum { 485 BPF_F_TUNINFO_IPV6 = (1ULL << 0), 486 }; 487 enum { 488 BPF_F_SKIP_FIELD_MASK = 0xffULL, 489 BPF_F_USER_STACK = (1ULL << 8), 490 BPF_F_FAST_STACK_CMP = (1ULL << 9), 491 BPF_F_REUSE_STACKID = (1ULL << 10), 492 BPF_F_USER_BUILD_ID = (1ULL << 11), 493 }; 494 enum { 495 BPF_F_ZERO_CSUM_TX = (1ULL << 1), 496 BPF_F_DONT_FRAGMENT = (1ULL << 2), 497 BPF_F_SEQ_NUMBER = (1ULL << 3), 498 }; 499 enum { 500 BPF_F_INDEX_MASK = 0xffffffffULL, 501 BPF_F_CURRENT_CPU = BPF_F_INDEX_MASK, 502 BPF_F_CTXLEN_MASK = (0xfffffULL << 32), 503 }; 504 enum { 505 BPF_F_CURRENT_NETNS = (- 1L), 506 }; 507 enum { 508 BPF_CSUM_LEVEL_QUERY, 509 BPF_CSUM_LEVEL_INC, 510 BPF_CSUM_LEVEL_DEC, 511 BPF_CSUM_LEVEL_RESET, 512 }; 513 enum { 514 BPF_F_ADJ_ROOM_FIXED_GSO = (1ULL << 0), 515 BPF_F_ADJ_ROOM_ENCAP_L3_IPV4 = (1ULL << 1), 516 BPF_F_ADJ_ROOM_ENCAP_L3_IPV6 = (1ULL << 2), 517 BPF_F_ADJ_ROOM_ENCAP_L4_GRE = (1ULL << 3), 518 BPF_F_ADJ_ROOM_ENCAP_L4_UDP = (1ULL << 4), 519 BPF_F_ADJ_ROOM_NO_CSUM_RESET = (1ULL << 5), 520 }; 521 enum { 522 BPF_ADJ_ROOM_ENCAP_L2_MASK = 0xff, 523 BPF_ADJ_ROOM_ENCAP_L2_SHIFT = 56, 524 }; 525 #define BPF_F_ADJ_ROOM_ENCAP_L2(len) (((__u64) len & BPF_ADJ_ROOM_ENCAP_L2_MASK) << BPF_ADJ_ROOM_ENCAP_L2_SHIFT) 526 enum { 527 BPF_F_SYSCTL_BASE_NAME = (1ULL << 0), 528 }; 529 enum { 530 BPF_LOCAL_STORAGE_GET_F_CREATE = (1ULL << 0), 531 BPF_SK_STORAGE_GET_F_CREATE = BPF_LOCAL_STORAGE_GET_F_CREATE, 532 }; 533 enum { 534 BPF_F_GET_BRANCH_RECORDS_SIZE = (1ULL << 0), 535 }; 536 enum { 537 BPF_RB_NO_WAKEUP = (1ULL << 0), 538 BPF_RB_FORCE_WAKEUP = (1ULL << 1), 539 }; 540 enum { 541 BPF_RB_AVAIL_DATA = 0, 542 BPF_RB_RING_SIZE = 1, 543 BPF_RB_CONS_POS = 2, 544 BPF_RB_PROD_POS = 3, 545 }; 546 enum { 547 BPF_RINGBUF_BUSY_BIT = (1U << 31), 548 BPF_RINGBUF_DISCARD_BIT = (1U << 30), 549 BPF_RINGBUF_HDR_SZ = 8, 550 }; 551 enum { 552 BPF_SK_LOOKUP_F_REPLACE = (1ULL << 0), 553 BPF_SK_LOOKUP_F_NO_REUSEPORT = (1ULL << 1), 554 }; 555 enum bpf_adj_room_mode { 556 BPF_ADJ_ROOM_NET, 557 BPF_ADJ_ROOM_MAC, 558 }; 559 enum bpf_hdr_start_off { 560 BPF_HDR_START_MAC, 561 BPF_HDR_START_NET, 562 }; 563 enum bpf_lwt_encap_mode { 564 BPF_LWT_ENCAP_SEG6, 565 BPF_LWT_ENCAP_SEG6_INLINE, 566 BPF_LWT_ENCAP_IP, 567 }; 568 enum { 569 BPF_F_BPRM_SECUREEXEC = (1ULL << 0), 570 }; 571 #define __bpf_md_ptr(type,name) union { type name; __u64 : 64; \ 572 } __attribute__((aligned(8))) 573 struct __sk_buff { 574 __u32 len; 575 __u32 pkt_type; 576 __u32 mark; 577 __u32 queue_mapping; 578 __u32 protocol; 579 __u32 vlan_present; 580 __u32 vlan_tci; 581 __u32 vlan_proto; 582 __u32 priority; 583 __u32 ingress_ifindex; 584 __u32 ifindex; 585 __u32 tc_index; 586 __u32 cb[5]; 587 __u32 hash; 588 __u32 tc_classid; 589 __u32 data; 590 __u32 data_end; 591 __u32 napi_id; 592 __u32 family; 593 __u32 remote_ip4; 594 __u32 local_ip4; 595 __u32 remote_ip6[4]; 596 __u32 local_ip6[4]; 597 __u32 remote_port; 598 __u32 local_port; 599 __u32 data_meta; 600 __bpf_md_ptr(struct bpf_flow_keys *, flow_keys); 601 __u64 tstamp; 602 __u32 wire_len; 603 __u32 gso_segs; 604 __bpf_md_ptr(struct bpf_sock *, sk); 605 __u32 gso_size; 606 }; 607 struct bpf_tunnel_key { 608 __u32 tunnel_id; 609 union { 610 __u32 remote_ipv4; 611 __u32 remote_ipv6[4]; 612 }; 613 __u8 tunnel_tos; 614 __u8 tunnel_ttl; 615 __u16 tunnel_ext; 616 __u32 tunnel_label; 617 }; 618 struct bpf_xfrm_state { 619 __u32 reqid; 620 __u32 spi; 621 __u16 family; 622 __u16 ext; 623 union { 624 __u32 remote_ipv4; 625 __u32 remote_ipv6[4]; 626 }; 627 }; 628 enum bpf_ret_code { 629 BPF_OK = 0, 630 BPF_DROP = 2, 631 BPF_REDIRECT = 7, 632 BPF_LWT_REROUTE = 128, 633 }; 634 struct bpf_sock { 635 __u32 bound_dev_if; 636 __u32 family; 637 __u32 type; 638 __u32 protocol; 639 __u32 mark; 640 __u32 priority; 641 __u32 src_ip4; 642 __u32 src_ip6[4]; 643 __u32 src_port; 644 __u32 dst_port; 645 __u32 dst_ip4; 646 __u32 dst_ip6[4]; 647 __u32 state; 648 __s32 rx_queue_mapping; 649 }; 650 struct bpf_tcp_sock { 651 __u32 snd_cwnd; 652 __u32 srtt_us; 653 __u32 rtt_min; 654 __u32 snd_ssthresh; 655 __u32 rcv_nxt; 656 __u32 snd_nxt; 657 __u32 snd_una; 658 __u32 mss_cache; 659 __u32 ecn_flags; 660 __u32 rate_delivered; 661 __u32 rate_interval_us; 662 __u32 packets_out; 663 __u32 retrans_out; 664 __u32 total_retrans; 665 __u32 segs_in; 666 __u32 data_segs_in; 667 __u32 segs_out; 668 __u32 data_segs_out; 669 __u32 lost_out; 670 __u32 sacked_out; 671 __u64 bytes_received; 672 __u64 bytes_acked; 673 __u32 dsack_dups; 674 __u32 delivered; 675 __u32 delivered_ce; 676 __u32 icsk_retransmits; 677 }; 678 struct bpf_sock_tuple { 679 union { 680 struct { 681 __be32 saddr; 682 __be32 daddr; 683 __be16 sport; 684 __be16 dport; 685 } ipv4; 686 struct { 687 __be32 saddr[4]; 688 __be32 daddr[4]; 689 __be16 sport; 690 __be16 dport; 691 } ipv6; 692 }; 693 }; 694 struct bpf_xdp_sock { 695 __u32 queue_id; 696 }; 697 #define XDP_PACKET_HEADROOM 256 698 enum xdp_action { 699 XDP_ABORTED = 0, 700 XDP_DROP, 701 XDP_PASS, 702 XDP_TX, 703 XDP_REDIRECT, 704 }; 705 struct xdp_md { 706 __u32 data; 707 __u32 data_end; 708 __u32 data_meta; 709 __u32 ingress_ifindex; 710 __u32 rx_queue_index; 711 __u32 egress_ifindex; 712 }; 713 struct bpf_devmap_val { 714 __u32 ifindex; 715 union { 716 int fd; 717 __u32 id; 718 } bpf_prog; 719 }; 720 struct bpf_cpumap_val { 721 __u32 qsize; 722 union { 723 int fd; 724 __u32 id; 725 } bpf_prog; 726 }; 727 enum sk_action { 728 SK_DROP = 0, 729 SK_PASS, 730 }; 731 struct sk_msg_md { 732 __bpf_md_ptr(void *, data); 733 __bpf_md_ptr(void *, data_end); 734 __u32 family; 735 __u32 remote_ip4; 736 __u32 local_ip4; 737 __u32 remote_ip6[4]; 738 __u32 local_ip6[4]; 739 __u32 remote_port; 740 __u32 local_port; 741 __u32 size; 742 __bpf_md_ptr(struct bpf_sock *, sk); 743 }; 744 struct sk_reuseport_md { 745 __bpf_md_ptr(void *, data); 746 __bpf_md_ptr(void *, data_end); 747 __u32 len; 748 __u32 eth_protocol; 749 __u32 ip_protocol; 750 __u32 bind_inany; 751 __u32 hash; 752 }; 753 #define BPF_TAG_SIZE 8 754 struct bpf_prog_info { 755 __u32 type; 756 __u32 id; 757 __u8 tag[BPF_TAG_SIZE]; 758 __u32 jited_prog_len; 759 __u32 xlated_prog_len; 760 __aligned_u64 jited_prog_insns; 761 __aligned_u64 xlated_prog_insns; 762 __u64 load_time; 763 __u32 created_by_uid; 764 __u32 nr_map_ids; 765 __aligned_u64 map_ids; 766 char name[BPF_OBJ_NAME_LEN]; 767 __u32 ifindex; 768 __u32 gpl_compatible : 1; 769 __u32 : 31; 770 __u64 netns_dev; 771 __u64 netns_ino; 772 __u32 nr_jited_ksyms; 773 __u32 nr_jited_func_lens; 774 __aligned_u64 jited_ksyms; 775 __aligned_u64 jited_func_lens; 776 __u32 btf_id; 777 __u32 func_info_rec_size; 778 __aligned_u64 func_info; 779 __u32 nr_func_info; 780 __u32 nr_line_info; 781 __aligned_u64 line_info; 782 __aligned_u64 jited_line_info; 783 __u32 nr_jited_line_info; 784 __u32 line_info_rec_size; 785 __u32 jited_line_info_rec_size; 786 __u32 nr_prog_tags; 787 __aligned_u64 prog_tags; 788 __u64 run_time_ns; 789 __u64 run_cnt; 790 __u64 recursion_misses; 791 } __attribute__((aligned(8))); 792 struct bpf_map_info { 793 __u32 type; 794 __u32 id; 795 __u32 key_size; 796 __u32 value_size; 797 __u32 max_entries; 798 __u32 map_flags; 799 char name[BPF_OBJ_NAME_LEN]; 800 __u32 ifindex; 801 __u32 btf_vmlinux_value_type_id; 802 __u64 netns_dev; 803 __u64 netns_ino; 804 __u32 btf_id; 805 __u32 btf_key_type_id; 806 __u32 btf_value_type_id; 807 } __attribute__((aligned(8))); 808 struct bpf_btf_info { 809 __aligned_u64 btf; 810 __u32 btf_size; 811 __u32 id; 812 __aligned_u64 name; 813 __u32 name_len; 814 __u32 kernel_btf; 815 } __attribute__((aligned(8))); 816 struct bpf_link_info { 817 __u32 type; 818 __u32 id; 819 __u32 prog_id; 820 union { 821 struct { 822 __aligned_u64 tp_name; 823 __u32 tp_name_len; 824 } raw_tracepoint; 825 struct { 826 __u32 attach_type; 827 } tracing; 828 struct { 829 __u64 cgroup_id; 830 __u32 attach_type; 831 } cgroup; 832 struct { 833 __aligned_u64 target_name; 834 __u32 target_name_len; 835 union { 836 struct { 837 __u32 map_id; 838 } map; 839 }; 840 } iter; 841 struct { 842 __u32 netns_ino; 843 __u32 attach_type; 844 } netns; 845 struct { 846 __u32 ifindex; 847 } xdp; 848 }; 849 } __attribute__((aligned(8))); 850 struct bpf_sock_addr { 851 __u32 user_family; 852 __u32 user_ip4; 853 __u32 user_ip6[4]; 854 __u32 user_port; 855 __u32 family; 856 __u32 type; 857 __u32 protocol; 858 __u32 msg_src_ip4; 859 __u32 msg_src_ip6[4]; 860 __bpf_md_ptr(struct bpf_sock *, sk); 861 }; 862 struct bpf_sock_ops { 863 __u32 op; 864 union { 865 __u32 args[4]; 866 __u32 reply; 867 __u32 replylong[4]; 868 }; 869 __u32 family; 870 __u32 remote_ip4; 871 __u32 local_ip4; 872 __u32 remote_ip6[4]; 873 __u32 local_ip6[4]; 874 __u32 remote_port; 875 __u32 local_port; 876 __u32 is_fullsock; 877 __u32 snd_cwnd; 878 __u32 srtt_us; 879 __u32 bpf_sock_ops_cb_flags; 880 __u32 state; 881 __u32 rtt_min; 882 __u32 snd_ssthresh; 883 __u32 rcv_nxt; 884 __u32 snd_nxt; 885 __u32 snd_una; 886 __u32 mss_cache; 887 __u32 ecn_flags; 888 __u32 rate_delivered; 889 __u32 rate_interval_us; 890 __u32 packets_out; 891 __u32 retrans_out; 892 __u32 total_retrans; 893 __u32 segs_in; 894 __u32 data_segs_in; 895 __u32 segs_out; 896 __u32 data_segs_out; 897 __u32 lost_out; 898 __u32 sacked_out; 899 __u32 sk_txhash; 900 __u64 bytes_received; 901 __u64 bytes_acked; 902 __bpf_md_ptr(struct bpf_sock *, sk); 903 __bpf_md_ptr(void *, skb_data); 904 __bpf_md_ptr(void *, skb_data_end); 905 __u32 skb_len; 906 __u32 skb_tcp_flags; 907 }; 908 enum { 909 BPF_SOCK_OPS_RTO_CB_FLAG = (1 << 0), 910 BPF_SOCK_OPS_RETRANS_CB_FLAG = (1 << 1), 911 BPF_SOCK_OPS_STATE_CB_FLAG = (1 << 2), 912 BPF_SOCK_OPS_RTT_CB_FLAG = (1 << 3), 913 BPF_SOCK_OPS_PARSE_ALL_HDR_OPT_CB_FLAG = (1 << 4), 914 BPF_SOCK_OPS_PARSE_UNKNOWN_HDR_OPT_CB_FLAG = (1 << 5), 915 BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG = (1 << 6), 916 BPF_SOCK_OPS_ALL_CB_FLAGS = 0x7F, 917 }; 918 enum { 919 BPF_SOCK_OPS_VOID, 920 BPF_SOCK_OPS_TIMEOUT_INIT, 921 BPF_SOCK_OPS_RWND_INIT, 922 BPF_SOCK_OPS_TCP_CONNECT_CB, 923 BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB, 924 BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB, 925 BPF_SOCK_OPS_NEEDS_ECN, 926 BPF_SOCK_OPS_BASE_RTT, 927 BPF_SOCK_OPS_RTO_CB, 928 BPF_SOCK_OPS_RETRANS_CB, 929 BPF_SOCK_OPS_STATE_CB, 930 BPF_SOCK_OPS_TCP_LISTEN_CB, 931 BPF_SOCK_OPS_RTT_CB, 932 BPF_SOCK_OPS_PARSE_HDR_OPT_CB, 933 BPF_SOCK_OPS_HDR_OPT_LEN_CB, 934 BPF_SOCK_OPS_WRITE_HDR_OPT_CB, 935 }; 936 enum { 937 BPF_TCP_ESTABLISHED = 1, 938 BPF_TCP_SYN_SENT, 939 BPF_TCP_SYN_RECV, 940 BPF_TCP_FIN_WAIT1, 941 BPF_TCP_FIN_WAIT2, 942 BPF_TCP_TIME_WAIT, 943 BPF_TCP_CLOSE, 944 BPF_TCP_CLOSE_WAIT, 945 BPF_TCP_LAST_ACK, 946 BPF_TCP_LISTEN, 947 BPF_TCP_CLOSING, 948 BPF_TCP_NEW_SYN_RECV, 949 BPF_TCP_MAX_STATES 950 }; 951 enum { 952 TCP_BPF_IW = 1001, 953 TCP_BPF_SNDCWND_CLAMP = 1002, 954 TCP_BPF_DELACK_MAX = 1003, 955 TCP_BPF_RTO_MIN = 1004, 956 TCP_BPF_SYN = 1005, 957 TCP_BPF_SYN_IP = 1006, 958 TCP_BPF_SYN_MAC = 1007, 959 }; 960 enum { 961 BPF_LOAD_HDR_OPT_TCP_SYN = (1ULL << 0), 962 }; 963 enum { 964 BPF_WRITE_HDR_TCP_CURRENT_MSS = 1, 965 BPF_WRITE_HDR_TCP_SYNACK_COOKIE = 2, 966 }; 967 struct bpf_perf_event_value { 968 __u64 counter; 969 __u64 enabled; 970 __u64 running; 971 }; 972 enum { 973 BPF_DEVCG_ACC_MKNOD = (1ULL << 0), 974 BPF_DEVCG_ACC_READ = (1ULL << 1), 975 BPF_DEVCG_ACC_WRITE = (1ULL << 2), 976 }; 977 enum { 978 BPF_DEVCG_DEV_BLOCK = (1ULL << 0), 979 BPF_DEVCG_DEV_CHAR = (1ULL << 1), 980 }; 981 struct bpf_cgroup_dev_ctx { 982 __u32 access_type; 983 __u32 major; 984 __u32 minor; 985 }; 986 struct bpf_raw_tracepoint_args { 987 __u64 args[0]; 988 }; 989 enum { 990 BPF_FIB_LOOKUP_DIRECT = (1U << 0), 991 BPF_FIB_LOOKUP_OUTPUT = (1U << 1), 992 }; 993 enum { 994 BPF_FIB_LKUP_RET_SUCCESS, 995 BPF_FIB_LKUP_RET_BLACKHOLE, 996 BPF_FIB_LKUP_RET_UNREACHABLE, 997 BPF_FIB_LKUP_RET_PROHIBIT, 998 BPF_FIB_LKUP_RET_NOT_FWDED, 999 BPF_FIB_LKUP_RET_FWD_DISABLED, 1000 BPF_FIB_LKUP_RET_UNSUPP_LWT, 1001 BPF_FIB_LKUP_RET_NO_NEIGH, 1002 BPF_FIB_LKUP_RET_FRAG_NEEDED, 1003 }; 1004 struct bpf_fib_lookup { 1005 __u8 family; 1006 __u8 l4_protocol; 1007 __be16 sport; 1008 __be16 dport; 1009 union { 1010 __u16 tot_len; 1011 __u16 mtu_result; 1012 }; 1013 __u32 ifindex; 1014 union { 1015 __u8 tos; 1016 __be32 flowinfo; 1017 __u32 rt_metric; 1018 }; 1019 union { 1020 __be32 ipv4_src; 1021 __u32 ipv6_src[4]; 1022 }; 1023 union { 1024 __be32 ipv4_dst; 1025 __u32 ipv6_dst[4]; 1026 }; 1027 __be16 h_vlan_proto; 1028 __be16 h_vlan_TCI; 1029 __u8 smac[6]; 1030 __u8 dmac[6]; 1031 }; 1032 struct bpf_redir_neigh { 1033 __u32 nh_family; 1034 union { 1035 __be32 ipv4_nh; 1036 __u32 ipv6_nh[4]; 1037 }; 1038 }; 1039 enum bpf_check_mtu_flags { 1040 BPF_MTU_CHK_SEGS = (1U << 0), 1041 }; 1042 enum bpf_check_mtu_ret { 1043 BPF_MTU_CHK_RET_SUCCESS, 1044 BPF_MTU_CHK_RET_FRAG_NEEDED, 1045 BPF_MTU_CHK_RET_SEGS_TOOBIG, 1046 }; 1047 enum bpf_task_fd_type { 1048 BPF_FD_TYPE_RAW_TRACEPOINT, 1049 BPF_FD_TYPE_TRACEPOINT, 1050 BPF_FD_TYPE_KPROBE, 1051 BPF_FD_TYPE_KRETPROBE, 1052 BPF_FD_TYPE_UPROBE, 1053 BPF_FD_TYPE_URETPROBE, 1054 }; 1055 enum { 1056 BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG = (1U << 0), 1057 BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL = (1U << 1), 1058 BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP = (1U << 2), 1059 }; 1060 struct bpf_flow_keys { 1061 __u16 nhoff; 1062 __u16 thoff; 1063 __u16 addr_proto; 1064 __u8 is_frag; 1065 __u8 is_first_frag; 1066 __u8 is_encap; 1067 __u8 ip_proto; 1068 __be16 n_proto; 1069 __be16 sport; 1070 __be16 dport; 1071 union { 1072 struct { 1073 __be32 ipv4_src; 1074 __be32 ipv4_dst; 1075 }; 1076 struct { 1077 __u32 ipv6_src[4]; 1078 __u32 ipv6_dst[4]; 1079 }; 1080 }; 1081 __u32 flags; 1082 __be32 flow_label; 1083 }; 1084 struct bpf_func_info { 1085 __u32 insn_off; 1086 __u32 type_id; 1087 }; 1088 #define BPF_LINE_INFO_LINE_NUM(line_col) ((line_col) >> 10) 1089 #define BPF_LINE_INFO_LINE_COL(line_col) ((line_col) & 0x3ff) 1090 struct bpf_line_info { 1091 __u32 insn_off; 1092 __u32 file_name_off; 1093 __u32 line_off; 1094 __u32 line_col; 1095 }; 1096 struct bpf_spin_lock { 1097 __u32 val; 1098 }; 1099 struct bpf_sysctl { 1100 __u32 write; 1101 __u32 file_pos; 1102 }; 1103 struct bpf_sockopt { 1104 __bpf_md_ptr(struct bpf_sock *, sk); 1105 __bpf_md_ptr(void *, optval); 1106 __bpf_md_ptr(void *, optval_end); 1107 __s32 level; 1108 __s32 optname; 1109 __s32 optlen; 1110 __s32 retval; 1111 }; 1112 struct bpf_pidns_info { 1113 __u32 pid; 1114 __u32 tgid; 1115 }; 1116 struct bpf_sk_lookup { 1117 __bpf_md_ptr(struct bpf_sock *, sk); 1118 __u32 family; 1119 __u32 protocol; 1120 __u32 remote_ip4; 1121 __u32 remote_ip6[4]; 1122 __u32 remote_port; 1123 __u32 local_ip4; 1124 __u32 local_ip6[4]; 1125 __u32 local_port; 1126 }; 1127 struct btf_ptr { 1128 void * ptr; 1129 __u32 type_id; 1130 __u32 flags; 1131 }; 1132 enum { 1133 BTF_F_COMPACT = (1ULL << 0), 1134 BTF_F_NONAME = (1ULL << 1), 1135 BTF_F_PTR_RAW = (1ULL << 2), 1136 BTF_F_ZERO = (1ULL << 3), 1137 }; 1138 #endif 1139