app-layer: don't switch dir if proto already known

pull/7226/head
Victor Julien 4 years ago
parent 7b55f8b2e3
commit 86e8611f5e

@ -399,10 +399,13 @@ static int TCPProtoDetect(ThreadVars *tv,
TcpSessionSetReassemblyDepth(ssn, TcpSessionSetReassemblyDepth(ssn,
AppLayerParserGetStreamDepth(f)); AppLayerParserGetStreamDepth(f));
FlagPacketFlow(p, f, flags); FlagPacketFlow(p, f, flags);
/* if protocol detection indicated that we need to reverse /* if protocol detection indicated that we need to reverse
* the direction of the flow, do it now. We flip the flow, * the direction of the flow, do it now. We flip the flow,
* packet and the direction flags */ * packet and the direction flags */
if (reverse_flow && (ssn->flags & STREAMTCP_FLAG_MIDSTREAM)) { if (reverse_flow && (ssn->flags & STREAMTCP_FLAG_MIDSTREAM)) {
/* but only if we didn't already detect it on the other side. */
if (*alproto_otherdir == ALPROTO_UNKNOWN) {
SCLogDebug("reversing flow after proto detect told us so"); SCLogDebug("reversing flow after proto detect told us so");
PacketSwap(p); PacketSwap(p);
FlowSwap(f); FlowSwap(f);
@ -413,6 +416,9 @@ static int TCPProtoDetect(ThreadVars *tv,
*stream = &ssn->client; *stream = &ssn->client;
} }
direction = 1 - direction; direction = 1 - direction;
} else {
// TODO event, error?
}
} }
/* account flow if we have both sides */ /* account flow if we have both sides */

Loading…
Cancel
Save