]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output-flow: use void * instead of OutputCtx * for initdata
authorJason Ish <jason.ish@oisf.net>
Mon, 26 Aug 2024 21:45:07 +0000 (15:45 -0600)
committerVictor Julien <victor@inliniac.net>
Sat, 31 Aug 2024 08:53:59 +0000 (10:53 +0200)
The use of OutputCtx as the data type for initdata was leaking Eve
submodule logic into the low level flow logger. Instead use void *, as
the flow logging module is not concerned with the type of data here.

Also document this initdata parameter.

Ticket: #7227

src/output-flow.c
src/output-flow.h

index 47c8b31f3071b2d7cd825742a93e01e67e07f2f3..5d7a08c8835862ad94a974415d7132ec647d95f7 100644 (file)
@@ -40,7 +40,10 @@ typedef struct OutputFlowLoggerThreadData_ {
  * log module (e.g. http.log) with different output ctx'. */
 typedef struct OutputFlowLogger_ {
     FlowLogger LogFunc;
-    OutputCtx *output_ctx;
+
+    /** Data that will be passed to the ThreadInit callback. */
+    void *initdata;
+
     struct OutputFlowLogger_ *next;
 
     /** A name for this logger, used for debugging only. */
@@ -61,17 +64,16 @@ static OutputFlowLogger *list = NULL;
  *
  * \retval 0 on success, -1 on failure.
  */
-int OutputRegisterFlowLogger(const char *name, FlowLogger LogFunc,
-    OutputCtx *output_ctx, ThreadInitFunc ThreadInit,
-    ThreadDeinitFunc ThreadDeinit,
-    ThreadExitPrintStatsFunc ThreadExitPrintStats)
+int OutputRegisterFlowLogger(const char *name, FlowLogger LogFunc, void *initdata,
+        ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
+        ThreadExitPrintStatsFunc ThreadExitPrintStats)
 {
     OutputFlowLogger *op = SCCalloc(1, sizeof(*op));
     if (op == NULL)
         return -1;
 
     op->LogFunc = LogFunc;
-    op->output_ctx = output_ctx;
+    op->initdata = initdata;
     op->name = name;
     op->ThreadInit = ThreadInit;
     op->ThreadDeinit = ThreadDeinit;
@@ -145,7 +147,7 @@ TmEcode OutputFlowLogThreadInit(ThreadVars *tv, void **data)
     while (logger) {
         if (logger->ThreadInit) {
             void *retptr = NULL;
-            if (logger->ThreadInit(tv, (void *)logger->output_ctx, &retptr) == TM_ECODE_OK) {
+            if (logger->ThreadInit(tv, (void *)logger->initdata, &retptr) == TM_ECODE_OK) {
                 OutputLoggerThreadStore *ts = SCCalloc(1, sizeof(*ts));
                 /* todo */ BUG_ON(ts == NULL);
 
index 86e0e00de007049f12ebc34039962ea1f509c424..c3dd3335cbd3df12f606ed45e53b1545dee6becc 100644 (file)
@@ -31,9 +31,9 @@
 /** flow logger function pointer type */
 typedef int (*FlowLogger)(ThreadVars *, void *thread_data, Flow *f);
 
-int OutputRegisterFlowLogger(const char *name, FlowLogger LogFunc,
-    OutputCtx *, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
-    ThreadExitPrintStatsFunc ThreadExitPrintStats);
+int OutputRegisterFlowLogger(const char *name, FlowLogger LogFunc, void *initdata,
+        ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit,
+        ThreadExitPrintStatsFunc ThreadExitPrintStats);
 
 void OutputFlowShutdown(void);