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

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

@ -399,20 +399,26 @@ 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)) {
SCLogDebug("reversing flow after proto detect told us so"); /* but only if we didn't already detect it on the other side. */
PacketSwap(p); if (*alproto_otherdir == ALPROTO_UNKNOWN) {
FlowSwap(f); SCLogDebug("reversing flow after proto detect told us so");
SWAP_FLAGS(flags, STREAM_TOSERVER, STREAM_TOCLIENT); PacketSwap(p);
if (*stream == &ssn->client) { FlowSwap(f);
*stream = &ssn->server; SWAP_FLAGS(flags, STREAM_TOSERVER, STREAM_TOCLIENT);
if (*stream == &ssn->client) {
*stream = &ssn->server;
} else {
*stream = &ssn->client;
}
direction = 1 - direction;
} else { } else {
*stream = &ssn->client; // TODO event, error?
} }
direction = 1 - direction;
} }
/* account flow if we have both sides */ /* account flow if we have both sides */

Loading…
Cancel
Save