Skip to content
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
3 changes: 2 additions & 1 deletion src/detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ static void DetectRun(ThreadVars *th_v,
PACKET_PROFILING_DETECT_END(p, PROF_DETECT_RULES);

/* run tx/state inspection. Don't call for ICMP error msgs. */
if (pflow && pflow->alstate && likely(pflow->proto == p->proto)) {
if (pflow && pflow->alstate && likely(pflow->proto == p->proto) &&
(p->flags & PKT_STREAM_EST)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one thing I would like to know here is if TCP fast open, data on syn, IPS mode (so app-layer is called immediately) also sets this flag

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should a similar check be done before the tx logging is called?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should a similar check be done before the tx logging is called?

There are likely other places where this optimization can happen

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also the flag will only be set for TCP I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one thing I would like to know here is if TCP fast open, data on syn, IPS mode (so app-layer is called immediately) also sets this flag

I do not think it does :
Code should get into StreamTcpPacketStateNone, case if (p->tcph->th_flags & TH_SYN) and TCP_HAS_TFO so not going to set PKT_STREAM_EST because not in same code path as StreamTcpPacketStateNone

if (p->proto == IPPROTO_TCP) {
const TcpSession *ssn = p->flow->protoctx;
if (ssn && (ssn->flags & STREAMTCP_FLAG_APP_LAYER_DISABLED) == 0) {
Expand Down
5 changes: 3 additions & 2 deletions src/flow-worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,9 @@ static TmEcode FlowWorker(ThreadVars *tv, Packet *p, void *data)
FramesPrune(p->flow, p);
}

if ((PKT_IS_PSEUDOPKT(p)) ||
(p->flow->flags & (FLOW_TS_APP_UPDATED | FLOW_TC_APP_UPDATED))) {
if ((p->flags & PKT_STREAM_EST) &&
((PKT_IS_PSEUDOPKT(p)) ||
(p->flow->flags & (FLOW_TS_APP_UPDATED | FLOW_TC_APP_UPDATED)))) {
if (PKT_IS_TOSERVER(p)) {
if (PKT_IS_PSEUDOPKT(p) || (p->flow->flags & (FLOW_TS_APP_UPDATED))) {
AppLayerParserTransactionsCleanup(p->flow, STREAM_TOSERVER);
Expand Down