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

cleanup(scap,sinsp): remove userspace/common #1454

Merged
merged 4 commits into from
Nov 2, 2023
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
13 changes: 2 additions & 11 deletions cmake/modules/libscap.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ else()
message(STATUS "No strlcat found, will use local definition")
endif()

configure_file(${LIBSCAP_DIR}/userspace/common/common_config.h.in ${PROJECT_BINARY_DIR}/common/common_config.h)
include_directories(${PROJECT_BINARY_DIR}/common)

add_definitions(-DPLATFORM_NAME="${CMAKE_SYSTEM_NAME}")

if(CMAKE_SYSTEM_NAME MATCHES "Linux")
Expand All @@ -58,8 +55,7 @@ else()
endif()

get_filename_component(LIBSCAP_INCLUDE_DIR ${LIBSCAP_DIR}/userspace/libscap ABSOLUTE)
get_filename_component(LIBSCAP_COMMON_INCLUDE_DIR ${LIBSCAP_DIR}/userspace/common ABSOLUTE)
set(LIBSCAP_INCLUDE_DIRS ${LIBSCAP_INCLUDE_DIR} ${LIBSCAP_COMMON_INCLUDE_DIR} ${PROJECT_BINARY_DIR}/libscap ${DRIVER_CONFIG_DIR})
set(LIBSCAP_INCLUDE_DIRS ${LIBSCAP_INCLUDE_DIR} ${PROJECT_BINARY_DIR}/libscap ${DRIVER_CONFIG_DIR})

function(set_scap_target_properties target)
set_target_properties(${target} PROPERTIES
Expand Down Expand Up @@ -138,15 +134,10 @@ install(DIRECTORY "${LIBSCAP_INCLUDE_DIR}" DESTINATION "${CMAKE_INSTALL_INCLUDED
install(DIRECTORY "${DRIVER_CONFIG_DIR}/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBS_PACKAGE_NAME}/driver"
COMPONENT "scap"
FILES_MATCHING PATTERN "*.h")
install(DIRECTORY "${LIBSCAP_DIR}/userspace/common" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBS_PACKAGE_NAME}/userspace"
COMPONENT "scap"
FILES_MATCHING PATTERN "*.h")
install(DIRECTORY "${PROJECT_BINARY_DIR}/common" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBS_PACKAGE_NAME}/userspace"
COMPONENT "scap"
FILES_MATCHING PATTERN "*.h")
install(DIRECTORY "${LIBSCAP_DIR}/userspace/plugin" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBS_PACKAGE_NAME}/userspace"
COMPONENT "scap"
FILES_MATCHING PATTERN "*.h")
install(FILES ${PROJECT_BINARY_DIR}/libscap/scap_config.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${LIBS_PACKAGE_NAME}/userspace/libscap)
install(FILES ${PROJECT_BINARY_DIR}/libscap/scap_strl_config.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${LIBS_PACKAGE_NAME}/userspace/libscap)
install(FILES ${PROJECT_BINARY_DIR}/libscap/libscap.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()
5 changes: 1 addition & 4 deletions cmake/modules/libsinsp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ include(valijson)
include(re2)
include(tinydir)

set(LIBSINSP_INCLUDE_DIRS ${LIBSINSP_DIR}/userspace/libsinsp ${LIBSINSP_DIR}/userspace/common ${LIBSCAP_INCLUDE_DIRS} ${DRIVER_CONFIG_DIR})
set(LIBSINSP_INCLUDE_DIRS ${LIBSINSP_DIR}/userspace/libsinsp ${LIBSCAP_INCLUDE_DIRS} ${DRIVER_CONFIG_DIR})
if(WITH_CHISEL)
list(APPEND LIBSINSP_INCLUDE_DIRS ${LIBSINSP_DIR}/userspace/chisel)
endif()
Expand Down Expand Up @@ -102,9 +102,6 @@ install(DIRECTORY "${LIBSINSP_DIR}/userspace/libsinsp" DESTINATION "${CMAKE_INST
PATTERN "*doxygen*" EXCLUDE
PATTERN "*scripts*" EXCLUDE
PATTERN "*test*" EXCLUDE)
install(DIRECTORY "${LIBSINSP_DIR}/common" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBS_PACKAGE_NAME}"
COMPONENT "sinsp"
FILES_MATCHING PATTERN "*.h")
install(DIRECTORY "${LIBSINSP_DIR}/userspace/async" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBS_PACKAGE_NAME}/userspace"
COMPONENT "sinsp"
FILES_MATCHING PATTERN "*.h")
Expand Down
2 changes: 1 addition & 1 deletion driver/ppm_events_public.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.
#elif defined(__USE_VMLINUX__ )
/* In the modern probe, if we have the vmlinux.h we need nothing here. */
#else
#include "../userspace/common/types.h"
#include <stdint.h>
#endif

#include "./feature_gates.h"
Expand Down
43 changes: 22 additions & 21 deletions driver/ppm_ringbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ or GPL2.txt for full copies of the license.
#include <linux/types.h>
#else
#include <stdbool.h>
#include <stdint.h>
#endif

/* This method validates the per-CPU buffer bytes dimension:
Expand All @@ -34,28 +35,28 @@ static inline bool validate_buffer_bytes_dim(unsigned long buf_bytes_dim, unsign
* This gets mapped to user level, so we want to keep it as clean as possible
*/
struct ppm_ring_buffer_info {
volatile __u32 head;
volatile __u32 tail;
volatile __u64 n_evts; /* Total number of events that were received by the driver. */
volatile __u64 n_drops_buffer; /* Total number of kernel side drops due to full buffer, includes all categories below, likely higher than sum of syscall categories. */
volatile uint32_t head;
volatile uint32_t tail;
volatile uint64_t n_evts; /* Total number of events that were received by the driver. */
volatile uint64_t n_drops_buffer; /* Total number of kernel side drops due to full buffer, includes all categories below, likely higher than sum of syscall categories. */
/* Kernel side drops due to full buffer for categories of system calls. Not all system calls of interest are mapped into one of the categories. */
volatile __u64 n_drops_buffer_clone_fork_enter;
volatile __u64 n_drops_buffer_clone_fork_exit;
volatile __u64 n_drops_buffer_execve_enter;
volatile __u64 n_drops_buffer_execve_exit;
volatile __u64 n_drops_buffer_connect_enter;
volatile __u64 n_drops_buffer_connect_exit;
volatile __u64 n_drops_buffer_open_enter;
volatile __u64 n_drops_buffer_open_exit;
volatile __u64 n_drops_buffer_dir_file_enter;
volatile __u64 n_drops_buffer_dir_file_exit;
volatile __u64 n_drops_buffer_other_interest_enter; /* Category of other system calls of interest, not all other system calls that did not match a category from above. */
volatile __u64 n_drops_buffer_other_interest_exit;
volatile __u64 n_drops_buffer_close_exit;
volatile __u64 n_drops_buffer_proc_exit;
volatile __u64 n_drops_pf; /* Number of dropped events (page faults). */
volatile __u64 n_preemptions; /* Number of preemptions. */
volatile __u64 n_context_switches; /* Number of received context switch events. */
volatile uint64_t n_drops_buffer_clone_fork_enter;
volatile uint64_t n_drops_buffer_clone_fork_exit;
volatile uint64_t n_drops_buffer_execve_enter;
volatile uint64_t n_drops_buffer_execve_exit;
volatile uint64_t n_drops_buffer_connect_enter;
volatile uint64_t n_drops_buffer_connect_exit;
volatile uint64_t n_drops_buffer_open_enter;
volatile uint64_t n_drops_buffer_open_exit;
volatile uint64_t n_drops_buffer_dir_file_enter;
volatile uint64_t n_drops_buffer_dir_file_exit;
volatile uint64_t n_drops_buffer_other_interest_enter; /* Category of other system calls of interest, not all other system calls that did not match a category from above. */
volatile uint64_t n_drops_buffer_other_interest_exit;
volatile uint64_t n_drops_buffer_close_exit;
volatile uint64_t n_drops_buffer_proc_exit;
volatile uint64_t n_drops_pf; /* Number of dropped events (page faults). */
volatile uint64_t n_preemptions; /* Number of preemptions. */
volatile uint64_t n_context_switches; /* Number of received context switch events. */
};

