feat(bpf): support enabling and disabling of BPF debug logging
Description:
This MR introduces the ability to enable and disable BPF kernel logs within the OAI UPF. Currently, these logs are always printed, which can negatively impact UPF performance under high traffic conditions.
Key Improvements:
- Performance Enhancement: Disabling BPF logs in production or high-traffic environments mitigates performance degradation caused by excessive logging.
- Platform Compatibility: Resolves an issue where the UPF fails to load on arm64 switches due to a "unknown func bpf_trace_printk" verifier error. Disabling BPF logging eliminates the need for platform-specific support for this function.
Implementation:
- A custom compiler definition,
-DBPF_DEBUG
, is used to control BPF log generation. - BPF logging is disabled by default.
- To enable BPF logs, build the Docker image with the
--build-arg BPF_DEBUG=true
flag, as shown in the example below:
docker build --target oai-upf --tag local/oai-upf:debug \
--file docker/Dockerfile.upf.ubuntu \
--build-arg BASE_IMAGE=ubuntu:jammy \
--build-arg BPF_DEBUG=true \
.
Testing:
docker compose -f docker-compose-basic-nrf-ebpf.yaml up -d
# Start UERANSIM
docker compose -f docker-compose-ueransim.yaml up -d
# Send traffic
docker exec -it ue \
ping -I uesimtun0 8.8.8.8 -c 4
# Print ebpf logs. When built with --build-arg BPF_DEBUG=true the logs will show.
cat /sys/kernel/debug/tracing/trace_pipe
-
Log Verification: If the Docker image was built with
--build-arg BPF_DEBUG=true
, BPF logs will be visible in/sys/kernel/debug/tracing/trace_pipe
.
Note: The attached zip file contains the relevant Docker manifests.
Edited by Stefan Spettel