From 81dac0670beac0d4e0be8afa46e67f0c40a3f14f Mon Sep 17 00:00:00 2001 From: Mohsin Kazmi Date: Wed, 11 Nov 2020 20:28:35 +0100 Subject: virtio: fix the index issue Type: fix Fixes: 587f9130424fd451e4ba823240d02f655fb197d1 Change-Id: I230993a54c84e22e324de2a8defeda83c517d733 Signed-off-by: Mohsin Kazmi --- src/vnet/devices/virtio/device.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/vnet') diff --git a/src/vnet/devices/virtio/device.c b/src/vnet/devices/virtio/device.c index cba13f920e3..add82b77634 100644 --- a/src/vnet/devices/virtio/device.c +++ b/src/vnet/devices/virtio/device.c @@ -707,13 +707,19 @@ retry: if (vif->type == VIRTIO_IF_TYPE_TAP) n_left = virtio_interface_tx_inline (vm, node, vif, vring, - VIRTIO_IF_TYPE_TAP, buffers, n_left); + VIRTIO_IF_TYPE_TAP, + &buffers[frame->n_vectors - n_left], + n_left); else if (vif->type == VIRTIO_IF_TYPE_PCI) n_left = virtio_interface_tx_inline (vm, node, vif, vring, - VIRTIO_IF_TYPE_PCI, buffers, n_left); + VIRTIO_IF_TYPE_PCI, + &buffers[frame->n_vectors - n_left], + n_left); else if (vif->type == VIRTIO_IF_TYPE_TUN) n_left = virtio_interface_tx_inline (vm, node, vif, vring, - VIRTIO_IF_TYPE_TUN, buffers, n_left); + VIRTIO_IF_TYPE_TUN, + &buffers[frame->n_vectors - n_left], + n_left); else ASSERT (0); @@ -722,15 +728,17 @@ retry: if (vif->packet_buffering && n_left) { - u16 n_buffered = - virtio_vring_buffering_store_packets (vring->buffering, buffers, - n_left); + u16 n_buffered = virtio_vring_buffering_store_packets (vring->buffering, + &buffers + [frame->n_vectors + - n_left], + n_left); buffers += n_buffered; n_left -= n_buffered; } if (n_left) virtio_interface_drop_inline (vm, node->node_index, - buffers + frame->n_vectors - n_left, n_left, + &buffers[frame->n_vectors - n_left], n_left, VIRTIO_TX_ERROR_NO_FREE_SLOTS); clib_spinlock_unlock_if_init (&vring->lockp); -- cgit 1.2.3-korg