Subject: kern/3738: bug in tcp_usrreq.c documentad in "TCP/IP Illustrated Vol. 2"
To: None <gnats-bugs@gnats.netbsd.org>
From: None <frueauf@ira.uka.de>
List: netbsd-bugs
Date: 06/11/1997 22:16:56
>Number:         3738
>Category:       kern
>Synopsis:       bug in tcp_usrreq.c documentad in "TCP/IP Illustrated Vol. 2"
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 11 13:20:04 1997
>Last-Modified:
>Originator:     Thorsten Frueauf
>Organization:
private
	
>Release:        <NetBSD-current source date> NetBSD current 10.06.1997
>Environment:
	
System: NetBSD cyberlap 1.2F NetBSD 1.2F (CYBERLAP) #6: Wed Jun 11 10:37:05 CEST 1997 frueauf@cyberlap:/usr/src/sys/arch/i386/compile/CYBERLAP i386


>Description:
	
On page 1010 of "TCP/IP Illustrated Vol. 2":

"The test for the state being greater than LISTEN is incorrect, because if the
state is SYN_SENT or SYN_RCVD, both of which are greater than LISTEN,
tcp_disconnect just calls tcp_close. This case could be simplified by just
calling tcp_disconnect."

>How-To-Repeat:
	
Read page 1010 of "TCP/IP Illustrated Vol. 2".

>Fix:
	
Apply the following patch to /src/sys/netinet/tcp_usrreq.c:

*** tcp_usrreq.c-orig	Wed Jun 11 21:59:57 1997
--- tcp_usrreq.c	Wed Jun 11 22:06:35 1997
***************
*** 148,157 ****
  	 * be discarded here.
  	 */
  	case PRU_DETACH:
! 		if (tp->t_state > TCPS_LISTEN)
! 			tp = tcp_disconnect(tp);
! 		else
! 			tp = tcp_close(tp);
  		break;
  
  	/*
--- 148,154 ----
  	 * be discarded here.
  	 */
  	case PRU_DETACH:
! 		tp = tcp_disconnect(tp);
  		break;
  
  	/*
>Audit-Trail:
>Unformatted:
bug in tcp_usrreq.c documentad in "TCP/IP Illustrated Vol. 2"