On Wed, Apr 20, 2022 at 9:12 AM grantseltzer <grantseltzer@xxxxxxxxx> wrote: > > From: Grant Seltzer <grantseltzer@xxxxxxxxx> > > This adds documentation for the following API functions: > - bpf_program__set_expected_attach_type() > - bpf_program__set_type() > - bpf_program__set_attach_target() > - bpf_program__attach() > - bpf_program__pin() > - bpf_program__unpin() > > Signed-off-by: Grant Seltzer <grantseltzer@xxxxxxxxx> > --- > tools/lib/bpf/libbpf.h | 77 ++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 75 insertions(+), 2 deletions(-) > [...] > > LIBBPF_API enum bpf_attach_type > bpf_program__expected_attach_type(const struct bpf_program *prog); > -LIBBPF_API void > + > +/** > + * @brief **bpf_program__set_expected_attach_type()** sets the > + * attach type of the passed BPF program. This is used for > + * auto-detection of attachment when programs are loaded. > + * @param prog BPF program to set the attach type for > + * @param type attach type to set the BPF map to have > + * @return error code; or 0 if no error. An error occurs > + * if the object is already loaded. > + * > + * This must be called before the BPF object is loaded, > + * otherwise it has no effect and an error is returned. > + */ > +LIBBPF_API int you forgot to do this void -> int replacement in libbpf.h. I've fixed it up while applying, so all the type changes happen in patch #1. > bpf_program__set_expected_attach_type(struct bpf_program *prog, > enum bpf_attach_type type); > > @@ -707,6 +772,14 @@ LIBBPF_API int bpf_program__set_log_level(struct bpf_program *prog, __u32 log_le > LIBBPF_API const char *bpf_program__log_buf(const struct bpf_program *prog, size_t *log_size); > LIBBPF_API int bpf_program__set_log_buf(struct bpf_program *prog, char *log_buf, size_t log_size); > > +/** > + * @brief **bpf_program__set_attach_target()** sets BTF-based attach target > + * for supported BPF program types: > + * BTF-aware raw tracepoints, fentry/fexit/fmod_ret, lsm, freplace also turned this into a proper list > + * @param prog BPF program to set the attach type for > + * @param type attach type to set the BPF map to have > + * @return error code; or 0 if no error occurred. > + */ > LIBBPF_API int > bpf_program__set_attach_target(struct bpf_program *prog, int attach_prog_fd, > const char *attach_func_name); > -- > 2.34.1 >