* [PATCH v2] netfilter: avoid double seq_adjust for loopback
@ 2011-06-08 6:31 Julian Anastasov
2011-06-16 15:30 ` Patrick McHardy
0 siblings, 1 reply; 2+ messages in thread
From: Julian Anastasov @ 2011-06-08 6:31 UTC (permalink / raw)
To: Patrick McHardy, Pablo Neira Ayuso, netfilter-devel, netdev
Avoid double seq adjustment for loopback traffic
because it causes silent repetition of TCP data. One
example is passive FTP with DNAT rule and difference in the
length of IP addresses.
This patch adds check if packet is sent and
received via loopback device. As the same conntrack is
used both for outgoing and incoming direction, we restrict
seq adjustment to happen only in POSTROUTING.
Signed-off-by: Julian Anastasov <ja@ssi.bg>
---
diff -urp v2.6.39/linux/include/net/netfilter/nf_conntrack.h linux/include/net/netfilter/nf_conntrack.h
--- v2.6.39/linux/include/net/netfilter/nf_conntrack.h 2011-05-20 10:38:04.000000000 +0300
+++ linux/include/net/netfilter/nf_conntrack.h 2011-06-08 08:29:58.880272586 +0300
@@ -308,6 +308,12 @@ static inline int nf_ct_is_untracked(con
return test_bit(IPS_UNTRACKED_BIT, &ct->status);
}
+/* Packet is received from loopback */
+static inline bool nf_is_loopback_packet(const struct sk_buff *skb)
+{
+ return skb->dev && skb->skb_iif && skb->dev->flags & IFF_LOOPBACK;
+}
+
extern int nf_conntrack_set_hashsize(const char *val, struct kernel_param *kp);
extern unsigned int nf_conntrack_htable_size;
extern unsigned int nf_conntrack_max;
diff -urp v2.6.39/linux/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c linux/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
--- v2.6.39/linux/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c 2010-08-02 09:37:49.000000000 +0300
+++ linux/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c 2011-06-08 08:34:15.594269592 +0300
@@ -121,7 +121,9 @@ static unsigned int ipv4_confirm(unsigne
return ret;
}
- if (test_bit(IPS_SEQ_ADJUST_BIT, &ct->status)) {
+ /* adjust seqs for loopback traffic only in outgoing direction */
+ if (test_bit(IPS_SEQ_ADJUST_BIT, &ct->status) &&
+ !nf_is_loopback_packet(skb)) {
typeof(nf_nat_seq_adjust_hook) seq_adjust;
seq_adjust = rcu_dereference(nf_nat_seq_adjust_hook);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] netfilter: avoid double seq_adjust for loopback
2011-06-08 6:31 [PATCH v2] netfilter: avoid double seq_adjust for loopback Julian Anastasov
@ 2011-06-16 15:30 ` Patrick McHardy
0 siblings, 0 replies; 2+ messages in thread
From: Patrick McHardy @ 2011-06-16 15:30 UTC (permalink / raw)
To: Julian Anastasov; +Cc: Pablo Neira Ayuso, netfilter-devel, netdev
On 08.06.2011 08:31, Julian Anastasov wrote:
> Avoid double seq adjustment for loopback traffic
> because it causes silent repetition of TCP data. One
> example is passive FTP with DNAT rule and difference in the
> length of IP addresses.
>
> This patch adds check if packet is sent and
> received via loopback device. As the same conntrack is
> used both for outgoing and incoming direction, we restrict
> seq adjustment to happen only in POSTROUTING.
>
> Signed-off-by: Julian Anastasov <ja@ssi.bg>
Applied, thanks Julian.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-06-16 15:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-08 6:31 [PATCH v2] netfilter: avoid double seq_adjust for loopback Julian Anastasov
2011-06-16 15:30 ` Patrick McHardy
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).