libbpf: Create a bpf_link in bpf_map__attach_struct_ops().
authorKui-Feng Lee <kuifeng@meta.com>
Thu, 23 Mar 2023 03:24:01 +0000 (20:24 -0700)
committerMartin KaFai Lau <martin.lau@kernel.org>
Thu, 23 Mar 2023 05:53:02 +0000 (22:53 -0700)
commit8d1608d70927747da9c1a8770edf7b6ee68f8ebc
tree62a2fcea2891964abe076315d003935823296600
parent68b04864ca425d1894c96b8141d4fba1181f11cb
libbpf: Create a bpf_link in bpf_map__attach_struct_ops().

bpf_map__attach_struct_ops() was creating a dummy bpf_link as a
placeholder, but now it is constructing an authentic one by calling
bpf_link_create() if the map has the BPF_F_LINK flag.

You can flag a struct_ops map with BPF_F_LINK by calling
bpf_map__set_map_flags().

Signed-off-by: Kui-Feng Lee <kuifeng@meta.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20230323032405.3735486-5-kuifeng@meta.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
tools/lib/bpf/libbpf.c