From: Patrick McHardy <kaber@trash.net>
To: "Thomas Bätzler" <t.baetzler@bringe.com>
Cc: netfilter@vger.kernel.org
Subject: Re: Weird nat/conntrack Problem with PASV FTP upload
Date: Thu, 05 Jun 2008 15:59:41 +0200 [thread overview]
Message-ID: <4847F14D.5000806@trash.net> (raw)
In-Reply-To: <E350C77ABFDBD242BDD51F5DA07905C102825E13@SONNE.gw.bringe.net>
Thomas Bätzler wrote:
> Hi & thank you for taking the time to have a look at this.
>
> The basic setup is like this:
>
> (ftp client)<=>(my nat box)<=big pipe=>(their nat box)<=>(ftp server)
>
> The FTP client is PHP5's FTP library on a Debian Etch box with kernel 2.6.23 built from a Debian source package.
> My NAT box is also Debian Etch, recently upgraded to 2.6.25 using the current Debian source package.
> I Don't know much about the remote side, except that their FTP server is supposedly ProFTPd on Debian Etch.
>
> We use PASV FTP transfers for our uploads and that's been working o.k. for us most of the time.
>
> I say "most of the time" because we lose the data connection in about 1% of the transfers (mostly files in the 100kB to 5MB Range).
>
> I've tcpdump'ed a some of those transfers on the external interface of my NAT box and on the client, and I don't understand what's going on. Let me give you an example:
>
> tcpdump -rtttS on myclient:
>
> 000000 IP myclient.56785 > server.39790: SWE 427872165:427872165(0) win 5840 <mss 1460,sackOK,timestamp 481846634 0,nop,w
> scale 7>
> 015646 IP server.39790 > myclient.56785: SE 2283192455:2283192455(0) ack 427872166 win 5792 <mss 1460,sackOK,timestamp 16317902 481846634,nop,wscale 7>
> 000010 IP myclient.56785 > server.39790: . ack 2283192456 win 46 <nop,nop,timestamp 481846636 16317902>
> [...]
> 000002 IP myclient.56785 > server.39790: . 428128803:428131699(2896) ack 2283192456 win 46 <nop,nop,timestamp 481846649 16317934>
> 000784 IP server.39790 > myclient.56785: . ack 428044995 win 696 <nop,nop,timestamp 16317935 481846647,nop,nop,sack 1 {428046443:428047891}>
> 000006 IP myclient.56785 > server.39790: . 428131699:428134083(2384) ack 2283192456 win 46 <nop,nop,timestamp 481846649 16317935>
> 000002 IP server.39790 > myclient.56785: . ack 428047891 win 686 <nop,nop,timestamp 16317935 481846647>
> 000003 IP myclient.56785 > server.39790: . 428134083:428135699(1616) ack 2283192456 win 46 <nop,nop,timestamp 481846649 16317935>
> 000004 IP server.39790 > myclient.56785: . ack 428049339 win 675 <nop,nop,timestamp 16317935 481846647>
>
> tcpdump -rtttS on natbox:
>
> 000000 IP mynatbox.56785 > server.39790: SWE 427872165:427872165(0) win 5840 <mss 1460,sackOK,timestamp 481846634 0,nop,wscale 7>
> 015564 IP server.39790 > mynatbox.56785: SE 2283192455:2283192455(0) ack 427872166 win 5792 <mss 1460,sackOK,timestamp 16317902 481846634,nop,wscale 7>
> 000062 IP mynatbox.56785 > server.39790: . ack 2283192456 win 46 <nop,nop,timestamp 481846636 16317902>
> [...]
> 000004 IP mynatbox.56785 > server.39790: . 428128803:428130251(1448) ack 2283192456 win 46 <nop,nop,timestamp 481846649 16317934>
> 000034 IP mynatbox.56785 > server.39790: . 428130251:428131699(1448) ack 2283192456 win 46 <nop,nop,timestamp 481846649 16317934>
> 000560 IP server.39790 > mynatbox.56785: . ack 428042099 win 700 <nop,nop,timestamp 16317935 481846647,nop,nop,sack 1 {428046443:428047891}>
> 000020 IP mynatbox.56785 > server.39790: R 428042099:428042099(0) win 0
> 000002 IP server.39790 > mynatbox.56785: . ack 428042099 win 700 <nop,nop,timestamp 16317935 481846647,nop,nop,sack 2 {428043547:428044995}{428046443:428047891}>
> 000005 IP mynatbox.56785 > server.39790: R 428042099:428042099(0) win 0
> 000002 IP server.39790 > mynatbox.56785: . ack 428044995 win 696 <nop,nop,timestamp 16317935 481846647,nop,nop,sack 1 {428046443:428047891}>
> 000006 IP server.39790 > mynatbox.56785: . ack 428047891 win 686 <nop,nop,timestamp 16317935 481846647>
> 000005 IP server.39790 > mynatbox.56785: . ack 428049339 win 675 <nop,nop,timestamp 16317935 481846647>
>
>
> Now I don't know why myclient thinks it's sending 2k+ byte segments, since its interface MTU is definitely 1500, and it also agreed on a mss of 1460. Since myclient's NIC is an e1000, it might be tcp segmentation offload at work.
Probably.
> No, what's really scaring me is that natbox tries to tear down the data connection for no apparent reason. Like in the example shown, it seems to happen mostly when server sends a selective ack for an out-of-order segment. Sometimes server just shrugs the rst off and keeps on acking data, but at other times it gives in and tears down the connection.
>
> I'm grateful for any pointer or explanation you might have for me. Right now I'm at my wit's end.
I guess you're seeing INVALID packets (from the view of conntrack)
and they're thus not NATed but delivered locally, causing a RST.
Does dropping -m state --state INVALID packets in PREROUTING make
any difference?
next prev parent reply other threads:[~2008-06-05 13:59 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-05 9:02 Weird nat/conntrack Problem with PASV FTP upload Thomas Bätzler
2008-06-05 13:59 ` Patrick McHardy [this message]
2008-06-06 13:56 ` Thomas Bätzler
2008-06-06 15:02 ` Patrick McHardy
2008-06-09 9:06 ` Jan Engelhardt
2008-06-09 9:09 ` Patrick McHardy
2008-06-09 12:38 ` Jan Engelhardt
-- strict thread matches above, loose matches on Subject: below --
2008-06-09 8:58 Thomas Bätzler
2008-06-09 9:14 ` Jozsef Kadlecsik
2008-06-09 10:36 Thomas Bätzler
2008-06-09 11:21 ` Jozsef Kadlecsik
2008-06-09 12:35 Thomas Bätzler
2008-06-09 12:53 ` Jozsef Kadlecsik
2008-06-10 8:28 ` Jozsef Kadlecsik
2008-06-11 8:50 ` Thomas Bätzler
2008-06-23 10:49 ` Jozsef Kadlecsik
2008-06-23 13:46 ` Thomas Bätzler
2008-06-25 9:47 ` Thomas Bätzler
2008-06-25 9:50 ` Jozsef Kadlecsik
2008-06-23 12:50 ` Thomas Bätzler
2008-06-23 13:15 ` Jozsef Kadlecsik
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=4847F14D.5000806@trash.net \
--to=kaber@trash.net \
--cc=netfilter@vger.kernel.org \
--cc=t.baetzler@bringe.com \
/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