diff options
| -rw-r--r-- | net/ipv4/netfilter/ip_nat_core.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/net/ipv4/netfilter/ip_nat_core.c b/net/ipv4/netfilter/ip_nat_core.c index c1a61462507f..1741d555ad0d 100644 --- a/net/ipv4/netfilter/ip_nat_core.c +++ b/net/ipv4/netfilter/ip_nat_core.c | |||
| @@ -434,6 +434,7 @@ int ip_nat_icmp_reply_translation(struct sk_buff **pskb, | |||
| 434 | } *inside; | 434 | } *inside; |
| 435 | struct ip_conntrack_tuple inner, target; | 435 | struct ip_conntrack_tuple inner, target; |
| 436 | int hdrlen = (*pskb)->nh.iph->ihl * 4; | 436 | int hdrlen = (*pskb)->nh.iph->ihl * 4; |
| 437 | unsigned long statusbit; | ||
| 437 | 438 | ||
| 438 | if (!skb_make_writable(pskb, hdrlen + sizeof(*inside))) | 439 | if (!skb_make_writable(pskb, hdrlen + sizeof(*inside))) |
| 439 | return 0; | 440 | return 0; |
| @@ -495,17 +496,16 @@ int ip_nat_icmp_reply_translation(struct sk_buff **pskb, | |||
| 495 | 496 | ||
| 496 | /* Change outer to look the reply to an incoming packet | 497 | /* Change outer to look the reply to an incoming packet |
| 497 | * (proto 0 means don't invert per-proto part). */ | 498 | * (proto 0 means don't invert per-proto part). */ |
| 499 | if (manip == IP_NAT_MANIP_SRC) | ||
| 500 | statusbit = IPS_SRC_NAT; | ||
| 501 | else | ||
| 502 | statusbit = IPS_DST_NAT; | ||
| 498 | 503 | ||
| 499 | /* Obviously, we need to NAT destination IP, but source IP | 504 | /* Invert if this is reply dir. */ |
| 500 | should be NAT'ed only if it is from a NAT'd host. | 505 | if (dir == IP_CT_DIR_REPLY) |
| 506 | statusbit ^= IPS_NAT_MASK; | ||
| 501 | 507 | ||
| 502 | Explanation: some people use NAT for anonymizing. Also, | 508 | if (ct->status & statusbit) { |
| 503 | CERT recommends dropping all packets from private IP | ||
| 504 | addresses (although ICMP errors from internal links with | ||
| 505 | such addresses are not too uncommon, as Alan Cox points | ||
| 506 | out) */ | ||
| 507 | if (manip != IP_NAT_MANIP_SRC | ||
| 508 | || ((*pskb)->nh.iph->saddr == ct->tuplehash[dir].tuple.src.ip)) { | ||
| 509 | invert_tuplepr(&target, &ct->tuplehash[!dir].tuple); | 509 | invert_tuplepr(&target, &ct->tuplehash[!dir].tuple); |
| 510 | if (!manip_pkt(0, pskb, 0, &target, manip)) | 510 | if (!manip_pkt(0, pskb, 0, &target, manip)) |
| 511 | return 0; | 511 | return 0; |
