Message ID | 20190605081005.15716-3-maxime.coquelin@redhat.com (mailing list archive) |
---|---|
State | Superseded, archived |
Delegated to: | Maxime Coquelin |
Headers | show |
Series | net/virtio: Fix packet segmentation bug | expand |
Context | Check | Description |
---|---|---|
ci/checkpatch | success | coding style OK |
ci/Intel-compilation | fail | apply issues |
On Wed, Jun 5, 2019 at 10:11 AM Maxime Coquelin <maxime.coquelin@redhat.com> wrote: > After having dequeued a burst of descriptors, there may be a > need to dequeue a few more if the last packet was segmented > and not complete. When it happens, the extra segments were > not properly attached to the mbuf chain, and so were lost. > > Also, head segment data_len field is wrongly summed with > the length of all the segments of the chain. > > This patch fixes both the mbuf chaining and head segment's > data_len field > > Fixes: bcac5aa207f8 ("net/virtio: improve batching in mergeable path") > Cc: stable@dpdk.org > > Reported-by: Yaroslav Brustinov <ybrustin@cisco.com> > Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com> > --- > drivers/net/virtio/virtio_rxtx.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/net/virtio/virtio_rxtx.c > b/drivers/net/virtio/virtio_rxtx.c > index 6b3baf0423..9469ecb743 100644 > --- a/drivers/net/virtio/virtio_rxtx.c > +++ b/drivers/net/virtio/virtio_rxtx.c > @@ -1614,7 +1614,7 @@ virtio_recv_mergeable_pkts(void *rx_queue, > struct virtqueue *vq = rxvq->vq; > struct virtio_hw *hw = vq->hw; > struct rte_mbuf *rxm; > - struct rte_mbuf *prev; > + struct rte_mbuf *prev = NULL; > uint16_t nb_used, num, nb_rx = 0; > uint32_t len[VIRTIO_MBUF_BURST_SZ]; > struct rte_mbuf *rcv_pkts[VIRTIO_MBUF_BURST_SZ]; > @@ -1721,7 +1721,6 @@ virtio_recv_mergeable_pkts(void *rx_queue, > uint16_t rcv_cnt = RTE_MIN((uint16_t)seg_res, > VIRTIO_MBUF_BURST_SZ); > > - prev = rcv_pkts[nb_rx]; > if (likely(VIRTQUEUE_NUSED(vq) >= rcv_cnt)) { > virtio_rmb(hw->weak_barriers); > num = virtqueue_dequeue_burst_rx(vq, rcv_pkts, len, > @@ -1738,7 +1737,6 @@ virtio_recv_mergeable_pkts(void *rx_queue, > prev->next = rxm; > prev = rxm; > rx_pkts[nb_rx]->pkt_len += len[extra_idx]; > - rx_pkts[nb_rx]->data_len += len[extra_idx]; > extra_idx += 1; > }; > seg_res -= rcv_cnt; > -- > 2.21.0 > > Idem previous patch, you have missed a data_len line 1704. Reviewed-by: David Marchand <david.marchand@redhat.com>
diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 6b3baf0423..9469ecb743 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -1614,7 +1614,7 @@ virtio_recv_mergeable_pkts(void *rx_queue, struct virtqueue *vq = rxvq->vq; struct virtio_hw *hw = vq->hw; struct rte_mbuf *rxm; - struct rte_mbuf *prev; + struct rte_mbuf *prev = NULL; uint16_t nb_used, num, nb_rx = 0; uint32_t len[VIRTIO_MBUF_BURST_SZ]; struct rte_mbuf *rcv_pkts[VIRTIO_MBUF_BURST_SZ]; @@ -1721,7 +1721,6 @@ virtio_recv_mergeable_pkts(void *rx_queue, uint16_t rcv_cnt = RTE_MIN((uint16_t)seg_res, VIRTIO_MBUF_BURST_SZ); - prev = rcv_pkts[nb_rx]; if (likely(VIRTQUEUE_NUSED(vq) >= rcv_cnt)) { virtio_rmb(hw->weak_barriers); num = virtqueue_dequeue_burst_rx(vq, rcv_pkts, len, @@ -1738,7 +1737,6 @@ virtio_recv_mergeable_pkts(void *rx_queue, prev->next = rxm; prev = rxm; rx_pkts[nb_rx]->pkt_len += len[extra_idx]; - rx_pkts[nb_rx]->data_len += len[extra_idx]; extra_idx += 1; }; seg_res -= rcv_cnt;
After having dequeued a burst of descriptors, there may be a need to dequeue a few more if the last packet was segmented and not complete. When it happens, the extra segments were not properly attached to the mbuf chain, and so were lost. Also, head segment data_len field is wrongly summed with the length of all the segments of the chain. This patch fixes both the mbuf chaining and head segment's data_len field Fixes: bcac5aa207f8 ("net/virtio: improve batching in mergeable path") Cc: stable@dpdk.org Reported-by: Yaroslav Brustinov <ybrustin@cisco.com> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com> --- drivers/net/virtio/virtio_rxtx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)