1
0
mirror of https://passt.top/passt synced 2025-04-01 20:04:15 +00:00

vhost_user: Drop packet with unsupported iovec array

If the iovec array cannot be managed, drop it rather than
passing the second entry to tap_add_packet().

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
Laurent Vivier 2025-01-21 14:16:02 +01:00 committed by Stefano Brivio
parent ec5c4d936d
commit 4f2c8e7913

@ -195,15 +195,17 @@ static void vu_handle_tx(struct vu_dev *vdev, int index,
hdrlen);
} else {
/* vnet header can be in a separate iovec */
if (elem[count].out_num != 2)
if (elem[count].out_num != 2) {
debug("virtio-net transmit queue contains more than one buffer ([%d]: %u)",
count, elem[count].out_num);
if (elem[count].out_sg[0].iov_len != (size_t)hdrlen)
} else if (elem[count].out_sg[0].iov_len != (size_t)hdrlen) {
debug("virtio-net transmit queue entry not aligned on hdrlen ([%d]: %d != %zu)",
count, hdrlen, elem[count].out_sg[0].iov_len);
tap_add_packet(vdev->context,
elem[count].out_sg[1].iov_len,
(char *)elem[count].out_sg[1].iov_base);
count, hdrlen, elem[count].out_sg[0].iov_len);
} else {
tap_add_packet(vdev->context,
elem[count].out_sg[1].iov_len,
(char *)elem[count].out_sg[1].iov_base);
}
}
count++;