🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.bugs.2bsd
Article #326

Fix to tcp_input.c to prevent remote ECONNRESET

#326
From: Vic Abell
Date: Wed, 20 Aug 1986 21:31
54 lines
2160 bytes
Symptom:  A 2.9BSD client writes a stream of data to a remote peer and
	  closes the socket.  The remote peer sometimes receives an
	  ECONNRESET error instead of an EOF.

Cause:    Any segment received by tcp_input.c after a 2.9BSD socket has
	  been closed causes it to return an RST to the remote peer.  If
	  the application in the remote peer has not yet read all the data
	  in transit, the data will be flushed and the peer will receive an
	  ECONNRESET error reply to its read call.

Cure:	  Modify tcp_input.c to avoid the reset if no data accompanies the
	  segment.

	  move lines 353 through 361 that read:

		/*
		 * If data is received on a connection after the
		 * user processes are gone, then RST the other end.
		 */
		if (so->so_state & SS_USERGONE) {
			tcp_close(tp);
			tp = 0;
			goto dropwithreset;
		}
	
	before the comment at lines 290 through 294 that reads:

		/*
		 * States other than LISTEN or SYN_SENT.
		 * First check that at least some bytes of segment are within
		 * receive window.
		 */

	modifying them to be:

		/*
		 * If data is received on a connection after the
		 * user processes are gone, then RST the other end.
		 */
		if (so->so_state & SS_USERGONE) {
			tcp_close(tp);
			tp = 0;
			if (ti->ti_len)
				goto dropwithreset;
			goto drop;
		}

This code has been lifted (with tailoring for 2.9BSD) from 4.2BSD and
4.3BSD.  It has the additional virtue that sockets disappear very quickly
after two peers have closed them by mutual agreement.


Vic Abell, Purdue University Computing Center, abe@j.cc.purdue.edu
Technical Details
Message-ID: <1828@j.cc.purdue.edu>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!caip!clyde!cbatt!cbosgd!ihnp4!inuxc!pur-ee!j.cc.purdue.edu!abe

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!caip!clyde!cbatt!cbosgd!ihnp4!inuxc!pur-ee!j.cc.purdue.edu!abe
From: abe@j.cc.purdue.edu (Vic Abell)
Newsgroups: net.bugs.2bsd
Subject: Fix to tcp_input.c to prevent remote ECONNRESET
Message-ID: <1828@j.cc.purdue.edu>
Date: Wed, 20-Aug-86 17:31:55 EDT
Article-I.D.: j.1828
Posted: Wed Aug 20 17:31:55 1986
Date-Received: Thu, 21-Aug-86 05:47:12 EDT
Organization: Purdue University Computing Center
Lines: 54
Keywords: tcp_input.c, RST, ECONNRESET