From ccc729300fe603bc8347b9f689f8ff5c8a5ac15d Mon Sep 17 00:00:00 2001 From: andre Date: Sat, 9 Jun 2007 21:19:12 +0000 Subject: Make the handling of the tcp window explicit for the SYN_SENT case in tcp_outout(). This is currently not strictly necessary but paves the way to simplify the entire SYN options handling quite a bit. Clarify comment. No change in effective behavour with this commit. RFC1323 requires the window field in a SYN (i.e., a or ) segment itself never be scaled. --- sys/netinet/tcp_output.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index d8adff3..da30813 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -906,9 +906,6 @@ send: /* * Calculate receive window. Don't shrink window, * but avoid silly window syndrome. - * - * XXX: RFC1323: The Window field in a SYN (i.e., a or - * ) segment itself is never scaled. */ if (recwin < (long)(so->so_rcv.sb_hiwat / 4) && recwin < (long)tp->t_maxseg) @@ -917,8 +914,17 @@ send: recwin = (long)(tp->rcv_adv - tp->rcv_nxt); if (recwin > (long)TCP_MAXWIN << tp->rcv_scale) recwin = (long)TCP_MAXWIN << tp->rcv_scale; - th->th_win = htons((u_short) (recwin >> tp->rcv_scale)); + /* + * According to RFC1323 the window field in a SYN (i.e., a + * or ) segment itself is never scaled. The + * case is handled in syncache. + */ + if (flags & TH_SYN) + th->th_win = htons((u_short) + (min(sbspace(&so->so_rcv), TCP_MAXWIN))); + else + th->th_win = htons((u_short)(recwin >> tp->rcv_scale)); /* * Adjust the RXWIN0SENT flag - indicate that we have advertised -- cgit v1.1