diff --git a/driver/bpf/CMakeLists.txt b/driver/bpf/CMakeLists.txt index b8fb869824..db29f10b10 100644 --- a/driver/bpf/CMakeLists.txt +++ b/driver/bpf/CMakeLists.txt @@ -10,36 +10,24 @@ configure_file(../driver_config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/../driver_confi option(BUILD_BPF "Build the BPF driver on Linux" OFF) -if(NOT BUILD_BPF) - return() -endif() +if(BUILD_BPF) + # Check minimum kernel version + set(bpf_min_kver_map_x86_64 4.14) + set(bpf_min_kver_map_aarch64 4.17) + set(bpf_min_kver_map_s390x 5.5) + set(bpf_min_kver_map_ppc64le 4.18) + if (LINUX_KERNEL_VERSION VERSION_LESS ${bpf_min_kver_map_${TARGET_ARCH}}) + message(WARNING "[BPF] To run this driver you need a Linux kernel version >= ${bpf_min_kver_map_${TARGET_ARCH}} but actual kernel version is: ${UNAME_RESULT}") + endif() -# Check minimum kernel version -set(bpf_min_kver_map_x86_64 4.14) -set(bpf_min_kver_map_aarch64 4.17) -set(bpf_min_kver_map_s390x 5.5) -set(bpf_min_kver_map_ppc64le 4.18) -if (LINUX_KERNEL_VERSION VERSION_LESS ${bpf_min_kver_map_${TARGET_ARCH}}) - message(WARNING "[BPF] To run this driver you need a Linux kernel version >= ${bpf_min_kver_map_${TARGET_ARCH}} but actual kernel version is: ${UNAME_RESULT}") + add_custom_target(bpf ALL + COMMAND make + COMMAND "${CMAKE_COMMAND}" -E copy_if_different probe.o "${CMAKE_CURRENT_BINARY_DIR}" + WORKING_DIRECTORY src + VERBATIM) endif() -add_custom_target(bpf ALL - COMMAND make - COMMAND "${CMAKE_COMMAND}" -E copy_if_different probe.o "${CMAKE_CURRENT_BINARY_DIR}" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - VERBATIM) - -if(NOT DEFINED DRIVER_BPF_COMPONENT_NAME) - set(DRIVER_BPF_COMPONENT_NAME ${DRIVER_COMPONENT_NAME}) -endif() - -install(DIRECTORY - ${CMAKE_CURRENT_BINARY_DIR}/../src/ - DESTINATION "src/${DRIVER_PACKAGE_NAME}-${DRIVER_VERSION}" - COMPONENT ${DRIVER_BPF_COMPONENT_NAME} - FILES_MATCHING PATTERN "*.h") - -install(FILES +set(BPF_SOURCES bpf_helpers.h builtins.h filler_helpers.h @@ -52,5 +40,27 @@ install(FILES ring_helpers.h missing_definitions.h types.h +) + +# Append driver headers too since they are used by bpf headers +file(GLOB DRIVER_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../*.h) +list(APPEND BPF_SOURCES ${DRIVER_HEADERS}) + +set(INSTALL_SET "") +# Copy all needed sources under src folder in current binary dir +# and add them to the set of installed files +foreach(SOURCE IN LISTS BPF_SOURCES) + get_filename_component(FILENAME ${SOURCE} NAME) + configure_file(${SOURCE} src/${FILENAME} COPYONLY) + list(APPEND INSTALL_SET ${CMAKE_CURRENT_BINARY_DIR}/src/${FILENAME}) +endforeach() + +if(NOT DEFINED DRIVER_BPF_COMPONENT_NAME) + set(DRIVER_BPF_COMPONENT_NAME ${DRIVER_COMPONENT_NAME}) +endif() + +install(FILES + ${INSTALL_SET} DESTINATION "src/${DRIVER_PACKAGE_NAME}-${DRIVER_VERSION}/bpf" - COMPONENT ${DRIVER_BPF_COMPONENT_NAME}) + COMPONENT ${DRIVER_BPF_COMPONENT_NAME} +) diff --git a/driver/bpf/filler_helpers.h b/driver/bpf/filler_helpers.h index 838b6d6e52..a2b7115bc8 100644 --- a/driver/bpf/filler_helpers.h +++ b/driver/bpf/filler_helpers.h @@ -19,7 +19,7 @@ or GPL2.txt for full copies of the license. #include #include -#include "../ppm_flag_helpers.h" +#include "ppm_flag_helpers.h" #include "builtins.h" #include "missing_definitions.h" diff --git a/driver/bpf/fillers.h b/driver/bpf/fillers.h index c7d0ec1406..023f2836bd 100644 --- a/driver/bpf/fillers.h +++ b/driver/bpf/fillers.h @@ -10,9 +10,9 @@ or GPL2.txt for full copies of the license. #ifndef __FILLERS_H #define __FILLERS_H -#include "../systype_compat.h" -#include "../ppm_flag_helpers.h" -#include "../ppm_version.h" +#include "systype_compat.h" +#include "ppm_flag_helpers.h" +#include "ppm_version.h" #include "bpf_helpers.h" #include diff --git a/driver/bpf/plumbing_helpers.h b/driver/bpf/plumbing_helpers.h index bbbb9306ab..bddbad65b6 100644 --- a/driver/bpf/plumbing_helpers.h +++ b/driver/bpf/plumbing_helpers.h @@ -16,7 +16,7 @@ or GPL2.txt for full copies of the license. #include "types.h" #include "builtins.h" -#include "../socketcall_to_syscall.h" +#include "socketcall_to_syscall.h" #define _READ(P) ({ typeof(P) _val; \ bpf_probe_read_kernel(&_val, sizeof(_val), &P); \ diff --git a/driver/bpf/probe.c b/driver/bpf/probe.c index ac5596859e..bb1feba3ac 100644 --- a/driver/bpf/probe.c +++ b/driver/bpf/probe.c @@ -16,8 +16,8 @@ or GPL2.txt for full copies of the license. #endif #include -#include "../driver_config.h" -#include "../ppm_events_public.h" +#include "driver_config.h" +#include "ppm_events_public.h" #include "bpf_helpers.h" #include "types.h" #include "maps.h"