Skip to content

KFunc bpf_stream_vprintk

v6.17

Write a message to a stdout/stderr like, per-program stream.

Definition

Parameters

stream_id: The ID of the stream to write to (BPF_STDOUT(1), or BPF_STDERR(2))

fmt__str: Format string following the same formatting as bpf_trace_printk

args: Pointer to an array of u64 argument values.

len_sz: Number of elements in args.

aux__prog: Pseudo argument, any value passed in is ignored.

Returns

Signature

int bpf_stream_vprintk(int stream_id, const char *fmt__str, const void *args, u32 len__sz, void *aux__prog)

Usage

This kfunc allows programs to write formatted strings to streams, the API is made to resemble stdout/stderr streams normal userspace programs have access to.

These streams are intended for debugging, an alternative to bpf_trace_printk and bpf_trace_vprintk which write to a system wide trace log. These streams are per-program, thus making it easier to consume logs from a specific program instead of having to figure out which log message in the system wide log is produces my the program you are interested in.

bpftool can be used to inspect these streams with the following command: bpftool prog tracelog { stdout | stderr } *PROG*

The libbpf eBPF side library defines a helper macro bpf_stream_printk which makes using this kfunc easier.

Program types

The following program types can make use of this kfunc:

Example

Docs could be improved

This part of the docs is incomplete, contributions are very welcome