bpf: Annotate context types
authorAlexei Starovoitov <ast@kernel.org>
Thu, 14 Nov 2019 18:57:15 +0000 (10:57 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 15 Nov 2019 22:44:48 +0000 (23:44 +0100)
commit91cc1a99740e2ed1d903b5906afb470cc5a07379
treeea7c450f397b2f02a81cde66a5f1e4f5fb819c5c
parent9cc31b3a092d9bf2a18f09ad77e727ddb42a5b1e
bpf: Annotate context types

Annotate BPF program context types with program-side type and kernel-side type.
This type information is used by the verifier. btf_get_prog_ctx_type() is
used in the later patches to verify that BTF type of ctx in BPF program matches to
kernel expected ctx type. For example, the XDP program type is:
BPF_PROG_TYPE(BPF_PROG_TYPE_XDP, xdp, struct xdp_md, struct xdp_buff)
That means that XDP program should be written as:
int xdp_prog(struct xdp_md *ctx) { ... }

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20191114185720.1641606-16-ast@kernel.org
include/linux/bpf.h
include/linux/bpf_types.h
kernel/bpf/btf.c
kernel/bpf/syscall.c
kernel/bpf/verifier.c
net/core/filter.c