All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hangbin Liu <liuhangbin@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Quentin Monnet <quentin@isovalent.com>,
	netdev@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCHv2 bpf-next] libbpf: making bpf_prog_load() ignore name if kernel doesn't support
Date: Tue, 16 Aug 2022 11:29:10 +0800	[thread overview]
Message-ID: <YvsPBk4Wo3Iw7spd@Laptop-X1> (raw)
In-Reply-To: <CAEf4BzbXehQtWnocp5KnArd0dq-Wg0ddPOyJZCwGPLO_L7wByg@mail.gmail.com>

On Mon, Aug 15, 2022 at 02:59:50PM -0700, Andrii Nakryiko wrote:
> I did a small adjustment to not fill out entire big bpf_attr union
> completely (and added a bit more meaningful "libbpf_nametest" prog
> name):
> 

Thanks for the adjustment.

Hangbin

> $ git diff --staged
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 4a351897bdcc..f05dd61a8a7f 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -4415,6 +4415,7 @@ static int probe_fd(int fd)
> 
>  static int probe_kern_prog_name(void)
>  {
> +       const size_t attr_sz = offsetofend(union bpf_attr, prog_name);
>         struct bpf_insn insns[] = {
>                 BPF_MOV64_IMM(BPF_REG_0, 0),
>                 BPF_EXIT_INSN(),
> @@ -4422,12 +4423,12 @@ static int probe_kern_prog_name(void)
>         union bpf_attr attr;
>         int ret;
> 
> -       memset(&attr, 0, sizeof(attr));
> +       memset(&attr, 0, attr_sz);
>         attr.prog_type = BPF_PROG_TYPE_SOCKET_FILTER;
>         attr.license = ptr_to_u64("GPL");
>         attr.insns = ptr_to_u64(insns);
>         attr.insn_cnt = (__u32)ARRAY_SIZE(insns);
> -       libbpf_strlcpy(attr.prog_name, "test", sizeof(attr.prog_name));
> +       libbpf_strlcpy(attr.prog_name, "libbpf_nametest",
> sizeof(attr.prog_name));
> 
> Pushed to bpf-next, thanks!

      reply	other threads:[~2022-08-16  7:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-13  0:09 [PATCHv2 bpf-next] libbpf: making bpf_prog_load() ignore name if kernel doesn't support Hangbin Liu
2022-08-15 15:36 ` Quentin Monnet
2022-08-15 21:59   ` Andrii Nakryiko
2022-08-16  3:29     ` Hangbin Liu [this message]

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=YvsPBk4Wo3Iw7spd@Laptop-X1 \
    --to=liuhangbin@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=quentin@isovalent.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.