From owner-freebsd-bugs Wed Sep 8 5: 1:52 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id E4D9C14E93 for ; Wed, 8 Sep 1999 05:01:46 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id FAA15127; Wed, 8 Sep 1999 05:00:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: by hub.freebsd.org (Postfix, from userid 32767) id 85ED214D07; Wed, 8 Sep 1999 04:58:04 -0700 (PDT) Message-Id: <19990908115804.85ED214D07@hub.freebsd.org> Date: Wed, 8 Sep 1999 04:58:04 -0700 (PDT) From: david@inty.net To: freebsd-gnats-submit@freebsd.org X-Send-Pr-Version: www-1.0 Subject: bin/13639: incorrect handling of TCP reset connection in libalias Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 13639 >Category: bin >Synopsis: incorrect handling of TCP reset connection in libalias >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Sep 8 05:00:01 PDT 1999 >Closed-Date: >Last-Modified: >Originator: David Hedley >Release: 3.2 >Organization: INTY >Environment: FreeBSD server.inty.net 3.2-RELEASE FreeBSD 3.2-RELEASE #1: Thu Jul 22 15:18:40 BST 1999 david@server.inty.net:/usr/src/sys/compile/GENERIC+MODS i386 >Description: If an incoming connection is initiated through natd and deny_incoming is not set, then a new alias_link structure is created to handle the link. If there is nothing listening for the incoming connection, then the kernel responds with a RST for the connection. However, this is not processed correctly in libalias/alias.c:TcpMonitor{In,Out} and libalias/alias_db.c:SetState{In,Out} as it thinks a connection has been established and therefore applies a timeout of 86400 seconds to the link. If many of these half-connections are initiated (during, for example, a port scan of the host), then many thousands of unnecessary links are created and the resident size of natd balloons to 20MB or more. >How-To-Repeat: Run natd without deny_incoming. Run a TCP port scanner against the machine. >Fix: The following patch will tell libalias to realise that a connection hasn't, in fact, been completed and thus will give the newly created link a timeout of TCP_EXPIRE_DEAD: *** /usr/src/lib/libalias/alias.c Wed Mar 24 17:12:00 1999 --- libalias/alias.c Wed Jul 28 10:58:32 1999 *************** *** 139,144 **** --- 139,148 ---- case ALIAS_TCP_STATE_NOT_CONNECTED: if (tc->th_flags & TH_SYN) SetStateIn(link, ALIAS_TCP_STATE_CONNECTED); + if (tc->th_flags & TH_RST) { + SetStateIn(link, ALIAS_TCP_STATE_DISCONNECTED); + SetStateOut(link, ALIAS_TCP_STATE_DISCONNECTED); + } break; case ALIAS_TCP_STATE_CONNECTED: if (tc->th_flags & TH_FIN *************** *** 160,165 **** --- 164,173 ---- case ALIAS_TCP_STATE_NOT_CONNECTED: if (tc->th_flags & TH_SYN) SetStateOut(link, ALIAS_TCP_STATE_CONNECTED); + if (tc->th_flags & TH_RST) { + SetStateIn(link, ALIAS_TCP_STATE_DISCONNECTED); + SetStateOut(link, ALIAS_TCP_STATE_DISCONNECTED); + } break; case ALIAS_TCP_STATE_CONNECTED: if (tc->th_flags & TH_FIN >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message