diff mbox

net/filter-rewriter.c: Fix rewirter checksum bug when use virtio-net

Message ID 1501236190-15177-1-git-send-email-zhangchen.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Zhang Chen July 28, 2017, 10:03 a.m. UTC
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>
---
 net/filter-rewriter.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Zhang Chen Aug. 21, 2017, 1:42 a.m. UTC | #1
Hi~ All~

Someone can review it? Just a ping for this patch.


Thanks

Zhang Chen


On 07/28/2017 06:03 PM, Zhang Chen wrote:
> 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>
> ---
>   net/filter-rewriter.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c
> index 55a6cf5..72e4928 100644
> --- a/net/filter-rewriter.c
> +++ b/net/filter-rewriter.c
> @@ -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);
>           }
>       }
>
Jason Wang Aug. 21, 2017, 3:17 a.m. UTC | #2
On 2017年08月21日 09:42, Zhang Chen wrote:
> Hi~ All~
>
> Someone can review it? Just a ping for this patch.
>
>
> Thanks
>
> Zhang Chen
>

Queued this for 2.11.

Thanks
diff mbox

Patch

diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c
index 55a6cf5..72e4928 100644
--- a/net/filter-rewriter.c
+++ b/net/filter-rewriter.c
@@ -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);
         }
     }