From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Eelco Chaudron <echaudro@redhat.com>,
xdp-newbies@vger.kernel.org, Andrii Nakryiko <andriin@fb.com>
Subject: Re: Need a way to modify the section name for a read program object
Date: Tue, 04 Feb 2020 11:19:53 +0100 [thread overview]
Message-ID: <874kw664dy.fsf@toke.dk> (raw)
In-Reply-To: <D0F8E306-ABEE-480E-BDFD-D43E3A98DC5A@redhat.com>
"Eelco Chaudron" <echaudro@redhat.com> writes:
> Hi All,
>
> I'm trying to write an xdpdump like utility and have some missing part
> in libbpf to change the fentry/FUNCTION section name before loading the
> trace program.
>
> In short, I have an eBPF program that has a section name like
> "fentry/FUNCTION" where FUNCTION needs to be replaced by the name of the
> XDP program loaded in the interfaces its start function.
>
> The code for loading the ftrace part is something like:
>
> open_opts.attach_prog_fd = bpf_prog_get_fd_by_id(info.id);
> trace_obj = bpf_object__open_file("xdpdump_bpf.o", &open_opts);
>
> trace_prog_fentry = bpf_object__find_program_by_title(trace_obj,
> "fentry/FUNCTION");
>
> /* Here I need to replace the trace_prog_fentry->section_name =
> "fentry/<INTERFACE PROG NAME> */
>
> bpf_object__load(trace_obj);
> trace_link_fentry = bpf_program__attach_trace(trace_prog_fentry);
>
>
> See the above, I would like to change the section_name but there is no
> API to do this, and of course, the struct bpf_program is
> implementation-specific.
>
> Any idea how I would work around this, or what extension to libbpf can
> be suggested to support this?
I think what's missing is a way for the caller to set the attach_btf_id.
Currently, libbpf always tries to discover this based on the section
name (see libbpf_find_attach_btf_id()). I think the right way to let the
caller specify this is not to change the section name, though, but just
to expose a way to explicitly set the btf_id (which the caller can then
go find on its own).
Not sure if it would be better with a new open_opt (to mirror
attach_prog_fd), or just a setter (bpf_program__set_attach_btf_id()?).
Or maybe both? Andrii, WDYT?
-Toke
next prev parent reply other threads:[~2020-02-04 10:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-30 15:32 Need a way to modify the section name for a read program object Eelco Chaudron
2020-02-04 10:19 ` Toke Høiland-Jørgensen [this message]
2020-02-04 19:00 ` Andrii Nakryiko
2020-02-04 19:26 ` Toke Høiland-Jørgensen
2020-02-04 19:26 ` Toke Høiland-Jørgensen
2020-02-04 19:32 ` Andrii Nakryiko
2020-02-11 14:37 ` Eelco Chaudron
2020-02-11 14:54 ` Toke Høiland-Jørgensen
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=874kw664dy.fsf@toke.dk \
--to=toke@redhat.com \
--cc=andriin@fb.com \
--cc=echaudro@redhat.com \
--cc=xdp-newbies@vger.kernel.org \
/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.