vhost: fix used descriptors number of mergeable enqueue
authorIlya Maximets <i.maximets@samsung.com>
Fri, 15 Jul 2016 11:15:04 +0000 (14:15 +0300)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Fri, 15 Jul 2016 20:12:37 +0000 (22:12 +0200)
Return value on error changed from '-1' to '0' because it returns
unsigned value and it means number of used descriptors.

Also fixed updating of 'last_used_idx' by using actual number of
used descriptors.

Fixes: 623bc47054d0 ("vhost: do sanity check for ring descriptor length")

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
lib/librte_vhost/vhost_rxtx.c

index 15ca956..a9b04df 100644 (file)
@@ -388,7 +388,7 @@ copy_mbuf_to_desc_mergeable(struct virtio_net *dev, struct vhost_virtqueue *vq,
                dev->vid, cur_idx, end_idx);
 
        if (buf_vec[vec_idx].buf_len < dev->vhost_hlen)
-               return -1;
+               return 0;
 
        desc_addr = gpa_to_vva(dev, buf_vec[vec_idx].buf_addr);
        rte_prefetch0((void *)(uintptr_t)desc_addr);
@@ -507,7 +507,7 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t queue_id,
                *(volatile uint16_t *)&vq->used->idx += nr_used;
                vhost_log_used_vring(dev, vq, offsetof(struct vring_used, idx),
                        sizeof(vq->used->idx));
-               vq->last_used_idx = end;
+               vq->last_used_idx += nr_used;
        }
 
        if (likely(pkt_idx)) {