Make sure we reuse a TCP session if we receive a valid 3WHS on a closed TCP session, can happen if a new session has the same tuple.

remotes/origin/master-1.1.x
Victor Julien 15 years ago
parent 24f071cabb
commit b5a5ef14b9

@ -2725,15 +2725,23 @@ static int StreamTcpPacket (ThreadVars *tv, Packet *p, StreamTcpThread *stt)
SCReturnInt(-1); SCReturnInt(-1);
break; break;
case TCP_CLOSED: case TCP_CLOSED:
/* As our TCP session memory is not returned to pool, until /* TCP session memory is not returned to pool until timeout.
timeout. If in the mean time we receive any other session from * If in the mean time we receive any other session from
the same client reusing same port then we switch back to * the same client reusing same port then we switch back to
tcp state none */ * tcp state none, but only on a valid SYN that is not a
if (PKT_IS_TOSERVER(p) && (p->tcph->th_flags & TH_SYN)) { * resend from our previous session.
if(SEQ_EQ(ssn->client.next_seq, TCP_GET_SEQ(p))) { *
if(StreamTcpPacketStateNone(tv,p,stt,ssn)) { * We also check it's not a SYN/ACK, all other SYN pkt
SCReturnInt(-1); * validation is done at StreamTcpPacketStateNone();
} */
if (PKT_IS_TOSERVER(p) && (p->tcph->th_flags & TH_SYN) &&
!(p->tcph->th_flags & TH_ACK) &&
!(SEQ_EQ(ssn->client.isn, TCP_GET_SEQ(p))))
{
SCLogDebug("reusing closed TCP session");
if (StreamTcpPacketStateNone(tv,p,stt,ssn)) {
SCReturnInt(-1);
} }
} else { } else {
SCLogDebug("packet received on closed state"); SCLogDebug("packet received on closed state");

Loading…
Cancel
Save