xdp-project / bpf-examples

Making eBPF programming easier via build env and examples
438 stars 85 forks source link

Could you please explain the purpose and usage of traffic-pacing-edt? #97

Open garenchan opened 1 year ago

garenchan commented 1 year ago

Additionally, I am having difficulty compiling these examples and encountering various errors.

tohojo commented 1 year ago

Can't help you with "various errors", you're going to have to be more specific :)

As for the purpose of traffic-pacing-edt, ping @netoptimizer

garenchan commented 1 year ago

@tohojo Can you help me with this?

root@ubuntu:/home/ck# git clone https://github.com/xdp-project/bpf-examples.git
Cloning into 'bpf-examples'...
remote: Enumerating objects: 2833, done.
remote: Counting objects: 100% (346/346), done.
remote: Compressing objects: 100% (149/149), done.
remote: Total 2833 (delta 224), reused 232 (delta 197), pack-reused 2487
Receiving objects: 100% (2833/2833), 1.63 MiB | 4.36 MiB/s, done.
Resolving deltas: 100% (1870/1870), done.
root@ubuntu:/home/ck# cd bpf-examples
root@ubuntu:/home/ck/bpf-examples# ./configure
clang: 11.1.0-++20211011094159+1fdec59bffc1-1~exp1~20211011214614.8
libmnl support: yes
libbpf support: submodule
Submodule 'lib/libbpf' (https://github.com/xdp-project/libbpf.git) registered for path 'lib/libbpf'
Submodule 'lib/xdp-tools' (https://github.com/xdp-project/xdp-tools) registered for path 'lib/xdp-tools'
Cloning into '/home/ck/bpf-examples/lib/libbpf'...
Cloning into '/home/ck/bpf-examples/lib/xdp-tools'...
Submodule path 'lib/libbpf': checked out 'a6d7530cb7dff87ac1e64a540e63b67ddde2e0f9'
Submodule path 'lib/xdp-tools': checked out '344b241da22a5358c714d6db1ea6f225f951dbdb'
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.1.0-++20211011094159+1fdec59bffc1-1~exp1~20211011214614.8')
bpftool doesn't support skeleton generation
root@ubuntu:/home/ck/bpf-examples# make

lib

  libbpf
    CC       install/lib/libbpf.a
    INSTALL  install/lib/libbpf.a

  libxdp
    CC       install/lib/libxdp.a
make[2]: *** [config.mk] Error 1
Makefile:67: recipe for target 'install/lib/libxdp.a' failed
make[1]: *** [install/lib/libxdp.a] Error 2
Makefile:34: recipe for target 'lib' failed
make: *** [lib] Error 2
root@ubuntu:/home/ck/bpf-examples# uname -a
Linux ubuntu 5.4.0-152-generic #169~18.04.1-Ubuntu SMP Wed Jun 7 22:22:24 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
root@ubuntu:/home/ck/bpf-examples# bpftool --version
/usr/lib/linux-tools/5.4.0-152-generic/bpftool v5.4.235
tohojo commented 1 year ago

Garen Chan @.***> writes:

bpftool doesn't support skeleton generation

You're getting an error from the xdp-tools configure script, here. You'll need to install a newer version of bpftool :)

garenchan commented 1 year ago

@tohojo OK. Thank you.

tohojo commented 1 year ago

Garen Chan @.***> writes:

@tohojo I have solved the problem you mentioned, but now I have encountered the following issue.


***@***.***:/home/ck/bpf-examples# ./configure
clang: 11.1.0-++20211011094159+1fdec59bffc1-1~exp1~20211011214614.8
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.1.0-++20211011094159+1fdec59bffc1-1~exp1~20211011214614.8')
using /usr/local/bin/bpftool v5.9.0
libbpf support: custom v1.0.0
  perf_buffer__consume support: yes
  btf__load_from_kernel_by_id support: yes
  btf__type_cnt support: yes
  bpf_object__next_map support: yes
  bpf_object__next_program support: yes
  bpf_program__insn_cnt support: yes
  bpf_map_create support: yes
  perf_buffer__new_raw support: yes
  bpf_xdp_attach support: yes
  bpf_map__set_autocreate support: yes
  bpf_prog_test_run_opts support: yes
zlib support: yes
ELF support: yes
pcap support: yes
secure_getenv support: yes
***@***.***:/home/ck/bpf-examples# make

lib

  libxdp
    CC       install/lib/libxdp.a
llc: xdp-dispatcher.ll:15:54: error: expected ')' at end of argument list
define dso_local i32 @prog0(%struct.xdp_md* readnone %0)
  local_unnamed_addr #0 !dbg !51 {

Hmm, this usually happens when the LLC and clang versions are incompatible. Try setting them explicitly before running configure with something like:

export CLANG=clang-11 LLC=llc-11

garenchan commented 1 year ago

@tohojo Thank you so much.

tohojo commented 1 year ago

Garen Chan @.***> writes:

@tohojo Thank you so much.

You're welcome! :)