]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output: tx logging optimizations
authorVictor Julien <victor@inliniac.net>
Sat, 11 Feb 2017 20:43:30 +0000 (21:43 +0100)
committerVictor Julien <victor@inliniac.net>
Mon, 15 May 2017 12:13:41 +0000 (14:13 +0200)
src/app-layer-parser.c
src/app-layer-parser.h
src/output-tx.c

index 0d6408dc7b83c6046670b1a4758a8b45aa871e60..2eced2648667cd6afc1cb26c8fd6bffc28824d7d 100644 (file)
@@ -598,16 +598,15 @@ void AppLayerParserSetTxLogged(uint8_t ipproto, AppProto alproto,
     SCReturn;
 }
 
-int AppLayerParserGetTxLogged(uint8_t ipproto, AppProto alproto,
+int AppLayerParserGetTxLogged(const Flow *f,
                               void *alstate, void *tx, uint32_t logger)
 {
     SCEnter();
 
     uint8_t r = 0;
-    if (alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].
-            StateGetTxLogged != NULL) {
-        r = alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].
-                StateGetTxLogged(alstate, tx, logger);
+    if (alp_ctx.ctxs[f->protomap][f->alproto].StateGetTxLogged != NULL) {
+        r = alp_ctx.ctxs[f->protomap][f->alproto].
+            StateGetTxLogged(alstate, tx, logger);
     }
 
     SCReturnInt(r);
index 8318ef34e6c5fecd9be00f1d7d3ab7c89b6e82b9..dc8667b0285a9ccb229f76c2d79b6006302ef33e 100644 (file)
@@ -169,7 +169,7 @@ void AppLayerParserSetTransactionLogId(AppLayerParserState *pstate, uint64_t tx_
 
 void AppLayerParserSetTxLogged(uint8_t ipproto, AppProto alproto, void *alstate,
                                void *tx, uint32_t logger);
-int AppLayerParserGetTxLogged(uint8_t ipproto, AppProto alproto, void *alstate,
+int AppLayerParserGetTxLogged(const Flow *f, void *alstate,
                               void *tx, uint32_t logger);
 
 uint64_t AppLayerParserGetTransactionInspectId(AppLayerParserState *pstate, uint8_t direction);
index 326d881b047ffa89c0aeeaa72772cccc19055559..b9c869c3aeadc7a2ff958feed147e66d5a9dc550 100644 (file)
@@ -138,11 +138,11 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
     OutputLoggerThreadData *op_thread_data = (OutputLoggerThreadData *)thread_data;
     OutputTxLogger *logger = list;
     OutputLoggerThreadStore *store = op_thread_data->store;
-
+#ifdef DEBUG_VALIDATION
     BUG_ON(logger == NULL && store != NULL);
     BUG_ON(logger != NULL && store == NULL);
     BUG_ON(logger == NULL && store == NULL);
-
+#endif
     if (p->flow == NULL)
         return TM_ECODE_OK;
 
@@ -161,6 +161,8 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
         goto end;
     }
 
+    const uint8_t ts_disrupt_flags = FlowGetDisruptionFlags(f, STREAM_TOSERVER);
+    const uint8_t tc_disrupt_flags = FlowGetDisruptionFlags(f, STREAM_TOCLIENT);
     const uint64_t total_txs = AppLayerParserGetTxCnt(f, alstate);
     uint64_t tx_id = AppLayerParserGetTransactionLogId(f->alparser);
     uint64_t max_id = tx_id;
@@ -182,10 +184,10 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
         }
 
         int tx_progress_ts = AppLayerParserGetStateProgress(p->proto, alproto,
-                tx, FlowGetDisruptionFlags(f, STREAM_TOSERVER));
+                tx, ts_disrupt_flags);
 
         int tx_progress_tc = AppLayerParserGetStateProgress(p->proto, alproto,
-                tx, FlowGetDisruptionFlags(f, STREAM_TOCLIENT));
+                tx, tc_disrupt_flags);
 
         SCLogDebug("tx_progress_ts %d tx_progress_tc %d",
                 tx_progress_ts, tx_progress_tc);
@@ -204,8 +206,7 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
 
                 number_of_loggers++;
 
-                if (AppLayerParserGetTxLogged(p->proto, alproto, alstate, tx,
-                        logger->id)) {
+                if (AppLayerParserGetTxLogged(f, alstate, tx, logger->id)) {
                     SCLogDebug("logger has already logged this transaction");
                     loggers_that_logged++;
                     goto next;
@@ -246,9 +247,10 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
 next:
             logger = logger->next;
             store = store->next;
-
+#ifdef DEBUG_VALIDATION
             BUG_ON(logger == NULL && store != NULL);
             BUG_ON(logger != NULL && store == NULL);
+#endif
         }
 
         /* If all loggers logged set a flag and update the last tx_id