From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id DACEAA32A2 for ; Thu, 24 Oct 2019 19:46:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 666321EBC7; Thu, 24 Oct 2019 19:46:26 +0200 (CEST) Received: from dispatchb-us1.ppe-hosted.com (dispatchb-us1.ppe-hosted.com [148.163.129.53]) by dpdk.org (Postfix) with ESMTP id 9FF5F1EBBB; Thu, 24 Oct 2019 19:46:22 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (webmail.solarflare.com [12.187.104.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us5.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 5424A180050; Thu, 24 Oct 2019 17:46:21 +0000 (UTC) Received: from ocex03.SolarFlarecom.com (10.20.40.36) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 24 Oct 2019 10:46:18 -0700 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Thu, 24 Oct 2019 10:46:18 -0700 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id x9OHkGdh014574; Thu, 24 Oct 2019 18:46:16 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id B03991613D1; Thu, 24 Oct 2019 18:46:16 +0100 (BST) From: Andrew Rybchenko To: Maxime Coquelin , Tiwei Bie , Zhihong Wang CC: , Date: Thu, 24 Oct 2019 18:46:09 +0100 Message-ID: <1571939170-19998-1-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24998.005 X-TM-AS-Result: No-7.702800-4.000000-10 X-TMASE-MatchedRID: gSeCwy/7g6NIQkQ+2Oh2tfFanwH6mNosnsHnxXScx4rM/0sSqPZieKf4 O0AyJYLdeaa+M+QbKhVkCWxjv0fR2sdfzbqBQzMUqJSK+HSPY+9LXPA26IG0hN9RlPzeVuQQ224 ueXqtKLtqw8n+WZoVEA9DaENdC/KWzh3sldLAd86SvRb8EMdYRVBijjE0XjY+mrP6dWYCNJSjxY yRBa/qJcFwgTvxipFajoczmuoPCq0+QFNkg1/kJyxd+EPiGj7Dn3J9oDo9biFH38hg4SvZe9Dnl Df89NBI X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--7.702800-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24998.005 X-MDID: 1571939181-R2CFXVMKzL-H Subject: [dpdk-stable] [PATCH] net/virtio: fix broken Tx checksum offloads X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Missing parenthesis around expression before type cast to struct virtio_net_hdr pointer makes the arithmetic to be in sizeof(struct virtio_net_hdr) units. Use rte_pktmbuf_mtod_offset() to fix the problem. Type of head_size is changed to signed since some compilers bark on unary minus applied to unsigned. Fixes: 1ae55ad38e5e ("net/virtio: fix mbuf data and packet length mismatch") Cc: stable@dpdk.org Signed-off-by: Andrew Rybchenko --- drivers/net/virtio/virtio_rxtx.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index b5fc4ecbe1..274b778d84 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -635,7 +635,7 @@ virtqueue_enqueue_xmit_inorder(struct virtnet_tx *txvq, struct vring_desc *start_dp; struct virtio_net_hdr *hdr; uint16_t idx; - uint16_t head_size = vq->hw->vtnet_hdr_size; + int16_t head_size = vq->hw->vtnet_hdr_size; uint16_t i = 0; idx = vq->vq_desc_head_idx; @@ -648,8 +648,8 @@ virtqueue_enqueue_xmit_inorder(struct virtnet_tx *txvq, dxp->ndescs = 1; virtio_update_packet_stats(&txvq->stats, cookies[i]); - hdr = (struct virtio_net_hdr *)(char *)cookies[i]->buf_addr + - cookies[i]->data_off - head_size; + hdr = rte_pktmbuf_mtod_offset(cookies[i], + struct virtio_net_hdr *, -head_size); /* if offload disabled, hdr is not zeroed yet, do it now */ if (!vq->hw->has_tx_offload) @@ -682,7 +682,7 @@ virtqueue_enqueue_xmit_packed_fast(struct virtnet_tx *txvq, struct vring_packed_desc *dp; struct vq_desc_extra *dxp; uint16_t idx, id, flags; - uint16_t head_size = vq->hw->vtnet_hdr_size; + int16_t head_size = vq->hw->vtnet_hdr_size; struct virtio_net_hdr *hdr; id = in_order ? vq->vq_avail_idx : vq->vq_desc_head_idx; @@ -696,8 +696,8 @@ virtqueue_enqueue_xmit_packed_fast(struct virtnet_tx *txvq, flags = vq->vq_packed.cached_flags; /* prepend cannot fail, checked by caller */ - hdr = (struct virtio_net_hdr *)(char *)cookie->buf_addr + - cookie->data_off - head_size; + hdr = rte_pktmbuf_mtod_offset(cookie, struct virtio_net_hdr *, + -head_size); /* if offload disabled, hdr is not zeroed yet, do it now */ if (!vq->hw->has_tx_offload) @@ -734,7 +734,7 @@ virtqueue_enqueue_xmit_packed(struct virtnet_tx *txvq, struct rte_mbuf *cookie, struct virtqueue *vq = txvq->vq; struct vring_packed_desc *start_dp, *head_dp; uint16_t idx, id, head_idx, head_flags; - uint16_t head_size = vq->hw->vtnet_hdr_size; + int16_t head_size = vq->hw->vtnet_hdr_size; struct virtio_net_hdr *hdr; uint16_t prev; bool prepend_header = false; @@ -756,8 +756,8 @@ virtqueue_enqueue_xmit_packed(struct virtnet_tx *txvq, struct rte_mbuf *cookie, if (can_push) { /* prepend cannot fail, checked by caller */ - hdr = (struct virtio_net_hdr *)(char *)cookie->buf_addr + - cookie->data_off - head_size; + hdr = rte_pktmbuf_mtod_offset(cookie, struct virtio_net_hdr *, + -head_size); prepend_header = true; /* if offload disabled, it is not zeroed below, do it now */ @@ -832,7 +832,7 @@ virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie, struct vring_desc *start_dp; uint16_t seg_num = cookie->nb_segs; uint16_t head_idx, idx; - uint16_t head_size = vq->hw->vtnet_hdr_size; + int16_t head_size = vq->hw->vtnet_hdr_size; bool prepend_header = false; struct virtio_net_hdr *hdr; @@ -849,8 +849,8 @@ virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie, if (can_push) { /* prepend cannot fail, checked by caller */ - hdr = (struct virtio_net_hdr *)(char *)cookie->buf_addr + - cookie->data_off - head_size; + hdr = rte_pktmbuf_mtod_offset(cookie, struct virtio_net_hdr *, + -head_size); prepend_header = true; /* if offload disabled, it is not zeroed below, do it now */ -- 2.17.1