Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 341867
b: refs/heads/master
c: a0ecb85
h: refs/heads/master
i:
  341865: db29225
  341863: 2d79aa3
v: v3
  • Loading branch information
Jozsef Kadlecsik authored and Pablo Neira Ayuso committed Dec 3, 2012
1 parent 740682d commit 95b00c7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6d1fafcaecaa2e66eb9861a39d22fc7380ce6f78
refs/heads/master: a0ecb85a2c3af73c63b6d44ce82aea52347ccf55
15 changes: 15 additions & 0 deletions trunk/include/net/netfilter/nf_nat.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,19 @@ static inline struct nf_conn_nat *nfct_nat(const struct nf_conn *ct)
#endif
}

static inline bool nf_nat_oif_changed(unsigned int hooknum,
enum ip_conntrack_info ctinfo,
struct nf_conn_nat *nat,
const struct net_device *out)
{
#if IS_ENABLED(CONFIG_IP_NF_TARGET_MASQUERADE) || \
IS_ENABLED(CONFIG_IP6_NF_TARGET_MASQUERADE)
return nat->masq_index && hooknum == NF_INET_POST_ROUTING &&
CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL &&
nat->masq_index != out->ifindex;
#else
return false;
#endif
}

#endif
4 changes: 4 additions & 0 deletions trunk/net/ipv4/netfilter/iptable_nat.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ nf_nat_ipv4_fn(unsigned int hooknum,
/* ESTABLISHED */
NF_CT_ASSERT(ctinfo == IP_CT_ESTABLISHED ||
ctinfo == IP_CT_ESTABLISHED_REPLY);
if (nf_nat_oif_changed(hooknum, ctinfo, nat, out)) {
nf_ct_kill_acct(ct, ctinfo, skb);
return NF_DROP;
}
}

return nf_nat_packet(ct, ctinfo, hooknum, skb);
Expand Down
4 changes: 4 additions & 0 deletions trunk/net/ipv6/netfilter/ip6table_nat.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ nf_nat_ipv6_fn(unsigned int hooknum,
/* ESTABLISHED */
NF_CT_ASSERT(ctinfo == IP_CT_ESTABLISHED ||
ctinfo == IP_CT_ESTABLISHED_REPLY);
if (nf_nat_oif_changed(hooknum, ctinfo, nat, out)) {
nf_ct_kill_acct(ct, ctinfo, skb);
return NF_DROP;
}
}

return nf_nat_packet(ct, ctinfo, hooknum, skb);
Expand Down

0 comments on commit 95b00c7

Please sign in to comment.