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;
109 #define BPF_PROG_LOAD_struct_size \
110 offsetofend(struct BPF_PROG_LOAD_struct, prog_ifindex)
111 #define expected_BPF_PROG_LOAD_struct_size 68
113 struct BPF_OBJ_PIN_struct {
114 uint64_t ATTRIBUTE_ALIGNED(8) pathname;
119 #define BPF_OBJ_PIN_struct_size \
120 sizeof(struct BPF_OBJ_PIN_struct)
121 #define expected_BPF_OBJ_PIN_struct_size 16
123 #define BPF_OBJ_GET_struct BPF_OBJ_PIN_struct
124 #define BPF_OBJ_GET_struct_size BPF_OBJ_PIN_struct_size
126 struct BPF_PROG_ATTACH_struct {
128 uint32_t attach_bpf_fd;
129 uint32_t attach_type;
130 uint32_t attach_flags;
133 #define BPF_PROG_ATTACH_struct_size \
134 sizeof(struct BPF_PROG_ATTACH_struct)
135 #define expected_BPF_PROG_ATTACH_struct_size 16
137 struct BPF_PROG_DETACH_struct {
140 uint32_t attach_type;
143 #define BPF_PROG_DETACH_struct_size \
144 sizeof(struct BPF_PROG_DETACH_struct)
145 #define expected_BPF_PROG_DETACH_struct_size 12
147 struct BPF_PROG_TEST_RUN_struct /* test */ {
150 uint32_t data_size_in;
151 uint32_t data_size_out;
152 uint64_t ATTRIBUTE_ALIGNED(8) data_in;
153 uint64_t ATTRIBUTE_ALIGNED(8) data_out;
158 #define BPF_PROG_TEST_RUN_struct_size \
159 sizeof(struct BPF_PROG_TEST_RUN_struct)
160 #define expected_BPF_PROG_TEST_RUN_struct_size 40
162 struct BPF_PROG_GET_NEXT_ID_struct {
168 #define BPF_PROG_GET_NEXT_ID_struct_size \
169 sizeof(struct BPF_PROG_GET_NEXT_ID_struct)
170 #define expected_BPF_PROG_GET_NEXT_ID_struct_size 12
172 #define BPF_MAP_GET_NEXT_ID_struct BPF_PROG_GET_NEXT_ID_struct
173 #define BPF_MAP_GET_NEXT_ID_struct_size BPF_PROG_GET_NEXT_ID_struct_size
175 struct BPF_PROG_GET_FD_BY_ID_struct {
181 #define BPF_PROG_GET_FD_BY_ID_struct_size \
182 sizeof(struct BPF_PROG_GET_FD_BY_ID_struct)
183 #define expected_BPF_PROG_GET_FD_BY_ID_struct_size 12
185 struct BPF_MAP_GET_FD_BY_ID_struct {
191 #define BPF_MAP_GET_FD_BY_ID_struct_size \
192 sizeof(struct BPF_MAP_GET_FD_BY_ID_struct)
193 #define expected_BPF_MAP_GET_FD_BY_ID_struct_size 12
195 struct BPF_OBJ_GET_INFO_BY_FD_struct /* info */ {
198 uint64_t ATTRIBUTE_ALIGNED(8) info;
201 #define BPF_OBJ_GET_INFO_BY_FD_struct_size \
202 sizeof(struct BPF_OBJ_GET_INFO_BY_FD_struct)
203 #define expected_BPF_OBJ_GET_INFO_BY_FD_struct_size 16
205 struct BPF_PROG_QUERY_struct /* query */ {
207 uint32_t attach_type;
208 uint32_t query_flags;
209 uint32_t attach_flags;
210 uint64_t ATTRIBUTE_ALIGNED(8) prog_ids;
214 #define BPF_PROG_QUERY_struct_size \
215 offsetofend(struct BPF_PROG_QUERY_struct, prog_cnt)
216 #define expected_BPF_PROG_QUERY_struct_size 28
218 #endif /* !STRACE_BPF_ATTR_H */