KFunc bpf_throw
Throw a BPF exception from the program
Definition
Throw a BPF exception from the program, immediately terminating its execution and unwinding the stack. The supplied cookie
parameter will be the return value of the program when an exception is thrown, and the default exception callback is used. Otherwise, if an exception callback is set using the __exception_cb(callback)
declaration tag on the main program, the cookie
parameter will be the callback's only input argument.
Thus, in case of default exception callback, cookie
is subjected to constraints on the program's return value (as with R0 on exit). Otherwise, the return value of the marked exception callback will be subjected to the same checks.
Note
throwing an exception with lingering resources (locks, references, etc.) will lead to a verification error.
Note
callbacks cannot call this helper.
Return
Never.
Throws
An exception with the specified cookie
value.
void bpf_throw(u64 cookie)
Usage
Docs could be improved
This part of the docs is incomplete, contributions are very welcome
Program types
The following program types can make use of this kfunc:
BPF_PROG_TYPE_LSM
BPF_PROG_TYPE_SCHED_CLS
BPF_PROG_TYPE_STRUCT_OPS
BPF_PROG_TYPE_TRACING
BPF_PROG_TYPE_XDP
Example
Docs could be improved
This part of the docs is incomplete, contributions are very welcome