]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
packet-logger: remove ThreadExitPrintStats
authorJason Ish <jason.ish@oisf.net>
Tue, 27 Aug 2024 22:18:55 +0000 (16:18 -0600)
committerVictor Julien <victor@inliniac.net>
Sat, 31 Aug 2024 08:53:59 +0000 (10:53 +0200)
The ThreadExitPrintStats callback was never being used, remove.

Ticket: #7227

17 files changed:
examples/plugins/c-custom-loggers/custom-logger.c
src/alert-debuglog.c
src/alert-fastlog.c
src/alert-syslog.c
src/log-pcap.c
src/output-eve-stream.c
src/output-json-alert.c
src/output-json-anomaly.c
src/output-json-arp.c
src/output-json-drop.c
src/output-json-frame.c
src/output-json-metadata.c
src/output-packet.c
src/output-packet.h
src/output.c
src/output.h
src/runmodes.c

index a9cca80110d747d47593d2978c509717218f2859..59c2077c0f6ada98a99cabf46d3e7268a3234cb6 100644 (file)
@@ -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 = {
index 356cf86ef36b5c3953f85c2f5625700b1039b52a..8872b6e35e487db4adf88b18ddba52365d52f333 100644 (file)
@@ -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);
 }
index 29f3e9dc0aa87bca41d64796b1f61dee1200c386..7f43de4bef25d41f97afc292922efb298adbf3b5 100644 (file)
@@ -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();
 }
 
index 5c00f1b350563cf12f062b89f57b903a12e472c7..016e633493ba228345b8553195ec785b2f38ef11 100644 (file)
@@ -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 */
 }
index 253560961dd0c28ae23c459b00501bb7018c9a98..e62a03dd806cd4c1e652f9757d0842d21b9badbb 100644 (file)
@@ -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 */
index f05aa6b38cfe4f084c920e93e6aa3c888369a2e8..fcdf0c2e5c0b3e163586cf5c4c04e9b9c89a4743 100644 (file)
@@ -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);
 }
index 4126e8feaddccdf74bf8efca7fa40755f5827b05..624cb6e491fa01ff32ab2c66f19f8fc8b57542bf 100644 (file)
@@ -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);
 }
index c1d9cc65c0eda6088bb3ce36ecae90548ed8773d..1680530280c6d1585c99da602b39ff15fba1d4fb 100644 (file)
@@ -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,
index 597e418d86ba4eb8fc558fc0cfbc51ce00621484..0490c6b54d1ecae1e33d0d1b18805b3423280c7c 100644 (file)
@@ -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.");
 }
index d4f2ac0a1931c41727e7e58b8f00585af061c2c5..0ee9cf3a03351652df4f2f6352e02074a22831e6 100644 (file)
@@ -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);
 }
index 4f761e7ca1737a322e75165609bab0e22756aeee..ab3aa5cc7ba5934fb4b8642a01b6100479631d90 100644 (file)
@@ -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);
 }
index 772b2ccb06f22c1545c40f4a319f0a172f205a6b..f97547c551b436e2191f0f9dd2d5eb3fa23514fd 100644 (file)
@@ -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);
 }
index 96d2e426c9d2dd61ee8306fe6f4735b4fcb456a5..9576e61153596e9cf998fa0ab688beacb2ca0499 100644 (file)
@@ -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)
index 83712007133400786132a93a4cf145239b088827..03cf2ee3f5db858ce0002dbd4750f601b1bff642 100644 (file)
@@ -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);
 
index a6ca3e1ae0465abcb2efeb59a42a342059ef5778..7b010fe6fbcff24c2085310571e85c1170fbe3f2 100644 (file)
@@ -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);
index bedb34b0318c3408b8b1552862fff13a911554ce..4abb529961ff8bf5ed9101337c7b63f807972e6f 100644 (file)
@@ -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,
index c702184e59414ba721f9ea833c9f855dd77900f0..362555603d7bc3c15d04c3603d7dadfc9b2b9029 100644 (file)
@@ -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,