]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commit7164f3c0eb0a86e5a9c03838798572b4fe4ccef0
treeea7c450f397b2f02a81cde66a5f1e4f5fb819c5c
parent3b55933d644eaafff926940cbfe0ad582fd672fc
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