Bug 13639

Summary: incorrect handling of TCP reset connection in libalias
Product: Base System Reporter: david <david>
Component: binAssignee: ru <ru>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff
none
p none

Description david 1999-09-08 13:00:01 UTC
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.

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:
How-To-Repeat: Run natd without deny_incoming. Run a TCP port scanner against the machine.
Comment 1 Sheldon Hearn freebsd_committer freebsd_triage 1999-09-08 14:25:00 UTC
Responsible Changed
From-To: freebsd-bugs->ru

Over to the natd maintainer. 

Comment 2 Ruslan Ermilov 1999-09-08 16:53:24 UTC
Hi, David!

What do you think of the following trivial patch?

-- 
Ruslan Ermilov		Sysadmin and DBA of the
ru@ucb.crimea.ua	United Commercial Bank,
ru@FreeBSD.org		FreeBSD committer,
+380.652.247.647	Simferopol, Ukraine

http://www.FreeBSD.org	The Power To Serve
http://www.oracle.com	Enabling The Information Age
Comment 3 ru freebsd_committer freebsd_triage 1999-09-12 17:09:55 UTC
State Changed
From-To: open->closed

Fixed in both -stable and -current. 
Thanks for the report!