stream: flag ACKs that ack segments after next_seq

Avoid this for async streams.
pull/8562/head
Victor Julien 2 years ago
parent a0f0a3b48b
commit b7739bfdba

@ -308,6 +308,7 @@ typedef struct TcpSession_ {
#define STREAM_PKT_FLAG_EVENTSET BIT_U16(6)
#define STREAM_PKT_FLAG_DUP_ACK BIT_U16(7)
#define STREAM_PKT_FLAG_DSACK BIT_U16(8)
#define STREAM_PKT_FLAG_ACK_UNSEEN_DATA BIT_U16(9)
#define STREAM_PKT_FLAG_SET(p, f) (p)->tcpvars.stream_pkt_flags |= (f)

@ -2626,8 +2626,14 @@ static int HandleEstablishedPacketToServer(
ssn->server.window);
/* Check if the ACK value is sane and inside the window limit */
if (p->tcph->th_flags & TH_ACK)
if (p->tcph->th_flags & TH_ACK) {
StreamTcpUpdateLastAck(ssn, &ssn->server, TCP_GET_ACK(p));
if ((ssn->flags & STREAMTCP_FLAG_ASYNC) == 0 &&
SEQ_GT(ssn->server.last_ack, ssn->server.next_seq)) {
STREAM_PKT_FLAG_SET(p, STREAM_PKT_FLAG_ACK_UNSEEN_DATA);
}
}
SCLogDebug("ack %u last_ack %u next_seq %u", TCP_GET_ACK(p), ssn->server.last_ack, ssn->server.next_seq);
if (ssn->flags & STREAMTCP_FLAG_TIMESTAMP) {
@ -2756,8 +2762,13 @@ static int HandleEstablishedPacketToClient(
SCLogDebug("ssn %p: ssn->client.window %"PRIu32"", ssn,
ssn->client.window);
if (p->tcph->th_flags & TH_ACK)
if (p->tcph->th_flags & TH_ACK) {
StreamTcpUpdateLastAck(ssn, &ssn->client, TCP_GET_ACK(p));
if ((ssn->flags & STREAMTCP_FLAG_ASYNC) == 0 &&
SEQ_GT(ssn->client.last_ack, ssn->client.next_seq)) {
STREAM_PKT_FLAG_SET(p, STREAM_PKT_FLAG_ACK_UNSEEN_DATA);
}
}
if (ssn->flags & STREAMTCP_FLAG_TIMESTAMP) {
StreamTcpHandleTimestamp(ssn, p);

Loading…
Cancel
Save