From 70096873cebd9b6c7ab2aed95a13373df22865f3 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Wed, 26 Nov 2025 10:41:21 +0100 Subject: [PATCH] counters: threadvar init func Add initializion. Also fixes DetectDsizeIcmpv6Test01 using two different ThreadVar structs. --- src/alert-fastlog.c | 8 +- src/app-layer-detect-proto.c | 4 + src/app-layer-htp.c | 1 + src/app-layer-modbus.c | 10 +++ src/app-layer-smtp.c | 2 + src/app-layer.c | 1 + src/counters.c | 86 ++++++++++++-------- src/counters.h | 1 + src/detect-base64-decode.c | 4 + src/detect-bytemath.c | 2 + src/detect-content.c | 3 + src/detect-csum.c | 1 + src/detect-dce-stub-data.c | 4 + src/detect-detection-filter.c | 3 + src/detect-dsize.c | 5 +- src/detect-engine-dcepayload.c | 6 ++ src/detect-engine-payload.c | 1 + src/detect-engine-siggroup.c | 1 + src/detect-engine-state.c | 10 +++ src/detect-engine-tag.c | 6 ++ src/detect-fast-pattern.c | 1 + src/detect-flow.c | 1 + src/detect-flowbits.c | 3 + src/detect-flowint.c | 3 + src/detect-fragoffset.c | 1 + src/detect-hostbits.c | 2 + src/detect-icmp-id.c | 2 + src/detect-icode.c | 1 + src/detect-ipproto.c | 2 + src/detect-iprep.c | 11 +++ src/detect-l3proto.c | 3 + src/detect-lua.c | 12 +++ src/detect-parse.c | 1 + src/detect-pcre.c | 2 + src/detect-quic-cyu-hash.c | 1 + src/detect-quic-cyu-string.c | 1 + src/detect-replace.c | 1 + src/detect-rpc.c | 1 + src/detect-sameip.c | 1 + src/detect-tcp-ack.c | 1 + src/detect-threshold.c | 14 ++++ src/detect-urilen.c | 3 +- src/detect-xbits.c | 1 + src/tests/detect-engine-content-inspection.c | 9 +- src/tests/detect-http-client-body.c | 11 +++ src/tests/detect-http-cookie.c | 26 ++++++ src/tests/detect-http-header.c | 44 ++++++++++ src/tests/detect-http-host.c | 12 +++ src/tests/detect-http-method.c | 5 ++ src/tests/detect-http-raw-header.c | 37 +++++++++ src/tests/detect-http-server-body.c | 6 ++ src/tests/detect-http-stat-code.c | 19 +++++ src/tests/detect-http-stat-msg.c | 18 ++++ src/tests/detect-http-user-agent.c | 10 +++ src/tests/detect-tls-cert-fingerprint.c | 1 + src/tests/detect-tls-cert-issuer.c | 1 + src/tests/detect-tls-cert-serial.c | 1 + src/tests/detect-tls-cert-subject.c | 1 + src/tests/detect-tls-cert-validity.c | 3 + src/tests/detect-tls-certs.c | 1 + src/tests/detect-ttl.c | 1 + src/tests/detect.c | 78 +++++++++++++++--- src/tm-threads.c | 2 +- src/util-mpm-ac-ks.c | 1 + src/util-mpm-ac.c | 1 + src/util-mpm-hs.c | 1 + src/util-threshold-config.c | 10 +++ src/util-unittest-helper.c | 4 + 68 files changed, 476 insertions(+), 55 deletions(-) diff --git a/src/alert-fastlog.c b/src/alert-fastlog.c index 5bc45e87b3..3983aacbce 100644 --- a/src/alert-fastlog.c +++ b/src/alert-fastlog.c @@ -278,9 +278,9 @@ static int AlertFastLogTest01(void) uint16_t buflen = strlen((char *)buf); Packet *p = NULL; ThreadVars th_v; - DetectEngineThreadCtx *det_ctx; - memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); + p = UTHBuildPacket(buf, buflen, IPPROTO_TCP); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -296,6 +296,7 @@ static int AlertFastLogTest01(void) "Classtype:unknown; sid:1;)"); SigGroupBuild(de_ctx); + DetectEngineThreadCtx *det_ctx; DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, p); @@ -316,9 +317,9 @@ static int AlertFastLogTest02(void) uint16_t buflen = strlen((char *)buf); Packet *p = NULL; ThreadVars th_v; - DetectEngineThreadCtx *det_ctx; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p = UTHBuildPacket(buf, buflen, IPPROTO_TCP); @@ -335,6 +336,7 @@ static int AlertFastLogTest02(void) "Classtype:unknown; sid:1;)"); SigGroupBuild(de_ctx); + DetectEngineThreadCtx *det_ctx; DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); SigMatchSignatures(&th_v, de_ctx, det_ctx, p); diff --git a/src/app-layer-detect-proto.c b/src/app-layer-detect-proto.c index dba98e728c..b2fbaef879 100644 --- a/src/app-layer-detect-proto.c +++ b/src/app-layer-detect-proto.c @@ -3164,6 +3164,7 @@ static int AppLayerProtoDetectTest16(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&ssn, 0, sizeof(TcpSession)); p = UTHBuildPacket(NULL, 0, IPPROTO_TCP); @@ -3260,6 +3261,7 @@ static int AppLayerProtoDetectTest17(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&ssn, 0, sizeof(TcpSession)); p = UTHBuildPacketSrcDstPorts(http_buf1, http_buf1_len, IPPROTO_TCP, 12345, 88); @@ -3350,6 +3352,7 @@ static int AppLayerProtoDetectTest18(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&ssn, 0, sizeof(TcpSession)); p = UTHBuildPacket(http_buf1, http_buf1_len, IPPROTO_TCP); @@ -3436,6 +3439,7 @@ static int AppLayerProtoDetectTest19(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&ssn, 0, sizeof(TcpSession)); p = UTHBuildPacketSrcDstPorts(http_buf1, http_buf1_len, IPPROTO_TCP, 12345, 88); diff --git a/src/app-layer-htp.c b/src/app-layer-htp.c index cadb5ce1be..ce43997521 100644 --- a/src/app-layer-htp.c +++ b/src/app-layer-htp.c @@ -5536,6 +5536,7 @@ libhtp:\n\ FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); diff --git a/src/app-layer-modbus.c b/src/app-layer-modbus.c index a2767115ec..caba37b284 100644 --- a/src/app-layer-modbus.c +++ b/src/app-layer-modbus.c @@ -379,6 +379,7 @@ static int ModbusParserTest03(void) FAIL_IF_NULL(alp_tctx); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); @@ -512,6 +513,7 @@ static int ModbusParserTest05(void) FAIL_IF_NULL(alp_tctx); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); @@ -581,6 +583,7 @@ static int ModbusParserTest06(void) FAIL_IF_NULL(alp_tctx); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); @@ -650,6 +653,7 @@ static int ModbusParserTest07(void) FAIL_IF_NULL(alp_tctx); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); @@ -720,6 +724,7 @@ static int ModbusParserTest08(void) FAIL_IF_NULL(alp_tctx); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); @@ -931,6 +936,7 @@ static int ModbusParserTest11(void) FAIL_IF(alp_tctx == NULL); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); @@ -999,6 +1005,7 @@ static int ModbusParserTest12(void) FAIL_IF_NULL(alp_tctx); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); @@ -1159,6 +1166,7 @@ static int ModbusParserTest15(void) FAIL_IF_NULL(alp_tctx); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1241,6 +1249,7 @@ static int ModbusParserTest16(void) FAIL_IF_NULL(alp_tctx); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1420,6 +1429,7 @@ static int ModbusParserTest19(void) FAIL_IF_NULL(alp_tctx); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); diff --git a/src/app-layer-smtp.c b/src/app-layer-smtp.c index 7c0274bef6..e63b6c414f 100644 --- a/src/app-layer-smtp.c +++ b/src/app-layer-smtp.c @@ -3552,6 +3552,7 @@ static int SMTPParserTest12(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -3686,6 +3687,7 @@ static int SMTPParserTest13(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); diff --git a/src/app-layer.c b/src/app-layer.c index b07c2ee960..6c7852a15d 100644 --- a/src/app-layer.c +++ b/src/app-layer.c @@ -1389,6 +1389,7 @@ void AppLayerDeSetupCounters(void) memset(&pq, 0, sizeof(PacketQueueNoLock)); \ memset(&f, 0, sizeof(Flow)); \ memset(&tv, 0, sizeof(ThreadVars)); \ + StatsThreadInit(&tv); \ memset(&tcph, 0, sizeof(TCPHdr)); \ \ FLOW_INITIALIZE(&f); \ diff --git a/src/counters.c b/src/counters.c index aa94365a1a..9d7b8cdbe3 100644 --- a/src/counters.c +++ b/src/counters.c @@ -1108,6 +1108,24 @@ static void CountersIdHashFreeFunc(void *data) SCFree(data); } +static int StatsThreadSetupPublic(StatsPublicThreadContext *pctx) +{ + size_t array_size = pctx->curr_id + 1; + pctx->pc_array = SCCalloc(array_size, sizeof(StatsCounter *)); + if (pctx->pc_array == NULL) { + return -1; + } + for (StatsCounter *pc = pctx->head; pc != NULL; pc = pc->next) { + BUG_ON(pctx->pc_array[pc->id] != NULL); + pctx->pc_array[pc->id] = pc; + } + + pctx->copy_of_private = SCCalloc(array_size, sizeof(StatsLocalCounter)); + if (pctx->copy_of_private == NULL) { + return -1; + } + return 0; +} /** \internal * \brief Adds a TM to the clubbed TM table. Multiple instances of the same TM @@ -1156,19 +1174,7 @@ static int StatsThreadRegister(const char *thread_name, StatsPublicThreadContext pc = pc->next; } - size_t array_size = pctx->curr_id + 1; - pctx->pc_array = SCCalloc(array_size, sizeof(StatsCounter *)); - if (pctx->pc_array == NULL) { - SCMutexUnlock(&stats_ctx->sts_lock); - return 0; - } - for (pc = pctx->head; pc != NULL; pc = pc->next) { - BUG_ON(pctx->pc_array[pc->id] != NULL); - pctx->pc_array[pc->id] = pc; - } - - pctx->copy_of_private = SCCalloc(array_size, sizeof(StatsLocalCounter)); - if (pctx->copy_of_private == NULL) { + if (StatsThreadSetupPublic(pctx) != 0) { SCMutexUnlock(&stats_ctx->sts_lock); return 0; } @@ -1268,6 +1274,17 @@ int StatsSetupPrivate(ThreadVars *tv) return 0; } +static void StatsThreadInitPublic(StatsPublicThreadContext *pctx) +{ + memset(pctx, 0x00, sizeof(*pctx)); + SCSpinInit(&pctx->lock, 0); +} + +void StatsThreadInit(ThreadVars *tv) +{ + StatsThreadInitPublic(&tv->perf_public_ctx); +} + /** * \brief the private stats store with the public stats store * @@ -1393,7 +1410,7 @@ static StatsCounterId RegisterCounter( static int StatsTestCounterReg02(void) { StatsPublicThreadContext pctx; - memset(&pctx, 0, sizeof(StatsPublicThreadContext)); + StatsThreadInitPublic(&pctx); StatsCounterId id = RegisterCounter(NULL, NULL, &pctx); FAIL_IF_NOT(id.id == 0); @@ -1403,7 +1420,7 @@ static int StatsTestCounterReg02(void) static int StatsTestCounterReg03(void) { StatsPublicThreadContext pctx; - memset(&pctx, 0, sizeof(StatsPublicThreadContext)); + StatsThreadInitPublic(&pctx); StatsCounterId id = RegisterCounter("t1", "c1", &pctx); FAIL_IF_NOT(id.id == 1); @@ -1415,7 +1432,7 @@ static int StatsTestCounterReg03(void) static int StatsTestCounterReg04(void) { StatsPublicThreadContext pctx; - memset(&pctx, 0, sizeof(StatsPublicThreadContext)); + StatsThreadInitPublic(&pctx); StatsCounterId c1 = RegisterCounter("t1", "c1", &pctx); FAIL_IF_NOT(c1.id == 1); @@ -1434,12 +1451,12 @@ static int StatsTestGetCntArray05(void) { ThreadVars tv; memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); StatsCounterId c1 = RegisterCounter("t1", "c1", &tv.perf_public_ctx); FAIL_IF(c1.id != 1); int r = StatsGetAllCountersArray(NULL, &tv.perf_private_ctx); FAIL_IF_NOT(r == -1); - StatsReleaseCounters(tv.perf_public_ctx.head); - StatsReleasePrivateThreadContext(&tv.perf_private_ctx); + StatsThreadCleanup(&tv); PASS; } @@ -1447,12 +1464,13 @@ static int StatsTestGetCntArray06(void) { ThreadVars tv; memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); StatsCounterId c1 = RegisterCounter("t1", "c1", &tv.perf_public_ctx); FAIL_IF(c1.id != 1); + StatsThreadSetupPublic(&tv.perf_public_ctx); int r = StatsGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx); FAIL_IF_NOT(r == 0); - StatsReleaseCounters(tv.perf_public_ctx.head); - StatsReleasePrivateThreadContext(&tv.perf_private_ctx); + StatsThreadCleanup(&tv); PASS; } @@ -1460,11 +1478,13 @@ static int StatsTestCntArraySize07(void) { ThreadVars tv; memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); StatsPrivateThreadContext *pca = NULL; StatsCounterId id1 = RegisterCounter("t1", "c1", &tv.perf_public_ctx); StatsCounterId id2 = RegisterCounter("t2", "c2", &tv.perf_public_ctx); + StatsThreadSetupPublic(&tv.perf_public_ctx); StatsGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx); pca = &tv.perf_private_ctx; @@ -1473,9 +1493,7 @@ static int StatsTestCntArraySize07(void) FAIL_IF_NOT(pca->size == 2); - StatsReleaseCounters(tv.perf_public_ctx.head); - StatsReleasePrivateThreadContext(pca); - + StatsThreadCleanup(&tv); PASS; } @@ -1483,7 +1501,9 @@ static int StatsTestUpdateCounter08(void) { ThreadVars tv; memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); StatsCounterId c1 = RegisterCounter("t1", "c1", &tv.perf_public_ctx); + StatsThreadSetupPublic(&tv.perf_public_ctx); StatsGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx); StatsPrivateThreadContext *pca = &tv.perf_private_ctx; @@ -1491,8 +1511,7 @@ static int StatsTestUpdateCounter08(void) StatsAddUI64(&tv, c1, 100); FAIL_IF_NOT(pca->head[c1.id].value == 101); - StatsReleaseCounters(tv.perf_public_ctx.head); - StatsReleasePrivateThreadContext(pca); + StatsThreadCleanup(&tv); PASS; } @@ -1500,6 +1519,7 @@ static int StatsTestUpdateCounter09(void) { ThreadVars tv; memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); StatsCounterId c1 = RegisterCounter("t1", "c1", &tv.perf_public_ctx); RegisterCounter("t2", "c2", &tv.perf_public_ctx); @@ -1507,6 +1527,7 @@ static int StatsTestUpdateCounter09(void) RegisterCounter("t4", "c4", &tv.perf_public_ctx); StatsCounterId c5 = RegisterCounter("t5", "c5", &tv.perf_public_ctx); + StatsThreadSetupPublic(&tv.perf_public_ctx); StatsGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx); StatsPrivateThreadContext *pca = &tv.perf_private_ctx; @@ -1516,9 +1537,7 @@ static int StatsTestUpdateCounter09(void) FAIL_IF_NOT(pca->head[c1.id].value == 0); FAIL_IF_NOT(pca->head[c5.id].value == 101); - StatsReleaseCounters(tv.perf_public_ctx.head); - StatsReleasePrivateThreadContext(pca); - + StatsThreadCleanup(&tv); PASS; } @@ -1526,11 +1545,13 @@ static int StatsTestUpdateGlobalCounter10(void) { ThreadVars tv; memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); StatsCounterId c1 = RegisterCounter("t1", "c1", &tv.perf_public_ctx); StatsCounterId c2 = RegisterCounter("t2", "c2", &tv.perf_public_ctx); StatsCounterId c3 = RegisterCounter("t3", "c3", &tv.perf_public_ctx); + StatsThreadSetupPublic(&tv.perf_public_ctx); StatsGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx); StatsPrivateThreadContext *pca = &tv.perf_private_ctx; @@ -1545,9 +1566,7 @@ static int StatsTestUpdateGlobalCounter10(void) FAIL_IF_NOT(100 == tv.perf_public_ctx.copy_of_private[c2.id].value); FAIL_IF_NOT(101 == tv.perf_public_ctx.copy_of_private[c3.id].value); - StatsReleaseCounters(tv.perf_public_ctx.head); - StatsReleasePrivateThreadContext(pca); - + StatsThreadCleanup(&tv); PASS; } @@ -1555,12 +1574,14 @@ static int StatsTestCounterValues11(void) { ThreadVars tv; memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); StatsCounterId c1 = RegisterCounter("t1", "c1", &tv.perf_public_ctx); StatsCounterId c2 = RegisterCounter("t2", "c2", &tv.perf_public_ctx); StatsCounterId c3 = RegisterCounter("t3", "c3", &tv.perf_public_ctx); StatsCounterId c4 = RegisterCounter("t4", "c4", &tv.perf_public_ctx); + StatsThreadSetupPublic(&tv.perf_public_ctx); StatsGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx); StatsPrivateThreadContext *pca = &tv.perf_private_ctx; @@ -1576,8 +1597,7 @@ static int StatsTestCounterValues11(void) FAIL_IF_NOT(257 == tv.perf_public_ctx.copy_of_private[c3.id].value); FAIL_IF_NOT(16843024 == tv.perf_public_ctx.copy_of_private[c4.id].value); - StatsReleaseCounters(tv.perf_public_ctx.head); - StatsReleasePrivateThreadContext(pca); + StatsThreadCleanup(&tv); PASS; } diff --git a/src/counters.h b/src/counters.h index 49d26a8070..0bce302e0f 100644 --- a/src/counters.h +++ b/src/counters.h @@ -147,6 +147,7 @@ void StatsCounterAvgAddI64(struct ThreadVars_ *tv, StatsCounterAvgId id, int64_t /* utility functions */ uint64_t StatsGetLocalCounterValue(struct ThreadVars_ *, StatsCounterId); +void StatsThreadInit(struct ThreadVars_ *); int StatsSetupPrivate(struct ThreadVars_ *); void StatsThreadCleanup(struct ThreadVars_ *); diff --git a/src/detect-base64-decode.c b/src/detect-base64-decode.c index c5dc658073..4818ab768c 100644 --- a/src/detect-base64-decode.c +++ b/src/detect-base64-decode.c @@ -373,6 +373,7 @@ static int DetectBase64DecodeTestDecode(void) }; memset(&tv, 0, sizeof(tv)); + StatsThreadInit(&tv); if ((de_ctx = DetectEngineCtxInit()) == NULL) { goto end; @@ -429,6 +430,7 @@ static int DetectBase64DecodeTestDecodeWithOffset(void) char decoded[] = "Hello World"; memset(&tv, 0, sizeof(tv)); + StatsThreadInit(&tv); if ((de_ctx = DetectEngineCtxInit()) == NULL) { goto end; @@ -488,6 +490,7 @@ static int DetectBase64DecodeTestDecodeLargeOffset(void) }; memset(&tv, 0, sizeof(tv)); + StatsThreadInit(&tv); if ((de_ctx = DetectEngineCtxInit()) == NULL) { goto end; @@ -545,6 +548,7 @@ static int DetectBase64DecodeTestDecodeRelative(void) char decoded[] = "Hello World"; memset(&tv, 0, sizeof(tv)); + StatsThreadInit(&tv); if ((de_ctx = DetectEngineCtxInit()) == NULL) { goto end; diff --git a/src/detect-bytemath.c b/src/detect-bytemath.c index 2ecaff646a..81c7bdb7b9 100644 --- a/src/detect-bytemath.c +++ b/src/detect-bytemath.c @@ -812,6 +812,7 @@ static int DetectByteMathPacket01(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); p = UTHBuildPacketReal(buf, sizeof(buf), IPPROTO_UDP, @@ -913,6 +914,7 @@ static int DetectByteMathPacket02(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); p = UTHBuildPacketReal(buf, sizeof(buf), IPPROTO_UDP, "192.168.1.5", "192.168.1.1", 41424, 53); diff --git a/src/detect-content.c b/src/detect-content.c index 2b5d84fc6b..41f466068a 100644 --- a/src/detect-content.c +++ b/src/detect-content.c @@ -1094,6 +1094,7 @@ static int DetectContentLongPatternMatchTest(uint8_t *raw_eth_pkt, uint16_t pkts DetectEngineThreadCtx *det_ctx = NULL; memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); FlowInitConfig(FLOW_QUIET); DecodeEthernet(&th_v, &dtv, p, raw_eth_pkt, pktsize); @@ -1904,6 +1905,7 @@ static int SigTestPositiveTestContent(const char *rule, uint8_t *buf) DetectEngineThreadCtx *det_ctx = NULL; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); Packet *p = UTHBuildPacket(buf, buflen, IPPROTO_TCP); FAIL_IF_NULL(p); @@ -2092,6 +2094,7 @@ static int SigTestNegativeTestContent(const char *rule, uint8_t *buf) DetectEngineThreadCtx *det_ctx = NULL; int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p = UTHBuildPacket(buf, buflen, IPPROTO_TCP); diff --git a/src/detect-csum.c b/src/detect-csum.c index 1d865bfb71..24e273da34 100644 --- a/src/detect-csum.c +++ b/src/detect-csum.c @@ -935,6 +935,7 @@ static int DetectCsumICMPV6Test01(void) PacketCopyData(p, pkt, sizeof(pkt)); memset(&tv, 0, sizeof(tv)); + StatsThreadInit(&tv); memset(&dtv, 0, sizeof(dtv)); StreamTcpInitConfig(true); diff --git a/src/detect-dce-stub-data.c b/src/detect-dce-stub-data.c index 9e25c1ccbc..46aa598dab 100644 --- a/src/detect-dce-stub-data.c +++ b/src/detect-dce-stub-data.c @@ -638,6 +638,7 @@ static int DetectDceStubDataTestParse02(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1187,6 +1188,7 @@ static int DetectDceStubDataTestParse03(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1370,6 +1372,7 @@ static int DetectDceStubDataTestParse04(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1655,6 +1658,7 @@ static int DetectDceStubDataTestParse05(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); diff --git a/src/detect-detection-filter.c b/src/detect-detection-filter.c index 7614bf2fbd..bcbbbebc21 100644 --- a/src/detect-detection-filter.c +++ b/src/detect-detection-filter.c @@ -381,6 +381,7 @@ static int DetectDetectionFilterTestSig1(void) ThresholdInit(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); Packet *p = UTHBuildPacketReal(NULL, 0, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); @@ -438,6 +439,7 @@ static int DetectDetectionFilterTestSig2(void) ThresholdInit(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); Packet *p = UTHBuildPacketReal(NULL, 0, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); @@ -496,6 +498,7 @@ static int DetectDetectionFilterTestSig3(void) ThresholdInit(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); Packet *p = UTHBuildPacketReal(NULL, 0, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); diff --git a/src/detect-dsize.c b/src/detect-dsize.c index a44742e18c..90371d0113 100644 --- a/src/detect-dsize.c +++ b/src/detect-dsize.c @@ -588,20 +588,19 @@ static int DetectDsizeIcmpv6Test01(void) Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); - ThreadVars tv; DecodeThreadVars dtv; ThreadVars th_v; DetectEngineThreadCtx *det_ctx = NULL; - memset(&tv, 0, sizeof(ThreadVars)); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); FlowInitConfig(FLOW_QUIET); p->src.family = AF_INET6; p->dst.family = AF_INET6; - DecodeIPV6(&tv, &dtv, p, raw_icmpv6, sizeof(raw_icmpv6)); + DecodeIPV6(&th_v, &dtv, p, raw_icmpv6, sizeof(raw_icmpv6)); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); diff --git a/src/detect-engine-dcepayload.c b/src/detect-engine-dcepayload.c index c354c62483..cb58077fc6 100644 --- a/src/detect-engine-dcepayload.c +++ b/src/detect-engine-dcepayload.c @@ -95,6 +95,7 @@ static int DcePayloadTest15(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); @@ -178,6 +179,7 @@ static int DcePayloadTest16(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); @@ -261,6 +263,7 @@ static int DcePayloadTest17(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); @@ -343,6 +346,7 @@ static int DcePayloadTest18(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); @@ -425,6 +429,7 @@ static int DcePayloadTest19(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); @@ -507,6 +512,7 @@ static int DcePayloadTest20(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); diff --git a/src/detect-engine-payload.c b/src/detect-engine-payload.c index 1733b6c372..da57a49877 100644 --- a/src/detect-engine-payload.c +++ b/src/detect-engine-payload.c @@ -645,6 +645,7 @@ static int PayloadTestSig13(void) memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); diff --git a/src/detect-engine-siggroup.c b/src/detect-engine-siggroup.c index 3d4c866195..513cfd878b 100644 --- a/src/detect-engine-siggroup.c +++ b/src/detect-engine-siggroup.c @@ -951,6 +951,7 @@ static int SigGroupHeadTest06(void) ThreadVars th_v; memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); Packet *p = UTHBuildPacketSrcDst(NULL, 0, IPPROTO_ICMP, "192.168.1.1", "1.2.3.4"); FAIL_IF_NULL(p); diff --git a/src/detect-engine-state.c b/src/detect-engine-state.c index 74c70b1cf1..79d7fe8e66 100644 --- a/src/detect-engine-state.c +++ b/src/detect-engine-state.c @@ -467,6 +467,7 @@ static int DeStateSigTest01(void) FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -554,6 +555,7 @@ static int DeStateSigTest02(void) FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -666,6 +668,7 @@ static int DeStateSigTest03(void) FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&ssn, 0, sizeof(ssn)); DetectEngineThreadCtx *det_ctx = NULL; @@ -750,6 +753,7 @@ static int DeStateSigTest04(void) FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&ssn, 0, sizeof(ssn)); DetectEngineThreadCtx *det_ctx = NULL; @@ -831,6 +835,7 @@ static int DeStateSigTest05(void) FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&ssn, 0, sizeof(ssn)); DetectEngineThreadCtx *det_ctx = NULL; @@ -915,6 +920,7 @@ static int DeStateSigTest06(void) FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&ssn, 0, sizeof(ssn)); DetectEngineThreadCtx *det_ctx = NULL; @@ -1000,6 +1006,7 @@ static int DeStateSigTest07(void) FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&ssn, 0, sizeof(ssn)); DetectEngineThreadCtx *det_ctx = NULL; @@ -1100,6 +1107,7 @@ static int DeStateSigTest08(void) FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&ssn, 0, sizeof(ssn)); DetectEngineThreadCtx *det_ctx = NULL; @@ -1230,6 +1238,7 @@ static int DeStateSigTest09(void) FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&ssn, 0, sizeof(ssn)); DetectEngineThreadCtx *det_ctx = NULL; @@ -1358,6 +1367,7 @@ static int DeStateSigTest10(void) FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&ssn, 0, sizeof(ssn)); DetectEngineThreadCtx *det_ctx = NULL; diff --git a/src/detect-engine-tag.c b/src/detect-engine-tag.c index a27644986c..d5a5e6304d 100644 --- a/src/detect-engine-tag.c +++ b/src/detect-engine-tag.c @@ -714,6 +714,7 @@ static int DetectTagTestPacket02 (void) DetectEngineThreadCtx *det_ctx = NULL; memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); StorageCleanup(); StorageInit(); @@ -818,6 +819,7 @@ static int DetectTagTestPacket03 (void) DetectEngineThreadCtx *det_ctx = NULL; memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); StorageCleanup(); StorageInit(); @@ -937,6 +939,7 @@ static int DetectTagTestPacket04 (void) DetectEngineThreadCtx *det_ctx = NULL; memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -1057,6 +1060,7 @@ static int DetectTagTestPacket05 (void) DetectEngineThreadCtx *det_ctx = NULL; memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -1182,6 +1186,7 @@ static int DetectTagTestPacket06 (void) DetectEngineThreadCtx *det_ctx = NULL; memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -1303,6 +1308,7 @@ static int DetectTagTestPacket07 (void) DetectEngineThreadCtx *det_ctx = NULL; memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); diff --git a/src/detect-fast-pattern.c b/src/detect-fast-pattern.c index 3a0307a7b4..da708876b9 100644 --- a/src/detect-fast-pattern.c +++ b/src/detect-fast-pattern.c @@ -1040,6 +1040,7 @@ static int DetectFastPatternTest14(void) DetectEngineThreadCtx *det_ctx = NULL; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); Packet *p = UTHBuildPacket(buf, buflen, IPPROTO_TCP); FAIL_IF_NULL(p); diff --git a/src/detect-flow.c b/src/detect-flow.c index 1c4e7c5c4b..7bce2e77c2 100644 --- a/src/detect-flow.c +++ b/src/detect-flow.c @@ -1001,6 +1001,7 @@ static int DetectFlowSigTest01(void) DecodeThreadVars dtv; memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); Packet *p = UTHBuildPacket(buf, buflen, IPPROTO_TCP); FAIL_IF_NULL(p); diff --git a/src/detect-flowbits.c b/src/detect-flowbits.c index deb4197a2a..2dfe66e3b3 100644 --- a/src/detect-flowbits.c +++ b/src/detect-flowbits.c @@ -1592,6 +1592,7 @@ static int FlowBitsTestSig06(void) uint32_t idx = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(Flow)); memset(&flowvar, 0, sizeof(GenericVar)); @@ -1666,6 +1667,7 @@ static int FlowBitsTestSig07(void) uint32_t idx = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(Flow)); memset(&flowvar, 0, sizeof(GenericVar)); @@ -1742,6 +1744,7 @@ static int FlowBitsTestSig08(void) uint32_t idx = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(Flow)); memset(&flowvar, 0, sizeof(GenericVar)); diff --git a/src/detect-flowint.c b/src/detect-flowint.c index c813ccbf4e..8264920c17 100644 --- a/src/detect-flowint.c +++ b/src/detect-flowint.c @@ -1115,6 +1115,7 @@ static int DetectFlowintTestPacket01Real(void) ThreadVars th_v; DetectEngineThreadCtx *det_ctx = NULL; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF(de_ctx == NULL); @@ -1188,6 +1189,7 @@ static int DetectFlowintTestPacket02Real(void) ThreadVars th_v; DetectEngineThreadCtx *det_ctx = NULL; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF(de_ctx == NULL); @@ -1264,6 +1266,7 @@ static int DetectFlowintTestPacket03Real(void) ThreadVars th_v; DetectEngineThreadCtx *det_ctx = NULL; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF(de_ctx == NULL); diff --git a/src/detect-fragoffset.c b/src/detect-fragoffset.c index 42f3ca2392..326f173a1a 100644 --- a/src/detect-fragoffset.c +++ b/src/detect-fragoffset.c @@ -265,6 +265,7 @@ static int DetectFragOffsetMatchTest01 (void) memset(&ip4h, 0, sizeof(IPV4Hdr)); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); FlowInitConfig(FLOW_QUIET); diff --git a/src/detect-hostbits.c b/src/detect-hostbits.c index 036f63234b..a46a7c3018 100644 --- a/src/detect-hostbits.c +++ b/src/detect-hostbits.c @@ -574,6 +574,7 @@ static int HostBitsTestSig01(void) DetectEngineCtx *de_ctx = NULL; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p->src.family = AF_INET; p->dst.family = AF_INET; p->payload = buf; @@ -676,6 +677,7 @@ static int HostBitsTestSig03(void) int idx = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p->src.family = AF_INET; p->dst.family = AF_INET; p->payload = buf; diff --git a/src/detect-icmp-id.c b/src/detect-icmp-id.c index 201f296753..0c6091f8a8 100644 --- a/src/detect-icmp-id.c +++ b/src/detect-icmp-id.c @@ -297,6 +297,7 @@ static int DetectIcmpIdMatchTest01 (void) DetectEngineThreadCtx *det_ctx = NULL; memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); p = UTHBuildPacket(NULL, 0, IPPROTO_ICMP); p->l4.vars.icmpv4.id = htons(21781); @@ -372,6 +373,7 @@ static int DetectIcmpIdMatchTest02 (void) memset(&ip4h, 0, sizeof(IPV4Hdr)); memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); FlowInitConfig(FLOW_QUIET); diff --git a/src/detect-icode.c b/src/detect-icode.c index 30cfa8dff2..7b45ffb7e0 100644 --- a/src/detect-icode.c +++ b/src/detect-icode.c @@ -333,6 +333,7 @@ static int DetectICodeMatchTest01(void) DetectEngineThreadCtx *det_ctx; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); Packet *p = UTHBuildPacket(NULL, 0, IPPROTO_ICMP); FAIL_IF_NULL(p); diff --git a/src/detect-ipproto.c b/src/detect-ipproto.c index ddb0071c55..9daab115c8 100644 --- a/src/detect-ipproto.c +++ b/src/detect-ipproto.c @@ -1918,6 +1918,7 @@ static int DetectIPProtoTestSig2(void) p->proto = 0; memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); FlowInitConfig(FLOW_QUIET); DecodeEthernet(&th_v, &dtv, p, raw_eth, sizeof(raw_eth)); @@ -1970,6 +1971,7 @@ static int DetectIPProtoTestSig3(void) p->proto = 0; memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); FlowInitConfig(FLOW_QUIET); DecodeEthernet(&th_v, &dtv, p, raw_eth, sizeof(raw_eth)); diff --git a/src/detect-iprep.c b/src/detect-iprep.c index df4b40da78..8bd230efb7 100644 --- a/src/detect-iprep.c +++ b/src/detect-iprep.c @@ -358,6 +358,7 @@ static int DetectIPRepTest01(void) HostInitConfig(HOST_QUIET); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); FAIL_IF_NULL(de_ctx); FAIL_IF_NULL(p); @@ -409,6 +410,7 @@ static int DetectIPRepTest02(void) HostInitConfig(HOST_QUIET); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); FAIL_IF_NULL(de_ctx); FAIL_IF_NULL(p); @@ -460,6 +462,7 @@ static int DetectIPRepTest03(void) HostInitConfig(HOST_QUIET); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); FAIL_IF_NULL(de_ctx); FAIL_IF_NULL(p); @@ -511,6 +514,7 @@ static int DetectIPRepTest04(void) HostInitConfig(HOST_QUIET); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); FAIL_IF_NULL(de_ctx); FAIL_IF_NULL(p); @@ -563,6 +567,7 @@ static int DetectIPRepTest05(void) HostInitConfig(HOST_QUIET); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); FAIL_IF_NULL(de_ctx); FAIL_IF_NULL(p); @@ -614,6 +619,7 @@ static int DetectIPRepTest06(void) HostInitConfig(HOST_QUIET); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); FAIL_IF_NULL(de_ctx); FAIL_IF_NULL(p); @@ -665,6 +671,7 @@ static int DetectIPRepTest07(void) HostInitConfig(HOST_QUIET); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); FAIL_IF_NULL(de_ctx); FAIL_IF_NULL(p); @@ -716,6 +723,7 @@ static int DetectIPRepTest08(void) HostInitConfig(HOST_QUIET); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); FAIL_IF_NULL(de_ctx); FAIL_IF_NULL(p); @@ -768,6 +776,7 @@ static int DetectIPRepTest09(void) HostInitConfig(HOST_QUIET); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); FAIL_IF_NULL(de_ctx); FAIL_IF_NULL(p); @@ -832,6 +841,7 @@ static int DetectIPRepTest10(void) HostInitConfig(HOST_QUIET); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); FAIL_IF_NULL(de_ctx); FAIL_IF_NULL(p); @@ -881,6 +891,7 @@ static int DetectIPRepTest11(void) HostInitConfig(HOST_QUIET); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); FAIL_IF_NULL(de_ctx); FAIL_IF_NULL(p); diff --git a/src/detect-l3proto.c b/src/detect-l3proto.c index 1588d3e758..963a273d27 100644 --- a/src/detect-l3proto.c +++ b/src/detect-l3proto.c @@ -126,6 +126,7 @@ static int DetectL3protoTestSig1(void) IPV4Hdr ip4h; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p->src.family = AF_INET; p->dst.family = AF_INET; @@ -186,6 +187,7 @@ static int DetectL3protoTestSig2(void) IPV6Hdr ip6h; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p->src.family = AF_INET6; p->dst.family = AF_INET6; @@ -246,6 +248,7 @@ static int DetectL3protoTestSig3(void) IPV6Hdr ip6h; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p->src.family = AF_INET6; p->dst.family = AF_INET6; diff --git a/src/detect-lua.c b/src/detect-lua.c index 7195c05a37..263e8fa8ef 100644 --- a/src/detect-lua.c +++ b/src/detect-lua.c @@ -834,6 +834,7 @@ static int LuaMatchTest01(void) ut_script = script; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -955,6 +956,7 @@ static int LuaMatchTest01a(void) ut_script = script; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1076,6 +1078,7 @@ static int LuaMatchTest02(void) ut_script = script; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1187,6 +1190,7 @@ static int LuaMatchTest02a(void) ut_script = script; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1297,6 +1301,7 @@ static int LuaMatchTest03(void) ut_script = script; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1406,6 +1411,7 @@ static int LuaMatchTest03a(void) ut_script = script; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1513,6 +1519,7 @@ static int LuaMatchTest04(void) ut_script = script; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1632,6 +1639,7 @@ static int LuaMatchTest04a(void) ut_script = script; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1744,6 +1752,7 @@ static int LuaMatchTest05(void) ut_script = script; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1856,6 +1865,7 @@ static int LuaMatchTest05a(void) ut_script = script; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1975,6 +1985,7 @@ static int LuaMatchTest06(void) ut_script = script; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2092,6 +2103,7 @@ static int LuaMatchTest06a(void) ut_script = script; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); diff --git a/src/detect-parse.c b/src/detect-parse.c index 44c2ef1fa0..8202470d70 100644 --- a/src/detect-parse.c +++ b/src/detect-parse.c @@ -4747,6 +4747,7 @@ static int SigTestBidirec04 (void) DetectEngineThreadCtx *det_ctx; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); FlowInitConfig(FLOW_QUIET); DecodeEthernet(&th_v, &dtv, p, rawpkt1_ether, sizeof(rawpkt1_ether)); diff --git a/src/detect-pcre.c b/src/detect-pcre.c index f2eb8171b3..091e6b4308 100644 --- a/src/detect-pcre.c +++ b/src/detect-pcre.c @@ -1726,6 +1726,7 @@ static int DetectPcreTxBodyChunksTest02(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1875,6 +1876,7 @@ static int DetectPcreTxBodyChunksTest03(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); diff --git a/src/detect-quic-cyu-hash.c b/src/detect-quic-cyu-hash.c index 37d8f7afff..0702f83bd3 100644 --- a/src/detect-quic-cyu-hash.c +++ b/src/detect-quic-cyu-hash.c @@ -199,6 +199,7 @@ static int DetectQuicCyuHashTest01(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); p = UTHBuildPacketReal(buf, sizeof(buf), IPPROTO_UDP, "192.168.1.5", "192.168.1.1", 41424, 443); diff --git a/src/detect-quic-cyu-string.c b/src/detect-quic-cyu-string.c index 28ff2b77bf..6b250971a6 100644 --- a/src/detect-quic-cyu-string.c +++ b/src/detect-quic-cyu-string.c @@ -197,6 +197,7 @@ static int DetectQuicCyuStringTest01(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); p = UTHBuildPacketReal(buf, sizeof(buf), IPPROTO_UDP, "192.168.1.5", "192.168.1.1", 41424, 443); diff --git a/src/detect-replace.c b/src/detect-replace.c index 5ee8297b03..c6c84a2169 100644 --- a/src/detect-replace.c +++ b/src/detect-replace.c @@ -238,6 +238,7 @@ int DetectReplaceLongPatternMatchTest(uint8_t *raw_eth_pkt, uint16_t pktsize, ThreadVars th_v; memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineThreadCtx *det_ctx = NULL; if (pp == NULL) { diff --git a/src/detect-rpc.c b/src/detect-rpc.c index 0b55165bad..48f09ccdc1 100644 --- a/src/detect-rpc.c +++ b/src/detect-rpc.c @@ -479,6 +479,7 @@ static int DetectRpcTestSig01(void) DetectEngineThreadCtx *det_ctx; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p = UTHBuildPacket(buf, buflen, IPPROTO_UDP); diff --git a/src/detect-sameip.c b/src/detect-sameip.c index 8de6d93eff..bbc6782e5b 100644 --- a/src/detect-sameip.c +++ b/src/detect-sameip.c @@ -118,6 +118,7 @@ static int DetectSameipSigTest01(void) DetectEngineThreadCtx *det_ctx; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); /* First packet has same IPs */ Packet *p1 = UTHBuildPacketSrcDst(buf, buflen, IPPROTO_TCP, "1.2.3.4", "1.2.3.4"); diff --git a/src/detect-tcp-ack.c b/src/detect-tcp-ack.c index d9fc9e1cbf..64c889084c 100644 --- a/src/detect-tcp-ack.c +++ b/src/detect-tcp-ack.c @@ -187,6 +187,7 @@ static int DetectAckSigTest01(void) { ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineThreadCtx *det_ctx = NULL; /* TCP w/ack=42 */ diff --git a/src/detect-threshold.c b/src/detect-threshold.c index 6f3c21a64a..185b17d3b6 100644 --- a/src/detect-threshold.c +++ b/src/detect-threshold.c @@ -574,6 +574,7 @@ static int DetectThresholdTestSig1(void) ThresholdInit(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p = UTHBuildPacketReal((uint8_t *)"A", 1, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); @@ -675,6 +676,7 @@ static int DetectThresholdTestSig2(void) ThresholdInit(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p = UTHBuildPacketReal((uint8_t *)"A", 1, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); @@ -745,6 +747,7 @@ static int DetectThresholdTestSig3(void) { ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); ThresholdInit(); Packet *p = UTHBuildPacketReal((uint8_t *)"A", 1, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); @@ -810,6 +813,7 @@ static int DetectThresholdTestSig4(void) ThresholdInit(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p = UTHBuildPacketReal((uint8_t *)"A", 1, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); @@ -884,6 +888,7 @@ static int DetectThresholdTestSig5(void) ThresholdInit(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p = UTHBuildPacketReal((uint8_t *)"A", 1, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -965,6 +970,7 @@ static int DetectThresholdTestSig6Ticks(void) ThresholdInit(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p = UTHBuildPacketReal((uint8_t *)"A", 1, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -1054,6 +1060,7 @@ static int DetectThresholdTestSig7(void) ThresholdInit(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p = UTHBuildPacketReal((uint8_t *)"A", 1, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); @@ -1143,6 +1150,7 @@ static int DetectThresholdTestSig8(void) ThresholdInit(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p = UTHBuildPacketReal((uint8_t *)"A", 1, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); @@ -1232,6 +1240,7 @@ static int DetectThresholdTestSig9(void) ThresholdInit(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p = UTHBuildPacketReal((uint8_t *)"A", 1, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); @@ -1321,6 +1330,7 @@ static int DetectThresholdTestSig10(void) ThresholdInit(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p = UTHBuildPacketReal((uint8_t *)"A", 1, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); @@ -1410,6 +1420,7 @@ static int DetectThresholdTestSig11(void) ThresholdInit(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p = UTHBuildPacketReal((uint8_t *)"A", 1, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); @@ -1499,6 +1510,7 @@ static int DetectThresholdTestSig12(void) ThresholdInit(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p = UTHBuildPacketReal((uint8_t *)"A", 1, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); @@ -1593,6 +1605,7 @@ static int DetectThresholdTestSig13(void) ThresholdInit(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p = UTHBuildPacketReal((uint8_t *)"A", 1, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); FAIL_IF_NULL(p); @@ -1665,6 +1678,7 @@ static int DetectThresholdTestSig14(void) ThresholdInit(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p1 = UTHBuildPacketReal((uint8_t *)"A", 1, IPPROTO_TCP, "1.1.1.1", "2.2.2.2", 1024, 80); p2 = UTHBuildPacketReal((uint8_t *)"A", 1, IPPROTO_TCP, "1.1.1.1", "3.3.3.3", 1024, 80); FAIL_IF_NULL(p1); diff --git a/src/detect-urilen.c b/src/detect-urilen.c index ebbd5876b0..99c1bfa8d5 100644 --- a/src/detect-urilen.c +++ b/src/detect-urilen.c @@ -464,6 +464,7 @@ static int DetectUrilenSigTest01(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -539,4 +540,4 @@ void DetectUrilenRegisterTests(void) UtRegisterTest("DetectUrilenSetpTest01", DetectUrilenSetpTest01); UtRegisterTest("DetectUrilenSigTest01", DetectUrilenSigTest01); } -#endif /* UNITTESTS */ \ No newline at end of file +#endif /* UNITTESTS */ diff --git a/src/detect-xbits.c b/src/detect-xbits.c index 06ca78346f..3ae34ef335 100644 --- a/src/detect-xbits.c +++ b/src/detect-xbits.c @@ -552,6 +552,7 @@ static int XBitsTestSig01(void) DetectEngineCtx *de_ctx = NULL; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p->src.family = AF_INET; p->dst.family = AF_INET; p->payload = buf; diff --git a/src/tests/detect-engine-content-inspection.c b/src/tests/detect-engine-content-inspection.c index 31783b50a9..adf420b1be 100644 --- a/src/tests/detect-engine-content-inspection.c +++ b/src/tests/detect-engine-content-inspection.c @@ -31,10 +31,11 @@ extern thread_local uint32_t ut_inspection_recursion_counter; -#define TEST_HEADER \ - ThreadVars tv; \ - memset(&tv, 0, sizeof(tv)); \ - Flow f; \ +#define TEST_HEADER \ + ThreadVars tv; \ + memset(&tv, 0, sizeof(tv)); \ + StatsThreadInit(&tv); \ + Flow f; \ memset(&f, 0, sizeof(f)); #define TEST_RUN(buf, buflen, sig, match, steps) \ diff --git a/src/tests/detect-http-client-body.c b/src/tests/detect-http-client-body.c index 2565e0288b..2e43350ac7 100644 --- a/src/tests/detect-http-client-body.c +++ b/src/tests/detect-http-client-body.c @@ -121,6 +121,7 @@ static int RunTest (struct TestSteps *steps, const char *sig, const char *yaml) FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -940,6 +941,7 @@ static int DetectHttpClientBodyTest06(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1043,6 +1045,7 @@ static int DetectHttpClientBodyTest07(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1165,6 +1168,7 @@ static int DetectHttpClientBodyTest08(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1290,6 +1294,7 @@ static int DetectHttpClientBodyTest09(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1415,6 +1420,7 @@ static int DetectHttpClientBodyTest10(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1536,6 +1542,7 @@ static int DetectHttpClientBodyTest11(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1635,6 +1642,7 @@ static int DetectHttpClientBodyTest12(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1734,6 +1742,7 @@ static int DetectHttpClientBodyTest13(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1835,6 +1844,7 @@ static int DetectHttpClientBodyTest14(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2033,6 +2043,7 @@ static int DetectHttpClientBodyTest15(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); diff --git a/src/tests/detect-http-cookie.c b/src/tests/detect-http-cookie.c index 2b81c4ec36..58c705e38f 100644 --- a/src/tests/detect-http-cookie.c +++ b/src/tests/detect-http-cookie.c @@ -63,6 +63,7 @@ static int DetectEngineHttpCookieTest01(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -130,6 +131,7 @@ static int DetectEngineHttpCookieTest02(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -197,6 +199,7 @@ static int DetectEngineHttpCookieTest03(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -264,6 +267,7 @@ static int DetectEngineHttpCookieTest04(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -331,6 +335,7 @@ static int DetectEngineHttpCookieTest05(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -398,6 +403,7 @@ static int DetectEngineHttpCookieTest06(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -465,6 +471,7 @@ static int DetectEngineHttpCookieTest07(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -532,6 +539,7 @@ static int DetectEngineHttpCookieTest08(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -599,6 +607,7 @@ static int DetectEngineHttpCookieTest09(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -666,6 +675,7 @@ static int DetectEngineHttpCookieTest10(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -734,6 +744,7 @@ static int DetectEngineHttpCookieTest11(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -802,6 +813,7 @@ static int DetectEngineHttpCookieTest12(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -870,6 +882,7 @@ static int DetectEngineHttpCookieTest13(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -938,6 +951,7 @@ static int DetectEngineHttpCookieTest14(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1006,6 +1020,7 @@ static int DetectEngineHttpCookieTest15(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1074,6 +1089,7 @@ static int DetectEngineHttpCookieTest16(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1142,6 +1158,7 @@ static int DetectEngineHttpCookieTest17(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1240,6 +1257,7 @@ static int DetectHttpCookieSigTest01(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1307,6 +1325,7 @@ static int DetectHttpCookieSigTest02(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1370,6 +1389,7 @@ static int DetectHttpCookieSigTest03(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1433,6 +1453,7 @@ static int DetectHttpCookieSigTest04(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1496,6 +1517,7 @@ static int DetectHttpCookieSigTest05(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1559,6 +1581,7 @@ static int DetectHttpCookieSigTest06(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1622,6 +1645,7 @@ static int DetectHttpCookieSigTest07(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1694,6 +1718,7 @@ static int DetectHttpCookieSigTest08(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1785,6 +1810,7 @@ static int DetectHttpCookieSigTest09(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); diff --git a/src/tests/detect-http-header.c b/src/tests/detect-http-header.c index 9b494c956d..e4c8d14cf2 100644 --- a/src/tests/detect-http-header.c +++ b/src/tests/detect-http-header.c @@ -112,6 +112,7 @@ static int DetectHttpHeaderTest06(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -213,6 +214,7 @@ static int DetectHttpHeaderTest07(void) FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -311,6 +313,7 @@ static int DetectHttpHeaderTest08(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -435,6 +438,7 @@ static int DetectHttpHeaderTest09(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -560,6 +564,7 @@ static int DetectHttpHeaderTest10(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -681,6 +686,7 @@ static int DetectHttpHeaderTest11(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -780,6 +786,7 @@ static int DetectHttpHeaderTest12(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -879,6 +886,7 @@ static int DetectHttpHeaderTest13(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -973,6 +981,7 @@ static int DetectHttpHeaderTest28(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1058,6 +1067,7 @@ static int DetectHttpHeaderTest29(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1143,6 +1153,7 @@ static int DetectHttpHeaderTest30(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1255,6 +1266,7 @@ static int DetectEngineHttpHeaderTest01(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1349,6 +1361,7 @@ static int DetectEngineHttpHeaderTest02(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1443,6 +1456,7 @@ static int DetectEngineHttpHeaderTest03(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1537,6 +1551,7 @@ static int DetectEngineHttpHeaderTest04(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1631,6 +1646,7 @@ static int DetectEngineHttpHeaderTest05(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1725,6 +1741,7 @@ static int DetectEngineHttpHeaderTest06(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1819,6 +1836,7 @@ static int DetectEngineHttpHeaderTest07(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1913,6 +1931,7 @@ static int DetectEngineHttpHeaderTest08(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2007,6 +2026,7 @@ static int DetectEngineHttpHeaderTest09(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2101,6 +2121,7 @@ static int DetectEngineHttpHeaderTest10(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2195,6 +2216,7 @@ static int DetectEngineHttpHeaderTest11(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2289,6 +2311,7 @@ static int DetectEngineHttpHeaderTest12(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2383,6 +2406,7 @@ static int DetectEngineHttpHeaderTest13(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2477,6 +2501,7 @@ static int DetectEngineHttpHeaderTest14(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2571,6 +2596,7 @@ static int DetectEngineHttpHeaderTest15(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2665,6 +2691,7 @@ static int DetectEngineHttpHeaderTest16(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2759,6 +2786,7 @@ static int DetectEngineHttpHeaderTest17(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2854,6 +2882,7 @@ static int DetectEngineHttpHeaderTest20(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2974,6 +3003,7 @@ static int DetectEngineHttpHeaderTest21(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -3094,6 +3124,7 @@ static int DetectEngineHttpHeaderTest22(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -3214,6 +3245,7 @@ static int DetectEngineHttpHeaderTest23(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -3334,6 +3366,7 @@ static int DetectEngineHttpHeaderTest24(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -3454,6 +3487,7 @@ static int DetectEngineHttpHeaderTest25(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -3574,6 +3608,7 @@ static int DetectEngineHttpHeaderTest26(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -3694,6 +3729,7 @@ static int DetectEngineHttpHeaderTest27(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -3819,6 +3855,7 @@ static int DetectEngineHttpHeaderTest28(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -3940,6 +3977,7 @@ static int DetectEngineHttpHeaderTest29(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -4095,6 +4133,7 @@ static int DetectEngineHttpHeaderTest30(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -4215,6 +4254,7 @@ static int DetectEngineHttpHeaderTest31(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -4319,6 +4359,7 @@ static int DetectEngineHttpHeaderTest32(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -4424,6 +4465,7 @@ static int DetectEngineHttpHeaderTest33(void) FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -4524,6 +4566,7 @@ static int DetectEngineHttpHeaderTest34(void) FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -4639,6 +4682,7 @@ static int DetectEngineHttpHeaderTest35(void) FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); diff --git a/src/tests/detect-http-host.c b/src/tests/detect-http-host.c index d8e5e1e81a..d2b658d175 100644 --- a/src/tests/detect-http-host.c +++ b/src/tests/detect-http-host.c @@ -54,6 +54,7 @@ static int RunTest(const uint8_t *buf, const uint32_t size, const char *sig_str, AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -651,6 +652,7 @@ static int DetectHttpHHTest07(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -741,6 +743,7 @@ static int DetectHttpHHTest08(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -836,6 +839,7 @@ static int DetectHttpHHTest09(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -933,6 +937,7 @@ static int DetectHttpHHTest10(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1113,6 +1118,7 @@ static int DetectHttpHHTest14(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1317,6 +1323,7 @@ static int DetectHttpHRHTest07(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1432,6 +1439,7 @@ static int DetectHttpHRHTest08(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1554,6 +1562,7 @@ static int DetectHttpHRHTest09(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1676,6 +1685,7 @@ static int DetectHttpHRHTest10(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1856,6 +1866,7 @@ static int DetectHttpHRHTest14(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2044,6 +2055,7 @@ static int DetectHttpHRHTest37(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); diff --git a/src/tests/detect-http-method.c b/src/tests/detect-http-method.c index ce6ebe00ca..e2eff2ee84 100644 --- a/src/tests/detect-http-method.c +++ b/src/tests/detect-http-method.c @@ -63,6 +63,7 @@ static int RunTest(struct TestSteps *steps, const char *sig, const char *yaml) FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -469,6 +470,7 @@ static int DetectHttpMethodSigTest01(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -543,6 +545,7 @@ static int DetectHttpMethodSigTest02(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -614,6 +617,7 @@ static int DetectHttpMethodSigTest03(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -680,6 +684,7 @@ static int DetectHttpMethodSigTest04(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); diff --git a/src/tests/detect-http-raw-header.c b/src/tests/detect-http-raw-header.c index 215cc8cc41..03d3c8d244 100644 --- a/src/tests/detect-http-raw-header.c +++ b/src/tests/detect-http-raw-header.c @@ -138,6 +138,7 @@ static int DetectEngineHttpRawHeaderTest01(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -206,6 +207,7 @@ static int DetectEngineHttpRawHeaderTest02(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -273,6 +275,7 @@ static int DetectEngineHttpRawHeaderTest03(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -342,6 +345,7 @@ static int DetectEngineHttpRawHeaderTest04(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -409,6 +413,7 @@ static int DetectEngineHttpRawHeaderTest05(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -476,6 +481,7 @@ static int DetectEngineHttpRawHeaderTest06(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -542,6 +548,7 @@ static int DetectEngineHttpRawHeaderTest07(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -608,6 +615,7 @@ static int DetectEngineHttpRawHeaderTest08(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -674,6 +682,7 @@ static int DetectEngineHttpRawHeaderTest09(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -740,6 +749,7 @@ static int DetectEngineHttpRawHeaderTest10(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -807,6 +817,7 @@ static int DetectEngineHttpRawHeaderTest11(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -875,6 +886,7 @@ static int DetectEngineHttpRawHeaderTest12(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -943,6 +955,7 @@ static int DetectEngineHttpRawHeaderTest13(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1010,6 +1023,7 @@ static int DetectEngineHttpRawHeaderTest14(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1077,6 +1091,7 @@ static int DetectEngineHttpRawHeaderTest15(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1145,6 +1160,7 @@ static int DetectEngineHttpRawHeaderTest16(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1212,6 +1228,7 @@ static int DetectEngineHttpRawHeaderTest17(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1279,6 +1296,7 @@ static int DetectEngineHttpRawHeaderTest20(void) FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1364,6 +1382,7 @@ static int DetectEngineHttpRawHeaderTest21(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1446,6 +1465,7 @@ static int DetectEngineHttpRawHeaderTest22(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1529,6 +1549,7 @@ static int DetectEngineHttpRawHeaderTest23(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1612,6 +1633,7 @@ static int DetectEngineHttpRawHeaderTest24(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1695,6 +1717,7 @@ static int DetectEngineHttpRawHeaderTest25(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1777,6 +1800,7 @@ static int DetectEngineHttpRawHeaderTest26(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1859,6 +1883,7 @@ static int DetectEngineHttpRawHeaderTest27(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1947,6 +1972,7 @@ static int DetectEngineHttpRawHeaderTest28(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2034,6 +2060,7 @@ static int DetectEngineHttpRawHeaderTest29(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2121,6 +2148,7 @@ static int DetectEngineHttpRawHeaderTest31(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2197,6 +2225,7 @@ static int DetectEngineHttpRawHeaderTest32(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2284,6 +2313,7 @@ static int DetectHttpRawHeaderTest06(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2360,6 +2390,7 @@ static int DetectHttpRawHeaderTest07(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2447,6 +2478,7 @@ static int DetectHttpRawHeaderTest08(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2536,6 +2568,7 @@ static int DetectHttpRawHeaderTest09(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2625,6 +2658,7 @@ static int DetectHttpRawHeaderTest10(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2711,6 +2745,7 @@ static int DetectHttpRawHeaderTest11(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2784,6 +2819,7 @@ static int DetectHttpRawHeaderTest12(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2859,6 +2895,7 @@ static int DetectHttpRawHeaderTest13(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); diff --git a/src/tests/detect-http-server-body.c b/src/tests/detect-http-server-body.c index cd9d433329..7b6b1168a2 100644 --- a/src/tests/detect-http-server-body.c +++ b/src/tests/detect-http-server-body.c @@ -82,6 +82,7 @@ static int RunTest(struct TestSteps *steps, const char *sig, const char *yaml) FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -865,6 +866,7 @@ static int DetectEngineHttpServerBodyFileDataTest03(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2280,6 +2282,7 @@ static int DetectHttpServerBodyTest14(void) uint32_t httplen4 = sizeof(httpbuf4) - 1; /* minus the \0 */ memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2397,6 +2400,7 @@ static int DetectHttpServerBodyTest15(void) uint32_t httplen4 = sizeof(httpbuf4) - 1; /* minus the \0 */ memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2739,6 +2743,7 @@ static int DetectHttpServerBodyFileDataTest09(void) uint32_t httplen4 = sizeof(httpbuf4) - 1; /* minus the \0 */ memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -2843,6 +2848,7 @@ static int DetectHttpServerBodyFileDataTest10(void) uint32_t httplen4 = sizeof(httpbuf4) - 1; /* minus the \0 */ memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); diff --git a/src/tests/detect-http-stat-code.c b/src/tests/detect-http-stat-code.c index e5fe78b651..98e153af38 100644 --- a/src/tests/detect-http-stat-code.c +++ b/src/tests/detect-http-stat-code.c @@ -62,6 +62,7 @@ static int DetectEngineHttpStatCodeTest01(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -147,6 +148,7 @@ static int DetectEngineHttpStatCodeTest02(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -225,6 +227,7 @@ static int DetectEngineHttpStatCodeTest03(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -314,6 +317,7 @@ static int DetectEngineHttpStatCodeTest04(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -399,6 +403,7 @@ static int DetectEngineHttpStatCodeTest05(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -484,6 +489,7 @@ static int DetectEngineHttpStatCodeTest06(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -569,6 +575,7 @@ static int DetectEngineHttpStatCodeTest07(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -654,6 +661,7 @@ static int DetectEngineHttpStatCodeTest08(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -739,6 +747,7 @@ static int DetectEngineHttpStatCodeTest09(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -825,6 +834,7 @@ static int DetectEngineHttpStatCodeTest10(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -911,6 +921,7 @@ static int DetectEngineHttpStatCodeTest11(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -997,6 +1008,7 @@ static int DetectEngineHttpStatCodeTest12(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1083,6 +1095,7 @@ static int DetectEngineHttpStatCodeTest13(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1169,6 +1182,7 @@ static int DetectEngineHttpStatCodeTest14(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1255,6 +1269,7 @@ static int DetectEngineHttpStatCodeTest15(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1335,6 +1350,7 @@ static int DetectHttpStatCodeSigTest01(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1402,6 +1418,7 @@ static int DetectHttpStatCodeSigTest02(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1476,6 +1493,7 @@ static int DetectHttpStatCodeSigTest03(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1550,6 +1568,7 @@ static int DetectHttpStatCodeSigTest04(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); diff --git a/src/tests/detect-http-stat-msg.c b/src/tests/detect-http-stat-msg.c index 682ebd8bb7..b1b6c9f8f3 100644 --- a/src/tests/detect-http-stat-msg.c +++ b/src/tests/detect-http-stat-msg.c @@ -62,6 +62,7 @@ static int DetectEngineHttpStatMsgTest01(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -150,6 +151,7 @@ static int DetectEngineHttpStatMsgTest02(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -229,6 +231,7 @@ static int DetectEngineHttpStatMsgTest03(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -318,6 +321,7 @@ static int DetectEngineHttpStatMsgTest04(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -403,6 +407,7 @@ static int DetectEngineHttpStatMsgTest05(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -488,6 +493,7 @@ static int DetectEngineHttpStatMsgTest06(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -573,6 +579,7 @@ static int DetectEngineHttpStatMsgTest07(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -658,6 +665,7 @@ static int DetectEngineHttpStatMsgTest08(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -743,6 +751,7 @@ static int DetectEngineHttpStatMsgTest09(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -829,6 +838,7 @@ static int DetectEngineHttpStatMsgTest10(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -915,6 +925,7 @@ static int DetectEngineHttpStatMsgTest11(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1001,6 +1012,7 @@ static int DetectEngineHttpStatMsgTest12(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1088,6 +1100,7 @@ static int DetectEngineHttpStatMsgTest13(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1174,6 +1187,7 @@ static int DetectEngineHttpStatMsgTest14(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1260,6 +1274,7 @@ static int DetectEngineHttpStatMsgTest15(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1340,6 +1355,7 @@ static int DetectHttpStatMsgSigTest01(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1413,6 +1429,7 @@ static int DetectHttpStatMsgSigTest02(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1481,6 +1498,7 @@ static int DetectHttpStatMsgSigTest03(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); diff --git a/src/tests/detect-http-user-agent.c b/src/tests/detect-http-user-agent.c index 9a2b1cf480..274d9cb515 100644 --- a/src/tests/detect-http-user-agent.c +++ b/src/tests/detect-http-user-agent.c @@ -56,6 +56,7 @@ static int DetectEngineHttpUATest( FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -443,6 +444,7 @@ static int DetectHttpUATest06(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -519,6 +521,7 @@ static int DetectHttpUATest07(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -609,6 +612,7 @@ static int DetectHttpUATest08(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -703,6 +707,7 @@ static int DetectHttpUATest09(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -796,6 +801,7 @@ static int DetectHttpUATest10(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -882,6 +888,7 @@ static int DetectHttpUATest11(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -953,6 +960,7 @@ static int DetectHttpUATest12(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1025,6 +1033,7 @@ static int DetectHttpUATest13(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -1103,6 +1112,7 @@ static int DetectHttpUATest14(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); diff --git a/src/tests/detect-tls-cert-fingerprint.c b/src/tests/detect-tls-cert-fingerprint.c index 2231d48743..3fda8e8a7c 100644 --- a/src/tests/detect-tls-cert-fingerprint.c +++ b/src/tests/detect-tls-cert-fingerprint.c @@ -269,6 +269,7 @@ static int DetectTlsFingerprintTest02(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); diff --git a/src/tests/detect-tls-cert-issuer.c b/src/tests/detect-tls-cert-issuer.c index 5d51970817..577dcbf610 100644 --- a/src/tests/detect-tls-cert-issuer.c +++ b/src/tests/detect-tls-cert-issuer.c @@ -269,6 +269,7 @@ static int DetectTlsIssuerTest02(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); diff --git a/src/tests/detect-tls-cert-serial.c b/src/tests/detect-tls-cert-serial.c index 286a3e7cd2..15ff3c8a0c 100644 --- a/src/tests/detect-tls-cert-serial.c +++ b/src/tests/detect-tls-cert-serial.c @@ -266,6 +266,7 @@ static int DetectTlsSerialTest02(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); diff --git a/src/tests/detect-tls-cert-subject.c b/src/tests/detect-tls-cert-subject.c index 16f2ac4893..0a73bcf4d3 100644 --- a/src/tests/detect-tls-cert-subject.c +++ b/src/tests/detect-tls-cert-subject.c @@ -269,6 +269,7 @@ static int DetectTlsSubjectTest02(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); diff --git a/src/tests/detect-tls-cert-validity.c b/src/tests/detect-tls-cert-validity.c index 07cfff92cf..e44904e46d 100644 --- a/src/tests/detect-tls-cert-validity.c +++ b/src/tests/detect-tls-cert-validity.c @@ -633,6 +633,7 @@ static int ValidityTestDetect01(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); @@ -955,6 +956,7 @@ static int ExpiredTestDetect01(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); @@ -1257,6 +1259,7 @@ static int ValidTestDetect01(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); diff --git a/src/tests/detect-tls-certs.c b/src/tests/detect-tls-certs.c index 4d2f4def2d..65fb48ed42 100644 --- a/src/tests/detect-tls-certs.c +++ b/src/tests/detect-tls-certs.c @@ -265,6 +265,7 @@ static int DetectTlsCertsTest02(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); diff --git a/src/tests/detect-ttl.c b/src/tests/detect-ttl.c index 028a938a68..6c32acad7f 100644 --- a/src/tests/detect-ttl.c +++ b/src/tests/detect-ttl.c @@ -166,6 +166,7 @@ static int DetectTtlTestSig1(void) IPV4Hdr ip4h; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&ip4h, 0, sizeof(ip4h)); p->src.family = AF_INET; diff --git a/src/tests/detect.c b/src/tests/detect.c index 7de2c34643..f5d4a99b4a 100644 --- a/src/tests/detect.c +++ b/src/tests/detect.c @@ -144,6 +144,7 @@ static int SigTest03 (void) uint16_t buflen = strlen((char *)buf); ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); Packet *p = UTHBuildPacket((uint8_t *)buf, buflen, IPPROTO_TCP); FAIL_IF_NULL(p); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -177,6 +178,7 @@ static int SigTest04 (void) uint16_t buflen = strlen((char *)buf); ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); Packet *p = UTHBuildPacket((uint8_t *)buf, buflen, IPPROTO_TCP); FAIL_IF_NULL(p); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -210,6 +212,7 @@ static int SigTest05 (void) uint16_t buflen = strlen((char *)buf); ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); Packet *p = UTHBuildPacket((uint8_t *)buf, buflen, IPPROTO_TCP); FAIL_IF_NULL(p); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -250,6 +253,7 @@ static int SigTest06 (void) FAIL_IF_NULL(alp_tctx); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -317,6 +321,7 @@ static int SigTest07 (void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); p = UTHBuildPacket((uint8_t *)buf, buflen, IPPROTO_TCP); @@ -384,6 +389,7 @@ static int SigTest08 (void) memset(&f, 0, sizeof(Flow)); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&ssn, 0, sizeof(ssn)); Packet *p = UTHBuildPacket((uint8_t *)buf, buflen, IPPROTO_TCP); @@ -451,6 +457,7 @@ static int SigTest09 (void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -513,6 +520,7 @@ static int SigTest10 (void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -574,6 +582,7 @@ static int SigTest11 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&f, 0, sizeof(f)); memset(&ssn, 0, sizeof(ssn)); @@ -613,16 +622,16 @@ static int SigTest11 (void) if (PacketAlertCheck(p, 1) && PacketAlertCheck(p, 2)) result = 1; - end: - FlowCleanupAppLayer(&f); - if (det_ctx) - DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - DetectEngineCtxFree(de_ctx); - UTHFreePackets(&p, 1); - StreamTcpFreeConfig(true); - FLOW_DESTROY(&f); - StatsThreadCleanup(&th_v); - return result; +end: + FlowCleanupAppLayer(&f); + if (det_ctx) + DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); + DetectEngineCtxFree(de_ctx); + UTHFreePackets(&p, 1); + StreamTcpFreeConfig(true); + FLOW_DESTROY(&f); + StatsThreadCleanup(&th_v); + return result; } static int SigTest12 (void) @@ -636,6 +645,7 @@ static int SigTest12 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); Flow f; memset(&f, 0, sizeof(Flow)); @@ -690,6 +700,7 @@ static int SigTest13 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); Flow f; memset(&f, 0, sizeof(Flow)); @@ -741,6 +752,7 @@ static int SigTest14 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p = UTHBuildPacket((uint8_t *)buf, buflen, IPPROTO_TCP); @@ -787,6 +799,7 @@ static int SigTest15 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p->src.family = AF_INET; p->dst.family = AF_INET; p->payload = buf; @@ -841,6 +854,7 @@ static int SigTest16 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&p, 0, sizeof(p)); p = UTHBuildPacketSrcDstPorts((uint8_t *)buf, buflen, IPPROTO_TCP, 12345, 1234); @@ -894,6 +908,7 @@ static int SigTest17 (void) ThreadVars th_v; DetectEngineThreadCtx *det_ctx = NULL; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p = UTHBuildPacketSrcDstPorts((uint8_t *)buf, buflen, IPPROTO_TCP, 12345, 80); FAIL_IF_NULL(p); @@ -942,6 +957,7 @@ static int SigTest18 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p->src.family = AF_INET; p->dst.family = AF_INET; p->payload = buf; @@ -993,6 +1009,7 @@ static int SigTest19 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p->src.family = AF_INET; p->src.addr_data32[0] = UTHSetIPv4Address("192.168.0.1"); p->dst.addr_data32[0] = UTHSetIPv4Address("1.2.3.4"); @@ -1053,6 +1070,7 @@ static int SigTest20 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p->src.family = AF_INET; p->src.addr_data32[0] = UTHSetIPv4Address("192.168.0.1"); p->dst.addr_data32[0] = UTHSetIPv4Address("1.2.3.4"); @@ -1104,6 +1122,7 @@ static int SigTest21 (void) { ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineThreadCtx *det_ctx = NULL; int result = 0; @@ -1180,6 +1199,7 @@ static int SigTest22 (void) { ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineThreadCtx *det_ctx = NULL; int result = 0; @@ -1253,6 +1273,7 @@ static int SigTest23 (void) { ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineThreadCtx *det_ctx = NULL; int result = 0; @@ -1351,6 +1372,7 @@ static int SigTest24IPV4Keyword(void) uint16_t buflen = strlen((char *)buf); memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); PacketSetIPV4(p1, valid_raw_ipv4); p1->src.family = AF_INET; @@ -1448,6 +1470,7 @@ static int SigTest25NegativeIPV4Keyword(void) uint16_t buflen = strlen((char *)buf); memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); PacketSetIPV4(p1, valid_raw_ipv4); p1->src.family = AF_INET; @@ -1548,6 +1571,7 @@ static int SigTest26TCPV4Keyword(void) DetectEngineThreadCtx *det_ctx = NULL; memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); PacketCopyData(p1, raw_ipv4, sizeof(raw_ipv4)); PacketCopyDataOffset(p1, GET_PKT_LEN(p1), valid_raw_tcp, sizeof(valid_raw_tcp)); @@ -1643,6 +1667,7 @@ static int SigTest26TCPV4AndNegativeIPV4Keyword(void) int result = 0; memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); PacketCopyData(p1, raw_ipv4, sizeof(raw_ipv4)); PacketCopyDataOffset(p1, GET_PKT_LEN(p1), valid_raw_tcp, sizeof(valid_raw_tcp)); @@ -1764,6 +1789,7 @@ static int SigTest26TCPV4AndIPV4Keyword(void) int result = 0; memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); PacketCopyData(p1, raw_ipv4, sizeof(raw_ipv4)); PacketCopyDataOffset(p1, GET_PKT_LEN(p1), valid_raw_tcp, sizeof(valid_raw_tcp)); @@ -1872,6 +1898,7 @@ static int SigTest27NegativeTCPV4Keyword(void) int result = 0; memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); PacketCopyData(p1, raw_ipv4, sizeof(raw_ipv4)); PacketCopyDataOffset(p1, GET_PKT_LEN(p1), valid_raw_tcp, sizeof(valid_raw_tcp)); @@ -1993,6 +2020,7 @@ static int SigTest28TCPV6Keyword(void) int result = 0; memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); PacketSetIPV6(p1, valid_raw_ipv6 + 14); PacketSetTCP(p1, (valid_raw_ipv6 + 54)); @@ -2116,6 +2144,7 @@ static int SigTest29NegativeTCPV6Keyword(void) int result = 0; memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); PacketSetIPV6(p1, valid_raw_ipv6 + 14); PacketSetTCP(p1, valid_raw_ipv6 + 54); @@ -2231,6 +2260,7 @@ static int SigTest30UDPV4Keyword(void) "\r\n\r\nyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"; memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); PacketSetIPV4(p1, raw_ipv4); PacketSetUDP(p1, valid_raw_udp); @@ -2334,6 +2364,7 @@ static int SigTest31NegativeUDPV4Keyword(void) "\r\n\r\nyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"; memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); PacketSetIPV4(p1, raw_ipv4); PacketSetUDP(p1, valid_raw_udp); @@ -2442,6 +2473,7 @@ static int SigTest32UDPV6Keyword(void) "\r\n\r\n"; memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); PacketSetIPV6(p1, valid_raw_ipv6 + 14); PacketSetUDP(p1, valid_raw_ipv6 + 54); @@ -2538,6 +2570,7 @@ static int SigTest33NegativeUDPV6Keyword(void) "\r\n\r\n"; memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); PacketSetIPV6(p1, valid_raw_ipv6 + 14); PacketSetUDP(p1, valid_raw_ipv6 + 54); @@ -2651,6 +2684,7 @@ static int SigTest34ICMPV4Keyword(void) uint16_t buflen = strlen((char *)buf); memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); IPV4Hdr *ip4h = PacketSetIPV4(p1, valid_raw_ipv4); ip4h->ip_verhl = 69; @@ -2766,6 +2800,7 @@ static int SigTest35NegativeICMPV4Keyword(void) uint16_t buflen = strlen((char *)buf); memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); IPV4Hdr *ip4h = PacketSetIPV4(p1, valid_raw_ipv4); ip4h->ip_verhl = 69; @@ -2880,6 +2915,7 @@ static int SigTest38(void) uint16_t buflen = sizeof(buf); memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); /* Copy raw data into packet */ if (PacketCopyData(p1, raw_eth, ethlen) == -1) { @@ -3003,6 +3039,7 @@ static int SigTest39(void) uint16_t buflen = sizeof(buf); memset(&th_v, 0, sizeof(ThreadVars)); + StatsThreadInit(&th_v); Packet *p1 = PacketGetFromAlloc(); FAIL_IF_NULL(p1); @@ -3105,6 +3142,7 @@ static int SigTest36ContentAndIsdataatKeywords01 (void) memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); FlowInitConfig(FLOW_QUIET); DecodeEthernet(&th_v, &dtv, p, raw_eth, sizeof(raw_eth)); @@ -3185,6 +3223,7 @@ static int SigTest37ContentAndIsdataatKeywords02 (void) memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); FlowInitConfig(FLOW_QUIET); DecodeEthernet(&th_v, &dtv, p, raw_eth, sizeof(raw_eth)); @@ -3268,6 +3307,7 @@ static int SigTest40NoPacketInspection01(void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); memset(&pq, 0, sizeof(pq)); memset(&f, 0, sizeof(f)); memset(&tcphdr, 0, sizeof(tcphdr)); @@ -3332,6 +3372,7 @@ static int SigTest40NoPayloadInspection02(void) uint16_t buflen = strlen((char *)buf); ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); Packet *p = PacketGetFromAlloc(); FAIL_IF_NULL(p); @@ -3384,6 +3425,7 @@ static int SigTestMemory01 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p->src.family = AF_INET; p->dst.family = AF_INET; p->payload = buf; @@ -3422,6 +3464,7 @@ static int SigTestMemory02 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) { @@ -3456,6 +3499,7 @@ static int SigTestMemory03 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) { @@ -3498,6 +3542,7 @@ static int SigTestContent01 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); Packet *p = NULL; p = UTHBuildPacket((uint8_t *)buf, buflen, IPPROTO_TCP); @@ -3540,6 +3585,7 @@ static int SigTestContent02 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); Packet *p = NULL; p = UTHBuildPacket((uint8_t *)buf, buflen, IPPROTO_TCP); @@ -3591,6 +3637,7 @@ static int SigTestContent03 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); Packet *p = NULL; p = UTHBuildPacket((uint8_t *)buf, buflen, IPPROTO_TCP); @@ -3633,6 +3680,7 @@ static int SigTestContent04 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); Packet *p = NULL; p = UTHBuildPacket((uint8_t *)buf, buflen, IPPROTO_TCP); @@ -3677,6 +3725,7 @@ static int SigTestContent05 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); Packet *p = NULL; p = UTHBuildPacket((uint8_t *)buf, buflen, IPPROTO_TCP); @@ -3736,6 +3785,7 @@ static int SigTestContent06 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); Packet *p = NULL; p = UTHBuildPacket((uint8_t *)buf, buflen, IPPROTO_TCP); @@ -3877,6 +3927,7 @@ static int SigTestWithin01 (void) memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineThreadCtx *det_ctx = NULL; @@ -3953,6 +4004,7 @@ static int SigTestDepthOffset01 (void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p = UTHBuildPacket(buf, buflen, IPPROTO_TCP); @@ -3990,6 +4042,7 @@ static int SigTestDetectAlertCounter(void) ThreadVars tv; DetectEngineThreadCtx *det_ctx = NULL; memset(&tv, 0, sizeof(tv)); + StatsThreadInit(&tv); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -4047,6 +4100,7 @@ static int SigTestDropFlow01(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); @@ -4122,6 +4176,7 @@ static int SigTestDropFlow02(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); @@ -4233,6 +4288,7 @@ static int SigTestDropFlow03(void) AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); memset(&f, 0, sizeof(Flow)); memset(&ssn, 0, sizeof(TcpSession)); @@ -4384,6 +4440,7 @@ static int SigTestPorts01(void) uint8_t payload[] = "AAAAAAAAAAAAAAAAAA"; memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); p1 = UTHBuildPacket(payload, sizeof(payload), IPPROTO_ICMP); @@ -4429,6 +4486,7 @@ static int SigTestBug01(void) DetectEngineThreadCtx *det_ctx = NULL; uint8_t payload[] = "!mymy"; memset(&tv, 0, sizeof(ThreadVars)); + StatsThreadInit(&tv); Packet *p1 = UTHBuildPacket(payload, sizeof(payload), IPPROTO_TCP); FAIL_IF_NULL(p1); diff --git a/src/tm-threads.c b/src/tm-threads.c index 04e3acc2a7..7a4d1e872d 100644 --- a/src/tm-threads.c +++ b/src/tm-threads.c @@ -951,7 +951,7 @@ ThreadVars *TmThreadCreate(const char *name, const char *inq_name, const char *i goto error; SC_ATOMIC_INIT(tv->flags); - SCSpinInit(&tv->perf_public_ctx.lock, 0); + StatsThreadInit(tv); strlcpy(tv->name, name, sizeof(tv->name)); diff --git a/src/util-mpm-ac-ks.c b/src/util-mpm-ac-ks.c index 2aa3bba125..6bdec7b11a 100644 --- a/src/util-mpm-ac-ks.c +++ b/src/util-mpm-ac-ks.c @@ -2297,6 +2297,7 @@ static int SCACTileTest29(void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p = UTHBuildPacket(buf, buflen, IPPROTO_TCP); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); diff --git a/src/util-mpm-ac.c b/src/util-mpm-ac.c index 9360f0702c..b60bd0df09 100644 --- a/src/util-mpm-ac.c +++ b/src/util-mpm-ac.c @@ -1981,6 +1981,7 @@ static int SCACTest29(void) DetectEngineThreadCtx *det_ctx = NULL; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); Packet *p = UTHBuildPacket(buf, buflen, IPPROTO_TCP); FAIL_IF_NULL(p); diff --git a/src/util-mpm-hs.c b/src/util-mpm-hs.c index 45750da5d5..8825c83423 100644 --- a/src/util-mpm-hs.c +++ b/src/util-mpm-hs.c @@ -2227,6 +2227,7 @@ static int SCHSTest29(void) int result = 0; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); p = UTHBuildPacket(buf, buflen, IPPROTO_TCP); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); diff --git a/src/util-threshold-config.c b/src/util-threshold-config.c index 7f00415989..fb8fa61ec1 100644 --- a/src/util-threshold-config.c +++ b/src/util-threshold-config.c @@ -1536,6 +1536,7 @@ static int SCThresholdConfTest09(void) { ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); ThresholdInit(); @@ -1633,6 +1634,7 @@ static int SCThresholdConfTest10(void) ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -1717,6 +1719,7 @@ static int SCThresholdConfTest11(void) ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -1823,6 +1826,7 @@ static int SCThresholdConfTest12(void) ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); FAIL_IF_NULL(de_ctx); @@ -1981,6 +1985,7 @@ static int SCThresholdConfTest14(void) ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); FAIL_IF_NOT_NULL(g_ut_threshold_fp); g_ut_threshold_fp = SCThresholdConfGenerateValidDummyFD11(); @@ -2025,6 +2030,7 @@ static int SCThresholdConfTest15(void) ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineThreadCtx *det_ctx = NULL; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -2074,6 +2080,7 @@ static int SCThresholdConfTest16(void) ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineThreadCtx *det_ctx = NULL; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -2122,6 +2129,7 @@ static int SCThresholdConfTest17(void) ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineThreadCtx *det_ctx = NULL; DetectEngineCtx *de_ctx = DetectEngineCtxInit(); @@ -2394,6 +2402,7 @@ static int SCThresholdConfTest22(void) { ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); ThresholdInit(); @@ -2532,6 +2541,7 @@ static int SCThresholdConfTest23(void) { ThreadVars th_v; memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); ThresholdInit(); diff --git a/src/util-unittest-helper.c b/src/util-unittest-helper.c index 3b4b20e0ee..dc31573abd 100644 --- a/src/util-unittest-helper.c +++ b/src/util-unittest-helper.c @@ -698,6 +698,7 @@ int UTHMatchPacketsWithResults(DetectEngineCtx *de_ctx, Packet **p, int num_pack memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); SigGroupBuild(de_ctx); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); @@ -736,6 +737,7 @@ int UTHMatchPackets(DetectEngineCtx *de_ctx, Packet **p, int num_packets) DetectEngineThreadCtx *det_ctx = NULL; memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); SCSigRegisterSignatureOrderingFuncs(de_ctx); SCSigOrderSignatures(de_ctx); SCSigSignatureOrderingModuleCleanup(de_ctx); @@ -776,6 +778,7 @@ int UTHPacketMatchSigMpm(Packet *p, char *sig, uint16_t mpm_type) memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); if (mpm_type == MPM_AC) { SCConfSet("mpm-algo", "ac"); @@ -838,6 +841,7 @@ int UTHPacketMatchSig(Packet *p, const char *sig) memset(&dtv, 0, sizeof(DecodeThreadVars)); memset(&th_v, 0, sizeof(th_v)); + StatsThreadInit(&th_v); DetectEngineCtx *de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) {