Commit 1291aca9 authored by Sagar Arora's avatar Sagar Arora

Merge branch 'chore_enable_disabling_of_bpf_logs' into 'develop'

feat(bpf): support enabling and disabling of BPF debug logging

See merge request oai/cn5g/oai-cn5g-upf!63
parents 2edad4d5 ec607f8b
...@@ -143,6 +143,11 @@ function main() ...@@ -143,6 +143,11 @@ function main()
verbose=1 verbose=1
shift; shift;
;; ;;
--bpf-debug)
echo "BPF debug logs enabled"
cmake_args="$cmake_args -DBPF_DEBUG=ON"
shift;
;;
-V | --Verbose) -V | --Verbose)
echo "CMake build process verbose" echo "CMake build process verbose"
verbose=1 verbose=1
......
...@@ -36,9 +36,11 @@ ENV DEBIAN_FRONTEND=noninteractive ...@@ -36,9 +36,11 @@ ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Paris ENV TZ=Europe/Paris
ENV IS_DOCKERFILE=1 ENV IS_DOCKERFILE=1
ARG ENABLE_LTTNG=false ARG ENABLE_LTTNG=false
ARG BPF_DEBUG=false
RUN apt-get update && \ RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \ DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \
DEBIAN_FRONTEND=noninteractive apt-get install --yes \ DEBIAN_FRONTEND=noninteractive apt-get install --yes \
cmake \
psmisc \ psmisc \
git \ git \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
...@@ -66,6 +68,7 @@ FROM oai-upf-base AS oai-upf-builder ...@@ -66,6 +68,7 @@ FROM oai-upf-base AS oai-upf-builder
COPY . /openair-upf COPY . /openair-upf
# Building UPF # Building UPF
WORKDIR /openair-upf/build/scripts WORKDIR /openair-upf/build/scripts
ARG BUILD_ARGS=""
RUN if [ "$ENABLE_LTTNG" = "true" ]; then apt-get update && \ RUN if [ "$ENABLE_LTTNG" = "true" ]; then apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install --yes \ DEBIAN_FRONTEND=noninteractive apt-get install --yes \
libstdc++-12-dev \ libstdc++-12-dev \
...@@ -73,11 +76,12 @@ RUN if [ "$ENABLE_LTTNG" = "true" ]; then apt-get update && \ ...@@ -73,11 +76,12 @@ RUN if [ "$ENABLE_LTTNG" = "true" ]; then apt-get update && \
liblttng-ust-dev \ liblttng-ust-dev \
lttng-tools && \ lttng-tools && \
ldconfig && \ ldconfig && \
./build_upf --clean --Verbose --build-type Release --jobs --lttng; \ BUILD_ARGS="--lttng"; \
else \ else \
ldconfig && \ ldconfig; \
./build_upf --clean --Verbose --build-type Release --jobs --jobs; \
fi && \ fi && \
if [ "$BPF_DEBUG" = "true" ]; then BUILD_ARGS="$BUILD_ARGS --bpf-debug"; fi && \
./build_upf --clean --Verbose --build-type Release --jobs ${BUILD_ARGS}; \
ldd /openair-upf/build/upf/build/upf && \ ldd /openair-upf/build/upf/build/upf && \
mv /openair-upf/build/upf/build/upf /openair-upf/build/upf/build/oai_upf && \ mv /openair-upf/build/upf/build/upf /openair-upf/build/upf/build/oai_upf && \
echo "end of UPF build" echo "end of UPF build"
......
...@@ -11,6 +11,11 @@ include_directories(${SRC_TOP_DIR}/${MOUNTED_COMMON}/utils) ...@@ -11,6 +11,11 @@ include_directories(${SRC_TOP_DIR}/${MOUNTED_COMMON}/utils)
add_definitions(-DKERNEL_SPACE) add_definitions(-DKERNEL_SPACE)
if(DEFINED BPF_DEBUG)
if(BPF_DEBUG)
add_definitions(-DBPF_DEBUG)
endif()
endif()
add_custom_target(upf_xdp_all DEPENDS pfcp_session_lookup_xdp) add_custom_target(upf_xdp_all DEPENDS pfcp_session_lookup_xdp)
# add_custom_target(upf_tc_all DEPENDS qer_tc) # add_custom_target(upf_tc_all DEPENDS qer_tc)
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#include <bpf_helpers.h> #include <bpf_helpers.h>
#define DEBUG 1 // #define DEBUG 0
#ifdef DEBUG #ifdef BPF_DEBUG
/* Only use this for debug output. Notice output from bpf_trace_printk() /* Only use this for debug output. Notice output from bpf_trace_printk()
* end-up in /sys/kernel/debug/tracing/trace_pipe * end-up in /sys/kernel/debug/tracing/trace_pipe
*/ */
...@@ -17,15 +17,7 @@ ...@@ -17,15 +17,7 @@
bpf_trace_printk(____fmt, sizeof(____fmt), ##__VA_ARGS__); \ bpf_trace_printk(____fmt, sizeof(____fmt), ##__VA_ARGS__); \
}) })
#else #else
#define bpf_debug(fmt, ...) \ #define bpf_debug(fmt, ...)
{} \
while (0)
#endif #endif
#define bpf_debug2(fmt, ...) \
({ \
char ____fmt[] = fmt; \
bpf_trace_printk(____fmt, sizeof(____fmt), ##__VA_ARGS__); \
})
#else
#endif // __LOGGER_H__ #endif // __LOGGER_H__
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment