diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2024-10-22 13:12:59 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2024-10-22 13:12:59 +0200 |
commit | 7d58703bdbd72f794a9c0c1b059f374240e79527 (patch) | |
tree | 8188caf20251bb797cac24b02396c551c5dd753a | |
parent | ae36f8df6c418469ca8e39f72791bdb026fbdc38 (diff) |
Removed `ENABLE_MEMORY_STATUS` CMake option as it's now enabled for **all** builds
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r-- | .github/workflows/build.yml | 8 | ||||
-rw-r--r-- | CMakeLists.txt | 13 | ||||
-rw-r--r-- | nDPId-test.c | 2 | ||||
-rw-r--r-- | nDPId.c | 16 |
4 files changed, 7 insertions, 32 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fe6ff8f6c..3586efd9d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -222,20 +222,20 @@ jobs: run: | pkg-config --cflags --libs libndpi cc -Wall -Wextra -std=gnu99 \ - ${{ matrix.poll }} -DENABLE_MEMORY_STATUS=1 -DENABLE_MEMORY_PROFILING=1 \ + ${{ matrix.poll }} -DENABLE_MEMORY_PROFILING=1 \ nDPId.c nio.c utils.c \ $(pkg-config --cflags libndpi) -I. -I./dependencies -I./dependencies/jsmn -I./dependencies/uthash/include \ -o /tmp/a.out \ -lpcap $(pkg-config --libs libndpi) -pthread -lm cc -Wall -Wextra -std=gnu99 \ - ${{ matrix.poll }} -DENABLE_MEMORY_STATUS=1 -DENABLE_MEMORY_PROFILING=1 \ + ${{ matrix.poll }} -DENABLE_MEMORY_PROFILING=1 \ nDPIsrvd.c nio.c utils.c \ -I. -I./dependencies -I./dependencies/jsmn -I./dependencies/uthash/include \ -o /tmp/a.out - name: Build single nDPId/nDPIsrvd executables (invoke CC directly - static nDPI lib) if: endsWith(matrix.compiler, 'gcc-7') == false && startsWith(matrix.ndpi_build, '-DBUILD_NDPI=ON') && startsWith(matrix.coverage, '-DENABLE_COVERAGE=OFF') && startsWith(matrix.sanitizer, '-DENABLE_SANITIZER=ON') && startsWith(matrix.ndpid_gcrypt, '-DNDPI_WITH_GCRYPT=OFF') && startsWith(matrix.ndpid_zlib, '-DENABLE_ZLIB=ON') run: | - cc -Wall -Wextra -std=gnu99 ${{ matrix.poll }} -DENABLE_ZLIB=1 -DENABLE_MEMORY_STATUS=1 -DENABLE_MEMORY_PROFILING=1 \ + cc -Wall -Wextra -std=gnu99 ${{ matrix.poll }} -DENABLE_ZLIB=1 -DENABLE_MEMORY_PROFILING=1 \ -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -fsanitize=enum -fsanitize=leak \ nDPId.c nio.c utils.c \ -I./build/libnDPI/include/ndpi -I. -I./dependencies -I./dependencies/jsmn -I./dependencies/uthash/include \ @@ -294,7 +294,7 @@ jobs: git clone --depth=1 https://github.com/ntop/PF_RING.git cd PF_RING && make all && sudo make install prefix=/usr cd .. - cc -Wall -Wextra -std=gnu99 ${{ matrix.poll }} -DENABLE_PFRING=1 -DENABLE_ZLIB=1 -DENABLE_MEMORY_STATUS=1 -DENABLE_MEMORY_PROFILING=1 \ + cc -Wall -Wextra -std=gnu99 ${{ matrix.poll }} -DENABLE_PFRING=1 -DENABLE_ZLIB=1 -DENABLE_MEMORY_PROFILING=1 \ -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -fsanitize=enum -fsanitize=leak \ nDPId.c npfring.c nio.c utils.c \ -I. -I./dependencies -I./dependencies/jsmn -I./dependencies/uthash/include \ diff --git a/CMakeLists.txt b/CMakeLists.txt index 2862b3d12..a4803e545 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,7 +83,6 @@ endif() option(ENABLE_COVERAGE "Generate a code coverage report using lcov/genhtml." OFF) option(ENABLE_SANITIZER "Enable ASAN/LSAN/UBSAN." OFF) option(ENABLE_SANITIZER_THREAD "Enable TSAN (does not work together with ASAN)." OFF) -option(ENABLE_MEMORY_STATUS "Enable malloc/free wrapper to gather and send heap memory statistics." ON) option(ENABLE_MEMORY_PROFILING "Enable dynamic memory tracking." OFF) option(ENABLE_ZLIB "Enable zlib support for nDPId (experimental)." OFF) option(ENABLE_SYSTEMD "Install systemd components." OFF) @@ -187,13 +186,6 @@ else() unset(NDPI_WITH_MAXMINDDB CACHE) endif() -if (ENABLE_MEMORY_STATUS) - set(MEMORY_STATUS_DEFS "-DENABLE_MEMORY_STATUS=1") -endif() -if (ENABLE_MEMORY_PROFILING AND NOT ENABLE_MEMORY_STATUS) - message(FATAL_ERROR "ENABLE_MEMORY_PROFILING requires ENABLE_MEMORY_STATUS to make it work!") -endif() - if(ENABLE_PFRING) set(NDPID_PFRING_SRCS npfring.c) endif() @@ -430,7 +422,7 @@ if(NOT pkgcfg_lib_PCAP_pcap) endif() target_compile_options(nDPId PRIVATE "-pthread") -target_compile_definitions(nDPId PRIVATE -D_GNU_SOURCE=1 -DPKG_VERSION=\"${PKG_VERSION}\" -DGIT_VERSION=\"${GIT_VERSION}\" ${NDPID_DEFS} ${EPOLL_DEFS} ${ZLIB_DEFS} ${PFRING_DEFS} ${MEMORY_STATUS_DEFS}) +target_compile_definitions(nDPId PRIVATE -D_GNU_SOURCE=1 -DPKG_VERSION=\"${PKG_VERSION}\" -DGIT_VERSION=\"${GIT_VERSION}\" ${NDPID_DEFS} ${EPOLL_DEFS} ${ZLIB_DEFS} ${PFRING_DEFS}) target_include_directories(nDPId PRIVATE "${STATIC_LIBNDPI_INC}" "${DEFAULT_NDPI_INCLUDE}" ${NDPID_DEPS_INC} ${PFRING_KERNEL_INC} ${PFRING_INC}) target_link_libraries(nDPId "${STATIC_LIBNDPI_LIB}" "${STATIC_PFRING_LIB}" "${pkgcfg_lib_PCAP_pcap}" "${pkgcfg_lib_NDPI_ndpi}" "${pkgcfg_lib_PCRE_pcre2-8}" "${pkgcfg_lib_MAXMINDDB_maxminddb}" "${pkgcfg_lib_ZLIB_z}" @@ -442,7 +434,7 @@ target_include_directories(nDPIsrvd PRIVATE ${NDPID_DEPS_INC}) target_compile_options(nDPId-test PRIVATE "-Wno-unused-function" "-pthread") target_compile_definitions(nDPId-test PRIVATE -D_GNU_SOURCE=1 -DNO_MAIN=1 -DPKG_VERSION=\"${PKG_VERSION}\" -DGIT_VERSION=\"${GIT_VERSION}\" - ${NDPID_DEFS} ${EPOLL_DEFS} ${ZLIB_DEFS} ${PFRING_DEFS} ${MEMORY_STATUS_DEFS} ${NDPID_TEST_MPROF_DEFS}) + ${NDPID_DEFS} ${EPOLL_DEFS} ${ZLIB_DEFS} ${PFRING_DEFS} ${NDPID_TEST_MPROF_DEFS}) target_include_directories(nDPId-test PRIVATE "${STATIC_LIBNDPI_INC}" "${DEFAULT_NDPI_INCLUDE}" ${NDPID_DEPS_INC} ${PFRING_KERNEL_INC} ${PFRING_INC}) target_link_libraries(nDPId-test "${STATIC_LIBNDPI_LIB}" "${STATIC_PFRING_LIB}" "${pkgcfg_lib_PCAP_pcap}" "${pkgcfg_lib_NDPI_ndpi}" @@ -580,7 +572,6 @@ endif() message(STATUS "ENABLE_COVERAGE..........: ${ENABLE_COVERAGE}") message(STATUS "ENABLE_SANITIZER.........: ${ENABLE_SANITIZER}") message(STATUS "ENABLE_SANITIZER_THREAD..: ${ENABLE_SANITIZER_THREAD}") -message(STATUS "ENABLE_MEMORY_STATUS.....: ${ENABLE_MEMORY_STATUS}") message(STATUS "ENABLE_MEMORY_PROFILING..: ${ENABLE_MEMORY_PROFILING}") message(STATUS "ENABLE_ZLIB..............: ${ENABLE_ZLIB}") message(STATUS "BUILD_NDPI...............: ${BUILD_NDPI}") diff --git a/nDPId-test.c b/nDPId-test.c index 7ac50b5b8..b804f7995 100644 --- a/nDPId-test.c +++ b/nDPId-test.c @@ -1649,12 +1649,10 @@ int main(int argc, char ** argv) return 1; } -#ifdef ENABLE_MEMORY_STATUS set_ndpi_malloc(ndpi_malloc_wrapper); set_ndpi_free(ndpi_free_wrapper); set_ndpi_flow_malloc(NULL); set_ndpi_flow_free(NULL); -#endif init_logging("nDPId-test"); log_app_info(); @@ -75,10 +75,6 @@ #error "Invalid value for nDPId_PACKETS_PLEN_MAX" #endif -#if defined(ENABLE_MEMORY_PROFILING) && !defined(ENABLE_MEMORY_STATUS) -#error "ENABLE_MEMORY_PROFILING requires ENABLE_MEMORY_STATUS to make it work!" -#endif - /* MIPS* does not support Compare and Swap. Use traditional locking as fallback. */ #if !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) || !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) #define MT_VALUE(name, type) \ @@ -462,7 +458,6 @@ static struct nDPId_reader_thread reader_threads[nDPId_MAX_READER_THREADS] = {}; static MT_VALUE(nDPId_main_thread_shutdown, int) = MT_INIT(0); static MT_VALUE(global_flow_id, uint64_t) = MT_INIT(1); -#ifdef ENABLE_MEMORY_STATUS static MT_VALUE(ndpi_memory_alloc_count, uint64_t) = MT_INIT(0); static MT_VALUE(ndpi_memory_alloc_bytes, uint64_t) = MT_INIT(0); static MT_VALUE(ndpi_memory_free_count, uint64_t) = MT_INIT(0); @@ -473,7 +468,6 @@ static MT_VALUE(zlib_decompressions, uint64_t) = MT_INIT(0); static MT_VALUE(zlib_compression_diff, uint64_t) = MT_INIT(0); static MT_VALUE(zlib_compression_bytes, uint64_t) = MT_INIT(0); #endif -#endif static struct { @@ -747,11 +741,9 @@ static int zlib_deflate(const void * const src, int srcLen, void * dst, int dstL if (err == Z_STREAM_END) { ret = strm.total_out; -#ifdef ENABLE_MEMORY_STATUS MT_GET_AND_ADD(zlib_compressions, 1); MT_GET_AND_ADD(zlib_compression_diff, srcLen - ret); MT_GET_AND_ADD(zlib_compression_bytes, ret); -#endif } else { @@ -791,10 +783,8 @@ static int zlib_inflate(const void * src, int srcLen, void * dst, int dstLen) if (err == Z_STREAM_END) { ret = strm.total_out; -#ifdef ENABLE_MEMORY_STATUS MT_GET_AND_ADD(zlib_decompressions, 1); MT_GET_AND_SUB(zlib_compression_diff, ret - srcLen); -#endif } else { @@ -1118,7 +1108,6 @@ static int get_ip_netmask_from_pcap_dev(char const * const pcap_dev) return retval; } -#ifdef ENABLE_MEMORY_STATUS static void * ndpi_malloc_wrapper(size_t const size) { void * p = malloc(sizeof(uint64_t) + size); @@ -1144,7 +1133,6 @@ static void ndpi_free_wrapper(void * const freeable) free(p); } -#endif #ifdef ENABLE_MEMORY_PROFILING static void log_memory_usage(struct nDPId_reader_thread const * const reader_thread) @@ -2399,7 +2387,7 @@ static void jsonize_daemon(struct nDPId_reader_thread * const reader_thread, enu ndpi_serialize_string_uint64(&workflow->ndpi_serializer, "total-compression-diff", 0); ndpi_serialize_string_uint64(&workflow->ndpi_serializer, "current-compression-diff", 0); #endif -#if defined(ENABLE_MEMORY_STATUS) && !defined(NO_MAIN) +#ifndef NO_MAIN /* * Global memory stats may very from run to run. * Due to this, `nDPId-test' results would be inconsistent and is disabled if NO_MAIN defined. @@ -5721,12 +5709,10 @@ int main(int argc, char ** argv) return 1; } -#ifdef ENABLE_MEMORY_STATUS set_ndpi_malloc(ndpi_malloc_wrapper); set_ndpi_free(ndpi_free_wrapper); set_ndpi_flow_malloc(NULL); set_ndpi_flow_free(NULL); -#endif init_logging("nDPId"); |