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"
39 struct BPF_MAP_CREATE_struct {
45 uint32_t inner_map_fd;
47 char map_name[BPF_OBJ_NAME_LEN];
51 #define BPF_MAP_CREATE_struct_size \
52 sizeof(struct BPF_MAP_CREATE_struct)
53 #define expected_BPF_MAP_CREATE_struct_size 48
55 struct BPF_MAP_LOOKUP_ELEM_struct {
57 uint64_t ATTRIBUTE_ALIGNED(8) key;
58 uint64_t ATTRIBUTE_ALIGNED(8) value;
61 #define BPF_MAP_LOOKUP_ELEM_struct_size \
62 sizeof(struct BPF_MAP_LOOKUP_ELEM_struct)
63 #define expected_BPF_MAP_LOOKUP_ELEM_struct_size 24
65 struct BPF_MAP_UPDATE_ELEM_struct {
67 uint64_t ATTRIBUTE_ALIGNED(8) key;
68 uint64_t ATTRIBUTE_ALIGNED(8) value;
72 #define BPF_MAP_UPDATE_ELEM_struct_size \
73 sizeof(struct BPF_MAP_UPDATE_ELEM_struct)
74 #define expected_BPF_MAP_UPDATE_ELEM_struct_size 32
76 struct BPF_MAP_DELETE_ELEM_struct {
78 uint64_t ATTRIBUTE_ALIGNED(8) key;
81 #define BPF_MAP_DELETE_ELEM_struct_size \
82 sizeof(struct BPF_MAP_DELETE_ELEM_struct)
83 #define expected_BPF_MAP_DELETE_ELEM_struct_size 16
85 struct BPF_MAP_GET_NEXT_KEY_struct {
87 uint64_t ATTRIBUTE_ALIGNED(8) key;
88 uint64_t ATTRIBUTE_ALIGNED(8) next_key;
91 #define BPF_MAP_GET_NEXT_KEY_struct_size \
92 sizeof(struct BPF_MAP_GET_NEXT_KEY_struct)
93 #define expected_BPF_MAP_GET_NEXT_KEY_struct_size 24
95 struct BPF_PROG_LOAD_struct {
98 uint64_t ATTRIBUTE_ALIGNED(8) insns;
99 uint64_t ATTRIBUTE_ALIGNED(8) license;
102 uint64_t ATTRIBUTE_ALIGNED(8) log_buf;
103 uint32_t kern_version;
105 char prog_name[BPF_OBJ_NAME_LEN];
106 uint32_t prog_ifindex;
107 uint32_t expected_attach_type;
110 #define BPF_PROG_LOAD_struct_size \
111 offsetofend(struct BPF_PROG_LOAD_struct, expected_attach_type)
112 #define expected_BPF_PROG_LOAD_struct_size 72
114 struct BPF_OBJ_PIN_struct {
115 uint64_t ATTRIBUTE_ALIGNED(8) pathname;
120 #define BPF_OBJ_PIN_struct_size \
121 sizeof(struct BPF_OBJ_PIN_struct)
122 #define expected_BPF_OBJ_PIN_struct_size 16
124 #define BPF_OBJ_GET_struct BPF_OBJ_PIN_struct
125 #define BPF_OBJ_GET_struct_size BPF_OBJ_PIN_struct_size
127 struct BPF_PROG_ATTACH_struct {
129 uint32_t attach_bpf_fd;
130 uint32_t attach_type;
131 uint32_t attach_flags;
134 #define BPF_PROG_ATTACH_struct_size \
135 sizeof(struct BPF_PROG_ATTACH_struct)
136 #define expected_BPF_PROG_ATTACH_struct_size 16
138 struct BPF_PROG_DETACH_struct {
141 uint32_t attach_type;
144 #define BPF_PROG_DETACH_struct_size \
145 sizeof(struct BPF_PROG_DETACH_struct)
146 #define expected_BPF_PROG_DETACH_struct_size 12
148 struct BPF_PROG_TEST_RUN_struct /* test */ {
151 uint32_t data_size_in;
152 uint32_t data_size_out;
153 uint64_t ATTRIBUTE_ALIGNED(8) data_in;
154 uint64_t ATTRIBUTE_ALIGNED(8) data_out;
159 #define BPF_PROG_TEST_RUN_struct_size \
160 sizeof(struct BPF_PROG_TEST_RUN_struct)
161 #define expected_BPF_PROG_TEST_RUN_struct_size 40
163 struct BPF_PROG_GET_NEXT_ID_struct {
169 #define BPF_PROG_GET_NEXT_ID_struct_size \
170 sizeof(struct BPF_PROG_GET_NEXT_ID_struct)
171 #define expected_BPF_PROG_GET_NEXT_ID_struct_size 12
173 #define BPF_MAP_GET_NEXT_ID_struct BPF_PROG_GET_NEXT_ID_struct
174 #define BPF_MAP_GET_NEXT_ID_struct_size BPF_PROG_GET_NEXT_ID_struct_size
176 struct BPF_PROG_GET_FD_BY_ID_struct {
182 #define BPF_PROG_GET_FD_BY_ID_struct_size \
183 sizeof(struct BPF_PROG_GET_FD_BY_ID_struct)
184 #define expected_BPF_PROG_GET_FD_BY_ID_struct_size 12
186 struct BPF_MAP_GET_FD_BY_ID_struct {
192 #define BPF_MAP_GET_FD_BY_ID_struct_size \
193 sizeof(struct BPF_MAP_GET_FD_BY_ID_struct)
194 #define expected_BPF_MAP_GET_FD_BY_ID_struct_size 12
196 struct BPF_OBJ_GET_INFO_BY_FD_struct /* info */ {
199 uint64_t ATTRIBUTE_ALIGNED(8) info;
202 #define BPF_OBJ_GET_INFO_BY_FD_struct_size \
203 sizeof(struct BPF_OBJ_GET_INFO_BY_FD_struct)
204 #define expected_BPF_OBJ_GET_INFO_BY_FD_struct_size 16
206 struct BPF_PROG_QUERY_struct /* query */ {
208 uint32_t attach_type;
209 uint32_t query_flags;
210 uint32_t attach_flags;
211 uint64_t ATTRIBUTE_ALIGNED(8) prog_ids;
215 #define BPF_PROG_QUERY_struct_size \
216 offsetofend(struct BPF_PROG_QUERY_struct, prog_cnt)
217 #define expected_BPF_PROG_QUERY_struct_size 28
219 struct BPF_RAW_TRACEPOINT_OPEN_struct /* raw_tracepoint */ {
220 uint64_t ATTRIBUTE_ALIGNED(8) name;
224 #define BPF_RAW_TRACEPOINT_OPEN_struct_size \
225 offsetofend(struct BPF_RAW_TRACEPOINT_OPEN_struct, prog_fd)
226 #define expected_BPF_RAW_TRACEPOINT_OPEN_struct_size 12
228 #endif /* !STRACE_BPF_ATTR_H */