blob: 0eb0d4547289c2dac50ecbf23997f00d58bdd923 [file] [log] [blame]
Christopher Ferris82d75042015-01-26 10:57:07 -08001/****************************************************************************
2 ****************************************************************************
3 ***
4 *** This header was automatically generated from a Linux kernel header
5 *** of the same name, to make information necessary for userspace to
6 *** call into the kernel available to libc. It contains only constants,
7 *** structures, and macros generated from the original header, and thus,
8 *** contains no copyrightable information.
9 ***
10 *** To edit the content of this header, modify the corresponding
11 *** source file (e.g. under external/kernel-headers/original/) then
12 *** run bionic/libc/kernel/tools/update_all.py
13 ***
14 *** Any manual change here will be lost the next time this script will
15 *** be run. You've been warned!
16 ***
17 ****************************************************************************
18 ****************************************************************************/
19#ifndef _UAPI__LINUX_BPF_H__
20#define _UAPI__LINUX_BPF_H__
21#include <linux/types.h>
22#include <linux/bpf_common.h>
Christopher Ferris82d75042015-01-26 10:57:07 -080023#define BPF_ALU64 0x07
24#define BPF_DW 0x18
25#define BPF_XADD 0xc0
26#define BPF_MOV 0xb0
Christopher Ferris82d75042015-01-26 10:57:07 -080027#define BPF_ARSH 0xc0
28#define BPF_END 0xd0
29#define BPF_TO_LE 0x00
30#define BPF_TO_BE 0x08
Christopher Ferris82d75042015-01-26 10:57:07 -080031#define BPF_FROM_LE BPF_TO_LE
32#define BPF_FROM_BE BPF_TO_BE
33#define BPF_JNE 0x50
Christopher Ferris1308ad32017-11-14 17:32:13 -080034#define BPF_JLT 0xa0
35#define BPF_JLE 0xb0
Christopher Ferris82d75042015-01-26 10:57:07 -080036#define BPF_JSGT 0x60
Christopher Ferris82d75042015-01-26 10:57:07 -080037#define BPF_JSGE 0x70
Christopher Ferris1308ad32017-11-14 17:32:13 -080038#define BPF_JSLT 0xc0
39#define BPF_JSLE 0xd0
Christopher Ferris82d75042015-01-26 10:57:07 -080040#define BPF_CALL 0x80
41#define BPF_EXIT 0x90
42enum {
Tao Baod7db5942015-01-28 10:07:51 -080043 BPF_REG_0 = 0,
44 BPF_REG_1,
45 BPF_REG_2,
46 BPF_REG_3,
Tao Baod7db5942015-01-28 10:07:51 -080047 BPF_REG_4,
48 BPF_REG_5,
49 BPF_REG_6,
50 BPF_REG_7,
Tao Baod7db5942015-01-28 10:07:51 -080051 BPF_REG_8,
52 BPF_REG_9,
53 BPF_REG_10,
54 __MAX_BPF_REG,
Christopher Ferris82d75042015-01-26 10:57:07 -080055};
56#define MAX_BPF_REG __MAX_BPF_REG
57struct bpf_insn {
Tao Baod7db5942015-01-28 10:07:51 -080058 __u8 code;
Tao Baod7db5942015-01-28 10:07:51 -080059 __u8 dst_reg : 4;
60 __u8 src_reg : 4;
61 __s16 off;
62 __s32 imm;
Christopher Ferris82d75042015-01-26 10:57:07 -080063};
Christopher Ferris525ce912017-07-26 13:12:53 -070064struct bpf_lpm_trie_key {
65 __u32 prefixlen;
66 __u8 data[0];
67};
Christopher Ferris82d75042015-01-26 10:57:07 -080068enum bpf_cmd {
Tao Baod7db5942015-01-28 10:07:51 -080069 BPF_MAP_CREATE,
70 BPF_MAP_LOOKUP_ELEM,
Tao Baod7db5942015-01-28 10:07:51 -080071 BPF_MAP_UPDATE_ELEM,
72 BPF_MAP_DELETE_ELEM,
73 BPF_MAP_GET_NEXT_KEY,
74 BPF_PROG_LOAD,
Christopher Ferris05d08e92016-02-04 13:16:38 -080075 BPF_OBJ_PIN,
76 BPF_OBJ_GET,
Christopher Ferris48af7cb2017-02-21 12:35:09 -080077 BPF_PROG_ATTACH,
78 BPF_PROG_DETACH,
Christopher Ferris525ce912017-07-26 13:12:53 -070079 BPF_PROG_TEST_RUN,
Christopher Ferris1308ad32017-11-14 17:32:13 -080080 BPF_PROG_GET_NEXT_ID,
81 BPF_MAP_GET_NEXT_ID,
82 BPF_PROG_GET_FD_BY_ID,
83 BPF_MAP_GET_FD_BY_ID,
84 BPF_OBJ_GET_INFO_BY_FD,
Christopher Ferris934ec942018-01-31 15:29:16 -080085 BPF_PROG_QUERY,
Christopher Ferris76a1d452018-06-27 14:12:29 -070086 BPF_RAW_TRACEPOINT_OPEN,
Christopher Ferris82d75042015-01-26 10:57:07 -080087};
88enum bpf_map_type {
Christopher Ferris05d08e92016-02-04 13:16:38 -080089 BPF_MAP_TYPE_UNSPEC,
90 BPF_MAP_TYPE_HASH,
91 BPF_MAP_TYPE_ARRAY,
92 BPF_MAP_TYPE_PROG_ARRAY,
Christopher Ferris05d08e92016-02-04 13:16:38 -080093 BPF_MAP_TYPE_PERF_EVENT_ARRAY,
Christopher Ferris106b3a82016-08-24 12:15:38 -070094 BPF_MAP_TYPE_PERCPU_HASH,
95 BPF_MAP_TYPE_PERCPU_ARRAY,
96 BPF_MAP_TYPE_STACK_TRACE,
Christopher Ferris49f525c2016-12-12 14:55:36 -080097 BPF_MAP_TYPE_CGROUP_ARRAY,
Christopher Ferris48af7cb2017-02-21 12:35:09 -080098 BPF_MAP_TYPE_LRU_HASH,
Christopher Ferris48af7cb2017-02-21 12:35:09 -080099 BPF_MAP_TYPE_LRU_PERCPU_HASH,
Christopher Ferris525ce912017-07-26 13:12:53 -0700100 BPF_MAP_TYPE_LPM_TRIE,
101 BPF_MAP_TYPE_ARRAY_OF_MAPS,
102 BPF_MAP_TYPE_HASH_OF_MAPS,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800103 BPF_MAP_TYPE_DEVMAP,
104 BPF_MAP_TYPE_SOCKMAP,
Christopher Ferris934ec942018-01-31 15:29:16 -0800105 BPF_MAP_TYPE_CPUMAP,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800106};
Christopher Ferris82d75042015-01-26 10:57:07 -0800107enum bpf_prog_type {
Tao Baod7db5942015-01-28 10:07:51 -0800108 BPF_PROG_TYPE_UNSPEC,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800109 BPF_PROG_TYPE_SOCKET_FILTER,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800110 BPF_PROG_TYPE_KPROBE,
111 BPF_PROG_TYPE_SCHED_CLS,
112 BPF_PROG_TYPE_SCHED_ACT,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800113 BPF_PROG_TYPE_TRACEPOINT,
114 BPF_PROG_TYPE_XDP,
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800115 BPF_PROG_TYPE_PERF_EVENT,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800116 BPF_PROG_TYPE_CGROUP_SKB,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800117 BPF_PROG_TYPE_CGROUP_SOCK,
118 BPF_PROG_TYPE_LWT_IN,
119 BPF_PROG_TYPE_LWT_OUT,
120 BPF_PROG_TYPE_LWT_XMIT,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800121 BPF_PROG_TYPE_SOCK_OPS,
122 BPF_PROG_TYPE_SK_SKB,
Christopher Ferris934ec942018-01-31 15:29:16 -0800123 BPF_PROG_TYPE_CGROUP_DEVICE,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700124 BPF_PROG_TYPE_SK_MSG,
125 BPF_PROG_TYPE_RAW_TRACEPOINT,
126 BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800127};
128enum bpf_attach_type {
129 BPF_CGROUP_INET_INGRESS,
130 BPF_CGROUP_INET_EGRESS,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800131 BPF_CGROUP_INET_SOCK_CREATE,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800132 BPF_CGROUP_SOCK_OPS,
133 BPF_SK_SKB_STREAM_PARSER,
134 BPF_SK_SKB_STREAM_VERDICT,
Christopher Ferris934ec942018-01-31 15:29:16 -0800135 BPF_CGROUP_DEVICE,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700136 BPF_SK_MSG_VERDICT,
137 BPF_CGROUP_INET4_BIND,
138 BPF_CGROUP_INET6_BIND,
139 BPF_CGROUP_INET4_CONNECT,
140 BPF_CGROUP_INET6_CONNECT,
141 BPF_CGROUP_INET4_POST_BIND,
142 BPF_CGROUP_INET6_POST_BIND,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800143 __MAX_BPF_ATTACH_TYPE
144};
145#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800146#define BPF_F_ALLOW_OVERRIDE (1U << 0)
Christopher Ferris934ec942018-01-31 15:29:16 -0800147#define BPF_F_ALLOW_MULTI (1U << 1)
Christopher Ferris525ce912017-07-26 13:12:53 -0700148#define BPF_F_STRICT_ALIGNMENT (1U << 0)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800149#define BPF_PSEUDO_MAP_FD 1
Christopher Ferris76a1d452018-06-27 14:12:29 -0700150#define BPF_PSEUDO_CALL 1
Christopher Ferris05d08e92016-02-04 13:16:38 -0800151#define BPF_ANY 0
152#define BPF_NOEXIST 1
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800153#define BPF_EXIST 2
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800154#define BPF_F_NO_PREALLOC (1U << 0)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800155#define BPF_F_NO_COMMON_LRU (1U << 1)
Christopher Ferris1308ad32017-11-14 17:32:13 -0800156#define BPF_F_NUMA_NODE (1U << 2)
Christopher Ferris934ec942018-01-31 15:29:16 -0800157#define BPF_F_QUERY_EFFECTIVE (1U << 0)
158#define BPF_OBJ_NAME_LEN 16U
159#define BPF_F_RDONLY (1U << 3)
160#define BPF_F_WRONLY (1U << 4)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700161#define BPF_F_STACK_BUILD_ID (1U << 5)
162enum bpf_stack_build_id_status {
163 BPF_STACK_BUILD_ID_EMPTY = 0,
164 BPF_STACK_BUILD_ID_VALID = 1,
165 BPF_STACK_BUILD_ID_IP = 2,
166};
167#define BPF_BUILD_ID_SIZE 20
168struct bpf_stack_build_id {
169 __s32 status;
170 unsigned char build_id[BPF_BUILD_ID_SIZE];
171 union {
172 __u64 offset;
173 __u64 ip;
174 };
175};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800176union bpf_attr {
Tao Baod7db5942015-01-28 10:07:51 -0800177 struct {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700178 __u32 map_type;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800179 __u32 key_size;
Tao Baod7db5942015-01-28 10:07:51 -0800180 __u32 value_size;
Tao Baod7db5942015-01-28 10:07:51 -0800181 __u32 max_entries;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700182 __u32 map_flags;
Christopher Ferris525ce912017-07-26 13:12:53 -0700183 __u32 inner_map_fd;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800184 __u32 numa_node;
Christopher Ferris934ec942018-01-31 15:29:16 -0800185 char map_name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700186 __u32 map_ifindex;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800187 };
Tao Baod7db5942015-01-28 10:07:51 -0800188 struct {
189 __u32 map_fd;
Tao Baod7db5942015-01-28 10:07:51 -0800190 __aligned_u64 key;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800191 union {
Tao Baod7db5942015-01-28 10:07:51 -0800192 __aligned_u64 value;
193 __aligned_u64 next_key;
Tao Baod7db5942015-01-28 10:07:51 -0800194 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800195 __u64 flags;
Tao Baod7db5942015-01-28 10:07:51 -0800196 };
197 struct {
198 __u32 prog_type;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800199 __u32 insn_cnt;
Tao Baod7db5942015-01-28 10:07:51 -0800200 __aligned_u64 insns;
201 __aligned_u64 license;
202 __u32 log_level;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800203 __u32 log_size;
Tao Baod7db5942015-01-28 10:07:51 -0800204 __aligned_u64 log_buf;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800205 __u32 kern_version;
Christopher Ferris525ce912017-07-26 13:12:53 -0700206 __u32 prog_flags;
Christopher Ferris934ec942018-01-31 15:29:16 -0800207 char prog_name[BPF_OBJ_NAME_LEN];
208 __u32 prog_ifindex;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700209 __u32 expected_attach_type;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800210 };
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800211 struct {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800212 __aligned_u64 pathname;
213 __u32 bpf_fd;
Christopher Ferris934ec942018-01-31 15:29:16 -0800214 __u32 file_flags;
Tao Baod7db5942015-01-28 10:07:51 -0800215 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800216 struct {
217 __u32 target_fd;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800218 __u32 attach_bpf_fd;
219 __u32 attach_type;
220 __u32 attach_flags;
221 };
Christopher Ferris525ce912017-07-26 13:12:53 -0700222 struct {
223 __u32 prog_fd;
224 __u32 retval;
225 __u32 data_size_in;
226 __u32 data_size_out;
227 __aligned_u64 data_in;
228 __aligned_u64 data_out;
229 __u32 repeat;
230 __u32 duration;
231 } test;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800232 struct {
233 union {
234 __u32 start_id;
235 __u32 prog_id;
236 __u32 map_id;
237 };
238 __u32 next_id;
Christopher Ferris934ec942018-01-31 15:29:16 -0800239 __u32 open_flags;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800240 };
241 struct {
242 __u32 bpf_fd;
243 __u32 info_len;
244 __aligned_u64 info;
245 } info;
Christopher Ferris934ec942018-01-31 15:29:16 -0800246 struct {
247 __u32 target_fd;
248 __u32 attach_type;
249 __u32 query_flags;
250 __u32 attach_flags;
251 __aligned_u64 prog_ids;
252 __u32 prog_cnt;
253 } query;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700254 struct {
255 __u64 name;
256 __u32 prog_fd;
257 } raw_tracepoint;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800258} __attribute__((aligned(8)));
Christopher Ferris76a1d452018-06-27 14:12:29 -0700259#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),
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800260#define __BPF_ENUM_FN(x) BPF_FUNC_ ##x
Christopher Ferris82d75042015-01-26 10:57:07 -0800261enum bpf_func_id {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800262 __BPF_FUNC_MAPPER(__BPF_ENUM_FN) __BPF_FUNC_MAX_ID,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800263};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800264#undef __BPF_ENUM_FN
Christopher Ferris106b3a82016-08-24 12:15:38 -0700265#define BPF_F_RECOMPUTE_CSUM (1ULL << 0)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800266#define BPF_F_INVALIDATE_HASH (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700267#define BPF_F_HDR_FIELD_MASK 0xfULL
268#define BPF_F_PSEUDO_HDR (1ULL << 4)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700269#define BPF_F_MARK_MANGLED_0 (1ULL << 5)
Christopher Ferris525ce912017-07-26 13:12:53 -0700270#define BPF_F_MARK_ENFORCE (1ULL << 6)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800271#define BPF_F_INGRESS (1ULL << 0)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700272#define BPF_F_TUNINFO_IPV6 (1ULL << 0)
273#define BPF_F_SKIP_FIELD_MASK 0xffULL
Christopher Ferris106b3a82016-08-24 12:15:38 -0700274#define BPF_F_USER_STACK (1ULL << 8)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800275#define BPF_F_FAST_STACK_CMP (1ULL << 9)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700276#define BPF_F_REUSE_STACKID (1ULL << 10)
277#define BPF_F_ZERO_CSUM_TX (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700278#define BPF_F_DONT_FRAGMENT (1ULL << 2)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700279#define BPF_F_SEQ_NUMBER (1ULL << 3)
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800280#define BPF_F_INDEX_MASK 0xffffffffULL
Christopher Ferris106b3a82016-08-24 12:15:38 -0700281#define BPF_F_CURRENT_CPU BPF_F_INDEX_MASK
Christopher Ferris49f525c2016-12-12 14:55:36 -0800282#define BPF_F_CTXLEN_MASK (0xfffffULL << 32)
Christopher Ferris1308ad32017-11-14 17:32:13 -0800283enum bpf_adj_room_mode {
284 BPF_ADJ_ROOM_NET,
285};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800286struct __sk_buff {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800287 __u32 len;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800288 __u32 pkt_type;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800289 __u32 mark;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800290 __u32 queue_mapping;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800291 __u32 protocol;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800292 __u32 vlan_present;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800293 __u32 vlan_tci;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800294 __u32 vlan_proto;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800295 __u32 priority;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800296 __u32 ingress_ifindex;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800297 __u32 ifindex;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800298 __u32 tc_index;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800299 __u32 cb[5];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800300 __u32 hash;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800301 __u32 tc_classid;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800302 __u32 data;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800303 __u32 data_end;
Christopher Ferris525ce912017-07-26 13:12:53 -0700304 __u32 napi_id;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800305 __u32 family;
306 __u32 remote_ip4;
307 __u32 local_ip4;
308 __u32 remote_ip6[4];
309 __u32 local_ip6[4];
310 __u32 remote_port;
311 __u32 local_port;
Christopher Ferris934ec942018-01-31 15:29:16 -0800312 __u32 data_meta;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800313};
314struct bpf_tunnel_key {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800315 __u32 tunnel_id;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800316 union {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700317 __u32 remote_ipv4;
318 __u32 remote_ipv6[4];
Christopher Ferris49f525c2016-12-12 14:55:36 -0800319 };
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800320 __u8 tunnel_tos;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700321 __u8 tunnel_ttl;
322 __u16 tunnel_ext;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800323 __u32 tunnel_label;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800324};
325enum bpf_ret_code {
326 BPF_OK = 0,
327 BPF_DROP = 2,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800328 BPF_REDIRECT = 7,
329};
330struct bpf_sock {
331 __u32 bound_dev_if;
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800332 __u32 family;
333 __u32 type;
334 __u32 protocol;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800335 __u32 mark;
336 __u32 priority;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700337 __u32 src_ip4;
338 __u32 src_ip6[4];
339 __u32 src_port;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800340};
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800341#define XDP_PACKET_HEADROOM 256
Christopher Ferris49f525c2016-12-12 14:55:36 -0800342enum xdp_action {
343 XDP_ABORTED = 0,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800344 XDP_DROP,
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800345 XDP_PASS,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800346 XDP_TX,
Christopher Ferris1308ad32017-11-14 17:32:13 -0800347 XDP_REDIRECT,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800348};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800349struct xdp_md {
Christopher Ferris48af7cb2017-02-21 12:35:09 -0800350 __u32 data;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800351 __u32 data_end;
Christopher Ferris934ec942018-01-31 15:29:16 -0800352 __u32 data_meta;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700353 __u32 ingress_ifindex;
354 __u32 rx_queue_index;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800355};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800356enum sk_action {
357 SK_DROP = 0,
358 SK_PASS,
359};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700360struct sk_msg_md {
361 void * data;
362 void * data_end;
363};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800364#define BPF_TAG_SIZE 8
365struct bpf_prog_info {
366 __u32 type;
367 __u32 id;
368 __u8 tag[BPF_TAG_SIZE];
369 __u32 jited_prog_len;
370 __u32 xlated_prog_len;
371 __aligned_u64 jited_prog_insns;
372 __aligned_u64 xlated_prog_insns;
Christopher Ferris934ec942018-01-31 15:29:16 -0800373 __u64 load_time;
374 __u32 created_by_uid;
375 __u32 nr_map_ids;
376 __aligned_u64 map_ids;
377 char name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700378 __u32 ifindex;
379 __u32 : 32;
380 __u64 netns_dev;
381 __u64 netns_ino;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800382} __attribute__((aligned(8)));
383struct bpf_map_info {
384 __u32 type;
385 __u32 id;
386 __u32 key_size;
387 __u32 value_size;
388 __u32 max_entries;
389 __u32 map_flags;
Christopher Ferris934ec942018-01-31 15:29:16 -0800390 char name[BPF_OBJ_NAME_LEN];
Christopher Ferris76a1d452018-06-27 14:12:29 -0700391 __u32 ifindex;
392 __u32 : 32;
393 __u64 netns_dev;
394 __u64 netns_ino;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800395} __attribute__((aligned(8)));
Christopher Ferris76a1d452018-06-27 14:12:29 -0700396struct bpf_sock_addr {
397 __u32 user_family;
398 __u32 user_ip4;
399 __u32 user_ip6[4];
400 __u32 user_port;
401 __u32 family;
402 __u32 type;
403 __u32 protocol;
404};
Christopher Ferris1308ad32017-11-14 17:32:13 -0800405struct bpf_sock_ops {
406 __u32 op;
407 union {
Christopher Ferris76a1d452018-06-27 14:12:29 -0700408 __u32 args[4];
Christopher Ferris1308ad32017-11-14 17:32:13 -0800409 __u32 reply;
410 __u32 replylong[4];
411 };
412 __u32 family;
413 __u32 remote_ip4;
414 __u32 local_ip4;
415 __u32 remote_ip6[4];
416 __u32 local_ip6[4];
417 __u32 remote_port;
418 __u32 local_port;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700419 __u32 is_fullsock;
420 __u32 snd_cwnd;
421 __u32 srtt_us;
422 __u32 bpf_sock_ops_cb_flags;
423 __u32 state;
424 __u32 rtt_min;
425 __u32 snd_ssthresh;
426 __u32 rcv_nxt;
427 __u32 snd_nxt;
428 __u32 snd_una;
429 __u32 mss_cache;
430 __u32 ecn_flags;
431 __u32 rate_delivered;
432 __u32 rate_interval_us;
433 __u32 packets_out;
434 __u32 retrans_out;
435 __u32 total_retrans;
436 __u32 segs_in;
437 __u32 data_segs_in;
438 __u32 segs_out;
439 __u32 data_segs_out;
440 __u32 lost_out;
441 __u32 sacked_out;
442 __u32 sk_txhash;
443 __u64 bytes_received;
444 __u64 bytes_acked;
Christopher Ferris1308ad32017-11-14 17:32:13 -0800445};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700446#define BPF_SOCK_OPS_RTO_CB_FLAG (1 << 0)
447#define BPF_SOCK_OPS_RETRANS_CB_FLAG (1 << 1)
448#define BPF_SOCK_OPS_STATE_CB_FLAG (1 << 2)
449#define BPF_SOCK_OPS_ALL_CB_FLAGS 0x7
Christopher Ferris1308ad32017-11-14 17:32:13 -0800450enum {
451 BPF_SOCK_OPS_VOID,
452 BPF_SOCK_OPS_TIMEOUT_INIT,
453 BPF_SOCK_OPS_RWND_INIT,
454 BPF_SOCK_OPS_TCP_CONNECT_CB,
455 BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB,
456 BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB,
457 BPF_SOCK_OPS_NEEDS_ECN,
Christopher Ferris934ec942018-01-31 15:29:16 -0800458 BPF_SOCK_OPS_BASE_RTT,
Christopher Ferris76a1d452018-06-27 14:12:29 -0700459 BPF_SOCK_OPS_RTO_CB,
460 BPF_SOCK_OPS_RETRANS_CB,
461 BPF_SOCK_OPS_STATE_CB,
462};
463enum {
464 BPF_TCP_ESTABLISHED = 1,
465 BPF_TCP_SYN_SENT,
466 BPF_TCP_SYN_RECV,
467 BPF_TCP_FIN_WAIT1,
468 BPF_TCP_FIN_WAIT2,
469 BPF_TCP_TIME_WAIT,
470 BPF_TCP_CLOSE,
471 BPF_TCP_CLOSE_WAIT,
472 BPF_TCP_LAST_ACK,
473 BPF_TCP_LISTEN,
474 BPF_TCP_CLOSING,
475 BPF_TCP_NEW_SYN_RECV,
476 BPF_TCP_MAX_STATES
Christopher Ferris1308ad32017-11-14 17:32:13 -0800477};
478#define TCP_BPF_IW 1001
479#define TCP_BPF_SNDCWND_CLAMP 1002
Christopher Ferris934ec942018-01-31 15:29:16 -0800480struct bpf_perf_event_value {
481 __u64 counter;
482 __u64 enabled;
483 __u64 running;
484};
485#define BPF_DEVCG_ACC_MKNOD (1ULL << 0)
486#define BPF_DEVCG_ACC_READ (1ULL << 1)
487#define BPF_DEVCG_ACC_WRITE (1ULL << 2)
488#define BPF_DEVCG_DEV_BLOCK (1ULL << 0)
489#define BPF_DEVCG_DEV_CHAR (1ULL << 1)
490struct bpf_cgroup_dev_ctx {
491 __u32 access_type;
492 __u32 major;
493 __u32 minor;
494};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700495struct bpf_raw_tracepoint_args {
496 __u64 args[0];
497};
Christopher Ferris82d75042015-01-26 10:57:07 -0800498#endif