feat(eBPF): embed BTF information in eBPF kernel (#8842)

It turns out that the Rust compiler doesn't always say that it is adding
debug information to a binary even when it does! The build output only
displays `[optimized]` when in fact it does actually emit debug
information. Adding an additional linker flag configures `bpf-linker` to
include the necessary BTF information in our kernel.

This makes debugging verifier errors much easier as the program output
contains source code annotiations. It also should make it easier to
debug issues using `xdpdump` which relies on BTF information.

Resolves: #8503
This commit is contained in:
Thomas Eizinger
2025-04-19 22:38:59 +10:00
committed by GitHub
parent 024b0b36ed
commit a41395a165
2 changed files with 10 additions and 0 deletions

View File

@@ -234,3 +234,6 @@ split-debuginfo = "packed"
[profile.release.package.firezone-gui-client]
debug = "full"
split-debuginfo = "packed"
[profile.release.package.ebpf-turn-router]
debug = 2

View File

@@ -14,4 +14,11 @@ use which::which;
fn main() {
let bpf_linker = which("bpf-linker").expect("bpf-linker not found in $PATH");
println!("cargo:rerun-if-changed={}", bpf_linker.to_str().unwrap());
if std::env::var("CARGO_BUILD_TARGET")
.ok()
.is_some_and(|t| t == "bpfel-unknown-none" || t == "bpfeb-unknown-unknown")
{
println!("cargo:rustc-link-arg=--btf");
}
}