[ovs-dev] [Patch] datapath: fix checksum after putting vlan tag

Cong Wang amwang at redhat.com
Tue Feb 26 09:46:12 UTC 2013


After inserting the VLAN tag with __vlan_put_tag(), we should
re-calculate the skb checksum if it is done.

Cc: Jesse Gross <jesse at nicira.com>
Signed-off-by: Cong Wang <amwang at redhat.com>

---
diff --git a/datapath/vport-netdev.c b/datapath/vport-netdev.c
index 727194e..99a6eca 100644
--- a/datapath/vport-netdev.c
+++ b/datapath/vport-netdev.c
@@ -313,6 +313,10 @@ static int netdev_send(struct vport *vport, struct sk_buff *skb)
 
 				skb = __vlan_put_tag(skb, vlan_tx_tag_get(skb));
 				if (likely(skb)) {
+					if (skb->ip_summed == CHECKSUM_COMPLETE)
+						skb->csum = csum_add(skb->csum, csum_partial(skb->data
+								     + (2 * ETH_ALEN), VLAN_HLEN, 0));
+
 					len += skb->len;
 					vlan_set_tci(skb, 0);
 					dev_queue_xmit(skb);
@@ -328,6 +332,9 @@ tag:
 		skb = __vlan_put_tag(skb, vlan_tx_tag_get(skb));
 		if (unlikely(!skb))
 			return 0;
+		if (skb->ip_summed == CHECKSUM_COMPLETE)
+			skb->csum = csum_add(skb->csum, csum_partial(skb->data
+					     + (2 * ETH_ALEN), VLAN_HLEN, 0));
 		vlan_set_tci(skb, 0);
 	}
 



More information about the dev mailing list