From: Jason Ish Date: Tue, 27 Aug 2024 22:18:55 +0000 (-0600) Subject: packet-logger: remove ThreadExitPrintStats X-Git-Tag: suricata-8.0.0-beta1~921 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8735c02995098cfa9d3352eec97cd1603d0aa9ce;p=thirdparty%2Fsuricata.git packet-logger: remove ThreadExitPrintStats The ThreadExitPrintStats callback was never being used, remove. Ticket: #7227 --- diff --git a/examples/plugins/c-custom-loggers/custom-logger.c b/examples/plugins/c-custom-loggers/custom-logger.c index a9cca80110..59c2077c0f 100644 --- a/examples/plugins/c-custom-loggers/custom-logger.c +++ b/examples/plugins/c-custom-loggers/custom-logger.c @@ -93,8 +93,9 @@ static TmEcode ThreadDeinit(ThreadVars *tv, void *data) static void Init(void) { OutputRegisterPacketLogger(LOGGER_USER, "custom-packet-logger", CustomPacketLogger, - CustomPacketLoggerCondition, NULL, ThreadInit, ThreadDeinit, NULL); - OutputRegisterFlowLogger("custom-flow-logger", CustomFlowLogger, NULL, ThreadInit, ThreadDeinit); + CustomPacketLoggerCondition, NULL, ThreadInit, ThreadDeinit); + OutputRegisterFlowLogger( + "custom-flow-logger", CustomFlowLogger, NULL, ThreadInit, ThreadDeinit); } const SCPlugin PluginRegistration = { diff --git a/src/alert-debuglog.c b/src/alert-debuglog.c index 356cf86ef3..8872b6e35e 100644 --- a/src/alert-debuglog.c +++ b/src/alert-debuglog.c @@ -484,7 +484,7 @@ static int AlertDebugLogLogger(ThreadVars *tv, void *thread_data, const Packet * void AlertDebugLogRegister(void) { - OutputRegisterPacketModule(LOGGER_ALERT_DEBUG, MODULE_NAME, "alert-debug", - AlertDebugLogInitCtx, AlertDebugLogLogger, AlertDebugLogCondition, - AlertDebugLogThreadInit, AlertDebugLogThreadDeinit, NULL); + OutputRegisterPacketModule(LOGGER_ALERT_DEBUG, MODULE_NAME, "alert-debug", AlertDebugLogInitCtx, + AlertDebugLogLogger, AlertDebugLogCondition, AlertDebugLogThreadInit, + AlertDebugLogThreadDeinit); } diff --git a/src/alert-fastlog.c b/src/alert-fastlog.c index 29f3e9dc0a..7f43de4bef 100644 --- a/src/alert-fastlog.c +++ b/src/alert-fastlog.c @@ -76,9 +76,9 @@ int AlertFastLogger(ThreadVars *tv, void *data, const Packet *p); void AlertFastLogRegister(void) { - OutputRegisterPacketModule(LOGGER_ALERT_FAST, MODULE_NAME, "fast", - AlertFastLogInitCtx, AlertFastLogger, AlertFastLogCondition, - AlertFastLogThreadInit, AlertFastLogThreadDeinit, NULL); + OutputRegisterPacketModule(LOGGER_ALERT_FAST, MODULE_NAME, "fast", AlertFastLogInitCtx, + AlertFastLogger, AlertFastLogCondition, AlertFastLogThreadInit, + AlertFastLogThreadDeinit); AlertFastLogRegisterTests(); } diff --git a/src/alert-syslog.c b/src/alert-syslog.c index 5c00f1b350..016e633493 100644 --- a/src/alert-syslog.c +++ b/src/alert-syslog.c @@ -384,8 +384,8 @@ static int AlertSyslogLogger(ThreadVars *tv, void *thread_data, const Packet *p) void AlertSyslogRegister (void) { #ifndef OS_WIN32 - OutputRegisterPacketModule(LOGGER_ALERT_SYSLOG, MODULE_NAME, "syslog", - AlertSyslogInitCtx, AlertSyslogLogger, AlertSyslogCondition, - AlertSyslogThreadInit, AlertSyslogThreadDeinit, NULL); + OutputRegisterPacketModule(LOGGER_ALERT_SYSLOG, MODULE_NAME, "syslog", AlertSyslogInitCtx, + AlertSyslogLogger, AlertSyslogCondition, AlertSyslogThreadInit, + AlertSyslogThreadDeinit); #endif /* !OS_WIN32 */ } diff --git a/src/log-pcap.c b/src/log-pcap.c index 253560961d..e62a03dd80 100644 --- a/src/log-pcap.c +++ b/src/log-pcap.c @@ -209,9 +209,8 @@ static bool PcapLogCondition(ThreadVars *, void *, const Packet *); void PcapLogRegister(void) { - OutputRegisterPacketModule(LOGGER_PCAP, MODULE_NAME, "pcap-log", - PcapLogInitCtx, PcapLog, PcapLogCondition, PcapLogDataInit, - PcapLogDataDeinit, NULL); + OutputRegisterPacketModule(LOGGER_PCAP, MODULE_NAME, "pcap-log", PcapLogInitCtx, PcapLog, + PcapLogCondition, PcapLogDataInit, PcapLogDataDeinit); PcapLogProfileSetup(); SC_ATOMIC_INIT(thread_cnt); SC_ATOMIC_SET(thread_cnt, 1); /* first id is 1 */ diff --git a/src/output-eve-stream.c b/src/output-eve-stream.c index f05aa6b38c..fcdf0c2e5c 100644 --- a/src/output-eve-stream.c +++ b/src/output-eve-stream.c @@ -453,5 +453,5 @@ void EveStreamLogRegister(void) { OutputRegisterPacketSubModule(LOGGER_JSON_STREAM, "eve-log", MODULE_NAME, "eve-log.stream", EveStreamLogInitCtxSub, EveStreamLogger, EveStreamLogCondition, EveStreamLogThreadInit, - EveStreamLogThreadDeinit, NULL); + EveStreamLogThreadDeinit); } diff --git a/src/output-json-alert.c b/src/output-json-alert.c index 4126e8fead..624cb6e491 100644 --- a/src/output-json-alert.c +++ b/src/output-json-alert.c @@ -1024,8 +1024,7 @@ error: void JsonAlertLogRegister (void) { - OutputRegisterPacketSubModule(LOGGER_JSON_ALERT, "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); } diff --git a/src/output-json-anomaly.c b/src/output-json-anomaly.c index c1d9cc65c0..1680530280 100644 --- a/src/output-json-anomaly.c +++ b/src/output-json-anomaly.c @@ -450,10 +450,9 @@ static OutputInitResult JsonAnomalyLogInitCtxSub(ConfNode *conf, OutputCtx *pare void JsonAnomalyLogRegister (void) { - OutputRegisterPacketSubModule(LOGGER_JSON_ANOMALY, "eve-log", MODULE_NAME, - "eve-log.anomaly", JsonAnomalyLogInitCtxSub, JsonAnomalyLogger, - JsonAnomalyLogCondition, JsonAnomalyLogThreadInit, JsonAnomalyLogThreadDeinit, - NULL); + OutputRegisterPacketSubModule(LOGGER_JSON_ANOMALY, "eve-log", MODULE_NAME, "eve-log.anomaly", + JsonAnomalyLogInitCtxSub, JsonAnomalyLogger, JsonAnomalyLogCondition, + JsonAnomalyLogThreadInit, JsonAnomalyLogThreadDeinit); OutputRegisterTxSubModule(LOGGER_JSON_ANOMALY, "eve-log", MODULE_NAME, "eve-log.anomaly", JsonAnomalyLogInitCtxHelper, ALPROTO_UNKNOWN, diff --git a/src/output-json-arp.c b/src/output-json-arp.c index 597e418d86..0490c6b54d 100644 --- a/src/output-json-arp.c +++ b/src/output-json-arp.c @@ -105,7 +105,7 @@ void JsonArpLogRegister(void) { OutputRegisterPacketSubModule(LOGGER_JSON_ARP, "eve-log", "JsonArpLog", "eve-log.arp", OutputJsonLogInitSub, JsonArpLogger, JsonArpLogCondition, JsonLogThreadInit, - JsonLogThreadDeinit, NULL); + JsonLogThreadDeinit); SCLogDebug("ARP JSON logger registered."); } diff --git a/src/output-json-drop.c b/src/output-json-drop.c index d4f2ac0a19..0ee9cf3a03 100644 --- a/src/output-json-drop.c +++ b/src/output-json-drop.c @@ -390,8 +390,7 @@ static bool JsonDropLogCondition(ThreadVars *tv, void *data, const Packet *p) void JsonDropLogRegister (void) { - OutputRegisterPacketSubModule(LOGGER_JSON_DROP, "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); } diff --git a/src/output-json-frame.c b/src/output-json-frame.c index 4f761e7ca1..ab3aa5cc7b 100644 --- a/src/output-json-frame.c +++ b/src/output-json-frame.c @@ -560,5 +560,5 @@ void JsonFrameLogRegister(void) { OutputRegisterPacketSubModule(LOGGER_JSON_FRAME, "eve-log", MODULE_NAME, "eve-log.frame", JsonFrameLogInitCtxSub, JsonFrameLogger, JsonFrameLogCondition, JsonFrameLogThreadInit, - JsonFrameLogThreadDeinit, NULL); + JsonFrameLogThreadDeinit); } diff --git a/src/output-json-metadata.c b/src/output-json-metadata.c index 772b2ccb06..f97547c551 100644 --- a/src/output-json-metadata.c +++ b/src/output-json-metadata.c @@ -96,10 +96,10 @@ void JsonMetadataLogRegister (void) { OutputRegisterPacketSubModule(LOGGER_JSON_METADATA, "eve-log", MODULE_NAME, "eve-log.metadata", OutputJsonLogInitSub, JsonMetadataLogger, JsonMetadataLogCondition, JsonLogThreadInit, - JsonLogThreadDeinit, NULL); + JsonLogThreadDeinit); /* Kept for compatibility. */ OutputRegisterPacketSubModule(LOGGER_JSON_METADATA, "eve-log", MODULE_NAME, "eve-log.vars", OutputJsonLogInitSub, JsonMetadataLogger, JsonMetadataLogCondition, JsonLogThreadInit, - JsonLogThreadDeinit, NULL); + JsonLogThreadDeinit); } diff --git a/src/output-packet.c b/src/output-packet.c index 96d2e426c9..9576e61153 100644 --- a/src/output-packet.c +++ b/src/output-packet.c @@ -48,14 +48,13 @@ typedef struct OutputPacketLogger_ { LoggerId logger_id; ThreadInitFunc ThreadInit; ThreadDeinitFunc ThreadDeinit; - ThreadExitPrintStatsFunc ThreadExitPrintStats; } OutputPacketLogger; static OutputPacketLogger *list = NULL; int OutputRegisterPacketLogger(LoggerId logger_id, const char *name, PacketLogger LogFunc, PacketLogCondition ConditionFunc, void *initdata, ThreadInitFunc ThreadInit, - ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats) + ThreadDeinitFunc ThreadDeinit) { OutputPacketLogger *op = SCCalloc(1, sizeof(*op)); if (op == NULL) @@ -67,7 +66,6 @@ int OutputRegisterPacketLogger(LoggerId logger_id, const char *name, PacketLogge op->name = name; op->ThreadInit = ThreadInit; op->ThreadDeinit = ThreadDeinit; - op->ThreadExitPrintStats = ThreadExitPrintStats; op->logger_id = logger_id; if (list == NULL) @@ -184,22 +182,6 @@ static TmEcode OutputPacketLogThreadDeinit(ThreadVars *tv, void *thread_data) return TM_ECODE_OK; } -static void OutputPacketLogExitPrintStats(ThreadVars *tv, void *thread_data) -{ - OutputPacketLoggerThreadData *op_thread_data = (OutputPacketLoggerThreadData *)thread_data; - OutputLoggerThreadStore *store = op_thread_data->store; - OutputPacketLogger *logger = list; - - while (logger && store) { - if (logger->ThreadExitPrintStats) { - logger->ThreadExitPrintStats(tv, store->thread_data); - } - - logger = logger->next; - store = store->next; - } -} - static uint32_t OutputPacketLoggerGetActiveCount(void) { uint32_t cnt = 0; @@ -211,9 +193,8 @@ static uint32_t OutputPacketLoggerGetActiveCount(void) void OutputPacketLoggerRegister(void) { - OutputRegisterRootLogger(OutputPacketLogThreadInit, - OutputPacketLogThreadDeinit, OutputPacketLogExitPrintStats, - OutputPacketLog, OutputPacketLoggerGetActiveCount); + OutputRegisterRootLogger(OutputPacketLogThreadInit, OutputPacketLogThreadDeinit, NULL, + OutputPacketLog, OutputPacketLoggerGetActiveCount); } void OutputPacketShutdown(void) diff --git a/src/output-packet.h b/src/output-packet.h index 8371200713..03cf2ee3f5 100644 --- a/src/output-packet.h +++ b/src/output-packet.h @@ -38,8 +38,7 @@ typedef int (*PacketLogger)(ThreadVars *, void *thread_data, const Packet *); typedef bool (*PacketLogCondition)(ThreadVars *, void *thread_data, const Packet *); int OutputRegisterPacketLogger(LoggerId logger_id, const char *name, PacketLogger LogFunc, - PacketLogCondition ConditionFunc, void *initdata, ThreadInitFunc, ThreadDeinitFunc, - ThreadExitPrintStatsFunc); + PacketLogCondition ConditionFunc, void *initdata, ThreadInitFunc, ThreadDeinitFunc); void OutputPacketLoggerRegister(void); diff --git a/src/output.c b/src/output.c index a6ca3e1ae0..7b010fe6fb 100644 --- a/src/output.c +++ b/src/output.c @@ -167,11 +167,9 @@ error: * * \retval Returns 0 on success, -1 on failure. */ -void OutputRegisterPacketModule(LoggerId id, const char *name, - const char *conf_name, OutputInitFunc InitFunc, - PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc, - ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, - ThreadExitPrintStatsFunc ThreadExitPrintStats) +void OutputRegisterPacketModule(LoggerId id, const char *name, const char *conf_name, + OutputInitFunc InitFunc, PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc, + ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit) { if (unlikely(PacketLogFunc == NULL || PacketConditionFunc == NULL)) { goto error; @@ -190,7 +188,6 @@ void OutputRegisterPacketModule(LoggerId id, const char *name, module->PacketConditionFunc = PacketConditionFunc; module->ThreadInit = ThreadInit; module->ThreadDeinit = ThreadDeinit; - module->ThreadExitPrintStats = ThreadExitPrintStats; TAILQ_INSERT_TAIL(&output_modules, module, entries); SCLogDebug("Packet logger \"%s\" registered.", name); @@ -207,11 +204,10 @@ error: * * \retval Returns 0 on success, -1 on failure. */ -void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name, - const char *name, const char *conf_name, OutputInitSubFunc InitFunc, - PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc, - ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, - ThreadExitPrintStatsFunc ThreadExitPrintStats) +void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name, const char *name, + const char *conf_name, OutputInitSubFunc InitFunc, PacketLogger PacketLogFunc, + PacketLogCondition PacketConditionFunc, ThreadInitFunc ThreadInit, + ThreadDeinitFunc ThreadDeinit) { if (unlikely(PacketLogFunc == NULL || PacketConditionFunc == NULL)) { goto error; @@ -231,7 +227,6 @@ void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name, module->PacketConditionFunc = PacketConditionFunc; module->ThreadInit = ThreadInit; module->ThreadDeinit = ThreadDeinit; - module->ThreadExitPrintStats = ThreadExitPrintStats; TAILQ_INSERT_TAIL(&output_modules, module, entries); SCLogDebug("Packet logger \"%s\" registered.", name); diff --git a/src/output.h b/src/output.h index bedb34b031..4abb529961 100644 --- a/src/output.h +++ b/src/output.h @@ -87,15 +87,12 @@ extern OutputModuleList output_modules; void OutputRegisterModule(const char *, const char *, OutputInitFunc); -void OutputRegisterPacketModule(LoggerId id, const char *name, - const char *conf_name, OutputInitFunc InitFunc, PacketLogger LogFunc, - PacketLogCondition ConditionFunc, ThreadInitFunc, ThreadDeinitFunc, - ThreadExitPrintStatsFunc); -void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name, - const char *name, const char *conf_name, OutputInitSubFunc InitFunc, - PacketLogger LogFunc, PacketLogCondition ConditionFunc, - ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, - ThreadExitPrintStatsFunc ThreadExitPrintStats); +void OutputRegisterPacketModule(LoggerId id, const char *name, const char *conf_name, + OutputInitFunc InitFunc, PacketLogger LogFunc, PacketLogCondition ConditionFunc, + ThreadInitFunc, ThreadDeinitFunc); +void OutputRegisterPacketSubModule(LoggerId id, const char *parent_name, const char *name, + const char *conf_name, OutputInitSubFunc InitFunc, PacketLogger LogFunc, + PacketLogCondition ConditionFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit); void OutputRegisterTxModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, AppProto alproto, diff --git a/src/runmodes.c b/src/runmodes.c index c702184e59..362555603d 100644 --- a/src/runmodes.c +++ b/src/runmodes.c @@ -620,8 +620,7 @@ static void SetupOutput( SCLogDebug("%s is a packet logger", module->name); OutputRegisterPacketLogger(module->logger_id, module->name, module->PacketLogFunc, module->PacketConditionFunc, output_ctx, - module->ThreadInit, module->ThreadDeinit, - module->ThreadExitPrintStats); + module->ThreadInit, module->ThreadDeinit); } else if (module->TxLogFunc) { SCLogDebug("%s is a tx logger", module->name); OutputRegisterTxLogger(module->logger_id, module->name, module->alproto,