From: Zhiyong Yang Date: Tue, 24 Oct 2017 03:06:14 +0000 (+0800) Subject: net/virtio: fix Tx packet length stats X-Git-Tag: spdx-start~1242 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=f1216c1eca5a54706af9f13133d06b3477099f8b;p=dpdk.git net/virtio: fix Tx packet length stats In the function virtqueue_enqueue_xmit(), when can_push is true, vtnet_hdr_size is added to pkt_len by calling rte_pktmbuf_prepend. which is wrong for pkt stats, virtio header length should be subtracted before calling stats function. Fixes: 58169a9c8153 ("net/virtio: support Tx checksum offload") Cc: stable@dpdk.org Signed-off-by: Zhiyong Yang Reviewed-by: Maxime Coquelin Acked-by: Yuanhan Liu --- diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 8560c9c56b..a483594f38 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -299,6 +299,10 @@ virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie, /* prepend cannot fail, checked by caller */ hdr = (struct virtio_net_hdr *) rte_pktmbuf_prepend(cookie, head_size); + /* rte_pktmbuf_prepend() counts the hdr size to the pkt length, + * which is wrong. Below subtract restores correct pkt size. + */ + cookie->pkt_len -= head_size; /* if offload disabled, it is not zeroed below, do it now */ if (offload == 0) { ASSIGN_UNLESS_EQUAL(hdr->csum_start, 0);