KFunc bpf_stream_vprintk
v6.17 - v6.18](https://github.com/torvalds/linux/commit/137cc92ffe2e71705fce112656a460d924934ebe)
Write a message to a
Note
In v6.17 this kfunc was introduced under bpf_stream_vprintk and renamed to bpf_stream_vprintk_impl in v6.18.
In v7.0 it was renamed back to bpf_stream_vprintk but with KF_IMPLICIT_ARGS which makes the aux__prog argument implicitly added.
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.
Signature
int bpf_stream_vprintk(int stream_id, const char *fmt__str, const void *args, u32 len__sz)
Usage
This kfunc allows programs to write formatted strings to streams, the API is made to resemble
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:
BPF_PROG_TYPE_CGROUP_DEVICEv6.12 -BPF_PROG_TYPE_CGROUP_SKBBPF_PROG_TYPE_CGROUP_SOCKv6.12 -BPF_PROG_TYPE_CGROUP_SOCKOPTv6.12 -BPF_PROG_TYPE_CGROUP_SOCK_ADDRv6.7 -BPF_PROG_TYPE_CGROUP_SYSCTLv6.12 -BPF_PROG_TYPE_LSMBPF_PROG_TYPE_LWT_INBPF_PROG_TYPE_LWT_OUTBPF_PROG_TYPE_LWT_SEG6LOCALBPF_PROG_TYPE_LWT_XMITBPF_PROG_TYPE_NETFILTERBPF_PROG_TYPE_PERF_EVENTv6.12 -BPF_PROG_TYPE_SCHED_ACTBPF_PROG_TYPE_SCHED_CLSBPF_PROG_TYPE_SK_SKBBPF_PROG_TYPE_SOCKET_FILTERBPF_PROG_TYPE_SOCK_OPSv6.15 -BPF_PROG_TYPE_STRUCT_OPSBPF_PROG_TYPE_SYSCALLBPF_PROG_TYPE_TRACEPOINTv6.12 -BPF_PROG_TYPE_TRACINGBPF_PROG_TYPE_XDP
Example
Docs could be improved
This part of the docs is incomplete, contributions are very welcome