182d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris/**************************************************************************** 282d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris **************************************************************************** 382d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris *** 482d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris *** This header was automatically generated from a Linux kernel header 582d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris *** of the same name, to make information necessary for userspace to 682d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris *** call into the kernel available to libc. It contains only constants, 782d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris *** structures, and macros generated from the original header, and thus, 882d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris *** contains no copyrightable information. 982d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris *** 1082d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris *** To edit the content of this header, modify the corresponding 1182d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris *** source file (e.g. under external/kernel-headers/original/) then 1282d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris *** run bionic/libc/kernel/tools/update_all.py 1382d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris *** 1482d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris *** Any manual change here will be lost the next time this script will 1582d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris *** be run. You've been warned! 1682d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris *** 1782d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris **************************************************************************** 1882d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris ****************************************************************************/ 1982d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#ifndef _UAPI__LINUX_BPF_H__ 2082d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#define _UAPI__LINUX_BPF_H__ 2182d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#include <linux/types.h> 2282d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#include <linux/bpf_common.h> 2382d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#define BPF_ALU64 0x07 2482d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#define BPF_DW 0x18 2582d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#define BPF_XADD 0xc0 2682d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#define BPF_MOV 0xb0 2782d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#define BPF_ARSH 0xc0 2882d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#define BPF_END 0xd0 2982d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#define BPF_TO_LE 0x00 3082d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#define BPF_TO_BE 0x08 3182d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#define BPF_FROM_LE BPF_TO_LE 3282d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#define BPF_FROM_BE BPF_TO_BE 3382d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#define BPF_JNE 0x50 341308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris#define BPF_JLT 0xa0 351308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris#define BPF_JLE 0xb0 3682d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#define BPF_JSGT 0x60 3782d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#define BPF_JSGE 0x70 381308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris#define BPF_JSLT 0xc0 391308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris#define BPF_JSLE 0xd0 4082d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#define BPF_CALL 0x80 4182d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#define BPF_EXIT 0x90 4282d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferrisenum { 43d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao BPF_REG_0 = 0, 44d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao BPF_REG_1, 45d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao BPF_REG_2, 46d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao BPF_REG_3, 47d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao BPF_REG_4, 48d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao BPF_REG_5, 49d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao BPF_REG_6, 50d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao BPF_REG_7, 51d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao BPF_REG_8, 52d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao BPF_REG_9, 53d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao BPF_REG_10, 54d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao __MAX_BPF_REG, 5582d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris}; 5682d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#define MAX_BPF_REG __MAX_BPF_REG 5782d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferrisstruct bpf_insn { 58d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao __u8 code; 59d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao __u8 dst_reg : 4; 60d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao __u8 src_reg : 4; 61d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao __s16 off; 62d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao __s32 imm; 6382d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris}; 64525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferrisstruct bpf_lpm_trie_key { 65525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris __u32 prefixlen; 66525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris __u8 data[0]; 67525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris}; 6882d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferrisenum bpf_cmd { 69d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao BPF_MAP_CREATE, 70d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao BPF_MAP_LOOKUP_ELEM, 71d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao BPF_MAP_UPDATE_ELEM, 72d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao BPF_MAP_DELETE_ELEM, 73d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao BPF_MAP_GET_NEXT_KEY, 74d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao BPF_PROG_LOAD, 7505d08e9716b5974d6ed08973f44930804890b902Christopher Ferris BPF_OBJ_PIN, 7605d08e9716b5974d6ed08973f44930804890b902Christopher Ferris BPF_OBJ_GET, 7748af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris BPF_PROG_ATTACH, 7848af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris BPF_PROG_DETACH, 79525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris BPF_PROG_TEST_RUN, 801308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris BPF_PROG_GET_NEXT_ID, 811308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris BPF_MAP_GET_NEXT_ID, 821308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris BPF_PROG_GET_FD_BY_ID, 831308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris BPF_MAP_GET_FD_BY_ID, 841308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris BPF_OBJ_GET_INFO_BY_FD, 85934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris BPF_PROG_QUERY, 8682d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris}; 8782d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferrisenum bpf_map_type { 88d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao BPF_MAP_TYPE_UNSPEC, 8905d08e9716b5974d6ed08973f44930804890b902Christopher Ferris BPF_MAP_TYPE_HASH, 9005d08e9716b5974d6ed08973f44930804890b902Christopher Ferris BPF_MAP_TYPE_ARRAY, 9105d08e9716b5974d6ed08973f44930804890b902Christopher Ferris BPF_MAP_TYPE_PROG_ARRAY, 9205d08e9716b5974d6ed08973f44930804890b902Christopher Ferris BPF_MAP_TYPE_PERF_EVENT_ARRAY, 93106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris BPF_MAP_TYPE_PERCPU_HASH, 94106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris BPF_MAP_TYPE_PERCPU_ARRAY, 95106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris BPF_MAP_TYPE_STACK_TRACE, 9649f525c47bd383cd6a87db8f067cddb3ab620d17Christopher Ferris BPF_MAP_TYPE_CGROUP_ARRAY, 9748af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris BPF_MAP_TYPE_LRU_HASH, 9848af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris BPF_MAP_TYPE_LRU_PERCPU_HASH, 99525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris BPF_MAP_TYPE_LPM_TRIE, 100525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris BPF_MAP_TYPE_ARRAY_OF_MAPS, 101525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris BPF_MAP_TYPE_HASH_OF_MAPS, 1021308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris BPF_MAP_TYPE_DEVMAP, 1031308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris BPF_MAP_TYPE_SOCKMAP, 104934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris BPF_MAP_TYPE_CPUMAP, 10505d08e9716b5974d6ed08973f44930804890b902Christopher Ferris}; 10682d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferrisenum bpf_prog_type { 107d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao BPF_PROG_TYPE_UNSPEC, 10849f525c47bd383cd6a87db8f067cddb3ab620d17Christopher Ferris BPF_PROG_TYPE_SOCKET_FILTER, 10905d08e9716b5974d6ed08973f44930804890b902Christopher Ferris BPF_PROG_TYPE_KPROBE, 11005d08e9716b5974d6ed08973f44930804890b902Christopher Ferris BPF_PROG_TYPE_SCHED_CLS, 11105d08e9716b5974d6ed08973f44930804890b902Christopher Ferris BPF_PROG_TYPE_SCHED_ACT, 11249f525c47bd383cd6a87db8f067cddb3ab620d17Christopher Ferris BPF_PROG_TYPE_TRACEPOINT, 11349f525c47bd383cd6a87db8f067cddb3ab620d17Christopher Ferris BPF_PROG_TYPE_XDP, 1146a9755d20a995756487bb1aafb7e954f4fd868a7Christopher Ferris BPF_PROG_TYPE_PERF_EVENT, 11548af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris BPF_PROG_TYPE_CGROUP_SKB, 11648af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris BPF_PROG_TYPE_CGROUP_SOCK, 11748af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris BPF_PROG_TYPE_LWT_IN, 11848af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris BPF_PROG_TYPE_LWT_OUT, 11948af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris BPF_PROG_TYPE_LWT_XMIT, 1201308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris BPF_PROG_TYPE_SOCK_OPS, 1211308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris BPF_PROG_TYPE_SK_SKB, 122934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris BPF_PROG_TYPE_CGROUP_DEVICE, 12382d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris}; 12448af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferrisenum bpf_attach_type { 12548af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris BPF_CGROUP_INET_INGRESS, 12648af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris BPF_CGROUP_INET_EGRESS, 12748af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris BPF_CGROUP_INET_SOCK_CREATE, 1281308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris BPF_CGROUP_SOCK_OPS, 1291308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris BPF_SK_SKB_STREAM_PARSER, 1301308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris BPF_SK_SKB_STREAM_VERDICT, 131934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris BPF_CGROUP_DEVICE, 13248af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris __MAX_BPF_ATTACH_TYPE 13348af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris}; 13448af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE 13548af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris#define BPF_F_ALLOW_OVERRIDE (1U << 0) 136934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris#define BPF_F_ALLOW_MULTI (1U << 1) 137525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris#define BPF_F_STRICT_ALIGNMENT (1U << 0) 1386a9755d20a995756487bb1aafb7e954f4fd868a7Christopher Ferris#define BPF_PSEUDO_MAP_FD 1 13905d08e9716b5974d6ed08973f44930804890b902Christopher Ferris#define BPF_ANY 0 14005d08e9716b5974d6ed08973f44930804890b902Christopher Ferris#define BPF_NOEXIST 1 14148af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris#define BPF_EXIST 2 1426a9755d20a995756487bb1aafb7e954f4fd868a7Christopher Ferris#define BPF_F_NO_PREALLOC (1U << 0) 14348af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris#define BPF_F_NO_COMMON_LRU (1U << 1) 1441308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris#define BPF_F_NUMA_NODE (1U << 2) 145934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris#define BPF_F_QUERY_EFFECTIVE (1U << 0) 146934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris#define BPF_OBJ_NAME_LEN 16U 147934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris#define BPF_F_RDONLY (1U << 3) 148934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris#define BPF_F_WRONLY (1U << 4) 14905d08e9716b5974d6ed08973f44930804890b902Christopher Ferrisunion bpf_attr { 150d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao struct { 151106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris __u32 map_type; 1526a9755d20a995756487bb1aafb7e954f4fd868a7Christopher Ferris __u32 key_size; 153d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao __u32 value_size; 154d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao __u32 max_entries; 155106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris __u32 map_flags; 156525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris __u32 inner_map_fd; 1571308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 numa_node; 158934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris char map_name[BPF_OBJ_NAME_LEN]; 1596a9755d20a995756487bb1aafb7e954f4fd868a7Christopher Ferris }; 160d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao struct { 161d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao __u32 map_fd; 162d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao __aligned_u64 key; 1636a9755d20a995756487bb1aafb7e954f4fd868a7Christopher Ferris union { 164d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao __aligned_u64 value; 165d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao __aligned_u64 next_key; 166d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao }; 1676a9755d20a995756487bb1aafb7e954f4fd868a7Christopher Ferris __u64 flags; 168d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao }; 169d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao struct { 170d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao __u32 prog_type; 1716a9755d20a995756487bb1aafb7e954f4fd868a7Christopher Ferris __u32 insn_cnt; 172d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao __aligned_u64 insns; 173d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao __aligned_u64 license; 174d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao __u32 log_level; 1756a9755d20a995756487bb1aafb7e954f4fd868a7Christopher Ferris __u32 log_size; 176d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao __aligned_u64 log_buf; 17705d08e9716b5974d6ed08973f44930804890b902Christopher Ferris __u32 kern_version; 178525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris __u32 prog_flags; 179934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris char prog_name[BPF_OBJ_NAME_LEN]; 180934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __u32 prog_ifindex; 18105d08e9716b5974d6ed08973f44930804890b902Christopher Ferris }; 1826a9755d20a995756487bb1aafb7e954f4fd868a7Christopher Ferris struct { 18305d08e9716b5974d6ed08973f44930804890b902Christopher Ferris __aligned_u64 pathname; 18405d08e9716b5974d6ed08973f44930804890b902Christopher Ferris __u32 bpf_fd; 185934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __u32 file_flags; 186d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao }; 18748af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris struct { 18848af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris __u32 target_fd; 18948af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris __u32 attach_bpf_fd; 19048af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris __u32 attach_type; 19148af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris __u32 attach_flags; 19248af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris }; 193525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris struct { 194525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris __u32 prog_fd; 195525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris __u32 retval; 196525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris __u32 data_size_in; 197525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris __u32 data_size_out; 198525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris __aligned_u64 data_in; 199525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris __aligned_u64 data_out; 200525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris __u32 repeat; 201525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris __u32 duration; 202525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris } test; 2031308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris struct { 2041308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris union { 2051308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 start_id; 2061308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 prog_id; 2071308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 map_id; 2081308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris }; 2091308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 next_id; 210934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __u32 open_flags; 2111308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris }; 2121308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris struct { 2131308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 bpf_fd; 2141308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 info_len; 2151308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __aligned_u64 info; 2161308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris } info; 217934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris struct { 218934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __u32 target_fd; 219934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __u32 attach_type; 220934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __u32 query_flags; 221934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __u32 attach_flags; 222934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __aligned_u64 prog_ids; 223934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __u32 prog_cnt; 224934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris } query; 2256a9755d20a995756487bb1aafb7e954f4fd868a7Christopher Ferris} __attribute__((aligned(8))); 226934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris#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), 22748af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris#define __BPF_ENUM_FN(x) BPF_FUNC_ ##x 22882d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferrisenum bpf_func_id { 22948af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris __BPF_FUNC_MAPPER(__BPF_ENUM_FN) __BPF_FUNC_MAX_ID, 23005d08e9716b5974d6ed08973f44930804890b902Christopher Ferris}; 23148af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris#undef __BPF_ENUM_FN 232106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris#define BPF_F_RECOMPUTE_CSUM (1ULL << 0) 23348af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris#define BPF_F_INVALIDATE_HASH (1ULL << 1) 234106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris#define BPF_F_HDR_FIELD_MASK 0xfULL 235106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris#define BPF_F_PSEUDO_HDR (1ULL << 4) 236106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris#define BPF_F_MARK_MANGLED_0 (1ULL << 5) 237525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris#define BPF_F_MARK_ENFORCE (1ULL << 6) 23848af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris#define BPF_F_INGRESS (1ULL << 0) 239106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris#define BPF_F_TUNINFO_IPV6 (1ULL << 0) 240106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris#define BPF_F_SKIP_FIELD_MASK 0xffULL 241106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris#define BPF_F_USER_STACK (1ULL << 8) 24248af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris#define BPF_F_FAST_STACK_CMP (1ULL << 9) 243106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris#define BPF_F_REUSE_STACKID (1ULL << 10) 244106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris#define BPF_F_ZERO_CSUM_TX (1ULL << 1) 245106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris#define BPF_F_DONT_FRAGMENT (1ULL << 2) 24648af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris#define BPF_F_INDEX_MASK 0xffffffffULL 247106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris#define BPF_F_CURRENT_CPU BPF_F_INDEX_MASK 24849f525c47bd383cd6a87db8f067cddb3ab620d17Christopher Ferris#define BPF_F_CTXLEN_MASK (0xfffffULL << 32) 2491308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferrisenum bpf_adj_room_mode { 2501308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris BPF_ADJ_ROOM_NET, 2511308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris}; 25249f525c47bd383cd6a87db8f067cddb3ab620d17Christopher Ferrisstruct __sk_buff { 25348af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris __u32 len; 25405d08e9716b5974d6ed08973f44930804890b902Christopher Ferris __u32 pkt_type; 25505d08e9716b5974d6ed08973f44930804890b902Christopher Ferris __u32 mark; 25649f525c47bd383cd6a87db8f067cddb3ab620d17Christopher Ferris __u32 queue_mapping; 25748af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris __u32 protocol; 25805d08e9716b5974d6ed08973f44930804890b902Christopher Ferris __u32 vlan_present; 25905d08e9716b5974d6ed08973f44930804890b902Christopher Ferris __u32 vlan_tci; 26049f525c47bd383cd6a87db8f067cddb3ab620d17Christopher Ferris __u32 vlan_proto; 26148af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris __u32 priority; 26205d08e9716b5974d6ed08973f44930804890b902Christopher Ferris __u32 ingress_ifindex; 26305d08e9716b5974d6ed08973f44930804890b902Christopher Ferris __u32 ifindex; 26449f525c47bd383cd6a87db8f067cddb3ab620d17Christopher Ferris __u32 tc_index; 26548af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris __u32 cb[5]; 26605d08e9716b5974d6ed08973f44930804890b902Christopher Ferris __u32 hash; 26705d08e9716b5974d6ed08973f44930804890b902Christopher Ferris __u32 tc_classid; 26849f525c47bd383cd6a87db8f067cddb3ab620d17Christopher Ferris __u32 data; 26948af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris __u32 data_end; 270525ce914edf136d2bd02ac8c404d56c52e737f4dChristopher Ferris __u32 napi_id; 2711308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 family; 2721308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 remote_ip4; 2731308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 local_ip4; 2741308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 remote_ip6[4]; 2751308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 local_ip6[4]; 2761308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 remote_port; 2771308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 local_port; 278934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __u32 data_meta; 27982d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris}; 28005d08e9716b5974d6ed08973f44930804890b902Christopher Ferrisstruct bpf_tunnel_key { 28149f525c47bd383cd6a87db8f067cddb3ab620d17Christopher Ferris __u32 tunnel_id; 28248af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris union { 283106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris __u32 remote_ipv4; 284106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris __u32 remote_ipv6[4]; 28549f525c47bd383cd6a87db8f067cddb3ab620d17Christopher Ferris }; 28648af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris __u8 tunnel_tos; 287106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris __u8 tunnel_ttl; 288106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris __u16 tunnel_ext; 289106b3a8a7dc03c19a45e322de425ac56aafac358Christopher Ferris __u32 tunnel_label; 29048af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris}; 29148af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferrisenum bpf_ret_code { 29248af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris BPF_OK = 0, 29348af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris BPF_DROP = 2, 29448af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris BPF_REDIRECT = 7, 29549f525c47bd383cd6a87db8f067cddb3ab620d17Christopher Ferris}; 29648af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferrisstruct bpf_sock { 29748af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris __u32 bound_dev_if; 29848af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris __u32 family; 29948af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris __u32 type; 30048af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris __u32 protocol; 3011308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 mark; 3021308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 priority; 30348af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris}; 30448af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris#define XDP_PACKET_HEADROOM 256 30549f525c47bd383cd6a87db8f067cddb3ab620d17Christopher Ferrisenum xdp_action { 30649f525c47bd383cd6a87db8f067cddb3ab620d17Christopher Ferris XDP_ABORTED = 0, 30749f525c47bd383cd6a87db8f067cddb3ab620d17Christopher Ferris XDP_DROP, 30848af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris XDP_PASS, 30949f525c47bd383cd6a87db8f067cddb3ab620d17Christopher Ferris XDP_TX, 3101308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris XDP_REDIRECT, 31105d08e9716b5974d6ed08973f44930804890b902Christopher Ferris}; 31249f525c47bd383cd6a87db8f067cddb3ab620d17Christopher Ferrisstruct xdp_md { 31348af7cb2e205dcc2f09a1a1b8a1a37c93e1943f0Christopher Ferris __u32 data; 31449f525c47bd383cd6a87db8f067cddb3ab620d17Christopher Ferris __u32 data_end; 315934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __u32 data_meta; 31649f525c47bd383cd6a87db8f067cddb3ab620d17Christopher Ferris}; 3171308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferrisenum sk_action { 3181308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris SK_DROP = 0, 3191308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris SK_PASS, 3201308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris}; 3211308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris#define BPF_TAG_SIZE 8 3221308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferrisstruct bpf_prog_info { 3231308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 type; 3241308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 id; 3251308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u8 tag[BPF_TAG_SIZE]; 3261308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 jited_prog_len; 3271308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 xlated_prog_len; 3281308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __aligned_u64 jited_prog_insns; 3291308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __aligned_u64 xlated_prog_insns; 330934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __u64 load_time; 331934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __u32 created_by_uid; 332934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __u32 nr_map_ids; 333934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __aligned_u64 map_ids; 334934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris char name[BPF_OBJ_NAME_LEN]; 3351308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris} __attribute__((aligned(8))); 3361308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferrisstruct bpf_map_info { 3371308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 type; 3381308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 id; 3391308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 key_size; 3401308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 value_size; 3411308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 max_entries; 3421308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 map_flags; 343934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris char name[BPF_OBJ_NAME_LEN]; 3441308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris} __attribute__((aligned(8))); 3451308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferrisstruct bpf_sock_ops { 3461308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 op; 3471308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris union { 3481308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 reply; 3491308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 replylong[4]; 3501308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris }; 3511308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 family; 3521308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 remote_ip4; 3531308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 local_ip4; 3541308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 remote_ip6[4]; 3551308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 local_ip6[4]; 3561308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 remote_port; 3571308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris __u32 local_port; 3581308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris}; 3591308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferrisenum { 3601308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris BPF_SOCK_OPS_VOID, 3611308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris BPF_SOCK_OPS_TIMEOUT_INIT, 3621308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris BPF_SOCK_OPS_RWND_INIT, 3631308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris BPF_SOCK_OPS_TCP_CONNECT_CB, 3641308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB, 3651308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB, 3661308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris BPF_SOCK_OPS_NEEDS_ECN, 367934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris BPF_SOCK_OPS_BASE_RTT, 3681308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris}; 3691308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris#define TCP_BPF_IW 1001 3701308ad3ab33294c3abfd96da12b6df58b381ce52Christopher Ferris#define TCP_BPF_SNDCWND_CLAMP 1002 371934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferrisstruct bpf_perf_event_value { 372934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __u64 counter; 373934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __u64 enabled; 374934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __u64 running; 375934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris}; 376934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris#define BPF_DEVCG_ACC_MKNOD (1ULL << 0) 377934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris#define BPF_DEVCG_ACC_READ (1ULL << 1) 378934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris#define BPF_DEVCG_ACC_WRITE (1ULL << 2) 379934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris#define BPF_DEVCG_DEV_BLOCK (1ULL << 0) 380934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris#define BPF_DEVCG_DEV_CHAR (1ULL << 1) 381934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferrisstruct bpf_cgroup_dev_ctx { 382934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __u32 access_type; 383934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __u32 major; 384934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris __u32 minor; 385934ec9495505d234b2c2fa284470c2f44aae9de9Christopher Ferris}; 38682d7504cd7d5c8d2175fb3b1a4ee3518cad6aa0fChristopher Ferris#endif 387