Re: [PATCH bpf-next] libbpf: making bpf_prog_load() ignore name if kernel doesn't support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 12, 2022 at 4:38 PM Quentin Monnet <quentin@xxxxxxxxxxxxx> 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



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux