xdp-project / bpf-examples

Making eBPF programming easier via build env and examples
436 stars 84 forks source link

Dependencies #74

Closed KillianCdP closed 1 year ago

KillianCdP commented 1 year ago

Hello,

What are the dependencies for compiling the project? I am having issue compiling on a Ubuntu Server 20.04 machine with kernel 5.15.39.

Output of configure is the following:

clang: 11.0.0-2~ubuntu20.04.1
libmnl support: yes
libbpf support: submodule
ELF support: yes
zlib support: yes
libxdp support: submodule
Configuring libxdp to use our libbpf submodule
Found clang binary 'clang' with version 11 (from 'Ubuntu clang version 11.0.0-2~ubuntu20.04.1')
libbpf support: custom v1.0.0
  perf_buffer__consume support: no
  btf__load_from_kernel_by_id support: no
  btf__type_cnt support: no
  bpf_object__next_map support: no
  bpf_object__next_program support: no
  bpf_program__insn_cnt support: no
  bpf_map_create support: no
  perf_buffer__new_raw support: no
  bpf_xdp_attach support: no
zlib support: yes
ELF support: yes
pcap support: yes
secure_getenv support: yes

libbpf is compiling fine however libxdp doesn't. Here is a snippet of the output log:

  libxdp
    CC       install/lib/libxdp.a
libxdp.c:244:20: error: static declaration of ‘btf__load_from_kernel_by_id’ follows non-static declaration
  244 | static struct btf *btf__load_from_kernel_by_id(__u32 id)
...

For comparison, here is the output of configure on the xdp-tools project which compiles fine:

Found clang binary 'clang' with version 11 (from 'Ubuntu clang version 11.0.0-2~ubuntu20.04.1')
libbpf support: submodule v1.0.0
  perf_buffer__consume support: yes (submodule)
  btf__load_from_kernel_by_id support: yes (submodule)
  btf__type_cnt support: yes (submodule)
  bpf_object__next_map support: yes (submodule)
  bpf_object__next_program support: yes (submodule)
  bpf_program__insn_cnt support: yes (submodule)
  bpf_map_create support: yes (submodule)
  perf_buffer__new_raw support: yes (submodule)
  bpf_xdp_attach support: yes (submodule)
zlib support: yes
ELF support: yes
pcap support: yes
secure_getenv support: yes

So it seems to be a difference on what libbpf supports between the two projects, but it should be the same as both are using libbpf as submodule on v1.0.0?

Thanks

tohojo commented 1 year ago

Hmm, no, that should definitely work. Could you try re-running configure (in the bpf-examples repository) as:

DEBUG_CONFIGURE=1 ./configure

and posting the output of that?

KillianCdP commented 1 year ago

DEBUG_CONFIGURE=1 ./configure

Here is the output:

