bpf: Factor out attach_type to prog_type mapping for attach/detach
authorAndrii Nakryiko <andriin@fb.com>
Wed, 25 Mar 2020 06:57:42 +0000 (23:57 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 26 Mar 2020 23:38:13 +0000 (16:38 -0700)
commite28784e3781e19f546bd2c2cd7c1c4e7c54e7f73
treecdd406fb52ca535e682513416117b13ceeab2887
parent00c4eddf7ee5cb4941d669d605815454dc9a5419
bpf: Factor out attach_type to prog_type mapping for attach/detach

Factor out logic mapping expected program attach type to program type and
subsequent handling of program attach/detach. Also list out all supported
cgroup BPF program types explicitly to prevent accidental bugs once more
program types are added to a mapping. Do the same for prog_query API.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200325065746.640559-3-andriin@fb.com
kernel/bpf/syscall.c