Closed kaseiwang closed 2 months ago
iproute can not attach xdp programs without libbpf.
I writen a tiny xdp program (gist) to connect the cloudflare warp vpn with wireguard kernel module. When I tried to attach this xdp program , ip link reported an error.
ip link
reproduce (copy wgcf_bpf_helper.c from gist):
~/working/nixos-xdp/ok ❯ ls shell.nix wgcf_bpf_helper.c ~/working/nixos-xdp/err ❯ cat shell.nix with import <nixpkgs> {}; mkShell { packages = [ clang llvm llvmPackages.stdenv glibc_multi libbpf iproute ]; } ~/working/nixos-xdp/err ❯ clang -O2 -target bpf -c wgcf_bpf_helper.c -o wgcf_bpf clang-11: warning: argument unused during compilation: '--gcc-toolchain=/nix/store/9pgq84sf921xh97gjj2wh7a7clrcrh4m-gcc-12.2.0' [-Wunused-command-line-argument] ~/working/nixos-xdp/err ❯ sudo ip link set dev wlo1 xdp object wgcf_bpf section wg-cf-xdp-ingress ELF contains non-{map,call} related relo data in entry 0 pointing to section 8! Compiler bug?! Error fetching program/map!
If rebuild iproute with libbpf, it works:
~/working/nixos-xdp/ok ❯ cat shell.nix with import <nixpkgs> {}; mkShell { packages = [ clang llvm llvmPackages.stdenv glibc_multi libbpf (iproute.overrideDerivation (oldAttrs: { nativeBuildInputs = [ bison flex pkg-config libbpf ]; })) ]; } ~/working/nixos-xdp/ok ❯ clang -O2 -target bpf -c wgcf_bpf_helper.c -o wgcf_bpf clang-11: warning: argument unused during compilation: '--gcc-toolchain=/nix/store/9pgq84sf921xh97gjj2wh7a7clrcrh4m-gcc-12.2.0' [-Wunused-command-line-argument] ~/working/nixos-xdp/ok ❯ sudo ip link set dev wlo1 xdp object wgcf_bpf section wg-cf-xdp-ingress
I am not sure if this is an upstream bug. The upstream code looks like it should works with or without libbpf.
FYI, archlinux and debian does build iproute with libbpf.
@primeos
~ ❯ nix-shell -p nix-info --run "nix-info -m" - system: `"x86_64-linux"` - host os: `Linux 6.1.12-zen1, NixOS, 23.05 (Stoat), 23.05.20230218.5f4e07d` - multi-user?: `yes` - sandbox: `yes` - version: `nix-env (Nix) 2.13.2` - channels(kasei): `"nixpkgs"` - nixpkgs: `/nix/store/z6hqic45nv80ymdbf6hx4xlh3s4s193i-source`
Closed by #321962
Describe the bug
iproute can not attach xdp programs without libbpf.
Steps To Reproduce
I writen a tiny xdp program (gist) to connect the cloudflare warp vpn with wireguard kernel module. When I tried to attach this xdp program ,
ip link
reported an error.reproduce (copy wgcf_bpf_helper.c from gist):
Expected behavior
If rebuild iproute with libbpf, it works:
Additional context
I am not sure if this is an upstream bug. The upstream code looks like it should works with or without libbpf.
FYI, archlinux and debian does build iproute with libbpf.
Notify maintainers
@primeos
Metadata