clang: 11.0.0-2~ubuntu20.04.1
libmnl support: yes
libbpf support: submodule
ELF support: yes
zlib support: yes
libxdp support: submodule
Configuring libxdp to use our libbpf submodule
Found clang binary 'clang' with version 11 (from 'Ubuntu clang version 11.0.0-2~ubuntu20.04.1')
libbpf support: custom v1.0.0
  perf_buffer__consume support: no
    gcc -o config.rGJjdI/libbpftest config.rGJjdI/libbpftest.c -Werror -Iconfig.rGJjdI/include -Xlinker --unresolved-symbols=ignore-in-object-files
    In file included from config.rGJjdI/libbpftest.c:1:
    config.rGJjdI/include/bpf/libbpf.h:70:54: error: ‘enum bpf_link_type’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
       70 | LIBBPF_API const char *libbpf_bpf_link_type_str(enum bpf_link_type t);
          |                                                      ^~~~~~~~~~~~~
    In file included from config.rGJjdI/libbpftest.c:3:
    config.rGJjdI/include/bpf/btf.h:208:14: error: ‘enum btf_func_linkage’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
      208 |         enum btf_func_linkage linkage, int proto_type_id);
          |              ^~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
  btf__load_from_kernel_by_id support: no
    gcc -o config.rGJjdI/libbpftest config.rGJjdI/libbpftest.c -Werror -Iconfig.rGJjdI/include -Xlinker --unresolved-symbols=ignore-in-object-files
    In file included from config.rGJjdI/libbpftest.c:1:
    config.rGJjdI/include/bpf/libbpf.h:70:54: error: ‘enum bpf_link_type’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
       70 | LIBBPF_API const char *libbpf_bpf_link_type_str(enum bpf_link_type t);
          |                                                      ^~~~~~~~~~~~~
    In file included from config.rGJjdI/libbpftest.c:3:
    config.rGJjdI/include/bpf/btf.h:208:14: error: ‘enum btf_func_linkage’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
      208 |         enum btf_func_linkage linkage, int proto_type_id);
          |              ^~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
  btf__type_cnt support: no
    gcc -o config.rGJjdI/libbpftest config.rGJjdI/libbpftest.c -Werror -Iconfig.rGJjdI/include -Xlinker --unresolved-symbols=ignore-in-object-files
    In file included from config.rGJjdI/libbpftest.c:1:
    config.rGJjdI/include/bpf/libbpf.h:70:54: error: ‘enum bpf_link_type’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
       70 | LIBBPF_API const char *libbpf_bpf_link_type_str(enum bpf_link_type t);
          |                                                      ^~~~~~~~~~~~~
    In file included from config.rGJjdI/libbpftest.c:3:
    config.rGJjdI/include/bpf/btf.h:208:14: error: ‘enum btf_func_linkage’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
      208 |         enum btf_func_linkage linkage, int proto_type_id);
          |              ^~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
  bpf_object__next_map support: no
    gcc -o config.rGJjdI/libbpftest config.rGJjdI/libbpftest.c -Werror -Iconfig.rGJjdI/include -Xlinker --unresolved-symbols=ignore-in-object-files
    In file included from config.rGJjdI/libbpftest.c:1:
    config.rGJjdI/include/bpf/libbpf.h:70:54: error: ‘enum bpf_link_type’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
       70 | LIBBPF_API const char *libbpf_bpf_link_type_str(enum bpf_link_type t);
          |                                                      ^~~~~~~~~~~~~
    In file included from config.rGJjdI/libbpftest.c:3:
    config.rGJjdI/include/bpf/btf.h:208:14: error: ‘enum btf_func_linkage’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
      208 |         enum btf_func_linkage linkage, int proto_type_id);
          |              ^~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
  bpf_object__next_program support: no
    gcc -o config.rGJjdI/libbpftest config.rGJjdI/libbpftest.c -Werror -Iconfig.rGJjdI/include -Xlinker --unresolved-symbols=ignore-in-object-files
    In file included from config.rGJjdI/libbpftest.c:1:
    config.rGJjdI/include/bpf/libbpf.h:70:54: error: ‘enum bpf_link_type’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
       70 | LIBBPF_API const char *libbpf_bpf_link_type_str(enum bpf_link_type t);
          |                                                      ^~~~~~~~~~~~~
    In file included from config.rGJjdI/libbpftest.c:3:
    config.rGJjdI/include/bpf/btf.h:208:14: error: ‘enum btf_func_linkage’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
      208 |         enum btf_func_linkage linkage, int proto_type_id);
          |              ^~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
  bpf_program__insn_cnt support: no
    gcc -o config.rGJjdI/libbpftest config.rGJjdI/libbpftest.c -Werror -Iconfig.rGJjdI/include -Xlinker --unresolved-symbols=ignore-in-object-files
    In file included from config.rGJjdI/libbpftest.c:1:
    config.rGJjdI/include/bpf/libbpf.h:70:54: error: ‘enum bpf_link_type’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
       70 | LIBBPF_API const char *libbpf_bpf_link_type_str(enum bpf_link_type t);
          |                                                      ^~~~~~~~~~~~~
    In file included from config.rGJjdI/libbpftest.c:3:
    config.rGJjdI/include/bpf/btf.h:208:14: error: ‘enum btf_func_linkage’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
      208 |         enum btf_func_linkage linkage, int proto_type_id);
          |              ^~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
  bpf_map_create support: no
    gcc -o config.rGJjdI/libbpftest config.rGJjdI/libbpftest.c -Werror -Iconfig.rGJjdI/include -Xlinker --unresolved-symbols=ignore-in-object-files
    In file included from config.rGJjdI/libbpftest.c:1:
    config.rGJjdI/include/bpf/libbpf.h:70:54: error: ‘enum bpf_link_type’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
       70 | LIBBPF_API const char *libbpf_bpf_link_type_str(enum bpf_link_type t);
          |                                                      ^~~~~~~~~~~~~
    In file included from config.rGJjdI/libbpftest.c:3:
    config.rGJjdI/include/bpf/btf.h:208:14: error: ‘enum btf_func_linkage’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
      208 |         enum btf_func_linkage linkage, int proto_type_id);
          |              ^~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
  perf_buffer__new_raw support: no
    gcc -o config.rGJjdI/libbpftest config.rGJjdI/libbpftest.c -Werror -Iconfig.rGJjdI/include -Xlinker --unresolved-symbols=ignore-in-object-files
    In file included from config.rGJjdI/libbpftest.c:1:
    config.rGJjdI/include/bpf/libbpf.h:70:54: error: ‘enum bpf_link_type’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
       70 | LIBBPF_API const char *libbpf_bpf_link_type_str(enum bpf_link_type t);
          |                                                      ^~~~~~~~~~~~~
    In file included from config.rGJjdI/libbpftest.c:3:
    config.rGJjdI/include/bpf/btf.h:208:14: error: ‘enum btf_func_linkage’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
      208 |         enum btf_func_linkage linkage, int proto_type_id);
          |              ^~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
  bpf_xdp_attach support: no
    gcc -o config.rGJjdI/libbpftest config.rGJjdI/libbpftest.c -Werror -Iconfig.rGJjdI/include -Xlinker --unresolved-symbols=ignore-in-object-files
    In file included from config.rGJjdI/libbpftest.c:1:
    config.rGJjdI/include/bpf/libbpf.h:70:54: error: ‘enum bpf_link_type’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
       70 | LIBBPF_API const char *libbpf_bpf_link_type_str(enum bpf_link_type t);
          |                                                      ^~~~~~~~~~~~~
    In file included from config.rGJjdI/libbpftest.c:3:
    config.rGJjdI/include/bpf/btf.h:208:14: error: ‘enum btf_func_linkage’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
      208 |         enum btf_func_linkage linkage, int proto_type_id);
          |              ^~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
zlib support: yes
ELF support: yes
pcap support: yes
secure_getenv support: yes
tohojo commented 1 year ago

Ah, thanks! This is a bug in the xdp-tools configure script that only surfaces when xdp-tools is embedded in this repo. Could you please try if the update in #75 fixes this (run git submodule update after switching to that branch)?

KillianCdP commented 1 year ago

Thanks, the included libxdp compiles fine now. However I am having issues compiling AF_XDP-example now but I suppose I should create another issue for it. (SO_PREFER_BUSY_POLL not defined on my system)

tohojo commented 1 year ago

Yes, please do!