Debian Codegraph @

templates/man2/bpf.2.pot

raw
1 # SOME DESCRIPTIVE TITLE
2 # Copyright (C) YEAR Free Software Foundation, Inc.
3 # This file is distributed under the same license as the PACKAGE package.
4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5 #
6 #, fuzzy
7 msgid ""
8 msgstr ""
9 "Project-Id-Version: PACKAGE VERSION\n"
10 "POT-Creation-Date: 2026-06-05 06:19+0200\n"
11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <[email protected]>\n"
14 "Language: \n"
15 "MIME-Version: 1.0\n"
16 "Content-Type: text/plain; charset=UTF-8\n"
17 "Content-Transfer-Encoding: 8bit\n"
18
19 #. type: TH
20 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
21 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
22 #, no-wrap
23 msgid "bpf"
24 msgstr ""
25
26 #. type: TH
27 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
28 #: opensuse-tumbleweed
29 #, no-wrap
30 msgid "2026-02-10"
31 msgstr ""
32
33 #. type: TH
34 #: archlinux debian-unstable
35 #, no-wrap
36 msgid "Linux man-pages 6.18"
37 msgstr ""
38
39 #. type: SH
40 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
41 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
42 #, no-wrap
43 msgid "NAME"
44 msgstr ""
45
46 #. type: Plain text
47 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
48 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
49 msgid "bpf - perform a command on an extended BPF map or program"
50 msgstr ""
51
52 #. type: SH
53 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
54 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
55 #, no-wrap
56 msgid "SYNOPSIS"
57 msgstr ""
58
59 #. type: Plain text
60 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
61 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
62 #, no-wrap
63 msgid "B<#include E<lt>linux/bpf.hE<gt>>\n"
64 msgstr ""
65
66 #. type: Plain text
67 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
68 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
69 #, no-wrap
70 msgid "B<int bpf(int >I<cmd>B<, union bpf_attr *>I<attr>B<, unsigned int >I<size>B<);>\n"
71 msgstr ""
72
73 #. type: SH
74 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
75 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
76 #, no-wrap
77 msgid "DESCRIPTION"
78 msgstr ""
79
80 #. type: Plain text
81 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
82 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
83 msgid ""
84 "The B<bpf>() system call performs a range of operations related to extended "
85 "Berkeley Packet Filters. Extended BPF (or eBPF) is similar to the original "
86 "(\"classic\") BPF (cBPF) used to filter network packets. For both cBPF and "
87 "eBPF programs, the kernel statically analyzes the programs before loading "
88 "them, in order to ensure that they cannot harm the running system."
89 msgstr ""
90
91 #. See 'enum bpf_func_id' in include/uapi/linux/bpf.h
92 #. type: Plain text
93 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
94 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
95 msgid ""
96 "eBPF extends cBPF in multiple ways, including the ability to call a fixed "
97 "set of in-kernel helper functions (via the B<BPF_CALL> opcode extension "
98 "provided by eBPF) and access shared data structures such as eBPF maps."
99 msgstr ""
100
101 #. type: SS
102 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
103 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
104 #, no-wrap
105 msgid "Extended BPF Design/Architecture"
106 msgstr ""
107
108 #. type: Plain text
109 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
110 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
111 msgid ""
112 "eBPF maps are a generic data structure for storage of different data types. "
113 "Data types are generally treated as binary blobs, so a user just specifies "
114 "the size of the key and the size of the value at map-creation time. In "
115 "other words, a key/value for a given map can have an arbitrary structure."
116 msgstr ""
117
118 #. type: Plain text
119 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
120 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
121 msgid ""
122 "A user process can create multiple maps (with key/value-pairs being opaque "
123 "bytes of data) and access them via file descriptors. Different eBPF "
124 "programs can access the same maps in parallel. It's up to the user process "
125 "and eBPF program to decide what they store inside maps."
126 msgstr ""
127
128 #. Defined by the kernel constant MAX_TAIL_CALL_CNT in include/linux/bpf.h
129 #. type: Plain text
130 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
131 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
132 msgid ""
133 "There's one special map type, called a program array. This type of map "
134 "stores file descriptors referring to other eBPF programs. When a lookup in "
135 "the map is performed, the program flow is redirected in-place to the "
136 "beginning of another eBPF program and does not return back to the calling "
137 "program. The level of nesting has a fixed limit of 32, so that infinite "
138 "loops cannot be crafted. At run time, the program file descriptors stored "
139 "in the map can be modified, so program functionality can be altered based on "
140 "specific requirements. All programs referred to in a program-array map must "
141 "have been previously loaded into the kernel via B<bpf>(). If a map lookup "
142 "fails, the current program continues its execution. See "
143 "B<BPF_MAP_TYPE_PROG_ARRAY> below for further details."
144 msgstr ""
145
146 #. type: Plain text
147 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
148 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
149 msgid ""
150 "Generally, eBPF programs are loaded by the user process and automatically "
151 "unloaded when the process exits. In some cases, for example, B<tc-bpf>(8), "
152 "the program will continue to stay alive inside the kernel even after the "
153 "process that loaded the program exits. In that case, the tc subsystem holds "
154 "a reference to the eBPF program after the file descriptor has been closed by "
155 "the user-space program. Thus, whether a specific program continues to live "
156 "inside the kernel depends on how it is further attached to a given kernel "
157 "subsystem after it was loaded via B<bpf>()."
158 msgstr ""
159
160 #. type: Plain text
161 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
162 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
163 msgid ""
164 "Each eBPF program is a set of instructions that is safe to run until its "
165 "completion. An in-kernel verifier statically determines that the eBPF "
166 "program terminates and is safe to execute. During verification, the kernel "
167 "increments reference counts for each of the maps that the eBPF program uses, "
168 "so that the attached maps can't be removed until the program is unloaded."
169 msgstr ""
170
171 #. type: Plain text
172 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
173 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
174 msgid ""
175 "eBPF programs can be attached to different events. These events can be the "
176 "arrival of network packets, tracing events, classification events by network "
177 "queueing disciplines (for eBPF programs attached to a B<tc>(8) classifier), "
178 "and other types that may be added in the future. A new event triggers "
179 "execution of the eBPF program, which may store information about the event "
180 "in eBPF maps. Beyond storing data, eBPF programs may call a fixed set of in-"
181 "kernel helper functions."
182 msgstr ""
183
184 #. type: Plain text
185 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
186 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
187 msgid ""
188 "The same eBPF program can be attached to multiple events and different eBPF "
189 "programs can access the same map:"
190 msgstr ""
191
192 #. type: Plain text
193 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
194 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
195 #, no-wrap
196 msgid ""
197 "tracing tracing tracing packet packet packet\n"
198 "event A event B event C on eth0 on eth1 on eth2\n"
199 " | | | | | \\[ha]\n"
200 " | | | | v |\n"
201 " --E<gt> tracing E<lt>-- tracing socket tc ingress tc egress\n"
202 " prog_1 prog_2 prog_3 classifier action\n"
203 " | | | | prog_4 prog_5\n"
204 " |--- -----| |------| map_3 | |\n"
205 " map_1 map_2 --| map_4 |--\n"
206 msgstr ""
207
208 #. type: SS
209 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
210 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
211 #, no-wrap
212 msgid "Arguments"
213 msgstr ""
214
215 #. type: Plain text
216 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
217 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
218 msgid ""
219 "The operation to be performed by the B<bpf>() system call is determined by "
220 "the I<cmd> argument. Each operation takes an accompanying argument, "
221 "provided via I<attr>, which is a pointer to a union of type I<bpf_attr> (see "
222 "below). The unused fields and padding must be zeroed out before the call. "
223 "The I<size> argument is the size of the union pointed to by I<attr>."
224 msgstr ""
225
226 #. type: Plain text
227 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
228 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
229 msgid "The value provided in I<cmd> is one of the following:"
230 msgstr ""
231
232 #. type: TP
233 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
234 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
235 #, no-wrap
236 msgid "B<BPF_MAP_CREATE>"
237 msgstr ""
238
239 #. type: Plain text
240 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
241 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
242 msgid ""
243 "Create a map and return a file descriptor that refers to the map. The close-"
244 "on-exec file descriptor flag (see B<fcntl>(2)) is automatically enabled for "
245 "the new file descriptor."
246 msgstr ""
247
248 #. type: TP
249 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
250 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
251 #, no-wrap
252 msgid "B<BPF_MAP_LOOKUP_ELEM>"
253 msgstr ""
254
255 #. type: Plain text
256 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
257 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
258 msgid "Look up an element by key in a specified map and return its value."
259 msgstr ""
260
261 #. type: TP
262 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
263 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
264 #, no-wrap
265 msgid "B<BPF_MAP_UPDATE_ELEM>"
266 msgstr ""
267
268 #. type: Plain text
269 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
270 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
271 msgid "Create or update an element (key/value pair) in a specified map."
272 msgstr ""
273
274 #. type: TP
275 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
276 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
277 #, no-wrap
278 msgid "B<BPF_MAP_DELETE_ELEM>"
279 msgstr ""
280
281 #. type: Plain text
282 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
283 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
284 msgid "Look up and delete an element by key in a specified map."
285 msgstr ""
286
287 #. type: TP
288 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
289 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
290 #, no-wrap
291 msgid "B<BPF_MAP_GET_NEXT_KEY>"
292 msgstr ""
293
294 #. type: Plain text
295 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
296 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
297 msgid ""
298 "Look up an element by key in a specified map and return the key of the next "
299 "element."
300 msgstr ""
301
302 #. type: TP
303 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
304 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
305 #, no-wrap
306 msgid "B<BPF_PROG_LOAD>"
307 msgstr ""
308
309 #. type: Plain text
310 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
311 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
312 msgid ""
313 "Verify and load an eBPF program, returning a new file descriptor associated "
314 "with the program. The close-on-exec file descriptor flag (see B<fcntl>(2)) "
315 "is automatically enabled for the new file descriptor."
316 msgstr ""
317
318 #. type: Plain text
319 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
320 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
321 msgid ""
322 "The I<bpf_attr> union consists of various anonymous structures that are used "
323 "by different B<bpf>() commands:"
324 msgstr ""
325
326 #. commit 2541517c32be2531e0da59dfd7efc1ce844644f5
327 #. type: Plain text
328 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
329 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
330 #, no-wrap
331 msgid ""
332 "union bpf_attr {\n"
333 " struct { /* Used by BPF_MAP_CREATE */\n"
334 " __u32 map_type;\n"
335 " __u32 key_size; /* size of key in bytes */\n"
336 " __u32 value_size; /* size of value in bytes */\n"
337 " __u32 max_entries; /* maximum number of entries\n"
338 " in a map */\n"
339 " };\n"
340 "\\&\n"
341 " struct { /* Used by BPF_MAP_*_ELEM and BPF_MAP_GET_NEXT_KEY\n"
342 " commands */\n"
343 " __u32 map_fd;\n"
344 " __aligned_u64 key;\n"
345 " union {\n"
346 " __aligned_u64 value;\n"
347 " __aligned_u64 next_key;\n"
348 " };\n"
349 " __u64 flags;\n"
350 " };\n"
351 "\\&\n"
352 " struct { /* Used by BPF_PROG_LOAD */\n"
353 " __u32 prog_type;\n"
354 " __u32 insn_cnt;\n"
355 " __aligned_u64 insns; /* \\[aq]const struct bpf_insn *\\[aq] */\n"
356 " __aligned_u64 license; /* \\[aq]const char *\\[aq] */\n"
357 " __u32 log_level; /* verbosity level of verifier */\n"
358 " __u32 log_size; /* size of user buffer */\n"
359 " __aligned_u64 log_buf; /* user supplied \\[aq]char *\\[aq]\n"
360 " buffer */\n"
361 " __u32 kern_version;\n"
362 " /* checked when prog_type=kprobe\n"
363 " (since Linux 4.1) */\n"
364 " };\n"
365 "} __attribute__((aligned(8)));\n"
366 msgstr ""
367
368 #. type: SS
369 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
370 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
371 #, no-wrap
372 msgid "eBPF maps"
373 msgstr ""
374
375 #. type: Plain text
376 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
377 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
378 msgid ""
379 "Maps are a generic data structure for storage of different types of data. "
380 "They allow sharing of data between eBPF kernel programs, and also between "
381 "kernel and user-space applications."
382 msgstr ""
383
384 #. type: Plain text
385 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
386 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
387 msgid "Each map type has the following attributes:"
388 msgstr ""
389
390 #. type: IP
391 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
392 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
393 #, no-wrap
394 msgid "\\[bu]"
395 msgstr ""
396
397 #. type: Plain text
398 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
399 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
400 msgid "type"
401 msgstr ""
402
403 #. type: Plain text
404 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
405 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
406 msgid "maximum number of elements"
407 msgstr ""
408
409 #. type: Plain text
410 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
411 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
412 msgid "key size in bytes"
413 msgstr ""
414
415 #. type: Plain text
416 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
417 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
418 msgid "value size in bytes"
419 msgstr ""
420
421 #. type: Plain text
422 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
423 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
424 msgid ""
425 "The following wrapper functions demonstrate how various B<bpf>() commands "
426 "can be used to access the maps. The functions use the I<cmd> argument to "
427 "invoke different operations."
428 msgstr ""
429
430 #. type: Plain text
431 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
432 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
433 msgid ""
434 "The B<BPF_MAP_CREATE> command creates a new map, returning a new file "
435 "descriptor that refers to the map."
436 msgstr ""
437
438 #. type: Plain text
439 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
440 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
441 #, no-wrap
442 msgid ""
443 "int\n"
444 "bpf_create_map(enum bpf_map_type map_type,\n"
445 " unsigned int key_size,\n"
446 " unsigned int value_size,\n"
447 " unsigned int max_entries)\n"
448 "{\n"
449 " union bpf_attr attr = {\n"
450 " .map_type = map_type,\n"
451 " .key_size = key_size,\n"
452 " .value_size = value_size,\n"
453 " .max_entries = max_entries\n"
454 " };\n"
455 "\\&\n"
456 " return bpf(BPF_MAP_CREATE, &attr, sizeof(attr));\n"
457 "}\n"
458 msgstr ""
459
460 #. type: Plain text
461 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
462 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
463 msgid ""
464 "The new map has the type specified by I<map_type>, and attributes as "
465 "specified in I<key_size>, I<value_size>, and I<max_entries>. On success, "
466 "this operation returns a file descriptor. On error, -1 is returned and "
467 "I<errno> is set to B<EINVAL>, B<EPERM>, or B<ENOMEM>."
468 msgstr ""
469
470 #. type: Plain text
471 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
472 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
473 msgid ""
474 "The I<key_size> and I<value_size> attributes will be used by the verifier "
475 "during program loading to check that the program is calling "
476 "B<bpf_map_*_elem>() helper functions with a correctly initialized I<key> "
477 "and to check that the program doesn't access the map element I<value> beyond "
478 "the specified I<value_size>. For example, when a map is created with a "
479 "I<key_size> of 8 and the eBPF program calls"
480 msgstr ""
481
482 #. type: Plain text
483 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
484 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
485 #, no-wrap
486 msgid "bpf_map_lookup_elem(map_fd, fp - 4)\n"
487 msgstr ""
488
489 #. type: Plain text
490 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
491 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
492 msgid "the program will be rejected, since the in-kernel helper function"
493 msgstr ""
494
495 #. type: Plain text
496 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
497 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
498 #, no-wrap
499 msgid "bpf_map_lookup_elem(map_fd, void *key)\n"
500 msgstr ""
501
502 #. type: Plain text
503 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
504 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
505 msgid ""
506 "expects to read 8 bytes from the location pointed to by I<key>, but the "
507 "I<fp\\ -\\ 4> (where I<fp> is the top of the stack) starting address will "
508 "cause out-of-bounds stack access."
509 msgstr ""
510
511 #. type: Plain text
512 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
513 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
514 msgid ""
515 "Similarly, when a map is created with a I<value_size> of 1 and the eBPF "
516 "program contains"
517 msgstr ""
518
519 #. type: Plain text
520 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
521 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
522 #, no-wrap
523 msgid ""
524 "value = bpf_map_lookup_elem(...);\n"
525 "*(u32 *) value = 1;\n"
526 msgstr ""
527
528 #. type: Plain text
529 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
530 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
531 msgid ""
532 "the program will be rejected, since it accesses the I<value> pointer beyond "
533 "the specified 1 byte I<value_size> limit."
534 msgstr ""
535
536 #. type: Plain text
537 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
538 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
539 msgid "Currently, the following values are supported for I<map_type>:"
540 msgstr ""
541
542 #. type: Plain text
543 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
544 #: opensuse-tumbleweed
545 #, no-wrap
546 msgid ""
547 "enum bpf_map_type {\n"
548 " BPF_MAP_TYPE_UNSPEC, /* Reserve 0 as invalid map type */\n"
549 " BPF_MAP_TYPE_HASH,\n"
550 " BPF_MAP_TYPE_ARRAY,\n"
551 " BPF_MAP_TYPE_PROG_ARRAY,\n"
552 " BPF_MAP_TYPE_PERF_EVENT_ARRAY,\n"
553 " BPF_MAP_TYPE_PERCPU_HASH,\n"
554 " BPF_MAP_TYPE_PERCPU_ARRAY,\n"
555 " BPF_MAP_TYPE_STACK_TRACE,\n"
556 " BPF_MAP_TYPE_CGROUP_ARRAY,\n"
557 " BPF_MAP_TYPE_LRU_HASH,\n"
558 " BPF_MAP_TYPE_LRU_PERCPU_HASH,\n"
559 " BPF_MAP_TYPE_LPM_TRIE,\n"
560 " BPF_MAP_TYPE_ARRAY_OF_MAPS,\n"
561 " BPF_MAP_TYPE_HASH_OF_MAPS,\n"
562 " BPF_MAP_TYPE_DEVMAP,\n"
563 " BPF_MAP_TYPE_SOCKMAP,\n"
564 " BPF_MAP_TYPE_CPUMAP,\n"
565 " BPF_MAP_TYPE_XSKMAP,\n"
566 " BPF_MAP_TYPE_SOCKHASH,\n"
567 " BPF_MAP_TYPE_CGROUP_STORAGE,\n"
568 " BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,\n"
569 " BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,\n"
570 " BPF_MAP_TYPE_QUEUE,\n"
571 " BPF_MAP_TYPE_STACK,\n"
572 " /* See /usr/include/linux/bpf.h for the full list. */\n"
573 "};\n"
574 msgstr ""
575
576 #. FIXME We need an explanation of why one might choose each of
577 #. these map implementations
578 #. type: Plain text
579 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
580 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
581 msgid ""
582 "I<map_type> selects one of the available map implementations in the kernel. "
583 "For all map types, eBPF programs access maps with the same "
584 "B<bpf_map_lookup_elem>() and B<bpf_map_update_elem>() helper functions. "
585 "Further details of the various map types are given below."
586 msgstr ""
587
588 #. type: Plain text
589 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
590 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
591 msgid ""
592 "The B<BPF_MAP_LOOKUP_ELEM> command looks up an element with a given I<key> "
593 "in the map referred to by the file descriptor I<fd>."
594 msgstr ""
595
596 #. type: Plain text
597 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
598 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
599 #, no-wrap
600 msgid ""
601 "int\n"
602 "bpf_lookup_elem(int fd, const void *key, void *value)\n"
603 "{\n"
604 " union bpf_attr attr = {\n"
605 " .map_fd = fd,\n"
606 " .key = ptr_to_u64(key),\n"
607 " .value = ptr_to_u64(value),\n"
608 " };\n"
609 "\\&\n"
610 " return bpf(BPF_MAP_LOOKUP_ELEM, &attr, sizeof(attr));\n"
611 "}\n"
612 msgstr ""
613
614 #. type: Plain text
615 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
616 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
617 msgid ""
618 "If an element is found, the operation returns zero and stores the element's "
619 "value into I<value>, which must point to a buffer of I<value_size> bytes."
620 msgstr ""
621
622 #. type: Plain text
623 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
624 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
625 msgid ""
626 "If no element is found, the operation returns -1 and sets I<errno> to "
627 "B<ENOENT>."
628 msgstr ""
629
630 #. type: Plain text
631 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
632 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
633 msgid ""
634 "The B<BPF_MAP_UPDATE_ELEM> command creates or updates an element with a "
635 "given I<key/value> in the map referred to by the file descriptor I<fd>."
636 msgstr ""
637
638 #. type: Plain text
639 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
640 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
641 #, no-wrap
642 msgid ""
643 "int\n"
644 "bpf_update_elem(int fd, const void *key, const void *value,\n"
645 " uint64_t flags)\n"
646 "{\n"
647 " union bpf_attr attr = {\n"
648 " .map_fd = fd,\n"
649 " .key = ptr_to_u64(key),\n"
650 " .value = ptr_to_u64(value),\n"
651 " .flags = flags,\n"
652 " };\n"
653 "\\&\n"
654 " return bpf(BPF_MAP_UPDATE_ELEM, &attr, sizeof(attr));\n"
655 "}\n"
656 msgstr ""
657
658 #. type: Plain text
659 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
660 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
661 msgid "The I<flags> argument should be specified as one of the following:"
662 msgstr ""
663
664 #. type: TP
665 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
666 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
667 #, no-wrap
668 msgid "B<BPF_ANY>"
669 msgstr ""
670
671 #. type: Plain text
672 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
673 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
674 msgid "Create a new element or update an existing element."
675 msgstr ""
676
677 #. type: TP
678 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
679 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
680 #, no-wrap
681 msgid "B<BPF_NOEXIST>"
682 msgstr ""
683
684 #. type: Plain text
685 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
686 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
687 msgid "Create a new element only if it did not exist."
688 msgstr ""
689
690 #. type: TP
691 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
692 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
693 #, no-wrap
694 msgid "B<BPF_EXIST>"
695 msgstr ""
696
697 #. type: Plain text
698 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
699 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
700 msgid "Update an existing element."
701 msgstr ""
702
703 #. type: Plain text
704 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
705 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
706 msgid ""
707 "On success, the operation returns zero. On error, -1 is returned and "
708 "I<errno> is set to B<EINVAL>, B<EPERM>, B<ENOMEM>, or B<E2BIG>. B<E2BIG> "
709 "indicates that the number of elements in the map reached the I<max_entries> "
710 "limit specified at map creation time. B<EEXIST> will be returned if "
711 "I<flags> specifies B<BPF_NOEXIST> and the element with I<key> already exists "
712 "in the map. B<ENOENT> will be returned if I<flags> specifies B<BPF_EXIST> "
713 "and the element with I<key> doesn't exist in the map."
714 msgstr ""
715
716 #. type: Plain text
717 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
718 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
719 msgid ""
720 "The B<BPF_MAP_DELETE_ELEM> command deletes the element whose key is I<key> "
721 "from the map referred to by the file descriptor I<fd>."
722 msgstr ""
723
724 #. type: Plain text
725 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
726 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
727 #, no-wrap
728 msgid ""
729 "int\n"
730 "bpf_delete_elem(int fd, const void *key)\n"
731 "{\n"
732 " union bpf_attr attr = {\n"
733 " .map_fd = fd,\n"
734 " .key = ptr_to_u64(key),\n"
735 " };\n"
736 "\\&\n"
737 " return bpf(BPF_MAP_DELETE_ELEM, &attr, sizeof(attr));\n"
738 "}\n"
739 msgstr ""
740
741 #. type: Plain text
742 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
743 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
744 msgid ""
745 "On success, zero is returned. If the element is not found, -1 is returned "
746 "and I<errno> is set to B<ENOENT>."
747 msgstr ""
748
749 #. type: Plain text
750 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
751 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
752 msgid ""
753 "The B<BPF_MAP_GET_NEXT_KEY> command looks up an element by I<key> in the map "
754 "referred to by the file descriptor I<fd> and sets the I<next_key> pointer to "
755 "the key of the next element."
756 msgstr ""
757
758 #. type: Plain text
759 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
760 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
761 #, no-wrap
762 msgid ""
763 "int\n"
764 "bpf_get_next_key(int fd, const void *key, void *next_key)\n"
765 "{\n"
766 " union bpf_attr attr = {\n"
767 " .map_fd = fd,\n"
768 " .key = ptr_to_u64(key),\n"
769 " .next_key = ptr_to_u64(next_key),\n"
770 " };\n"
771 "\\&\n"
772 " return bpf(BPF_MAP_GET_NEXT_KEY, &attr, sizeof(attr));\n"
773 "}\n"
774 msgstr ""
775
776 #. type: Plain text
777 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
778 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
779 msgid ""
780 "If I<key> is found, the operation returns zero and sets the I<next_key> "
781 "pointer to the key of the next element. If I<key> is not found, the "
782 "operation returns zero and sets the I<next_key> pointer to the key of the "
783 "first element. If I<key> is the last element, -1 is returned and I<errno> "
784 "is set to B<ENOENT>. Other possible I<errno> values are B<ENOMEM>, "
785 "B<EFAULT>, B<EPERM>, and B<EINVAL>. This method can be used to iterate over "
786 "all elements in the map."
787 msgstr ""
788
789 #. type: TP
790 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
791 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
792 #, no-wrap
793 msgid "B<close(map_fd)>"
794 msgstr ""
795
796 #. type: Plain text
797 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
798 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
799 msgid ""
800 "Delete the map referred to by the file descriptor I<map_fd>. When the user-"
801 "space program that created a map exits, all maps will be deleted "
802 "automatically (but see NOTES)."
803 msgstr ""
804
805 #. type: SS
806 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
807 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
808 #, no-wrap
809 msgid "eBPF map types"
810 msgstr ""
811
812 #. type: Plain text
813 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
814 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
815 msgid "The following map types are supported:"
816 msgstr ""
817
818 #. type: TP
819 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
820 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
821 #, no-wrap
822 msgid "B<BPF_MAP_TYPE_HASH>"
823 msgstr ""
824
825 #. commit 0f8e4bd8a1fc8c4185f1630061d0a1f2d197a475
826 #. type: Plain text
827 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
828 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
829 msgid "Hash-table maps have the following characteristics:"
830 msgstr ""
831
832 #. type: Plain text
833 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
834 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
835 msgid ""
836 "Maps are created and destroyed by user-space programs. Both user-space and "
837 "eBPF programs can perform lookup, update, and delete operations."
838 msgstr ""
839
840 #. type: Plain text
841 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
842 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
843 msgid "The kernel takes care of allocating and freeing key/value pairs."
844 msgstr ""
845
846 #. type: Plain text
847 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
848 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
849 msgid ""
850 "The B<map_update_elem>() helper will fail to insert new element when the "
851 "I<max_entries> limit is reached. (This ensures that eBPF programs cannot "
852 "exhaust memory.)"
853 msgstr ""
854
855 #. type: Plain text
856 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
857 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
858 msgid "B<map_update_elem>() replaces existing elements atomically."
859 msgstr ""
860
861 #. type: Plain text
862 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
863 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
864 msgid "Hash-table maps are optimized for speed of lookup."
865 msgstr ""
866
867 #. type: TP
868 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
869 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
870 #, no-wrap
871 msgid "B<BPF_MAP_TYPE_ARRAY>"
872 msgstr ""
873
874 #. commit 28fbcfa08d8ed7c5a50d41a0433aad222835e8e3
875 #. type: Plain text
876 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
877 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
878 msgid "Array maps have the following characteristics:"
879 msgstr ""
880
881 #. type: Plain text
882 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
883 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
884 msgid ""
885 "Optimized for fastest possible lookup. In the future the verifier/JIT "
886 "compiler may recognize lookup() operations that employ a constant key and "
887 "optimize it into constant pointer. It is possible to optimize a non-"
888 "constant key into direct pointer arithmetic as well, since pointers and "
889 "I<value_size> are constant for the life of the eBPF program. In other "
890 "words, B<array_map_lookup_elem>() may be 'inlined' by the verifier/JIT "
891 "compiler while preserving concurrent access to this map from user space."
892 msgstr ""
893
894 #. type: Plain text
895 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
896 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
897 msgid "All array elements pre-allocated and zero initialized at init time"
898 msgstr ""
899
900 #. type: Plain text
901 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
902 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
903 msgid "The key is an array index, and must be exactly four bytes."
904 msgstr ""
905
906 #. type: Plain text
907 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
908 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
909 msgid ""
910 "B<map_delete_elem>() fails with the error B<EINVAL>, since elements cannot "
911 "be deleted."
912 msgstr ""
913
914 #. type: Plain text
915 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
916 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
917 msgid ""
918 "B<map_update_elem>() replaces elements in a B<nonatomic> fashion; for "
919 "atomic updates, a hash-table map should be used instead. There is however "
920 "one special case that can also be used with arrays: the atomic built-in "
921 "B<__sync_fetch_and_add()> can be used on 32 and 64 bit atomic counters. For "
922 "example, it can be applied on the whole value itself if it represents a "
923 "single counter, or in case of a structure containing multiple counters, it "
924 "could be used on individual counters. This is quite often useful for "
925 "aggregation and accounting of events."
926 msgstr ""
927
928 #. type: Plain text
929 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
930 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
931 msgid "Among the uses for array maps are the following:"
932 msgstr ""
933
934 #. type: Plain text
935 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
936 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
937 msgid ""
938 "As \"global\" eBPF variables: an array of 1 element whose key is (index) 0 "
939 "and where the value is a collection of 'global' variables which eBPF "
940 "programs can use to keep state between events."
941 msgstr ""
942
943 #. type: Plain text
944 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
945 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
946 msgid "Aggregation of tracing events into a fixed set of buckets."
947 msgstr ""
948
949 #. type: Plain text
950 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
951 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
952 msgid ""
953 "Accounting of networking events, for example, number of packets and packet "
954 "sizes."
955 msgstr ""
956
957 #. type: TP
958 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
959 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
960 #, no-wrap
961 msgid "B<BPF_MAP_TYPE_PROG_ARRAY> (since Linux 4.2)"
962 msgstr ""
963
964 #. type: Plain text
965 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
966 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
967 msgid ""
968 "A program array map is a special kind of array map whose map values contain "
969 "only file descriptors referring to other eBPF programs. Thus, both the "
970 "I<key_size> and I<value_size> must be exactly four bytes. This map is used "
971 "in conjunction with the B<bpf_tail_call>() helper."
972 msgstr ""
973
974 #. type: Plain text
975 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
976 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
977 msgid ""
978 "This means that an eBPF program with a program array map attached to it can "
979 "call from kernel side into"
980 msgstr ""
981
982 #. type: Plain text
983 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
984 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
985 #, no-wrap
986 msgid ""
987 "void bpf_tail_call(void *context, void *prog_map,\n"
988 " unsigned int index);\n"
989 msgstr ""
990
991 #. type: Plain text
992 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
993 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
994 msgid ""
995 "and therefore replace its own program flow with the one from the program at "
996 "the given program array slot, if present. This can be regarded as kind of a "
997 "jump table to a different eBPF program. The invoked program will then reuse "
998 "the same stack. When a jump into the new program has been performed, it "
999 "won't return to the old program anymore."
1000 msgstr ""
1001
1002 #. MAX_TAIL_CALL_CNT
1003 #. type: Plain text
1004 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1005 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1006 msgid ""
1007 "If no eBPF program is found at the given index of the program array (because "
1008 "the map slot doesn't contain a valid program file descriptor, the specified "
1009 "lookup index/key is out of bounds, or the limit of 32 nested calls has been "
1010 "exceed), execution continues with the current eBPF program. This can be "
1011 "used as a fall-through for default cases."
1012 msgstr ""
1013
1014 #. type: Plain text
1015 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1016 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1017 msgid ""
1018 "A program array map is useful, for example, in tracing or networking, to "
1019 "handle individual system calls or protocols in their own subprograms and use "
1020 "their identifiers as an individual map index. This approach may result in "
1021 "performance benefits, and also makes it possible to overcome the maximum "
1022 "instruction limit of a single eBPF program. In dynamic environments, a user-"
1023 "space daemon might atomically replace individual subprograms at run-time "
1024 "with newer versions to alter overall program behavior, for instance, if "
1025 "global policies change."
1026 msgstr ""
1027
1028 #. type: SS
1029 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1030 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1031 #, no-wrap
1032 msgid "eBPF programs"
1033 msgstr ""
1034
1035 #. type: Plain text
1036 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1037 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1038 msgid ""
1039 "The B<BPF_PROG_LOAD> command is used to load an eBPF program into the "
1040 "kernel. The return value for this command is a new file descriptor "
1041 "associated with this eBPF program."
1042 msgstr ""
1043
1044 #. type: Plain text
1045 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1046 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1047 #, no-wrap
1048 msgid ""
1049 "char bpf_log_buf[LOG_BUF_SIZE];\n"
1050 "\\&\n"
1051 "int\n"
1052 "bpf_prog_load(enum bpf_prog_type type,\n"
1053 " const struct bpf_insn *insns, int insn_cnt,\n"
1054 " const char *license)\n"
1055 "{\n"
1056 " union bpf_attr attr = {\n"
1057 " .prog_type = type,\n"
1058 " .insns = ptr_to_u64(insns),\n"
1059 " .insn_cnt = insn_cnt,\n"
1060 " .license = ptr_to_u64(license),\n"
1061 " .log_buf = ptr_to_u64(bpf_log_buf),\n"
1062 " .log_size = LOG_BUF_SIZE,\n"
1063 " .log_level = 1,\n"
1064 " };\n"
1065 "\\&\n"
1066 " return bpf(BPF_PROG_LOAD, &attr, sizeof(attr));\n"
1067 "}\n"
1068 msgstr ""
1069
1070 #. type: Plain text
1071 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1072 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1073 msgid "I<prog_type> is one of the available program types:"
1074 msgstr ""
1075
1076 #. type: Plain text
1077 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1078 #: opensuse-tumbleweed
1079 #, no-wrap
1080 msgid ""
1081 "enum bpf_prog_type {\n"
1082 " BPF_PROG_TYPE_UNSPEC, /* Reserve 0 as invalid\n"
1083 " program type */\n"
1084 " BPF_PROG_TYPE_SOCKET_FILTER,\n"
1085 " BPF_PROG_TYPE_KPROBE,\n"
1086 " BPF_PROG_TYPE_SCHED_CLS,\n"
1087 " BPF_PROG_TYPE_SCHED_ACT,\n"
1088 " BPF_PROG_TYPE_TRACEPOINT,\n"
1089 " BPF_PROG_TYPE_XDP,\n"
1090 " BPF_PROG_TYPE_PERF_EVENT,\n"
1091 " BPF_PROG_TYPE_CGROUP_SKB,\n"
1092 " BPF_PROG_TYPE_CGROUP_SOCK,\n"
1093 " BPF_PROG_TYPE_LWT_IN,\n"
1094 " BPF_PROG_TYPE_LWT_OUT,\n"
1095 " BPF_PROG_TYPE_LWT_XMIT,\n"
1096 " BPF_PROG_TYPE_SOCK_OPS,\n"
1097 " BPF_PROG_TYPE_SK_SKB,\n"
1098 " BPF_PROG_TYPE_CGROUP_DEVICE,\n"
1099 " BPF_PROG_TYPE_SK_MSG,\n"
1100 " BPF_PROG_TYPE_RAW_TRACEPOINT,\n"
1101 " BPF_PROG_TYPE_CGROUP_SOCK_ADDR,\n"
1102 " BPF_PROG_TYPE_LWT_SEG6LOCAL,\n"
1103 " BPF_PROG_TYPE_LIRC_MODE2,\n"
1104 " BPF_PROG_TYPE_SK_REUSEPORT,\n"
1105 " BPF_PROG_TYPE_FLOW_DISSECTOR,\n"
1106 " /* See /usr/include/linux/bpf.h for the full list. */\n"
1107 "};\n"
1108 msgstr ""
1109
1110 #. type: Plain text
1111 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1112 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1113 msgid "For further details of eBPF program types, see below."
1114 msgstr ""
1115
1116 #. type: Plain text
1117 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1118 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1119 msgid "The remaining fields of I<bpf_attr> are set as follows:"
1120 msgstr ""
1121
1122 #. type: Plain text
1123 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1124 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1125 msgid "I<insns> is an array of I<struct bpf_insn> instructions."
1126 msgstr ""
1127
1128 #. type: Plain text
1129 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1130 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1131 msgid ""
1132 "I<insn_cnt> is the number of instructions in the program referred to by "
1133 "I<insns>."
1134 msgstr ""
1135
1136 #. type: Plain text
1137 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1138 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1139 msgid ""
1140 "I<license> is a license string, which must be GPL compatible to call helper "
1141 "functions marked I<gpl_only>. (The licensing rules are the same as for "
1142 "kernel modules, so that also dual licenses, such as \"Dual BSD/GPL\", may be "
1143 "used.)"
1144 msgstr ""
1145
1146 #. type: Plain text
1147 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1148 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1149 msgid ""
1150 "I<log_buf> is a pointer to a caller-allocated buffer in which the in-kernel "
1151 "verifier can store the verification log. This log is a multi-line string "
1152 "that can be checked by the program author in order to understand how the "
1153 "verifier came to the conclusion that the eBPF program is unsafe. The format "
1154 "of the output can change at any time as the verifier evolves."
1155 msgstr ""
1156
1157 #. type: Plain text
1158 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1159 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1160 msgid ""
1161 "I<log_size> size of the buffer pointed to by I<log_buf>. If the size of the "
1162 "buffer is not large enough to store all verifier messages, -1 is returned "
1163 "and I<errno> is set to B<ENOSPC>."
1164 msgstr ""
1165
1166 #. type: Plain text
1167 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1168 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1169 msgid ""
1170 "I<log_level> verbosity level of the verifier. A value of zero means that "
1171 "the verifier will not provide a log; in this case, I<log_buf> must be a null "
1172 "pointer, and I<log_size> must be zero."
1173 msgstr ""
1174
1175 #. type: Plain text
1176 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1177 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1178 msgid ""
1179 "Applying B<close>(2) to the file descriptor returned by B<BPF_PROG_LOAD> "
1180 "will unload the eBPF program (but see NOTES)."
1181 msgstr ""
1182
1183 #. type: Plain text
1184 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1185 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1186 msgid ""
1187 "Maps are accessible from eBPF programs and are used to exchange data between "
1188 "eBPF programs and between eBPF programs and user-space programs. For "
1189 "example, eBPF programs can process various events (like kprobe, packets) and "
1190 "store their data into a map, and user-space programs can then fetch data "
1191 "from the map. Conversely, user-space programs can use a map as a "
1192 "configuration mechanism, populating the map with values checked by the eBPF "
1193 "program, which then modifies its behavior on the fly according to those "
1194 "values."
1195 msgstr ""
1196
1197 #. type: SS
1198 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1199 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1200 #, no-wrap
1201 msgid "eBPF program types"
1202 msgstr ""
1203
1204 #
1205 #. #-#-#-#-# archlinux: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1206 #. FIXME
1207 #. Somewhere in this page we need a general introduction to the
1208 #. bpf_context. For example, how does a BPF program access the
1209 #. context?
1210 #. type: Plain text
1211 #. #-#-#-#-# debian-trixie: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1212 #. FIXME
1213 #. Somewhere in this page we need a general introduction to the
1214 #. bpf_context. For example, how does a BPF program access the
1215 #. context?
1216 #. type: Plain text
1217 #. #-#-#-#-# debian-unstable: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1218 #. FIXME
1219 #. Somewhere in this page we need a general introduction to the
1220 #. bpf_context. For example, how does a BPF program access the
1221 #. context?
1222 #. type: Plain text
1223 #. #-#-#-#-# fedora-44: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1224 #. FIXME
1225 #. Somewhere in this page we need a general introduction to the
1226 #. bpf_context. For example, how does a BPF program access the
1227 #. context?
1228 #. type: Plain text
1229 #. #-#-#-#-# fedora-rawhide: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1230 #. FIXME
1231 #. Somewhere in this page we need a general introduction to the
1232 #. bpf_context. For example, how does a BPF program access the
1233 #. context?
1234 #. type: Plain text
1235 #. #-#-#-#-# mageia-cauldron: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1236 #. FIXME
1237 #. Somewhere in this page we need a general introduction to the
1238 #. bpf_context. For example, how does a BPF program access the
1239 #. context?
1240 #. type: Plain text
1241 #. #-#-#-#-# opensuse-leap-16-1: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1242 #. FIXME
1243 #. Somewhere in this page we need a general introduction to the
1244 #. bpf_context. For example, how does a BPF program access the
1245 #. context?
1246 #. type: Plain text
1247 #. #-#-#-#-# opensuse-tumbleweed: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1248 #. FIXME
1249 #. Somewhere in this page we need a general introduction to the
1250 #. bpf_context. For example, how does a BPF program access the
1251 #. context?
1252 #. type: Plain text
1253 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1254 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1255 msgid ""
1256 "The eBPF program type (I<prog_type>) determines the subset of kernel helper "
1257 "functions that the program may call. The program type also determines the "
1258 "program input (context)\\[em]the format of I<struct bpf_context> (which is "
1259 "the data blob passed into the eBPF program as the first argument)."
1260 msgstr ""
1261
1262 #. type: Plain text
1263 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1264 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1265 msgid ""
1266 "For example, a tracing program does not have the exact same subset of helper "
1267 "functions as a socket filter program (though they may have some helpers in "
1268 "common). Similarly, the input (context) for a tracing program is a set of "
1269 "register values, while for a socket filter it is a network packet."
1270 msgstr ""
1271
1272 #. type: Plain text
1273 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1274 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1275 msgid ""
1276 "The set of functions available to eBPF programs of a given type may increase "
1277 "in the future."
1278 msgstr ""
1279
1280 #. type: Plain text
1281 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1282 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1283 msgid "The following program types are supported:"
1284 msgstr ""
1285
1286 #. type: TP
1287 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1288 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1289 #, no-wrap
1290 msgid "B<BPF_PROG_TYPE_SOCKET_FILTER> (since Linux 3.19)"
1291 msgstr ""
1292
1293 #. type: Plain text
1294 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1295 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1296 msgid "Currently, the set of functions for B<BPF_PROG_TYPE_SOCKET_FILTER> is:"
1297 msgstr ""
1298
1299 #. type: Plain text
1300 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1301 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1302 #, no-wrap
1303 msgid ""
1304 "bpf_map_lookup_elem(map_fd, void *key)\n"
1305 " /* look up key in a map_fd */\n"
1306 "bpf_map_update_elem(map_fd, void *key, void *value)\n"
1307 " /* update key/value */\n"
1308 "bpf_map_delete_elem(map_fd, void *key)\n"
1309 " /* delete key in a map_fd */\n"
1310 msgstr ""
1311
1312 #
1313 #. FIXME: We need some text here to explain how the program
1314 #. accesses __sk_buff.
1315 #. See 'struct __sk_buff' and commit 9bac3d6d548e5
1316 #. Alexei commented:
1317 #. Actually now in case of SOCKET_FILTER, SCHED_CLS, SCHED_ACT
1318 #. the program can now access skb fields.
1319 #. type: Plain text
1320 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1321 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1322 msgid "The I<bpf_context> argument is a pointer to a I<struct __sk_buff>."
1323 msgstr ""
1324
1325 #. type: TP
1326 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1327 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1328 #, no-wrap
1329 msgid "B<BPF_PROG_TYPE_KPROBE> (since Linux 4.1)"
1330 msgstr ""
1331
1332 #. commit 94caee8c312d96522bcdae88791aaa9ebcd5f22c
1333 #. commit a8cb5f556b567974d75ea29c15181c445c541b1f
1334 #. FIXME Document this program type
1335 #. Describe allowed helper functions for this program type
1336 #. Describe bpf_context for this program type
1337 #. type: Plain text
1338 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1339 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1340 msgid "[To be documented]"
1341 msgstr ""
1342
1343 #. type: TP
1344 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1345 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1346 #, no-wrap
1347 msgid "B<BPF_PROG_TYPE_SCHED_CLS> (since Linux 4.1)"
1348 msgstr ""
1349
1350 #. type: TP
1351 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1352 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1353 #, no-wrap
1354 msgid "B<BPF_PROG_TYPE_SCHED_ACT> (since Linux 4.1)"
1355 msgstr ""
1356
1357 #. type: SS
1358 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1359 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1360 #, no-wrap
1361 msgid "Events"
1362 msgstr ""
1363
1364 #. type: Plain text
1365 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1366 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1367 msgid ""
1368 "Once a program is loaded, it can be attached to an event. Various kernel "
1369 "subsystems have different ways to do so."
1370 msgstr ""
1371
1372 #. commit 89aa075832b0da4402acebd698d0411dcc82d03e
1373 #. type: Plain text
1374 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1375 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1376 msgid ""
1377 "Since Linux 3.19, the following call will attach the program I<prog_fd> to "
1378 "the socket I<sockfd>, which was created by an earlier call to B<socket>(2):"
1379 msgstr ""
1380
1381 #. type: Plain text
1382 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1383 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1384 #, no-wrap
1385 msgid ""
1386 "setsockopt(sockfd, SOL_SOCKET, SO_ATTACH_BPF,\n"
1387 " &prog_fd, sizeof(prog_fd));\n"
1388 msgstr ""
1389
1390 #. commit 2541517c32be2531e0da59dfd7efc1ce844644f5
1391 #. type: Plain text
1392 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1393 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1394 msgid ""
1395 "Since Linux 4.1, the following call may be used to attach the eBPF program "
1396 "referred to by the file descriptor I<prog_fd> to a perf event file "
1397 "descriptor, I<event_fd>, that was created by a previous call to "
1398 "B<perf_event_open>(2):"
1399 msgstr ""
1400
1401 #. type: Plain text
1402 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1403 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1404 #, no-wrap
1405 msgid "ioctl(event_fd, PERF_EVENT_IOC_SET_BPF, prog_fd);\n"
1406 msgstr ""
1407
1408 #. type: SH
1409 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1410 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1411 #, no-wrap
1412 msgid "RETURN VALUE"
1413 msgstr ""
1414
1415 #. type: Plain text
1416 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1417 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1418 msgid "For a successful call, the return value depends on the operation:"
1419 msgstr ""
1420
1421 #. type: Plain text
1422 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1423 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1424 msgid "The new file descriptor associated with the eBPF map."
1425 msgstr ""
1426
1427 #. type: Plain text
1428 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1429 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1430 msgid "The new file descriptor associated with the eBPF program."
1431 msgstr ""
1432
1433 #. type: TP
1434 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1435 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1436 #, no-wrap
1437 msgid "All other commands"
1438 msgstr ""
1439
1440 #. type: Plain text
1441 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1442 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1443 msgid "Zero."
1444 msgstr ""
1445
1446 #. type: Plain text
1447 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1448 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1449 msgid "On error, -1 is returned, and I<errno> is set to indicate the error."
1450 msgstr ""
1451
1452 #. type: SH
1453 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1454 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1455 #, no-wrap
1456 msgid "ERRORS"
1457 msgstr ""
1458
1459 #. type: TP
1460 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1461 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1462 #, no-wrap
1463 msgid "B<E2BIG>"
1464 msgstr ""
1465
1466 #. type: Plain text
1467 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1468 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1469 msgid ""
1470 "The eBPF program is too large or a map reached the I<max_entries> limit "
1471 "(maximum number of elements)."
1472 msgstr ""
1473
1474 #. type: TP
1475 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1476 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1477 #, no-wrap
1478 msgid "B<EACCES>"
1479 msgstr ""
1480
1481 #. type: Plain text
1482 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1483 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1484 msgid ""
1485 "For B<BPF_PROG_LOAD>, even though all program instructions are valid, the "
1486 "program has been rejected because it was deemed unsafe. This may be because "
1487 "it may have accessed a disallowed memory region or an uninitialized stack/"
1488 "register or because the function constraints don't match the actual types or "
1489 "because there was a misaligned memory access. In this case, it is "
1490 "recommended to call B<bpf>() again with I<log_level = 1> and examine "
1491 "I<log_buf> for the specific reason provided by the verifier."
1492 msgstr ""
1493
1494 #. type: TP
1495 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1496 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1497 #, no-wrap
1498 msgid "B<EAGAIN>"
1499 msgstr ""
1500
1501 #. type: Plain text
1502 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1503 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1504 msgid ""
1505 "For B<BPF_PROG_LOAD>, indicates that needed resources are blocked. This "
1506 "happens when the verifier detects pending signals while it is checking the "
1507 "validity of the bpf program. In this case, just call B<bpf>() again with "
1508 "the same parameters."
1509 msgstr ""
1510
1511 #. type: TP
1512 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1513 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1514 #, no-wrap
1515 msgid "B<EBADF>"
1516 msgstr ""
1517
1518 #. type: Plain text
1519 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1520 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1521 msgid "I<fd> is not an open file descriptor."
1522 msgstr ""
1523
1524 #. type: TP
1525 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1526 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1527 #, no-wrap
1528 msgid "B<EFAULT>"
1529 msgstr ""
1530
1531 #. type: Plain text
1532 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1533 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1534 msgid ""
1535 "One of the pointers (I<key> or I<value> or I<log_buf> or I<insns>) is "
1536 "outside the accessible address space."
1537 msgstr ""
1538
1539 #. type: TP
1540 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1541 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1542 #, no-wrap
1543 msgid "B<EINVAL>"
1544 msgstr ""
1545
1546 #. type: Plain text
1547 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1548 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1549 msgid "The value specified in I<cmd> is not recognized by this kernel."
1550 msgstr ""
1551
1552 #. type: Plain text
1553 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1554 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1555 msgid "For B<BPF_MAP_CREATE>, either I<map_type> or attributes are invalid."
1556 msgstr ""
1557
1558 #. type: Plain text
1559 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1560 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1561 msgid ""
1562 "For B<BPF_MAP_*_ELEM> commands, some of the fields of I<union bpf_attr> that "
1563 "are not used by this command are not set to zero."
1564 msgstr ""
1565
1566 #. type: Plain text
1567 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1568 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1569 msgid ""
1570 "For B<BPF_PROG_LOAD>, indicates an attempt to load an invalid program. eBPF "
1571 "programs can be deemed invalid due to unrecognized instructions, the use of "
1572 "reserved fields, jumps out of range, infinite loops or calls of unknown "
1573 "functions."
1574 msgstr ""
1575
1576 #. type: TP
1577 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1578 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1579 #, no-wrap
1580 msgid "B<ENOENT>"
1581 msgstr ""
1582
1583 #. type: Plain text
1584 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1585 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1586 msgid ""
1587 "For B<BPF_MAP_LOOKUP_ELEM> or B<BPF_MAP_DELETE_ELEM>, indicates that the "
1588 "element with the given I<key> was not found."
1589 msgstr ""
1590
1591 #. type: TP
1592 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1593 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1594 #, no-wrap
1595 msgid "B<ENOMEM>"
1596 msgstr ""
1597
1598 #. type: Plain text
1599 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1600 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1601 msgid "Cannot allocate sufficient memory."
1602 msgstr ""
1603
1604 #. type: TP
1605 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1606 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1607 #, no-wrap
1608 msgid "B<EPERM>"
1609 msgstr ""
1610
1611 #. type: Plain text
1612 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1613 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1614 msgid ""
1615 "The call was made without sufficient privilege (without the B<CAP_SYS_ADMIN> "
1616 "capability)."
1617 msgstr ""
1618
1619 #. type: SH
1620 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1621 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1622 #, no-wrap
1623 msgid "STANDARDS"
1624 msgstr ""
1625
1626 #. type: Plain text
1627 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1628 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1629 msgid "Linux."
1630 msgstr ""
1631
1632 #. type: SH
1633 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1634 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1635 #, no-wrap
1636 msgid "HISTORY"
1637 msgstr ""
1638
1639 #. type: Plain text
1640 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1641 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1642 msgid "Linux 3.18."
1643 msgstr ""
1644
1645 #. type: SH
1646 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1647 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1648 #, no-wrap
1649 msgid "NOTES"
1650 msgstr ""
1651
1652 #. commit 1be7f75d1668d6296b80bf35dcf6762393530afc
1653 #. [Linux 5.6] mtk: The list of available functions is, I think, governed
1654 #. by the check in net/core/filter.c::bpf_base_func_proto().
1655 #. type: Plain text
1656 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1657 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1658 msgid ""
1659 "Prior to Linux 4.4, all B<bpf>() commands require the caller to have the "
1660 "B<CAP_SYS_ADMIN> capability. From Linux 4.4 onwards, an unprivileged user "
1661 "may create limited programs of type B<BPF_PROG_TYPE_SOCKET_FILTER> and "
1662 "associated maps. However they may not store kernel pointers within the maps "
1663 "and are presently limited to the following helper functions:"
1664 msgstr ""
1665
1666 #. type: Plain text
1667 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1668 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1669 msgid "get_random"
1670 msgstr ""
1671
1672 #. type: Plain text
1673 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1674 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1675 msgid "get_smp_processor_id"
1676 msgstr ""
1677
1678 #. type: Plain text
1679 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1680 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1681 msgid "tail_call"
1682 msgstr ""
1683
1684 #. type: Plain text
1685 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1686 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1687 msgid "ktime_get_ns"
1688 msgstr ""
1689
1690 #. type: Plain text
1691 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1692 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1693 msgid ""
1694 "Unprivileged access may be blocked by writing the value 1 to the file I</"
1695 "proc/sys/kernel/unprivileged_bpf_disabled>."
1696 msgstr ""
1697
1698 #. type: Plain text
1699 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1700 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1701 msgid ""
1702 "eBPF objects (maps and programs) can be shared between processes. For "
1703 "example, after B<fork>(2), the child inherits file descriptors referring to "
1704 "the same eBPF objects. In addition, file descriptors referring to eBPF "
1705 "objects can be transferred over UNIX domain sockets. File descriptors "
1706 "referring to eBPF objects can be duplicated in the usual way, using "
1707 "B<dup>(2) and similar calls. An eBPF object is deallocated only after all "
1708 "file descriptors referring to the object have been closed."
1709 msgstr ""
1710
1711 #. There are also examples for the tc classifier, in the iproute2
1712 #. project, in examples/bpf
1713 #. type: Plain text
1714 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1715 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1716 msgid ""
1717 "eBPF programs can be written in a restricted C that is compiled (using the "
1718 "B<clang> compiler) into eBPF bytecode. Various features are omitted from "
1719 "this restricted C, such as loops, global variables, variadic functions, "
1720 "floating-point numbers, and passing structures as function arguments. Some "
1721 "examples can be found in the I<samples/bpf/*_kern.c> files in the kernel "
1722 "source tree."
1723 msgstr ""
1724
1725 #. type: Plain text
1726 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1727 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1728 msgid ""
1729 "The kernel contains a just-in-time (JIT) compiler that translates eBPF "
1730 "bytecode into native machine code for better performance. Before Linux "
1731 "4.15, the JIT compiler is disabled by default, but its operation can be "
1732 "controlled by writing one of the following integer strings to the file I</"
1733 "proc/sys/net/core/bpf_jit_enable>:"
1734 msgstr ""
1735
1736 #. type: TP
1737 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1738 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1739 #, no-wrap
1740 msgid "B<0>"
1741 msgstr ""
1742
1743 #. type: Plain text
1744 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1745 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1746 msgid "Disable JIT compilation (default)."
1747 msgstr ""
1748
1749 #. type: TP
1750 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1751 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1752 #, no-wrap
1753 msgid "B<1>"
1754 msgstr ""
1755
1756 #. type: Plain text
1757 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1758 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1759 msgid "Normal compilation."
1760 msgstr ""
1761
1762 #. type: TP
1763 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1764 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1765 #, no-wrap
1766 msgid "B<2>"
1767 msgstr ""
1768
1769 #. type: Plain text
1770 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1771 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1772 msgid ""
1773 "Debugging mode. The generated opcodes are dumped in hexadecimal into the "
1774 "kernel log. These opcodes can then be disassembled using the program "
1775 "I<tools/net/bpf_jit_disasm.c> provided in the kernel source tree."
1776 msgstr ""
1777
1778 #. commit 290af86629b25ffd1ed6232c4e9107da031705cb
1779 #. type: Plain text
1780 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1781 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1782 msgid ""
1783 "Since Linux 4.15, the kernel may be configured with the "
1784 "B<CONFIG_BPF_JIT_ALWAYS_ON> option. In this case, the JIT compiler is "
1785 "always enabled, and the I<bpf_jit_enable> is initialized to 1 and is "
1786 "immutable. (This kernel configuration option was provided as a mitigation "
1787 "for one of the Spectre attacks against the BPF interpreter.)"
1788 msgstr ""
1789
1790 #. #-#-#-#-# archlinux: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1791 #. type: Plain text
1792 #. #-#-#-#-# debian-trixie: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1793 #. Last reviewed in Linux 4.18-rc by grepping for BPF_ALU64 in arch/
1794 #. and by checking the documentation for bpf_jit_enable in
1795 #. Documentation/sysctl/net.txt
1796 #. type: Plain text
1797 #. #-#-#-#-# debian-unstable: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1798 #. type: Plain text
1799 #. #-#-#-#-# fedora-44: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1800 #. Last reviewed in Linux 4.18-rc by grepping for BPF_ALU64 in arch/
1801 #. and by checking the documentation for bpf_jit_enable in
1802 #. Documentation/sysctl/net.txt
1803 #. type: Plain text
1804 #. #-#-#-#-# fedora-rawhide: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1805 #. Last reviewed in Linux 4.18-rc by grepping for BPF_ALU64 in arch/
1806 #. and by checking the documentation for bpf_jit_enable in
1807 #. Documentation/sysctl/net.txt
1808 #. type: Plain text
1809 #. #-#-#-#-# mageia-cauldron: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1810 #. type: Plain text
1811 #. #-#-#-#-# opensuse-leap-16-1: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1812 #. type: Plain text
1813 #. #-#-#-#-# opensuse-tumbleweed: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1814 #. type: Plain text
1815 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1816 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1817 msgid ""
1818 "The JIT compiler for eBPF is currently available for the following "
1819 "architectures:"
1820 msgstr ""
1821
1822 #. commit 0a14842f5a3c0e88a1e59fac5c3025db39721f74
1823 #. type: Plain text
1824 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1825 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1826 msgid "x86-64 (since Linux 3.18; cBPF since Linux 3.0);"
1827 msgstr ""
1828
1829 #. commit ddecdfcea0ae891f782ae853771c867ab51024c2
1830 #. type: Plain text
1831 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1832 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1833 msgid "ARM32 (since Linux 3.18; cBPF since Linux 3.4);"
1834 msgstr ""
1835
1836 #. commit 2809a2087cc44b55e4377d7b9be3f7f5d2569091
1837 #. type: Plain text
1838 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1839 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1840 msgid "SPARC 32 (since Linux 3.18; cBPF since Linux 3.5);"
1841 msgstr ""
1842
1843 #. commit e54bcde3d69d40023ae77727213d14f920eb264a
1844 #. type: Plain text
1845 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1846 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1847 msgid "ARM-64 (since Linux 3.18);"
1848 msgstr ""
1849
1850 #. commit c10302efe569bfd646b4c22df29577a4595b4580
1851 #. type: Plain text
1852 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1853 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1854 msgid "s390 (since Linux 4.1; cBPF since Linux 3.7);"
1855 msgstr ""
1856
1857 #. commit 0ca87f05ba8bdc6791c14878464efc901ad71e99
1858 #. commit 156d0e290e969caba25f1851c52417c14d141b24
1859 #. type: Plain text
1860 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1861 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1862 msgid "PowerPC 64 (since Linux 4.8; cBPF since Linux 3.1);"
1863 msgstr ""
1864
1865 #. commit 7a12b5031c6b947cc13918237ae652b536243b76
1866 #. type: Plain text
1867 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1868 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1869 msgid "SPARC 64 (since Linux 4.12);"
1870 msgstr ""
1871
1872 #. commit 03f5781be2c7b7e728d724ac70ba10799cc710d7
1873 #. type: Plain text
1874 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1875 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1876 msgid "x86-32 (since Linux 4.18);"
1877 msgstr ""
1878
1879 #. commit c6610de353da5ca6eee5b8960e838a87a90ead0c
1880 #. commit f381bf6d82f032b7410185b35d000ea370ac706b
1881 #. type: Plain text
1882 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1883 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1884 msgid "MIPS 64 (since Linux 4.18; cBPF since Linux 3.16);"
1885 msgstr ""
1886
1887 #. commit 2353ecc6f91fd15b893fa01bf85a1c7a823ee4f2
1888 #. type: Plain text
1889 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1890 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1891 msgid "riscv (since Linux 5.1)."
1892 msgstr ""
1893
1894 #. type: SH
1895 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1896 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1897 #, no-wrap
1898 msgid "EXAMPLES"
1899 msgstr ""
1900
1901 #. == atomic64_add
1902 #. type: Plain text
1903 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1904 #: opensuse-tumbleweed
1905 #, no-wrap
1906 msgid ""
1907 "#include E<lt>stdcountof.hE<gt>\n"
1908 "\\&\n"
1909 "/* bpf+sockets example:\n"
1910 " * 1. create array map of 256 elements\n"
1911 " * 2. load program that counts number of packets received\n"
1912 " * r0 = skb-E<gt>data[ETH_HLEN + offsetof(struct iphdr, protocol)]\n"
1913 " * map[r0]++\n"
1914 " * 3. attach prog_fd to raw socket via setsockopt()\n"
1915 " * 4. print number of received TCP/UDP packets every second\n"
1916 " */\n"
1917 "int\n"
1918 "main(int argc, char *argv[])\n"
1919 "{\n"
1920 " int sock, map_fd, prog_fd, key;\n"
1921 " long long value = 0, tcp_cnt, udp_cnt;\n"
1922 "\\&\n"
1923 " map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(key),\n"
1924 " sizeof(value), 256);\n"
1925 " if (map_fd E<lt> 0) {\n"
1926 " printf(\"failed to create map \\[aq]%s\\[aq]\\[rs]n\", strerror(errno));\n"
1927 " /* likely not run as root */\n"
1928 " return 1;\n"
1929 " }\n"
1930 "\\&\n"
1931 " struct bpf_insn prog[] = {\n"
1932 " BPF_MOV64_REG(BPF_REG_6, BPF_REG_1), /* r6 = r1 */\n"
1933 " BPF_LD_ABS(BPF_B, ETH_HLEN + offsetof(struct iphdr, protocol)),\n"
1934 " /* r0 = ip-E<gt>proto */\n"
1935 " BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_0, -4),\n"
1936 " /* *(u32 *) (fp - 4) = r0 */\n"
1937 " BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), /* r2 = fp */\n"
1938 " BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -4), /* r2 = r2 - 4 */\n"
1939 " BPF_LD_MAP_FD(BPF_REG_1, map_fd), /* r1 = map_fd */\n"
1940 " BPF_CALL_FUNC(BPF_FUNC_map_lookup_elem),\n"
1941 " /* r0 = map_lookup(r1, r2) */\n"
1942 " BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 2),\n"
1943 " /* if (r0 == 0) goto pc+2 */\n"
1944 " BPF_MOV64_IMM(BPF_REG_1, 1), /* r1 = 1 */\n"
1945 " BPF_XADD(BPF_DW, BPF_REG_0, BPF_REG_1, 0, 0),\n"
1946 " /* lock *(u64 *) r0 += r1 */\n"
1947 " BPF_MOV64_IMM(BPF_REG_0, 0), /* r0 = 0 */\n"
1948 " BPF_EXIT_INSN(), /* return r0 */\n"
1949 " };\n"
1950 "\\&\n"
1951 " prog_fd = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, prog,\n"
1952 " countof(prog), \"GPL\");\n"
1953 "\\&\n"
1954 " sock = open_raw_sock(\"lo\");\n"
1955 "\\&\n"
1956 " assert(setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, &prog_fd,\n"
1957 " sizeof(prog_fd)) == 0);\n"
1958 "\\&\n"
1959 " for (;;) {\n"
1960 " key = IPPROTO_TCP;\n"
1961 " assert(bpf_lookup_elem(map_fd, &key, &tcp_cnt) == 0);\n"
1962 " key = IPPROTO_UDP;\n"
1963 " assert(bpf_lookup_elem(map_fd, &key, &udp_cnt) == 0);\n"
1964 " printf(\"TCP %lld UDP %lld packets\\[rs]n\", tcp_cnt, udp_cnt);\n"
1965 " sleep(1);\n"
1966 " }\n"
1967 "\\&\n"
1968 " return 0;\n"
1969 "}\n"
1970 msgstr ""
1971
1972 #. type: Plain text
1973 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1974 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1975 msgid ""
1976 "Some complete working code can be found in the I<samples/bpf> directory in "
1977 "the kernel source tree."
1978 msgstr ""
1979
1980 #. type: SH
1981 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1982 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1983 #, no-wrap
1984 msgid "SEE ALSO"
1985 msgstr ""
1986
1987 #. type: Plain text
1988 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1989 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1990 msgid "B<seccomp>(2), B<bpf-helpers>(7), B<socket>(7), B<tc>(8), B<tc-bpf>(8)"
1991 msgstr ""
1992
1993 #. type: Plain text
1994 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1995 #: opensuse-tumbleweed
1996 msgid ""
1997 "Both classic and extended BPF are explained in the kernel source file "
1998 "I<Documentation/networking/filter.rst>."
1999 msgstr ""
2000
2001 #. type: TH
2002 #: debian-trixie
2003 #, no-wrap
2004 msgid "2024-06-15"
2005 msgstr ""
2006
2007 #. type: TH
2008 #: debian-trixie
2009 #, no-wrap
2010 msgid "Linux man-pages 6.9.1"
2011 msgstr ""
2012
2013 #. type: Plain text
2014 #: debian-trixie fedora-44 fedora-rawhide
2015 #, no-wrap
2016 msgid ""
2017 "enum bpf_map_type {\n"
2018 " BPF_MAP_TYPE_UNSPEC, /* Reserve 0 as invalid map type */\n"
2019 " BPF_MAP_TYPE_HASH,\n"
2020 " BPF_MAP_TYPE_ARRAY,\n"
2021 " BPF_MAP_TYPE_PROG_ARRAY,\n"
2022 " BPF_MAP_TYPE_PERF_EVENT_ARRAY,\n"
2023 " BPF_MAP_TYPE_PERCPU_HASH,\n"
2024 " BPF_MAP_TYPE_PERCPU_ARRAY,\n"
2025 " BPF_MAP_TYPE_STACK_TRACE,\n"
2026 " BPF_MAP_TYPE_CGROUP_ARRAY,\n"
2027 " BPF_MAP_TYPE_LRU_HASH,\n"
2028 " BPF_MAP_TYPE_LRU_PERCPU_HASH,\n"
2029 " BPF_MAP_TYPE_LPM_TRIE,\n"
2030 " BPF_MAP_TYPE_ARRAY_OF_MAPS,\n"
2031 " BPF_MAP_TYPE_HASH_OF_MAPS,\n"
2032 " BPF_MAP_TYPE_DEVMAP,\n"
2033 " BPF_MAP_TYPE_SOCKMAP,\n"
2034 " BPF_MAP_TYPE_CPUMAP,\n"
2035 " BPF_MAP_TYPE_XSKMAP,\n"
2036 " BPF_MAP_TYPE_SOCKHASH,\n"
2037 " BPF_MAP_TYPE_CGROUP_STORAGE,\n"
2038 " BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,\n"
2039 " BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,\n"
2040 " BPF_MAP_TYPE_QUEUE,\n"
2041 " BPF_MAP_TYPE_STACK,\n"
2042 " /* See /usr/include/linux/bpf.h for the full list. */\n"
2043 "};\n"
2044 msgstr ""
2045
2046 #. type: Plain text
2047 #: debian-trixie fedora-44 fedora-rawhide
2048 #, no-wrap
2049 msgid ""
2050 "enum bpf_prog_type {\n"
2051 " BPF_PROG_TYPE_UNSPEC, /* Reserve 0 as invalid\n"
2052 " program type */\n"
2053 " BPF_PROG_TYPE_SOCKET_FILTER,\n"
2054 " BPF_PROG_TYPE_KPROBE,\n"
2055 " BPF_PROG_TYPE_SCHED_CLS,\n"
2056 " BPF_PROG_TYPE_SCHED_ACT,\n"
2057 " BPF_PROG_TYPE_TRACEPOINT,\n"
2058 " BPF_PROG_TYPE_XDP,\n"
2059 " BPF_PROG_TYPE_PERF_EVENT,\n"
2060 " BPF_PROG_TYPE_CGROUP_SKB,\n"
2061 " BPF_PROG_TYPE_CGROUP_SOCK,\n"
2062 " BPF_PROG_TYPE_LWT_IN,\n"
2063 " BPF_PROG_TYPE_LWT_OUT,\n"
2064 " BPF_PROG_TYPE_LWT_XMIT,\n"
2065 " BPF_PROG_TYPE_SOCK_OPS,\n"
2066 " BPF_PROG_TYPE_SK_SKB,\n"
2067 " BPF_PROG_TYPE_CGROUP_DEVICE,\n"
2068 " BPF_PROG_TYPE_SK_MSG,\n"
2069 " BPF_PROG_TYPE_RAW_TRACEPOINT,\n"
2070 " BPF_PROG_TYPE_CGROUP_SOCK_ADDR,\n"
2071 " BPF_PROG_TYPE_LWT_SEG6LOCAL,\n"
2072 " BPF_PROG_TYPE_LIRC_MODE2,\n"
2073 " BPF_PROG_TYPE_SK_REUSEPORT,\n"
2074 " BPF_PROG_TYPE_FLOW_DISSECTOR,\n"
2075 " /* See /usr/include/linux/bpf.h for the full list. */\n"
2076 "};\n"
2077 msgstr ""
2078
2079 #. == atomic64_add
2080 #. type: Plain text
2081 #: debian-trixie
2082 #, no-wrap
2083 msgid ""
2084 "/* bpf+sockets example:\n"
2085 " * 1. create array map of 256 elements\n"
2086 " * 2. load program that counts number of packets received\n"
2087 " * r0 = skb-E<gt>data[ETH_HLEN + offsetof(struct iphdr, protocol)]\n"
2088 " * map[r0]++\n"
2089 " * 3. attach prog_fd to raw socket via setsockopt()\n"
2090 " * 4. print number of received TCP/UDP packets every second\n"
2091 " */\n"
2092 "int\n"
2093 "main(int argc, char *argv[])\n"
2094 "{\n"
2095 " int sock, map_fd, prog_fd, key;\n"
2096 " long long value = 0, tcp_cnt, udp_cnt;\n"
2097 "\\&\n"
2098 " map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(key),\n"
2099 " sizeof(value), 256);\n"
2100 " if (map_fd E<lt> 0) {\n"
2101 " printf(\"failed to create map \\[aq]%s\\[aq]\\[rs]n\", strerror(errno));\n"
2102 " /* likely not run as root */\n"
2103 " return 1;\n"
2104 " }\n"
2105 "\\&\n"
2106 " struct bpf_insn prog[] = {\n"
2107 " BPF_MOV64_REG(BPF_REG_6, BPF_REG_1), /* r6 = r1 */\n"
2108 " BPF_LD_ABS(BPF_B, ETH_HLEN + offsetof(struct iphdr, protocol)),\n"
2109 " /* r0 = ip-E<gt>proto */\n"
2110 " BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_0, -4),\n"
2111 " /* *(u32 *)(fp - 4) = r0 */\n"
2112 " BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), /* r2 = fp */\n"
2113 " BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -4), /* r2 = r2 - 4 */\n"
2114 " BPF_LD_MAP_FD(BPF_REG_1, map_fd), /* r1 = map_fd */\n"
2115 " BPF_CALL_FUNC(BPF_FUNC_map_lookup_elem),\n"
2116 " /* r0 = map_lookup(r1, r2) */\n"
2117 " BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 2),\n"
2118 " /* if (r0 == 0) goto pc+2 */\n"
2119 " BPF_MOV64_IMM(BPF_REG_1, 1), /* r1 = 1 */\n"
2120 " BPF_XADD(BPF_DW, BPF_REG_0, BPF_REG_1, 0, 0),\n"
2121 " /* lock *(u64 *) r0 += r1 */\n"
2122 " BPF_MOV64_IMM(BPF_REG_0, 0), /* r0 = 0 */\n"
2123 " BPF_EXIT_INSN(), /* return r0 */\n"
2124 " };\n"
2125 "\\&\n"
2126 " prog_fd = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, prog,\n"
2127 " sizeof(prog) / sizeof(prog[0]), \"GPL\");\n"
2128 "\\&\n"
2129 " sock = open_raw_sock(\"lo\");\n"
2130 "\\&\n"
2131 " assert(setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, &prog_fd,\n"
2132 " sizeof(prog_fd)) == 0);\n"
2133 "\\&\n"
2134 " for (;;) {\n"
2135 " key = IPPROTO_TCP;\n"
2136 " assert(bpf_lookup_elem(map_fd, &key, &tcp_cnt) == 0);\n"
2137 " key = IPPROTO_UDP;\n"
2138 " assert(bpf_lookup_elem(map_fd, &key, &udp_cnt) == 0);\n"
2139 " printf(\"TCP %lld UDP %lld packets\\[rs]n\", tcp_cnt, udp_cnt);\n"
2140 " sleep(1);\n"
2141 " }\n"
2142 "\\&\n"
2143 " return 0;\n"
2144 "}\n"
2145 msgstr ""
2146
2147 #. type: Plain text
2148 #: debian-trixie fedora-44 fedora-rawhide
2149 msgid ""
2150 "Both classic and extended BPF are explained in the kernel source file "
2151 "I<Documentation/networking/filter.txt>."
2152 msgstr ""
2153
2154 #. type: TH
2155 #: fedora-44 fedora-rawhide
2156 #, no-wrap
2157 msgid "2025-01-05"
2158 msgstr ""
2159
2160 #. type: TH
2161 #: fedora-44 fedora-rawhide
2162 #, no-wrap
2163 msgid "Linux man-pages 6.13"
2164 msgstr ""
2165
2166 #. == atomic64_add
2167 #. type: Plain text
2168 #: fedora-44 fedora-rawhide
2169 #, no-wrap
2170 msgid ""
2171 "/* bpf+sockets example:\n"
2172 " * 1. create array map of 256 elements\n"
2173 " * 2. load program that counts number of packets received\n"
2174 " * r0 = skb-E<gt>data[ETH_HLEN + offsetof(struct iphdr, protocol)]\n"
2175 " * map[r0]++\n"
2176 " * 3. attach prog_fd to raw socket via setsockopt()\n"
2177 " * 4. print number of received TCP/UDP packets every second\n"
2178 " */\n"
2179 "int\n"
2180 "main(int argc, char *argv[])\n"
2181 "{\n"
2182 " int sock, map_fd, prog_fd, key;\n"
2183 " long long value = 0, tcp_cnt, udp_cnt;\n"
2184 "\\&\n"
2185 " map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(key),\n"
2186 " sizeof(value), 256);\n"
2187 " if (map_fd E<lt> 0) {\n"
2188 " printf(\"failed to create map \\[aq]%s\\[aq]\\[rs]n\", strerror(errno));\n"
2189 " /* likely not run as root */\n"
2190 " return 1;\n"
2191 " }\n"
2192 "\\&\n"
2193 " struct bpf_insn prog[] = {\n"
2194 " BPF_MOV64_REG(BPF_REG_6, BPF_REG_1), /* r6 = r1 */\n"
2195 " BPF_LD_ABS(BPF_B, ETH_HLEN + offsetof(struct iphdr, protocol)),\n"
2196 " /* r0 = ip-E<gt>proto */\n"
2197 " BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_0, -4),\n"
2198 " /* *(u32 *) (fp - 4) = r0 */\n"
2199 " BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), /* r2 = fp */\n"
2200 " BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -4), /* r2 = r2 - 4 */\n"
2201 " BPF_LD_MAP_FD(BPF_REG_1, map_fd), /* r1 = map_fd */\n"
2202 " BPF_CALL_FUNC(BPF_FUNC_map_lookup_elem),\n"
2203 " /* r0 = map_lookup(r1, r2) */\n"
2204 " BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 2),\n"
2205 " /* if (r0 == 0) goto pc+2 */\n"
2206 " BPF_MOV64_IMM(BPF_REG_1, 1), /* r1 = 1 */\n"
2207 " BPF_XADD(BPF_DW, BPF_REG_0, BPF_REG_1, 0, 0),\n"
2208 " /* lock *(u64 *) r0 += r1 */\n"
2209 " BPF_MOV64_IMM(BPF_REG_0, 0), /* r0 = 0 */\n"
2210 " BPF_EXIT_INSN(), /* return r0 */\n"
2211 " };\n"
2212 "\\&\n"
2213 " prog_fd = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, prog,\n"
2214 " sizeof(prog) / sizeof(prog[0]), \"GPL\");\n"
2215 "\\&\n"
2216 " sock = open_raw_sock(\"lo\");\n"
2217 "\\&\n"
2218 " assert(setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, &prog_fd,\n"
2219 " sizeof(prog_fd)) == 0);\n"
2220 "\\&\n"
2221 " for (;;) {\n"
2222 " key = IPPROTO_TCP;\n"
2223 " assert(bpf_lookup_elem(map_fd, &key, &tcp_cnt) == 0);\n"
2224 " key = IPPROTO_UDP;\n"
2225 " assert(bpf_lookup_elem(map_fd, &key, &udp_cnt) == 0);\n"
2226 " printf(\"TCP %lld UDP %lld packets\\[rs]n\", tcp_cnt, udp_cnt);\n"
2227 " sleep(1);\n"
2228 " }\n"
2229 "\\&\n"
2230 " return 0;\n"
2231 "}\n"
2232 msgstr ""
2233
2234 #. type: TH
2235 #: mageia-cauldron
2236 #, no-wrap
2237 msgid "Linux man-pages 6.17"
2238 msgstr ""
2239
2240 #. type: TH
2241 #: opensuse-leap-16-1 opensuse-tumbleweed
2242 #, no-wrap
2243 msgid "Linux man-pages (unreleased)"
2244 msgstr ""