From: Guikun Yang <yangguikun19@qq.com>
To: Michael S. Tsirkin <mst@redhat.com>
Cc: kvm@vger.kernel.org, virtualization@lists.linux.dev,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vhost/net: initialize the whole negotiated RX vnet header
Date: Sat, 24 Oct 2026 15:08:15 +0800 [thread overview]
Message-ID: <tencent_567CCAA268528DBF6F46AC9D4A4D21A3DE09@qq.com> (raw)
In-Reply-To: <20261023080824-mutt-send-email-mst@kernel.org>
On Sat, Oct 24, 2026 at 02:45:39AM -0400, Michael S. Tsirkin wrote:
> Ah, no IFF_VNET_HDR *with* vhost. That's a weird combination.
>
> Apologies. TUN_VNET_TNL_SIZE is an internal macro that header size
> is set it. TUNSETVNETHDRSZ is what I meant.
>
> I have in mind simply disabling this combo: vhost + !IFF_VNET_HDR)
>
> I'll research a bit whether anything anywhere could reasonably
> use it.
>
> Can you reproduce any problem *with* IFF_VNET_HDR?
Yes. I added IFF_VNET_HDR + TUNSETVNETHDRSZ(24) to the repro
(in addition to VHOST_SET_FEATURES_ARRAY with the tunnel GSO bits
and VHOST_NET_F_VIRTIO_NET_HDR):
tap ifindex = 20482
TUNSETVNETHDRSZ(24) ok
tap attached to RX vq
--- RX buffer first 32 bytes (initially all 0xAA) ---
hdr: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
aa aa aa aa aa aa aa aa 00 00 00 00 00 00 00 00
The entire 24-byte vnet header area is stale 0xAA fill — including
offsets 0..9 where vhost is supposed to write the virtio_net_hdr.
The payload (from the host) starts at offset 24.
So the uninitialized vnet header is observable in both configurations:
with and without IFF_VNET_HDR on the tun device.
Note that with IFF_VNET_HDR enabled, the RX buffer is also corrupted
in a different way: the tun device prepends its own 24-byte vnet
header to the data it sends to vhost, and handle_rx() with
sock_hlen = 0 does not skip it. So even if the virtio_net_hdr
were properly written, the payload delivered to the guest would
be shifted by 24 bytes.
Best,
Guikun Yang
next prev parent reply other threads:[~2026-10-24 7:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 11:37 [PATCH] vhost/net: initialize the whole negotiated RX vnet header Guikun Yang
2026-10-23 12:13 ` Michael S. Tsirkin
2026-10-24 2:11 ` Guikun Yang
2026-10-24 6:45 ` Michael S. Tsirkin
2026-10-24 7:08 ` Guikun Yang [this message]
[not found] ` <20261024101101.71420-vhost-yangguikun19@qq.com>
[not found] ` <20261024150815.36216-vhost-yangguikun19@qq.com>
2026-10-24 7:33 ` Guikun Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_567CCAA268528DBF6F46AC9D4A4D21A3DE09@qq.com \
--to=yangguikun19@qq.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=virtualization@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox