]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/frames: avoid IPS rescanning
authorVictor Julien <vjulien@oisf.net>
Thu, 30 Nov 2023 10:59:45 +0000 (11:59 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 4 Jun 2024 20:05:25 +0000 (22:05 +0200)
Make sure to only scan the data when the app layer has been updated
as well.

Ticket: #6718.

src/detect.c

index 989f1133daeba05f496f630e9a602306433d1b06..7c7536a22709e7373b27b4a3d6b496ffce2248a7 100644 (file)
@@ -1627,6 +1627,15 @@ static void DetectRunFrames(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngin
     const SigGroupHead *const sgh = scratch->sgh;
     const AppProto alproto = f->alproto;
 
+    /* for TCP, limit inspection to pseudo packets or real packet that did
+     * an app-layer update. */
+    if (p->proto == IPPROTO_TCP && !PKT_IS_PSEUDOPKT(p) &&
+            ((PKT_IS_TOSERVER(p) && (f->flags & FLOW_TS_APP_UPDATED) == 0) ||
+                    (PKT_IS_TOCLIENT(p) && (f->flags & FLOW_TC_APP_UPDATED) == 0))) {
+        SCLogDebug("pcap_cnt %" PRIu64 ": %s: skip frame inspection for TCP w/o APP UPDATE",
+                p->pcap_cnt, PKT_IS_TOSERVER(p) ? "toserver" : "toclient");
+        return;
+    }
     FramesContainer *frames_container = AppLayerFramesGetContainer(f);
     if (frames_container == NULL) {
         return;