vhost_net: revert upend_idx only on retriable error
authorAndrey Smetanin <asmetanin@yandex-team.ru>
Mon, 24 Apr 2023 20:44:11 +0000 (23:44 +0300)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 8 Jun 2023 19:43:08 +0000 (15:43 -0400)
commit1f5d2e3bab16369d5d4b4020a25db4ab1f4f082c
treefec6d47fc4c1f4134c4871e4afdd93067d6ae1db
parent376daf317753ccb6b1ecbdece66018f7f6313a7f
vhost_net: revert upend_idx only on retriable error

Fix possible virtqueue used buffers leak and corresponding stuck
in case of temporary -EIO from sendmsg() which is produced by
tun driver while backend device is not up.

In case of no-retriable error and zcopy do not revert upend_idx
to pass packet data (that is update used_idx in corresponding
vhost_zerocopy_signal_used()) as if packet data has been
transferred successfully.

v2: set vq->heads[ubuf->desc].len equal to VHOST_DMA_DONE_LEN
in case of fake successful transmit.

Signed-off-by: Andrey Smetanin <asmetanin@yandex-team.ru>
Message-Id: <20230424204411.24888-1-asmetanin@yandex-team.ru>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Andrey Smetanin <asmetanin@yandex-team.ru>
Acked-by: Jason Wang <jasowang@redhat.com>
drivers/vhost/net.c