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;
49 #define BPF_MAP_CREATE_struct_size \
50 sizeof(struct BPF_MAP_CREATE_struct)
51 #define expected_BPF_MAP_CREATE_struct_size 28
53 struct BPF_MAP_LOOKUP_ELEM_struct {
55 uint64_t ATTRIBUTE_ALIGNED(8) key;
56 uint64_t ATTRIBUTE_ALIGNED(8) value;
59 #define BPF_MAP_LOOKUP_ELEM_struct_size \
60 sizeof(struct BPF_MAP_LOOKUP_ELEM_struct)
61 #define expected_BPF_MAP_LOOKUP_ELEM_struct_size 24
63 struct BPF_MAP_UPDATE_ELEM_struct {
65 uint64_t ATTRIBUTE_ALIGNED(8) key;
66 uint64_t ATTRIBUTE_ALIGNED(8) value;
70 #define BPF_MAP_UPDATE_ELEM_struct_size \
71 sizeof(struct BPF_MAP_UPDATE_ELEM_struct)
72 #define expected_BPF_MAP_UPDATE_ELEM_struct_size 32
74 struct BPF_MAP_DELETE_ELEM_struct {
76 uint64_t ATTRIBUTE_ALIGNED(8) key;
79 #define BPF_MAP_DELETE_ELEM_struct_size \
80 sizeof(struct BPF_MAP_DELETE_ELEM_struct)
81 #define expected_BPF_MAP_DELETE_ELEM_struct_size 16
83 struct BPF_MAP_GET_NEXT_KEY_struct {
85 uint64_t ATTRIBUTE_ALIGNED(8) key;
86 uint64_t ATTRIBUTE_ALIGNED(8) next_key;
89 #define BPF_MAP_GET_NEXT_KEY_struct_size \
90 sizeof(struct BPF_MAP_GET_NEXT_KEY_struct)
91 #define expected_BPF_MAP_GET_NEXT_KEY_struct_size 24
93 struct BPF_PROG_LOAD_struct {
96 uint64_t ATTRIBUTE_ALIGNED(8) insns;
97 uint64_t ATTRIBUTE_ALIGNED(8) license;
100 uint64_t ATTRIBUTE_ALIGNED(8) log_buf;
101 uint32_t kern_version;
103 char prog_name[BPF_OBJ_NAME_LEN];
104 uint32_t prog_ifindex;
107 #define BPF_PROG_LOAD_struct_size \
108 offsetofend(struct BPF_PROG_LOAD_struct, prog_ifindex)
109 #define expected_BPF_PROG_LOAD_struct_size 68
111 struct BPF_OBJ_PIN_struct {
112 uint64_t ATTRIBUTE_ALIGNED(8) pathname;
117 #define BPF_OBJ_PIN_struct_size \
118 sizeof(struct BPF_OBJ_PIN_struct)
119 #define expected_BPF_OBJ_PIN_struct_size 16
121 #define BPF_OBJ_GET_struct BPF_OBJ_PIN_struct
122 #define BPF_OBJ_GET_struct_size BPF_OBJ_PIN_struct_size
124 struct BPF_PROG_ATTACH_struct {
126 uint32_t attach_bpf_fd;
127 uint32_t attach_type;
128 uint32_t attach_flags;
131 #define BPF_PROG_ATTACH_struct_size \
132 sizeof(struct BPF_PROG_ATTACH_struct)
133 #define expected_BPF_PROG_ATTACH_struct_size 16
135 struct BPF_PROG_DETACH_struct {
138 uint32_t attach_type;
141 #define BPF_PROG_DETACH_struct_size \
142 sizeof(struct BPF_PROG_DETACH_struct)
143 #define expected_BPF_PROG_DETACH_struct_size 12
145 struct BPF_PROG_TEST_RUN_struct /* test */ {
148 uint32_t data_size_in;
149 uint32_t data_size_out;
150 uint64_t ATTRIBUTE_ALIGNED(8) data_in;
151 uint64_t ATTRIBUTE_ALIGNED(8) data_out;
156 #define BPF_PROG_TEST_RUN_struct_size \
157 sizeof(struct BPF_PROG_TEST_RUN_struct)
158 #define expected_BPF_PROG_TEST_RUN_struct_size 40
160 struct BPF_PROG_GET_NEXT_ID_struct {
166 #define BPF_PROG_GET_NEXT_ID_struct_size \
167 sizeof(struct BPF_PROG_GET_NEXT_ID_struct)
168 #define expected_BPF_PROG_GET_NEXT_ID_struct_size 12
170 #define BPF_MAP_GET_NEXT_ID_struct BPF_PROG_GET_NEXT_ID_struct
171 #define BPF_MAP_GET_NEXT_ID_struct_size BPF_PROG_GET_NEXT_ID_struct_size
173 struct BPF_PROG_GET_FD_BY_ID_struct {
179 #define BPF_PROG_GET_FD_BY_ID_struct_size \
180 sizeof(struct BPF_PROG_GET_FD_BY_ID_struct)
181 #define expected_BPF_PROG_GET_FD_BY_ID_struct_size 12
183 struct BPF_MAP_GET_FD_BY_ID_struct {
189 #define BPF_MAP_GET_FD_BY_ID_struct_size \
190 sizeof(struct BPF_MAP_GET_FD_BY_ID_struct)
191 #define expected_BPF_MAP_GET_FD_BY_ID_struct_size 12
193 struct BPF_OBJ_GET_INFO_BY_FD_struct /* info */ {
196 uint64_t ATTRIBUTE_ALIGNED(8) info;
199 #define BPF_OBJ_GET_INFO_BY_FD_struct_size \
200 sizeof(struct BPF_OBJ_GET_INFO_BY_FD_struct)
201 #define expected_BPF_OBJ_GET_INFO_BY_FD_struct_size 16
203 #endif /* !STRACE_BPF_ATTR_H */