Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frame fixup/v1 #12250

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/flow-timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#include "detect-engine-state.h"
#include "stream.h"

#include "app-layer-frames.h"
#include "app-layer-parser.h"
#include "app-layer.h"

Expand Down Expand Up @@ -287,7 +288,6 @@ Packet *FlowPseudoPacketGet(int direction, Flow *f, const TcpSession *ssn)
*/
bool FlowNeedsReassembly(Flow *f)
{

if (f == NULL || f->protoctx == NULL) {
return false;
}
Expand Down Expand Up @@ -318,6 +318,15 @@ bool FlowNeedsReassembly(Flow *f)
}
}

/* if any frame is present we assume it still needs work */
FramesContainer *frames_container = AppLayerFramesGetContainer(f);
if (frames_container) {
if (frames_container->toserver.cnt)
client = STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION;
if (frames_container->toclient.cnt)
server = STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION;
}

/* nothing to do */
if (client == STREAM_HAS_UNPROCESSED_SEGMENTS_NONE &&
server == STREAM_HAS_UNPROCESSED_SEGMENTS_NONE) {
Expand Down
12 changes: 7 additions & 5 deletions src/output-json-frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,9 @@ static int FrameJson(ThreadVars *tv, JsonFrameLogThread *aft, const Packet *p)
int64_t abs_offset = (int64_t)frame->offset + (int64_t)STREAM_BASE_OFFSET(stream);
int64_t win = STREAM_APP_PROGRESS(stream) - abs_offset;

if (!eof && win < frame->len && win < 2500) {
/* skip frame if threshold not yet reached, esp if frame length is
* still unknown. */
if (!eof && ((frame->len == -1) || (win < frame->len)) && win < 2500) {
SCLogDebug("frame id %" PRIi64 " len %" PRIi64 ", win %" PRIi64
", skipping logging",
frame->id, frame->len, win);
Expand All @@ -390,8 +392,6 @@ static int FrameJson(ThreadVars *tv, JsonFrameLogThread *aft, const Packet *p)
OutputJsonBuilderBuffer(tv, p, p->flow, jb, aft->ctx);
jb_free(jb);
frame->flags |= FRAME_FLAG_LOGGED;
} else if (frame != NULL) {
SCLogDebug("frame %p id %" PRIi64, frame, frame->id);
}
}
return TM_ECODE_OK;
Expand All @@ -410,9 +410,11 @@ static bool JsonFrameLogCondition(ThreadVars *tv, void *thread_data, const Packe

if ((p->proto == IPPROTO_TCP || p->proto == IPPROTO_UDP) && p->flow->alparser != NULL) {
if (p->proto == IPPROTO_TCP) {
if ((p->flow->flags & FLOW_TS_APP_UPDATED) && PKT_IS_TOSERVER(p)) {
if ((PKT_IS_PSEUDOPKT(p) || (p->flow->flags & FLOW_TS_APP_UPDATED)) &&
PKT_IS_TOSERVER(p)) {
// fallthrough
} else if ((p->flow->flags & FLOW_TC_APP_UPDATED) && PKT_IS_TOCLIENT(p)) {
} else if ((PKT_IS_PSEUDOPKT(p) || (p->flow->flags & FLOW_TC_APP_UPDATED)) &&
PKT_IS_TOCLIENT(p)) {
// fallthrough
} else {
return false;
Expand Down
Loading