BPF Code Generation¶
The build process generates BPF C code and Kotlin MapReader classes from the DSL definitions.
Running Code Generation¶
This produces:
build/generated/bpf/*.bpf.c— kernel-side C programsbuild/generated/kotlin/*MapReader.kt— type-safe map deserialization classes
Build Pipeline¶
The 5-stage Dockerfile handles the full pipeline:
- Codegen — Gradle runs kotlin-ebpf-dsl to generate BPF C code and Kotlin MapReader classes
- BPF compile — clang compiles generated
.bpf.cinto both CO-RE (5.2+) and legacy (4.18+).bpf.oobjects - JNI build — CMake compiles the JNI bridge (
libkpod_bpf.so) against libbpf - App build — Gradle builds the Spring Boot executable JAR
- Runtime — Eclipse Temurin JRE 21, minimal image with compiled artifacts
Generated Artifacts in Image¶
/app/
├── bpf/
│ ├── core/ # CO-RE objects (kernel 5.2+)
│ └── legacy/ # Legacy fallback (kernel 4.18+)
├── lib/
│ └── libkpod_bpf.so # JNI bridge
└── app.jar # Spring Boot application
MapReader Usage¶
Collectors use generated MapReader layout classes instead of manual ByteBuffer parsing: