On Thu, Apr 16, 2026 at 05:57:18PM +0200, Laurent Vivier wrote:
With vhost-user multibuffer frames, the iov can be larger than the actual L2 frame. The previous approach of computing L2 length as iov_size() - offset would overcount and write extra bytes into the pcap file.
Pass the L2 frame length explicitly to pcap_frame() and pcap_iov(), and write exactly that many bytes instead of the full iov remainder.
Signed-off-by: Laurent Vivier
Reviewed-by: David Gibson
@@ -500,7 +500,8 @@ static size_t tap_send_frames_passt(const struct ctx *c, /* Number of unsent or partially sent buffers for the frame */ size_t rembufs = bufs_per_frame - (i % bufs_per_frame);
- if (write_remainder(c->fd_tap, &iov[i], rembufs, buf_offset) < 0) { + if (write_remainder(c->fd_tap, &iov[i], rembufs, buf_offset, + SIZE_MAX) < 0) { err_perror("tap: partial frame send"); return i; [snip] @@ -722,31 +722,54 @@ int do_clone(int (*fn)(void *), char *stack_area, size_t stack_size, int flags, * @iov: IO vector * @iovcnt: Number of entries in @iov * @skip: Number of bytes of the vector to skip writing + * @length: Number of bytes of the vector to write
Nit: This is the maximum number of bytes to write, not the exact number, which we rely on in tap_send_frames_passt() above. That makes the comment slightly misleading. -- David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson