From be2034ea2469d327451803a5d35804e96f1076be Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 7 Dec 2015 14:29:25 +0000 Subject: [PATCH] Start hyperscan support --- CMakeLists.txt | 8 ++ config.h.in | 302 +++++++++++++++++---------------------------- src/CMakeLists.txt | 4 + 3 files changed, 126 insertions(+), 188 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 786399bc2..96118f12d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,7 @@ OPTION(INSTALL_WEBUI "Install web interface [default: ON]" OPTION(WANT_SYSTEMD_UNITS "Install systemd unit files on Linux [default: OFF]" OFF) OPTION(ENABLE_SNOWBALL "Enable snowball stemmer [default: ON]" ON) OPTION(ENABLE_CLANG_PLUGIN "Enable clang static analysing plugin [default: OFF]" OFF) +OPTION(ENABLE_HYPERSCAN "Enable hyperscan for fast regexp processing [default: OFF]" OFF) # Build optimized code for following CPU (default i386) #SET(CPU_TUNE "i686") @@ -621,6 +622,13 @@ ProcessPackage(OPENSSL LIBRARY crypto INCLUDE err.h INCLUDE_SUFFIXES include/ope ProcessPackage(MAGIC LIBRARY magic INCLUDE magic.h INCLUDE_SUFFIXES include/libmagic ROOT ${LIBMAGIC_ROOT_DIR} MODULES magic) +IF(ENABLE_HYPERSCAN MATCHES "ON") + ProcessPackage(HYPERSCAN LIBRARY hs INCLUDE hs.h INCLUDE_SUFFIXES + include/hyperscan include/hs + ROOT ${HYPERSCAN_ROOT_DIR} MODULES hs) + SET(WITH_HYPERSCAN 1) +ENDIF() + #Check for openssl (required for dkim) IF(WITH_OPENSSL) SET(HAVE_OPENSSL 1) diff --git a/config.h.in b/config.h.in index 001506a6a..0f9e063dc 100644 --- a/config.h.in +++ b/config.h.in @@ -1,69 +1,131 @@ #ifndef RSPAMD_CONFIG_H_IN #define RSPAMD_CONFIG_H_IN -#cmakedefine HAVE_SYS_TYPES_H 1 - -#cmakedefine HAVE_SYS_TIME_H 1 - -#cmakedefine HAVE_SYS_UIO_H 1 - +#cmakedefine BUILD_STATIC 1 +#cmakedefine CURL_FOUND 1 +#cmakedefine DEBUG_MODE 1 +#cmakedefine GLIB_COMPAT 1 +#cmakedefine GLIB_HASH_COMPAT 1 +#cmakedefine GLIB_RE_COMPAT 1 +#cmakedefine GLIB_UNISCRIPT_COMPAT 1 +#cmakedefine GMIME24 1 +#cmakedefine HAVE_AIO_H 1 +#cmakedefine HAVE_ARPA_INET_H 1 +#cmakedefine HAVE_ASM_PAUSE 1 +#cmakedefine HAVE_ATOMIC_BUILTINS 1 +#cmakedefine HAVE_CLOCK_GETTIME 1 +#cmakedefine HAVE_CLOCK_PROCESS_CPUTIME_ID 1 +#cmakedefine HAVE_CLOCK_VIRTUAL 1 +#cmakedefine HAVE_COMPATIBLE_QUEUE_H 1 +#cmakedefine HAVE_CPUID_H 1 +#cmakedefine HAVE_CTYPE_H 1 +#cmakedefine HAVE_DIRENT_H 1 +#cmakedefine HAVE_ENDIAN_H 1 +#cmakedefine HAVE_EXP2L 1 +#cmakedefine HAVE_EXPL 1 +#cmakedefine HAVE_EXPLICIT_BZERO 1 +#cmakedefine HAVE_FADVISE 1 +#cmakedefine HAVE_FALLOCATE 1 #cmakedefine HAVE_FCNTL_H 1 - +#cmakedefine HAVE_FDATASYNC 1 +#cmakedefine HAVE_FETCH_H 1 +#cmakedefine HAVE_FLOCK 1 +#cmakedefine HAVE_GETPAGESIZE 1 +#cmakedefine HAVE_GET_CPUID 1 +#cmakedefine HAVE_GLOB_H 1 +#cmakedefine HAVE_GRP_H 1 +#cmakedefine HAVE_INET_PTON 1 +#cmakedefine HAVE_INTTYPES_H 1 +#cmakedefine HAVE_IPV6_V6ONLY 1 +#cmakedefine HAVE_LIBAIO_H 1 +#cmakedefine HAVE_LIBGEN_H 1 +#cmakedefine HAVE_LIBUTIL_H 1 +#cmakedefine HAVE_LOCALE_H 1 +#cmakedefine HAVE_MACHINE_ENDIAN_H 1 #cmakedefine HAVE_MATH_H 1 - +#cmakedefine HAVE_MAXPATHLEN 1 +#cmakedefine HAVE_MEMSET_S 1 +#cmakedefine HAVE_MKSTEMP 1 +#cmakedefine HAVE_MMAP_ANON 1 +#cmakedefine HAVE_MMAP_NOCORE 1 +#cmakedefine HAVE_MMAP_SHARED 1 +#cmakedefine HAVE_NANOSLEEP 1 +#cmakedefine HAVE_NETDB_H 1 +#cmakedefine HAVE_NETINET_IN_H 1 +#cmakedefine HAVE_OASYNC 1 +#cmakedefine HAVE_OPENSSL 1 +#cmakedefine HAVE_O_DIRECT 1 +#cmakedefine HAVE_PATH_MAX 1 +#cmakedefine HAVE_PCRE_JIT 1 +#cmakedefine HAVE_PCRE_JIT_FAST 1 +#cmakedefine HAVE_PIDFILE 1 +#cmakedefine HAVE_PIDFILE_FILENO 1 +#cmakedefine HAVE_POLL_H 1 +#cmakedefine HAVE_POSIX_FALLOCATE 1 +#cmakedefine HAVE_PTHREAD_PROCESS_SHARED 1 +#cmakedefine HAVE_PWD_H 1 +#cmakedefine HAVE_READPASSPHRASE_H 1 +#cmakedefine HAVE_SA_SIGINFO 1 +#cmakedefine HAVE_SCHED_YEILD 1 +#cmakedefine HAVE_SC_NPROCESSORS_ONLN 1 +#cmakedefine HAVE_SEARCH_H 1 +#cmakedefine HAVE_SENDFILE 1 +#cmakedefine HAVE_SETITIMER 1 +#cmakedefine HAVE_SETPROCTITLE 1 +#cmakedefine HAVE_SETSIG 1 +#cmakedefine HAVE_SIGINFO_H 1 +#cmakedefine HAVE_SOCK_SEQPACKET 1 +#cmakedefine HAVE_STDBOOL_H 1 +#cmakedefine HAVE_STDINT_H 1 #cmakedefine HAVE_STDIO_H 1 - #cmakedefine HAVE_STDLIB_H 1 - -#cmakedefine HAVE_STRING_H 1 - #cmakedefine HAVE_STRINGS_H 1 - -#cmakedefine HAVE_TIME_H 1 - -#cmakedefine HAVE_UNISTD_H 1 - +#cmakedefine HAVE_STRING_H 1 +#cmakedefine HAVE_STROPS_H 1 #cmakedefine HAVE_SYSEXITS_H 1 - -#cmakedefine HAVE_STDINT_H 1 - -#cmakedefine HAVE_INTTYPES_H 1 - -#cmakedefine HAVE_STDBOOL_H 1 - -#cmakedefine HAVE_ARPA_INET_H 1 -#cmakedefine HAVE_NETINET_IN_H 1 - -#cmakedefine HAVE_NETDB_H 1 - -#cmakedefine HAVE_POLL_H 1 - #cmakedefine HAVE_SYSLOG_H 1 - -#cmakedefine HAVE_SIGINFO_H 1 - -#cmakedefine HAVE_LIBUTIL_H 1 - -#cmakedefine HAVE_LIBGEN_H 1 - -#cmakedefine HAVE_SEARCH_H 1 - -#cmakedefine HAVE_LOCALE_H 1 - -#cmakedefine HAVE_GRP_H 1 -#cmakedefine HAVE_PWD_H 1 - -#cmakedefine HAVE_GLOB_H 1 - -#cmakedefine HAVE_ENDIAN_H 1 -#cmakedefine HAVE_SYS_ENDIAN_H 1 -#cmakedefine HAVE_MACHINE_ENDIAN_H 1 #cmakedefine HAVE_SYS_CDEFS_H 1 - +#cmakedefine HAVE_SYS_ENDIAN_H 1 +#cmakedefine HAVE_SYS_EVENTFD_H 1 +#cmakedefine HAVE_SYS_FILE_H 1 +#cmakedefine HAVE_SYS_IOCTL_H 1 +#cmakedefine HAVE_SYS_MMAN_H 1 +#cmakedefine HAVE_SYS_PARAM_H 1 +#cmakedefine HAVE_SYS_QUEUE_H 1 +#cmakedefine HAVE_SYS_RESOURCE_H 1 +#cmakedefine HAVE_SYS_SENDFILE_H 1 +#cmakedefine HAVE_SYS_SOCKET_H 1 +#cmakedefine HAVE_SYS_STAT_H 1 +#cmakedefine HAVE_SYS_TIMEB_H 1 +#cmakedefine HAVE_SYS_TIME_H 1 +#cmakedefine HAVE_SYS_TYPES_H 1 +#cmakedefine HAVE_SYS_UIO_H 1 +#cmakedefine HAVE_SYS_UN_H 1 +#cmakedefine HAVE_SYS_UTSNAME_H 1 +#cmakedefine HAVE_SYS_WAIT_H 1 +#cmakedefine HAVE_TANH 1 +#cmakedefine HAVE_TANHL 1 +#cmakedefine HAVE_TERMIOS_H 1 +#cmakedefine HAVE_TIME_H 1 +#cmakedefine HAVE_UNISTD_H 1 +#cmakedefine HAVE_VFORK 1 +#cmakedefine HAVE_WAIT4 1 +#cmakedefine HAVE_WAITPID 1 +#cmakedefine HAVE_WEAK_SYMBOLS 1 #cmakedefine LIBEVENT_EVHTTP 1 - +#cmakedefine PARAM_H_HAS_BITSET 1 +#cmakedefine WITH_DB 1 +#cmakedefine WITH_GPERF_TOOLS 1 #cmakedefine WITH_HIREDIS 1 +#cmakedefine WITH_HYPERSCAN 1 +#cmakedefine WITH_JUDY 1 +#cmakedefine WITH_LUA 1 +#cmakedefine WITH_PROFILER 1 +#cmakedefine WITH_SNOWBALL 1 +#cmakedefine WITH_SQLITE 1 +#cmakedefine WITH_SYSTEM_HIREDIS 1 +/* Detect endiannes */ #ifdef HAVE_ENDIAN_H #include #else @@ -91,142 +153,6 @@ #if !defined(BYTE_ORDER) # error "Undefined or unknown BYTE_ORDER" #endif -#cmakedefine HAVE_SYS_QUEUE_H 1 -#cmakedefine HAVE_SYS_MMAN_H 1 -#cmakedefine HAVE_SYS_SOCKET_H 1 -#cmakedefine HAVE_SYS_UN_H 1 -#cmakedefine HAVE_SYS_STAT_H 1 -#cmakedefine HAVE_SYS_WAIT_H 1 -#cmakedefine HAVE_SYS_PARAM_H 1 -#cmakedefine HAVE_SYS_FILE_H 1 -#cmakedefine HAVE_SYS_RESOURCE_H 1 -#cmakedefine HAVE_SYS_TIMEB_H 1 -#cmakedefine HAVE_SYS_UTSNAME_H 1 - -#cmakedefine HAVE_PIDFILE 1 - -#cmakedefine HAVE_PIDFILE_FILENO 1 - -#cmakedefine HAVE_SETPROCTITLE 1 - -#cmakedefine HAVE_GETPAGESIZE 1 - -#cmakedefine HAVE_NANOSLEEP 1 - -#cmakedefine HAVE_PATH_MAX 1 - -#cmakedefine HAVE_MAXPATHLEN 1 - -#cmakedefine HAVE_MMAP_SHARED 1 - -#cmakedefine HAVE_MMAP_ANON 1 - -#cmakedefine HAVE_MMAP_NOCORE 1 - -#cmakedefine HAVE_O_DIRECT 1 - -#cmakedefine HAVE_FADVISE 1 - -#cmakedefine HAVE_FALLOCATE 1 -#cmakedefine HAVE_POSIX_FALLOCATE 1 - -#cmakedefine HAVE_FDATASYNC 1 -#cmakedefine HAVE_COMPATIBLE_QUEUE_H 1 - -#cmakedefine HAVE_SC_NPROCESSORS_ONLN 1 - -#cmakedefine HAVE_VFORK 1 - -#cmakedefine HAVE_WAIT4 1 - -#cmakedefine HAVE_WAITPID 1 - -#cmakedefine HAVE_FLOCK 1 - -#cmakedefine HAVE_TANHL 1 -#cmakedefine HAVE_TANH 1 - -#cmakedefine HAVE_EXPL 1 -#cmakedefine HAVE_EXP2L 1 - -#cmakedefine HAVE_SA_SIGINFO 1 - -#cmakedefine DEBUG_MODE 1 - -#cmakedefine GMIME24 1 - -#cmakedefine HAVE_CLOCK_VIRTUAL 1 -#cmakedefine HAVE_CLOCK_PROCESS_CPUTIME_ID 1 - -#cmakedefine HAVE_SETITIMER 1 - -#cmakedefine HAVE_INET_PTON 1 - -#define WITHOUT_PERL 1 - -#cmakedefine WITH_LUA 1 - -#cmakedefine WITH_PROFILER 1 - -#cmakedefine WITH_JUDY 1 - -#cmakedefine WITH_DB 1 - -#cmakedefine WITH_SQLITE 1 - -#cmakedefine WITH_GPERF_TOOLS 1 - -#cmakedefine WITH_SYSTEM_HIREDIS 1 - -#cmakedefine HAVE_ASM_PAUSE 1 - -#cmakedefine BUILD_STATIC 1 - -#cmakedefine HAVE_SENDFILE 1 -#cmakedefine HAVE_SYS_SENDFILE_H 1 -#cmakedefine HAVE_SYS_EVENTFD_H 1 -#cmakedefine HAVE_AIO_H 1 -#cmakedefine HAVE_LIBAIO_H 1 - -#cmakedefine HAVE_MKSTEMP 1 - -#cmakedefine HAVE_CLOCK_GETTIME 1 - -#cmakedefine HAVE_OPENSSL 1 - -#cmakedefine GLIB_COMPAT 1 -#cmakedefine GLIB_RE_COMPAT 1 -#cmakedefine GLIB_UNISCRIPT_COMPAT 1 -#cmakedefine GLIB_HASH_COMPAT 1 -#cmakedefine PARAM_H_HAS_BITSET 1 - -#cmakedefine HAVE_FETCH_H 1 -#cmakedefine CURL_FOUND 1 - -#cmakedefine HAVE_READPASSPHRASE_H 1 -#cmakedefine HAVE_TERMIOS_H 1 - -#cmakedefine HAVE_IPV6_V6ONLY 1 - -#cmakedefine HAVE_CTYPE_H 1 -#cmakedefine HAVE_SCHED_YEILD 1 -#cmakedefine HAVE_PTHREAD_PROCESS_SHARED 1 - -#cmakedefine HAVE_MEMSET_S 1 -#cmakedefine HAVE_EXPLICIT_BZERO 1 -#cmakedefine HAVE_WEAK_SYMBOLS 1 -#cmakedefine HAVE_PCRE_JIT 1 -#cmakedefine HAVE_PCRE_JIT_FAST 1 -#cmakedefine HAVE_GET_CPUID 1 -#cmakedefine HAVE_CPUID_H 1 -#cmakedefine HAVE_DIRENT_H 1 -#cmakedefine HAVE_SOCK_SEQPACKET 1 -#cmakedefine HAVE_SYS_IOCTL_H 1 -#cmakedefine HAVE_STROPS_H 1 -#cmakedefine HAVE_SETSIG 1 -#cmakedefine HAVE_OASYNC 1 -#cmakedefine WITH_SNOWBALL 1 -#cmakedefine HAVE_ATOMIC_BUILTINS 1 /* Configure allocator */ #define uthash_malloc(sz) g_slice_alloc(sz) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a348c5faa..a99b6e7ac 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -123,6 +123,10 @@ IF (ENABLE_SNOWBALL MATCHES "ON") ENDIF() TARGET_LINK_LIBRARIES(rspamd rspamd-actrie) +IF (ENABLE_HYPERSCAN MATCHES "ON") + TARGET_LINK_LIBRARIES(rspamd hs) +ENDIF() + TARGET_LINK_LIBRARIES(rspamd ${RSPAMD_REQUIRED_LIBRARIES}) INSTALL(TARGETS rspamd RUNTIME DESTINATION bin) -- 2.39.5