Debian Codegraph @

po/ru/man2/bpf.2.po

raw
1 # Russian translation of manpages
2 # This file is distributed under the same license as the manpages-l10n package.
3 # Copyright © of this file:
4 # Aleksandr Felda <[email protected]>, 2024.
5 msgid ""
6 msgstr ""
7 "Project-Id-Version: manpages-l10n 4.24.0\n"
8 "POT-Creation-Date: 2026-06-05 06:19+0200\n"
9 "PO-Revision-Date: 2024-12-21 19:49+0300\n"
10 "Last-Translator: Aleksandr Felda <[email protected]>\n"
11 "Language-Team: Russian <[email protected]>\n"
12 "Language: ru\n"
13 "MIME-Version: 1.0\n"
14 "Content-Type: text/plain; charset=UTF-8\n"
15 "Content-Transfer-Encoding: 8bit\n"
16 "X-Generator: Poedit 3.2.2\n"
17
18 #. type: TH
19 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
20 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
21 #, no-wrap
22 msgid "bpf"
23 msgstr "bpf"
24
25 #. type: TH
26 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
27 #: opensuse-tumbleweed
28 #, no-wrap
29 msgid "2026-02-10"
30 msgstr "10 февраля 2026 г."
31
32 #. type: TH
33 #: archlinux debian-unstable
34 #, fuzzy, no-wrap
35 #| msgid "Linux man-pages 6.17"
36 msgid "Linux man-pages 6.18"
37 msgstr "Справочные страницы Linux 6.17"
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 "bpf - выполнение команды с расширенной картой или программой BPF"
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 "B<#include E<lt>linux/bpf.hE<gt>>\n"
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 "B<int bpf(int >I<cmd>B<, union bpf_attr *>I<attr>B<, unsigned int >I<size>B<);>\n"
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 "Системный вызов B<bpf>() выполняет ряд операций, связанных с дополнительными "
91 "пакетными фильтрами Berkeley. Дополнительный BPF (или eBPF) аналогичен "
92 "оригинальному (\"классическому\") BPF, используемому для фильтрации сетевых "
93 "пакетов. Как для программ cBPF, так и для eBPF ядро статически анализирует "
94 "программы перед их загрузкой, чтобы убедиться, что они не могут нанести вред "
95 "работающей системе."
96
97 #. See 'enum bpf_func_id' in include/uapi/linux/bpf.h
98 #. type: Plain text
99 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
100 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
101 msgid ""
102 "eBPF extends cBPF in multiple ways, including the ability to call a fixed "
103 "set of in-kernel helper functions (via the B<BPF_CALL> opcode extension "
104 "provided by eBPF) and access shared data structures such as eBPF maps."
105 msgstr ""
106 "eBPF дополняет cBPF несколькими способами, включая возможность вызова "
107 "фиксированного набора вспомогательных функций в ядре (с помощью "
108 "дополнительного кода операции B<BPF_CALL>, предоставляемого eBPF) и доступа "
109 "к общим структурам данных, таким как карты eBPF."
110
111 #. type: SS
112 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
113 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
114 #, no-wrap
115 msgid "Extended BPF Design/Architecture"
116 msgstr "Дополнительная конструкция/архитектура BPF"
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 "eBPF maps are a generic data structure for storage of different data types. "
123 "Data types are generally treated as binary blobs, so a user just specifies "
124 "the size of the key and the size of the value at map-creation time. In "
125 "other words, a key/value for a given map can have an arbitrary structure."
126 msgstr ""
127 "Карты eBPF - это универсальная структура данных для хранения различных типов "
128 "данных. Типы данных обычно обрабатываются как большие двоичные, поэтому "
129 "пользователь просто указывает размер ключа и размер значения во время "
130 "создания карты. Другими словами, ключ/значение для данной карты могут иметь "
131 "произвольную структуру."
132
133 #. type: Plain text
134 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
135 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
136 msgid ""
137 "A user process can create multiple maps (with key/value-pairs being opaque "
138 "bytes of data) and access them via file descriptors. Different eBPF "
139 "programs can access the same maps in parallel. It's up to the user process "
140 "and eBPF program to decide what they store inside maps."
141 msgstr ""
142 "Пользовательский процесс может создавать несколько карт (с парами ключ/"
143 "значение, представляющими собой непрозрачные байты данных) и получать к ним "
144 "доступ через файловые дескрипторы. Различные программы eBPF могут "
145 "параллельно получать доступ к одним и тем же картам."
146
147 #. Defined by the kernel constant MAX_TAIL_CALL_CNT in include/linux/bpf.h
148 #. type: Plain text
149 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
150 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
151 msgid ""
152 "There's one special map type, called a program array. This type of map "
153 "stores file descriptors referring to other eBPF programs. When a lookup in "
154 "the map is performed, the program flow is redirected in-place to the "
155 "beginning of another eBPF program and does not return back to the calling "
156 "program. The level of nesting has a fixed limit of 32, so that infinite "
157 "loops cannot be crafted. At run time, the program file descriptors stored "
158 "in the map can be modified, so program functionality can be altered based on "
159 "specific requirements. All programs referred to in a program-array map must "
160 "have been previously loaded into the kernel via B<bpf>(). If a map lookup "
161 "fails, the current program continues its execution. See "
162 "B<BPF_MAP_TYPE_PROG_ARRAY> below for further details."
163 msgstr ""
164 "Существует один особый тип карт, называемый программным массивом. Этот тип "
165 "карты хранит файловые дескрипторы, относящиеся к другим программам eBPF. "
166 "Когда выполняется поиск по карте, поток выполнения программы "
167 "перенаправляется на месте к началу другой программы eBPF и не возвращается "
168 "обратно к вызывающей программе. Уровень вложенности имеет фиксированное "
169 "ограничение в 32, так что бесконечные циклы не могут быть созданы. Во время "
170 "выполнения дескрипторы программных файлов, хранящиеся на карте, могут быть "
171 "изменены, поэтому функциональность программы может быть изменена в "
172 "зависимости от конкретных требований. Все программы, упомянутые в карте "
173 "программных массивов, должны быть предварительно загружены в ядро с помощью "
174 "функции B<bpf>(). Если поиск по карте завершается неудачей, текущая "
175 "программа продолжает свое выполнение. Смотрите ниже "
176 "B<BPF_MAP_TYPE_PROG_ARRAY> для получения более подробной информации."
177
178 #. type: Plain text
179 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
180 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
181 msgid ""
182 "Generally, eBPF programs are loaded by the user process and automatically "
183 "unloaded when the process exits. In some cases, for example, B<tc-bpf>(8), "
184 "the program will continue to stay alive inside the kernel even after the "
185 "process that loaded the program exits. In that case, the tc subsystem holds "
186 "a reference to the eBPF program after the file descriptor has been closed by "
187 "the user-space program. Thus, whether a specific program continues to live "
188 "inside the kernel depends on how it is further attached to a given kernel "
189 "subsystem after it was loaded via B<bpf>()."
190 msgstr ""
191 "В основном программы eBPF загружаются пользовательским процессом и "
192 "автоматически выгружаются при завершении процесса. В некоторых случаях, "
193 "например, B<tc-bpf>(8), программа будет продолжать работать внутри ядра даже "
194 "после завершения процесса, который загрузил программу. В этом случае "
195 "подсистема tc хранит ссылку на программу eBPF после того, как файловый "
196 "дескриптор был закрыт программой пользовательского пространства. Таким "
197 "образом, будет ли конкретная программа продолжать работать в ядре, зависит "
198 "от того, как она будет подключена к данной подсистеме ядра после того, как "
199 "она была загружена через B<bpf>()."
200
201 #. type: Plain text
202 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
203 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
204 msgid ""
205 "Each eBPF program is a set of instructions that is safe to run until its "
206 "completion. An in-kernel verifier statically determines that the eBPF "
207 "program terminates and is safe to execute. During verification, the kernel "
208 "increments reference counts for each of the maps that the eBPF program uses, "
209 "so that the attached maps can't be removed until the program is unloaded."
210 msgstr ""
211 "Каждая программа eBPF представляет собой набор инструкций, которые безопасны "
212 "для выполнения до ее завершения. Встроенный в ядро верификатор статически "
213 "определяет, что программа eBPF остановлена и безопасна для выполнения. Во "
214 "время проверки ядро увеличивает количество ссылок для каждой из карт, "
215 "используемых программой eBPF, так что прикрепленные карты не могут быть "
216 "удалены до тех пор, пока программа не будет выгружена."
217
218 #. type: Plain text
219 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
220 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
221 msgid ""
222 "eBPF programs can be attached to different events. These events can be the "
223 "arrival of network packets, tracing events, classification events by network "
224 "queueing disciplines (for eBPF programs attached to a B<tc>(8) classifier), "
225 "and other types that may be added in the future. A new event triggers "
226 "execution of the eBPF program, which may store information about the event "
227 "in eBPF maps. Beyond storing data, eBPF programs may call a fixed set of in-"
228 "kernel helper functions."
229 msgstr ""
230 "Программы eBPF могут быть привязаны к различным событиям. Этими событиями "
231 "могут быть прибытие сетевых пакетов, события трассировки, события "
232 "классификации по правилам сетевого массового обслуживания (для программ "
233 "eBPF, подключенных к классификатору B<tc>(8)), и другие типы, которые могут "
234 "быть добавлены в будущем. Новое событие запускает выполнение программы eBPF, "
235 "которая может сохранять информацию об этом событии в картах eBPF. Помимо "
236 "хранения данных, программы eBPF могут вызывать фиксированный набор "
237 "встроенных в ядро вспомогательных функций."
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 "The same eBPF program can be attached to multiple events and different eBPF "
244 "programs can access the same map:"
245 msgstr ""
246 "Одна и та же программа eBPF может быть привязана к нескольким событиям и "
247 "разные программы eBPF могут получить доступ к одной и той же карте:"
248
249 #. type: Plain text
250 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
251 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
252 #, no-wrap
253 msgid ""
254 "tracing tracing tracing packet packet packet\n"
255 "event A event B event C on eth0 on eth1 on eth2\n"
256 " | | | | | \\[ha]\n"
257 " | | | | v |\n"
258 " --E<gt> tracing E<lt>-- tracing socket tc ingress tc egress\n"
259 " prog_1 prog_2 prog_3 classifier action\n"
260 " | | | | prog_4 prog_5\n"
261 " |--- -----| |------| map_3 | |\n"
262 " map_1 map_2 --| map_4 |--\n"
263 msgstr ""
264 "трассировка трассировка трассировка пакет пакет пакет\n"
265 "событие A событие B событие C на eth0 на eth1 на eth2\n"
266 " | | | | | \\[ha]\n"
267 " | | | | v |\n"
268 " --E<gt> трассировка E<lt>-- трассировка сокет вход tc вход tc\n"
269 " программа_1 программа_2 программа_3 классификатор действие\n"
270 " | | | | программа_4 программа_5\n"
271 " |--- -----| |------| карта_3 | |\n"
272 " карта_1 карта_2 --| карта_4 |--\n"
273
274 #. type: SS
275 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
276 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
277 #, no-wrap
278 msgid "Arguments"
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 ""
285 "The operation to be performed by the B<bpf>() system call is determined by "
286 "the I<cmd> argument. Each operation takes an accompanying argument, "
287 "provided via I<attr>, which is a pointer to a union of type I<bpf_attr> (see "
288 "below). The unused fields and padding must be zeroed out before the call. "
289 "The I<size> argument is the size of the union pointed to by I<attr>."
290 msgstr ""
291 "Операция, которая должна быть выполнена системным вызовом B<bpf>(), "
292 "определяется аргументом I<cmd>. Каждая операция принимает сопутствующий "
293 "аргумент, предоставляемый через I<attr>, который является указателем на "
294 "объединение типа I<bpf_attr> (см. ниже). Неиспользуемые поля и отступы "
295 "должны быть обнулены перед вызовом. Аргумент I<size> - это размер "
296 "объединения, на которое указывает I<attr>."
297
298 #. type: Plain text
299 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
300 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
301 msgid "The value provided in I<cmd> is one of the following:"
302 msgstr "Значение, указанное в I<cmd>, может быть одним из следующих:"
303
304 #. type: TP
305 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
306 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
307 #, no-wrap
308 msgid "B<BPF_MAP_CREATE>"
309 msgstr "B<BPF_MAP_CREATE>"
310
311 #. type: Plain text
312 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
313 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
314 msgid ""
315 "Create a map and return a file descriptor that refers to the map. The close-"
316 "on-exec file descriptor flag (see B<fcntl>(2)) is automatically enabled for "
317 "the new file descriptor."
318 msgstr ""
319 "Создать карту и вернуть файловый дескриптор, который ссылается на карту. "
320 "Флаг дескриптора файла close-on-exec (см. B<fcntl>(2)) автоматически "
321 "включается для нового дескриптора файла."
322
323 #. type: TP
324 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
325 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
326 #, no-wrap
327 msgid "B<BPF_MAP_LOOKUP_ELEM>"
328 msgstr "B<BPF_MAP_LOOKUP_ELEM>"
329
330 #. type: Plain text
331 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
332 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
333 msgid "Look up an element by key in a specified map and return its value."
334 msgstr "Найти элемент по ключу на указанной карте и вернуть его значение."
335
336 #. type: TP
337 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
338 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
339 #, no-wrap
340 msgid "B<BPF_MAP_UPDATE_ELEM>"
341 msgstr "B<BPF_MAP_UPDATE_ELEM>"
342
343 #. type: Plain text
344 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
345 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
346 msgid "Create or update an element (key/value pair) in a specified map."
347 msgstr "Создать или обновить элемент (пару ключ/значение) на указанной карте."
348
349 #. type: TP
350 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
351 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
352 #, no-wrap
353 msgid "B<BPF_MAP_DELETE_ELEM>"
354 msgstr "B<BPF_MAP_DELETE_ELEM>"
355
356 #. type: Plain text
357 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
358 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
359 msgid "Look up and delete an element by key in a specified map."
360 msgstr "Найти и удалить элемент по ключу на указанной карте."
361
362 #. type: TP
363 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
364 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
365 #, no-wrap
366 msgid "B<BPF_MAP_GET_NEXT_KEY>"
367 msgstr "B<BPF_MAP_GET_NEXT_KEY>"
368
369 #. type: Plain text
370 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
371 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
372 msgid ""
373 "Look up an element by key in a specified map and return the key of the next "
374 "element."
375 msgstr ""
376 "Найти элемент по ключу в указанной карте и вернуть ключ следующего элемента."
377
378 #. type: TP
379 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
380 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
381 #, no-wrap
382 msgid "B<BPF_PROG_LOAD>"
383 msgstr "B<BPF_PROG_LOAD>"
384
385 #. type: Plain text
386 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
387 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
388 msgid ""
389 "Verify and load an eBPF program, returning a new file descriptor associated "
390 "with the program. The close-on-exec file descriptor flag (see B<fcntl>(2)) "
391 "is automatically enabled for the new file descriptor."
392 msgstr ""
393 "Проверить и загрузить программу eBPF, которая вернет новый файловый "
394 "дескриптор, связанный с программой. Флаг дескриптора файла close-on-exec "
395 "(см. B<fcntl>(2)) автоматически включается для нового дескриптора файла."
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 ""
401 "The I<bpf_attr> union consists of various anonymous structures that are used "
402 "by different B<bpf>() commands:"
403 msgstr ""
404 "Объединение I<bpf_attr> состоит из различных анонимных структур, которые "
405 "используются различными командами B<bpf>():"
406
407 #. commit 2541517c32be2531e0da59dfd7efc1ce844644f5
408 #. type: Plain text
409 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
410 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
411 #, no-wrap
412 msgid ""
413 "union bpf_attr {\n"
414 " struct { /* Used by BPF_MAP_CREATE */\n"
415 " __u32 map_type;\n"
416 " __u32 key_size; /* size of key in bytes */\n"
417 " __u32 value_size; /* size of value in bytes */\n"
418 " __u32 max_entries; /* maximum number of entries\n"
419 " in a map */\n"
420 " };\n"
421 "\\&\n"
422 " struct { /* Used by BPF_MAP_*_ELEM and BPF_MAP_GET_NEXT_KEY\n"
423 " commands */\n"
424 " __u32 map_fd;\n"
425 " __aligned_u64 key;\n"
426 " union {\n"
427 " __aligned_u64 value;\n"
428 " __aligned_u64 next_key;\n"
429 " };\n"
430 " __u64 flags;\n"
431 " };\n"
432 "\\&\n"
433 " struct { /* Used by BPF_PROG_LOAD */\n"
434 " __u32 prog_type;\n"
435 " __u32 insn_cnt;\n"
436 " __aligned_u64 insns; /* \\[aq]const struct bpf_insn *\\[aq] */\n"
437 " __aligned_u64 license; /* \\[aq]const char *\\[aq] */\n"
438 " __u32 log_level; /* verbosity level of verifier */\n"
439 " __u32 log_size; /* size of user buffer */\n"
440 " __aligned_u64 log_buf; /* user supplied \\[aq]char *\\[aq]\n"
441 " buffer */\n"
442 " __u32 kern_version;\n"
443 " /* checked when prog_type=kprobe\n"
444 " (since Linux 4.1) */\n"
445 " };\n"
446 "} __attribute__((aligned(8)));\n"
447 msgstr ""
448 "union bpf_attr {\n"
449 " struct { /* Used by BPF_MAP_CREATE */\n"
450 " __u32 map_type;\n"
451 " __u32 key_size; /* size of key in bytes */\n"
452 " __u32 value_size; /* size of value in bytes */\n"
453 " __u32 max_entries; /* maximum number of entries\n"
454 " in a map */\n"
455 " };\n"
456 "\\&\n"
457 " struct { /* Used by BPF_MAP_*_ELEM and BPF_MAP_GET_NEXT_KEY\n"
458 " commands */\n"
459 " __u32 map_fd;\n"
460 " __aligned_u64 key;\n"
461 " union {\n"
462 " __aligned_u64 value;\n"
463 " __aligned_u64 next_key;\n"
464 " };\n"
465 " __u64 flags;\n"
466 " };\n"
467 "\\&\n"
468 " struct { /* Used by BPF_PROG_LOAD */\n"
469 " __u32 prog_type;\n"
470 " __u32 insn_cnt;\n"
471 " __aligned_u64 insns; /* \\[aq]const struct bpf_insn *\\[aq] */\n"
472 " __aligned_u64 license; /* \\[aq]const char *\\[aq] */\n"
473 " __u32 log_level; /* verbosity level of verifier */\n"
474 " __u32 log_size; /* size of user buffer */\n"
475 " __aligned_u64 log_buf; /* user supplied \\[aq]char *\\[aq]\n"
476 " buffer */\n"
477 " __u32 kern_version;\n"
478 " /* checked when prog_type=kprobe\n"
479 " (since Linux 4.1) */\n"
480 " };\n"
481 "} __attribute__((aligned(8)));\n"
482
483 #. type: SS
484 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
485 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
486 #, no-wrap
487 msgid "eBPF maps"
488 msgstr "eBPF maps"
489
490 #. type: Plain text
491 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
492 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
493 msgid ""
494 "Maps are a generic data structure for storage of different types of data. "
495 "They allow sharing of data between eBPF kernel programs, and also between "
496 "kernel and user-space applications."
497 msgstr ""
498 "Карты представляют собой универсальную структуру данных для хранения "
499 "различных типов данных. Они позволяют обмениваться данными между программами "
500 "ядра eBPF, а также между ядром и пользовательскими приложениями."
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 "Each map type has the following attributes:"
506 msgstr "Каждый тип карты имеет следующие атрибуты:"
507
508 #. type: IP
509 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
510 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
511 #, no-wrap
512 msgid "\\[bu]"
513 msgstr "\\[bu]"
514
515 #. type: Plain text
516 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
517 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
518 msgid "type"
519 msgstr "тип"
520
521 #. type: Plain text
522 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
523 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
524 msgid "maximum number of elements"
525 msgstr "максимальное количество элементов"
526
527 #. type: Plain text
528 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
529 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
530 msgid "key size in bytes"
531 msgstr "размер ключа в байтах"
532
533 #. type: Plain text
534 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
535 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
536 msgid "value size in bytes"
537 msgstr "размер значения в байтах"
538
539 #. type: Plain text
540 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
541 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
542 msgid ""
543 "The following wrapper functions demonstrate how various B<bpf>() commands "
544 "can be used to access the maps. The functions use the I<cmd> argument to "
545 "invoke different operations."
546 msgstr ""
547 "Следующие функции-оболочки демонстрируют, как можно использовать различные "
548 "команды B<bpf>() для доступа к картам. Функции используют аргумент I<cmd> "
549 "для вызова различных операций."
550
551 #. type: Plain text
552 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
553 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
554 msgid ""
555 "The B<BPF_MAP_CREATE> command creates a new map, returning a new file "
556 "descriptor that refers to the map."
557 msgstr ""
558 "Команда B<BPF_MAP_CREATE> создает новую карту и возвращает новый файловый "
559 "дескриптор, который ссылается на карту."
560
561 #. type: Plain text
562 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
563 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
564 #, no-wrap
565 msgid ""
566 "int\n"
567 "bpf_create_map(enum bpf_map_type map_type,\n"
568 " unsigned int key_size,\n"
569 " unsigned int value_size,\n"
570 " unsigned int max_entries)\n"
571 "{\n"
572 " union bpf_attr attr = {\n"
573 " .map_type = map_type,\n"
574 " .key_size = key_size,\n"
575 " .value_size = value_size,\n"
576 " .max_entries = max_entries\n"
577 " };\n"
578 "\\&\n"
579 " return bpf(BPF_MAP_CREATE, &attr, sizeof(attr));\n"
580 "}\n"
581 msgstr ""
582 "int\n"
583 "bpf_create_map(enum bpf_map_type map_type,\n"
584 " unsigned int key_size,\n"
585 " unsigned int value_size,\n"
586 " unsigned int max_entries)\n"
587 "{\n"
588 " union bpf_attr attr = {\n"
589 " .map_type = map_type,\n"
590 " .key_size = key_size,\n"
591 " .value_size = value_size,\n"
592 " .max_entries = max_entries\n"
593 " };\n"
594 "\\&\n"
595 " return bpf(BPF_MAP_CREATE, &attr, sizeof(attr));\n"
596 "}\n"
597
598 #. type: Plain text
599 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
600 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
601 msgid ""
602 "The new map has the type specified by I<map_type>, and attributes as "
603 "specified in I<key_size>, I<value_size>, and I<max_entries>. On success, "
604 "this operation returns a file descriptor. On error, -1 is returned and "
605 "I<errno> is set to B<EINVAL>, B<EPERM>, or B<ENOMEM>."
606 msgstr ""
607 "Новая карта имеет тип, указанный в параметре I<map_type> и атрибуты, "
608 "указанные в параметрах I<key_size>, I<value_size> и I<max_entries>. В "
609 "случае успеха эта операция возвращает файловый дескриптор. В случае ошибки "
610 "возвращается значение -1, а для параметра I<errno> устанавливается значение "
611 "B<EINVAL>, B<EPERM> или B<ENOMEM>."
612
613 #. type: Plain text
614 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
615 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
616 msgid ""
617 "The I<key_size> and I<value_size> attributes will be used by the verifier "
618 "during program loading to check that the program is calling "
619 "B<bpf_map_*_elem>() helper functions with a correctly initialized I<key> "
620 "and to check that the program doesn't access the map element I<value> beyond "
621 "the specified I<value_size>. For example, when a map is created with a "
622 "I<key_size> of 8 and the eBPF program calls"
623 msgstr ""
624 "Атрибуты I<key_size> и I<value_size> будут использоваться верификатором во "
625 "время загрузки программы для проверки того, что программа вызывает "
626 "вспомогательные функции B<bpf_map_*_elem>() с правильно инициализированным "
627 "I<key> и чтобы проверить, что программа не обращается к элементу карты c "
628 "I<value> за пределами размера, указанного в I<value_size>. Например, когда "
629 "создается карта с I<key_size> равным 8 и программа eBPF вызывает"
630
631 #. type: Plain text
632 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
633 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
634 #, no-wrap
635 msgid "bpf_map_lookup_elem(map_fd, fp - 4)\n"
636 msgstr "bpf_map_lookup_elem(map_fd, fp - 4)\n"
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 msgid "the program will be rejected, since the in-kernel helper function"
642 msgstr ""
643 "программа будет отклонена, поскольку встроенная в ядро вспомогательная "
644 "функция"
645
646 #. type: Plain text
647 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
648 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
649 #, no-wrap
650 msgid "bpf_map_lookup_elem(map_fd, void *key)\n"
651 msgstr "bpf_map_lookup_elem(map_fd, void *key)\n"
652
653 #. type: Plain text
654 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
655 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
656 msgid ""
657 "expects to read 8 bytes from the location pointed to by I<key>, but the "
658 "I<fp\\ -\\ 4> (where I<fp> is the top of the stack) starting address will "
659 "cause out-of-bounds stack access."
660 msgstr ""
661 "ожидает, что будет прочитано 8 байт из местоположения, на которое указывает "
662 "I<key>, но начальный адрес I<fp\\ -\\4> (где I<fp> - вершина стека) приведет "
663 "к невозможности доступа к стеку. "
664
665 #. type: Plain text
666 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
667 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
668 msgid ""
669 "Similarly, when a map is created with a I<value_size> of 1 and the eBPF "
670 "program contains"
671 msgstr ""
672 "Аналогично, когда создается man с aI<value_size> равным 1 и программа bpf "
673 "содержит"
674
675 #. type: Plain text
676 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
677 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
678 #, no-wrap
679 msgid ""
680 "value = bpf_map_lookup_elem(...);\n"
681 "*(u32 *) value = 1;\n"
682 msgstr ""
683 "value = bpf_map_lookup_elem(...);\n"
684 "*(u32 *) value = 1;\n"
685
686 #. type: Plain text
687 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
688 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
689 msgid ""
690 "the program will be rejected, since it accesses the I<value> pointer beyond "
691 "the specified 1 byte I<value_size> limit."
692 msgstr ""
693 "программа будет отклонена, поскольку она обращается к указателю I<value> за "
694 "пределами указанного предела в 1 байт I<value_size>."
695
696 #. type: Plain text
697 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
698 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
699 msgid "Currently, the following values are supported for I<map_type>:"
700 msgstr "В настоящее время для I<map_type> поддерживаются следующие значения:"
701
702 #. type: Plain text
703 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
704 #: opensuse-tumbleweed
705 #, fuzzy, no-wrap
706 #| msgid ""
707 #| "enum bpf_map_type {\n"
708 #| " BPF_MAP_TYPE_UNSPEC, /* Reserve 0 as invalid map type */\n"
709 #| " BPF_MAP_TYPE_HASH,\n"
710 #| " BPF_MAP_TYPE_ARRAY,\n"
711 #| " BPF_MAP_TYPE_PROG_ARRAY,\n"
712 #| " BPF_MAP_TYPE_PERF_EVENT_ARRAY,\n"
713 #| " BPF_MAP_TYPE_PERCPU_HASH,\n"
714 #| " BPF_MAP_TYPE_PERCPU_ARRAY,\n"
715 #| " BPF_MAP_TYPE_STACK_TRACE,\n"
716 #| " BPF_MAP_TYPE_CGROUP_ARRAY,\n"
717 #| " BPF_MAP_TYPE_LRU_HASH,\n"
718 #| " BPF_MAP_TYPE_LRU_PERCPU_HASH,\n"
719 #| " BPF_MAP_TYPE_LPM_TRIE,\n"
720 #| " BPF_MAP_TYPE_ARRAY_OF_MAPS,\n"
721 #| " BPF_MAP_TYPE_HASH_OF_MAPS,\n"
722 #| " BPF_MAP_TYPE_DEVMAP,\n"
723 #| " BPF_MAP_TYPE_SOCKMAP,\n"
724 #| " BPF_MAP_TYPE_CPUMAP,\n"
725 #| " BPF_MAP_TYPE_XSKMAP,\n"
726 #| " BPF_MAP_TYPE_SOCKHASH,\n"
727 #| " BPF_MAP_TYPE_CGROUP_STORAGE,\n"
728 #| " BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,\n"
729 #| " BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,\n"
730 #| " BPF_MAP_TYPE_QUEUE,\n"
731 #| " BPF_MAP_TYPE_STACK,\n"
732 #| " /* See /usr/include/linux/bpf.h for the full list. */\n"
733 #| "};\n"
734 msgid ""
735 "enum bpf_map_type {\n"
736 " BPF_MAP_TYPE_UNSPEC, /* Reserve 0 as invalid map type */\n"
737 " BPF_MAP_TYPE_HASH,\n"
738 " BPF_MAP_TYPE_ARRAY,\n"
739 " BPF_MAP_TYPE_PROG_ARRAY,\n"
740 " BPF_MAP_TYPE_PERF_EVENT_ARRAY,\n"
741 " BPF_MAP_TYPE_PERCPU_HASH,\n"
742 " BPF_MAP_TYPE_PERCPU_ARRAY,\n"
743 " BPF_MAP_TYPE_STACK_TRACE,\n"
744 " BPF_MAP_TYPE_CGROUP_ARRAY,\n"
745 " BPF_MAP_TYPE_LRU_HASH,\n"
746 " BPF_MAP_TYPE_LRU_PERCPU_HASH,\n"
747 " BPF_MAP_TYPE_LPM_TRIE,\n"
748 " BPF_MAP_TYPE_ARRAY_OF_MAPS,\n"
749 " BPF_MAP_TYPE_HASH_OF_MAPS,\n"
750 " BPF_MAP_TYPE_DEVMAP,\n"
751 " BPF_MAP_TYPE_SOCKMAP,\n"
752 " BPF_MAP_TYPE_CPUMAP,\n"
753 " BPF_MAP_TYPE_XSKMAP,\n"
754 " BPF_MAP_TYPE_SOCKHASH,\n"
755 " BPF_MAP_TYPE_CGROUP_STORAGE,\n"
756 " BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,\n"
757 " BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,\n"
758 " BPF_MAP_TYPE_QUEUE,\n"
759 " BPF_MAP_TYPE_STACK,\n"
760 " /* See /usr/include/linux/bpf.h for the full list. */\n"
761 "};\n"
762 msgstr ""
763 "enum bpf_map_type {\n"
764 " BPF_MAP_TYPE_UNSPEC, /* Reserve 0 as invalid map type */\n"
765 " BPF_MAP_TYPE_HASH,\n"
766 " BPF_MAP_TYPE_ARRAY,\n"
767 " BPF_MAP_TYPE_PROG_ARRAY,\n"
768 " BPF_MAP_TYPE_PERF_EVENT_ARRAY,\n"
769 " BPF_MAP_TYPE_PERCPU_HASH,\n"
770 " BPF_MAP_TYPE_PERCPU_ARRAY,\n"
771 " BPF_MAP_TYPE_STACK_TRACE,\n"
772 " BPF_MAP_TYPE_CGROUP_ARRAY,\n"
773 " BPF_MAP_TYPE_LRU_HASH,\n"
774 " BPF_MAP_TYPE_LRU_PERCPU_HASH,\n"
775 " BPF_MAP_TYPE_LPM_TRIE,\n"
776 " BPF_MAP_TYPE_ARRAY_OF_MAPS,\n"
777 " BPF_MAP_TYPE_HASH_OF_MAPS,\n"
778 " BPF_MAP_TYPE_DEVMAP,\n"
779 " BPF_MAP_TYPE_SOCKMAP,\n"
780 " BPF_MAP_TYPE_CPUMAP,\n"
781 " BPF_MAP_TYPE_XSKMAP,\n"
782 " BPF_MAP_TYPE_SOCKHASH,\n"
783 " BPF_MAP_TYPE_CGROUP_STORAGE,\n"
784 " BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,\n"
785 " BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,\n"
786 " BPF_MAP_TYPE_QUEUE,\n"
787 " BPF_MAP_TYPE_STACK,\n"
788 " /* See /usr/include/linux/bpf.h for the full list. */\n"
789 "};\n"
790
791 #. FIXME We need an explanation of why one might choose each of
792 #. these map implementations
793 #. type: Plain text
794 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
795 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
796 msgid ""
797 "I<map_type> selects one of the available map implementations in the kernel. "
798 "For all map types, eBPF programs access maps with the same "
799 "B<bpf_map_lookup_elem>() and B<bpf_map_update_elem>() helper functions. "
800 "Further details of the various map types are given below."
801 msgstr ""
802 "Параметр I<map_type> выбирает одну из доступных реализаций карты в ядре. "
803 "Для всех типов карт программы eBPF получают доступ к картам с помощью одних "
804 "и тех же вспомогательных функций B<bpf_map_lookup_elem>() и "
805 "B<bpf_map_update_elem>(). Более подробная информация о различных типах карт "
806 "приведена ниже."
807
808 #. type: Plain text
809 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
810 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
811 msgid ""
812 "The B<BPF_MAP_LOOKUP_ELEM> command looks up an element with a given I<key> "
813 "in the map referred to by the file descriptor I<fd>."
814 msgstr ""
815 "Команда B<BPF_MAP_LOOKUP_ELEM> выполняет поиск элемента с заданным значением "
816 "I<key> на карте, на которую ссылается файловый дескриптор I<fd>."
817
818 #. type: Plain text
819 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
820 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
821 #, no-wrap
822 msgid ""
823 "int\n"
824 "bpf_lookup_elem(int fd, const void *key, void *value)\n"
825 "{\n"
826 " union bpf_attr attr = {\n"
827 " .map_fd = fd,\n"
828 " .key = ptr_to_u64(key),\n"
829 " .value = ptr_to_u64(value),\n"
830 " };\n"
831 "\\&\n"
832 " return bpf(BPF_MAP_LOOKUP_ELEM, &attr, sizeof(attr));\n"
833 "}\n"
834 msgstr ""
835 "int\n"
836 "bpf_lookup_elem(int fd, const void *key, void *value)\n"
837 "{\n"
838 " union bpf_attr attr = {\n"
839 " .map_fd = fd,\n"
840 " .key = ptr_to_u64(key),\n"
841 " .value = ptr_to_u64(value),\n"
842 " };\n"
843 "\\&\n"
844 " return bpf(BPF_MAP_LOOKUP_ELEM, &attr, sizeof(attr));\n"
845 "}\n"
846
847 #. type: Plain text
848 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
849 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
850 msgid ""
851 "If an element is found, the operation returns zero and stores the element's "
852 "value into I<value>, which must point to a buffer of I<value_size> bytes."
853 msgstr ""
854 "Если элемент найден, операция возвращает ноль и сохраняет значение элемента "
855 "в I<value>, которое должно указывать на буфер с I<value_size> байт."
856
857 #. type: Plain text
858 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
859 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
860 msgid ""
861 "If no element is found, the operation returns -1 and sets I<errno> to "
862 "B<ENOENT>."
863 msgstr ""
864 "Если элемент не найден, операция возвращает значение -1 и присваивает "
865 "I<errno> значение B<ENOENT>."
866
867 #. type: Plain text
868 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
869 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
870 msgid ""
871 "The B<BPF_MAP_UPDATE_ELEM> command creates or updates an element with a "
872 "given I<key/value> in the map referred to by the file descriptor I<fd>."
873 msgstr ""
874 "Команда B<BPF_MAP_UPDATE_ELEM> создает или обновляет элемент с заданным "
875 "значением I<key/value> на карте, на которую ссылается файловый дескриптор "
876 "I<fd>."
877
878 #. type: Plain text
879 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
880 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
881 #, no-wrap
882 msgid ""
883 "int\n"
884 "bpf_update_elem(int fd, const void *key, const void *value,\n"
885 " uint64_t flags)\n"
886 "{\n"
887 " union bpf_attr attr = {\n"
888 " .map_fd = fd,\n"
889 " .key = ptr_to_u64(key),\n"
890 " .value = ptr_to_u64(value),\n"
891 " .flags = flags,\n"
892 " };\n"
893 "\\&\n"
894 " return bpf(BPF_MAP_UPDATE_ELEM, &attr, sizeof(attr));\n"
895 "}\n"
896 msgstr ""
897 "int\n"
898 "bpf_update_elem(int fd, const void *key, const void *value,\n"
899 " uint64_t flags)\n"
900 "{\n"
901 " union bpf_attr attr = {\n"
902 " .map_fd = fd,\n"
903 " .key = ptr_to_u64(key),\n"
904 " .value = ptr_to_u64(value),\n"
905 " .flags = flags,\n"
906 " };\n"
907 "\\&\n"
908 " return bpf(BPF_MAP_UPDATE_ELEM, &attr, sizeof(attr));\n"
909 "}\n"
910
911 #. type: Plain text
912 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
913 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
914 msgid "The I<flags> argument should be specified as one of the following:"
915 msgstr "Аргументу I<flags> может быть присвоено одно из следующих значений:"
916
917 #. type: TP
918 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
919 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
920 #, no-wrap
921 msgid "B<BPF_ANY>"
922 msgstr "B<BPF_ANY>"
923
924 #. type: Plain text
925 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
926 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
927 msgid "Create a new element or update an existing element."
928 msgstr "Создать новый элемент или обновить существующий."
929
930 #. type: TP
931 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
932 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
933 #, no-wrap
934 msgid "B<BPF_NOEXIST>"
935 msgstr "B<BPF_NOEXIST>"
936
937 #. type: Plain text
938 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
939 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
940 msgid "Create a new element only if it did not exist."
941 msgstr "Создать новый элемент только, если он не существует."
942
943 #. type: TP
944 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
945 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
946 #, no-wrap
947 msgid "B<BPF_EXIST>"
948 msgstr "B<BPF_EXIST>"
949
950 #. type: Plain text
951 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
952 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
953 msgid "Update an existing element."
954 msgstr "Обновить существующий элемент."
955
956 #. type: Plain text
957 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
958 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
959 msgid ""
960 "On success, the operation returns zero. On error, -1 is returned and "
961 "I<errno> is set to B<EINVAL>, B<EPERM>, B<ENOMEM>, or B<E2BIG>. B<E2BIG> "
962 "indicates that the number of elements in the map reached the I<max_entries> "
963 "limit specified at map creation time. B<EEXIST> will be returned if "
964 "I<flags> specifies B<BPF_NOEXIST> and the element with I<key> already exists "
965 "in the map. B<ENOENT> will be returned if I<flags> specifies B<BPF_EXIST> "
966 "and the element with I<key> doesn't exist in the map."
967 msgstr ""
968 "В случае успеха операция возвращает ноль. В случае ошибки возвращается "
969 "значение -1, а для параметра I<errno> устанавливаются значения B<EINVAL>, "
970 "B<EPERM>, B<ENOMEM> или B<E2BIG>."
971
972 #. type: Plain text
973 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
974 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
975 msgid ""
976 "The B<BPF_MAP_DELETE_ELEM> command deletes the element whose key is I<key> "
977 "from the map referred to by the file descriptor I<fd>."
978 msgstr ""
979 "Команда B<BPF_MAP_DELETE_ELEM> удаляет элемент, ключом которого является "
980 "I<key>, с карты, на которую ссылается файловый дескриптор I<fd>."
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 "int\n"
988 "bpf_delete_elem(int fd, const void *key)\n"
989 "{\n"
990 " union bpf_attr attr = {\n"
991 " .map_fd = fd,\n"
992 " .key = ptr_to_u64(key),\n"
993 " };\n"
994 "\\&\n"
995 " return bpf(BPF_MAP_DELETE_ELEM, &attr, sizeof(attr));\n"
996 "}\n"
997 msgstr ""
998 "int\n"
999 "bpf_delete_elem(int fd, const void *key)\n"
1000 "{\n"
1001 " union bpf_attr attr = {\n"
1002 " .map_fd = fd,\n"
1003 " .key = ptr_to_u64(key),\n"
1004 " };\n"
1005 "\\&\n"
1006 " return bpf(BPF_MAP_DELETE_ELEM, &attr, sizeof(attr));\n"
1007 "}\n"
1008
1009 #. type: Plain text
1010 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1011 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1012 msgid ""
1013 "On success, zero is returned. If the element is not found, -1 is returned "
1014 "and I<errno> is set to B<ENOENT>."
1015 msgstr ""
1016 "В случае успеха возвращается ноль. Если элемент не найден, возвращается "
1017 "значение -1, а I<errno> присваивается значение B<ENOENT>."
1018
1019 #. type: Plain text
1020 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1021 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1022 msgid ""
1023 "The B<BPF_MAP_GET_NEXT_KEY> command looks up an element by I<key> in the map "
1024 "referred to by the file descriptor I<fd> and sets the I<next_key> pointer to "
1025 "the key of the next element."
1026 msgstr ""
1027 "Команда B<BPF_MAP_GET_NEXT_KEY> выполняет поиск элемента по I<key> на карте, "
1028 "на которую ссылается файловый дескриптор I<fd> и устанавливает указатель "
1029 "I<next_key> на ключ следующего элемента."
1030
1031 #. type: Plain text
1032 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1033 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1034 #, no-wrap
1035 msgid ""
1036 "int\n"
1037 "bpf_get_next_key(int fd, const void *key, void *next_key)\n"
1038 "{\n"
1039 " union bpf_attr attr = {\n"
1040 " .map_fd = fd,\n"
1041 " .key = ptr_to_u64(key),\n"
1042 " .next_key = ptr_to_u64(next_key),\n"
1043 " };\n"
1044 "\\&\n"
1045 " return bpf(BPF_MAP_GET_NEXT_KEY, &attr, sizeof(attr));\n"
1046 "}\n"
1047 msgstr ""
1048 "int\n"
1049 "bpf_get_next_key(int fd, const void *key, void *next_key)\n"
1050 "{\n"
1051 " union bpf_attr attr = {\n"
1052 " .map_fd = fd,\n"
1053 " .key = ptr_to_u64(key),\n"
1054 " .next_key = ptr_to_u64(next_key),\n"
1055 " };\n"
1056 "\\&\n"
1057 " return bpf(BPF_MAP_GET_NEXT_KEY, &attr, sizeof(attr));\n"
1058 "}\n"
1059
1060 #. type: Plain text
1061 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1062 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1063 msgid ""
1064 "If I<key> is found, the operation returns zero and sets the I<next_key> "
1065 "pointer to the key of the next element. If I<key> is not found, the "
1066 "operation returns zero and sets the I<next_key> pointer to the key of the "
1067 "first element. If I<key> is the last element, -1 is returned and I<errno> "
1068 "is set to B<ENOENT>. Other possible I<errno> values are B<ENOMEM>, "
1069 "B<EFAULT>, B<EPERM>, and B<EINVAL>. This method can be used to iterate over "
1070 "all elements in the map."
1071 msgstr ""
1072 "Если I<key> найден, операция возвращает ноль и устанавливает указатель "
1073 "I<next_key> на ключ следующего элемента. Если I<key> не найден, операция "
1074 "возвращает ноль и устанавливает указатель I<next_key> на ключ первого "
1075 "элемента. Если I<key> является последним элементом, возвращается значение "
1076 "-1, а I<errno> присваивается значение B<ENOENT>. Другими возможными "
1077 "значениями I<errno> являются B<ENOMEM>, B<DEFAULT>, B<EPERM> и B<EINVAL>. "
1078 "Этот метод можно использовать для перебора всех элементов на карте."
1079
1080 #. type: TP
1081 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1082 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1083 #, no-wrap
1084 msgid "B<close(map_fd)>"
1085 msgstr "B<close(map_fd)>"
1086
1087 #. type: Plain text
1088 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1089 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1090 msgid ""
1091 "Delete the map referred to by the file descriptor I<map_fd>. When the user-"
1092 "space program that created a map exits, all maps will be deleted "
1093 "automatically (but see NOTES)."
1094 msgstr ""
1095 "Удаляет карту, на которую ссылается файловый дескриптор I<map_fd>. При "
1096 "завершении работы программы пользовательского пространства, создавшей карту, "
1097 "все карты будут удалены автоматически (однако, смотрите ПРИМЕЧАНИЯ)."
1098
1099 #. type: SS
1100 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1101 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1102 #, no-wrap
1103 msgid "eBPF map types"
1104 msgstr "eBPF map types"
1105
1106 #. type: Plain text
1107 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1108 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1109 msgid "The following map types are supported:"
1110 msgstr "Поддерживаются следующие типы карт:"
1111
1112 #. type: TP
1113 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1114 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1115 #, no-wrap
1116 msgid "B<BPF_MAP_TYPE_HASH>"
1117 msgstr "B<BPF_MAP_TYPE_HASH>"
1118
1119 #. commit 0f8e4bd8a1fc8c4185f1630061d0a1f2d197a475
1120 #. type: Plain text
1121 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1122 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1123 msgid "Hash-table maps have the following characteristics:"
1124 msgstr "Карты хэш-таблиц, которые обладают следующими характеристиками:"
1125
1126 #. type: Plain text
1127 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1128 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1129 msgid ""
1130 "Maps are created and destroyed by user-space programs. Both user-space and "
1131 "eBPF programs can perform lookup, update, and delete operations."
1132 msgstr ""
1133 "Карты создаются и уничтожаются программами пользовательского пространства. "
1134 "Как программы пользовательского пространства, так и программы eBPF могут "
1135 "выполнять операции поиска, обновления и удаления."
1136
1137 #. type: Plain text
1138 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1139 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1140 msgid "The kernel takes care of allocating and freeing key/value pairs."
1141 msgstr "Ядро заботится о выделении и освобождении пар key/value."
1142
1143 #. type: Plain text
1144 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1145 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1146 msgid ""
1147 "The B<map_update_elem>() helper will fail to insert new element when the "
1148 "I<max_entries> limit is reached. (This ensures that eBPF programs cannot "
1149 "exhaust memory.)"
1150 msgstr ""
1151 "Помощнику B<map_update_elem>() не удастся вставить новый элемент, когда "
1152 "будет достигнут предел I<max_entries> (это гарантирует, что программы eBPF "
1153 "не смогут исчерпать объем памяти)."
1154
1155 #. type: Plain text
1156 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1157 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1158 msgid "B<map_update_elem>() replaces existing elements atomically."
1159 msgstr "B<map_update_elem>() - заменяет существующие элементы атомарно."
1160
1161 #. type: Plain text
1162 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1163 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1164 msgid "Hash-table maps are optimized for speed of lookup."
1165 msgstr "Карты с хэш-таблицами оптимизированы для ускорения поиска."
1166
1167 #. type: TP
1168 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1169 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1170 #, no-wrap
1171 msgid "B<BPF_MAP_TYPE_ARRAY>"
1172 msgstr "B<BPF_MAP_TYPE_ARRAY>"
1173
1174 #. commit 28fbcfa08d8ed7c5a50d41a0433aad222835e8e3
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 "Array maps have the following characteristics:"
1179 msgstr "Карты массивов имеют следующие характеристики:"
1180
1181 #. type: Plain text
1182 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1183 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1184 msgid ""
1185 "Optimized for fastest possible lookup. In the future the verifier/JIT "
1186 "compiler may recognize lookup() operations that employ a constant key and "
1187 "optimize it into constant pointer. It is possible to optimize a non-"
1188 "constant key into direct pointer arithmetic as well, since pointers and "
1189 "I<value_size> are constant for the life of the eBPF program. In other "
1190 "words, B<array_map_lookup_elem>() may be 'inlined' by the verifier/JIT "
1191 "compiler while preserving concurrent access to this map from user space."
1192 msgstr ""
1193 "Оптимизированы для максимально быстрого поиска. В будущем компилятор "
1194 "verifier/JIT сможет распознать операции lookup(), которые используют "
1195 "постоянный ключ и оптимизировать его в постоянный указатель. Можно также "
1196 "оптимизировать непостоянный ключ для прямой арифметики указателей, поскольку "
1197 "указатели и I<value_size> являются постоянными в течение всего срока службы "
1198 "программы eBPF. Другими словами, B<array_map_lookup_elem>() может быть "
1199 "\"встроен\" верификатором/JIT-компилятором, сохраняя одновременный доступ к "
1200 "этой карте из пространства пользователя."
1201
1202 #. type: Plain text
1203 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1204 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1205 msgid "All array elements pre-allocated and zero initialized at init time"
1206 msgstr ""
1207 "Все элементы массива предварительно распределены и инициализированы нулем во "
1208 "время инициализации."
1209
1210 #. type: Plain text
1211 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1212 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1213 msgid "The key is an array index, and must be exactly four bytes."
1214 msgstr ""
1215 "Ключ представляет собой индекс массива и должен содержать ровно четыре байта."
1216
1217 #. type: Plain text
1218 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1219 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1220 msgid ""
1221 "B<map_delete_elem>() fails with the error B<EINVAL>, since elements cannot "
1222 "be deleted."
1223 msgstr ""
1224 "B<map_delete_elem>() завершается ошибкой B<EINVAL>, поскольку элементы не "
1225 "могут быть удалены."
1226
1227 #. type: Plain text
1228 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1229 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1230 msgid ""
1231 "B<map_update_elem>() replaces elements in a B<nonatomic> fashion; for "
1232 "atomic updates, a hash-table map should be used instead. There is however "
1233 "one special case that can also be used with arrays: the atomic built-in "
1234 "B<__sync_fetch_and_add()> can be used on 32 and 64 bit atomic counters. For "
1235 "example, it can be applied on the whole value itself if it represents a "
1236 "single counter, or in case of a structure containing multiple counters, it "
1237 "could be used on individual counters. This is quite often useful for "
1238 "aggregation and accounting of events."
1239 msgstr ""
1240 "B<map_update_elem>() заменяет элементы в стиле B<nonatomic>; для атомарных "
1241 "обновлений вместо этого следует использовать карту хэш-таблицы. Однако есть "
1242 "один особый случай, который также может быть использован с массивами: "
1243 "атомарные встроенные функции B<__sync_fetch_и_add()> могут использоваться с "
1244 "32-разрядными и 64-разрядными атомарными счетчиками. Например, они могут "
1245 "быть применен ко всему значению, если оно представляет собой один счетчик "
1246 "или, в случае структуры, содержащей несколько счетчиков, они могут быть "
1247 "использованы для отдельных счетчиков. Это довольно часто бывает полезно для "
1248 "агрегирования и учета событий."
1249
1250 #. type: Plain text
1251 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1252 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1253 msgid "Among the uses for array maps are the following:"
1254 msgstr "Среди применений для отображения массивов можно выделить следующие:"
1255
1256 #. type: Plain text
1257 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1258 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1259 msgid ""
1260 "As \"global\" eBPF variables: an array of 1 element whose key is (index) 0 "
1261 "and where the value is a collection of 'global' variables which eBPF "
1262 "programs can use to keep state between events."
1263 msgstr ""
1264 "Как \"глобальные\" переменные eBPF: массив из 1 элемента, ключ которого "
1265 "(индекс) равен 0, а значение представляет собой набор \"глобальных\" "
1266 "переменных, которые программы eBPF могут использовать для сохранения "
1267 "состояния между событиями."
1268
1269 #. type: Plain text
1270 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1271 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1272 msgid "Aggregation of tracing events into a fixed set of buckets."
1273 msgstr "Объединение событий трассировки в фиксированный набор сегментов."
1274
1275 #. type: Plain text
1276 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1277 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1278 msgid ""
1279 "Accounting of networking events, for example, number of packets and packet "
1280 "sizes."
1281 msgstr "Учет сетевых событий, например, количества пакетов и их размеров."
1282
1283 #. type: TP
1284 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1285 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1286 #, no-wrap
1287 msgid "B<BPF_MAP_TYPE_PROG_ARRAY> (since Linux 4.2)"
1288 msgstr "B<BPF_MAP_TYPE_PROG_ARRAY> (since Linux 4.2)"
1289
1290 #. type: Plain text
1291 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1292 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1293 msgid ""
1294 "A program array map is a special kind of array map whose map values contain "
1295 "only file descriptors referring to other eBPF programs. Thus, both the "
1296 "I<key_size> and I<value_size> must be exactly four bytes. This map is used "
1297 "in conjunction with the B<bpf_tail_call>() helper."
1298 msgstr ""
1299 "Программная карта массива - это особый вид карты массива, значения которой "
1300 "содержат только файловые дескрипторы, относящиеся к другим программам eBPF. "
1301 "Таким образом, как I<key_size>, так и I<value_size> должны составлять ровно "
1302 "четыре байта. Эта карта используется совместно с помощником "
1303 "B<bpf_tail_call>()."
1304
1305 #. type: Plain text
1306 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1307 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1308 msgid ""
1309 "This means that an eBPF program with a program array map attached to it can "
1310 "call from kernel side into"
1311 msgstr ""
1312 "Это означает, что программа eBPF с привязанной к ней картой программного "
1313 "массива может вызываться со стороны ядра в"
1314
1315 #. type: Plain text
1316 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1317 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1318 #, no-wrap
1319 msgid ""
1320 "void bpf_tail_call(void *context, void *prog_map,\n"
1321 " unsigned int index);\n"
1322 msgstr ""
1323 "void bpf_tail_call(void *context, void *prog_map,\n"
1324 " unsigned int index);\n"
1325
1326 #. type: Plain text
1327 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1328 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1329 msgid ""
1330 "and therefore replace its own program flow with the one from the program at "
1331 "the given program array slot, if present. This can be regarded as kind of a "
1332 "jump table to a different eBPF program. The invoked program will then reuse "
1333 "the same stack. When a jump into the new program has been performed, it "
1334 "won't return to the old program anymore."
1335 msgstr ""
1336 "и, следовательно, заменяет свой собственный программный поток на поток из "
1337 "программы в данном слоте массива программ, если таковой имеется. Это можно "
1338 "рассматривать как своего рода таблицу перехода к другой программе eBPF. "
1339 "Затем вызываемая программа повторно использует тот же стек. Когда будет "
1340 "выполнен переход к новой программе, она больше не вернется к старой "
1341 "программе."
1342
1343 #. MAX_TAIL_CALL_CNT
1344 #. type: Plain text
1345 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1346 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1347 msgid ""
1348 "If no eBPF program is found at the given index of the program array (because "
1349 "the map slot doesn't contain a valid program file descriptor, the specified "
1350 "lookup index/key is out of bounds, or the limit of 32 nested calls has been "
1351 "exceed), execution continues with the current eBPF program. This can be "
1352 "used as a fall-through for default cases."
1353 msgstr ""
1354 "Если программа eBPF не найдена по заданному индексу массива программ "
1355 "(поскольку слот карты не содержит допустимого дескриптора файла программы, "
1356 "указанный индекс/ключ поиска находится за пределами допустимого значения или "
1357 "превышено ограничение в 32 вложенных вызова), выполнение продолжается с "
1358 "текущей программой eBPF. Это может быть использовано в качестве запасного "
1359 "варианта для случаев по умолчанию."
1360
1361 #. type: Plain text
1362 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1363 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1364 msgid ""
1365 "A program array map is useful, for example, in tracing or networking, to "
1366 "handle individual system calls or protocols in their own subprograms and use "
1367 "their identifiers as an individual map index. This approach may result in "
1368 "performance benefits, and also makes it possible to overcome the maximum "
1369 "instruction limit of a single eBPF program. In dynamic environments, a user-"
1370 "space daemon might atomically replace individual subprograms at run-time "
1371 "with newer versions to alter overall program behavior, for instance, if "
1372 "global policies change."
1373 msgstr ""
1374 "Карта программного массива полезна, например, при трассировке или создании "
1375 "сетей для обработки отдельных системных вызовов или протоколов в их "
1376 "собственных подпрограммах и использования их идентификаторов в качестве "
1377 "индивидуального картографического индекса. Такой подход может привести к "
1378 "повышению производительности, а также позволяет преодолеть максимальное "
1379 "ограничение на количество команд в одной программе eBPF. В динамических "
1380 "средах демон пользовательского пространства может атомарно заменять "
1381 "отдельные подпрограммы во время выполнения более новыми версиями, чтобы "
1382 "изменить общее поведение программы, например, при изменении глобальных "
1383 "политик."
1384
1385 #. type: SS
1386 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1387 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1388 #, no-wrap
1389 msgid "eBPF programs"
1390 msgstr "Программы eBPF"
1391
1392 #. type: Plain text
1393 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1394 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1395 msgid ""
1396 "The B<BPF_PROG_LOAD> command is used to load an eBPF program into the "
1397 "kernel. The return value for this command is a new file descriptor "
1398 "associated with this eBPF program."
1399 msgstr ""
1400 "Команда B<BPF_PROG_LOAD> используется для загрузки программы eBPF в ядро. "
1401 "Возвращаемое значение этой команды - это новый файловый дескриптор, "
1402 "связанный с этой программой eBPF."
1403
1404 #. type: Plain text
1405 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1406 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1407 #, no-wrap
1408 msgid ""
1409 "char bpf_log_buf[LOG_BUF_SIZE];\n"
1410 "\\&\n"
1411 "int\n"
1412 "bpf_prog_load(enum bpf_prog_type type,\n"
1413 " const struct bpf_insn *insns, int insn_cnt,\n"
1414 " const char *license)\n"
1415 "{\n"
1416 " union bpf_attr attr = {\n"
1417 " .prog_type = type,\n"
1418 " .insns = ptr_to_u64(insns),\n"
1419 " .insn_cnt = insn_cnt,\n"
1420 " .license = ptr_to_u64(license),\n"
1421 " .log_buf = ptr_to_u64(bpf_log_buf),\n"
1422 " .log_size = LOG_BUF_SIZE,\n"
1423 " .log_level = 1,\n"
1424 " };\n"
1425 "\\&\n"
1426 " return bpf(BPF_PROG_LOAD, &attr, sizeof(attr));\n"
1427 "}\n"
1428 msgstr ""
1429 "char bpf_log_buf[LOG_BUF_SIZE];\n"
1430 "\\&\n"
1431 "int\n"
1432 "bpf_prog_load(enum bpf_prog_type type,\n"
1433 " const struct bpf_insn *insns, int insn_cnt,\n"
1434 " const char *license)\n"
1435 "{\n"
1436 " union bpf_attr attr = {\n"
1437 " .prog_type = type,\n"
1438 " .insns = ptr_to_u64(insns),\n"
1439 " .insn_cnt = insn_cnt,\n"
1440 " .license = ptr_to_u64(license),\n"
1441 " .log_buf = ptr_to_u64(bpf_log_buf),\n"
1442 " .log_size = LOG_BUF_SIZE,\n"
1443 " .log_level = 1,\n"
1444 " };\n"
1445 "\\&\n"
1446 " return bpf(BPF_PROG_LOAD, &attr, sizeof(attr));\n"
1447 "}\n"
1448
1449 #. type: Plain text
1450 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1451 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1452 msgid "I<prog_type> is one of the available program types:"
1453 msgstr "Один из доступных типов программ I<prog_type> это :"
1454
1455 #. type: Plain text
1456 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1457 #: opensuse-tumbleweed
1458 #, fuzzy, no-wrap
1459 #| msgid ""
1460 #| "enum bpf_prog_type {\n"
1461 #| " BPF_PROG_TYPE_UNSPEC, /* Reserve 0 as invalid\n"
1462 #| " program type */\n"
1463 #| " BPF_PROG_TYPE_SOCKET_FILTER,\n"
1464 #| " BPF_PROG_TYPE_KPROBE,\n"
1465 #| " BPF_PROG_TYPE_SCHED_CLS,\n"
1466 #| " BPF_PROG_TYPE_SCHED_ACT,\n"
1467 #| " BPF_PROG_TYPE_TRACEPOINT,\n"
1468 #| " BPF_PROG_TYPE_XDP,\n"
1469 #| " BPF_PROG_TYPE_PERF_EVENT,\n"
1470 #| " BPF_PROG_TYPE_CGROUP_SKB,\n"
1471 #| " BPF_PROG_TYPE_CGROUP_SOCK,\n"
1472 #| " BPF_PROG_TYPE_LWT_IN,\n"
1473 #| " BPF_PROG_TYPE_LWT_OUT,\n"
1474 #| " BPF_PROG_TYPE_LWT_XMIT,\n"
1475 #| " BPF_PROG_TYPE_SOCK_OPS,\n"
1476 #| " BPF_PROG_TYPE_SK_SKB,\n"
1477 #| " BPF_PROG_TYPE_CGROUP_DEVICE,\n"
1478 #| " BPF_PROG_TYPE_SK_MSG,\n"
1479 #| " BPF_PROG_TYPE_RAW_TRACEPOINT,\n"
1480 #| " BPF_PROG_TYPE_CGROUP_SOCK_ADDR,\n"
1481 #| " BPF_PROG_TYPE_LWT_SEG6LOCAL,\n"
1482 #| " BPF_PROG_TYPE_LIRC_MODE2,\n"
1483 #| " BPF_PROG_TYPE_SK_REUSEPORT,\n"
1484 #| " BPF_PROG_TYPE_FLOW_DISSECTOR,\n"
1485 #| " /* See /usr/include/linux/bpf.h for the full list. */\n"
1486 #| "};\n"
1487 msgid ""
1488 "enum bpf_prog_type {\n"
1489 " BPF_PROG_TYPE_UNSPEC, /* Reserve 0 as invalid\n"
1490 " program type */\n"
1491 " BPF_PROG_TYPE_SOCKET_FILTER,\n"
1492 " BPF_PROG_TYPE_KPROBE,\n"
1493 " BPF_PROG_TYPE_SCHED_CLS,\n"
1494 " BPF_PROG_TYPE_SCHED_ACT,\n"
1495 " BPF_PROG_TYPE_TRACEPOINT,\n"
1496 " BPF_PROG_TYPE_XDP,\n"
1497 " BPF_PROG_TYPE_PERF_EVENT,\n"
1498 " BPF_PROG_TYPE_CGROUP_SKB,\n"
1499 " BPF_PROG_TYPE_CGROUP_SOCK,\n"
1500 " BPF_PROG_TYPE_LWT_IN,\n"
1501 " BPF_PROG_TYPE_LWT_OUT,\n"
1502 " BPF_PROG_TYPE_LWT_XMIT,\n"
1503 " BPF_PROG_TYPE_SOCK_OPS,\n"
1504 " BPF_PROG_TYPE_SK_SKB,\n"
1505 " BPF_PROG_TYPE_CGROUP_DEVICE,\n"
1506 " BPF_PROG_TYPE_SK_MSG,\n"
1507 " BPF_PROG_TYPE_RAW_TRACEPOINT,\n"
1508 " BPF_PROG_TYPE_CGROUP_SOCK_ADDR,\n"
1509 " BPF_PROG_TYPE_LWT_SEG6LOCAL,\n"
1510 " BPF_PROG_TYPE_LIRC_MODE2,\n"
1511 " BPF_PROG_TYPE_SK_REUSEPORT,\n"
1512 " BPF_PROG_TYPE_FLOW_DISSECTOR,\n"
1513 " /* See /usr/include/linux/bpf.h for the full list. */\n"
1514 "};\n"
1515 msgstr ""
1516 "enum bpf_prog_type {\n"
1517 " BPF_PROG_TYPE_UNSPEC, /* Reserve 0 as invalid\n"
1518 " program type */\n"
1519 " BPF_PROG_TYPE_SOCKET_FILTER,\n"
1520 " BPF_PROG_TYPE_KPROBE,\n"
1521 " BPF_PROG_TYPE_SCHED_CLS,\n"
1522 " BPF_PROG_TYPE_SCHED_ACT,\n"
1523 " BPF_PROG_TYPE_TRACEPOINT,\n"
1524 " BPF_PROG_TYPE_XDP,\n"
1525 " BPF_PROG_TYPE_PERF_EVENT,\n"
1526 " BPF_PROG_TYPE_CGROUP_SKB,\n"
1527 " BPF_PROG_TYPE_CGROUP_SOCK,\n"
1528 " BPF_PROG_TYPE_LWT_IN,\n"
1529 " BPF_PROG_TYPE_LWT_OUT,\n"
1530 " BPF_PROG_TYPE_LWT_XMIT,\n"
1531 " BPF_PROG_TYPE_SOCK_OPS,\n"
1532 " BPF_PROG_TYPE_SK_SKB,\n"
1533 " BPF_PROG_TYPE_CGROUP_DEVICE,\n"
1534 " BPF_PROG_TYPE_SK_MSG,\n"
1535 " BPF_PROG_TYPE_RAW_TRACEPOINT,\n"
1536 " BPF_PROG_TYPE_CGROUP_SOCK_ADDR,\n"
1537 " BPF_PROG_TYPE_LWT_SEG6LOCAL,\n"
1538 " BPF_PROG_TYPE_LIRC_MODE2,\n"
1539 " BPF_PROG_TYPE_SK_REUSEPORT,\n"
1540 " BPF_PROG_TYPE_FLOW_DISSECTOR,\n"
1541 " /* Смотрите полный список в /usr/include/linux/bpf.h. */\n"
1542 "};\n"
1543
1544 #. type: Plain text
1545 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1546 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1547 msgid "For further details of eBPF program types, see below."
1548 msgstr "Более подробную информацию о типах программ eBPF смотрите ниже."
1549
1550 #. type: Plain text
1551 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1552 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1553 msgid "The remaining fields of I<bpf_attr> are set as follows:"
1554 msgstr "Остальные поля I<bpf_attr> задаются следующим образом:"
1555
1556 #. type: Plain text
1557 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1558 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1559 msgid "I<insns> is an array of I<struct bpf_insn> instructions."
1560 msgstr "I<ins> - это массив инструкций I<struct bpf_insn>."
1561
1562 #. type: Plain text
1563 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1564 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1565 msgid ""
1566 "I<insn_cnt> is the number of instructions in the program referred to by "
1567 "I<insns>."
1568 msgstr ""
1569 "I<insn_cnt> - это количество инструкций в программе, на которые ссылается "
1570 "I<ins>."
1571
1572 #. type: Plain text
1573 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1574 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1575 msgid ""
1576 "I<license> is a license string, which must be GPL compatible to call helper "
1577 "functions marked I<gpl_only>. (The licensing rules are the same as for "
1578 "kernel modules, so that also dual licenses, such as \"Dual BSD/GPL\", may be "
1579 "used.)"
1580 msgstr ""
1581 "I<license> - это строка лицензии, которая должна быть совместима с GPL для "
1582 "вызова вспомогательных функций с пометкой I<gpl_only>. (Правила "
1583 "лицензирования те же, что и для модулей ядра, так что могут использоваться и "
1584 "двойные лицензии, такие как \"Dual BSD/GPL\")."
1585
1586 #. type: Plain text
1587 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1588 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1589 msgid ""
1590 "I<log_buf> is a pointer to a caller-allocated buffer in which the in-kernel "
1591 "verifier can store the verification log. This log is a multi-line string "
1592 "that can be checked by the program author in order to understand how the "
1593 "verifier came to the conclusion that the eBPF program is unsafe. The format "
1594 "of the output can change at any time as the verifier evolves."
1595 msgstr ""
1596 "I<log_buf> - это указатель на выделенный вызывающим пользователем буфер, в "
1597 "котором встроенный в ядро верификатор может хранить журнал проверки. Этот "
1598 "журнал представляет собой многострочную строку, которую автор программы "
1599 "может проверить, чтобы понять, как верификатор пришел к выводу, что "
1600 "программа eBPF небезопасна. Формат выходных данных может измениться в любое "
1601 "время по мере развития верификатора."
1602
1603 #. type: Plain text
1604 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1605 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1606 msgid ""
1607 "I<log_size> size of the buffer pointed to by I<log_buf>. If the size of the "
1608 "buffer is not large enough to store all verifier messages, -1 is returned "
1609 "and I<errno> is set to B<ENOSPC>."
1610 msgstr ""
1611 "I<log_size> - размер буфера, на который указывает параметр I<log_buf>. Если "
1612 "размер буфера недостаточно велик для хранения всех сообщений средства "
1613 "проверки, возвращается значение -1, а для параметра I<errno> устанавливается "
1614 "значение B<ENOSPC>."
1615
1616 #. type: Plain text
1617 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1618 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1619 msgid ""
1620 "I<log_level> verbosity level of the verifier. A value of zero means that "
1621 "the verifier will not provide a log; in this case, I<log_buf> must be a null "
1622 "pointer, and I<log_size> must be zero."
1623 msgstr ""
1624 "I<log_level> - уровень детализации верификатора. Нулевое значение означает, "
1625 "что верификатор не будет обеспечивать журналирование; в этом случае "
1626 "I<log_buf> должен быть нулевым указателем, а I<log_size> должен быть равен "
1627 "нулю."
1628
1629 #. type: Plain text
1630 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1631 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1632 msgid ""
1633 "Applying B<close>(2) to the file descriptor returned by B<BPF_PROG_LOAD> "
1634 "will unload the eBPF program (but see NOTES)."
1635 msgstr ""
1636 "Применение B<close>(2) к файловому дескриптору, возвращаемому "
1637 "B<BPF_PROG_LOAD>, приведет к выгрузке программы eBPF (однако, смотрите "
1638 "ПРИМЕЧАНИЯ)."
1639
1640 #. type: Plain text
1641 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1642 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1643 msgid ""
1644 "Maps are accessible from eBPF programs and are used to exchange data between "
1645 "eBPF programs and between eBPF programs and user-space programs. For "
1646 "example, eBPF programs can process various events (like kprobe, packets) and "
1647 "store their data into a map, and user-space programs can then fetch data "
1648 "from the map. Conversely, user-space programs can use a map as a "
1649 "configuration mechanism, populating the map with values checked by the eBPF "
1650 "program, which then modifies its behavior on the fly according to those "
1651 "values."
1652 msgstr ""
1653 "Карты доступны из программ eBPF и используются для обмена данными между "
1654 "программами eBPF, а также между программами eBPF и программами "
1655 "пользовательского пространства. Например, программы eBPF могут обрабатывать "
1656 "различные события (например, kprobe, пакеты) и сохранять их данные на карте, "
1657 "а программы пользовательского пространства могут затем извлекать данные с "
1658 "карты. И наоборот, пользовательские программы могут использовать карту в "
1659 "качестве механизма настройки, заполняя карту значениями, проверенными "
1660 "программой eBPF, которая затем изменяет свое поведение на лету в "
1661 "соответствии с этими значениями."
1662
1663 #. type: SS
1664 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1665 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1666 #, no-wrap
1667 msgid "eBPF program types"
1668 msgstr "Типы программ eBPF"
1669
1670 #
1671 #. #-#-#-#-# archlinux: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1672 #. FIXME
1673 #. Somewhere in this page we need a general introduction to the
1674 #. bpf_context. For example, how does a BPF program access the
1675 #. context?
1676 #. type: Plain text
1677 #. #-#-#-#-# debian-trixie: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1678 #. FIXME
1679 #. Somewhere in this page we need a general introduction to the
1680 #. bpf_context. For example, how does a BPF program access the
1681 #. context?
1682 #. type: Plain text
1683 #. #-#-#-#-# debian-unstable: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1684 #. FIXME
1685 #. Somewhere in this page we need a general introduction to the
1686 #. bpf_context. For example, how does a BPF program access the
1687 #. context?
1688 #. type: Plain text
1689 #. #-#-#-#-# fedora-44: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1690 #. FIXME
1691 #. Somewhere in this page we need a general introduction to the
1692 #. bpf_context. For example, how does a BPF program access the
1693 #. context?
1694 #. type: Plain text
1695 #. #-#-#-#-# fedora-rawhide: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1696 #. FIXME
1697 #. Somewhere in this page we need a general introduction to the
1698 #. bpf_context. For example, how does a BPF program access the
1699 #. context?
1700 #. type: Plain text
1701 #. #-#-#-#-# mageia-cauldron: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1702 #. FIXME
1703 #. Somewhere in this page we need a general introduction to the
1704 #. bpf_context. For example, how does a BPF program access the
1705 #. context?
1706 #. type: Plain text
1707 #. #-#-#-#-# opensuse-leap-16-1: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1708 #. FIXME
1709 #. Somewhere in this page we need a general introduction to the
1710 #. bpf_context. For example, how does a BPF program access the
1711 #. context?
1712 #. type: Plain text
1713 #. #-#-#-#-# opensuse-tumbleweed: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
1714 #. FIXME
1715 #. Somewhere in this page we need a general introduction to the
1716 #. bpf_context. For example, how does a BPF program access the
1717 #. context?
1718 #. type: Plain text
1719 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1720 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1721 msgid ""
1722 "The eBPF program type (I<prog_type>) determines the subset of kernel helper "
1723 "functions that the program may call. The program type also determines the "
1724 "program input (context)\\[em]the format of I<struct bpf_context> (which is "
1725 "the data blob passed into the eBPF program as the first argument)."
1726 msgstr ""
1727 "Тип программы eBPF (I<prog_type>) определяет подмножество вспомогательных "
1728 "функций ядра, которые может вызывать программа. Тип программы также "
1729 "определяет вводимые программой данные (содержимое) в формате I<struct "
1730 "bpf_context>, который представляет собой большой двоичный объект данных, "
1731 "передаваемый в программу eBPF в качестве первого аргумента."
1732
1733 #. type: Plain text
1734 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1735 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1736 msgid ""
1737 "For example, a tracing program does not have the exact same subset of helper "
1738 "functions as a socket filter program (though they may have some helpers in "
1739 "common). Similarly, the input (context) for a tracing program is a set of "
1740 "register values, while for a socket filter it is a network packet."
1741 msgstr ""
1742 "Например, программа трассировки не имеет точно такого же набора "
1743 "вспомогательных функций, как программа фильтрации сокетов (хотя у них могут "
1744 "быть некоторые общие вспомогательные функции). Аналогично, входными данными "
1745 "(контекстом) для программы трассировки является набор значений регистров, в "
1746 "то время как для фильтра сокетов это сетевой пакет."
1747
1748 #. type: Plain text
1749 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1750 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1751 msgid ""
1752 "The set of functions available to eBPF programs of a given type may increase "
1753 "in the future."
1754 msgstr ""
1755 "В будущем набор функций, доступных для программ eBPF данного типа, может "
1756 "быть расширен."
1757
1758 #. type: Plain text
1759 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1760 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1761 msgid "The following program types are supported:"
1762 msgstr "Поддерживаются следующие типы программ:"
1763
1764 #. type: TP
1765 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1766 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1767 #, no-wrap
1768 msgid "B<BPF_PROG_TYPE_SOCKET_FILTER> (since Linux 3.19)"
1769 msgstr "B<BPF_PROG_TYPE_SOCKET_FILTER> (начиная с версии Linux 3.19)"
1770
1771 #. type: Plain text
1772 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1773 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1774 msgid "Currently, the set of functions for B<BPF_PROG_TYPE_SOCKET_FILTER> is:"
1775 msgstr ""
1776 "В настоящее время набор функций для B<BPF_PROG_TYPE_SOCKET_FILTER> содержит:"
1777
1778 #. type: Plain text
1779 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1780 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1781 #, no-wrap
1782 msgid ""
1783 "bpf_map_lookup_elem(map_fd, void *key)\n"
1784 " /* look up key in a map_fd */\n"
1785 "bpf_map_update_elem(map_fd, void *key, void *value)\n"
1786 " /* update key/value */\n"
1787 "bpf_map_delete_elem(map_fd, void *key)\n"
1788 " /* delete key in a map_fd */\n"
1789 msgstr ""
1790 "bpf_map_lookup_elem(map_fd, void *key)\n"
1791 " /* look up key in a map_fd */\n"
1792 "bpf_map_update_elem(map_fd, void *key, void *value)\n"
1793 " /* update key/value */\n"
1794 "bpf_map_delete_elem(map_fd, void *key)\n"
1795 " /* delete key in a map_fd */\n"
1796
1797 #
1798 #. FIXME: We need some text here to explain how the program
1799 #. accesses __sk_buff.
1800 #. See 'struct __sk_buff' and commit 9bac3d6d548e5
1801 #. Alexei commented:
1802 #. Actually now in case of SOCKET_FILTER, SCHED_CLS, SCHED_ACT
1803 #. the program can now access skb fields.
1804 #. type: Plain text
1805 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1806 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1807 msgid "The I<bpf_context> argument is a pointer to a I<struct __sk_buff>."
1808 msgstr "Аргумент I<bpf_context> является указателем на I<struct __sk_buff>."
1809
1810 #. type: TP
1811 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1812 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1813 #, no-wrap
1814 msgid "B<BPF_PROG_TYPE_KPROBE> (since Linux 4.1)"
1815 msgstr "B<BPF_PROG_TYPE_KPROBE> (начиная с версии Linux 4.1)"
1816
1817 #. commit 94caee8c312d96522bcdae88791aaa9ebcd5f22c
1818 #. commit a8cb5f556b567974d75ea29c15181c445c541b1f
1819 #. FIXME Document this program type
1820 #. Describe allowed helper functions for this program type
1821 #. Describe bpf_context for this program type
1822 #. type: Plain text
1823 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1824 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1825 msgid "[To be documented]"
1826 msgstr "[Будет описано]"
1827
1828 #. type: TP
1829 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1830 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1831 #, no-wrap
1832 msgid "B<BPF_PROG_TYPE_SCHED_CLS> (since Linux 4.1)"
1833 msgstr "B<BPF_PROG_TYPE_SCHED_CLS> (начиная с версии Linux 4.1)"
1834
1835 #. type: TP
1836 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1837 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1838 #, no-wrap
1839 msgid "B<BPF_PROG_TYPE_SCHED_ACT> (since Linux 4.1)"
1840 msgstr "B<BPF_PROG_TYPE_SCHED_ACT> (начиная с версии Linux 4.1)"
1841
1842 #. type: SS
1843 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1844 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1845 #, no-wrap
1846 msgid "Events"
1847 msgstr "События"
1848
1849 #. type: Plain text
1850 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1851 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1852 msgid ""
1853 "Once a program is loaded, it can be attached to an event. Various kernel "
1854 "subsystems have different ways to do so."
1855 msgstr ""
1856 "Как только программа загружена, ее можно привязать к событию. В различных "
1857 "подсистемах ядра это делается по-разному."
1858
1859 #. commit 89aa075832b0da4402acebd698d0411dcc82d03e
1860 #. type: Plain text
1861 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1862 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1863 msgid ""
1864 "Since Linux 3.19, the following call will attach the program I<prog_fd> to "
1865 "the socket I<sockfd>, which was created by an earlier call to B<socket>(2):"
1866 msgstr ""
1867 "Начиная с Linux 3.19, следующий вызов присоединяет программу I<prog_fd> к "
1868 "сокету I<sockfd>, который был создан предыдущим вызовом B<socket>(2).:"
1869
1870 #. type: Plain text
1871 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1872 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1873 #, no-wrap
1874 msgid ""
1875 "setsockopt(sockfd, SOL_SOCKET, SO_ATTACH_BPF,\n"
1876 " &prog_fd, sizeof(prog_fd));\n"
1877 msgstr ""
1878 "setsockopt(sockfd, SOL_SOCKET, SO_ATTACH_BPF,\n"
1879 " &prog_fd, sizeof(prog_fd));\n"
1880
1881 #. commit 2541517c32be2531e0da59dfd7efc1ce844644f5
1882 #. type: Plain text
1883 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1884 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1885 msgid ""
1886 "Since Linux 4.1, the following call may be used to attach the eBPF program "
1887 "referred to by the file descriptor I<prog_fd> to a perf event file "
1888 "descriptor, I<event_fd>, that was created by a previous call to "
1889 "B<perf_event_open>(2):"
1890 msgstr ""
1891 "Начиная с Linux 4.1, следующий вызов может использоваться для присоединения "
1892 "программы eBPF, на которую ссылается файловый дескриптор I<prog_fd>, к "
1893 "файловому дескриптору события perf, I<event_fd>, который был создан "
1894 "предыдущим вызовом B<perf_event_open>(2):"
1895
1896 #. type: Plain text
1897 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1898 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1899 #, no-wrap
1900 msgid "ioctl(event_fd, PERF_EVENT_IOC_SET_BPF, prog_fd);\n"
1901 msgstr "ioctl(event_fd, PERF_EVENT_IOC_SET_BPF, prog_fd);\n"
1902
1903 #. type: SH
1904 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1905 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1906 #, no-wrap
1907 msgid "RETURN VALUE"
1908 msgstr "ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ"
1909
1910 #. type: Plain text
1911 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1912 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1913 msgid "For a successful call, the return value depends on the operation:"
1914 msgstr ""
1915 "При успешном выполнении возвращаемое значение зависит от используемой "
1916 "команды:"
1917
1918 #. type: Plain text
1919 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1920 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1921 msgid "The new file descriptor associated with the eBPF map."
1922 msgstr "Новый файловый дескриптор, связанный с картой eBPF."
1923
1924 #. type: Plain text
1925 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1926 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1927 msgid "The new file descriptor associated with the eBPF program."
1928 msgstr "Новый файловый дескриптор, связанный с программой eBPF."
1929
1930 #. type: TP
1931 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1932 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1933 #, no-wrap
1934 msgid "All other commands"
1935 msgstr "Все остальные команды"
1936
1937 #. type: Plain text
1938 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1939 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1940 msgid "Zero."
1941 msgstr "Ноль."
1942
1943 #. type: Plain text
1944 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1945 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1946 msgid "On error, -1 is returned, and I<errno> is set to indicate the error."
1947 msgstr ""
1948 "В случае ошибки возвращается -1, а I<errno> устанавливается в значение "
1949 "ошибки."
1950
1951 #. type: SH
1952 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1953 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1954 #, no-wrap
1955 msgid "ERRORS"
1956 msgstr "ОШИБКИ"
1957
1958 #. type: TP
1959 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1960 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1961 #, no-wrap
1962 msgid "B<E2BIG>"
1963 msgstr "B<E2BIG>"
1964
1965 #. type: Plain text
1966 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1967 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1968 msgid ""
1969 "The eBPF program is too large or a map reached the I<max_entries> limit "
1970 "(maximum number of elements)."
1971 msgstr ""
1972 "Программа eBPF слишком велика, или карта достигла предела I<max_entries> "
1973 "(максимальное количество элементов)."
1974
1975 #. type: TP
1976 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1977 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1978 #, no-wrap
1979 msgid "B<EACCES>"
1980 msgstr "B<EACCES>"
1981
1982 #. type: Plain text
1983 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1984 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1985 msgid ""
1986 "For B<BPF_PROG_LOAD>, even though all program instructions are valid, the "
1987 "program has been rejected because it was deemed unsafe. This may be because "
1988 "it may have accessed a disallowed memory region or an uninitialized stack/"
1989 "register or because the function constraints don't match the actual types or "
1990 "because there was a misaligned memory access. In this case, it is "
1991 "recommended to call B<bpf>() again with I<log_level = 1> and examine "
1992 "I<log_buf> for the specific reason provided by the verifier."
1993 msgstr ""
1994 "Для B<BPF_PROG_LOAD>, несмотря на то, что все инструкции программы верны, "
1995 "программа была отклонена, поскольку была признана небезопасной. Это может "
1996 "быть связано с тем, что она может получить доступ к запрещенной области "
1997 "памяти или к не инициализированному стеку/регистру, или с тем, что "
1998 "ограничения функции не соответствуют фактическим типам, или с тем, что "
1999 "доступ к памяти был несогласован. В этом случае рекомендуется снова вызвать "
2000 "B<bpf>() с I<log_level = 1> и проверить I<log_buf> о конкретной причине, "
2001 "указанной верификатором."
2002
2003 #. type: TP
2004 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2005 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2006 #, no-wrap
2007 msgid "B<EAGAIN>"
2008 msgstr "B<EAGAIN>"
2009
2010 #. type: Plain text
2011 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2012 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2013 msgid ""
2014 "For B<BPF_PROG_LOAD>, indicates that needed resources are blocked. This "
2015 "happens when the verifier detects pending signals while it is checking the "
2016 "validity of the bpf program. In this case, just call B<bpf>() again with "
2017 "the same parameters."
2018 msgstr ""
2019 "Для параметра B<BPF_PROG_LOAD> указывает, что необходимые ресурсы "
2020 "заблокированы. Это происходит, когда верификатор обнаруживает ожидающие "
2021 "отправки сигналы во время проверки работоспособности программы bpf. В этом "
2022 "случае просто вызовите B<bpf>() еще раз с теми же параметрами."
2023
2024 #. type: TP
2025 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2026 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2027 #, no-wrap
2028 msgid "B<EBADF>"
2029 msgstr "B<EBADF>"
2030
2031 #. type: Plain text
2032 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2033 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2034 msgid "I<fd> is not an open file descriptor."
2035 msgstr "I<fd> не является открытым файловым дескриптором."
2036
2037 #. type: TP
2038 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2039 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2040 #, no-wrap
2041 msgid "B<EFAULT>"
2042 msgstr "B<EFAULT>"
2043
2044 #. type: Plain text
2045 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2046 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2047 msgid ""
2048 "One of the pointers (I<key> or I<value> or I<log_buf> or I<insns>) is "
2049 "outside the accessible address space."
2050 msgstr ""
2051 "Один из указателей (I<key> или I<value>, или I<log_buf>, или I<ins>) "
2052 "находится за пределами доступного адресного пространства."
2053
2054 #. type: TP
2055 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2056 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2057 #, no-wrap
2058 msgid "B<EINVAL>"
2059 msgstr "B<EINVAL>"
2060
2061 #. type: Plain text
2062 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2063 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2064 msgid "The value specified in I<cmd> is not recognized by this kernel."
2065 msgstr "Значение I<cmd> не распознано ядром."
2066
2067 #. type: Plain text
2068 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2069 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2070 msgid "For B<BPF_MAP_CREATE>, either I<map_type> or attributes are invalid."
2071 msgstr "Для B<BPF_MAP_CREATE> либо I<map_type>, либо атрибуты недопустимы."
2072
2073 #. type: Plain text
2074 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2075 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2076 msgid ""
2077 "For B<BPF_MAP_*_ELEM> commands, some of the fields of I<union bpf_attr> that "
2078 "are not used by this command are not set to zero."
2079 msgstr ""
2080 "Для команд B<BPF_MAP_*_ELEM> некоторые поля I<union bpf_attr>, которые не "
2081 "используются этой командой, не имеют нулевого значения. "
2082
2083 #. type: Plain text
2084 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2085 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2086 msgid ""
2087 "For B<BPF_PROG_LOAD>, indicates an attempt to load an invalid program. eBPF "
2088 "programs can be deemed invalid due to unrecognized instructions, the use of "
2089 "reserved fields, jumps out of range, infinite loops or calls of unknown "
2090 "functions."
2091 msgstr ""
2092 "Для B<BPF_PROG_LOAD> указывает на попытку загрузки недопустимой программы. "
2093 "Программы eBPF могут быть признаны недействительными из-за нераспознанных "
2094 "инструкций, использования зарезервированных полей, выхода за пределы "
2095 "диапазона, бесконечных циклов или вызовов неизвестных функций."
2096
2097 #. type: TP
2098 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2099 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2100 #, no-wrap
2101 msgid "B<ENOENT>"
2102 msgstr "B<ENOENT>"
2103
2104 #. type: Plain text
2105 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2106 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2107 msgid ""
2108 "For B<BPF_MAP_LOOKUP_ELEM> or B<BPF_MAP_DELETE_ELEM>, indicates that the "
2109 "element with the given I<key> was not found."
2110 msgstr ""
2111 "Для B<BPF_MAP_LOOKUP_ELEM> или B<BPF_MAP_DELETE_ELEM> указывает, что элемент "
2112 "с заданным значением I<key> не найден."
2113
2114 #. type: TP
2115 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2116 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2117 #, no-wrap
2118 msgid "B<ENOMEM>"
2119 msgstr "B<ENOMEM>"
2120
2121 #. type: Plain text
2122 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2123 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2124 msgid "Cannot allocate sufficient memory."
2125 msgstr "Не удается выделить достаточно памяти."
2126
2127 #. type: TP
2128 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2129 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2130 #, no-wrap
2131 msgid "B<EPERM>"
2132 msgstr "B<EPERM>"
2133
2134 #. type: Plain text
2135 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2136 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2137 msgid ""
2138 "The call was made without sufficient privilege (without the B<CAP_SYS_ADMIN> "
2139 "capability)."
2140 msgstr ""
2141 "Вызов был выполнен без достаточных привилегий (без возможности "
2142 "B<CAP_SYS_ADMIN>)."
2143
2144 #. type: SH
2145 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2146 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2147 #, no-wrap
2148 msgid "STANDARDS"
2149 msgstr "СТАНДАРТЫ"
2150
2151 #. type: Plain text
2152 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2153 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2154 msgid "Linux."
2155 msgstr "Linux."
2156
2157 #. type: SH
2158 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2159 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2160 #, no-wrap
2161 msgid "HISTORY"
2162 msgstr "ИСТОРИЯ"
2163
2164 #. type: Plain text
2165 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2166 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2167 msgid "Linux 3.18."
2168 msgstr "Linux 3.18."
2169
2170 #. type: SH
2171 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2172 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2173 #, no-wrap
2174 msgid "NOTES"
2175 msgstr "ПРИМЕЧАНИЯ"
2176
2177 #. commit 1be7f75d1668d6296b80bf35dcf6762393530afc
2178 #. [Linux 5.6] mtk: The list of available functions is, I think, governed
2179 #. by the check in net/core/filter.c::bpf_base_func_proto().
2180 #. type: Plain text
2181 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2182 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2183 msgid ""
2184 "Prior to Linux 4.4, all B<bpf>() commands require the caller to have the "
2185 "B<CAP_SYS_ADMIN> capability. From Linux 4.4 onwards, an unprivileged user "
2186 "may create limited programs of type B<BPF_PROG_TYPE_SOCKET_FILTER> and "
2187 "associated maps. However they may not store kernel pointers within the maps "
2188 "and are presently limited to the following helper functions:"
2189 msgstr ""
2190 "До Linux 4.4 все команды B<bpf>() требовали, чтобы вызывающий объект обладал "
2191 "возможностями B<CAP_SYS_ADMIN>. Начиная с Linux 4.4, непривилегированный "
2192 "пользователь может создавать ограниченные программы типа "
2193 "B<BPF_PROG_TYPE_SOCKET_FILTER> и связанные с ними карты. Однако они не могут "
2194 "хранить указатели ядра в картах и в настоящее время ограничены следующими "
2195 "вспомогательными функциями:"
2196
2197 #. type: Plain text
2198 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2199 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2200 msgid "get_random"
2201 msgstr "get_random"
2202
2203 #. type: Plain text
2204 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2205 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2206 msgid "get_smp_processor_id"
2207 msgstr "get_smp_processor_id"
2208
2209 #. type: Plain text
2210 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2211 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2212 msgid "tail_call"
2213 msgstr "tail_call"
2214
2215 #. type: Plain text
2216 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2217 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2218 msgid "ktime_get_ns"
2219 msgstr "ktime_get_ns"
2220
2221 #. type: Plain text
2222 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2223 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2224 msgid ""
2225 "Unprivileged access may be blocked by writing the value 1 to the file I</"
2226 "proc/sys/kernel/unprivileged_bpf_disabled>."
2227 msgstr ""
2228 "Непривилегированный доступ может быть заблокирован путем записи значения 1 в "
2229 "файл I</proc/sys/kernel/unprivileged_bpf_disabled>."
2230
2231 #. type: Plain text
2232 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2233 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2234 msgid ""
2235 "eBPF objects (maps and programs) can be shared between processes. For "
2236 "example, after B<fork>(2), the child inherits file descriptors referring to "
2237 "the same eBPF objects. In addition, file descriptors referring to eBPF "
2238 "objects can be transferred over UNIX domain sockets. File descriptors "
2239 "referring to eBPF objects can be duplicated in the usual way, using "
2240 "B<dup>(2) and similar calls. An eBPF object is deallocated only after all "
2241 "file descriptors referring to the object have been closed."
2242 msgstr ""
2243 "Объекты eBPF (карты и программы) могут совместно использоваться процессами. "
2244 "Например, после B<fork>(2) дочерний процесс наследует файловые дескрипторы, "
2245 "относящиеся к тем же объектам eBPF. Кроме того, файловые дескрипторы, "
2246 "ссылающиеся на объекты eBPF, могут передаваться через доменные сокеты UNIX. "
2247 "Файловые дескрипторы, ссылающиеся на объекты eBPF, можно дублировать обычным "
2248 "способом, используя B<dup>(2) и аналогичные вызовы. Объект eBPF "
2249 "освобождается только после того, как все файловые дескрипторы, ссылающиеся "
2250 "на этот объект, будут закрыты."
2251
2252 #. There are also examples for the tc classifier, in the iproute2
2253 #. project, in examples/bpf
2254 #. type: Plain text
2255 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2256 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2257 msgid ""
2258 "eBPF programs can be written in a restricted C that is compiled (using the "
2259 "B<clang> compiler) into eBPF bytecode. Various features are omitted from "
2260 "this restricted C, such as loops, global variables, variadic functions, "
2261 "floating-point numbers, and passing structures as function arguments. Some "
2262 "examples can be found in the I<samples/bpf/*_kern.c> files in the kernel "
2263 "source tree."
2264 msgstr ""
2265 "Программы eBPF могут быть написаны на ограниченном языке С, который "
2266 "компилируется (с помощью компилятора B<clang>) в байт-код bpf. В этом "
2267 "ограниченном C отсутствуют различные функции, такие как циклы, глобальные "
2268 "переменные, функции с переменным числом, числа с плавающей запятой и "
2269 "передача структур в качестве аргументов функций. Некоторые примеры можно "
2270 "найти в файлах I<samples/bpf/*_kern.c> в дереве исходных текстов ядра. "
2271
2272 #. type: Plain text
2273 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2274 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2275 msgid ""
2276 "The kernel contains a just-in-time (JIT) compiler that translates eBPF "
2277 "bytecode into native machine code for better performance. Before Linux "
2278 "4.15, the JIT compiler is disabled by default, but its operation can be "
2279 "controlled by writing one of the following integer strings to the file I</"
2280 "proc/sys/net/core/bpf_jit_enable>:"
2281 msgstr ""
2282 "Ядро содержит JIT-компилятор, который преобразует байт-код bpf в машинный "
2283 "код для повышения производительности. До Linux 4.15 JIT-компилятор по "
2284 "умолчанию отключен, но его работой можно управлять, записав одно из "
2285 "следующих целых чисел в файл I</proc/sys/net/core/bpf_jit_enable>:"
2286
2287 #. type: TP
2288 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2289 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2290 #, no-wrap
2291 msgid "B<0>"
2292 msgstr "B<0>"
2293
2294 #. type: Plain text
2295 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2296 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2297 msgid "Disable JIT compilation (default)."
2298 msgstr "Отключить JIT-компиляцию (по умолчанию)."
2299
2300 #. type: TP
2301 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2302 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2303 #, no-wrap
2304 msgid "B<1>"
2305 msgstr "B<1>"
2306
2307 #. type: Plain text
2308 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2309 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2310 msgid "Normal compilation."
2311 msgstr "Обычная компиляция."
2312
2313 #. type: TP
2314 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2315 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2316 #, no-wrap
2317 msgid "B<2>"
2318 msgstr "B<2>"
2319
2320 #. type: Plain text
2321 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2322 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2323 msgid ""
2324 "Debugging mode. The generated opcodes are dumped in hexadecimal into the "
2325 "kernel log. These opcodes can then be disassembled using the program "
2326 "I<tools/net/bpf_jit_disasm.c> provided in the kernel source tree."
2327 msgstr ""
2328 "Режим отладки. Сгенерированные коды операций в шестнадцатеричном формате "
2329 "записываются в журнал ядра. Затем эти коды операций можно разобрать с "
2330 "помощью программы I<tools/net/bpf_jit_disasm.c>, представленной в дереве "
2331 "исходных текстов ядра."
2332
2333 #. commit 290af86629b25ffd1ed6232c4e9107da031705cb
2334 #. type: Plain text
2335 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2336 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2337 msgid ""
2338 "Since Linux 4.15, the kernel may be configured with the "
2339 "B<CONFIG_BPF_JIT_ALWAYS_ON> option. In this case, the JIT compiler is "
2340 "always enabled, and the I<bpf_jit_enable> is initialized to 1 and is "
2341 "immutable. (This kernel configuration option was provided as a mitigation "
2342 "for one of the Spectre attacks against the BPF interpreter.)"
2343 msgstr ""
2344 "Начиная с Linux 4.15, ядро может быть настроено с помощью параметра "
2345 "B<CONFIG_BPF_JIT_ALWAYS_ON>. В этом случае JIT-компилятор всегда включен, а "
2346 "параметр I<bpf_jit_enable> инициализируется значением 1 и является "
2347 "неизменяемым. Этот параметр конфигурации ядра был предоставлен в качестве "
2348 "средства защиты от одной из атак Spectre на интерпретатор BPF."
2349
2350 #. #-#-#-#-# archlinux: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
2351 #. type: Plain text
2352 #. #-#-#-#-# debian-trixie: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
2353 #. Last reviewed in Linux 4.18-rc by grepping for BPF_ALU64 in arch/
2354 #. and by checking the documentation for bpf_jit_enable in
2355 #. Documentation/sysctl/net.txt
2356 #. type: Plain text
2357 #. #-#-#-#-# debian-unstable: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
2358 #. type: Plain text
2359 #. #-#-#-#-# fedora-44: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
2360 #. Last reviewed in Linux 4.18-rc by grepping for BPF_ALU64 in arch/
2361 #. and by checking the documentation for bpf_jit_enable in
2362 #. Documentation/sysctl/net.txt
2363 #. type: Plain text
2364 #. #-#-#-#-# fedora-rawhide: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
2365 #. Last reviewed in Linux 4.18-rc by grepping for BPF_ALU64 in arch/
2366 #. and by checking the documentation for bpf_jit_enable in
2367 #. Documentation/sysctl/net.txt
2368 #. type: Plain text
2369 #. #-#-#-#-# mageia-cauldron: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
2370 #. type: Plain text
2371 #. #-#-#-#-# opensuse-leap-16-1: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
2372 #. type: Plain text
2373 #. #-#-#-#-# opensuse-tumbleweed: bpf.2.pot (PACKAGE VERSION) #-#-#-#-#
2374 #. type: Plain text
2375 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2376 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2377 msgid ""
2378 "The JIT compiler for eBPF is currently available for the following "
2379 "architectures:"
2380 msgstr ""
2381 "JIT-компилятор для bpf в настоящее время доступен для следующих архитектур:"
2382
2383 #. commit 0a14842f5a3c0e88a1e59fac5c3025db39721f74
2384 #. type: Plain text
2385 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2386 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2387 msgid "x86-64 (since Linux 3.18; cBPF since Linux 3.0);"
2388 msgstr "x86-64 (начиная с Linux 3.18; cBPF начиная с Linux 3.0);"
2389
2390 #. commit ddecdfcea0ae891f782ae853771c867ab51024c2
2391 #. type: Plain text
2392 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2393 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2394 msgid "ARM32 (since Linux 3.18; cBPF since Linux 3.4);"
2395 msgstr "ARM32 (начиная с Linux 3.18; cBPF начиная с Linux 3.4);"
2396
2397 #. commit 2809a2087cc44b55e4377d7b9be3f7f5d2569091
2398 #. type: Plain text
2399 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2400 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2401 msgid "SPARC 32 (since Linux 3.18; cBPF since Linux 3.5);"
2402 msgstr "SPARC 32 (начиная с Linux 3.18; cBPF начиная с Linux 3.5);"
2403
2404 #. commit e54bcde3d69d40023ae77727213d14f920eb264a
2405 #. type: Plain text
2406 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2407 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2408 msgid "ARM-64 (since Linux 3.18);"
2409 msgstr "ARM-64 (начиная с Linux 3.18);"
2410
2411 #. commit c10302efe569bfd646b4c22df29577a4595b4580
2412 #. type: Plain text
2413 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2414 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2415 msgid "s390 (since Linux 4.1; cBPF since Linux 3.7);"
2416 msgstr "s390 (начиная с Linux 4.1; cBPF начиная с Linux 3.7);"
2417
2418 #. commit 0ca87f05ba8bdc6791c14878464efc901ad71e99
2419 #. commit 156d0e290e969caba25f1851c52417c14d141b24
2420 #. type: Plain text
2421 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2422 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2423 msgid "PowerPC 64 (since Linux 4.8; cBPF since Linux 3.1);"
2424 msgstr "PowerPC 64 (начиная с Linux 4.8; cBPF начиная с Linux 3.1);"
2425
2426 #. commit 7a12b5031c6b947cc13918237ae652b536243b76
2427 #. type: Plain text
2428 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2429 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2430 msgid "SPARC 64 (since Linux 4.12);"
2431 msgstr "SPARC 64 (начиная с Linux 4.12);"
2432
2433 #. commit 03f5781be2c7b7e728d724ac70ba10799cc710d7
2434 #. type: Plain text
2435 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2436 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2437 msgid "x86-32 (since Linux 4.18);"
2438 msgstr "x86-32 (начиная с Linux 4.18);"
2439
2440 #. commit c6610de353da5ca6eee5b8960e838a87a90ead0c
2441 #. commit f381bf6d82f032b7410185b35d000ea370ac706b
2442 #. type: Plain text
2443 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2444 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2445 msgid "MIPS 64 (since Linux 4.18; cBPF since Linux 3.16);"
2446 msgstr "MIPS 64 (начиная с Linux 4.18; cBPF начиная с Linux 3.16);"
2447
2448 #. commit 2353ecc6f91fd15b893fa01bf85a1c7a823ee4f2
2449 #. type: Plain text
2450 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2451 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2452 msgid "riscv (since Linux 5.1)."
2453 msgstr "riscv (начиная с Linux 5.1)."
2454
2455 #. type: SH
2456 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2457 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2458 #, no-wrap
2459 msgid "EXAMPLES"
2460 msgstr "ПРИМЕРЫ"
2461
2462 #. == atomic64_add
2463 #. type: Plain text
2464 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
2465 #: opensuse-tumbleweed
2466 #, fuzzy, no-wrap
2467 #| msgid ""
2468 #| "/* bpf+sockets example:\n"
2469 #| " * 1. create array map of 256 elements\n"
2470 #| " * 2. load program that counts number of packets received\n"
2471 #| " * r0 = skb-E<gt>data[ETH_HLEN + offsetof(struct iphdr, protocol)]\n"
2472 #| " * map[r0]++\n"
2473 #| " * 3. attach prog_fd to raw socket via setsockopt()\n"
2474 #| " * 4. print number of received TCP/UDP packets every second\n"
2475 #| " */\n"
2476 #| "int\n"
2477 #| "main(int argc, char *argv[])\n"
2478 #| "{\n"
2479 #| " int sock, map_fd, prog_fd, key;\n"
2480 #| " long long value = 0, tcp_cnt, udp_cnt;\n"
2481 #| "\\&\n"
2482 #| " map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(key),\n"
2483 #| " sizeof(value), 256);\n"
2484 #| " if (map_fd E<lt> 0) {\n"
2485 #| " printf(\"failed to create map \\[aq]%s\\[aq]\\[rs]n\", strerror(errno));\n"
2486 #| " /* likely not run as root */\n"
2487 #| " return 1;\n"
2488 #| " }\n"
2489 #| "\\&\n"
2490 #| " struct bpf_insn prog[] = {\n"
2491 #| " BPF_MOV64_REG(BPF_REG_6, BPF_REG_1), /* r6 = r1 */\n"
2492 #| " BPF_LD_ABS(BPF_B, ETH_HLEN + offsetof(struct iphdr, protocol)),\n"
2493 #| " /* r0 = ip-E<gt>proto */\n"
2494 #| " BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_0, -4),\n"
2495 #| " /* *(u32 *)(fp - 4) = r0 */\n"
2496 #| " BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), /* r2 = fp */\n"
2497 #| " BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -4), /* r2 = r2 - 4 */\n"
2498 #| " BPF_LD_MAP_FD(BPF_REG_1, map_fd), /* r1 = map_fd */\n"
2499 #| " BPF_CALL_FUNC(BPF_FUNC_map_lookup_elem),\n"
2500 #| " /* r0 = map_lookup(r1, r2) */\n"
2501 #| " BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 2),\n"
2502 #| " /* if (r0 == 0) goto pc+2 */\n"
2503 #| " BPF_MOV64_IMM(BPF_REG_1, 1), /* r1 = 1 */\n"
2504 #| " BPF_XADD(BPF_DW, BPF_REG_0, BPF_REG_1, 0, 0),\n"
2505 #| " /* lock *(u64 *) r0 += r1 */\n"
2506 #| " BPF_MOV64_IMM(BPF_REG_0, 0), /* r0 = 0 */\n"
2507 #| " BPF_EXIT_INSN(), /* return r0 */\n"
2508 #| " };\n"
2509 #| "\\&\n"
2510 #| " prog_fd = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, prog,\n"
2511 #| " sizeof(prog) / sizeof(prog[0]), \"GPL\");\n"
2512 #| "\\&\n"
2513 #| " sock = open_raw_sock(\"lo\");\n"
2514 #| "\\&\n"
2515 #| " assert(setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, &prog_fd,\n"
2516 #| " sizeof(prog_fd)) == 0);\n"
2517 #| "\\&\n"
2518 #| " for (;;) {\n"
2519 #| " key = IPPROTO_TCP;\n"
2520 #| " assert(bpf_lookup_elem(map_fd, &key, &tcp_cnt) == 0);\n"
2521 #| " key = IPPROTO_UDP;\n"
2522 #| " assert(bpf_lookup_elem(map_fd, &key, &udp_cnt) == 0);\n"
2523 #| " printf(\"TCP %lld UDP %lld packets\\[rs]n\", tcp_cnt, udp_cnt);\n"
2524 #| " sleep(1);\n"
2525 #| " }\n"
2526 #| "\\&\n"
2527 #| " return 0;\n"
2528 #| "}\n"
2529 msgid ""
2530 "#include E<lt>stdcountof.hE<gt>\n"
2531 "\\&\n"
2532 "/* bpf+sockets example:\n"
2533 " * 1. create array map of 256 elements\n"
2534 " * 2. load program that counts number of packets received\n"
2535 " * r0 = skb-E<gt>data[ETH_HLEN + offsetof(struct iphdr, protocol)]\n"
2536 " * map[r0]++\n"
2537 " * 3. attach prog_fd to raw socket via setsockopt()\n"
2538 " * 4. print number of received TCP/UDP packets every second\n"
2539 " */\n"
2540 "int\n"
2541 "main(int argc, char *argv[])\n"
2542 "{\n"
2543 " int sock, map_fd, prog_fd, key;\n"
2544 " long long value = 0, tcp_cnt, udp_cnt;\n"
2545 "\\&\n"
2546 " map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(key),\n"
2547 " sizeof(value), 256);\n"
2548 " if (map_fd E<lt> 0) {\n"
2549 " printf(\"failed to create map \\[aq]%s\\[aq]\\[rs]n\", strerror(errno));\n"
2550 " /* likely not run as root */\n"
2551 " return 1;\n"
2552 " }\n"
2553 "\\&\n"
2554 " struct bpf_insn prog[] = {\n"
2555 " BPF_MOV64_REG(BPF_REG_6, BPF_REG_1), /* r6 = r1 */\n"
2556 " BPF_LD_ABS(BPF_B, ETH_HLEN + offsetof(struct iphdr, protocol)),\n"
2557 " /* r0 = ip-E<gt>proto */\n"
2558 " BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_0, -4),\n"
2559 " /* *(u32 *) (fp - 4) = r0 */\n"
2560 " BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), /* r2 = fp */\n"
2561 " BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -4), /* r2 = r2 - 4 */\n"
2562 " BPF_LD_MAP_FD(BPF_REG_1, map_fd), /* r1 = map_fd */\n"
2563 " BPF_CALL_FUNC(BPF_FUNC_map_lookup_elem),\n"
2564 " /* r0 = map_lookup(r1, r2) */\n"
2565 " BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 2),\n"
2566 " /* if (r0 == 0) goto pc+2 */\n"
2567 " BPF_MOV64_IMM(BPF_REG_1, 1), /* r1 = 1 */\n"
2568 " BPF_XADD(BPF_DW, BPF_REG_0, BPF_REG_1, 0, 0),\n"
2569 " /* lock *(u64 *) r0 += r1 */\n"
2570 " BPF_MOV64_IMM(BPF_REG_0, 0), /* r0 = 0 */\n"
2571 " BPF_EXIT_INSN(), /* return r0 */\n"
2572 " };\n"
2573 "\\&\n"
2574 " prog_fd = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, prog,\n"
2575 " countof(prog), \"GPL\");\n"
2576 "\\&\n"
2577 " sock = open_raw_sock(\"lo\");\n"
2578 "\\&\n"
2579 " assert(setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, &prog_fd,\n"
2580 " sizeof(prog_fd)) == 0);\n"
2581 "\\&\n"
2582 " for (;;) {\n"
2583 " key = IPPROTO_TCP;\n"
2584 " assert(bpf_lookup_elem(map_fd, &key, &tcp_cnt) == 0);\n"
2585 " key = IPPROTO_UDP;\n"
2586 " assert(bpf_lookup_elem(map_fd, &key, &udp_cnt) == 0);\n"
2587 " printf(\"TCP %lld UDP %lld packets\\[rs]n\", tcp_cnt, udp_cnt);\n"
2588 " sleep(1);\n"
2589 " }\n"
2590 "\\&\n"
2591 " return 0;\n"
2592 "}\n"
2593 msgstr ""
2594 "/* bpf+sockets example:\n"
2595 " * 1. create array map of 256 elements\n"
2596 " * 2. load program that counts number of packets received\n"
2597 " * r0 = skb-E<gt>data[ETH_HLEN + offsetof(struct iphdr, protocol)]\n"
2598 " * map[r0]++\n"
2599 " * 3. attach prog_fd to raw socket via setsockopt()\n"
2600 " * 4. print number of received TCP/UDP packets every second\n"
2601 " */\n"
2602 "int\n"
2603 "main(int argc, char *argv[])\n"
2604 "{\n"
2605 " int sock, map_fd, prog_fd, key;\n"
2606 " long long value = 0, tcp_cnt, udp_cnt;\n"
2607 "\\&\n"
2608 " map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(key),\n"
2609 " sizeof(value), 256);\n"
2610 " if (map_fd E<lt> 0) {\n"
2611 " printf(\"failed to create map \\[aq]%s\\[aq]\\[rs]n\", strerror(errno));\n"
2612 " /* likely not run as root */\n"
2613 " return 1;\n"
2614 " }\n"
2615 "\\&\n"
2616 " struct bpf_insn prog[] = {\n"
2617 " BPF_MOV64_REG(BPF_REG_6, BPF_REG_1), /* r6 = r1 */\n"
2618 " BPF_LD_ABS(BPF_B, ETH_HLEN + offsetof(struct iphdr, protocol)),\n"
2619 " /* r0 = ip-E<gt>proto */\n"
2620 " BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_0, -4),\n"
2621 " /* *(u32 *)(fp - 4) = r0 */\n"
2622 " BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), /* r2 = fp */\n"
2623 " BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -4), /* r2 = r2 - 4 */\n"
2624 " BPF_LD_MAP_FD(BPF_REG_1, map_fd), /* r1 = map_fd */\n"
2625 " BPF_CALL_FUNC(BPF_FUNC_map_lookup_elem),\n"
2626 " /* r0 = map_lookup(r1, r2) */\n"
2627 " BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 2),\n"
2628 " /* if (r0 == 0) goto pc+2 */\n"
2629 " BPF_MOV64_IMM(BPF_REG_1, 1), /* r1 = 1 */\n"
2630 " BPF_XADD(BPF_DW, BPF_REG_0, BPF_REG_1, 0, 0),\n"
2631 " /* lock *(u64 *) r0 += r1 */\n"
2632 " BPF_MOV64_IMM(BPF_REG_0, 0), /* r0 = 0 */\n"
2633 " BPF_EXIT_INSN(), /* return r0 */\n"
2634 " };\n"
2635 "\\&\n"
2636 " prog_fd = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, prog,\n"
2637 " sizeof(prog) / sizeof(prog[0]), \"GPL\");\n"
2638 "\\&\n"
2639 " sock = open_raw_sock(\"lo\");\n"
2640 "\\&\n"
2641 " assert(setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, &prog_fd,\n"
2642 " sizeof(prog_fd)) == 0);\n"
2643 "\\&\n"
2644 " for (;;) {\n"
2645 " key = IPPROTO_TCP;\n"
2646 " assert(bpf_lookup_elem(map_fd, &key, &tcp_cnt) == 0);\n"
2647 " key = IPPROTO_UDP;\n"
2648 " assert(bpf_lookup_elem(map_fd, &key, &udp_cnt) == 0);\n"
2649 " printf(\"TCP %lld UDP %lld packets\\[rs]n\", tcp_cnt, udp_cnt);\n"
2650 " sleep(1);\n"
2651 " }\n"
2652 "\\&\n"
2653 " return 0;\n"
2654 "}\n"
2655
2656 #. type: Plain text
2657 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2658 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2659 msgid ""
2660 "Some complete working code can be found in the I<samples/bpf> directory in "
2661 "the kernel source tree."
2662 msgstr ""
2663 "Другой подробный рабочий код можно найти в каталоге I<samples/bpf> в дереве "
2664 "исходных текстов ядра."
2665
2666 #. type: SH
2667 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2668 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2669 #, no-wrap
2670 msgid "SEE ALSO"
2671 msgstr "СМОТРИТЕ ТАКЖЕ"
2672
2673 #. type: Plain text
2674 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2675 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2676 msgid "B<seccomp>(2), B<bpf-helpers>(7), B<socket>(7), B<tc>(8), B<tc-bpf>(8)"
2677 msgstr "B<seccomp>(2), B<bpf-helpers>(7), B<socket>(7), B<tc>(8), B<tc-bpf>(8)"
2678
2679 #. type: Plain text
2680 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
2681 #: opensuse-tumbleweed
2682 #, fuzzy
2683 #| msgid ""
2684 #| "Both classic and extended BPF are explained in the kernel source file "
2685 #| "I<Documentation/networking/filter.txt>."
2686 msgid ""
2687 "Both classic and extended BPF are explained in the kernel source file "
2688 "I<Documentation/networking/filter.rst>."
2689 msgstr ""
2690 "Как классический, так и расширенный BPF описаны в исходном файле ядра "
2691 "I<Documentation/networking/filter.txt>."
2692
2693 #. type: TH
2694 #: debian-trixie
2695 #, no-wrap
2696 msgid "2024-06-15"
2697 msgstr "15 июня 2024 г."
2698
2699 #. type: TH
2700 #: debian-trixie
2701 #, no-wrap
2702 msgid "Linux man-pages 6.9.1"
2703 msgstr "Страницы руководства Linux 6.9.1"
2704
2705 #. type: Plain text
2706 #: debian-trixie fedora-44 fedora-rawhide
2707 #, no-wrap
2708 msgid ""
2709 "enum bpf_map_type {\n"
2710 " BPF_MAP_TYPE_UNSPEC, /* Reserve 0 as invalid map type */\n"
2711 " BPF_MAP_TYPE_HASH,\n"
2712 " BPF_MAP_TYPE_ARRAY,\n"
2713 " BPF_MAP_TYPE_PROG_ARRAY,\n"
2714 " BPF_MAP_TYPE_PERF_EVENT_ARRAY,\n"
2715 " BPF_MAP_TYPE_PERCPU_HASH,\n"
2716 " BPF_MAP_TYPE_PERCPU_ARRAY,\n"
2717 " BPF_MAP_TYPE_STACK_TRACE,\n"
2718 " BPF_MAP_TYPE_CGROUP_ARRAY,\n"
2719 " BPF_MAP_TYPE_LRU_HASH,\n"
2720 " BPF_MAP_TYPE_LRU_PERCPU_HASH,\n"
2721 " BPF_MAP_TYPE_LPM_TRIE,\n"
2722 " BPF_MAP_TYPE_ARRAY_OF_MAPS,\n"
2723 " BPF_MAP_TYPE_HASH_OF_MAPS,\n"
2724 " BPF_MAP_TYPE_DEVMAP,\n"
2725 " BPF_MAP_TYPE_SOCKMAP,\n"
2726 " BPF_MAP_TYPE_CPUMAP,\n"
2727 " BPF_MAP_TYPE_XSKMAP,\n"
2728 " BPF_MAP_TYPE_SOCKHASH,\n"
2729 " BPF_MAP_TYPE_CGROUP_STORAGE,\n"
2730 " BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,\n"
2731 " BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,\n"
2732 " BPF_MAP_TYPE_QUEUE,\n"
2733 " BPF_MAP_TYPE_STACK,\n"
2734 " /* See /usr/include/linux/bpf.h for the full list. */\n"
2735 "};\n"
2736 msgstr ""
2737 "enum bpf_map_type {\n"
2738 " BPF_MAP_TYPE_UNSPEC, /* Reserve 0 as invalid map type */\n"
2739 " BPF_MAP_TYPE_HASH,\n"
2740 " BPF_MAP_TYPE_ARRAY,\n"
2741 " BPF_MAP_TYPE_PROG_ARRAY,\n"
2742 " BPF_MAP_TYPE_PERF_EVENT_ARRAY,\n"
2743 " BPF_MAP_TYPE_PERCPU_HASH,\n"
2744 " BPF_MAP_TYPE_PERCPU_ARRAY,\n"
2745 " BPF_MAP_TYPE_STACK_TRACE,\n"
2746 " BPF_MAP_TYPE_CGROUP_ARRAY,\n"
2747 " BPF_MAP_TYPE_LRU_HASH,\n"
2748 " BPF_MAP_TYPE_LRU_PERCPU_HASH,\n"
2749 " BPF_MAP_TYPE_LPM_TRIE,\n"
2750 " BPF_MAP_TYPE_ARRAY_OF_MAPS,\n"
2751 " BPF_MAP_TYPE_HASH_OF_MAPS,\n"
2752 " BPF_MAP_TYPE_DEVMAP,\n"
2753 " BPF_MAP_TYPE_SOCKMAP,\n"
2754 " BPF_MAP_TYPE_CPUMAP,\n"
2755 " BPF_MAP_TYPE_XSKMAP,\n"
2756 " BPF_MAP_TYPE_SOCKHASH,\n"
2757 " BPF_MAP_TYPE_CGROUP_STORAGE,\n"
2758 " BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,\n"
2759 " BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,\n"
2760 " BPF_MAP_TYPE_QUEUE,\n"
2761 " BPF_MAP_TYPE_STACK,\n"
2762 " /* See /usr/include/linux/bpf.h for the full list. */\n"
2763 "};\n"
2764
2765 #. type: Plain text
2766 #: debian-trixie fedora-44 fedora-rawhide
2767 #, no-wrap
2768 msgid ""
2769 "enum bpf_prog_type {\n"
2770 " BPF_PROG_TYPE_UNSPEC, /* Reserve 0 as invalid\n"
2771 " program type */\n"
2772 " BPF_PROG_TYPE_SOCKET_FILTER,\n"
2773 " BPF_PROG_TYPE_KPROBE,\n"
2774 " BPF_PROG_TYPE_SCHED_CLS,\n"
2775 " BPF_PROG_TYPE_SCHED_ACT,\n"
2776 " BPF_PROG_TYPE_TRACEPOINT,\n"
2777 " BPF_PROG_TYPE_XDP,\n"
2778 " BPF_PROG_TYPE_PERF_EVENT,\n"
2779 " BPF_PROG_TYPE_CGROUP_SKB,\n"
2780 " BPF_PROG_TYPE_CGROUP_SOCK,\n"
2781 " BPF_PROG_TYPE_LWT_IN,\n"
2782 " BPF_PROG_TYPE_LWT_OUT,\n"
2783 " BPF_PROG_TYPE_LWT_XMIT,\n"
2784 " BPF_PROG_TYPE_SOCK_OPS,\n"
2785 " BPF_PROG_TYPE_SK_SKB,\n"
2786 " BPF_PROG_TYPE_CGROUP_DEVICE,\n"
2787 " BPF_PROG_TYPE_SK_MSG,\n"
2788 " BPF_PROG_TYPE_RAW_TRACEPOINT,\n"
2789 " BPF_PROG_TYPE_CGROUP_SOCK_ADDR,\n"
2790 " BPF_PROG_TYPE_LWT_SEG6LOCAL,\n"
2791 " BPF_PROG_TYPE_LIRC_MODE2,\n"
2792 " BPF_PROG_TYPE_SK_REUSEPORT,\n"
2793 " BPF_PROG_TYPE_FLOW_DISSECTOR,\n"
2794 " /* See /usr/include/linux/bpf.h for the full list. */\n"
2795 "};\n"
2796 msgstr ""
2797 "enum bpf_prog_type {\n"
2798 " BPF_PROG_TYPE_UNSPEC, /* Reserve 0 as invalid\n"
2799 " program type */\n"
2800 " BPF_PROG_TYPE_SOCKET_FILTER,\n"
2801 " BPF_PROG_TYPE_KPROBE,\n"
2802 " BPF_PROG_TYPE_SCHED_CLS,\n"
2803 " BPF_PROG_TYPE_SCHED_ACT,\n"
2804 " BPF_PROG_TYPE_TRACEPOINT,\n"
2805 " BPF_PROG_TYPE_XDP,\n"
2806 " BPF_PROG_TYPE_PERF_EVENT,\n"
2807 " BPF_PROG_TYPE_CGROUP_SKB,\n"
2808 " BPF_PROG_TYPE_CGROUP_SOCK,\n"
2809 " BPF_PROG_TYPE_LWT_IN,\n"
2810 " BPF_PROG_TYPE_LWT_OUT,\n"
2811 " BPF_PROG_TYPE_LWT_XMIT,\n"
2812 " BPF_PROG_TYPE_SOCK_OPS,\n"
2813 " BPF_PROG_TYPE_SK_SKB,\n"
2814 " BPF_PROG_TYPE_CGROUP_DEVICE,\n"
2815 " BPF_PROG_TYPE_SK_MSG,\n"
2816 " BPF_PROG_TYPE_RAW_TRACEPOINT,\n"
2817 " BPF_PROG_TYPE_CGROUP_SOCK_ADDR,\n"
2818 " BPF_PROG_TYPE_LWT_SEG6LOCAL,\n"
2819 " BPF_PROG_TYPE_LIRC_MODE2,\n"
2820 " BPF_PROG_TYPE_SK_REUSEPORT,\n"
2821 " BPF_PROG_TYPE_FLOW_DISSECTOR,\n"
2822 " /* Смотрите полный список в /usr/include/linux/bpf.h. */\n"
2823 "};\n"
2824
2825 #. == atomic64_add
2826 #. type: Plain text
2827 #: debian-trixie
2828 #, no-wrap
2829 msgid ""
2830 "/* bpf+sockets example:\n"
2831 " * 1. create array map of 256 elements\n"
2832 " * 2. load program that counts number of packets received\n"
2833 " * r0 = skb-E<gt>data[ETH_HLEN + offsetof(struct iphdr, protocol)]\n"
2834 " * map[r0]++\n"
2835 " * 3. attach prog_fd to raw socket via setsockopt()\n"
2836 " * 4. print number of received TCP/UDP packets every second\n"
2837 " */\n"
2838 "int\n"
2839 "main(int argc, char *argv[])\n"
2840 "{\n"
2841 " int sock, map_fd, prog_fd, key;\n"
2842 " long long value = 0, tcp_cnt, udp_cnt;\n"
2843 "\\&\n"
2844 " map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(key),\n"
2845 " sizeof(value), 256);\n"
2846 " if (map_fd E<lt> 0) {\n"
2847 " printf(\"failed to create map \\[aq]%s\\[aq]\\[rs]n\", strerror(errno));\n"
2848 " /* likely not run as root */\n"
2849 " return 1;\n"
2850 " }\n"
2851 "\\&\n"
2852 " struct bpf_insn prog[] = {\n"
2853 " BPF_MOV64_REG(BPF_REG_6, BPF_REG_1), /* r6 = r1 */\n"
2854 " BPF_LD_ABS(BPF_B, ETH_HLEN + offsetof(struct iphdr, protocol)),\n"
2855 " /* r0 = ip-E<gt>proto */\n"
2856 " BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_0, -4),\n"
2857 " /* *(u32 *)(fp - 4) = r0 */\n"
2858 " BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), /* r2 = fp */\n"
2859 " BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -4), /* r2 = r2 - 4 */\n"
2860 " BPF_LD_MAP_FD(BPF_REG_1, map_fd), /* r1 = map_fd */\n"
2861 " BPF_CALL_FUNC(BPF_FUNC_map_lookup_elem),\n"
2862 " /* r0 = map_lookup(r1, r2) */\n"
2863 " BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 2),\n"
2864 " /* if (r0 == 0) goto pc+2 */\n"
2865 " BPF_MOV64_IMM(BPF_REG_1, 1), /* r1 = 1 */\n"
2866 " BPF_XADD(BPF_DW, BPF_REG_0, BPF_REG_1, 0, 0),\n"
2867 " /* lock *(u64 *) r0 += r1 */\n"
2868 " BPF_MOV64_IMM(BPF_REG_0, 0), /* r0 = 0 */\n"
2869 " BPF_EXIT_INSN(), /* return r0 */\n"
2870 " };\n"
2871 "\\&\n"
2872 " prog_fd = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, prog,\n"
2873 " sizeof(prog) / sizeof(prog[0]), \"GPL\");\n"
2874 "\\&\n"
2875 " sock = open_raw_sock(\"lo\");\n"
2876 "\\&\n"
2877 " assert(setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, &prog_fd,\n"
2878 " sizeof(prog_fd)) == 0);\n"
2879 "\\&\n"
2880 " for (;;) {\n"
2881 " key = IPPROTO_TCP;\n"
2882 " assert(bpf_lookup_elem(map_fd, &key, &tcp_cnt) == 0);\n"
2883 " key = IPPROTO_UDP;\n"
2884 " assert(bpf_lookup_elem(map_fd, &key, &udp_cnt) == 0);\n"
2885 " printf(\"TCP %lld UDP %lld packets\\[rs]n\", tcp_cnt, udp_cnt);\n"
2886 " sleep(1);\n"
2887 " }\n"
2888 "\\&\n"
2889 " return 0;\n"
2890 "}\n"
2891 msgstr ""
2892 "/* bpf+sockets example:\n"
2893 " * 1. create array map of 256 elements\n"
2894 " * 2. load program that counts number of packets received\n"
2895 " * r0 = skb-E<gt>data[ETH_HLEN + offsetof(struct iphdr, protocol)]\n"
2896 " * map[r0]++\n"
2897 " * 3. attach prog_fd to raw socket via setsockopt()\n"
2898 " * 4. print number of received TCP/UDP packets every second\n"
2899 " */\n"
2900 "int\n"
2901 "main(int argc, char *argv[])\n"
2902 "{\n"
2903 " int sock, map_fd, prog_fd, key;\n"
2904 " long long value = 0, tcp_cnt, udp_cnt;\n"
2905 "\\&\n"
2906 " map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(key),\n"
2907 " sizeof(value), 256);\n"
2908 " if (map_fd E<lt> 0) {\n"
2909 " printf(\"failed to create map \\[aq]%s\\[aq]\\[rs]n\", strerror(errno));\n"
2910 " /* likely not run as root */\n"
2911 " return 1;\n"
2912 " }\n"
2913 "\\&\n"
2914 " struct bpf_insn prog[] = {\n"
2915 " BPF_MOV64_REG(BPF_REG_6, BPF_REG_1), /* r6 = r1 */\n"
2916 " BPF_LD_ABS(BPF_B, ETH_HLEN + offsetof(struct iphdr, protocol)),\n"
2917 " /* r0 = ip-E<gt>proto */\n"
2918 " BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_0, -4),\n"
2919 " /* *(u32 *)(fp - 4) = r0 */\n"
2920 " BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), /* r2 = fp */\n"
2921 " BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -4), /* r2 = r2 - 4 */\n"
2922 " BPF_LD_MAP_FD(BPF_REG_1, map_fd), /* r1 = map_fd */\n"
2923 " BPF_CALL_FUNC(BPF_FUNC_map_lookup_elem),\n"
2924 " /* r0 = map_lookup(r1, r2) */\n"
2925 " BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 2),\n"
2926 " /* if (r0 == 0) goto pc+2 */\n"
2927 " BPF_MOV64_IMM(BPF_REG_1, 1), /* r1 = 1 */\n"
2928 " BPF_XADD(BPF_DW, BPF_REG_0, BPF_REG_1, 0, 0),\n"
2929 " /* lock *(u64 *) r0 += r1 */\n"
2930 " BPF_MOV64_IMM(BPF_REG_0, 0), /* r0 = 0 */\n"
2931 " BPF_EXIT_INSN(), /* return r0 */\n"
2932 " };\n"
2933 "\\&\n"
2934 " prog_fd = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, prog,\n"
2935 " sizeof(prog) / sizeof(prog[0]), \"GPL\");\n"
2936 "\\&\n"
2937 " sock = open_raw_sock(\"lo\");\n"
2938 "\\&\n"
2939 " assert(setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, &prog_fd,\n"
2940 " sizeof(prog_fd)) == 0);\n"
2941 "\\&\n"
2942 " for (;;) {\n"
2943 " key = IPPROTO_TCP;\n"
2944 " assert(bpf_lookup_elem(map_fd, &key, &tcp_cnt) == 0);\n"
2945 " key = IPPROTO_UDP;\n"
2946 " assert(bpf_lookup_elem(map_fd, &key, &udp_cnt) == 0);\n"
2947 " printf(\"TCP %lld UDP %lld packets\\[rs]n\", tcp_cnt, udp_cnt);\n"
2948 " sleep(1);\n"
2949 " }\n"
2950 "\\&\n"
2951 " return 0;\n"
2952 "}\n"
2953
2954 #. type: Plain text
2955 #: debian-trixie fedora-44 fedora-rawhide
2956 msgid ""
2957 "Both classic and extended BPF are explained in the kernel source file "
2958 "I<Documentation/networking/filter.txt>."
2959 msgstr ""
2960 "Как классический, так и расширенный BPF описаны в исходном файле ядра "
2961 "I<Documentation/networking/filter.txt>."
2962
2963 #. type: TH
2964 #: fedora-44 fedora-rawhide
2965 #, no-wrap
2966 msgid "2025-01-05"
2967 msgstr "5 января 2025 г."
2968
2969 #. type: TH
2970 #: fedora-44 fedora-rawhide
2971 #, no-wrap
2972 msgid "Linux man-pages 6.13"
2973 msgstr "Страницы руководства Linux 6.13"
2974
2975 #. == atomic64_add
2976 #. type: Plain text
2977 #: fedora-44 fedora-rawhide
2978 #, fuzzy, no-wrap
2979 #| msgid ""
2980 #| "/* bpf+sockets example:\n"
2981 #| " * 1. create array map of 256 elements\n"
2982 #| " * 2. load program that counts number of packets received\n"
2983 #| " * r0 = skb-E<gt>data[ETH_HLEN + offsetof(struct iphdr, protocol)]\n"
2984 #| " * map[r0]++\n"
2985 #| " * 3. attach prog_fd to raw socket via setsockopt()\n"
2986 #| " * 4. print number of received TCP/UDP packets every second\n"
2987 #| " */\n"
2988 #| "int\n"
2989 #| "main(int argc, char *argv[])\n"
2990 #| "{\n"
2991 #| " int sock, map_fd, prog_fd, key;\n"
2992 #| " long long value = 0, tcp_cnt, udp_cnt;\n"
2993 #| "\\&\n"
2994 #| " map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(key),\n"
2995 #| " sizeof(value), 256);\n"
2996 #| " if (map_fd E<lt> 0) {\n"
2997 #| " printf(\"failed to create map \\[aq]%s\\[aq]\\[rs]n\", strerror(errno));\n"
2998 #| " /* likely not run as root */\n"
2999 #| " return 1;\n"
3000 #| " }\n"
3001 #| "\\&\n"
3002 #| " struct bpf_insn prog[] = {\n"
3003 #| " BPF_MOV64_REG(BPF_REG_6, BPF_REG_1), /* r6 = r1 */\n"
3004 #| " BPF_LD_ABS(BPF_B, ETH_HLEN + offsetof(struct iphdr, protocol)),\n"
3005 #| " /* r0 = ip-E<gt>proto */\n"
3006 #| " BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_0, -4),\n"
3007 #| " /* *(u32 *)(fp - 4) = r0 */\n"
3008 #| " BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), /* r2 = fp */\n"
3009 #| " BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -4), /* r2 = r2 - 4 */\n"
3010 #| " BPF_LD_MAP_FD(BPF_REG_1, map_fd), /* r1 = map_fd */\n"
3011 #| " BPF_CALL_FUNC(BPF_FUNC_map_lookup_elem),\n"
3012 #| " /* r0 = map_lookup(r1, r2) */\n"
3013 #| " BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 2),\n"
3014 #| " /* if (r0 == 0) goto pc+2 */\n"
3015 #| " BPF_MOV64_IMM(BPF_REG_1, 1), /* r1 = 1 */\n"
3016 #| " BPF_XADD(BPF_DW, BPF_REG_0, BPF_REG_1, 0, 0),\n"
3017 #| " /* lock *(u64 *) r0 += r1 */\n"
3018 #| " BPF_MOV64_IMM(BPF_REG_0, 0), /* r0 = 0 */\n"
3019 #| " BPF_EXIT_INSN(), /* return r0 */\n"
3020 #| " };\n"
3021 #| "\\&\n"
3022 #| " prog_fd = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, prog,\n"
3023 #| " sizeof(prog) / sizeof(prog[0]), \"GPL\");\n"
3024 #| "\\&\n"
3025 #| " sock = open_raw_sock(\"lo\");\n"
3026 #| "\\&\n"
3027 #| " assert(setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, &prog_fd,\n"
3028 #| " sizeof(prog_fd)) == 0);\n"
3029 #| "\\&\n"
3030 #| " for (;;) {\n"
3031 #| " key = IPPROTO_TCP;\n"
3032 #| " assert(bpf_lookup_elem(map_fd, &key, &tcp_cnt) == 0);\n"
3033 #| " key = IPPROTO_UDP;\n"
3034 #| " assert(bpf_lookup_elem(map_fd, &key, &udp_cnt) == 0);\n"
3035 #| " printf(\"TCP %lld UDP %lld packets\\[rs]n\", tcp_cnt, udp_cnt);\n"
3036 #| " sleep(1);\n"
3037 #| " }\n"
3038 #| "\\&\n"
3039 #| " return 0;\n"
3040 #| "}\n"
3041 msgid ""
3042 "/* bpf+sockets example:\n"
3043 " * 1. create array map of 256 elements\n"
3044 " * 2. load program that counts number of packets received\n"
3045 " * r0 = skb-E<gt>data[ETH_HLEN + offsetof(struct iphdr, protocol)]\n"
3046 " * map[r0]++\n"
3047 " * 3. attach prog_fd to raw socket via setsockopt()\n"
3048 " * 4. print number of received TCP/UDP packets every second\n"
3049 " */\n"
3050 "int\n"
3051 "main(int argc, char *argv[])\n"
3052 "{\n"
3053 " int sock, map_fd, prog_fd, key;\n"
3054 " long long value = 0, tcp_cnt, udp_cnt;\n"
3055 "\\&\n"
3056 " map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(key),\n"
3057 " sizeof(value), 256);\n"
3058 " if (map_fd E<lt> 0) {\n"
3059 " printf(\"failed to create map \\[aq]%s\\[aq]\\[rs]n\", strerror(errno));\n"
3060 " /* likely not run as root */\n"
3061 " return 1;\n"
3062 " }\n"
3063 "\\&\n"
3064 " struct bpf_insn prog[] = {\n"
3065 " BPF_MOV64_REG(BPF_REG_6, BPF_REG_1), /* r6 = r1 */\n"
3066 " BPF_LD_ABS(BPF_B, ETH_HLEN + offsetof(struct iphdr, protocol)),\n"
3067 " /* r0 = ip-E<gt>proto */\n"
3068 " BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_0, -4),\n"
3069 " /* *(u32 *) (fp - 4) = r0 */\n"
3070 " BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), /* r2 = fp */\n"
3071 " BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -4), /* r2 = r2 - 4 */\n"
3072 " BPF_LD_MAP_FD(BPF_REG_1, map_fd), /* r1 = map_fd */\n"
3073 " BPF_CALL_FUNC(BPF_FUNC_map_lookup_elem),\n"
3074 " /* r0 = map_lookup(r1, r2) */\n"
3075 " BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 2),\n"
3076 " /* if (r0 == 0) goto pc+2 */\n"
3077 " BPF_MOV64_IMM(BPF_REG_1, 1), /* r1 = 1 */\n"
3078 " BPF_XADD(BPF_DW, BPF_REG_0, BPF_REG_1, 0, 0),\n"
3079 " /* lock *(u64 *) r0 += r1 */\n"
3080 " BPF_MOV64_IMM(BPF_REG_0, 0), /* r0 = 0 */\n"
3081 " BPF_EXIT_INSN(), /* return r0 */\n"
3082 " };\n"
3083 "\\&\n"
3084 " prog_fd = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, prog,\n"
3085 " sizeof(prog) / sizeof(prog[0]), \"GPL\");\n"
3086 "\\&\n"
3087 " sock = open_raw_sock(\"lo\");\n"
3088 "\\&\n"
3089 " assert(setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, &prog_fd,\n"
3090 " sizeof(prog_fd)) == 0);\n"
3091 "\\&\n"
3092 " for (;;) {\n"
3093 " key = IPPROTO_TCP;\n"
3094 " assert(bpf_lookup_elem(map_fd, &key, &tcp_cnt) == 0);\n"
3095 " key = IPPROTO_UDP;\n"
3096 " assert(bpf_lookup_elem(map_fd, &key, &udp_cnt) == 0);\n"
3097 " printf(\"TCP %lld UDP %lld packets\\[rs]n\", tcp_cnt, udp_cnt);\n"
3098 " sleep(1);\n"
3099 " }\n"
3100 "\\&\n"
3101 " return 0;\n"
3102 "}\n"
3103 msgstr ""
3104 "/* bpf+sockets example:\n"
3105 " * 1. create array map of 256 elements\n"
3106 " * 2. load program that counts number of packets received\n"
3107 " * r0 = skb-E<gt>data[ETH_HLEN + offsetof(struct iphdr, protocol)]\n"
3108 " * map[r0]++\n"
3109 " * 3. attach prog_fd to raw socket via setsockopt()\n"
3110 " * 4. print number of received TCP/UDP packets every second\n"
3111 " */\n"
3112 "int\n"
3113 "main(int argc, char *argv[])\n"
3114 "{\n"
3115 " int sock, map_fd, prog_fd, key;\n"
3116 " long long value = 0, tcp_cnt, udp_cnt;\n"
3117 "\\&\n"
3118 " map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(key),\n"
3119 " sizeof(value), 256);\n"
3120 " if (map_fd E<lt> 0) {\n"
3121 " printf(\"failed to create map \\[aq]%s\\[aq]\\[rs]n\", strerror(errno));\n"
3122 " /* likely not run as root */\n"
3123 " return 1;\n"
3124 " }\n"
3125 "\\&\n"
3126 " struct bpf_insn prog[] = {\n"
3127 " BPF_MOV64_REG(BPF_REG_6, BPF_REG_1), /* r6 = r1 */\n"
3128 " BPF_LD_ABS(BPF_B, ETH_HLEN + offsetof(struct iphdr, protocol)),\n"
3129 " /* r0 = ip-E<gt>proto */\n"
3130 " BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_0, -4),\n"
3131 " /* *(u32 *)(fp - 4) = r0 */\n"
3132 " BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), /* r2 = fp */\n"
3133 " BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -4), /* r2 = r2 - 4 */\n"
3134 " BPF_LD_MAP_FD(BPF_REG_1, map_fd), /* r1 = map_fd */\n"
3135 " BPF_CALL_FUNC(BPF_FUNC_map_lookup_elem),\n"
3136 " /* r0 = map_lookup(r1, r2) */\n"
3137 " BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 2),\n"
3138 " /* if (r0 == 0) goto pc+2 */\n"
3139 " BPF_MOV64_IMM(BPF_REG_1, 1), /* r1 = 1 */\n"
3140 " BPF_XADD(BPF_DW, BPF_REG_0, BPF_REG_1, 0, 0),\n"
3141 " /* lock *(u64 *) r0 += r1 */\n"
3142 " BPF_MOV64_IMM(BPF_REG_0, 0), /* r0 = 0 */\n"
3143 " BPF_EXIT_INSN(), /* return r0 */\n"
3144 " };\n"
3145 "\\&\n"
3146 " prog_fd = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, prog,\n"
3147 " sizeof(prog) / sizeof(prog[0]), \"GPL\");\n"
3148 "\\&\n"
3149 " sock = open_raw_sock(\"lo\");\n"
3150 "\\&\n"
3151 " assert(setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, &prog_fd,\n"
3152 " sizeof(prog_fd)) == 0);\n"
3153 "\\&\n"
3154 " for (;;) {\n"
3155 " key = IPPROTO_TCP;\n"
3156 " assert(bpf_lookup_elem(map_fd, &key, &tcp_cnt) == 0);\n"
3157 " key = IPPROTO_UDP;\n"
3158 " assert(bpf_lookup_elem(map_fd, &key, &udp_cnt) == 0);\n"
3159 " printf(\"TCP %lld UDP %lld packets\\[rs]n\", tcp_cnt, udp_cnt);\n"
3160 " sleep(1);\n"
3161 " }\n"
3162 "\\&\n"
3163 " return 0;\n"
3164 "}\n"
3165
3166 #. type: TH
3167 #: mageia-cauldron
3168 #, no-wrap
3169 msgid "Linux man-pages 6.17"
3170 msgstr "Страницы руководства Linux 6.17"
3171
3172 #. type: TH
3173 #: opensuse-leap-16-1 opensuse-tumbleweed
3174 #, no-wrap
3175 msgid "Linux man-pages (unreleased)"
3176 msgstr "Страницы руководства Linux (не выпущены)"