All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: jjedwa165 <jonathan.edwards@165gc.onmicrosoft.com>
Cc: bpf <bpf@vger.kernel.org>
Subject: Re: [PATCH bpf-next] libbpf: add extra BPF_PROG_TYPE check to bpf_object__probe_loading
Date: Fri, 18 Jun 2021 20:26:19 -0700	[thread overview]
Message-ID: <CAEf4BzZxHSAn6d7M9O5_HE7p5K-Z2OJ1E9f0YGXfAbdWhsZ1GQ@mail.gmail.com> (raw)
In-Reply-To: <20210618231322.GA27742@165gc.onmicrosoft.com>

On Fri, Jun 18, 2021 at 4:13 PM jjedwa165
<jonathan.edwards@165gc.onmicrosoft.com> wrote:
>
> eBPF has been backported for RHEL 7 w/ kernel 3.10-940+ [0]. However
> only the following program types are supported [1]
>
> BPF_PROG_TYPE_KPROBE
> BPF_PROG_TYPE_TRACEPOINT
> BPF_PROG_TYPE_PERF_EVENT
>
> For libbpf this causes an EINVAL return during the bpf_object__probe_loading
> call which only checks to see if programs of type BPF_PROG_TYPE_SOCKET_FILTER
> can load.
>
> The following will try BPF_PROG_TYPE_TRACEPOINT as a fallback attempt before
> erroring out. BPF_PROG_TYPE_KPROBE was not a good candidate because on some
> kernels it requires knowledge of the LINUX_VERSION_CODE.
>
> [0] https://www.redhat.com/en/blog/introduction-ebpf-red-hat-enterprise-linux-7
> [1] https://access.redhat.com/articles/3550581
>
> Signed-off-by: jjedwa165 <jonathan.edwards@165gc.onmicrosoft.com>
> ---

LGTM, but please re-submit with your real first and last name in
Signed-off-by. Also add my ack:

Acked-by: Andrii Nakryiko <andrii@kernel.org>

>  tools/lib/bpf/libbpf.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 48c0ade05..1e04ce724 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -4000,6 +4000,10 @@ bpf_object__probe_loading(struct bpf_object *obj)
>         attr.license = "GPL";
>
>         ret = bpf_load_program_xattr(&attr, NULL, 0);
> +       if (ret < 0) {
> +               attr.prog_type = BPF_PROG_TYPE_TRACEPOINT;
> +               ret = bpf_load_program_xattr(&attr, NULL, 0);
> +       }
>         if (ret < 0) {
>                 ret = errno;
>                 cp = libbpf_strerror_r(ret, errmsg, sizeof(errmsg));
> --
> 2.17.1
>

  reply	other threads:[~2021-06-19  3:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-16 20:22 [PATCH] add multiple program checks to bpf_object__probe_loading Jonathan Edwards
2021-06-17  5:12 ` Andrii Nakryiko
2021-06-18 23:13   ` [PATCH bpf-next] libbpf: add extra BPF_PROG_TYPE check " jjedwa165
2021-06-19  3:26     ` Andrii Nakryiko [this message]
2021-06-19 15:10       ` Jonathan Edwards
2021-06-21 15:30         ` patchwork-bot+netdevbpf

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=CAEf4BzZxHSAn6d7M9O5_HE7p5K-Z2OJ1E9f0YGXfAbdWhsZ1GQ@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=jonathan.edwards@165gc.onmicrosoft.com \
    /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.