From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 02/12] netfilter: nf_conntrack: avoid large timeout for mid-stream pickup
Date: Mon, 1 Jul 2013 01:54:31 +0200 [thread overview]
Message-ID: <1372636481-3705-3-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1372636481-3705-1-git-send-email-pablo@netfilter.org>
From: Florian Westphal <fw@strlen.de>
When loose tracking is enabled (default), non-syn packets cause
creation of new conntracks in established state with default timeout for
established state (5 days). This causes the table to fill up with UNREPLIED
when the 'new ack' packet happened to be the last-ack of a previous,
already timed-out connection.
Consider:
A 192.168.x.52792 > 10.184.y.80: F, 426:426(0) ack 9237 win 255
B 10.184.y.80 > 192.168.x.52792: ., ack 427 win 123
<61 second pause>
C 10.184.y.80 > 192.168.x.52792: F, 9237:9237(0) ack 427 win 123
D 192.168.x.52792 > 10.184.y.80: ., ack 9238 win 255
B moves conntrack to CLOSE_WAIT and will kill it after 60 second timeout,
C is ignored (FIN set), but last packet (D) causes new ct with 5-days timeout.
Use UNACK timeout (5 minutes) instead to get rid of these entries sooner
when in ESTABLISHED state without having seen traffic in both directions.
Signed-off-by: Florian Westphal <fw@strlen.de>
Acked-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_conntrack_proto_tcp.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 4d4d8f1..7dcc376 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -1043,6 +1043,12 @@ static int tcp_packet(struct nf_conn *ct,
nf_ct_kill_acct(ct, ctinfo, skb);
return NF_ACCEPT;
}
+ /* ESTABLISHED without SEEN_REPLY, i.e. mid-connection
+ * pickup with loose=1. Avoid large ESTABLISHED timeout.
+ */
+ if (new_state == TCP_CONNTRACK_ESTABLISHED &&
+ timeout > timeouts[TCP_CONNTRACK_UNACK])
+ timeout = timeouts[TCP_CONNTRACK_UNACK];
} else if (!test_bit(IPS_ASSURED_BIT, &ct->status)
&& (old_state == TCP_CONNTRACK_SYN_RECV
|| old_state == TCP_CONNTRACK_ESTABLISHED)
--
1.7.10.4
next prev parent reply other threads:[~2013-06-30 23:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-30 23:54 [PATCH 00/12] netfilter updates for net-next Pablo Neira Ayuso
2013-06-30 23:54 ` [PATCH 01/12] netfilter: check return code from nla_parse_tested Pablo Neira Ayuso
2013-06-30 23:54 ` Pablo Neira Ayuso [this message]
2013-06-30 23:54 ` [PATCH 03/12] netfilter: xt_socket: add XT_SOCKET_NOWILDCARD flag Pablo Neira Ayuso
2013-06-30 23:54 ` [PATCH 04/12] ipvs: provide iph to schedulers Pablo Neira Ayuso
2013-06-30 23:54 ` [PATCH 05/12] ipvs: sloppy TCP and SCTP Pablo Neira Ayuso
2013-06-30 23:54 ` [PATCH 06/12] ipvs: replace the SCTP state machine Pablo Neira Ayuso
2013-06-30 23:54 ` [PATCH 07/12] ipvs: drop SCTP connections depending on state Pablo Neira Ayuso
2013-06-30 23:54 ` [PATCH 08/12] ipvs: SH fallback and L4 hashing Pablo Neira Ayuso
2013-06-30 23:54 ` [PATCH 09/12] ipvs: add sync_persist_mode flag Pablo Neira Ayuso
2013-06-30 23:54 ` [PATCH 10/12] kernel: remove unnecessary head file Pablo Neira Ayuso
2013-06-30 23:54 ` [PATCH 11/12] netns: exclude ipvs from struct net when IPVS disabled Pablo Neira Ayuso
2013-06-30 23:54 ` [PATCH 12/12] netfilter: nf_queue: add NFQA_SKB_CSUM_NOTVERIFIED info flag Pablo Neira Ayuso
2013-07-01 0:35 ` [PATCH 00/12] netfilter updates for net-next David Miller
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=1372636481-3705-3-git-send-email-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--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).