From: Victor Julien Date: Fri, 16 May 2025 14:19:33 +0000 (+0200) Subject: detect: pass de_ctx around as const X-Git-Tag: suricata-8.0.0-rc1~116 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afa88757fef6aef5186535805461f370f505cd6b;p=thirdparty%2Fsuricata.git detect: pass de_ctx around as const --- diff --git a/src/detect-engine-alert.c b/src/detect-engine-alert.c index 50b97fb7f4..e7f1f847c3 100644 --- a/src/detect-engine-alert.c +++ b/src/detect-engine-alert.c @@ -504,7 +504,7 @@ static inline void PacketAlertFinalizeProcessQueue( * \param det_ctx detection engine thread context * \param p pointer to the packet */ -void PacketAlertFinalize(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p) +void PacketAlertFinalize(const DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p) { SCEnter(); diff --git a/src/detect-engine-alert.h b/src/detect-engine-alert.h index 9fcd33996c..1a8c8b81c3 100644 --- a/src/detect-engine-alert.h +++ b/src/detect-engine-alert.h @@ -32,7 +32,7 @@ void AlertQueueInit(DetectEngineThreadCtx *det_ctx); void AlertQueueFree(DetectEngineThreadCtx *det_ctx); void AlertQueueAppend(DetectEngineThreadCtx *det_ctx, const Signature *s, Packet *p, uint64_t tx_id, uint8_t alert_flags); -void PacketAlertFinalize(DetectEngineCtx *, DetectEngineThreadCtx *, Packet *); +void PacketAlertFinalize(const DetectEngineCtx *, DetectEngineThreadCtx *, Packet *); #ifdef UNITTESTS int PacketAlertCheck(Packet *, uint32_t); #endif diff --git a/src/detect-engine-tag.c b/src/detect-engine-tag.c index cef785d98b..2cf61abae6 100644 --- a/src/detect-engine-tag.c +++ b/src/detect-engine-tag.c @@ -520,8 +520,7 @@ static Host *GetLockedDstHost(Packet *p) * \param p packet * */ -void TagHandlePacket(DetectEngineCtx *de_ctx, - DetectEngineThreadCtx *det_ctx, Packet *p) +void TagHandlePacket(const DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p) { SCEnter(); diff --git a/src/detect-engine-tag.h b/src/detect-engine-tag.h index 64f11f316c..d54493e8c4 100644 --- a/src/detect-engine-tag.h +++ b/src/detect-engine-tag.h @@ -44,7 +44,7 @@ int TagHashAddTag(DetectTagDataEntry *, Packet *); int TagFlowAdd(Packet *, DetectTagDataEntry *); -void TagHandlePacket(DetectEngineCtx *, DetectEngineThreadCtx *, Packet *); +void TagHandlePacket(const DetectEngineCtx *, DetectEngineThreadCtx *, Packet *); void TagInitCtx(void); void TagDestroyCtx(void); diff --git a/src/detect.c b/src/detect.c index 93537aac11..571e03a9d8 100644 --- a/src/detect.c +++ b/src/detect.c @@ -80,19 +80,18 @@ static void DetectRunInspectIPOnly(ThreadVars *tv, const DetectEngineCtx *de_ctx DetectEngineThreadCtx *det_ctx, Flow * const pflow, Packet * const p); static inline void DetectRunGetRuleGroup(const DetectEngineCtx *de_ctx, Packet * const p, Flow * const pflow, DetectRunScratchpad *scratch); -static inline void DetectRunPrefilterPkt(ThreadVars *tv, - DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p, - DetectRunScratchpad *scratch); -static inline uint8_t DetectRulePacketRules(ThreadVars *const tv, DetectEngineCtx *const de_ctx, - DetectEngineThreadCtx *const det_ctx, Packet *const p, Flow *const pflow, - const DetectRunScratchpad *scratch); +static inline void DetectRunPrefilterPkt(ThreadVars *tv, const DetectEngineCtx *de_ctx, + DetectEngineThreadCtx *det_ctx, Packet *p, DetectRunScratchpad *scratch); +static inline uint8_t DetectRulePacketRules(ThreadVars *const tv, + const DetectEngineCtx *const de_ctx, DetectEngineThreadCtx *const det_ctx, Packet *const p, + Flow *const pflow, const DetectRunScratchpad *scratch); static void DetectRunTx(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p, Flow *f, DetectRunScratchpad *scratch); static void DetectRunFrames(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p, Flow *f, DetectRunScratchpad *scratch); -static inline void DetectRunPostRules(ThreadVars *tv, DetectEngineCtx *de_ctx, - DetectEngineThreadCtx *det_ctx, Packet * const p, Flow * const pflow, +static inline void DetectRunPostRules(ThreadVars *tv, const DetectEngineCtx *de_ctx, + DetectEngineThreadCtx *det_ctx, Packet *const p, Flow *const pflow, DetectRunScratchpad *scratch); static void DetectRunCleanup(DetectEngineThreadCtx *det_ctx, Packet *p, Flow * const pflow); @@ -276,7 +275,8 @@ const SigGroupHead *SigMatchSignaturesGetSgh(const DetectEngineCtx *de_ctx, SCReturnPtr(sgh, "SigGroupHead"); } -static inline void DetectPrefilterCopyDeDup(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx) +static inline void DetectPrefilterCopyDeDup( + const DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx) { SigIntId *pf_ptr = det_ctx->pmq.rule_id_array; uint32_t final_cnt = det_ctx->pmq.rule_id_array_cnt; @@ -542,13 +542,8 @@ static inline bool DetectRunInspectRuleHeader(const Packet *p, const Flow *f, co /** \internal * \brief run packet/stream prefilter engines */ -static inline void DetectRunPrefilterPkt( - ThreadVars *tv, - DetectEngineCtx *de_ctx, - DetectEngineThreadCtx *det_ctx, - Packet *p, - DetectRunScratchpad *scratch -) +static inline void DetectRunPrefilterPkt(ThreadVars *tv, const DetectEngineCtx *de_ctx, + DetectEngineThreadCtx *det_ctx, Packet *p, DetectRunScratchpad *scratch) { /* create our prefilter mask */ PacketCreateMask(p, &p->sig_mask, scratch->alproto, scratch->app_decoder_events); @@ -608,9 +603,9 @@ static int SortHelper(const void *a, const void *b) return sa->iid > sb->iid ? 1 : -1; } -static inline uint8_t DetectRulePacketRules(ThreadVars *const tv, DetectEngineCtx *const de_ctx, - DetectEngineThreadCtx *const det_ctx, Packet *const p, Flow *const pflow, - const DetectRunScratchpad *scratch) +static inline uint8_t DetectRulePacketRules(ThreadVars *const tv, + const DetectEngineCtx *const de_ctx, DetectEngineThreadCtx *const det_ctx, Packet *const p, + Flow *const pflow, const DetectRunScratchpad *scratch) { uint8_t action = 0; bool fw_verdict = false; @@ -966,13 +961,9 @@ static DetectRunScratchpad DetectRunSetup( return pad; } -static inline void DetectRunPostRules( - ThreadVars *tv, - DetectEngineCtx *de_ctx, - DetectEngineThreadCtx *det_ctx, - Packet * const p, - Flow * const pflow, - DetectRunScratchpad *scratch) +static inline void DetectRunPostRules(ThreadVars *tv, const DetectEngineCtx *de_ctx, + DetectEngineThreadCtx *det_ctx, Packet *const p, Flow *const pflow, + DetectRunScratchpad *scratch) { /* so now let's iterate the alerts and remove the ones after a pass rule * matched (if any). This is done inside PacketAlertFinalize() */