Skip to content

KFunc bpf_cast_to_kern_ctx



void *bpf_cast_to_kern_ctx(void *obj)


The purpose of this kfunc is to cast the uAPI context programs get by default, into a kernel pointer that is allowed to access the kernel type.

So for example an BPF_PROG_TYPE_SCHED_CLS program would get a struct __sk_buff* as the context, passing it to this kfunc would return a struct sk_buff* which is less stable but has more fields. CO-RE should be used to access the fields of the struct sk_buff* to ensure the program is compatible with different kernel versions.

Program types

The following program types can make use of this kfunc:


Docs could be improved

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