act_nat: fix the wrong checksum when addr isn't in old_addr/mask
Subsystems (3)
PATCH v2 1/1 act_nat: fix the wrong checksum when addr isn't in old_addr/mask
fix the wrong checksum when addr isn't in old_addr/mask
For TCP and UDP packets, when addr isn't in old_addr/mask we don't do SNAT or DNAT, and we should not update layer 4 checksum.
----
net/sched/act_nat.c | 4 ++++ 1 file changed, 4 insertions(+)
net/sched/act_nat.c +4 -0
@@ -159,6 +159,9 @@ static int tcf_nat(struct sk_buff *skb, struct tc_action *a, iph->daddr = new_addr;csum_replace4 (&iph->check, addr, new_addr); + }else if ((iph->frag_off &htons (IP_OFFSET )) || + iph->protocol !=IPPROTO_ICMP ) { + goto out; } ihl = iph->ihl *4 ;
@@ -247,6 +250,7 @@ static int tcf_nat(struct sk_buff *skb, struct tc_action *a,break ; } +out:return action; drop:
Copying Herbert, taking linux-kernel off...
Quoted 31 lines · Changli Gao
fix the wrong checksum when addr isn't in old_addr/mask
For TCP and UDP packets, when addr isn't in old_addr/mask we don't do SNAT or DNAT, and we should not update layer 4 checksum.
Signed-off-by Changli Gao <[email protected]>----
net/sched/act_nat.c | 4 ++++ 1 file changed, 4 insertions(+)net/sched/act_nat.c +4
-0@@ -159,6 +159,9 @@ static int tcf_nat(struct sk_buff *skb, struct tc_action *a, iph->daddr = new_addr;csum_replace4 (&iph->check, addr, new_addr); + }else if ((iph->frag_off &htons (IP_OFFSET )) || + iph->protocol !=IPPROTO_ICMP ) { + goto out; } ihl = iph->ihl *4 ;@@ -247,6 +250,7 @@ static int tcf_nat(struct sk_buff *skb, struct tc_action *a,break ; } +out:return action; drop:
Quoted 2 lines · jamal
Copying Herbert, taking linux-kernel off...
Thanks Jamal.
Quoted 17 lines · Changli Gao
Quoted 16 lines
fix the wrong checksum when addr isn't in old_addr/mask
For TCP and UDP packets, when addr isn't in old_addr/mask we don't do SNAT or DNAT, and we should not update layer 4 checksum.
Signed-off-by Changli Gao <[email protected]>----
net/sched/act_nat.c | 4 ++++ 1 file changed, 4 insertions(+)net/sched/act_nat.c +0
-0@@ -159,6 +159,9 @@ static int tcf_nat(struct sk_buff *skb, struct tc_action *a, iph->daddr = new_addr;
Quoted 5 lines
net/sched/act_nat.c static int tcf_nat(struct sk_buff *skb, struct tc_action *a, · line 165
Quoted 5 lines
net/sched/act_nat.c +3
-0csum_replace4 (&iph->check, addr, new_addr); + }else if ((iph->frag_off &htons (IP_OFFSET )) || + iph->protocol !=IPPROTO_ICMP ) { + goto out; }
Yes the patch is correct.
However, the fact that you need this patch means that your act_nat setup isn't perfect. Ideally all the unNATed packets should be filtered out before you hit act_nat.
Thanks,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 31 lines · Herbert Xu
Quoted 2 lines · jamal
Copying Herbert, taking linux-kernel off...
Thanks Jamal.
Quoted 17 lines · Changli Gao
Quoted 16 lines
fix the wrong checksum when addr isn't in old_addr/mask
For TCP and UDP packets, when addr isn't in old_addr/mask we don't do SNAT or DNAT, and we should not update layer 4 checksum.
Signed-off-by Changli Gao <[email protected]>----
net/sched/act_nat.c | 4 ++++1 file changed, 4 insertions(+)net/sched/act_nat.c +0
-0@@ -159,6 +159,9 @@ static int tcf_nat(struct sk_buff *skb, struct tc_action *a, iph->daddr = new_addr;Quoted 5 lines
net/sched/act_nat.c static int tcf_nat(struct sk_buff *skb, struct tc_action *a, · line 165
Quoted 5 lines
net/sched/act_nat.c +3
-0csum_replace4(&iph->check, addr, new_addr); + } else if ((iph->frag_off & htons(IP_OFFSET)) || + iph->protocol != IPPROTO_ICMP) { + goto out; }Yes the patch is correct.
Quoted 3 lines
However, the fact that you need this patch means that your
act_natsetup isn't perfect. Ideally all the unNATed packets should be filtered out before you hitact_nat.
Thinking about this topologic:
client -> DNAT -> router -> server.
DNAT is used to map a public IP to server's private IP. If a DEST_UNREACH ICMP packet is sent out by router, in order to handle this ICMP packet correctly, I have to pass it to act_nat.c. How can I filter out the other packets? By inspecting the inner IP destination address of this ICMP packet? Maybe I can use u32 with complicate parameters.
Signature · 2 lines
Regards, Changli Gao([email protected])
Quoted 10 lines · Changli Gao
Quoted 6 lines · Herbert Xu
Yes the patch is correct.
However, the fact that you need this patch means that your
act_natsetup isn't perfect. Ideally all the unNATed packets should be filtered out before you hitact_nat.Thinking about this topologic:
Quoted 9 lines
client -> DNAT -> router -> server.
DNAT is used to map a public IP to server's private IP. If a
DEST_UNREACHICMP packet is sent out by router, in order to handle this ICMP packet correctly, I have to pass it toact_nat.c. How can I filter out the other packets? By inspecting the inner IP destination address of this ICMP packet? Maybe I can use u32 with complicate parameters.
Oh, I can pass all the ICMP packets, and the packets to the public IP and the packets from the private IP.
Signature · 2 lines
Regards, Changli Gao([email protected])
Quoted 11 lines · Changli Gao
Thinking about this topologic:
client -> DNAT -> router -> server.
DNAT is used to map a public IP to server's private IP. If a
DEST_UNREACHICMP packet is sent out by router, in order to handle this ICMP packet correctly, I have to pass it toact_nat.c. How can I filter out the other packets? By inspecting the inner IP destination address of this ICMP packet? Maybe I can use u32 with complicate parameters.
You should filter out all the non-ICMP packets, just like you do here.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtDavid Miller
maintainerFrom: Herbert Xu <[email protected]>
Date: Sun, 30 May 2010 22:58:11 +1000
Quoted 5 lines
Yes the patch is correct.
However, the fact that you need this patch means that your
act_natsetup isn't perfect. Ideally all the unNATed packets should be filtered out before you hitact_nat.
Regardless of whether said configuration is optimal, we should handle this case correctly.
So I have applied this patch.