[PATCH v8 0/3] vhost-user,udp: Handle multiple iovec entries per virtqueue element

Laurent Vivier
2026-04-16T16:09:31Z

Some virtio-net drivers (notably iPXE) provide descriptors where the
vnet header and the frame payload are in separate buffers, resulting in
two iovec entries per virtqueue element. Currently, the RX (host to
guest) path assumes a single iovec per element, which triggers:

ASSERTION FAILED in virtqueue_map_desc (virtio.c:403):
num_sg < max_num_sg

This series reworks the UDP vhost-user receive path to support multiple
iovec entries per element, fixing the iPXE crash.

This series only addresses the UDP path. TCP vhost-user will be
updated to use multi-iov elements in a subsequent series.

Based-on: 20260416155721.3807225-1-lvivier@redhat.com

v8:
- Add Reviewed-by from David for 1/3 and 2/3
- Remove VLA to use fixed size (VIRTQUEUE_MAX_SIZE)
- Rename udp_frame to datagram
- Use sizeof(uh) instead of sizeof(struct udphdr)
- Push back uh in memory in udp_vu_csum()

v7:
- In udp_vu_sock_to_tap(), introduce iov_still_needed variable
- Fix iov_tail @data doc comments in udp_vu_prepare()/udp_vu_csum()
- Don't rewrap the virtio checksum comment in udp_update_hdr6()
- Add NULL check for uh in udp_vu_csum()

v6:
- Rebased on top of
[PATCH 00/10] vhost-user: Preparatory series for multiple iovec entries per virtqueue element

v5:
- This version doesn't change the padding system regarding v4,
it's a complex task that will be addressed in another version
- reorder patches and add new patches
- remove IOV_PUT_HEADER()/with_header() and introduce IOV_PUSH_HEADER()
- don't use the iov_tail to provide the headers to the functions
- move vu_set_vnethdr() to vu_flush(), extract vu_queue_notify()
- move vu_flush() inside loop in tcp_vu_data_from_sock() to flush data
by frame and not by full data length

v4:
- rebase
- replace ASSERT() by assert()

v3:
- include the series "Decouple iovec management from virtqueues elements"
- because of this series, drop:
"vu_common: Accept explicit iovec counts in vu_set_element()"
"vu_common: Accept explicit iovec count per element in vu_init_elem()"
"vu_common: Prepare to use multibuffer with guest RX"
"vhost-user,udp: Use 2 iovec entries per element"
- drop "vu_common: Pass iov_tail to vu_set_vnethdr()"
as the specs insures a buffer is big enough to contain vnet header
- introduce "with_header()" and merge
"udp: Pass iov_tail to udp_update_hdr4()/udp_update_hdr6()" and
"udp_vu: Use iov_tail in udp_vu_prepare()"
to use it

v2:
- add iov_truncate(), iov_memset()
- remove iov_tail_truncate() and iov_tail_zero_end()
- manage 802.3 minimum frame size

Laurent Vivier (3):
udp_vu: Allow virtqueue elements with multiple iovec entries
iov: Introduce IOV_PUSH_HEADER() macro
udp: Pass iov_tail to udp_update_hdr4()/udp_update_hdr6()

iov.c | 22 ++++++++++
iov.h | 11 +++++
udp.c | 70 ++++++++++++++++-------------
udp_internal.h | 4 +-
udp_vu.c | 116 ++++++++++++++++++++++++++-----------------------
5 files changed, 135 insertions(+), 88 deletions(-)

--
2.53.0