On Wed, Mar 04, 2026 at 11:02:25PM +0000, [email protected] wrote:
> > The provided <pattern> is used as 'pattern' argument in
> > bpf_program__attach_kprobe_multi_opts function.
>
> The function referenced here should be
> bpf_program__attach_tracing_multi, not
> bpf_program__attach_kprobe_multi_opts. This was noted in v1
> review.
I'm refering to bpf_program__attach_kprobe_multi_opts intentionaly
>
> > - bpf_program__attach_kprobe_multi_opts must either have
> > pattern with module spec or BTF ids from the module
>
> Same here, should be bpf_program__attach_tracing_multi.
yep, that's typo, thnx
>
> > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> > --- a/tools/lib/bpf/libbpf.c
> > +++ b/tools/lib/bpf/libbpf.c
>
> [ ... ]
>
> > +struct bpf_link *
> > +bpf_program__attach_tracing_multi(const struct bpf_program *prog, const
> > char *pattern,
> > + const struct bpf_tracing_multi_opts *opts)
> > +{
> > + LIBBPF_OPTS(bpf_link_create_opts, lopts);
> > + __u32 *ids, *free_ids = NULL;
> > + __u64 *cookies;
> > + int prog_fd, link_fd, err, cnt;
> > + struct bpf_link *link;
> > +
> > + cnt = OPTS_GET(opts, cnt, 0);
> > + ids = OPTS_GET(opts, ids, NULL);
> > + cookies = OPTS_GET(opts, cookies, NULL);
>
> Should this function validate opts with OPTS_VALID() before
> calling OPTS_GET()? The comparable
> bpf_program__attach_kprobe_multi_opts() does:
>
> if (!OPTS_VALID(opts, bpf_kprobe_multi_opts))
> return libbpf_err_ptr(-EINVAL);
>
> Without OPTS_VALID(), a caller passing opts with sz=0 would have
> ids, cookies and cnt silently ignored rather than getting -EINVAL
> back.
yep, should be there, will fix, thnx
jirka