From: Jason Ish Date: Sat, 28 May 2016 00:57:06 +0000 (-0600) Subject: logging: add profiling back for non-tmm loggers X-Git-Tag: suricata-3.2beta1~362 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa27a7646255ad684264b6d21e035344ff069d89;p=thirdparty%2Fsuricata.git logging: add profiling back for non-tmm loggers The loggers moved away from a TMM required a new profiling support. --- diff --git a/src/alert-debuglog.c b/src/alert-debuglog.c index 1c0b4640dc..931fa70cba 100644 --- a/src/alert-debuglog.c +++ b/src/alert-debuglog.c @@ -512,7 +512,7 @@ static int AlertDebugLogLogger(ThreadVars *tv, void *thread_data, const Packet * void TmModuleAlertDebugLogRegister (void) { - OutputRegisterPacketModule(MODULE_NAME, "alert-debug", + OutputRegisterPacketModule(LOGGER_ALERT_DEBUG, MODULE_NAME, "alert-debug", AlertDebugLogInitCtx, AlertDebugLogLogger, AlertDebugLogCondition, AlertDebugLogThreadInit, AlertDebugLogThreadDeinit, AlertDebugLogExitPrintStats); diff --git a/src/alert-fastlog.c b/src/alert-fastlog.c index 59ff045e02..42d601997c 100644 --- a/src/alert-fastlog.c +++ b/src/alert-fastlog.c @@ -78,9 +78,10 @@ int AlertFastLogger(ThreadVars *tv, void *data, const Packet *p); void TmModuleAlertFastLogRegister (void) { - OutputRegisterPacketModule(MODULE_NAME, "fast", AlertFastLogInitCtx, - AlertFastLogger, AlertFastLogCondition, AlertFastLogThreadInit, - AlertFastLogThreadDeinit, AlertFastLogExitPrintStats); + OutputRegisterPacketModule(LOGGER_ALERT_FAST, MODULE_NAME, "fast", + AlertFastLogInitCtx, AlertFastLogger, AlertFastLogCondition, + AlertFastLogThreadInit, AlertFastLogThreadDeinit, + AlertFastLogExitPrintStats); AlertFastLogRegisterTests(); } diff --git a/src/alert-prelude.c b/src/alert-prelude.c index b29e885fa9..3996410155 100644 --- a/src/alert-prelude.c +++ b/src/alert-prelude.c @@ -916,7 +916,7 @@ err: void TmModuleAlertPreludeRegister (void) { - OutputRegisterPacketModule("AlertPrelude", "alert-prelude", + OutputRegisterPacketModule(LOGGER_PRELUDE, "AlertPrelude", "alert-prelude", AlertPreludeInitCtx, AlertPreludeLogger, AlertPreludeCondition, AlertPreludeThreadInit, AlertPreludeThreadDeinit, NULL); } diff --git a/src/alert-syslog.c b/src/alert-syslog.c index a48b99f7a2..3d312c9a01 100644 --- a/src/alert-syslog.c +++ b/src/alert-syslog.c @@ -411,7 +411,7 @@ static int AlertSyslogLogger(ThreadVars *tv, void *thread_data, const Packet *p) void TmModuleAlertSyslogRegister (void) { #ifndef OS_WIN32 - OutputRegisterPacketModule(MODULE_NAME, "syslog", + OutputRegisterPacketModule(LOGGER_ALERT_SYSLOG, MODULE_NAME, "syslog", AlertSyslogInitCtx, AlertSyslogLogger, AlertSyslogCondition, AlertSyslogThreadInit, AlertSyslogThreadDeinit, AlertSyslogExitPrintStats); diff --git a/src/alert-unified2-alert.c b/src/alert-unified2-alert.c index 89b588d0e2..a39a328c5e 100644 --- a/src/alert-unified2-alert.c +++ b/src/alert-unified2-alert.c @@ -235,7 +235,7 @@ int Unified2Logger(ThreadVars *tv, void *data, const Packet *p); void TmModuleUnified2AlertRegister(void) { - OutputRegisterPacketModule(MODULE_NAME, "unified2-alert", + OutputRegisterPacketModule(LOGGER_UNIFIED2, MODULE_NAME, "unified2-alert", Unified2AlertInitCtx, Unified2Logger, Unified2Condition, Unified2AlertThreadInit, Unified2AlertThreadDeinit, NULL); Unified2RegisterTests(); diff --git a/src/decode.h b/src/decode.h index 2a5d39d38e..0a829ec2fa 100644 --- a/src/decode.h +++ b/src/decode.h @@ -341,6 +341,12 @@ typedef struct PktProfilingAppData_ { uint64_t ticks_spent; } PktProfilingAppData; +typedef struct PktProfilingLoggerData_ { + uint64_t ticks_start; + uint64_t ticks_end; + uint64_t ticks_spent; +} PktProfilingLoggerData; + /** \brief Per pkt stats storage */ typedef struct PktProfiling_ { uint64_t ticks_start; @@ -350,6 +356,7 @@ typedef struct PktProfiling_ { PktProfilingData flowworker[PROFILE_FLOWWORKER_SIZE]; PktProfilingAppData app[ALPROTO_MAX]; PktProfilingDetectData detect[PROF_DETECT_SIZE]; + PktProfilingLoggerData logger[LOGGER_SIZE]; uint64_t proto_detect; } PktProfiling; diff --git a/src/log-dnslog.c b/src/log-dnslog.c index 5267175d5d..418b2dd479 100644 --- a/src/log-dnslog.c +++ b/src/log-dnslog.c @@ -346,7 +346,7 @@ static OutputCtx *LogDnsLogInitCtx(ConfNode *conf) void TmModuleLogDnsLogRegister (void) { - OutputRegisterTxModule(MODULE_NAME, "dns-log", LogDnsLogInitCtx, + OutputRegisterTxModule(LOGGER_DNS, MODULE_NAME, "dns-log", LogDnsLogInitCtx, ALPROTO_DNS, LogDnsLogger, LogDnsLogThreadInit, LogDnsLogThreadDeinit, LogDnsLogExitPrintStats); diff --git a/src/log-droplog.c b/src/log-droplog.c index c680a42337..03c66c620f 100644 --- a/src/log-droplog.c +++ b/src/log-droplog.c @@ -494,9 +494,9 @@ static void LogDropLogRegisterTests(void) /** \brief function to register the drop log module */ void TmModuleLogDropLogRegister (void) { - OutputRegisterPacketModule(MODULE_NAME, "drop", LogDropLogInitCtx, - LogDropLogger, LogDropCondition, LogDropLogThreadInit, - LogDropLogThreadDeinit, LogDropLogExitPrintStats); + OutputRegisterPacketModule(LOGGER_DROP, MODULE_NAME, "drop", + LogDropLogInitCtx, LogDropLogger, LogDropCondition, + LogDropLogThreadInit, LogDropLogThreadDeinit, LogDropLogExitPrintStats); #ifdef UNITTESTS LogDropLogRegisterTests(); #endif diff --git a/src/log-file.c b/src/log-file.c index 5a7e4b87a3..71e683a420 100644 --- a/src/log-file.c +++ b/src/log-file.c @@ -455,9 +455,9 @@ int LogFileLogOpenFileCtx(LogFileCtx *file_ctx, const char *filename, const void TmModuleLogFileLogRegister (void) { - OutputRegisterFileModule(MODULE_NAME, "file-log", LogFileLogInitCtx, - LogFileLogger, LogFileLogThreadInit, LogFileLogThreadDeinit, - LogFileLogExitPrintStats); + OutputRegisterFileModule(LOGGER_FILE, MODULE_NAME, "file-log", + LogFileLogInitCtx, LogFileLogger, LogFileLogThreadInit, + LogFileLogThreadDeinit, LogFileLogExitPrintStats); SCLogDebug("registered"); } diff --git a/src/log-filestore.c b/src/log-filestore.c index 80c32dfd0a..aacd219433 100644 --- a/src/log-filestore.c +++ b/src/log-filestore.c @@ -481,10 +481,10 @@ static OutputCtx *LogFilestoreLogInitCtx(ConfNode *conf) void TmModuleLogFilestoreRegister (void) { - OutputRegisterFiledataModule(MODULE_NAME, "file", LogFilestoreLogInitCtx, - LogFilestoreLogger, LogFilestoreLogThreadInit, + OutputRegisterFiledataModule(LOGGER_FILE_STORE, MODULE_NAME, "file", + LogFilestoreLogInitCtx, LogFilestoreLogger, LogFilestoreLogThreadInit, LogFilestoreLogThreadDeinit, LogFilestoreLogExitPrintStats); - OutputRegisterFiledataModule(MODULE_NAME, "file-store", + OutputRegisterFiledataModule(LOGGER_FILE_STORE, MODULE_NAME, "file-store", LogFilestoreLogInitCtx, LogFilestoreLogger, LogFilestoreLogThreadInit, LogFilestoreLogThreadDeinit, LogFilestoreLogExitPrintStats); diff --git a/src/log-httplog.c b/src/log-httplog.c index 64b825f891..695b98e538 100644 --- a/src/log-httplog.c +++ b/src/log-httplog.c @@ -65,8 +65,8 @@ int LogHttpLogger(ThreadVars *tv, void *thread_data, const Packet *, Flow *f, vo void TmModuleLogHttpLogRegister (void) { - OutputRegisterTxModule(MODULE_NAME, "http-log", LogHttpLogInitCtx, - ALPROTO_HTTP, LogHttpLogger, LogHttpLogThreadInit, + OutputRegisterTxModule(LOGGER_HTTP, MODULE_NAME, "http-log", + LogHttpLogInitCtx, ALPROTO_HTTP, LogHttpLogger, LogHttpLogThreadInit, LogHttpLogThreadDeinit, LogHttpLogExitPrintStats); } diff --git a/src/log-stats.c b/src/log-stats.c index 51cb56c481..343fce06ae 100644 --- a/src/log-stats.c +++ b/src/log-stats.c @@ -296,7 +296,7 @@ static void LogStatsLogDeInitCtx(OutputCtx *output_ctx) void TmModuleLogStatsLogRegister (void) { - OutputRegisterStatsModule(MODULE_NAME, "stats", LogStatsLogInitCtx, - LogStatsLogger, LogStatsLogThreadInit, LogStatsLogThreadDeinit, - LogStatsLogExitPrintStats); + OutputRegisterStatsModule(LOGGER_STATS, MODULE_NAME, "stats", + LogStatsLogInitCtx, LogStatsLogger, LogStatsLogThreadInit, + LogStatsLogThreadDeinit, LogStatsLogExitPrintStats); } diff --git a/src/log-tcp-data.c b/src/log-tcp-data.c index b1ebfca397..d56a9fc588 100644 --- a/src/log-tcp-data.c +++ b/src/log-tcp-data.c @@ -61,10 +61,11 @@ static void LogTcpDataLogDeInitCtx(OutputCtx *); int LogTcpDataLogger(ThreadVars *tv, void *thread_data, const Flow *f, const uint8_t *data, uint32_t data_len, uint64_t tx_id, uint8_t flags); void TmModuleLogTcpDataLogRegister (void) { - OutputRegisterStreamingModule(MODULE_NAME, "tcp-data", LogTcpDataLogInitCtx, - LogTcpDataLogger, STREAMING_TCP_DATA, LogTcpDataLogThreadInit, - LogTcpDataLogThreadDeinit, LogTcpDataLogExitPrintStats); - OutputRegisterStreamingModule(MODULE_NAME, "http-body-data", + OutputRegisterStreamingModule(LOGGER_TCP_DATA, MODULE_NAME, "tcp-data", + LogTcpDataLogInitCtx, LogTcpDataLogger, STREAMING_TCP_DATA, + LogTcpDataLogThreadInit, LogTcpDataLogThreadDeinit, + LogTcpDataLogExitPrintStats); + OutputRegisterStreamingModule(LOGGER_TCP_DATA, MODULE_NAME, "http-body-data", LogTcpDataLogInitCtx, LogTcpDataLogger, STREAMING_HTTP_BODIES, LogTcpDataLogThreadInit, LogTcpDataLogThreadDeinit, LogTcpDataLogExitPrintStats); diff --git a/src/log-tlslog.c b/src/log-tlslog.c index 0239606362..aa04ad1105 100644 --- a/src/log-tlslog.c +++ b/src/log-tlslog.c @@ -314,7 +314,8 @@ static int LogTlsLogger(ThreadVars *tv, void *thread_data, const Packet *p, void TmModuleLogTlsLogRegister(void) { - OutputRegisterTxModuleWithProgress(MODULE_NAME, "tls-log", LogTlsLogInitCtx, - ALPROTO_TLS, LogTlsLogger, TLS_HANDSHAKE_DONE, TLS_HANDSHAKE_DONE, - LogTlsLogThreadInit, LogTlsLogThreadDeinit, LogTlsLogExitPrintStats); + OutputRegisterTxModuleWithProgress(LOGGER_TLS, MODULE_NAME, "tls-log", + LogTlsLogInitCtx, ALPROTO_TLS, LogTlsLogger, TLS_HANDSHAKE_DONE, + TLS_HANDSHAKE_DONE, LogTlsLogThreadInit, LogTlsLogThreadDeinit, + LogTlsLogExitPrintStats); } diff --git a/src/log-tlsstore.c b/src/log-tlsstore.c index d26d02e505..13840af1ec 100644 --- a/src/log-tlsstore.c +++ b/src/log-tlsstore.c @@ -408,8 +408,8 @@ static OutputCtx *LogTlsStoreLogInitCtx(ConfNode *conf) void TmModuleLogTlsStoreRegister (void) { - OutputRegisterTxModuleWithCondition(MODULE_NAME, "tls-store", - LogTlsStoreLogInitCtx, ALPROTO_TLS, LogTlsStoreLogger, + OutputRegisterTxModuleWithCondition(LOGGER_TLS_STORE, MODULE_NAME, + "tls-store", LogTlsStoreLogInitCtx, ALPROTO_TLS, LogTlsStoreLogger, LogTlsStoreCondition, LogTlsStoreLogThreadInit, LogTlsStoreLogThreadDeinit, LogTlsStoreLogExitPrintStats); diff --git a/src/output-file.c b/src/output-file.c index 50075c5b66..995e320009 100644 --- a/src/output-file.c +++ b/src/output-file.c @@ -50,7 +50,7 @@ typedef struct OutputFileLogger_ { OutputCtx *output_ctx; struct OutputFileLogger_ *next; const char *name; - TmmId module_id; + LoggerId logger_id; ThreadInitFunc ThreadInit; ThreadDeinitFunc ThreadDeinit; ThreadExitPrintStatsFunc ThreadExitPrintStats; @@ -58,17 +58,11 @@ typedef struct OutputFileLogger_ { static OutputFileLogger *list = NULL; -int OutputRegisterFileLogger(const char *name, FileLogger LogFunc, +int OutputRegisterFileLogger(LoggerId id, const char *name, FileLogger LogFunc, OutputCtx *output_ctx, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) { -#if 0 - int module_id = TmModuleGetIdByName(name); - if (module_id < 0) - return -1; -#endif - OutputFileLogger *op = SCMalloc(sizeof(*op)); if (op == NULL) return -1; @@ -77,9 +71,7 @@ int OutputRegisterFileLogger(const char *name, FileLogger LogFunc, op->LogFunc = LogFunc; op->output_ctx = output_ctx; op->name = name; -#if 0 - op->module_id = (TmmId) module_id; -#endif + op->logger_id = id; op->ThreadInit = ThreadInit; op->ThreadDeinit = ThreadDeinit; op->ThreadExitPrintStats = ThreadExitPrintStats; @@ -162,9 +154,9 @@ static TmEcode OutputFileLog(ThreadVars *tv, Packet *p, void *thread_data, Packe BUG_ON(logger->LogFunc == NULL); SCLogDebug("logger %p", logger); - PACKET_PROFILING_TMM_START(p, logger->module_id); + PACKET_PROFILING_LOGGER_START(p, logger->logger_id); logger->LogFunc(tv, store->thread_data, (const Packet *)p, (const File *)ff); - PACKET_PROFILING_TMM_END(p, logger->module_id); + PACKET_PROFILING_LOGGER_END(p, logger->logger_id); file_logged = 1; logger = logger->next; diff --git a/src/output-file.h b/src/output-file.h index 75f3d8860b..3f335447da 100644 --- a/src/output-file.h +++ b/src/output-file.h @@ -37,8 +37,8 @@ typedef int (*FileLogger)(ThreadVars *, void *thread_data, const Packet *, const */ //typedef int (*TxLogCondition)(ThreadVars *, const Packet *); -int OutputRegisterFileLogger(const char *name, FileLogger LogFunc, OutputCtx *, - ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, +int OutputRegisterFileLogger(LoggerId id, const char *name, FileLogger LogFunc, + OutputCtx *, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats); void TmModuleFileLoggerRegister (void); diff --git a/src/output-filedata.c b/src/output-filedata.c index 828dac2384..75e3a83fc3 100644 --- a/src/output-filedata.c +++ b/src/output-filedata.c @@ -51,7 +51,7 @@ typedef struct OutputFiledataLogger_ { OutputCtx *output_ctx; struct OutputFiledataLogger_ *next; const char *name; - TmmId module_id; + LoggerId logger_id; ThreadInitFunc ThreadInit; ThreadDeinitFunc ThreadDeinit; ThreadExitPrintStatsFunc ThreadExitPrintStats; @@ -63,17 +63,11 @@ static SCMutex g_waldo_mutex = SCMUTEX_INITIALIZER; static int g_waldo_init = 0; static int g_waldo_deinit = 0; -int OutputRegisterFiledataLogger(const char *name, FiledataLogger LogFunc, - OutputCtx *output_ctx, ThreadInitFunc ThreadInit, +int OutputRegisterFiledataLogger(LoggerId id, const char *name, + FiledataLogger LogFunc, OutputCtx *output_ctx, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) { -#if 0 - int module_id = TmModuleGetIdByName(name); - if (module_id < 0) - return -1; -#endif - OutputFiledataLogger *op = SCMalloc(sizeof(*op)); if (op == NULL) return -1; @@ -82,9 +76,7 @@ int OutputRegisterFiledataLogger(const char *name, FiledataLogger LogFunc, op->LogFunc = LogFunc; op->output_ctx = output_ctx; op->name = name; -#if 0 - op->module_id = (TmmId) module_id; -#endif + op->logger_id = id; op->ThreadInit = ThreadInit; op->ThreadDeinit = ThreadDeinit; op->ThreadExitPrintStats = ThreadExitPrintStats; @@ -116,9 +108,9 @@ static int CallLoggers(ThreadVars *tv, OutputLoggerThreadStore *store_list, BUG_ON(logger->LogFunc == NULL); SCLogDebug("logger %p", logger); - PACKET_PROFILING_TMM_START(p, logger->module_id); + PACKET_PROFILING_LOGGER_START(p, logger->logger_id); logger->LogFunc(tv, store->thread_data, (const Packet *)p, ff, data, data_len, flags); - PACKET_PROFILING_TMM_END(p, logger->module_id); + PACKET_PROFILING_LOGGER_END(p, logger->logger_id); file_logged = 1; diff --git a/src/output-filedata.h b/src/output-filedata.h index c9478990aa..562eba6bb0 100644 --- a/src/output-filedata.h +++ b/src/output-filedata.h @@ -41,8 +41,9 @@ typedef int (*FiledataLogger)(ThreadVars *, void *thread_data, const Packet *, */ //typedef int (*TxLogCondition)(ThreadVars *, const Packet *); -int OutputRegisterFiledataLogger(const char *name, FiledataLogger LogFunc, - OutputCtx *, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, +int OutputRegisterFiledataLogger(LoggerId id, const char *name, + FiledataLogger LogFunc, OutputCtx *, ThreadInitFunc ThreadInit, + ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats); void TmModuleFiledataLoggerRegister (void); diff --git a/src/output-json-alert.c b/src/output-json-alert.c index 79c8ea0e29..ac28c6c9d6 100644 --- a/src/output-json-alert.c +++ b/src/output-json-alert.c @@ -741,12 +741,13 @@ error: void TmModuleJsonAlertLogRegister (void) { - OutputRegisterPacketModule(MODULE_NAME, "alert-json-log", + OutputRegisterPacketModule(LOGGER_JSON_ALERT, MODULE_NAME, "alert-json-log", JsonAlertLogInitCtx, JsonAlertLogger, JsonAlertLogCondition, JsonAlertLogThreadInit, JsonAlertLogThreadDeinit, NULL); - OutputRegisterPacketSubModule("eve-log", MODULE_NAME, "eve-log.alert", - JsonAlertLogInitCtxSub, JsonAlertLogger, JsonAlertLogCondition, - JsonAlertLogThreadInit, JsonAlertLogThreadDeinit, NULL); + OutputRegisterPacketSubModule(LOGGER_JSON_ALERT, "eve-log", MODULE_NAME, + "eve-log.alert", JsonAlertLogInitCtxSub, JsonAlertLogger, + JsonAlertLogCondition, JsonAlertLogThreadInit, JsonAlertLogThreadDeinit, + NULL); } #else diff --git a/src/output-json-dns.c b/src/output-json-dns.c index 228d575b5d..8d0e8e76ed 100644 --- a/src/output-json-dns.c +++ b/src/output-json-dns.c @@ -852,24 +852,26 @@ static OutputCtx *JsonDnsLogInitCtx(ConfNode *conf) void TmModuleJsonDnsLogRegister (void) { /* Logger for requests. */ - OutputRegisterTxModuleWithProgress(MODULE_NAME, "dns-json-log", - JsonDnsLogInitCtx, ALPROTO_DNS, JsonDnsLoggerToServer, 0, 1, - LogDnsLogThreadInit, LogDnsLogThreadDeinit, NULL); + OutputRegisterTxModuleWithProgress(LOGGER_JSON_DNS, MODULE_NAME, + "dns-json-log", JsonDnsLogInitCtx, ALPROTO_DNS, JsonDnsLoggerToServer, + 0, 1, LogDnsLogThreadInit, LogDnsLogThreadDeinit, NULL); /* Logger for replies. */ - OutputRegisterTxModuleWithProgress(MODULE_NAME, "dns-json-log", - JsonDnsLogInitCtx, ALPROTO_DNS, JsonDnsLoggerToClient, 1, 1, - LogDnsLogThreadInit, LogDnsLogThreadDeinit, NULL); + OutputRegisterTxModuleWithProgress(LOGGER_JSON_DNS, MODULE_NAME, + "dns-json-log", JsonDnsLogInitCtx, ALPROTO_DNS, JsonDnsLoggerToClient, + 1, 1, LogDnsLogThreadInit, LogDnsLogThreadDeinit, NULL); /* Sub-logger for requests. */ - OutputRegisterTxSubModuleWithProgress("eve-log", MODULE_NAME, "eve-log.dns", - JsonDnsLogInitCtxSub, ALPROTO_DNS, JsonDnsLoggerToServer, 0, 1, - LogDnsLogThreadInit, LogDnsLogThreadDeinit, NULL); + OutputRegisterTxSubModuleWithProgress(LOGGER_JSON_DNS, "eve-log", + MODULE_NAME, "eve-log.dns", JsonDnsLogInitCtxSub, ALPROTO_DNS, + JsonDnsLoggerToServer, 0, 1, LogDnsLogThreadInit, + LogDnsLogThreadDeinit, NULL); /* Sub-logger for replies. */ - OutputRegisterTxSubModuleWithProgress("eve-log", MODULE_NAME, "eve-log.dns", - JsonDnsLogInitCtxSub, ALPROTO_DNS, JsonDnsLoggerToClient, 1, 1, - LogDnsLogThreadInit, LogDnsLogThreadDeinit, NULL); + OutputRegisterTxSubModuleWithProgress(LOGGER_JSON_DNS, "eve-log", + MODULE_NAME, "eve-log.dns", JsonDnsLogInitCtxSub, ALPROTO_DNS, + JsonDnsLoggerToClient, 1, 1, LogDnsLogThreadInit, LogDnsLogThreadDeinit, + NULL); } #else diff --git a/src/output-json-drop.c b/src/output-json-drop.c index c7a8b18b85..fa2c7de008 100644 --- a/src/output-json-drop.c +++ b/src/output-json-drop.c @@ -429,12 +429,13 @@ static int JsonDropLogCondition(ThreadVars *tv, const Packet *p) void TmModuleJsonDropLogRegister (void) { - OutputRegisterPacketModule(MODULE_NAME, "drop-json-log", + OutputRegisterPacketModule(LOGGER_JSON_DROP, MODULE_NAME, "drop-json-log", JsonDropLogInitCtx, JsonDropLogger, JsonDropLogCondition, JsonDropLogThreadInit, JsonDropLogThreadDeinit, NULL); - OutputRegisterPacketSubModule("eve-log", MODULE_NAME, "eve-log.drop", - JsonDropLogInitCtxSub, JsonDropLogger, JsonDropLogCondition, - JsonDropLogThreadInit, JsonDropLogThreadDeinit, NULL); + OutputRegisterPacketSubModule(LOGGER_JSON_DROP, "eve-log", MODULE_NAME, + "eve-log.drop", JsonDropLogInitCtxSub, JsonDropLogger, + JsonDropLogCondition, JsonDropLogThreadInit, JsonDropLogThreadDeinit, + NULL); } #else diff --git a/src/output-json-file.c b/src/output-json-file.c index 273750dc93..6e1ad571ff 100644 --- a/src/output-json-file.c +++ b/src/output-json-file.c @@ -291,9 +291,9 @@ OutputCtx *OutputFileLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) void TmModuleJsonFileLogRegister (void) { /* register as child of eve-log */ - OutputRegisterFileSubModule("eve-log", "JsonFileLog", "eve-log.files", - OutputFileLogInitSub, JsonFileLogger, JsonFileLogThreadInit, - JsonFileLogThreadDeinit, NULL); + OutputRegisterFileSubModule(LOGGER_JSON_FILE, "eve-log", "JsonFileLog", + "eve-log.files", OutputFileLogInitSub, JsonFileLogger, + JsonFileLogThreadInit, JsonFileLogThreadDeinit, NULL); } #else diff --git a/src/output-json-flow.c b/src/output-json-flow.c index a55faa3115..3a59027793 100644 --- a/src/output-json-flow.c +++ b/src/output-json-flow.c @@ -451,14 +451,14 @@ static TmEcode JsonFlowLogThreadDeinit(ThreadVars *t, void *data) void TmModuleJsonFlowLogRegister (void) { /* register as separate module */ - OutputRegisterFlowModule("JsonFlowLog", "flow-json-log", + OutputRegisterFlowModule(LOGGER_JSON_FLOW, "JsonFlowLog", "flow-json-log", OutputFlowLogInit, JsonFlowLogger, JsonFlowLogThreadInit, JsonFlowLogThreadDeinit, NULL); /* also register as child of eve-log */ - OutputRegisterFlowSubModule("eve-log", "JsonFlowLog", "eve-log.flow", - OutputFlowLogInitSub, JsonFlowLogger, JsonFlowLogThreadInit, - JsonFlowLogThreadDeinit, NULL); + OutputRegisterFlowSubModule(LOGGER_JSON_FLOW, "eve-log", "JsonFlowLog", + "eve-log.flow", OutputFlowLogInitSub, JsonFlowLogger, + JsonFlowLogThreadInit, JsonFlowLogThreadDeinit, NULL); } #else diff --git a/src/output-json-http.c b/src/output-json-http.c index fdf03a33f6..9075e0cce3 100644 --- a/src/output-json-http.c +++ b/src/output-json-http.c @@ -585,13 +585,13 @@ static TmEcode JsonHttpLogThreadDeinit(ThreadVars *t, void *data) void TmModuleJsonHttpLogRegister (void) { /* register as separate module */ - OutputRegisterTxModule("JsonHttpLog", "http-json-log", OutputHttpLogInit, - ALPROTO_HTTP, JsonHttpLogger, JsonHttpLogThreadInit, + OutputRegisterTxModule(LOGGER_JSON_HTTP, "JsonHttpLog", "http-json-log", + OutputHttpLogInit, ALPROTO_HTTP, JsonHttpLogger, JsonHttpLogThreadInit, JsonHttpLogThreadDeinit, NULL); /* also register as child of eve-log */ - OutputRegisterTxSubModule("eve-log", "JsonHttpLog", "eve-log.http", - OutputHttpLogInitSub, ALPROTO_HTTP, JsonHttpLogger, + OutputRegisterTxSubModule(LOGGER_JSON_HTTP, "eve-log", "JsonHttpLog", + "eve-log.http", OutputHttpLogInitSub, ALPROTO_HTTP, JsonHttpLogger, JsonHttpLogThreadInit, JsonHttpLogThreadDeinit, NULL); } diff --git a/src/output-json-netflow.c b/src/output-json-netflow.c index 2091be08d8..0ac1683a85 100644 --- a/src/output-json-netflow.c +++ b/src/output-json-netflow.c @@ -433,14 +433,14 @@ static TmEcode JsonNetFlowLogThreadDeinit(ThreadVars *t, void *data) void TmModuleJsonNetFlowLogRegister (void) { /* register as separate module */ - OutputRegisterFlowModule("JsonNetFlowLog", "netflow-json-log", - OutputNetFlowLogInit, JsonNetFlowLogger, JsonNetFlowLogThreadInit, - JsonNetFlowLogThreadDeinit, NULL); + OutputRegisterFlowModule(LOGGER_JSON_NETFLOW, "JsonNetFlowLog", + "netflow-json-log", OutputNetFlowLogInit, JsonNetFlowLogger, + JsonNetFlowLogThreadInit, JsonNetFlowLogThreadDeinit, NULL); /* also register as child of eve-log */ - OutputRegisterFlowSubModule("eve-log", "JsonNetFlowLog", "eve-log.netflow", - OutputNetFlowLogInitSub, JsonNetFlowLogger, JsonNetFlowLogThreadInit, - JsonNetFlowLogThreadDeinit, NULL); + OutputRegisterFlowSubModule(LOGGER_JSON_NETFLOW, "eve-log", "JsonNetFlowLog", + "eve-log.netflow", OutputNetFlowLogInitSub, JsonNetFlowLogger, + JsonNetFlowLogThreadInit, JsonNetFlowLogThreadDeinit, NULL); } #else diff --git a/src/output-json-smtp.c b/src/output-json-smtp.c index 8bf94d2604..456f2c6af0 100644 --- a/src/output-json-smtp.c +++ b/src/output-json-smtp.c @@ -259,13 +259,13 @@ static TmEcode JsonSmtpLogThreadDeinit(ThreadVars *t, void *data) void TmModuleJsonSmtpLogRegister (void) { /* register as separate module */ - OutputRegisterTxModule("JsonSmtpLog", "smtp-json-log", OutputSmtpLogInit, - ALPROTO_SMTP, JsonSmtpLogger, JsonSmtpLogThreadInit, + OutputRegisterTxModule(LOGGER_JSON_SMTP, "JsonSmtpLog", "smtp-json-log", + OutputSmtpLogInit, ALPROTO_SMTP, JsonSmtpLogger, JsonSmtpLogThreadInit, JsonSmtpLogThreadDeinit, NULL); /* also register as child of eve-log */ - OutputRegisterTxSubModule("eve-log", "JsonSmtpLog", "eve-log.smtp", - OutputSmtpLogInitSub, ALPROTO_SMTP, JsonSmtpLogger, + OutputRegisterTxSubModule(LOGGER_JSON_SMTP, "eve-log", "JsonSmtpLog", + "eve-log.smtp", OutputSmtpLogInitSub, ALPROTO_SMTP, JsonSmtpLogger, JsonSmtpLogThreadInit, JsonSmtpLogThreadDeinit, NULL); } diff --git a/src/output-json-ssh.c b/src/output-json-ssh.c index 313df7c824..deec854acd 100644 --- a/src/output-json-ssh.c +++ b/src/output-json-ssh.c @@ -317,13 +317,13 @@ dontlog: void TmModuleJsonSshLogRegister (void) { /* register as separate module */ - OutputRegisterPacketModule("JsonSshLog", "ssh-json-log", OutputSshLogInit, - JsonSshLogger, JsonSshCondition, JsonSshLogThreadInit, + OutputRegisterPacketModule(LOGGER_JSON_SSH, "JsonSshLog", "ssh-json-log", + OutputSshLogInit, JsonSshLogger, JsonSshCondition, JsonSshLogThreadInit, JsonSshLogThreadDeinit, NULL); /* also register as child of eve-log */ - OutputRegisterPacketSubModule("eve-log", "JsonSshLog", "eve-log.ssh", - OutputSshLogInitSub, JsonSshLogger, JsonSshCondition, + OutputRegisterPacketSubModule(LOGGER_JSON_SSH, "eve-log", "JsonSshLog", + "eve-log.ssh", OutputSshLogInitSub, JsonSshLogger, JsonSshCondition, JsonSshLogThreadInit, JsonSshLogThreadDeinit, NULL); } diff --git a/src/output-json-stats.c b/src/output-json-stats.c index dbfba0c43c..ec0fc4152d 100644 --- a/src/output-json-stats.c +++ b/src/output-json-stats.c @@ -373,14 +373,14 @@ OutputCtx *OutputStatsLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) void TmModuleJsonStatsLogRegister (void) { /* register as separate module */ - OutputRegisterStatsModule(MODULE_NAME, "stats-json", OutputStatsLogInit, - JsonStatsLogger, JsonStatsLogThreadInit, JsonStatsLogThreadDeinit, - NULL); + OutputRegisterStatsModule(LOGGER_JSON_STATS, MODULE_NAME, "stats-json", + OutputStatsLogInit, JsonStatsLogger, JsonStatsLogThreadInit, + JsonStatsLogThreadDeinit, NULL); /* also register as child of eve-log */ - OutputRegisterStatsSubModule("eve-log", MODULE_NAME, "eve-log.stats", - OutputStatsLogInitSub, JsonStatsLogger, JsonStatsLogThreadInit, - JsonStatsLogThreadDeinit, NULL); + OutputRegisterStatsSubModule(LOGGER_JSON_STATS, "eve-log", MODULE_NAME, + "eve-log.stats", OutputStatsLogInitSub, JsonStatsLogger, + JsonStatsLogThreadInit, JsonStatsLogThreadDeinit, NULL); } #else diff --git a/src/output-json-template.c b/src/output-json-template.c index 195f1786f3..e877259de7 100644 --- a/src/output-json-template.c +++ b/src/output-json-template.c @@ -198,9 +198,10 @@ void TmModuleJsonTemplateLogRegister(void) } /* TEMPLATE_END_REMOVE */ /* Register as an eve sub-module. */ - OutputRegisterTxSubModule("eve-log", "JsonTemplateLog", "eve-log.template", - OutputTemplateLogInitSub, ALPROTO_TEMPLATE, JsonTemplateLogger, - JsonTemplateLogThreadInit, JsonTemplateLogThreadDeinit, NULL); + OutputRegisterTxSubModule(LOGGER_JSON_TEMPLATE, "eve-log", "JsonTemplateLog", + "eve-log.template", OutputTemplateLogInitSub, ALPROTO_TEMPLATE, + JsonTemplateLogger, JsonTemplateLogThreadInit, + JsonTemplateLogThreadDeinit, NULL); SCLogNotice("Template JSON logger registered."); } diff --git a/src/output-json-tls.c b/src/output-json-tls.c index 52237ba934..18ea2cab94 100644 --- a/src/output-json-tls.c +++ b/src/output-json-tls.c @@ -311,15 +311,16 @@ OutputCtx *OutputTlsLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) void TmModuleJsonTlsLogRegister (void) { /* register as separate module */ - OutputRegisterTxModuleWithProgress("JsonTlsLog", "tls-json-log", - OutputTlsLogInit, ALPROTO_TLS, JsonTlsLogger, TLS_HANDSHAKE_DONE, - TLS_HANDSHAKE_DONE, JsonTlsLogThreadInit, JsonTlsLogThreadDeinit, NULL); - - /* also register as child of eve-log */ - OutputRegisterTxSubModuleWithProgress("eve-log", "JsonTlsLog", - "eve-log.tls", OutputTlsLogInitSub, ALPROTO_TLS, JsonTlsLogger, + OutputRegisterTxModuleWithProgress(LOGGER_JSON_TLS, "JsonTlsLog", + "tls-json-log", OutputTlsLogInit, ALPROTO_TLS, JsonTlsLogger, TLS_HANDSHAKE_DONE, TLS_HANDSHAKE_DONE, JsonTlsLogThreadInit, JsonTlsLogThreadDeinit, NULL); + + /* also register as child of eve-log */ + OutputRegisterTxSubModuleWithProgress(LOGGER_JSON_TLS, "eve-log", + "JsonTlsLog", "eve-log.tls", OutputTlsLogInitSub, ALPROTO_TLS, + JsonTlsLogger, TLS_HANDSHAKE_DONE, TLS_HANDSHAKE_DONE, + JsonTlsLogThreadInit, JsonTlsLogThreadDeinit, NULL); } #else diff --git a/src/output-packet.c b/src/output-packet.c index 376b2cd51f..94197fbc9d 100644 --- a/src/output-packet.c +++ b/src/output-packet.c @@ -25,6 +25,7 @@ #include "suricata-common.h" #include "tm-modules.h" +#include "output.h" #include "output-packet.h" #include "util-profiling.h" @@ -48,7 +49,7 @@ typedef struct OutputPacketLogger_ { OutputCtx *output_ctx; struct OutputPacketLogger_ *next; const char *name; - TmmId module_id; + LoggerId logger_id; ThreadInitFunc ThreadInit; ThreadDeinitFunc ThreadDeinit; ThreadExitPrintStatsFunc ThreadExitPrintStats; @@ -56,17 +57,12 @@ typedef struct OutputPacketLogger_ { static OutputPacketLogger *list = NULL; -int OutputRegisterPacketLogger(const char *name, PacketLogger LogFunc, - PacketLogCondition ConditionFunc, OutputCtx *output_ctx, - ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, +int OutputRegisterPacketLogger(LoggerId logger_id, const char *name, + PacketLogger LogFunc, PacketLogCondition ConditionFunc, + OutputCtx *output_ctx, ThreadInitFunc ThreadInit, + ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) { -#if 0 - int module_id = TmModuleGetIdByName(name); - if (module_id < 0) - return -1; -#endif - OutputPacketLogger *op = SCMalloc(sizeof(*op)); if (op == NULL) return -1; @@ -79,9 +75,7 @@ int OutputRegisterPacketLogger(const char *name, PacketLogger LogFunc, op->ThreadInit = ThreadInit; op->ThreadDeinit = ThreadDeinit; op->ThreadExitPrintStats = ThreadExitPrintStats; -#if 0 - op->module_id = (TmmId) module_id; -#endif + op->logger_id = logger_id; if (list == NULL) list = op; @@ -113,9 +107,9 @@ static TmEcode OutputPacketLog(ThreadVars *tv, Packet *p, void *thread_data, Pac BUG_ON(logger->LogFunc == NULL || logger->ConditionFunc == NULL); if ((logger->ConditionFunc(tv, (const Packet *)p)) == TRUE) { - PACKET_PROFILING_TMM_START(p, logger->module_id); + PACKET_PROFILING_LOGGER_START(p, logger->logger_id); logger->LogFunc(tv, store->thread_data, (const Packet *)p); - PACKET_PROFILING_TMM_END(p, logger->module_id); + PACKET_PROFILING_LOGGER_END(p, logger->logger_id); } logger = logger->next; diff --git a/src/output-packet.h b/src/output-packet.h index 431c441b11..408be05b27 100644 --- a/src/output-packet.h +++ b/src/output-packet.h @@ -27,6 +27,7 @@ #define __OUTPUT_PACKET_H__ #include "decode.h" +#include "output.h" /** packet logger function pointer type */ typedef int (*PacketLogger)(ThreadVars *, void *thread_data, const Packet *); @@ -36,9 +37,9 @@ typedef int (*PacketLogger)(ThreadVars *, void *thread_data, const Packet *); */ typedef int (*PacketLogCondition)(ThreadVars *, const Packet *); -int OutputRegisterPacketLogger(const char *name, PacketLogger LogFunc, - PacketLogCondition ConditionFunc, OutputCtx *, ThreadInitFunc, - ThreadDeinitFunc, ThreadExitPrintStatsFunc); +int OutputRegisterPacketLogger(LoggerId logger_id, const char *name, + PacketLogger LogFunc, PacketLogCondition ConditionFunc, OutputCtx *, + ThreadInitFunc, ThreadDeinitFunc, ThreadExitPrintStatsFunc); void TmModulePacketLoggerRegister (void); diff --git a/src/output-streaming.c b/src/output-streaming.c index b72a38a44f..9413721986 100644 --- a/src/output-streaming.c +++ b/src/output-streaming.c @@ -53,7 +53,7 @@ typedef struct OutputStreamingLogger_ { OutputCtx *output_ctx; struct OutputStreamingLogger_ *next; const char *name; - TmmId module_id; + LoggerId logger_id; enum OutputStreamingType type; ThreadInitFunc ThreadInit; ThreadDeinitFunc ThreadDeinit; @@ -62,17 +62,12 @@ typedef struct OutputStreamingLogger_ { static OutputStreamingLogger *list = NULL; -int OutputRegisterStreamingLogger(const char *name, StreamingLogger LogFunc, - OutputCtx *output_ctx, enum OutputStreamingType type, - ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, +int OutputRegisterStreamingLogger(LoggerId id, const char *name, + StreamingLogger LogFunc, OutputCtx *output_ctx, + enum OutputStreamingType type, ThreadInitFunc ThreadInit, + ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) { -#if 0 - int module_id = TmModuleGetIdByName(name); - if (module_id < 0) - return -1; -#endif - OutputStreamingLogger *op = SCMalloc(sizeof(*op)); if (op == NULL) return -1; @@ -81,9 +76,7 @@ int OutputRegisterStreamingLogger(const char *name, StreamingLogger LogFunc, op->LogFunc = LogFunc; op->output_ctx = output_ctx; op->name = name; -#if 0 - op->module_id = (TmmId) module_id; -#endif + op->logger_id = id; op->type = type; op->ThreadInit = ThreadInit; op->ThreadDeinit = ThreadDeinit; @@ -128,9 +121,9 @@ int Streamer(void *cbdata, Flow *f, const uint8_t *data, uint32_t data_len, uint if (logger->type == streamer_cbdata->type) { SCLogDebug("logger %p", logger); - PACKET_PROFILING_TMM_START(p, logger->module_id); + PACKET_PROFILING_LOGGER_START(p, logger->logger_id); logger->LogFunc(tv, store->thread_data, (const Flow *)f, data, data_len, tx_id, flags); - PACKET_PROFILING_TMM_END(p, logger->module_id); + PACKET_PROFILING_LOGGER_END(p, logger->logger_id); } logger = logger->next; diff --git a/src/output-streaming.h b/src/output-streaming.h index 9508903a8a..8db555f94c 100644 --- a/src/output-streaming.h +++ b/src/output-streaming.h @@ -45,9 +45,9 @@ typedef int (*StreamingLogger)(ThreadVars *, void *thread_data, const Flow *f, const uint8_t *data, uint32_t data_len, uint64_t tx_id, uint8_t flags); -int OutputRegisterStreamingLogger(const char *name, StreamingLogger LogFunc, - OutputCtx *, enum OutputStreamingType, ThreadInitFunc ThreadInit, - ThreadDeinitFunc ThreadDeinit, +int OutputRegisterStreamingLogger(LoggerId id, const char *name, + StreamingLogger LogFunc, OutputCtx *, enum OutputStreamingType, + ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats); void TmModuleStreamingLoggerRegister (void); diff --git a/src/output-tx.c b/src/output-tx.c index 4a7934aad1..3d37e89e8e 100644 --- a/src/output-tx.c +++ b/src/output-tx.c @@ -51,7 +51,7 @@ typedef struct OutputTxLogger_ { OutputCtx *output_ctx; struct OutputTxLogger_ *next; const char *name; - TmmId module_id; + LoggerId logger_id; uint32_t id; int tc_log_progress; int ts_log_progress; @@ -62,7 +62,8 @@ typedef struct OutputTxLogger_ { static OutputTxLogger *list = NULL; -int OutputRegisterTxLogger(const char *name, AppProto alproto, TxLogger LogFunc, +int OutputRegisterTxLogger(LoggerId id, const char *name, AppProto alproto, + TxLogger LogFunc, OutputCtx *output_ctx, int tc_log_progress, int ts_log_progress, TxLoggerCondition LogCondition, ThreadInitFunc ThreadInit, @@ -91,9 +92,7 @@ int OutputRegisterTxLogger(const char *name, AppProto alproto, TxLogger LogFunc, op->LogCondition = LogCondition; op->output_ctx = output_ctx; op->name = name; -#if 0 - op->module_id = (TmmId) module_id; -#endif + op->logger_id = id; op->ThreadInit = ThreadInit; op->ThreadDeinit = ThreadDeinit; op->ThreadExitPrintStats = ThreadExitPrintStats; @@ -230,9 +229,9 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data, PacketQ } } - PACKET_PROFILING_TMM_START(p, logger->module_id); + PACKET_PROFILING_LOGGER_START(p, logger->logger_id); logger->LogFunc(tv, store->thread_data, p, f, alstate, tx, tx_id); - PACKET_PROFILING_TMM_END(p, logger->module_id); + PACKET_PROFILING_LOGGER_END(p, logger->logger_id); AppLayerParserSetTxLogged(p->proto, alproto, alstate, tx, logger->id); diff --git a/src/output-tx.h b/src/output-tx.h index 53f563aca2..e548cdd160 100644 --- a/src/output-tx.h +++ b/src/output-tx.h @@ -36,7 +36,8 @@ typedef int (*TxLogger)(ThreadVars *, void *thread_data, const Packet *, Flow *f */ typedef int (*TxLoggerCondition)(ThreadVars *, const Packet *, void *state, void *tx, uint64_t tx_id); -int OutputRegisterTxLogger(const char *name, AppProto alproto, TxLogger LogFunc, +int OutputRegisterTxLogger(LoggerId id, const char *name, AppProto alproto, + TxLogger LogFunc, OutputCtx *, int tc_log_progress, int ts_log_progress, TxLoggerCondition LogCondition, ThreadInitFunc, ThreadDeinitFunc, diff --git a/src/output.c b/src/output.c index 351cd294ae..5c7e71a25c 100644 --- a/src/output.c +++ b/src/output.c @@ -84,7 +84,7 @@ error: * \retval Returns 0 on success, -1 on failure. */ void -OutputRegisterPacketModule(const char *name, const char *conf_name, +OutputRegisterPacketModule(LoggerId id, const char *name, const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *), PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, @@ -99,6 +99,7 @@ OutputRegisterPacketModule(const char *name, const char *conf_name, goto error; } + module->logger_id = id; module->name = name; module->conf_name = conf_name; module->InitFunc = InitFunc; @@ -125,8 +126,9 @@ error: * \retval Returns 0 on success, -1 on failure. */ void -OutputRegisterPacketSubModule(const char *parent_name, const char *name, - const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *parent_ctx), +OutputRegisterPacketSubModule(LoggerId id, const char *parent_name, + const char *name, const char *conf_name, + OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *parent_ctx), PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) @@ -140,6 +142,7 @@ OutputRegisterPacketSubModule(const char *parent_name, const char *name, goto error; } + module->logger_id = id; module->name = name; module->conf_name = conf_name; module->parent_name = parent_name; @@ -166,10 +169,10 @@ error: * * \retval Returns 0 on success, -1 on failure. */ -void OutputRegisterTxModuleWrapper(const char *name, const char *conf_name, - OutputCtx *(*InitFunc)(ConfNode *), AppProto alproto, - TxLogger TxLogFunc, int tc_log_progress, int ts_log_progress, - TxLoggerCondition TxLogCondition, +void OutputRegisterTxModuleWrapper(LoggerId id, const char *name, + const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *), + AppProto alproto, TxLogger TxLogFunc, int tc_log_progress, + int ts_log_progress, TxLoggerCondition TxLogCondition, TmEcode (*ThreadInit)(ThreadVars *t, void *, void **), TmEcode (*ThreadDeinit)(ThreadVars *t, void *), void (*ThreadExitPrintStats)(ThreadVars *, void *)) @@ -183,6 +186,7 @@ void OutputRegisterTxModuleWrapper(const char *name, const char *conf_name, goto error; } + module->logger_id = id; module->name = name; module->conf_name = conf_name; module->InitFunc = InitFunc; @@ -203,7 +207,7 @@ error: exit(EXIT_FAILURE); } -void OutputRegisterTxSubModuleWrapper(const char *parent_name, +void OutputRegisterTxSubModuleWrapper(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *parent_ctx), AppProto alproto, TxLogger TxLogFunc, int tc_log_progress, int ts_log_progress, @@ -221,6 +225,7 @@ void OutputRegisterTxSubModuleWrapper(const char *parent_name, goto error; } + module->logger_id = id; module->name = name; module->conf_name = conf_name; module->parent_name = parent_name; @@ -250,25 +255,27 @@ error: * * \retval Returns 0 on success, -1 on failure. */ -void OutputRegisterTxModuleWithCondition(const char *name, +void OutputRegisterTxModuleWithCondition(LoggerId id, const char *name, const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *), AppProto alproto, TxLogger TxLogFunc, TxLoggerCondition TxLogCondition, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) { - OutputRegisterTxModuleWrapper(name, conf_name, InitFunc, alproto, - TxLogFunc, -1, -1, TxLogCondition, NULL, NULL, NULL); + OutputRegisterTxModuleWrapper(id, name, conf_name, InitFunc, alproto, + TxLogFunc, -1, -1, TxLogCondition, ThreadInit, ThreadDeinit, + ThreadExitPrintStats); } -void OutputRegisterTxSubModuleWithCondition(const char *parent_name, +void OutputRegisterTxSubModuleWithCondition(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *parent_ctx), AppProto alproto, TxLogger TxLogFunc, TxLoggerCondition TxLogCondition, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) { - OutputRegisterTxSubModuleWrapper(parent_name, name, conf_name, InitFunc, - alproto, TxLogFunc, -1, -1, TxLogCondition, NULL, NULL, NULL); + OutputRegisterTxSubModuleWrapper(id, parent_name, name, conf_name, InitFunc, + alproto, TxLogFunc, -1, -1, TxLogCondition, ThreadInit, ThreadDeinit, + ThreadExitPrintStats); } /** @@ -279,18 +286,20 @@ void OutputRegisterTxSubModuleWithCondition(const char *parent_name, * * \retval Returns 0 on success, -1 on failure. */ -void OutputRegisterTxModuleWithProgress(const char *name, const char *conf_name, - OutputCtx *(*InitFunc)(ConfNode *), AppProto alproto, - TxLogger TxLogFunc, int tc_log_progress, int ts_log_progress, - ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, +void OutputRegisterTxModuleWithProgress(LoggerId id, const char *name, + const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *), + AppProto alproto, TxLogger TxLogFunc, int tc_log_progress, + int ts_log_progress, ThreadInitFunc ThreadInit, + ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) { - OutputRegisterTxModuleWrapper(name, conf_name, InitFunc, alproto, - TxLogFunc, tc_log_progress, ts_log_progress, NULL, ThreadInit, - ThreadDeinit, ThreadExitPrintStats); + OutputRegisterTxModuleWrapper(id, name, conf_name, InitFunc, alproto, + TxLogFunc, tc_log_progress, ts_log_progress, + NULL, ThreadInit, ThreadDeinit, + ThreadExitPrintStats); } -void OutputRegisterTxSubModuleWithProgress(const char *parent_name, +void OutputRegisterTxSubModuleWithProgress(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *parent_ctx), AppProto alproto, TxLogger TxLogFunc, int tc_log_progress, @@ -298,7 +307,7 @@ void OutputRegisterTxSubModuleWithProgress(const char *parent_name, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) { - OutputRegisterTxSubModuleWrapper(parent_name, name, conf_name, InitFunc, + OutputRegisterTxSubModuleWrapper(id, parent_name, name, conf_name, InitFunc, alproto, TxLogFunc, tc_log_progress, ts_log_progress, NULL, ThreadInit, ThreadDeinit, ThreadExitPrintStats); } @@ -312,25 +321,25 @@ void OutputRegisterTxSubModuleWithProgress(const char *parent_name, * \retval Returns 0 on success, -1 on failure. */ void -OutputRegisterTxModule(const char *name, const char *conf_name, +OutputRegisterTxModule(LoggerId id, const char *name, const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *), AppProto alproto, TxLogger TxLogFunc, TmEcode (*ThreadInit)(ThreadVars *, void *, void **), TmEcode (*ThreadDeinit)(ThreadVars *, void *), void (*ThreadExitPrintStats)(ThreadVars *, void *)) { - OutputRegisterTxModuleWrapper(name, conf_name, InitFunc, alproto, + OutputRegisterTxModuleWrapper(id, name, conf_name, InitFunc, alproto, TxLogFunc, -1, -1, NULL, ThreadInit, ThreadDeinit, ThreadExitPrintStats); } -void OutputRegisterTxSubModule(const char *parent_name, const char *name, - const char *conf_name, +void OutputRegisterTxSubModule(LoggerId id, const char *parent_name, + const char *name, const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *parent_ctx), AppProto alproto, TxLogger TxLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) { - OutputRegisterTxSubModuleWrapper(parent_name, name, conf_name, + OutputRegisterTxSubModuleWrapper(id, parent_name, name, conf_name, InitFunc, alproto, TxLogFunc, -1, -1, NULL, ThreadInit, ThreadDeinit, ThreadExitPrintStats); @@ -345,7 +354,7 @@ void OutputRegisterTxSubModule(const char *parent_name, const char *name, * \retval Returns 0 on success, -1 on failure. */ void -OutputRegisterFileModule(const char *name, const char *conf_name, +OutputRegisterFileModule(LoggerId id, const char *name, const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *), FileLogger FileLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) @@ -359,6 +368,7 @@ OutputRegisterFileModule(const char *name, const char *conf_name, goto error; } + module->logger_id = id; module->name = name; module->conf_name = conf_name; module->InitFunc = InitFunc; @@ -384,8 +394,9 @@ error: * \retval Returns 0 on success, -1 on failure. */ void -OutputRegisterFileSubModule(const char *parent_name, const char *name, - const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), +OutputRegisterFileSubModule(LoggerId id, const char *parent_name, + const char *name, const char *conf_name, + OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), FileLogger FileLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) @@ -399,6 +410,7 @@ OutputRegisterFileSubModule(const char *parent_name, const char *name, goto error; } + module->logger_id = id; module->name = name; module->conf_name = conf_name; module->parent_name = parent_name; @@ -425,9 +437,10 @@ error: * \retval Returns 0 on success, -1 on failure. */ void -OutputRegisterFiledataModule(const char *name, const char *conf_name, - OutputCtx *(*InitFunc)(ConfNode *), FiledataLogger FiledataLogFunc, - ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, +OutputRegisterFiledataModule(LoggerId id, const char *name, + const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *), + FiledataLogger FiledataLogFunc, ThreadInitFunc ThreadInit, + ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) { if (unlikely(FiledataLogFunc == NULL)) { @@ -439,6 +452,7 @@ OutputRegisterFiledataModule(const char *name, const char *conf_name, goto error; } + module->logger_id = id; module->name = name; module->conf_name = conf_name; module->InitFunc = InitFunc; @@ -464,8 +478,9 @@ error: * \retval Returns 0 on success, -1 on failure. */ void -OutputRegisterFiledataSubModule(const char *parent_name, const char *name, - const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), +OutputRegisterFiledataSubModule(LoggerId id, const char *parent_name, + const char *name, const char *conf_name, + OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), FiledataLogger FiledataLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) @@ -479,6 +494,7 @@ OutputRegisterFiledataSubModule(const char *parent_name, const char *name, goto error; } + module->logger_id = id; module->name = name; module->conf_name = conf_name; module->parent_name = parent_name; @@ -505,7 +521,7 @@ error: * \retval Returns 0 on success, -1 on failure. */ void -OutputRegisterFlowModule(const char *name, const char *conf_name, +OutputRegisterFlowModule(LoggerId id, const char *name, const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *), FlowLogger FlowLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) @@ -519,6 +535,7 @@ OutputRegisterFlowModule(const char *name, const char *conf_name, goto error; } + module->logger_id = id; module->name = name; module->conf_name = conf_name; module->InitFunc = InitFunc; @@ -544,8 +561,9 @@ error: * \retval Returns 0 on success, -1 on failure. */ void -OutputRegisterFlowSubModule(const char *parent_name, const char *name, - const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), +OutputRegisterFlowSubModule(LoggerId id, const char *parent_name, + const char *name, const char *conf_name, + OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), FlowLogger FlowLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) @@ -559,6 +577,7 @@ OutputRegisterFlowSubModule(const char *parent_name, const char *name, goto error; } + module->logger_id = id; module->name = name; module->conf_name = conf_name; module->parent_name = parent_name; @@ -585,8 +604,9 @@ error: * \retval Returns 0 on success, -1 on failure. */ void -OutputRegisterStreamingModule(const char *name, const char *conf_name, - OutputCtx *(*InitFunc)(ConfNode *), StreamingLogger StreamingLogFunc, +OutputRegisterStreamingModule(LoggerId id, const char *name, + const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *), + StreamingLogger StreamingLogFunc, enum OutputStreamingType stream_type, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) @@ -600,6 +620,7 @@ OutputRegisterStreamingModule(const char *name, const char *conf_name, goto error; } + module->logger_id = id; module->name = name; module->conf_name = conf_name; module->InitFunc = InitFunc; @@ -626,8 +647,9 @@ error: * \retval Returns 0 on success, -1 on failure. */ void -OutputRegisterStreamingSubModule(const char *parent_name, const char *name, - const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), +OutputRegisterStreamingSubModule(LoggerId id, const char *parent_name, + const char *name, const char *conf_name, + OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), StreamingLogger StreamingLogFunc, enum OutputStreamingType stream_type, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) @@ -641,6 +663,7 @@ OutputRegisterStreamingSubModule(const char *parent_name, const char *name, goto error; } + module->logger_id = id; module->name = name; module->conf_name = conf_name; module->parent_name = parent_name; @@ -668,7 +691,7 @@ error: * \retval Returns 0 on success, -1 on failure. */ void -OutputRegisterStatsModule(const char *name, const char *conf_name, +OutputRegisterStatsModule(LoggerId id, const char *name, const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *), StatsLogger StatsLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) @@ -682,6 +705,7 @@ OutputRegisterStatsModule(const char *name, const char *conf_name, goto error; } + module->logger_id = id; module->name = name; module->conf_name = conf_name; module->InitFunc = InitFunc; @@ -707,8 +731,9 @@ error: * \retval Returns 0 on success, -1 on failure. */ void -OutputRegisterStatsSubModule(const char *parent_name, const char *name, - const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), +OutputRegisterStatsSubModule(LoggerId id, const char *parent_name, + const char *name, const char *conf_name, + OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), StatsLogger StatsLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) @@ -722,6 +747,7 @@ OutputRegisterStatsSubModule(const char *parent_name, const char *name, goto error; } + module->logger_id = id; module->name = name; module->conf_name = conf_name; module->parent_name = parent_name; diff --git a/src/output.h b/src/output.h index e34d34379d..ad78719368 100644 --- a/src/output.h +++ b/src/output.h @@ -39,6 +39,7 @@ #include "output-stats.h" typedef struct OutputModule_ { + LoggerId logger_id; const char *name; const char *conf_name; const char *parent_name; @@ -71,48 +72,49 @@ extern OutputModuleList output_modules; void OutputRegisterModule(const char *, const char *, OutputCtx *(*)(ConfNode *)); -void OutputRegisterPacketModule(const char *name, const char *conf_name, - OutputCtx *(*InitFunc)(ConfNode *), +void OutputRegisterPacketModule(LoggerId id, const char *name, + const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *), PacketLogger LogFunc, PacketLogCondition ConditionFunc, ThreadInitFunc, ThreadDeinitFunc, ThreadExitPrintStatsFunc); -void OutputRegisterPacketSubModule(const char *parent_name, const char *name, - const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), +void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name, + const char *name, const char *conf_name, + OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), PacketLogger LogFunc, PacketLogCondition ConditionFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats); -void OutputRegisterTxModule(const char *name, const char *conf_name, - OutputCtx *(*InitFunc)(ConfNode *), AppProto alproto, - TxLogger TxLogFunc, TmEcode (*ThreadInit)(ThreadVars *t, void *, void **), +void OutputRegisterTxModule(LoggerId id, const char *name, const char *conf_name, + OutputCtx *(*InitFunc)(ConfNode *), AppProto alproto, TxLogger TxLogFunc, + TmEcode (*ThreadInit)(ThreadVars *t, void *, void **), TmEcode (*ThreadDeinit)(ThreadVars *t, void *), void (*ThreadExitPrintStats)(ThreadVars *, void *)); -void OutputRegisterTxSubModule(const char *parent_name, const char *name, - const char *conf_name, +void OutputRegisterTxSubModule(LoggerId id, const char *parent_name, + const char *name, const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *parent_ctx), AppProto alproto, TxLogger TxLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats); -void OutputRegisterTxModuleWithCondition(const char *name, +void OutputRegisterTxModuleWithCondition(LoggerId id, const char *name, const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *), AppProto alproto, TxLogger TxLogFunc, TxLoggerCondition TxLogCondition, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats); -void OutputRegisterTxSubModuleWithCondition(const char *parent_name, +void OutputRegisterTxSubModuleWithCondition(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *parent_ctx), AppProto alproto, TxLogger TxLogFunc, TxLoggerCondition TxLogCondition, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats); -void OutputRegisterTxModuleWithProgress(const char *name, const char *conf_name, - OutputCtx *(*InitFunc)(ConfNode *), AppProto alproto, +void OutputRegisterTxModuleWithProgress(LoggerId id, const char *name, + const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *), AppProto alproto, TxLogger TxLogFunc, int tc_log_progress, int ts_log_progress, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats); -void OutputRegisterTxSubModuleWithProgress(const char *parent_name, +void OutputRegisterTxSubModuleWithProgress(LoggerId id, const char *parent_name, const char *name, const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *parent_ctx), AppProto alproto, TxLogger TxLogFunc, int tc_log_progress, @@ -120,54 +122,61 @@ void OutputRegisterTxSubModuleWithProgress(const char *parent_name, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats); -void OutputRegisterFileModule(const char *name, const char *conf_name, - OutputCtx *(*InitFunc)(ConfNode *), FileLogger FileLogFunc, - ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, - ThreadExitPrintStatsFunc ThreadExitPrintStats); -void OutputRegisterFileSubModule(const char *parent_name, const char *name, - const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), +void OutputRegisterFileModule(LoggerId id, const char *name, + const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *), FileLogger FileLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats); - -void OutputRegisterFiledataModule(const char *name, const char *conf_name, - OutputCtx *(*InitFunc)(ConfNode *), FiledataLogger FiledataLogFunc, +void OutputRegisterFileSubModule(LoggerId id, const char *parent_name, + const char *name, const char *conf_name, + OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), FileLogger FileLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats); -void OutputRegisterFiledataSubModule(const char *parent_name, const char *name, - const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), + +void OutputRegisterFiledataModule(LoggerId id, const char *name, + const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *), + FiledataLogger FiledataLogFunc, ThreadInitFunc ThreadInit, + ThreadDeinitFunc ThreadDeinit, + ThreadExitPrintStatsFunc ThreadExitPrintStats); +void OutputRegisterFiledataSubModule(LoggerId, const char *parent_name, + const char *name, const char *conf_name, + OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), FiledataLogger FiledataLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats); -void OutputRegisterFlowModule(const char *name, const char *conf_name, - OutputCtx *(*InitFunc)(ConfNode *), FlowLogger FlowLogFunc, - ThreadInitFunc ThreadInit, +void OutputRegisterFlowModule(LoggerId id, const char *name, + const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *), + FlowLogger FlowLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats); -void OutputRegisterFlowSubModule(const char *parent_name, const char *name, - const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), +void OutputRegisterFlowSubModule(LoggerId id, const char *parent_name, + const char *name, const char *conf_name, + OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), FlowLogger FlowLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats); -void OutputRegisterStreamingModule(const char *name, const char *conf_name, - OutputCtx *(*InitFunc)(ConfNode *), StreamingLogger StreamingLogFunc, - enum OutputStreamingType stream_type, ThreadInitFunc ThreadInit, - ThreadDeinitFunc ThreadDeinit, +void OutputRegisterStreamingModule(LoggerId id, const char *name, + const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *), + StreamingLogger StreamingLogFunc, enum OutputStreamingType stream_type, + ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats); -void OutputRegisterStreamingSubModule(const char *parent_name, const char *name, - const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), +void OutputRegisterStreamingSubModule(LoggerId id, const char *parent_name, + const char *name, const char *conf_name, + OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), StreamingLogger StreamingLogFunc, enum OutputStreamingType stream_type, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats); -void OutputRegisterStatsModule(const char *name, const char *conf_name, - OutputCtx *(*InitFunc)(ConfNode *), StatsLogger StatsLogFunc, - ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, +void OutputRegisterStatsModule(LoggerId id, const char *name, + const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *), + StatsLogger StatsLogFunc, ThreadInitFunc ThreadInit, + ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats); -void OutputRegisterStatsSubModule(const char *parent_name, const char *name, - const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), +void OutputRegisterStatsSubModule(LoggerId id, const char *parent_name, + const char *name, const char *conf_name, + OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), StatsLogger StatsLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats); diff --git a/src/runmodes.c b/src/runmodes.c index 3f043b9409..b4f319d408 100644 --- a/src/runmodes.c +++ b/src/runmodes.c @@ -106,9 +106,6 @@ static char *active_runmode; /* free list for our outputs */ typedef struct OutputFreeList_ { -#if 0 - TmModule *tm_module; -#endif OutputModule *output_module; OutputCtx *output_ctx; @@ -469,9 +466,6 @@ void RunOutputFreeList(void) { OutputFreeList *output; while ((output = TAILQ_FIRST(&output_free_list))) { -#if 0 - SCLogNotice("output %s %p %p", output->tm_module->name, output, output->output_ctx); -#endif SCLogDebug("output %s %p %p", output->output_module->name, output, output->output_ctx); @@ -535,20 +529,9 @@ void RunModeShutDown(void) * the output ctx at shutdown and unix socket reload */ static void AddOutputToFreeList(OutputModule *module, OutputCtx *output_ctx) { -#if 0 - TmModule *tm_module = TmModuleGetByName(module->name); - if (tm_module == NULL) { - SCLogError(SC_ERR_INVALID_ARGUMENT, - "TmModuleGetByName for %s failed", module->name); - exit(EXIT_FAILURE); - } -#endif OutputFreeList *fl_output = SCCalloc(1, sizeof(OutputFreeList)); if (unlikely(fl_output == NULL)) return; -#if 0 - fl_output->tm_module = tm_module; -#endif fl_output->output_module = module; fl_output->output_ctx = output_ctx; TAILQ_INSERT_TAIL(&output_free_list, fl_output, entries); @@ -598,23 +581,16 @@ static void SetupOutput(const char *name, OutputModule *module, OutputCtx *outpu return; } -#if 0 - TmModule *tm_module = TmModuleGetByName(module->name); - if (tm_module == NULL) { - SCLogError(SC_ERR_INVALID_ARGUMENT, - "TmModuleGetByName for %s failed", module->name); - exit(EXIT_FAILURE); - } - /* XXX What to do here? */ - if (tm_module != NULL && strcmp(tmm_modules[TMM_ALERTDEBUGLOG].name, tm_module->name) == 0) + if (module->logger_id == LOGGER_ALERT_DEBUG) { debuglog_enabled = 1; -#endif + } if (module->PacketLogFunc) { SCLogNotice("%s is a packet logger", module->name); - OutputRegisterPacketLogger(module->name, module->PacketLogFunc, - module->PacketConditionFunc, output_ctx, module->ThreadInit, - module->ThreadDeinit, module->ThreadExitPrintStats); + OutputRegisterPacketLogger(module->logger_id, module->name, + module->PacketLogFunc, module->PacketConditionFunc, output_ctx, + module->ThreadInit, module->ThreadDeinit, + module->ThreadExitPrintStats); /* need one instance of the packet logger module */ if (pkt_logger_module == NULL) { @@ -636,7 +612,7 @@ static void SetupOutput(const char *name, OutputModule *module, OutputCtx *outpu } } else if (module->TxLogFunc) { SCLogDebug("%s is a tx logger", module->name); - OutputRegisterTxLogger(module->name, module->alproto, + OutputRegisterTxLogger(module->logger_id, module->name, module->alproto, module->TxLogFunc, output_ctx, module->tc_log_progress, module->ts_log_progress, module->TxLogCondition, module->ThreadInit, module->ThreadDeinit, @@ -662,9 +638,9 @@ static void SetupOutput(const char *name, OutputModule *module, OutputCtx *outpu } } else if (module->FiledataLogFunc) { SCLogDebug("%s is a filedata logger", module->name); - OutputRegisterFiledataLogger(module->name, module->FiledataLogFunc, - output_ctx, module->ThreadInit, module->ThreadDeinit, - module->ThreadExitPrintStats); + OutputRegisterFiledataLogger(module->logger_id, module->name, + module->FiledataLogFunc, output_ctx, module->ThreadInit, + module->ThreadDeinit, module->ThreadExitPrintStats); /* need one instance of the tx logger module */ if (filedata_logger_module == NULL) { @@ -686,9 +662,9 @@ static void SetupOutput(const char *name, OutputModule *module, OutputCtx *outpu } } else if (module->FileLogFunc) { SCLogDebug("%s is a file logger", module->name); - OutputRegisterFileLogger(module->name, module->FileLogFunc, output_ctx, - module->ThreadInit, module->ThreadDeinit, - module->ThreadExitPrintStats); + OutputRegisterFileLogger(module->logger_id, module->name, + module->FileLogFunc, output_ctx, module->ThreadInit, + module->ThreadDeinit, module->ThreadExitPrintStats); /* need one instance of the tx logger module */ if (file_logger_module == NULL) { @@ -710,9 +686,10 @@ static void SetupOutput(const char *name, OutputModule *module, OutputCtx *outpu } } else if (module->StreamingLogFunc) { SCLogDebug("%s is a streaming logger", module->name); - OutputRegisterStreamingLogger(module->name, module->StreamingLogFunc, - output_ctx, module->stream_type, module->ThreadInit, - module->ThreadDeinit, module->ThreadExitPrintStats); + OutputRegisterStreamingLogger(module->logger_id, module->name, + module->StreamingLogFunc, output_ctx, module->stream_type, + module->ThreadInit, module->ThreadDeinit, + module->ThreadExitPrintStats); /* need one instance of the streaming logger module */ if (streaming_logger_module == NULL) { @@ -739,9 +716,6 @@ static void SetupOutput(const char *name, OutputModule *module, OutputCtx *outpu if (unlikely(runmode_output == NULL)) return; runmode_output->name = module->name; -#if 0 - runmode_output->tm_module = tm_module; -#endif runmode_output->output_ctx = output_ctx; InsertInRunModeOutputs(runmode_output); } diff --git a/src/suricata-common.h b/src/suricata-common.h index 0db433f9c4..b837de26ad 100644 --- a/src/suricata-common.h +++ b/src/suricata-common.h @@ -341,6 +341,37 @@ typedef enum PacketProfileDetectId_ { PROF_DETECT_SIZE, } PacketProfileDetectId; +typedef enum { + LOGGER_UNDEFINED, + LOGGER_ALERT_DEBUG, + LOGGER_ALERT_FAST, + LOGGER_UNIFIED2, + LOGGER_ALERT_SYSLOG, + LOGGER_DROP, + LOGGER_JSON_ALERT, + LOGGER_JSON_DROP, + LOGGER_JSON_SSH, + LOGGER_DNS, + LOGGER_HTTP, + LOGGER_JSON_DNS, + LOGGER_JSON_HTTP, + LOGGER_JSON_SMTP, + LOGGER_JSON_TLS, + LOGGER_JSON_TEMPLATE, + LOGGER_TLS_STORE, + LOGGER_TLS, + LOGGER_FILE, + LOGGER_FILE_STORE, + LOGGER_JSON_FILE, + LOGGER_TCP_DATA, + LOGGER_JSON_FLOW, + LOGGER_JSON_NETFLOW, + LOGGER_STATS, + LOGGER_JSON_STATS, + LOGGER_PRELUDE, + LOGGER_SIZE, +} LoggerId; + #include #include "threads.h" #include "tm-threads-common.h" diff --git a/src/util-profiling.c b/src/util-profiling.c index 500a3ebc8e..cbbef0c20a 100644 --- a/src/util-profiling.c +++ b/src/util-profiling.c @@ -87,6 +87,9 @@ SCProfilePacketData packet_profile_app_pd_data6[257]; SCProfilePacketData packet_profile_detect_data4[PROF_DETECT_SIZE][257]; SCProfilePacketData packet_profile_detect_data6[PROF_DETECT_SIZE][257]; +SCProfilePacketData packet_profile_log_data4[LOGGER_SIZE][256]; +SCProfilePacketData packet_profile_log_data6[LOGGER_SIZE][256]; + struct ProfileProtoRecords { SCProfilePacketData records4[257]; SCProfilePacketData records6[257]; @@ -114,6 +117,7 @@ __thread int profiling_rules_entered = 0; void SCProfilingDumpPacketStats(void); const char * PacketProfileDetectIdToString(PacketProfileDetectId id); +const char * PacketProfileLoggertIdToString(LoggerId id); static void FormatNumber(uint64_t num, char *str, size_t size) { @@ -167,6 +171,8 @@ SCProfilingInit(void) memset(&packet_profile_app_pd_data6, 0, sizeof(packet_profile_app_pd_data6)); memset(&packet_profile_detect_data4, 0, sizeof(packet_profile_detect_data4)); memset(&packet_profile_detect_data6, 0, sizeof(packet_profile_detect_data6)); + memset(&packet_profile_log_data4, 0, sizeof(packet_profile_log_data4)); + memset(&packet_profile_log_data6, 0, sizeof(packet_profile_log_data6)); memset(&packet_profile_flowworker_data, 0, sizeof(packet_profile_flowworker_data)); const char *filename = ConfNodeLookupChildValue(conf, "filename"); @@ -685,6 +691,58 @@ void SCProfilingDumpPacketStats(void) } } + fprintf(fp, "\nLogger/output stats:\n"); + + total = 0; + for (m = 0; m < LOGGER_SIZE; m++) { + int p; + for (p = 0; p < 257; p++) { + SCProfilePacketData *pd = &packet_profile_log_data4[m][p]; + total += pd->tot; + pd = &packet_profile_log_data6[m][p]; + total += pd->tot; + } + } + + fprintf(fp, "\n%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s\n", + "Logger", "IP ver", "Proto", "cnt", "min", "max", "avg", "tot"); + fprintf(fp, "%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s\n", + "------------------------", "------", "-----", "----------", "------------", "------------", "-----------", "-----------"); + for (m = 0; m < LOGGER_SIZE; m++) { + int p; + for (p = 0; p < 257; p++) { + SCProfilePacketData *pd = &packet_profile_log_data4[m][p]; + + if (pd->cnt == 0) { + continue; + } + + FormatNumber(pd->tot, totalstr, sizeof(totalstr)); + double percent = (long double)pd->tot / + (long double)total * 100; + + fprintf(fp, "%-24s IPv4 %3d %12"PRIu64" %12"PRIu64" %12"PRIu64" %12"PRIu64" %12s %-6.2f\n", + PacketProfileLoggertIdToString(m), p, pd->cnt, pd->min, pd->max, (uint64_t)(pd->tot / pd->cnt), totalstr, percent); + } + } + for (m = 0; m < LOGGER_SIZE; m++) { + int p; + for (p = 0; p < 257; p++) { + SCProfilePacketData *pd = &packet_profile_log_data6[m][p]; + + if (pd->cnt == 0) { + continue; + } + + FormatNumber(pd->tot, totalstr, sizeof(totalstr)); + double percent = (long double)pd->tot / + (long double)total * 100; + + fprintf(fp, "%-24s IPv6 %3d %12"PRIu64" %12"PRIu64" %12"PRIu64" %12"PRIu64" %12s %-6.2f\n", + PacketProfileLoggertIdToString(m), p, pd->cnt, pd->min, pd->max, (uint64_t)(pd->tot / pd->cnt), totalstr, percent); + } + } + fprintf(fp, "\nGeneral detection engine stats:\n"); total = 0; @@ -984,6 +1042,45 @@ static void SCProfilingUpdatePacketGenericRecords(Packet *p, PktProfilingData *p } } +static void SCProfilingUpdatePacketLogRecord(LoggerId id, + uint8_t ipproto, PktProfilingLoggerData *pdt, int ipver) +{ + if (pdt == NULL) { + return; + } + + SCProfilePacketData *pd; + if (ipver == 4) + pd = &packet_profile_log_data4[id][ipproto]; + else + pd = &packet_profile_log_data6[id][ipproto]; + + if (pd->min == 0 || pdt->ticks_spent < pd->min) { + pd->min = pdt->ticks_spent; + } + if (pd->max < pdt->ticks_spent) { + pd->max = pdt->ticks_spent; + } + + pd->tot += pdt->ticks_spent; + pd->cnt++; +} + +static void SCProfilingUpdatePacketLogRecords(Packet *p) +{ + for (LoggerId i = 0; i < LOGGER_SIZE; i++) { + PktProfilingLoggerData *pdt = &p->profile->logger[i]; + + if (pdt->ticks_spent > 0) { + if (PKT_IS_IPV4(p)) { + SCProfilingUpdatePacketLogRecord(i, p->proto, pdt, 4); + } else { + SCProfilingUpdatePacketLogRecord(i, p->proto, pdt, 6); + } + } + } +} + void SCProfilingAddPacket(Packet *p) { if (p == NULL || p->profile == NULL || @@ -1031,6 +1128,7 @@ void SCProfilingAddPacket(Packet *p) SCProfilingUpdatePacketTmmRecords(p); SCProfilingUpdatePacketAppRecords(p); SCProfilingUpdatePacketDetectRecords(p); + SCProfilingUpdatePacketLogRecords(p); } else if (PKT_IS_IPV6(p)) { SCProfilePacketData *pd = &packet_profile_data6[p->proto]; @@ -1066,6 +1164,7 @@ void SCProfilingAddPacket(Packet *p) SCProfilingUpdatePacketTmmRecords(p); SCProfilingUpdatePacketAppRecords(p); SCProfilingUpdatePacketDetectRecords(p); + SCProfilingUpdatePacketLogRecords(p); } } pthread_mutex_unlock(&packet_profile_lock); @@ -1142,7 +1241,47 @@ const char * PacketProfileDetectIdToString(PacketProfileDetectId id) } } - +/** + * \brief Maps the LoggerId's to its string equivalent for profiling output. + * + * \param id LoggerId id + * + * \retval string equivalent for the LoggerId id + */ +const char * PacketProfileLoggertIdToString(LoggerId id) +{ + switch (id) { + CASE_CODE (LOGGER_UNDEFINED); + CASE_CODE (LOGGER_ALERT_DEBUG); + CASE_CODE (LOGGER_ALERT_FAST); + CASE_CODE (LOGGER_UNIFIED2); + CASE_CODE (LOGGER_ALERT_SYSLOG); + CASE_CODE (LOGGER_DROP); + CASE_CODE (LOGGER_JSON_ALERT); + CASE_CODE (LOGGER_JSON_DROP); + CASE_CODE (LOGGER_JSON_SSH); + CASE_CODE (LOGGER_DNS); + CASE_CODE (LOGGER_HTTP); + CASE_CODE (LOGGER_JSON_DNS); + CASE_CODE (LOGGER_JSON_HTTP); + CASE_CODE (LOGGER_JSON_SMTP); + CASE_CODE (LOGGER_JSON_TLS); + CASE_CODE (LOGGER_JSON_TEMPLATE); + CASE_CODE (LOGGER_TLS_STORE); + CASE_CODE (LOGGER_TLS); + CASE_CODE (LOGGER_FILE); + CASE_CODE (LOGGER_FILE_STORE); + CASE_CODE (LOGGER_JSON_FILE); + CASE_CODE (LOGGER_TCP_DATA); + CASE_CODE (LOGGER_JSON_FLOW); + CASE_CODE (LOGGER_JSON_NETFLOW); + CASE_CODE (LOGGER_STATS); + CASE_CODE (LOGGER_JSON_STATS); + CASE_CODE (LOGGER_PRELUDE); + default: + return "UNKNOWN"; + } +} #ifdef UNITTESTS diff --git a/src/util-profiling.h b/src/util-profiling.h index 54521a4220..990697ca1e 100644 --- a/src/util-profiling.h +++ b/src/util-profiling.h @@ -250,6 +250,25 @@ PktProfiling *SCProfilePacketStart(void); } \ } +#define PACKET_PROFILING_LOGGER_START(p, id) \ + if (profiling_packets_enabled && (p)->profile != NULL) { \ + if ((id) < LOGGER_SIZE) { \ + (p)->profile->logger[(id)].ticks_start = UtilCpuGetTicks(); \ + } \ + } + +#define PACKET_PROFILING_LOGGER_END(p, id) \ + if (profiling_packets_enabled && (p)->profile != NULL) { \ + if ((id) < LOGGER_SIZE) { \ + (p)->profile->logger[(id)].ticks_end = UtilCpuGetTicks();\ + if ((p)->profile->logger[(id)].ticks_start != 0 && \ + (p)->profile->logger[(id)].ticks_start < (p)->profile->logger[(id)].ticks_end) { \ + (p)->profile->logger[(id)].ticks_spent += \ + ((p)->profile->logger[(id)].ticks_end - (p)->profile->logger[(id)].ticks_start); \ + } \ + } \ + } + #define SGH_PROFILING_RECORD(det_ctx, sgh) \ if (profiling_sghs_enabled) { \ SCProfilingSghUpdateCounter((det_ctx), (sgh)); \ @@ -311,6 +330,9 @@ void SCProfilingDump(void); #define PACKET_PROFILING_DETECT_START(p, id) #define PACKET_PROFILING_DETECT_END(p, id) +#define PACKET_PROFILING_LOGGER_START(p, id) +#define PACKET_PROFILING_LOGGER_END(p, id) + #define SGH_PROFILING_RECORD(det_ctx, sgh) #define FLOWWORKER_PROFILING_START(p, id)