net/filter-rewriter.c: Fix rewirter checksum bug when use virtio-net
authorZhang Chen <zhangchen.fnst@cn.fujitsu.com>
Fri, 28 Jul 2017 10:03:10 +0000 (18:03 +0800)
committerJason Wang <jasowang@redhat.com>
Fri, 8 Sep 2017 00:17:35 +0000 (08:17 +0800)
Because vnet_hdr have a offset to net packet, we must add it when use
virtio-net.

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
net/filter-rewriter.c

index 98120095de29d9e60d00dfa7ddb14b21052d7122..2be388f53973d0fba91eda9a61092346d3549b5e 100644 (file)
@@ -99,7 +99,8 @@ static int handle_primary_tcp_pkt(NetFilterState *nf,
             /* handle packets to the secondary from the primary */
             tcp_pkt->th_ack = htonl(ntohl(tcp_pkt->th_ack) + conn->offset);
 
-            net_checksum_calculate((uint8_t *)pkt->data, pkt->size);
+            net_checksum_calculate((uint8_t *)pkt->data + pkt->vnet_hdr_len,
+                                   pkt->size - pkt->vnet_hdr_len);
         }
     }
 
@@ -138,7 +139,8 @@ static int handle_secondary_tcp_pkt(NetFilterState *nf,
             /* handle packets to the primary from the secondary*/
             tcp_pkt->th_seq = htonl(ntohl(tcp_pkt->th_seq) - conn->offset);
 
-            net_checksum_calculate((uint8_t *)pkt->data, pkt->size);
+            net_checksum_calculate((uint8_t *)pkt->data + pkt->vnet_hdr_len,
+                                   pkt->size - pkt->vnet_hdr_len);
         }
     }