From a179f79eb6798882abddac18e9d6a59f968dd59d Mon Sep 17 00:00:00 2001 From: Justin Azoff Date: Tue, 28 Feb 2023 17:54:26 -0500 Subject: [PATCH] detect/iponly: remove DetectEngineIPOnlyThreadCtx This is unused. Issue: 4578 (cherry picked from commit aacb7dc291de99dccfb4b6c4b6d6adbe433494f0) --- src/detect-engine-iponly.c | 37 ++----------------------------------- src/detect-engine-iponly.h | 7 ++----- src/detect-engine.c | 5 ----- src/detect.c | 5 ++--- src/detect.h | 8 -------- 5 files changed, 6 insertions(+), 56 deletions(-) diff --git a/src/detect-engine-iponly.c b/src/detect-engine-iponly.c index 91cf07d6c0..740e00d031 100644 --- a/src/detect-engine-iponly.c +++ b/src/detect-engine-iponly.c @@ -912,25 +912,6 @@ SigIntId IPOnlyTrackSigNum(DetectEngineIPOnlyCtx *io_ctx, SigIntId signum) return loc; } -/** - * \brief Setup the IP Only thread detection engine context - * - * \param de_ctx Pointer to the current detection engine - * \param io_ctx Pointer to the current ip only thread detection engine - */ -void DetectEngineIPOnlyThreadInit(DetectEngineCtx *de_ctx, - DetectEngineIPOnlyThreadCtx *io_tctx) -{ - /* initialize the signature bitarray */ - io_tctx->sig_match_size = de_ctx->io_ctx.max_idx / 8 + 1; - io_tctx->sig_match_array = SCMalloc(io_tctx->sig_match_size); - if (io_tctx->sig_match_array == NULL) { - exit(EXIT_FAILURE); - } - - memset(io_tctx->sig_match_array, 0, io_tctx->sig_match_size); -} - /** * \brief Print stats of the IP Only engine * @@ -975,17 +956,6 @@ void IPOnlyDeinit(DetectEngineCtx *de_ctx, DetectEngineIPOnlyCtx *io_ctx) io_ctx->sig_mapping = NULL; } -/** - * \brief Deinitialize the IP Only thread detection engine context - * - * \param de_ctx Pointer to the current detection engine - * \param io_ctx Pointer to the current ip only detection engine - */ -void DetectEngineIPOnlyThreadDeinit(DetectEngineIPOnlyThreadCtx *io_tctx) -{ - SCFree(io_tctx->sig_match_array); -} - static inline int IPOnlyMatchCompatSMs(ThreadVars *tv, DetectEngineThreadCtx *det_ctx, @@ -1019,11 +989,8 @@ int IPOnlyMatchCompatSMs(ThreadVars *tv, * \param io_ctx Pointer to the current ip only thread detection engine * \param p Pointer to the Packet to match against */ -void IPOnlyMatchPacket(ThreadVars *tv, - const DetectEngineCtx *de_ctx, - DetectEngineThreadCtx *det_ctx, - const DetectEngineIPOnlyCtx *io_ctx, - DetectEngineIPOnlyThreadCtx *io_tctx, Packet *p) +void IPOnlyMatchPacket(ThreadVars *tv, const DetectEngineCtx *de_ctx, + DetectEngineThreadCtx *det_ctx, const DetectEngineIPOnlyCtx *io_ctx, Packet *p) { SigNumArray *src = NULL; SigNumArray *dst = NULL; diff --git a/src/detect-engine-iponly.h b/src/detect-engine-iponly.h index 117cb3c367..7fa9e223e7 100644 --- a/src/detect-engine-iponly.h +++ b/src/detect-engine-iponly.h @@ -26,15 +26,12 @@ void IPOnlyCIDRListFree(IPOnlyCIDRItem *tmphead); int IPOnlySigParseAddress(const DetectEngineCtx *, Signature *, const char *, char); -void IPOnlyMatchPacket(ThreadVars *tv, const DetectEngineCtx *, - DetectEngineThreadCtx *, const DetectEngineIPOnlyCtx *, - DetectEngineIPOnlyThreadCtx *, Packet *); +void IPOnlyMatchPacket(ThreadVars *tv, const DetectEngineCtx *, DetectEngineThreadCtx *, + const DetectEngineIPOnlyCtx *, Packet *); void IPOnlyInit(DetectEngineCtx *, DetectEngineIPOnlyCtx *); void IPOnlyPrint(DetectEngineCtx *, DetectEngineIPOnlyCtx *); void IPOnlyDeinit(DetectEngineCtx *, DetectEngineIPOnlyCtx *); void IPOnlyPrepare(DetectEngineCtx *); -void DetectEngineIPOnlyThreadInit(DetectEngineCtx *, DetectEngineIPOnlyThreadCtx *); -void DetectEngineIPOnlyThreadDeinit(DetectEngineIPOnlyThreadCtx *); SigIntId IPOnlyTrackSigNum(DetectEngineIPOnlyCtx *, SigIntId); void IPOnlyAddSignature(DetectEngineCtx *, DetectEngineIPOnlyCtx *, Signature *); void IPOnlyRegisterTests(void); diff --git a/src/detect-engine.c b/src/detect-engine.c index 46c5b61b24..8dd210d963 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -2723,9 +2723,6 @@ static TmEcode ThreadCtxDoInit (DetectEngineCtx *de_ctx, DetectEngineThreadCtx * BUG_ON(det_ctx->non_pf_id_array == NULL); } - /* IP-ONLY */ - DetectEngineIPOnlyThreadInit(de_ctx,&det_ctx->io_ctx); - /* DeState */ if (de_ctx->sig_array_len > 0) { det_ctx->match_array_len = de_ctx->sig_array_len; @@ -2954,8 +2951,6 @@ static void DetectEngineThreadCtxFree(DetectEngineThreadCtx *det_ctx) SCProfilingSghThreadCleanup(det_ctx); #endif - DetectEngineIPOnlyThreadDeinit(&det_ctx->io_ctx); - /** \todo get rid of this static */ if (det_ctx->de_ctx != NULL) { PatternMatchThreadDestroy(&det_ctx->mtc, det_ctx->de_ctx->mpm_matcher); diff --git a/src/detect.c b/src/detect.c index 1aea748587..800c81927b 100644 --- a/src/detect.c +++ b/src/detect.c @@ -541,7 +541,7 @@ static void DetectRunInspectIPOnly(ThreadVars *tv, const DetectEngineCtx *de_ctx SCLogDebug("testing against \"ip-only\" signatures"); PACKET_PROFILING_DETECT_START(p, PROF_DETECT_IPONLY); - IPOnlyMatchPacket(tv, de_ctx, det_ctx, &de_ctx->io_ctx, &det_ctx->io_ctx, p); + IPOnlyMatchPacket(tv, de_ctx, det_ctx, &de_ctx->io_ctx, p); PACKET_PROFILING_DETECT_END(p, PROF_DETECT_IPONLY); /* save in the flow that we scanned this direction... */ @@ -552,8 +552,7 @@ static void DetectRunInspectIPOnly(ThreadVars *tv, const DetectEngineCtx *de_ctx /* Even without flow we should match the packet src/dst */ PACKET_PROFILING_DETECT_START(p, PROF_DETECT_IPONLY); - IPOnlyMatchPacket(tv, de_ctx, det_ctx, &de_ctx->io_ctx, - &det_ctx->io_ctx, p); + IPOnlyMatchPacket(tv, de_ctx, det_ctx, &de_ctx->io_ctx, p); PACKET_PROFILING_DETECT_END(p, PROF_DETECT_IPONLY); } } diff --git a/src/detect.h b/src/detect.h index 0320dc7a1d..0b727e498a 100644 --- a/src/detect.h +++ b/src/detect.h @@ -675,11 +675,6 @@ typedef struct DetectVarList_ { struct DetectVarList_ *next; } DetectVarList; -typedef struct DetectEngineIPOnlyThreadCtx_ { - uint8_t *sig_match_array; /* bit array of sig nums */ - uint32_t sig_match_size; /* size in bytes of the array */ -} DetectEngineIPOnlyThreadCtx; - /** \brief IP only rules matching ctx. */ typedef struct DetectEngineIPOnlyCtx_ { /* Lookup trees */ @@ -1119,9 +1114,6 @@ typedef struct DetectEngineThreadCtx_ { * prototype held by DetectEngineCtx. */ SpmThreadCtx *spm_thread_ctx; - /** ip only rules ctx */ - DetectEngineIPOnlyThreadCtx io_ctx; - /* byte_* values */ uint64_t *byte_values; -- 2.47.2