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.
Showing the changes to include/uapi/linux (1 of 2 files). Show all
Unified · Split
| @@ -113,6 +113,8 @@ enum bpf_cmd { · 112 unmodified lines | |||
| 113 | BPF_MAP_DELETE_BATCH, | 113 | BPF_MAP_DELETE_BATCH, |
| 114 | BPF_LINK_CREATE, | 114 | BPF_LINK_CREATE, |
| 115 | BPF_LINK_UPDATE, | 115 | BPF_LINK_UPDATE, |
| 116 | BPF_LINK_GET_FD_BY_ID, | ||
| 117 | BPF_LINK_GET_NEXT_ID, | ||
| 116 | }; | 118 | }; |
| 117 | 119 | ||
| 118 | enum bpf_map_type { | 120 | enum bpf_map_type { |