I was looking at the different types of BPF program, and noticed that for different program types the context is being passed differently.
Example:
For program type
BPF_PROG_TYPE_SOCK_OPS, an object of typestruct bpf_sock_ops_kernis passed. However, the BPF program of this type takes a reference tostruct bpf_sock_ops. Why is it done this way and where is the "translation" frombpf_sock_ops_kerntobpf_sock_ops?For program type
BPF_PROG_TYPE_CGROUP_SKB, an object of typestruct sk_buffis passed (e.g., in__cgroup_bpf_run_filter_skb), but the BPF program expects a minimized version,struct __sk_buff.
So I looked at the struct bpf_verifier_ops function callbacks, but they seem to only adjust the offsets in BPF instructions, as they are called by the BPF verifier.
I'd be glad if someone could shed light on how the BPF context is defined. Thanks.