On Fri, 6 Mar 2026 12:51:19 +0100
Laurent Vivier
Add a generic iov_truncate() function that truncates an IO vector to a given number of bytes, returning the number of iov entries that contain data after truncation.
Use it in udp_vu_sock_recv() and tcp_vu_sock_recv() to replace the open-coded truncation logic that adjusted iov entries after recvmsg(). Also convert the direct iov_len assignment in tcp_vu_send_flag() to use iov_truncate() for consistency.
Add an ASSERT() in tcp_vu_data_from_sock() to quiet the Coverity error:
passt/tcp_vu.c:457:3: 19. overflow_const: Expression "dlen + hdrlen", where "dlen" is known to be equal to -86, and "hdrlen" is known to be equal to 86, underflows the type of "dlen + hdrlen", which is type "unsigned long".
Signed-off-by: Laurent Vivier
--- Notes: v4: add ASSERT() to quiet the Coverity error v3: use in tcp_vu_send_flag() too v2: use iov_truncate() in udp_vu_sock_recv() too
Applied. -- Stefano