]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Support GET_FD_BY_ID and GET_NEXT_ID for bpf_link
authorAndrii Nakryiko <andriin@fb.com>
Wed, 29 Apr 2020 00:16:07 +0000 (17:16 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 29 Apr 2020 00:27:08 +0000 (17:27 -0700)
commitc8e7bc4431535ce3816fca4f88ed704b289ab003
tree6c34aec45b8df74c35b19e7b7516c788f4dd29fa
parenta6cadd0768058025656bf87989ffd42317447c28
bpf: Support GET_FD_BY_ID and GET_NEXT_ID for bpf_link

Add support to look up bpf_link by ID and iterate over all existing bpf_links
in the system. GET_FD_BY_ID code handles not-yet-ready bpf_link by checking
that its ID hasn't been set to non-zero value yet. Setting bpf_link's ID is
done as the very last step in finalizing bpf_link, together with installing
FD. This approach allows users of bpf_link in kernel code to not worry about
races between user-space and kernel code that hasn't finished attaching and
initializing bpf_link.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200429001614.1544-4-andriin@fb.com
include/uapi/linux/bpf.h
kernel/bpf/syscall.c