netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Larry Auton <netfilter@winux.com>
To: netfilter-devel@vger.kernel.org
Subject: TCP connections that use NAT silently time out
Date: Tue, 06 Nov 2007 09:25:31 -0500	[thread overview]
Message-ID: <4730795B.6080107@winux.com> (raw)

This report was originally posted on Friday, Nov 2.  I haven't seen any 
response or acknowledgment of the issue.  Is there any interest?

Note:
 this bug is real, one side gets RST the other just hangs
 it's easy to reproduce and I've included trivial code that reproduces it

Larry
----
Date:   Fri, 02 Nov 2007 15:40:52 -0400
From:   Larry Auton <netfilter@winux.com>
To:     netfilter-devel@vger.kernel.org
Subject: TCP connections that use NAT silently time out

See http://www.winux.com/hc/ for the sample programs.  The entire 
package is in hc.tgz

TCP connections that use NAT silently time out after 60 seconds if one
of the peers shutsdown its write-side of the connection.  This sequence
illustrates the problem.

c.1             fd = socket(...)
c.2             connect(... fd ...)
        s.1                             fd = accept(...)
c.3             write(...)
        s.2                             read(...)
c.4             shutdown(fd, SHUT_WR)
c.5             read(...)
        s.3                             sleep(65)
        s.4                             write(....)

If the client is on one side of a NAT connection and the server is
on the other side, then Step c.5 NEVER COMPLETES.  It will simpy hang.

Packet sniffing shows that the NAT host sends RST responses to
the "outside" server machine when it sends the data to the client
at step s.4.

After the ACK in response to the client's write (step c.3) is forwarded
to the client,
no more packets are sent from the NAT machine to the client.

The URL above provides two simple C programs that illustrate the problem.

on the "outside" server (say 192.168.136.7)

        $ hc-server

on the "inside" client machine

        $ hc-client 192.168.136.7 9999 1 65

        the arguments are:

        x.x.x.x = IP address of the "outside" server
           9999 = server port number
              1 = whether or not to do the half-close
             65 = seconds of delay before the server responds

It will complete normally if any of the following are true:

        use delay of less than 60 seconds
        don't use the half-close (set to next to last argument to 0)
        server is NOT on the far side of a NAT connection

Otherwise, the client will hang until a SIGALRM wakes it 15 seconds after
the delay period has elapsed.


             reply	other threads:[~2007-11-06 14:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-06 14:25 Larry Auton [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-11-02 19:40 TCP connections that use NAT silently time out Larry Auton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4730795B.6080107@winux.com \
    --to=netfilter@winux.com \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).