netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
To: Krzysztof Oledzki <ole@ans.pl>
Cc: Netfilter Developer Mailing List
	<netfilter-devel@vger.kernel.org>,
	Patrick McHardy <kaber@trash.net>
Subject: Re: PATCH: "invalid SYNIN=" - a patch and a question
Date: Fri, 12 Oct 2007 00:42:05 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0710120026240.14889@blackhole.kfki.hu> (raw)
In-Reply-To: <Pine.LNX.4.64.0710112238010.29814@bizon.gios.gov.pl>

On Thu, 11 Oct 2007, Krzysztof Oledzki wrote:

> Something is still wrong in this area. With the recent fix there are no 
> more "invalid SYNIN=" messages, but with unsuccessful request simulated 
> with "echo|nc" next connections are not possible. 
[...]
> --- cut here ---
> sysctl net.ipv4.ip_local_port_range="50000 50003"
> sysctl net.netfilter.nf_conntrack_log_invalid=255
> 
> while true ; do echo|nc -w 1 wp.pl 80 2>/dev/null >/dev/null; echo -ne "HEAD /
> HTTP/1.0\r\nHost: www.wp.pl\r\n\r\n"|nc -w 2 wp.pl 80 ; sleep 1 ; done
> --- cut here ---

Odd, but I could not reproduce it using my local test webserver. However 
looking through the tcpdump and the kernel log, I think the problem is as 
follows: the aborted connection still lingers in conntrack for 10s (in 
order to catch late packets) and reopening after RST is not handled 
properly yet. You are digging into the grey areas of TCP conntrack ;-).

Could you check the patch below?

If one side aborts an established connection, the entry still lingers for 
10s in conntrack for the late packets. Allow to open up the connection 
again for the party which sent the RST packet.

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
---
 net/netfilter/nf_conntrack_proto_tcp.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 1b836d0..10a04ff 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -834,9 +834,11 @@ static int tcp_packet(struct nf_conn *conntrack,
 	case TCP_CONNTRACK_SYN_SENT:
 		if (old_state < TCP_CONNTRACK_TIME_WAIT)
 			break;
-		if (conntrack->proto.tcp.seen[!dir].flags &
-			IP_CT_TCP_FLAG_CLOSE_INIT) {
-			/* Attempt to reopen a closed connection.
+		if ((conntrack->proto.tcp.seen[!dir].flags & 
+			IP_CT_TCP_FLAG_CLOSE_INIT)
+		    || (conntrack->proto.tcp.last_dir == dir
+		        && conntrack->proto.tcp.last_index == TCP_RST_SET)) {
+			/* Attempt to reopen a closed/aborted connection.
 			* Delete this connection and look up again. */
 			write_unlock_bh(&tcp_lock);
 			if (del_timer(&conntrack->timeout))
-- 
1.5.3.4

Best regards,
Jozsef
-
E-mail  : kadlec@blackhole.kfki.hu, kadlec@sunserv.kfki.hu
PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics
          H-1525 Budapest 114, POB. 49, Hungary

  parent reply	other threads:[~2007-10-11 22:42 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-26 12:27 PATCH: "invalid SYNIN=" - a patch and a question Krzysztof Oledzki
2007-10-03 13:06 ` Krzysztof Oledzki
2007-10-03 13:54   ` Jozsef Kadlecsik
2007-10-03 19:57     ` Krzysztof Oledzki
2007-10-04  7:26       ` Jozsef Kadlecsik
2007-10-04  5:59     ` Patrick McHardy
2007-10-04  7:52       ` Jozsef Kadlecsik
2007-10-04  7:59         ` Patrick McHardy
2007-10-04  8:41           ` Jozsef Kadlecsik
2007-10-05 20:06             ` Krzysztof Oledzki
2007-10-08  9:32               ` Jozsef Kadlecsik
2007-10-08  9:45                 ` Jozsef Kadlecsik
2007-10-08 13:56                   ` Krzysztof Oledzki
2007-10-08 14:01                     ` Krzysztof Oledzki
2007-10-08 13:58                 ` Krzysztof Oledzki
2007-10-08 14:01                   ` Jozsef Kadlecsik
2007-10-08 17:28                     ` Krzysztof Oledzki
2007-10-09  8:11                       ` Jozsef Kadlecsik
2007-10-09 13:17                         ` Krzysztof Oledzki
2007-10-09 13:22                           ` Krzysztof Oledzki
2007-10-08 16:39                 ` Patrick McHardy
2007-10-08 17:23                   ` Krzysztof Oledzki
2007-10-04  6:15   ` Patrick McHardy
2007-10-10 19:26   ` Jozsef Kadlecsik
2007-10-11  4:04     ` Patrick McHardy
2007-10-11 13:52       ` Krzysztof Oledzki
2007-10-31 19:34         ` Krzysztof Oledzki
2007-11-05 11:11           ` Patrick McHardy
2007-11-14 21:46             ` [stable] " Greg KH
2007-10-11 13:50     ` Krzysztof Oledzki
     [not found]     ` <Pine.LNX.4.64.0710112238010.29814@bizon.gios.gov.pl>
2007-10-11 22:42       ` Jozsef Kadlecsik [this message]
2007-10-12 10:09         ` Krzysztof Oledzki
2007-10-12 14:48           ` Jozsef Kadlecsik
2007-10-12 18:09             ` Krzysztof Oledzki
2007-10-17 17:41               ` Jozsef Kadlecsik
2007-10-17 20:08                 ` Krzysztof Oledzki
2007-10-18  8:43                 ` Patrick McHardy
2007-10-04  5:45 ` Patrick McHardy
2007-10-17 20:13   ` Krzysztof Oledzki
2007-10-18  8:43     ` Patrick McHardy

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=Pine.LNX.4.64.0710120026240.14889@blackhole.kfki.hu \
    --to=kadlec@blackhole.kfki.hu \
    --cc=kaber@trash.net \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=ole@ans.pl \
    /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).