KFunc bpf_stream_vprintk_impl
Write a message to a
Note
In v6.17 this kfunc was introduced as bpf_stream_vprintk and was renamed to bpf_stream_vprintk_impl in v6.18
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_impl(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
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