All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kui-Feng Lee <kuifeng@fb.com>
To: "andrii.nakryiko@gmail.com" <andrii.nakryiko@gmail.com>
Cc: "daniel@iogearbox.net" <daniel@iogearbox.net>,
	Kernel Team <Kernel-team@fb.com>,
	"ast@kernel.org" <ast@kernel.org>,
	"andrii@kernel.org" <andrii@kernel.org>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>
Subject: Re: [PATCH bpf-next v7 4/5] libbpf: Assign cookies to links in libbpf.
Date: Tue, 10 May 2022 17:23:48 +0000	[thread overview]
Message-ID: <021ea9d3a2008c39a8ee41fe3955d473baa61c66.camel@fb.com> (raw)
In-Reply-To: <CAEf4BzZ06F3vwhHHixpCyXHpnhCx2mwhT6GS5S5FfvBp_bsV9g@mail.gmail.com>

On Mon, 2022-05-09 at 12:05 -0700, Andrii Nakryiko wrote:
> On Sat, May 7, 2022 at 8:21 PM Kui-Feng Lee <kuifeng@fb.com> wrote:
> > 
> > Add a cookie field to the attributes of bpf_link_create().
> > Add bpf_program__attach_trace_opts() to attach a cookie to a link.
> > 
> > Signed-off-by: Kui-Feng Lee <kuifeng@fb.com>
> > ---
> >  tools/lib/bpf/bpf.c      |  8 ++++++++
> >  tools/lib/bpf/bpf.h      |  3 +++
> >  tools/lib/bpf/libbpf.c   | 32 ++++++++++++++++++++++++++++++++
> >  tools/lib/bpf/libbpf.h   | 12 ++++++++++++
> >  tools/lib/bpf/libbpf.map |  1 +
> >  5 files changed, 56 insertions(+)
> > 
> 
> I have a gripe with better code reuse, but that's internal change so
> we can do it in a follow up.
> 
> Acked-by: Andrii Nakryiko <andrii@kernel.org>
> 
> > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> > index 73a5192defb3..df9be47d67bc 100644
> > --- a/tools/lib/bpf/libbpf.c
> > +++ b/tools/lib/bpf/libbpf.c
> > @@ -11440,6 +11440,38 @@ struct bpf_link
> > *bpf_program__attach_trace(const struct bpf_program *prog)
> >         return bpf_program__attach_btf_id(prog);
> >  }
> > 
> > +struct bpf_link *bpf_program__attach_trace_opts(const struct
> > bpf_program *prog,
> > +                                               const struct
> > bpf_trace_opts *opts)
> 
> there is bpf_program__attach_btf_id() that does all of this except
> for
> the cookie. It would be nicer to extend bpf_program__attach_btf_id(),
> which won't break any API because it's an internal helper, add
> optional bpf_trace_opts to it and then just redirect
> bpf_program__attach_trace_opts() to bpf_program__attach_btf_id and
> update all the existing callers with just passing NULL for opts.

Fixed!  I copied the code from bpf_program__attach_btf_id() for
testing, and forgot to refactor it.

> 
> We can do that as a follow up, given your patch set seems to be
> pretty
> much ready to be landed.
> 
> > +{
> > +       char errmsg[STRERR_BUFSIZE];
> > +       struct bpf_link *link;
> > +       int prog_fd, pfd;
> > +       LIBBPF_OPTS(bpf_link_create_opts, link_opts);
> > +
> 
> [...]


  reply	other threads:[~2022-05-10 17:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-08  3:21 [PATCH bpf-next v7 0/5] Attach a cookie to a tracing program Kui-Feng Lee
2022-05-08  3:21 ` [PATCH bpf-next v7 1/5] bpf, x86: Generate trampolines from bpf_tramp_links Kui-Feng Lee
2022-05-09 18:54   ` Andrii Nakryiko
2022-05-10 16:50     ` Kui-Feng Lee
2022-05-08  3:21 ` [PATCH bpf-next v7 2/5] bpf, x86: Create bpf_tramp_run_ctx on the caller thread's stack Kui-Feng Lee
2022-05-09 18:54   ` Andrii Nakryiko
2022-05-09 21:04   ` Alexei Starovoitov
2022-05-10  1:29     ` Kui-Feng Lee
2022-05-10  1:43       ` Kui-Feng Lee
2022-05-10  2:11         ` Alexei Starovoitov
2022-05-08  3:21 ` [PATCH bpf-next v7 3/5] bpf, x86: Attach a cookie to fentry/fexit/fmod_ret/lsm Kui-Feng Lee
2022-05-09 18:58   ` Andrii Nakryiko
2022-05-10 16:44     ` Kui-Feng Lee
2022-05-10 18:44       ` Andrii Nakryiko
2022-05-08  3:21 ` [PATCH bpf-next v7 4/5] libbpf: Assign cookies to links in libbpf Kui-Feng Lee
2022-05-09 19:05   ` Andrii Nakryiko
2022-05-10 17:23     ` Kui-Feng Lee [this message]
2022-05-08  3:21 ` [PATCH bpf-next v7 5/5] selftest/bpf: The test cses of BPF cookie for fentry/fexit/fmod_ret/lsm Kui-Feng Lee
2022-05-09 19:08   ` Andrii Nakryiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=021ea9d3a2008c39a8ee41fe3955d473baa61c66.camel@fb.com \
    --to=kuifeng@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.