LOCAL_OUT Nat fix, part 2
Subsystems (2)
PATCH 1/1 LOCAL_OUT Nat fix, part 2
Hi Davem!
Please apply the following patch to your 2.6 tree, thanks.
Author: Rusty Russell / Harald Welte
Status: Pending for kernel inclusion
D: Balazs Scheidler pointed out that we can fail to call ip_nat_setup_info
D: for local NAT, which causes the connection to be added twice. Boom.
D: Also move the hash table insertion into ip_nat_setup_info.
Signature · 5 lines
- Harald Welte <[email protected]> http://www.netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie
include/linux/netfilter_ipv4/ip_nat_rule.h +5 -0
@@ -14,5 +14,10 @@const struct net_device *out, struct ip_conntrack *ct, struct ip_nat_info *info); + +extern unsigned int +alloc_null_binding (struct ip_conntrack *conntrack, +struct ip_nat_info *info, +unsigned int hooknum);#endif #endif /* _IP_NAT_RULE_H */
net/ipv4/netfilter/ip_nat_core.c +10 -0
@@ -516,12 +516,14 @@struct ip_conntrack_tuple new_tuple, inv_tuple, reply;struct ip_conntrack_tuple orig_tp;struct ip_nat_info *info = &conntrack->nat.info; +int in_hashes = info->initialized;MUST_BE_WRITE_LOCKED (&ip_nat_lock);IP_NF_ASSERT (hooknum ==NF_IP_PRE_ROUTING || hooknum ==NF_IP_POST_ROUTING || hooknum ==NF_IP_LOCAL_OUT );IP_NF_ASSERT (info->num_manips <IP_NAT_MAX_MANIPS ); +IP_NF_ASSERT (!(info->initialized & (1 <<HOOK2MANIP (hooknum))));/* What we've got will look like inverse of reply. Normally this is what is in the conntrack, except for prior
@@ -638,6 +640,14 @@/* It's done. */ info->initialized |= (1 <<HOOK2MANIP (hooknum)); + +if (in_hashes) { +IP_NF_ASSERT (info->bysource.conntrack); +replace_in_hashes (conntrack, info); + }else { +place_in_hashes (conntrack, info); + } +return NF_ACCEPT ; }
net/ipv4/netfilter/ip_nat_rule.c +1 -1
@@ -233,7 +233,7 @@return 1 ; } -static inline unsigned int +inline unsigned int alloc_null_binding (struct ip_conntrack *conntrack,struct ip_nat_info *info,unsigned int hooknum)
net/ipv4/netfilter/ip_nat_standalone.c +4 -11
@@ -119,7 +119,6 @@/* Seen it before? This can happen for loopback, retrans, or local packets.. */ if (!(info->initialized & (1 << maniptype))) { -int in_hashes = info->initialized;unsigned int ret; if (ct->master
@@ -130,9 +129,10 @@ }else {#ifdef CONFIG_IP_NF_NAT_LOCAL /* LOCAL_IN hook doesn't have a chain! */ -if (hooknum ==NF_IP_LOCAL_IN ) { - ret =NF_ACCEPT ; - } else +if (hooknum ==NF_IP_LOCAL_IN ) + ret =alloc_null_binding (ct, info, + hooknum); + else#endif ret =ip_nat_rule_find (pskb, hooknum, in, out, ct, info);
@@ -142,13 +142,6 @@WRITE_UNLOCK (&ip_nat_lock);return ret; } - -if (in_hashes) { -IP_NF_ASSERT (info->bysource.conntrack); -replace_in_hashes (ct, info); - }else { -place_in_hashes (ct, info); - } }else DEBUGP("Already setup manip %s for ct %p\n", maniptype == IP_NAT_MANIP_SRC ? "SRC" : "DST",
David S. Miller
AppliedQuoted 1 line · On Thu, 2 Oct 2003 18:18:36 +0200 Harald Welte <[email protected]> wrote:
Please apply the following patch to your 2.6 tree, thanks.
Applied, thanks.