]> granicus.if.org Git - strace/blob - bpf_attr.h
net: print SO_GET_FILTER in getsockopt
[strace] / bpf_attr.h
1 /*
2  * Copyright (c) 2015-2018 Dmitry V. Levin <ldv@altlinux.org>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
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.
15  *
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.
26  */
27
28 #ifndef STRACE_BPF_ATTR_H
29 #define STRACE_BPF_ATTR_H
30
31 #ifndef BPF_OBJ_NAME_LEN
32 # define BPF_OBJ_NAME_LEN 16U
33 #else
34 # if BPF_OBJ_NAME_LEN != 16U
35 #  error "Unexpected value of BPF_OBJ_NAME_LEN"
36 # endif
37 #endif
38
39 struct BPF_MAP_CREATE_struct {
40         uint32_t map_type;
41         uint32_t key_size;
42         uint32_t value_size;
43         uint32_t max_entries;
44         uint32_t map_flags;
45         uint32_t inner_map_fd;
46         uint32_t numa_node;
47         char     map_name[BPF_OBJ_NAME_LEN];
48         uint32_t map_ifindex;
49 };
50
51 #define BPF_MAP_CREATE_struct_size \
52         sizeof(struct BPF_MAP_CREATE_struct)
53 #define expected_BPF_MAP_CREATE_struct_size 48
54
55 struct BPF_MAP_LOOKUP_ELEM_struct {
56         uint32_t map_fd;
57         uint64_t ATTRIBUTE_ALIGNED(8) key;
58         uint64_t ATTRIBUTE_ALIGNED(8) value;
59 };
60
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
64
65 struct BPF_MAP_UPDATE_ELEM_struct {
66         uint32_t map_fd;
67         uint64_t ATTRIBUTE_ALIGNED(8) key;
68         uint64_t ATTRIBUTE_ALIGNED(8) value;
69         uint64_t flags;
70 };
71
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
75
76 struct BPF_MAP_DELETE_ELEM_struct {
77         uint32_t map_fd;
78         uint64_t ATTRIBUTE_ALIGNED(8) key;
79 };
80
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
84
85 struct BPF_MAP_GET_NEXT_KEY_struct {
86         uint32_t map_fd;
87         uint64_t ATTRIBUTE_ALIGNED(8) key;
88         uint64_t ATTRIBUTE_ALIGNED(8) next_key;
89 };
90
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
94
95 struct BPF_PROG_LOAD_struct {
96         uint32_t prog_type;
97         uint32_t insn_cnt;
98         uint64_t ATTRIBUTE_ALIGNED(8) insns;
99         uint64_t ATTRIBUTE_ALIGNED(8) license;
100         uint32_t log_level;
101         uint32_t log_size;
102         uint64_t ATTRIBUTE_ALIGNED(8) log_buf;
103         uint32_t kern_version;
104         uint32_t prog_flags;
105         char     prog_name[BPF_OBJ_NAME_LEN];
106         uint32_t prog_ifindex;
107 };
108
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
112
113 struct BPF_OBJ_PIN_struct {
114         uint64_t ATTRIBUTE_ALIGNED(8) pathname;
115         uint32_t bpf_fd;
116         uint32_t file_flags;
117 };
118
119 #define BPF_OBJ_PIN_struct_size \
120         sizeof(struct BPF_OBJ_PIN_struct)
121 #define expected_BPF_OBJ_PIN_struct_size 16
122
123 #define BPF_OBJ_GET_struct BPF_OBJ_PIN_struct
124 #define BPF_OBJ_GET_struct_size BPF_OBJ_PIN_struct_size
125
126 struct BPF_PROG_ATTACH_struct {
127         uint32_t target_fd;
128         uint32_t attach_bpf_fd;
129         uint32_t attach_type;
130         uint32_t attach_flags;
131 };
132
133 #define BPF_PROG_ATTACH_struct_size \
134         sizeof(struct BPF_PROG_ATTACH_struct)
135 #define expected_BPF_PROG_ATTACH_struct_size 16
136
137 struct BPF_PROG_DETACH_struct {
138         uint32_t target_fd;
139         uint32_t dummy;
140         uint32_t attach_type;
141 };
142
143 #define BPF_PROG_DETACH_struct_size \
144         sizeof(struct BPF_PROG_DETACH_struct)
145 #define expected_BPF_PROG_DETACH_struct_size 12
146
147 struct BPF_PROG_TEST_RUN_struct /* test */ {
148         uint32_t prog_fd;
149         uint32_t retval;
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;
154         uint32_t repeat;
155         uint32_t duration;
156 };
157
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
161
162 struct BPF_PROG_GET_NEXT_ID_struct {
163         uint32_t start_id;
164         uint32_t next_id;
165         uint32_t open_flags;
166 };
167
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
171
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
174
175 struct BPF_PROG_GET_FD_BY_ID_struct {
176         uint32_t prog_id;
177         uint32_t next_id;
178         uint32_t open_flags;
179 };
180
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
184
185 struct BPF_MAP_GET_FD_BY_ID_struct {
186         uint32_t map_id;
187         uint32_t next_id;
188         uint32_t open_flags;
189 };
190
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
194
195 struct BPF_OBJ_GET_INFO_BY_FD_struct /* info */ {
196         uint32_t bpf_fd;
197         uint32_t info_len;
198         uint64_t ATTRIBUTE_ALIGNED(8) info;
199 };
200
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
204
205 struct BPF_PROG_QUERY_struct /* query */ {
206         uint32_t target_fd;
207         uint32_t attach_type;
208         uint32_t query_flags;
209         uint32_t attach_flags;
210         uint64_t ATTRIBUTE_ALIGNED(8) prog_ids;
211         uint32_t prog_cnt;
212 };
213
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
217
218 #endif /* !STRACE_BPF_ATTR_H */