Lines Matching +full:len +full:- +full:or +full:- +full:define
6 ----------
8 ----------
16 tools like `ss <https://man7.org/linux/man-pages/man8/ss.8.html>`_ where any
30 ----------------------
32 ----------------------
36 allow users to define callbacks that are invoked at particular points of
37 execution in the kernel, BPF iterators allow users to define callbacks that
40 For example, users can define a BPF iterator that iterates over every task on
60 ------------------------
62 ------------------------
67 <https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/tree/tools/testing/selftests/bpf/…
88 * `bpf_iter_tcp4.c <https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/tree/tools/tes…
89 * `bpf_iter_task_vma.c <https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/tree/tools…
90 * `bpf_iter_task_file.c <https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/tree/tool…
95 <https://facebookmicrosites.github.io/bpf/blog/2020/02/19/bpf-portability-and-co-re.html#btf>`_.
120 …cebookmicrosites.github.io/bpf/blog/2018/08/31/object-lifetime.html#file-descriptors-and-reference…
130 struct seq_file *seq = ctx->meta->seq;
131 struct task_struct *task = ctx->task;
132 struct file *file = ctx->file;
133 __u32 fd = ctx->fd;
138 if (ctx->meta->seq_num == 0) {
143 if (tgid == task->tgid && task->tgid != task->pid)
146 if (last_tgid != task->tgid) {
147 last_tgid = task->tgid;
151 BPF_SEQ_PRINTF(seq, "%8d %8d %8d %lx\n", task->tgid, task->pid, fd,
152 (long)file->f_op);
163 You can use either ``bpf_seq_printf()`` (and BPF_SEQ_PRINTF helper macro) or
164 ``bpf_seq_write()`` function based on whether you need formatted output or just
165 binary data, respectively. For binary-encoded data, the user space applications
169 use ``rm -f <path>`` to remove the pinned iterator.
186 -------------------------------------------------------
188 -------------------------------------------------------
190 To implement a BPF iterator in the kernel, the developer must make a one-time
192 <https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/tree/include/linux/bpf.h>`_
215 .. list-table::
217 :header-rows: 1
219 * - Fields
220 - Description
221 * - target
222 - Specifies the name of the BPF iterator. For example: ``bpf_map``,
224 * - attach_target and detach_target
225 - Allows for target specific ``link_create`` action since some targets
227 * - show_fdinfo and fill_link_info
228 - Called to fill target specific information when user tries to get link
230 * - get_func_proto
231 - Permits a BPF iterator to access BPF helpers specific to the iterator.
232 * - ctx_arg_info_size and ctx_arg_info
233 - Specifies the verifier states for BPF program arguments associated with
235 * - feature
236 - Specifies certain action requests in the kernel BPF iterator
240 * - seq_info
241 - Specifies the set of seq operations for the BPF iterator and helpers to
245 <https://lore.kernel.org/bpf/20210212183107.50963-2-songliubraving@fb.com/>`_
248 ---------------------------------
250 ---------------------------------
260 --------------------------
262 --------------------------
279 struct seq_file *seq = ctx->meta->seq;
280 struct task_struct *task = ctx->task;
281 struct file *file = ctx->file;
282 __u32 fd = ctx->fd;
285 if (ctx->meta->seq_num == 0) {
288 BPF_SEQ_PRINTF(seq, "%8d %8d %8d %lx\n", task->tgid, task->pid, fd,
289 (long)file->f_op);
293 ----------------------------------------
295 ----------------------------------------
311 ``linfo.task.pid``, if it is non-zero, directs the kernel to create an iterator
348 int iter_fd = -1, len;
354 return -1;
359 ret = -1;
363 while ((len = read(iter_fd, buf, sizeof(buf) - 1)) > 0) {
364 buf[len] = 0;
388 do_read_opts(skel->progs.dump_task_file, &opts);
414 ------------------
416 ------------------
419 processes in the system. In this case, the BPF program has to check the pid or
420 the tid of tasks, or it will receive every opened file in the system (in the
435 if (task->tgid != target_pid) /* Check task->pid instead to check thread IDs */
437 BPF_SEQ_PRINTF(seq, "%8d %8d %8d %lx\n", task->tgid, task->pid, fd,
438 (long)file->f_op);
453 skel->bss->target_pid = getpid(); /* process ID. For thread id, use gettid() */
466 ---------------------------
468 ---------------------------
471 you can still specify a process or a thread to include only its VMAs. Unlike
472 files, a thread can not have a separate address space (since Linux 2.6.0-test6).
475 ----------------------------
477 ----------------------------