Skip to content

Commit c668199

Browse files
ssharksmbolivar-nordic
authored andcommitted
net: tcp: Correctly determine when the TCP transmit window is full
In the stack both unacked_len and send_data_total track the amount of data for retransmission. send_data_total actually accounts the total bytes in the buffer, where unacked_len is used to control the retransmission progress. Using unacked_len is sometimes reset to 0, this can lead to more data being allowd in the send_data buffer. In worse case this can cause depletion of the net buffers, causing a stall and crash of the connection. The value send_data_total actually accounts the total amount of data in the send_data buffer, so it is the proper value to used in the tcp_window_full function. Signed-off-by: Sjors Hettinga <[email protected]>
1 parent bc2f83f commit c668199

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

subsys/net/ip/tcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ static int tcp_pkt_peek(struct net_pkt *to, struct net_pkt *from, size_t pos,
978978

979979
static bool tcp_window_full(struct tcp *conn)
980980
{
981-
bool window_full = !(conn->unacked_len < conn->send_win);
981+
bool window_full = (conn->send_data_total >= conn->send_win);
982982

983983
NET_DBG("conn: %p window_full=%hu", conn, window_full);
984984

0 commit comments

Comments
 (0)