From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: kaber@trash.net, kadlec@blackhole.kfki.hu
Subject: [PATCH] netfilter: nf_ct_tcp: better handling for SYN retransmissions after SYN+ACK
Date: Sat, 26 Feb 2011 04:33:24 +0100 [thread overview]
Message-ID: <20110226033324.4335.53000.stgit@decadence> (raw)
In-Reply-To: <20110226032834.4335.74168.stgit@decadence>
Consider the following scenario:
client firewall server
| | |
| syn | syn |
|------------->|------------>|
| | |
| syn+ack | syn+ack |
| x<------|<------------| syn+ack got lost!
| | |
| syn | syn |
|------------->|------------>|
| | |
| syn+ack | syn+ack |
|<-------------|<------------|
| | |
Note that the syn+ack is lost after we have seen it. Without this
patch, the TCP tracking ignores the retransmitted SYN without
checking if the sequence number is in the window.
This patch also helps a lot to conntrackd in stress scenarios
(assumming a client that generates lots of small TCP connections).
During the failover, consider that the new primary has injected
one outdated flow in SYN_RECV state (this is likely to happen if
the conntrack event rate is high because the backup will be a bit
delayed from the primary). With the current code, if the client
starts a new fresh connection that matches the tuple, the SYN
packet will be ignored without updating the state tracking, and
the SYN+ACK in reply will blocked as it will not pass checkings
III or IV (since all state tracking in the original direction is
not initialized because of the SYN packet was ignored).
Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_conntrack_proto_tcp.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 3fb2b73..be0b84d 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -142,12 +142,12 @@ static const u8 tcp_conntracks[2][6][TCP_CONNTRACK_MAX] = {
{
/* ORIGINAL */
/* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sS2 */
-/*syn*/ { sSS, sSS, sIG, sIG, sIG, sIG, sIG, sSS, sSS, sS2 },
+/*syn*/ { sSS, sSS, sSR, sIG, sIG, sIG, sIG, sSS, sSS, sS2 },
/*
* sNO -> sSS Initialize a new connection
* sSS -> sSS Retransmitted SYN
* sS2 -> sS2 Late retransmitted SYN
- * sSR -> sIG
+ * sSR -> sSR Retransmitted SYN, SYN/ACK got lost?
* sES -> sIG Error: SYNs in window outside the SYN_SENT state
* are errors. Receiver will reply with RST
* and close the connection.
next prev parent reply other threads:[~2011-02-26 3:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-26 3:32 [PATCH] improvement for TCP connection tracking Pablo Neira Ayuso
2011-02-26 3:33 ` Pablo Neira Ayuso [this message]
2011-02-26 6:15 ` [PATCH] netfilter: nf_ct_tcp: better handling for SYN retransmissions after SYN+ACK Changli Gao
2011-02-26 18:30 ` Jozsef Kadlecsik
2011-02-26 20:11 ` Pablo Neira Ayuso
2011-02-26 21:45 ` Jozsef Kadlecsik
2011-02-26 23:42 ` Pablo Neira Ayuso
2011-02-27 0:00 ` Pablo Neira Ayuso
2011-02-27 2:08 ` Igor 'Lo' (И.L.)
2011-02-27 15:22 ` Patrick McHardy
2011-02-27 17:28 ` Jozsef Kadlecsik
2011-02-28 17:04 ` 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=20110226033324.4335.53000.stgit@decadence \
--to=pablo@netfilter.org \
--cc=kaber@trash.net \
--cc=kadlec@blackhole.kfki.hu \
--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).