BPF Archive on lore.kernel.org
 help / color / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Alexei Starovoitov <ast@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH bpf-next 2/3] libbpf: Add support for program extensions
Date: Mon, 20 Jan 2020 14:51:42 -0800
Message-ID: <CAEf4BzaOhCqYbznPsnuScJx1qbnLJu+2SQfhMwfdq-tJx9k7gA@mail.gmail.com> (raw)
In-Reply-To: <20200118000657.2135859-3-ast@kernel.org>

On Fri, Jan 17, 2020 at 4:47 PM Alexei Starovoitov <ast@kernel.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@kernel.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),

[...]

  reply index

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-18  0:06 [PATCH bpf-next 0/3] bpf: Program extensions or dynamic re-linking Alexei Starovoitov
2020-01-18  0:06 ` [PATCH bpf-next 1/3] bpf: Introduce dynamic program extensions Alexei Starovoitov
2020-01-20 22:52   ` Andrii Nakryiko
2020-01-20 23:31     ` Alexei Starovoitov
2020-01-18  0:06 ` [PATCH bpf-next 2/3] libbpf: Add support for " Alexei Starovoitov
2020-01-20 22:51   ` Andrii Nakryiko [this message]
2020-01-21  0:35     ` Alexei Starovoitov
2020-01-18  0:06 ` [PATCH bpf-next 3/3] selftests/bpf: Add tests " Alexei Starovoitov

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=CAEf4BzaOhCqYbznPsnuScJx1qbnLJu+2SQfhMwfdq-tJx9k7gA@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@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

BPF Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/bpf/0 bpf/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 bpf bpf/ https://lore.kernel.org/bpf \
		bpf@vger.kernel.org
	public-inbox-index bpf

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.bpf


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git