netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] act_nat: fix the wrong checksum when addr isn't in old_addr/mask
@ 2010-05-30  0:26 Changli Gao
  2010-05-30 12:43 ` jamal
  0 siblings, 1 reply; 7+ messages in thread
From: Changli Gao @ 2010-05-30  0:26 UTC (permalink / raw)
  To: Jamal Hadi Salim; +Cc: David S. Miller, netdev, linux-kernel, 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 <xiaosuo@gmail.com>
----
 net/sched/act_nat.c |    4 ++++
 1 file changed, 4 insertions(+)
diff --git a/net/sched/act_nat.c b/net/sched/act_nat.c
index d885ba3..5709494 100644
--- a/net/sched/act_nat.c
+++ b/net/sched/act_nat.c
@@ -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:

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-06-02 13:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-30  0:26 [PATCH v2] act_nat: fix the wrong checksum when addr isn't in old_addr/mask Changli Gao
2010-05-30 12:43 ` jamal
2010-05-30 12:58   ` Herbert Xu
2010-05-30 13:33     ` Changli Gao
2010-05-30 14:11       ` Changli Gao
2010-05-30 21:53       ` Herbert Xu
2010-06-02 13:52     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).