[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzaOhCqYbznPsnuScJx1qbnLJu+2SQfhMwfdq-tJx9k7gA@mail.gmail.com>
Date: Mon, 20 Jan 2020 14:51:42 -0800
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Alexei Starovoitov <ast@...nel.org>
Cc: "David S. Miller" <davem@...emloft.net>,
Daniel Borkmann <daniel@...earbox.net>,
Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
Kernel Team <kernel-team@...com>
Subject: Re: [PATCH bpf-next 2/3] libbpf: Add support for program extensions
On Fri, Jan 17, 2020 at 4:47 PM Alexei Starovoitov <ast@...nel.org> wrote:
>
> Add minimal support for program extensions. bpf_object_open_opts() needs to be
> called with attach_prog_fd = target_prog_fd and BPF program extension needs to
> have in .c file section definition like SEC("replace/func_to_be_replaced").
> libbpf will search for "func_to_be_replaced" in the target_prog_fd's BTF and
> will pass it in attach_btf_id to the kernel. This approach works for tests, but
> more compex use case may need to request function name (and attach_btf_id that
> kernel sees) to be more dynamic. Such API will be added in future patches.
>
> Signed-off-by: Alexei Starovoitov <ast@...nel.org>
> ---
> tools/include/uapi/linux/bpf.h | 1 +
> tools/lib/bpf/bpf.c | 3 ++-
> tools/lib/bpf/libbpf.c | 14 +++++++++++---
> tools/lib/bpf/libbpf.h | 2 ++
> tools/lib/bpf/libbpf.map | 2 ++
> tools/lib/bpf/libbpf_probes.c | 1 +
> 6 files changed, 19 insertions(+), 4 deletions(-)
>
[...]
> enum bpf_attach_type
> bpf_program__get_expected_attach_type(struct bpf_program *prog)
> @@ -6265,6 +6269,10 @@ static const struct bpf_sec_def section_defs[] = {
> .expected_attach_type = BPF_TRACE_FEXIT,
> .is_attach_btf = true,
> .attach_fn = attach_trace),
> + SEC_DEF("replace/", EXT,
how about freplace/, similar to fentry/fexit?
> + .expected_attach_type = 0,
no need, it will be zero, if not specified here
> + .is_attach_btf = true,
> + .attach_fn = attach_trace),
> BPF_PROG_SEC("xdp", BPF_PROG_TYPE_XDP),
> BPF_PROG_SEC("perf_event", BPF_PROG_TYPE_PERF_EVENT),
> BPF_PROG_SEC("lwt_in", BPF_PROG_TYPE_LWT_IN),
[...]
Powered by blists - more mailing lists