Skip to content

Commit 5c9e98b

Browse files
committed
feat: increment recv next with payload in case of syn during an already established connection
1 parent df2bf56 commit 5c9e98b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/core/tcp_in.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -848,9 +848,14 @@ tcp_process(struct tcp_pcb *pcb)
848848
}
849849

850850
if ((flags & TCP_SYN) && (pcb->state != SYN_SENT && pcb->state != SYN_RCVD)) {
851-
/* Cope with new connection attempt after remote end crashed.
852-
* NOTE: We don't process SYN payload here - this is an unexpected SYN
853-
* on an already established connection, so we just ACK it and continue. */
851+
#if SYN_WITH_PAYLOAD_ENABLED
852+
/* RFC Compliance: Handle SYN with payload in unexpected states.
853+
* Update rcv_nxt to account for SYN flag and any payload to maintain
854+
* correct sequence tracking and generate proper ACK numbers.
855+
* Note: Sequence nb could be the same becuase we don't intend a new seq nb */
856+
pcb->rcv_nxt += tcplen;
857+
#endif
858+
/* Cope with new connection attempt after remote end crashed */
854859
tcp_ack_now(pcb);
855860
return ERR_OK;
856861
}

0 commit comments

Comments
 (0)