* [passt-dev] [bug] vhost-user multi-vector packets cause corrupted duplicates to be transmitted
@ 2026-11-23 7:27 Agustín Dall'Alba
2026-11-23 9:55 ` Stefano Brivio
0 siblings, 1 reply; 2+ messages in thread
From: Agustín Dall'Alba @ 2026-11-23 7:27 UTC (permalink / raw)
To: passt-user; +Cc: lvivier, david, sbrivio
[-- Attachment #1: Type: text/plain, Size: 1314 bytes --]
Dear passt authors,
I'm sending this bug report to you directly because I was unable to
register to the bug tracker or subscribe to the mailing list.
I've found an issue when attempting to use passt with qemu vhost-user.
The VM guest is Windows 11 with the NetKVM driver. The issue can be
reproduced more easily by disabling offloads.
Unlike the Linux virtio driver, NetKVM places the frame headers and
the payload in different buffers. Then for every UDP frame coming from
the guest, the host sends 3 UDP packets:
- 1 packet with the whole payload
- 1 packet with no payload
- 1 packet with the payload offset by 8 bytes (size of the header)
This causes QUIC and DNS to work unreliably on the guest.
I've attached a cut of the pcap and log files produced by passt
2026_10_02.cba3570-28-g094211f with flags `--debug --trace --pcap`, as
well as the corresponding output of `strace -tt -e trace=network`.
Reproducing the issue is quite difficult, since it requires setting up
a Windows VM. As an alternative I've attached a largely "vibe-coded"
test case. Place `multibuf.py` into `tests/vhost_user/multibuf.py`,
then `chmod +x` and `./run vhost_user/multibuf.py`.
This bug was introduced in commit ca38be0 "packet: Add support for
multi-vector packets"
Thanks,
Agustín
[-- Attachment #2: passt-selected.pcap --]
[-- Type: application/octet-stream, Size: 1014 bytes --]
[-- Attachment #3: passt-selected.log --]
[-- Type: application/octet-stream, Size: 2876 bytes --]
375.0186: tap: protocol 17, 10.244.1.21:61636 -> 10.96.0.10:53 (3 packets)
375.0186: Flow 13 (NEW): FREE -> NEW
375.0186: Flow 13 (INI): NEW -> INI
375.0187: Flow 13 (INI): TAP [10.244.1.21]:61636 -> [10.96.0.10]:53 => ?
375.0187: Flow 13 (TGT): INI -> TGT
375.0188: Flow 13 (TGT): TAP [10.244.1.21]:61636 -> [10.96.0.10]:53 => HOST [0.0.0.0]:61636 -> [10.96.0.10]:53
375.0213: Flow 13 (UDP flow): TGT -> TYPED
375.0213: Flow 13 (UDP flow): TAP [10.244.1.21]:61636 -> [10.96.0.10]:53 => HOST [0.0.0.0]:61636 -> [10.96.0.10]:53
375.0221: Flow 13 (UDP flow): Side 0 hash table insert: bucket: 238732
375.0221: Flow 13 (UDP flow): Side 1 hash table insert: bucket: 245972
375.0222: Flow 13 (UDP flow): TYPED -> ACTIVE
375.0222: Flow 13 (UDP flow): TAP [10.244.1.21]:61636 -> [10.96.0.10]:53 => HOST [10.244.1.21]:61636 -> [10.96.0.10]:53
375.0231: tap: protocol 17, 10.244.1.21:64869 -> 10.96.0.10:53 (3 packets)
375.0232: Flow 14 (NEW): FREE -> NEW
375.0232: Flow 14 (INI): NEW -> INI
375.0232: Flow 14 (INI): TAP [10.244.1.21]:64869 -> [10.96.0.10]:53 => ?
375.0233: Flow 14 (TGT): INI -> TGT
375.0233: Flow 14 (TGT): TAP [10.244.1.21]:64869 -> [10.96.0.10]:53 => HOST [0.0.0.0]:64869 -> [10.96.0.10]:53
375.0233: Flow 14 (UDP flow): TGT -> TYPED
375.0234: Flow 14 (UDP flow): TAP [10.244.1.21]:64869 -> [10.96.0.10]:53 => HOST [0.0.0.0]:64869 -> [10.96.0.10]:53
375.0244: Flow 14 (UDP flow): Side 0 hash table insert: bucket: 103747
375.0244: Flow 14 (UDP flow): Side 1 hash table insert: bucket: 315467
375.0244: Flow 14 (UDP flow): TYPED -> ACTIVE
375.0245: Flow 14 (UDP flow): TAP [10.244.1.21]:64869 -> [10.96.0.10]:53 => HOST [10.244.1.21]:64869 -> [10.96.0.10]:53
375.0252: tap: protocol 17, 10.244.1.21:65426 -> 10.96.0.10:53 (3 packets)
375.0253: Flow 15 (NEW): FREE -> NEW
375.0253: Flow 15 (INI): NEW -> INI
375.0254: Flow 15 (INI): TAP [10.244.1.21]:65426 -> [10.96.0.10]:53 => ?
375.0254: Flow 15 (TGT): INI -> TGT
375.0254: Flow 15 (TGT): TAP [10.244.1.21]:65426 -> [10.96.0.10]:53 => HOST [0.0.0.0]:65426 -> [10.96.0.10]:53
375.0255: Flow 15 (UDP flow): TGT -> TYPED
375.0255: Flow 15 (UDP flow): TAP [10.244.1.21]:65426 -> [10.96.0.10]:53 => HOST [0.0.0.0]:65426 -> [10.96.0.10]:53
375.0264: Flow 15 (UDP flow): Side 0 hash table insert: bucket: 355762
375.0265: Flow 15 (UDP flow): Side 1 hash table insert: bucket: 71794
375.0265: Flow 15 (UDP flow): TYPED -> ACTIVE
375.0265: Flow 15 (UDP flow): TAP [10.244.1.21]:65426 -> [10.96.0.10]:53 => HOST [10.244.1.21]:65426 -> [10.96.0.10]:53
[-- Attachment #4: strace-selected.log --]
[-- Type: application/octet-stream, Size: 4239 bytes --]
03:31:44.651265 socket(AF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_UDP) = 48
03:31:44.651383 setsockopt(48, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
03:31:44.651472 setsockopt(48, SOL_IP, IP_RECVERR, [1], 4) = 0
03:31:44.651554 setsockopt(48, SOL_IP, IP_PKTINFO, [1], 4) = 0
03:31:44.651639 bind(48, {sa_family=AF_INET, sin_port=htons(61636), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
03:31:44.651776 connect(48, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("10.96.0.10")}, 16) = 0
03:31:44.651899 getsockname(48, {sa_family=AF_INET, sin_port=htons(61636), sin_addr=inet_addr("10.244.1.21")}, [28 => 16]) = 0
03:31:44.652166 setsockopt(48, SOL_IP, IP_TTL, "\200", 1) = 0
03:31:44.652266 sendmmsg(48, [{msg_hdr={msg_name={sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("10.96.0.10")}, msg_namelen=16, msg_iov=[{iov_base="Ko\1\0\0\1\0\0\0\0\0\0\4quic\5nginx\3org\0\0A\0\1", iov_len=32}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, msg_len=32}, {msg_hdr={msg_name={sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("10.96.0.10")}, msg_namelen=16, msg_iov=[], msg_iovlen=0, msg_controllen=0, msg_flags=0}, msg_len=0}, {msg_hdr={msg_name={sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("10.96.0.10")}, msg_namelen=16, msg_iov=[{iov_base="\0\0\0\0\4quic\5nginx\3org\0\0A\0\1", iov_len=24}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, msg_len=24}], 3, MSG_NOSIGNAL) = 3
03:31:44.653319 socket(AF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_UDP) = 49
03:31:44.653424 setsockopt(49, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
03:31:44.653511 setsockopt(49, SOL_IP, IP_RECVERR, [1], 4) = 0
03:31:44.653611 setsockopt(49, SOL_IP, IP_PKTINFO, [1], 4) = 0
03:31:44.653704 bind(49, {sa_family=AF_INET, sin_port=htons(64869), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
03:31:44.653994 connect(49, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("10.96.0.10")}, 16) = 0
03:31:44.654122 getsockname(49, {sa_family=AF_INET, sin_port=htons(64869), sin_addr=inet_addr("10.244.1.21")}, [28 => 16]) = 0
03:31:44.654401 setsockopt(49, SOL_IP, IP_TTL, "\200", 1) = 0
03:31:44.654492 sendmmsg(49, [{msg_hdr={msg_name={sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("10.96.0.10")}, msg_namelen=16, msg_iov=[{iov_base="\236\235\1\0\0\1\0\0\0\0\0\0\4quic\5nginx\3org\0\0\34\0\1", iov_len=32}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, msg_len=32}, {msg_hdr={msg_name={sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("10.96.0.10")}, msg_namelen=16, msg_iov=[], msg_iovlen=0, msg_controllen=0, msg_flags=0}, msg_len=0}, {msg_hdr={msg_name={sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("10.96.0.10")}, msg_namelen=16, msg_iov=[{iov_base="\0\0\0\0\4quic\5nginx\3org\0\0\34\0\1", iov_len=24}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, msg_len=24}], 3, MSG_NOSIGNAL) = 3
03:31:44.655457 socket(AF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_UDP) = 54
03:31:44.655549 setsockopt(54, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
03:31:44.655650 setsockopt(54, SOL_IP, IP_RECVERR, [1], 4) = 0
03:31:44.655759 setsockopt(54, SOL_IP, IP_PKTINFO, [1], 4) = 0
03:31:44.655838 bind(54, {sa_family=AF_INET, sin_port=htons(65426), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
03:31:44.655997 connect(54, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("10.96.0.10")}, 16) = 0
03:31:44.656127 getsockname(54, {sa_family=AF_INET, sin_port=htons(65426), sin_addr=inet_addr("10.244.1.21")}, [28 => 16]) = 0
03:31:44.656480 setsockopt(54, SOL_IP, IP_TTL, "\200", 1) = 0
03:31:44.656567 sendmmsg(54, [{msg_hdr={msg_name={sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("10.96.0.10")}, msg_namelen=16, msg_iov=[{iov_base="\251\272\1\0\0\1\0\0\0\0\0\0\4quic\5nginx\3org\0\0\1\0\1", iov_len=32}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, msg_len=32}, {msg_hdr={msg_name={sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("10.96.0.10")}, msg_namelen=16, msg_iov=[], msg_iovlen=0, msg_controllen=0, msg_flags=0}, msg_len=0}, {msg_hdr={msg_name={sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("10.96.0.10")}, msg_namelen=16, msg_iov=[{iov_base="\0\0\0\0\4quic\5nginx\3org\0\0\1\0\1", iov_len=24}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, msg_len=24}], 3, MSG_NOSIGNAL) = 3
[-- Attachment #5: multibuf.py --]
[-- Type: text/x-python, Size: 6503 bytes --]
#! /usr/bin/env python3
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
# PASST - Plug A Simple Socket Transport
# for qemu/UNIX domain socket mode
#
# PASTA - Pack A Subtle Tap Abstraction
# for network namespace/tap device mode
#
# test/vhost_user/multibuf.py - Guest frames split over several descriptors
#
# A minimal vhost-user front-end, standing in for qemu and a guest driver, that
# sends a single UDP datagram with the frame split over two descriptors:
# virtio-net header plus Ethernet, IP and UDP headers in the first one, payload
# in the second one. This is how the Windows NetKVM driver submits frames with
# VIRTIO_F_ANY_LAYOUT, while Linux guests use a single buffer for the frame.
import contextlib
import mmap
import os
import socket
import struct
import subprocess
import tempfile
import time
from typing import Iterator
import exeter
PASST = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'..', '..', 'passt')
# vhost-user requests
GET_FEATURES, SET_FEATURES, SET_OWNER, SET_MEM_TABLE = 1, 2, 3, 5
SET_VRING_NUM, SET_VRING_ADDR, SET_VRING_BASE = 8, 9, 10
SET_VRING_KICK, SET_VRING_CALL = 12, 13
F_VERSION_1, F_MRG_RXBUF = 1 << 32, 1 << 15
QSIZE = 16
MEMSIZE = 1 << 20
QVA = 0x7f0000000000 # Address of guest memory for the "front-end"
DESC, AVAIL, USED = 0x0, 0x1000, 0x2000 # Ring offsets in guest memory
DATA = 0x10000 # Packet buffers in guest memory
GUEST_IP, GW_IP = '10.0.2.15', '10.0.2.2' # GW_IP mapped to host loopback
GUEST_MAC = bytes.fromhex('525400123456')
PASST_MAC = bytes.fromhex('9a559a559a55')
def ip_csum(hdr: bytes) -> int:
s: int = sum(struct.unpack(f'!{len(hdr) // 2}H', hdr))
while s >> 16:
s = (s & 0xffff) + (s >> 16)
return ~s & 0xffff
def udp_frame(src: str, dst: str, port: int, payload: bytes) -> bytes:
"""Ethernet, IPv4 and UDP headers for payload (UDP checksum disabled)"""
eth = PASST_MAC + GUEST_MAC + b'\x08\x00'
ip = struct.pack('!BBHHHBBH4s4s', 0x45, 0, 20 + 8 + len(payload), 0,
0x4000, 64, socket.IPPROTO_UDP, 0,
socket.inet_aton(src), socket.inet_aton(dst))
ip = ip[:10] + struct.pack('!H', ip_csum(ip)) + ip[12:]
udp = struct.pack('!HHHH', 40000, port, 8 + len(payload), 0)
return eth + ip + udp
class VhostUser:
def __init__(self, path: str) -> None:
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.sock.connect(path)
self.memfd = os.memfd_create('guest', 0)
os.ftruncate(self.memfd, MEMSIZE)
self.mem = mmap.mmap(self.memfd, MEMSIZE)
def msg(self, req: int, payload: bytes = b'', fds: tuple[int, ...] = (),
reply: bool = False) -> bytes:
hdr = struct.pack('<III', req, 0x1, len(payload))
socket.send_fds(self.sock, [hdr + payload], list(fds))
if not reply:
return b''
rhdr = self.sock.recv(12)
size = struct.unpack('<III', rhdr)[2]
return self.sock.recv(size)
def setup(self) -> None:
feat = struct.unpack('<Q', self.msg(GET_FEATURES, reply=True))[0]
assert feat & F_VERSION_1
self.msg(SET_FEATURES, struct.pack('<Q', F_VERSION_1 | F_MRG_RXBUF))
self.msg(SET_OWNER)
# One region: guest physical address 0 maps to offset 0 of memfd
self.msg(SET_MEM_TABLE, struct.pack('<IIQQQQ', 1, 0, 0, MEMSIZE,
QVA, 0), (self.memfd,))
self.kick: list[int] = []
for q in (0, 1): # RX and TX queues, separate rings
base = q * 0x8000
self.msg(SET_VRING_NUM, struct.pack('<II', q, QSIZE))
self.msg(SET_VRING_BASE, struct.pack('<II', q, 0))
self.msg(SET_VRING_ADDR,
struct.pack('<IIQQQQ', q, 0, QVA + base + DESC,
QVA + base + USED, QVA + base + AVAIL, 0))
call, kick = os.eventfd(0), os.eventfd(0)
self.msg(SET_VRING_CALL, struct.pack('<Q', q), (call,))
self.msg(SET_VRING_KICK, struct.pack('<Q', q), (kick,))
self.kick.append(kick)
def send(self, bufs: list[bytes]) -> None:
"""Queue one frame on TX as a descriptor chain, one buffer each"""
base, addr = 0x8000, DATA
for i, b in enumerate(bufs):
self.mem[addr:addr + len(b)] = b
more = i < len(bufs) - 1
struct.pack_into('<QIHH', self.mem, base + DESC + i * 16,
addr, len(b), 1 if more else 0, i + 1)
addr += 0x1000
struct.pack_into('<H', self.mem, base + AVAIL + 4, 0) # ring[0]
struct.pack_into('<H', self.mem, base + AVAIL + 2, 1) # idx
os.eventfd_write(self.kick[1], 1)
@contextlib.contextmanager
def passt_vu() -> Iterator[VhostUser]:
with tempfile.TemporaryDirectory() as tmpdir:
path = os.path.join(tmpdir, 'vu.sock')
proc = subprocess.Popen([PASST, '-f', '-q', '--vhost-user',
'--socket', path, '-4', '-a', GUEST_IP,
'-n', '24', '-g', GW_IP,
'--map-host-loopback', GW_IP])
try:
for _ in range(100):
if os.path.exists(path):
break
time.sleep(0.05)
yield VhostUser(path)
finally:
proc.kill()
proc.wait()
def guest_udp(bufs_of: str) -> None:
payload = bytes(range(32))
host = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
host.bind(('127.0.0.1', 0))
host.settimeout(1)
port = host.getsockname()[1]
with passt_vu() as vu:
vu.setup()
hdrs = udp_frame(GUEST_IP, GW_IP, port, payload)
vnet = bytes(12)
if bufs_of == 'single':
vu.send([vnet + hdrs + payload])
else:
vu.send([vnet + hdrs, payload])
got = []
with contextlib.suppress(socket.timeout):
while True:
got.append(host.recv(65536))
assert got == [payload], f'expected one datagram {payload!r}, got {got!r}'
@exeter.test
def udp_single_buffer() -> None:
"""Guest UDP datagram in one descriptor reaches host once, intact"""
guest_udp('single')
@exeter.test
def udp_split_headers_payload() -> None:
"""Guest UDP datagram split over two descriptors reaches host once"""
guest_udp('split')
if __name__ == '__main__':
exeter.main()
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [passt-dev] [bug] vhost-user multi-vector packets cause corrupted duplicates to be transmitted
2026-11-23 7:27 [passt-dev] [bug] vhost-user multi-vector packets cause corrupted duplicates to be transmitted Agustín Dall'Alba
@ 2026-11-23 9:55 ` Stefano Brivio
0 siblings, 0 replies; 2+ messages in thread
From: Stefano Brivio @ 2026-11-23 9:55 UTC (permalink / raw)
To: Agustín Dall'Alba; +Cc: passt-user, lvivier, david
Hi Augustin,
On Mon, 23 Nov 2026 04:27:33 -0300
Agustín Dall'Alba <passt@dallalba.com.ar> wrote:
> Dear passt authors,
>
> I'm sending this bug report to you directly because I was unable to
> register to the bug tracker or subscribe to the mailing list.
Thanks for the report. You should have received confirmation emails
now. It would still be valuable if you could file this as a ticket.
> I've found an issue when attempting to use passt with qemu vhost-user.
> The VM guest is Windows 11 with the NetKVM driver. The issue can be
> reproduced more easily by disabling offloads.
>
> Unlike the Linux virtio driver, NetKVM places the frame headers and
> the payload in different buffers. Then for every UDP frame coming from
> the guest, the host sends 3 UDP packets:
>
> - 1 packet with the whole payload
> - 1 packet with no payload
> - 1 packet with the payload offset by 8 bytes (size of the header)
>
> This causes QUIC and DNS to work unreliably on the guest.
This should be addressed by this pending patch:
https://archives.passt.top/passt-dev/20261102073011.3537587-1-luochunsheng@ustc.edu/
but it's not merged yet, because a part is missing. See:
https://archives.passt.top/passt-dev/15a03a23-c8fb-49dc-8f65-6620e48b2941@redhat.com/
...we should understand if we want to merge it anyway for the moment,
or if somebody finds the time to implement the missing bit...
--
Stefano
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-23 9:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23 7:27 [passt-dev] [bug] vhost-user multi-vector packets cause corrupted duplicates to be transmitted Agustín Dall'Alba
2026-11-23 9:55 ` Stefano Brivio
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).