stream: use flow/packet swap logic for SYN/ACK midstream

pull/3739/head
Victor Julien 8 years ago
parent 2f1ace64c6
commit 9c241fa32c

@ -927,6 +927,12 @@ static int StreamTcpPacketStateNone(ThreadVars *tv, Packet *p,
StatsIncr(tv, stt->counter_tcp_sessions);
StatsIncr(tv, stt->counter_tcp_midstream_pickups);
}
/* reverse packet and flow */
SCLogDebug("reversing flow and packet");
PacketSwap(p);
FlowSwap(p->flow);
/* set the state */
StreamTcpPacketSetState(p, ssn, TCP_SYN_RECV);
SCLogDebug("ssn %p: =~ midstream picked ssn state is now "
@ -1001,9 +1007,7 @@ static int StreamTcpPacketStateNone(ThreadVars *tv, Packet *p,
SCLogDebug("ssn %p: SYN/ACK with SACK permitted, assuming "
"SACK permitted for both sides", ssn);
}
/* packet thinks it is in the wrong direction, flip it */
StreamTcpPacketSwitchDir(ssn, p);
return 0;
} else if (p->tcph->th_flags & TH_SYN) {
if (ssn == NULL) {
@ -4774,11 +4778,6 @@ int StreamTcpPacket (ThreadVars *tv, Packet *p, StreamTcpThread *stt,
p->flags |= PKT_STREAM_NO_EVENTS;
}
/* check if the packet is in right direction, when we missed the
SYN packet and picked up midstream session. */
if (ssn->flags & STREAMTCP_FLAG_MIDSTREAM_SYNACK)
StreamTcpPacketSwitchDir(ssn, p);
if (StreamTcpPacketIsKeepAlive(ssn, p) == 1) {
goto skip;
}

@ -164,21 +164,6 @@ static inline int StreamTcpCheckFlowDrops(Packet *p)
return 0;
}
/**
* \brief Function to flip the direction When we missed the SYN packet,
* SYN/ACK is considered as sent by server, but our engine flagged the
* packet as from client for the host whose packet is received first in
* the session.
*
* \param ssn TcpSession to whom this packet belongs
* \param p Packet whose flag has to be changed
*/
static inline void StreamTcpPacketSwitchDir(TcpSession *ssn, Packet *p)
{
SCLogDebug("ssn %p: switching pkt direction", ssn);
PacketSwap(p);
}
enum {
/* stream has no segments for forced reassembly, nor for detection */
STREAM_HAS_UNPROCESSED_SEGMENTS_NONE = 0,

Loading…
Cancel
Save