Re: [PATCH bpf-next 02/14] libbpf: add bpf() syscall wrapper into public API

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

 



On Mon, Nov 1, 2021 at 9:00 AM Daniel Borkmann <daniel@xxxxxxxxxxxxx> wrote:
>
> On 10/30/21 6:59 AM, Andrii Nakryiko wrote:
> > Move internal sys_bpf() helper into bpf.h and expose as public API.
> > __NR_bpf definition logic is also moved. Renamed sys_bpf() into bpf() to
> > follow libbpf naming conventions. Adapt internal uses accordingly.
> >
> > Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
> [...]
> >
> > +/*
> > + * Kernel headers might be outdated, so define __NR_bpf explicitly, if necessary.
> > + */
> > +#ifndef __NR_bpf
> > +# if defined(__i386__)
> > +#  define __NR_bpf 357
> > +# elif defined(__x86_64__)
> > +#  define __NR_bpf 321
> > +# elif defined(__aarch64__)
> > +#  define __NR_bpf 280
> > +# elif defined(__sparc__)
> > +#  define __NR_bpf 349
> > +# elif defined(__s390__)
> > +#  define __NR_bpf 351
> > +# elif defined(__arc__)
> > +#  define __NR_bpf 280
> > +# else
> > +#  error __NR_bpf not defined. libbpf does not support your arch.
> > +# endif
> > +#endif
>
> Do we still need this nowadays, presumably it's been long enough that system headers do
> have __NR_bpf by now?

No idea, didn't want to risk it, tbh. But I'll just drop the change
for now. I started this patch set by moving more `static inline` stuff
into bpf.h that used sys_bpf(), but ended up going in a different
direction, ultimately. So this patch isn't necessary and I'll drop it.
We can always revisit later.

>
> > +static inline long bpf(enum bpf_cmd cmd, union bpf_attr *attr, unsigned int size)
> > +{
> > +     return syscall(__NR_bpf, cmd, attr, size);
> > +}
> > +
> >   struct bpf_create_map_attr {
> >       const char *name;
> >       enum bpf_map_type map_type;
> >
>



[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