Skip site navigation (1)Skip section navigation (2)
Date:      Wed,  8 Sep 1999 04:58:04 -0700 (PDT)
From:      david@inty.net
To:        freebsd-gnats-submit@freebsd.org
Subject:   bin/13639: incorrect handling of TCP reset connection in libalias
Message-ID:  <19990908115804.85ED214D07@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990908115804.85ED214D07>