Subject: kern/3958: superfluous test in tcp_input.c descriped in TCP/IP Illustrated Vol.2
To: None <gnats-bugs@gnats.netbsd.org>
From: None <frueauf@ira.uka.de>
List: netbsd-bugs
Date: 08/08/1997 16:08:23
>Number:         3958
>Category:       kern
>Synopsis:       superfluous test in tcp_input.c descriped in TCP/IP Illustrated Vol.2
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Aug  8 07:20:01 1997
>Last-Modified:
>Originator:     Thorsten Frueauf
>Organization:
private
	
>Release:        <NetBSD-current source date> NetBSD current 07.08.1997
>Environment:
	
System: NetBSD cyberlap 1.2G NetBSD 1.2G (CYBERLAP) #6: Thu Aug 7 16:35:37 CEST 1997 frueauf@cyberlap:/usr/src/sys/arch/i386/compile/CYBERLAP i386


>Description:
	
To cite page 948/949 in TCP/IP Illustrated Vol. 2:

"The second test appears superfluous. At the beginning of Figure 28.20
[beginning from line 633 in the NetBSD code] `snd_una' was set to the
received acknowledgement field if the ACK flag was on. Also the `if'
following the `case' statement in Figure 28.18 verified that the received
acknowledment field is greater than the ISS. So at this point in the code, if
the ACK flag is set, we're already guaranteed that `snd_una' is greater
than the ISS."

>How-To-Repeat:
	
Read TCP/IP Illustrated Vol. 2 on page 948/949 :)

>Fix:
	
Apply the following diff to /src/sys/netinet/tcp_input.c:

*** tcp_input.c-orig	Fri Aug  8 15:44:25 1997
--- tcp_input.c	Fri Aug  8 15:45:24 1997
***************
*** 652,658 ****
  		tcp_rcvseqinit(tp);
  		tp->t_flags |= TF_ACKNOW;
  		tcp_mss(tp, opti.maxseg);
! 		if (tiflags & TH_ACK && SEQ_GT(tp->snd_una, tp->iss)) {
  			tcpstat.tcps_connects++;
  			soisconnected(so);
  			tp->t_state = TCPS_ESTABLISHED;
--- 652,658 ----
  		tcp_rcvseqinit(tp);
  		tp->t_flags |= TF_ACKNOW;
  		tcp_mss(tp, opti.maxseg);
! 		if (tiflags & TH_ACK) {
  			tcpstat.tcps_connects++;
  			soisconnected(so);
  			tp->t_state = TCPS_ESTABLISHED;
>Audit-Trail:
>Unformatted:
superfluous test in tcp_input.c descriped in TCP/IP Illustrated Vol.2