Re: vmlinux.h conflicts with bpf.h

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

 



On Thu, Jun 9, 2022 at 8:22 AM Théophile Dubuc
<theophile.dubuc@xxxxxxxxxxx> wrote:
>
> Hello,
>
> I get errors when compiling my bpf application, because vmlinux.h seems to conflict with bpf.h.
> If I include <bpf/bpf.h> or <bpf/libbpf.h>, I get tons of errors like

vmlinux.h is included from BPF-side source code. While bpf/bpf.h and
bpf/libbpf.h is included from user-space side. You shouldn't have an
application including both at the same time. And then vmlinux.h is not
compatible with most UAPI headers (that's a known limitation we are
hopefully will solve eventually), but it defines all the kernel types
down to __u32 alias, so you generally don't need other UAPI headers.

>
> >    In file included from .output/bpf/libbpf.h:18:
> >    ../libbpf/include/uapi/linux/bpf.h:54:2: error: redefinition of enumerator 'BPF_REG_0'
> >            BPF_REG_0 = 0,
> >            ^
> >    ../vmlinux/vmlinux.h:31938:2: note: previous definition is here
> >            BPF_REG_0 = 0,
> >            ^
>
>
>
> What I'm trying to do is use the function `bpf_map_get_next_key` to find an entry in a hash table, and that function is defined in bpf.h.
> I also tried using the `bpf_map__get_next_key` function from libbpf.h instead, but libbpf.h includes bpf.h so I get the conflicts anyway.
>
> I generated vmlinux.h using the `gen_vm_linux_h.sh` script from libbpf-bootstrap/tools, and my Makefile is also the one from the bootstrap example.
>
>
>
> I feel like I am missing something but I can't figure it out (I am quite new to bpf) even by looking in this mailing list archive.
> If you have any idea of what's wrong, please let me know.
>
>
>
> Best regards,
>
> Théophile




[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