2 * Copyright (c) 2015-2018 Dmitry V. Levin <ldv@altlinux.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef STRACE_BPF_ATTR_H
29 #define STRACE_BPF_ATTR_H
31 #ifndef BPF_OBJ_NAME_LEN
32 # define BPF_OBJ_NAME_LEN 16U
34 # if BPF_OBJ_NAME_LEN != 16U
35 # error "Unexpected value of BPF_OBJ_NAME_LEN"
40 # define BPF_TAG_SIZE 8
42 # if BPF_TAG_SIZE != 8
43 # error "Unexpected value of BPF_TAG_SIZE"
47 struct BPF_MAP_CREATE_struct {
53 uint32_t inner_map_fd;
55 char map_name[BPF_OBJ_NAME_LEN];
59 #define BPF_MAP_CREATE_struct_size \
60 sizeof(struct BPF_MAP_CREATE_struct)
61 #define expected_BPF_MAP_CREATE_struct_size 48
63 struct BPF_MAP_LOOKUP_ELEM_struct {
65 uint64_t ATTRIBUTE_ALIGNED(8) key;
66 uint64_t ATTRIBUTE_ALIGNED(8) value;
69 #define BPF_MAP_LOOKUP_ELEM_struct_size \
70 sizeof(struct BPF_MAP_LOOKUP_ELEM_struct)
71 #define expected_BPF_MAP_LOOKUP_ELEM_struct_size 24
73 struct BPF_MAP_UPDATE_ELEM_struct {
75 uint64_t ATTRIBUTE_ALIGNED(8) key;
76 uint64_t ATTRIBUTE_ALIGNED(8) value;
80 #define BPF_MAP_UPDATE_ELEM_struct_size \
81 sizeof(struct BPF_MAP_UPDATE_ELEM_struct)
82 #define expected_BPF_MAP_UPDATE_ELEM_struct_size 32
84 struct BPF_MAP_DELETE_ELEM_struct {
86 uint64_t ATTRIBUTE_ALIGNED(8) key;
89 #define BPF_MAP_DELETE_ELEM_struct_size \
90 sizeof(struct BPF_MAP_DELETE_ELEM_struct)
91 #define expected_BPF_MAP_DELETE_ELEM_struct_size 16
93 struct BPF_MAP_GET_NEXT_KEY_struct {
95 uint64_t ATTRIBUTE_ALIGNED(8) key;
96 uint64_t ATTRIBUTE_ALIGNED(8) next_key;
99 #define BPF_MAP_GET_NEXT_KEY_struct_size \
100 sizeof(struct BPF_MAP_GET_NEXT_KEY_struct)
101 #define expected_BPF_MAP_GET_NEXT_KEY_struct_size 24
103 struct BPF_PROG_LOAD_struct {
106 uint64_t ATTRIBUTE_ALIGNED(8) insns;
107 uint64_t ATTRIBUTE_ALIGNED(8) license;
110 uint64_t ATTRIBUTE_ALIGNED(8) log_buf;
111 uint32_t kern_version;
113 char prog_name[BPF_OBJ_NAME_LEN];
114 uint32_t prog_ifindex;
115 uint32_t expected_attach_type;
118 #define BPF_PROG_LOAD_struct_size \
119 offsetofend(struct BPF_PROG_LOAD_struct, expected_attach_type)
120 #define expected_BPF_PROG_LOAD_struct_size 72
122 struct BPF_OBJ_PIN_struct {
123 uint64_t ATTRIBUTE_ALIGNED(8) pathname;
128 #define BPF_OBJ_PIN_struct_size \
129 sizeof(struct BPF_OBJ_PIN_struct)
130 #define expected_BPF_OBJ_PIN_struct_size 16
132 #define BPF_OBJ_GET_struct BPF_OBJ_PIN_struct
133 #define BPF_OBJ_GET_struct_size BPF_OBJ_PIN_struct_size
135 struct BPF_PROG_ATTACH_struct {
137 uint32_t attach_bpf_fd;
138 uint32_t attach_type;
139 uint32_t attach_flags;
142 #define BPF_PROG_ATTACH_struct_size \
143 sizeof(struct BPF_PROG_ATTACH_struct)
144 #define expected_BPF_PROG_ATTACH_struct_size 16
146 struct BPF_PROG_DETACH_struct {
149 uint32_t attach_type;
152 #define BPF_PROG_DETACH_struct_size \
153 sizeof(struct BPF_PROG_DETACH_struct)
154 #define expected_BPF_PROG_DETACH_struct_size 12
156 struct BPF_PROG_TEST_RUN_struct /* test */ {
159 uint32_t data_size_in;
160 uint32_t data_size_out;
161 uint64_t ATTRIBUTE_ALIGNED(8) data_in;
162 uint64_t ATTRIBUTE_ALIGNED(8) data_out;
167 #define BPF_PROG_TEST_RUN_struct_size \
168 sizeof(struct BPF_PROG_TEST_RUN_struct)
169 #define expected_BPF_PROG_TEST_RUN_struct_size 40
171 struct BPF_PROG_GET_NEXT_ID_struct {
177 #define BPF_PROG_GET_NEXT_ID_struct_size \
178 sizeof(struct BPF_PROG_GET_NEXT_ID_struct)
179 #define expected_BPF_PROG_GET_NEXT_ID_struct_size 12
181 #define BPF_MAP_GET_NEXT_ID_struct BPF_PROG_GET_NEXT_ID_struct
182 #define BPF_MAP_GET_NEXT_ID_struct_size BPF_PROG_GET_NEXT_ID_struct_size
184 struct BPF_PROG_GET_FD_BY_ID_struct {
190 #define BPF_PROG_GET_FD_BY_ID_struct_size \
191 sizeof(struct BPF_PROG_GET_FD_BY_ID_struct)
192 #define expected_BPF_PROG_GET_FD_BY_ID_struct_size 12
194 struct BPF_MAP_GET_FD_BY_ID_struct {
200 #define BPF_MAP_GET_FD_BY_ID_struct_size \
201 sizeof(struct BPF_MAP_GET_FD_BY_ID_struct)
202 #define expected_BPF_MAP_GET_FD_BY_ID_struct_size 12
204 struct BPF_OBJ_GET_INFO_BY_FD_struct /* info */ {
207 uint64_t ATTRIBUTE_ALIGNED(8) info;
210 #define BPF_OBJ_GET_INFO_BY_FD_struct_size \
211 sizeof(struct BPF_OBJ_GET_INFO_BY_FD_struct)
212 #define expected_BPF_OBJ_GET_INFO_BY_FD_struct_size 16
214 struct BPF_PROG_QUERY_struct /* query */ {
216 uint32_t attach_type;
217 uint32_t query_flags;
218 uint32_t attach_flags;
219 uint64_t ATTRIBUTE_ALIGNED(8) prog_ids;
223 #define BPF_PROG_QUERY_struct_size \
224 offsetofend(struct BPF_PROG_QUERY_struct, prog_cnt)
225 #define expected_BPF_PROG_QUERY_struct_size 28
227 struct BPF_RAW_TRACEPOINT_OPEN_struct /* raw_tracepoint */ {
228 uint64_t ATTRIBUTE_ALIGNED(8) name;
232 #define BPF_RAW_TRACEPOINT_OPEN_struct_size \
233 offsetofend(struct BPF_RAW_TRACEPOINT_OPEN_struct, prog_fd)
234 #define expected_BPF_RAW_TRACEPOINT_OPEN_struct_size 12
236 struct bpf_map_info_struct {
241 uint32_t max_entries;
243 char name[BPF_OBJ_NAME_LEN];
245 uint64_t ATTRIBUTE_ALIGNED(8) netns_dev; /* kernel UAPI is buggy, skip check */
246 uint64_t ATTRIBUTE_ALIGNED(8) netns_ino; /* kernel UAPI is buggy, skip check */
249 #define bpf_map_info_struct_size \
250 sizeof(struct bpf_map_info_struct)
251 #define expected_bpf_map_info_struct_size 64
253 struct bpf_prog_info_struct {
256 uint8_t tag[BPF_TAG_SIZE];
257 uint32_t jited_prog_len;
258 uint32_t xlated_prog_len;
259 uint64_t ATTRIBUTE_ALIGNED(8) jited_prog_insns;
260 uint64_t ATTRIBUTE_ALIGNED(8) xlated_prog_insns;
262 uint32_t created_by_uid;
264 uint64_t ATTRIBUTE_ALIGNED(8) map_ids;
265 char name[BPF_OBJ_NAME_LEN];
267 uint64_t ATTRIBUTE_ALIGNED(8) netns_dev; /* kernel UAPI is buggy, skip check */
268 uint64_t ATTRIBUTE_ALIGNED(8) netns_ino; /* kernel UAPI is buggy, skip check */
271 #define bpf_prog_info_struct_size \
272 sizeof(struct bpf_prog_info_struct)
273 #define expected_bpf_prog_info_struct_size 104
275 #endif /* !STRACE_BPF_ATTR_H */