diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index 53fe05edd3b5..11c5ec4e8357 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1172,14 +1172,18 @@ tcp_output(struct tcpcb *tp) /* * Calculate receive window. Don't shrink window, * but avoid silly window syndrome. + * If a RST segment is sent, advertise a window of zero. */ - if (recwin < (so->so_rcv.sb_hiwat / 4) && - recwin < tp->t_maxseg) + if (flags & TH_RST) { recwin = 0; - if (SEQ_GT(tp->rcv_adv, tp->rcv_nxt) && - recwin < (tp->rcv_adv - tp->rcv_nxt)) - recwin = (tp->rcv_adv - tp->rcv_nxt); - + } else { + if (recwin < (so->so_rcv.sb_hiwat / 4) && + recwin < tp->t_maxseg) + recwin = 0; + if (SEQ_GT(tp->rcv_adv, tp->rcv_nxt) && + recwin < (tp->rcv_adv - tp->rcv_nxt)) + recwin = (tp->rcv_adv - tp->rcv_nxt); + } /* * According to RFC1323 the window field in a SYN (i.e., a * or ) segment itself is never scaled. The diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index 5b1db5c70f66..556b747dc667 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -8189,15 +8189,20 @@ rack_output(struct tcpcb *tp) /* * Calculate receive window. Don't shrink window, but avoid silly * window syndrome. + * If a RST segment is sent, advertise a window of zero. */ - if (recwin < (long)(so->so_rcv.sb_hiwat / 4) && - recwin < (long)tp->t_maxseg) + if (flags & TH_RST) { recwin = 0; - if (SEQ_GT(tp->rcv_adv, tp->rcv_nxt) && - recwin < (long)(tp->rcv_adv - tp->rcv_nxt)) - recwin = (long)(tp->rcv_adv - tp->rcv_nxt); - if (recwin > (long)TCP_MAXWIN << tp->rcv_scale) - recwin = (long)TCP_MAXWIN << tp->rcv_scale; + } else { + if (recwin < (long)(so->so_rcv.sb_hiwat / 4) && + recwin < (long)tp->t_maxseg) + recwin = 0; + if (SEQ_GT(tp->rcv_adv, tp->rcv_nxt) && + recwin < (long)(tp->rcv_adv - tp->rcv_nxt)) + recwin = (long)(tp->rcv_adv - tp->rcv_nxt); + if (recwin > (long)TCP_MAXWIN << tp->rcv_scale) + recwin = (long)TCP_MAXWIN << tp->rcv_scale; + } /* * According to RFC1323 the window field in a SYN (i.e., a or