]> git.ipfire.org Git - thirdparty/qemu.git/commit
virtio-net: drop too short packets early
authorAlexey Dobriyan <adobriyan@yandex-team.ru>
Tue, 30 Apr 2024 10:53:33 +0000 (13:53 +0300)
committerMichael Tokarev <mjt@tls.msk.ru>
Tue, 11 Jun 2024 07:09:42 +0000 (10:09 +0300)
commit09f36a1f3fb3ebf0f14c9fd6d29611d339028280
tree59ceda3beb4defce0c7cc35055bc73471ca1edb9
parentdb0a21257e58ef65fef75eb15a3673777a3c59f8
virtio-net: drop too short packets early

Reproducer from https://gitlab.com/qemu-project/qemu/-/issues/1451
creates small packet (1 segment, len = 10 == n->guest_hdr_len),
then destroys queue.

"if (n->host_hdr_len != n->guest_hdr_len)" is triggered, if body creates
zero length/zero segment packet as there is nothing after guest header.

qemu_sendv_packet_async() tries to send it.

slirp discards it because it is smaller than Ethernet header,
but returns 0 because tx hooks are supposed to return total length of data.

0 is propagated upwards and is interpreted as "packet has been sent"
which is terrible because queue is being destroyed, nobody is waiting for TX
to complete and assert it triggered.

Fix is discard such empty packets instead of sending them.

Length 1 packets will go via different codepath:

virtqueue_push(q->tx_vq, elem, 0);
virtio_notify(vdev, q->tx_vq);
g_free(elem);

and aren't problematic.

Signed-off-by: Alexey Dobriyan <adobriyan@yandex-team.ru>
Signed-off-by: Jason Wang <jasowang@redhat.com>
(cherry picked from commit 2c3e4e2de699cd4d9f6c71f30a22d8f125cd6164)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
hw/net/virtio-net.c