output: tx logging optimizations

pull/2712/head
Victor Julien 9 years ago
parent 5c01b40931
commit 4459b88782

@ -598,15 +598,14 @@ void AppLayerParserSetTxLogged(uint8_t ipproto, AppProto alproto,
SCReturn; SCReturn;
} }
int AppLayerParserGetTxLogged(uint8_t ipproto, AppProto alproto, int AppLayerParserGetTxLogged(const Flow *f,
void *alstate, void *tx, uint32_t logger) void *alstate, void *tx, uint32_t logger)
{ {
SCEnter(); SCEnter();
uint8_t r = 0; uint8_t r = 0;
if (alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto]. if (alp_ctx.ctxs[f->protomap][f->alproto].StateGetTxLogged != NULL) {
StateGetTxLogged != NULL) { r = alp_ctx.ctxs[f->protomap][f->alproto].
r = alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].
StateGetTxLogged(alstate, tx, logger); StateGetTxLogged(alstate, tx, logger);
} }

@ -169,7 +169,7 @@ void AppLayerParserSetTransactionLogId(AppLayerParserState *pstate, uint64_t tx_
void AppLayerParserSetTxLogged(uint8_t ipproto, AppProto alproto, void *alstate, void AppLayerParserSetTxLogged(uint8_t ipproto, AppProto alproto, void *alstate,
void *tx, uint32_t logger); 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); void *tx, uint32_t logger);
uint64_t AppLayerParserGetTransactionInspectId(AppLayerParserState *pstate, uint8_t direction); uint64_t AppLayerParserGetTransactionInspectId(AppLayerParserState *pstate, uint8_t direction);

@ -138,11 +138,11 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
OutputLoggerThreadData *op_thread_data = (OutputLoggerThreadData *)thread_data; OutputLoggerThreadData *op_thread_data = (OutputLoggerThreadData *)thread_data;
OutputTxLogger *logger = list; OutputTxLogger *logger = list;
OutputLoggerThreadStore *store = op_thread_data->store; 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); BUG_ON(logger != NULL && store == NULL);
BUG_ON(logger == NULL && store == NULL); BUG_ON(logger == NULL && store == NULL);
#endif
if (p->flow == NULL) if (p->flow == NULL)
return TM_ECODE_OK; return TM_ECODE_OK;
@ -161,6 +161,8 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
goto end; 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); const uint64_t total_txs = AppLayerParserGetTxCnt(f, alstate);
uint64_t tx_id = AppLayerParserGetTransactionLogId(f->alparser); uint64_t tx_id = AppLayerParserGetTransactionLogId(f->alparser);
uint64_t max_id = tx_id; 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, 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, 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", SCLogDebug("tx_progress_ts %d tx_progress_tc %d",
tx_progress_ts, tx_progress_tc); tx_progress_ts, tx_progress_tc);
@ -204,8 +206,7 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
number_of_loggers++; number_of_loggers++;
if (AppLayerParserGetTxLogged(p->proto, alproto, alstate, tx, if (AppLayerParserGetTxLogged(f, alstate, tx, logger->id)) {
logger->id)) {
SCLogDebug("logger has already logged this transaction"); SCLogDebug("logger has already logged this transaction");
loggers_that_logged++; loggers_that_logged++;
goto next; goto next;
@ -246,9 +247,10 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
next: next:
logger = logger->next; logger = logger->next;
store = store->next; store = store->next;
#ifdef DEBUG_VALIDATION
BUG_ON(logger == NULL && store != NULL); BUG_ON(logger == NULL && store != NULL);
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 /* If all loggers logged set a flag and update the last tx_id

Loading…
Cancel
Save