diff options
author | Andrew Collins <bsderandrew@gmail.com> | 2012-12-12 09:23:49 -0500 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2012-12-16 17:28:30 -0500 |
commit | c65ef8dc7b1c16379b9fc29e925716a10804af43 (patch) | |
tree | 52c8c66e995ea0c8e115a137163be2090561dd3c | |
parent | c6f408996c625cb950cad024f90e50519f94713c (diff) |
netfilter: nf_nat: Also handle non-ESTABLISHED routing changes in MASQUERADE
Since (a0ecb85 netfilter: nf_nat: Handle routing changes in MASQUERADE
target), the MASQUERADE target handles routing changes which affect
the output interface of a connection, but only for ESTABLISHED
connections. It is also possible for NEW connections which
already have a conntrack entry to be affected by routing changes.
This adds a check to drop entries in the NEW+conntrack state
when the oif has changed.
Signed-off-by: Andrew Collins <bsderandrew@gmail.com>
Acked-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r-- | net/ipv4/netfilter/iptable_nat.c | 15 | ||||
-rw-r--r-- | net/ipv6/netfilter/ip6table_nat.c | 15 |
2 files changed, 20 insertions, 10 deletions
diff --git a/net/ipv4/netfilter/iptable_nat.c b/net/ipv4/netfilter/iptable_nat.c index da2c8a368f68..eeaff7e4acb5 100644 --- a/net/ipv4/netfilter/iptable_nat.c +++ b/net/ipv4/netfilter/iptable_nat.c | |||
@@ -124,23 +124,28 @@ nf_nat_ipv4_fn(unsigned int hooknum, | |||
124 | ret = nf_nat_rule_find(skb, hooknum, in, out, ct); | 124 | ret = nf_nat_rule_find(skb, hooknum, in, out, ct); |
125 | if (ret != NF_ACCEPT) | 125 | if (ret != NF_ACCEPT) |
126 | return ret; | 126 | return ret; |
127 | } else | 127 | } else { |
128 | pr_debug("Already setup manip %s for ct %p\n", | 128 | pr_debug("Already setup manip %s for ct %p\n", |
129 | maniptype == NF_NAT_MANIP_SRC ? "SRC" : "DST", | 129 | maniptype == NF_NAT_MANIP_SRC ? "SRC" : "DST", |
130 | ct); | 130 | ct); |
131 | if (nf_nat_oif_changed(hooknum, ctinfo, nat, out)) | ||
132 | goto oif_changed; | ||
133 | } | ||
131 | break; | 134 | break; |
132 | 135 | ||
133 | default: | 136 | default: |
134 | /* ESTABLISHED */ | 137 | /* ESTABLISHED */ |
135 | NF_CT_ASSERT(ctinfo == IP_CT_ESTABLISHED || | 138 | NF_CT_ASSERT(ctinfo == IP_CT_ESTABLISHED || |
136 | ctinfo == IP_CT_ESTABLISHED_REPLY); | 139 | ctinfo == IP_CT_ESTABLISHED_REPLY); |
137 | if (nf_nat_oif_changed(hooknum, ctinfo, nat, out)) { | 140 | if (nf_nat_oif_changed(hooknum, ctinfo, nat, out)) |
138 | nf_ct_kill_acct(ct, ctinfo, skb); | 141 | goto oif_changed; |
139 | return NF_DROP; | ||
140 | } | ||
141 | } | 142 | } |
142 | 143 | ||
143 | return nf_nat_packet(ct, ctinfo, hooknum, skb); | 144 | return nf_nat_packet(ct, ctinfo, hooknum, skb); |
145 | |||
146 | oif_changed: | ||
147 | nf_ct_kill_acct(ct, ctinfo, skb); | ||
148 | return NF_DROP; | ||
144 | } | 149 | } |
145 | 150 | ||
146 | static unsigned int | 151 | static unsigned int |
diff --git a/net/ipv6/netfilter/ip6table_nat.c b/net/ipv6/netfilter/ip6table_nat.c index 6c8ae24b85eb..e0e788d25b14 100644 --- a/net/ipv6/netfilter/ip6table_nat.c +++ b/net/ipv6/netfilter/ip6table_nat.c | |||
@@ -127,23 +127,28 @@ nf_nat_ipv6_fn(unsigned int hooknum, | |||
127 | ret = nf_nat_rule_find(skb, hooknum, in, out, ct); | 127 | ret = nf_nat_rule_find(skb, hooknum, in, out, ct); |
128 | if (ret != NF_ACCEPT) | 128 | if (ret != NF_ACCEPT) |
129 | return ret; | 129 | return ret; |
130 | } else | 130 | } else { |
131 | pr_debug("Already setup manip %s for ct %p\n", | 131 | pr_debug("Already setup manip %s for ct %p\n", |
132 | maniptype == NF_NAT_MANIP_SRC ? "SRC" : "DST", | 132 | maniptype == NF_NAT_MANIP_SRC ? "SRC" : "DST", |
133 | ct); | 133 | ct); |
134 | if (nf_nat_oif_changed(hooknum, ctinfo, nat, out)) | ||
135 | goto oif_changed; | ||
136 | } | ||
134 | break; | 137 | break; |
135 | 138 | ||
136 | default: | 139 | default: |
137 | /* ESTABLISHED */ | 140 | /* ESTABLISHED */ |
138 | NF_CT_ASSERT(ctinfo == IP_CT_ESTABLISHED || | 141 | NF_CT_ASSERT(ctinfo == IP_CT_ESTABLISHED || |
139 | ctinfo == IP_CT_ESTABLISHED_REPLY); | 142 | ctinfo == IP_CT_ESTABLISHED_REPLY); |
140 | if (nf_nat_oif_changed(hooknum, ctinfo, nat, out)) { | 143 | if (nf_nat_oif_changed(hooknum, ctinfo, nat, out)) |
141 | nf_ct_kill_acct(ct, ctinfo, skb); | 144 | goto oif_changed; |
142 | return NF_DROP; | ||
143 | } | ||
144 | } | 145 | } |
145 | 146 | ||
146 | return nf_nat_packet(ct, ctinfo, hooknum, skb); | 147 | return nf_nat_packet(ct, ctinfo, hooknum, skb); |
148 | |||
149 | oif_changed: | ||
150 | nf_ct_kill_acct(ct, ctinfo, skb); | ||
151 | return NF_DROP; | ||
147 | } | 152 | } |
148 | 153 | ||
149 | static unsigned int | 154 | static unsigned int |