Hi, This calculation of the receive window has a logic error:
If win is 0 it will be overwritten by (rcv_adv - rcv_nxt). Thus, win will be (rcv_adv - rcv_nxt) even if its below (sb_hiwat / 4). We could just remove the dead (sb_hiwat / 4) code, or reorder the conditions to keep the original feature. OK? bye, Jan Index: netinet/tcp_output.c =================================================================== RCS file: /cvs/src/sys/netinet/tcp_output.c,v retrieving revision 1.130 diff -u -p -r1.130 tcp_output.c --- netinet/tcp_output.c 8 Feb 2021 19:37:15 -0000 1.130 +++ netinet/tcp_output.c 22 Jul 2021 12:33:13 -0000 @@ -812,12 +812,12 @@ send: * Calculate receive window. Don't shrink window, * but avoid silly window syndrome. */ - if (win < (long)(so->so_rcv.sb_hiwat / 4) && win < (long)tp->t_maxseg) - win = 0; if (win > (long)TCP_MAXWIN << tp->rcv_scale) win = (long)TCP_MAXWIN << tp->rcv_scale; if (win < (long)(int32_t)(tp->rcv_adv - tp->rcv_nxt)) win = (long)(int32_t)(tp->rcv_adv - tp->rcv_nxt); + if (win < (long)(so->so_rcv.sb_hiwat / 4) && win < (long)tp->t_maxseg) + win = 0; if (flags & TH_RST) win = 0; th->th_win = htons((u_int16_t) (win>>tp->rcv_scale));