[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YvsPBk4Wo3Iw7spd@Laptop-X1>
Date: Tue, 16 Aug 2022 11:29:10 +0800
From: Hangbin Liu <liuhangbin@...il.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: Quentin Monnet <quentin@...valent.com>, netdev@...r.kernel.org,
bpf@...r.kernel.org
Subject: Re: [PATCHv2 bpf-next] libbpf: making bpf_prog_load() ignore name if
kernel doesn't support
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!
Powered by blists - more mailing lists