#endif /* PPM_RINGBUFFER_H_ */
1 change: 0 additions & 1 deletion test/drivers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ set(DRIVERS_TEST_SOURCES

set(DRIVERS_TEST_INCLUDE
PRIVATE
../../userspace/common
"${GTEST_INCLUDE}"
"${LIBSCAP_DIR}/driver/"
"${LIBSCAP_INCLUDE_DIRS}"
Expand Down
40 changes: 0 additions & 40 deletions userspace/common/types.h

This file was deleted.

2 changes: 1 addition & 1 deletion userspace/libpman/include/libpman.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ limitations under the License.
#include <stdbool.h>
#include <stdint.h>

#include "falcosecurity/log.h"
#include "scap_log.h"

#ifdef __cplusplus
extern "C"
Expand Down
2 changes: 1 addition & 1 deletion userspace/libpman/src/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ limitations under the License.

#pragma once

#include "falcosecurity/log.h"
#include "scap_log.h"

#include <bpf/libbpf.h>
#include <bpf/bpf.h>
Expand Down
3 changes: 2 additions & 1 deletion userspace/libscap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../common")
include_directories("${PROJECT_BINARY_DIR}/libscap")

include(engine_config)
Expand Down Expand Up @@ -62,6 +61,8 @@ endif()

include_directories(${CMAKE_CURRENT_SOURCE_DIR})

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scap_strl_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/scap_strl_config.h)

add_library(scap
scap.c
scap_api_version.c
Expand Down
2 changes: 1 addition & 1 deletion userspace/libscap/debug_log_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ limitations under the License.
#ifndef __DEBUG_LOG_HELPERS_H
#define __DEBUG_LOG_HELPERS_H

#include "falcosecurity/log.h"
#include "scap_log.h"

#include <stdio.h>

Expand Down
1 change: 0 additions & 1 deletion userspace/libscap/examples/01-open/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_directories("../../../common")
include_directories("../../")

add_executable(scap-open
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_directories("../../../common")
include_directories("../..")

add_executable(scap-validatebuffer
Expand Down
2 changes: 1 addition & 1 deletion userspace/libscap/libscap.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Description: lib for System CAPture
Version: @FALCOSECURITY_LIBS_VERSION@

Libs: -L${libdir}/@LIBS_PACKAGE_NAME@ @LIBSCAP_LINK_LIBDIRS_FLAGS@ @LIBSCAP_LINK_LIBRARIES_FLAGS@
Cflags: -I${includedir}/@LIBS_PACKAGE_NAME@/userspace/libscap -I${includedir}/@LIBS_PACKAGE_NAME@/userspace/common
Cflags: -I${includedir}/@LIBS_PACKAGE_NAME@/userspace/libscap
4 changes: 2 additions & 2 deletions userspace/libscap/linux/scap_linux_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ extern "C" {
#include "scap_cgroup.h"
#include "scap_platform_impl.h"
#include "engine_handle.h"
#include "falcosecurity/log.h"
#include "scap_log.h"

struct scap_mountinfo;
struct scap_mountinfo;

struct scap_linux_vtable {
/**
Expand Down
1 change: 0 additions & 1 deletion userspace/libscap/ppm_sc_names.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ limitations under the License.

*/

#include "../common/types.h"
#include "../../driver/ppm_events_public.h"
#include "scap.h"
#include "scap-int.h"
Expand Down
2 changes: 1 addition & 1 deletion userspace/libscap/scap-int.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ limitations under the License.

#include "settings.h"
#include "scap_assert.h"
#include "falcosecurity/log.h"
#include "scap_log.h"

#ifdef __linux__
#include "linux/scap_cgroup.h"
Expand Down
1 change: 0 additions & 1 deletion userspace/libscap/scap.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ struct scap_vtable;
#include <time.h>
#include <stdarg.h>
#include "uthash_ext.h"
#include "../common/types.h"
#include "../../driver/ppm_api_version.h"
#include "../../driver/ppm_events_public.h"
#include "../../driver/capture_macro.h"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion userspace/libscap/scap_open.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ limitations under the License.
#include "scap_limits.h"
#include "scap_procs.h"
#include "../../driver/ppm_events_public.h"
#include "falcosecurity/log.h"
#include "scap_log.h"

#ifdef __cplusplus
extern "C"
Expand Down
2 changes: 1 addition & 1 deletion userspace/common/strl.h → userspace/libscap/strl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.

#include <sys/types.h>
#include <string.h>
#include "common_config.h"
#include "scap_strl_config.h"

#pragma once

Expand Down
1 change: 0 additions & 1 deletion userspace/libsinsp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# limitations under the License.
#
include_directories(./)
include_directories(../common)
include_directories(${LIBSCAP_INCLUDE_DIRS})
include_directories(../async)
include_directories(./include)
Expand Down
2 changes: 0 additions & 2 deletions userspace/libsinsp/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ target_link_libraries(sinsp-example
sinsp
)

target_include_directories(sinsp-example PRIVATE "${CMAKE_SOURCE_DIR}/userspace/common")

if (EMSCRIPTEN)
target_compile_options(sinsp-example PRIVATE "-sDISABLE_EXCEPTION_CATCHING=0")
target_link_options(sinsp-example PRIVATE "-sDISABLE_EXCEPTION_CATCHING=0")
Expand Down
2 changes: 1 addition & 1 deletion userspace/libsinsp/libsinsp.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Version: @FALCOSECURITY_LIBS_VERSION@

Requires: libscap
Libs: -L${libdir}/@LIBS_PACKAGE_NAME@ -lsinsp @SINSP_PKG_CONFIG_LIBDIRS@ @SINSP_PKG_CONFIG_LIBS@
Cflags: -I${includedir}/@LIBS_PACKAGE_NAME@/userspace/libsinsp -I${includedir}/@LIBS_PACKAGE_NAME@/userspace/common @SINSP_PKG_CONFIG_INCLUDES@
Cflags: -I${includedir}/@LIBS_PACKAGE_NAME@/userspace/libsinsp @SINSP_PKG_CONFIG_INCLUDES@
2 changes: 1 addition & 1 deletion userspace/libsinsp/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ limitations under the License.
#pragma once

#include "sinsp_public.h"
#include "falcosecurity/log.h"
#include "scap_log.h"

#include <atomic>
#include <string>
Expand Down
1 change: 0 additions & 1 deletion userspace/libsinsp/sinsp_debug/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_directories("../../../common")
include_directories("../../")

add_executable(sinsp-debug
Expand Down
5 changes: 4 additions & 1 deletion userspace/libsinsp/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ limitations under the License.
#include <tuples.h>
#include <scap.h>
#include "json/json.h"
#include "../common/types.h"
#include "sinsp_public.h"

#ifdef _MSC_VER
#define strcasecmp _stricmp
#endif

class sinsp_evttables;
typedef union _sinsp_sockinfo sinsp_sockinfo;
class filter_check_info;
Expand Down
Loading