[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAPwn2JSacQ6mOOKLL1Ju68BJf5PepnJnziM5k88Gx-7nxtmNmA@mail.gmail.com>
Date: Sat, 13 Aug 2022 07:53:07 +0800
From: Hangbin Liu <liuhangbin@...il.com>
To: Quentin Monnet <quentin@...valent.com>
Cc: netdev@...r.kernel.org, Andrii Nakryiko <andrii@...nel.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Martin KaFai Lau <martin.lau@...ux.dev>,
Song Liu <song@...nel.org>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...gle.com>,
Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
bpf@...r.kernel.org
Subject: Re: [PATCH bpf-next] libbpf: making bpf_prog_load() ignore name if
kernel doesn't support
On Fri, Aug 12, 2022 at 4:38 PM Quentin Monnet <quentin@...valent.com> wrote:
> > diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h
> > index 9c50beabdd14..125c580e45f8 100644
> > --- a/tools/lib/bpf/bpf.h
> > +++ b/tools/lib/bpf/bpf.h
> > @@ -35,6 +35,9 @@
> > extern "C" {
> > #endif
> >
> > +#define PROG_LOAD_ATTEMPTS 5
> > +int sys_bpf_prog_load(union bpf_attr *attr, unsigned int size, int attempts);
> > +
>
> bpf.h is the user-facing header, should these go into libbpf_internal.h
> instead?
libbpf_internal.h makes more sense, I wil move it.
> > + union bpf_attr attr = {
> > + .prog_type = BPF_PROG_TYPE_SOCKET_FILTER,
> > + .prog_name = "test",
> > + .license = ptr_to_u64("GPL"),
> > + .insns = ptr_to_u64(insns),
> > + .insn_cnt = (__u32)ARRAY_SIZE(insns),
> > + };
>
> I think you cannot initialise "attr" directly, you need a "memset(&attr,
> 0, sizeof(attr));" first, in case the struct contains padding between
> the fields.
Thanks for the reminder. I forgot the padding issue.
I will post version 2.
Thanks
Hangbin
Powered by blists - more mailing lists