Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(driver): allow kmod and bpf drivers different components #1709

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ endif()
if(NOT DEFINED DRIVER_COMPONENT_NAME)
set(DRIVER_COMPONENT_NAME "scap-driver")
endif()
if(NOT DEFINED DRIVER_KMOD_COMPONENT_NAME)
set(DRIVER_KMOD_COMPONENT_NAME ${DRIVER_COMPONENT_NAME})
endif()

if(NOT DEFINED DRIVER_PACKAGE_NAME)
set(DRIVER_PACKAGE_NAME "scap")
Expand Down Expand Up @@ -166,7 +169,7 @@ if(ENABLE_DKMS)
${CMAKE_CURRENT_BINARY_DIR}/src/driver_config.h
${DRIVER_SOURCES}
DESTINATION "src/${DRIVER_PACKAGE_NAME}-${DRIVER_VERSION}"
COMPONENT ${DRIVER_COMPONENT_NAME})
COMPONENT ${DRIVER_KMOD_COMPONENT_NAME})
endif()

add_subdirectory(bpf)
34 changes: 28 additions & 6 deletions driver/bpf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ if(BUILD_BPF)
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)
COMMAND make
COMMAND "${CMAKE_COMMAND}" -E copy_if_different probe.o "${CMAKE_CURRENT_BINARY_DIR}"
WORKING_DIRECTORY src
VERBATIM)
endif()

install(FILES
set(BPF_SOURCES
bpf_helpers.h
builtins.h
filler_helpers.h
Expand All @@ -40,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_COMPONENT_NAME})
COMPONENT ${DRIVER_BPF_COMPONENT_NAME}
)
2 changes: 1 addition & 1 deletion driver/bpf/filler_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ or GPL2.txt for full copies of the license.
#include <linux/fdtable.h>
#include <linux/net.h>

#include "../ppm_flag_helpers.h"
#include "ppm_flag_helpers.h"
#include "builtins.h"
#include "missing_definitions.h"

Expand Down
6 changes: 3 additions & 3 deletions driver/bpf/fillers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <linux/tty.h>
Expand Down
2 changes: 1 addition & 1 deletion driver/bpf/plumbing_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); \
Expand Down
4 changes: 2 additions & 2 deletions driver/bpf/probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ or GPL2.txt for full copies of the license.
#endif
#include <linux/sched.h>

#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"
Expand Down
Loading