From e53f98999714047a035d43c35cc3ebd50d2c9fa2 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 27 Jul 2021 13:47:18 +0900 Subject: [PATCH] tcp_rexmit: advance conn->sndseq Otherwise, we use an old sequence number when sending non-data segment. (eg. window update) The peer might consider such a segment stale and ignore. --- net/tcp/tcp_appsend.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/tcp/tcp_appsend.c b/net/tcp/tcp_appsend.c index d2a05bd175d..c31a9427417 100644 --- a/net/tcp/tcp_appsend.c +++ b/net/tcp/tcp_appsend.c @@ -319,11 +319,18 @@ void tcp_rexmit(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, if (dev->d_sndlen > 0 && conn->tx_unacked > 0) #endif { + uint32_t seq; + /* We always set the ACK flag in response packets adding the length of * the IP and TCP headers. */ tcp_send(dev, conn, TCP_ACK | TCP_PSH, dev->d_sndlen + hdrlen); + + /* Advance sndseq */ + + seq = tcp_getsequence(conn->sndseq); + tcp_setsequence(conn->sndseq, seq + dev->d_sndlen); } /* If there is no data to send, just send out a pure ACK if one is