From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=162.62.57.137 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792807872; b=ZA6gUry8AKrSKKljPP9Jub5ROlOsfMkGnu8dUsWQ1+KGPwx56VfXmNBl8IwmNv/+2Qx4 zO9HL/HxHMZ2/T8qy9Bv6o74YsfaN8kl6cZiTn+YcaHXKpashSA0VNtXDdTt6oKCGs+9e KRRwc201emVXRw5XdZydnoogbIdgkXmkM4l5ydjddsll/Th8C4lVKRPhlEo977DllenXv 9raYVBScQP3wkOTohsMGQYNgjmzxOJt5gXY5vLxplfuh5EoCHoASPSwAS8Pr+WvIlZsvn vjx9RTxyoZrWnJ4Bn3fCP1geoai8OYxcX8sABFVjsczLlGbouBoRCd4apVXb8YnuJMg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792807872; h=DMARC-Filter:DKIM-Signature:Received:X-QQ-mid:Message-ID: X-QQ-XMAILINFO:X-QQ-XMRINFO:From:To:Cc:Subject:Date:X-OQ-MSGID: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=863FoNpy4fj3rnzzl3jnxGRI7PKAwuQa9MouObwaNBU=; b=5JtkMS8VliTXX7shdhiA8JHGihAgvSMfCUM98vKyv8iXY9xeIiPI8Mqoaml7ur6MM0GP O3mECDgDJXmVRiJ0Sk3gZgzU0CuAMfi+nBQGL8k3qhgakS+n2qSoO+pZhlQ1BgxwmWRsy pUMELn8WgOQO/P16viCt36v9r7BAHPgQWQyp6fnttnGMOWwX1V9xeszKaMatMpJoXZdLQ TjzEsZVLsg+4T4IHyFycLczc+0yMQSwhHE/LcuiB+E5xX/cc5kZWLoWqugCDpTaJkbA3D bIxxDGgJNqsdwmZFc4xkhS3ArIhvdE+vyUr74LSprTabTdYDl7xmfpkbh9ZFYRTMtgg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=qq.com; spf=pass smtp.mailfrom=qq.com; dkim=pass header.d=qq.com header.i=@qq.com header.a=rsa-sha256 header.s=s201512 header.b=fLNbGzcO; arc=none smtp.remote-ip=162.62.57.137 Received: from out162-62-57-137.mail.qq.com (out162-62-57-137.mail.qq.com [162.62.57.137]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3924D606A31A; Sat, 24 Oct 2026 02:11:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3924D606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=qq.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qq.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=qq.com header.i=@qq.com header.a=rsa-sha256 header.s=s201512 header.b=fLNbGzcO DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1792807865; bh=863FoNpy4fj3rnzzl3jnxGRI7PKAwuQa9MouObwaNBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fLNbGzcOgmMflwz2BVnAkdwzwvFmwyQkbEBnzvnf2+uYWmhbA7R6/XQ1vQnZ95AXm GvvF5BGodXNvZs3gObE8P9Acw8OwpYoZfjjhZDfFaGgnIg8qYDzaHmT+TQuuBnij0M 560SWiYo/WJfqP4GS+44h/SQPS285ekaO8aJNW20= Received: from [172.18.4.77] ([111.31.227.58]) by newxmesmtplogicsvrsza73-0.qq.com (NewEsmtp) with SMTP id 2C2AE094; Sat, 24 Oct 2026 10:11:02 +0800 X-QQ-mid: xmsmtpt1792807862tc0qulw03 Message-ID: X-QQ-XMAILINFO: N1JCMsqefaecSzIBam8zWC5oCLpflIj/PvoxrkbFRGfCDTMnJrNWJalOpMgpW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X7UuhPEoou2bs1g== From: Guikun Yang To: Michael S. Tsirkin Cc: Jason Wang , Eugenio Perez , 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 10:11:01 +0800 X-OQ-MSGID: <20261024101101.71420-vhost-yangguikun19@qq.com> In-Reply-To: <20261023080824-mutt-send-email-mst@kernel.org> References: <20261023080824-mutt-send-email-mst@kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit On Fri, Oct 23, 2026 at 08:13:22AM -0400, Michael S. Tsirkin wrote: > Which backend did you use? Sounds like you did not set > TUN_VNET_TNL_SIZE or did not set TUNSETOFFLOAD? > That's the issue then. The backend is a tap device attached via the normal tun path: TUNSETIFF (IFF_TAP|IFF_NO_PI, no IFF_VNET_HDR), then VHOST_NET_SET_BACKEND on the RX vq. I re-ran the repro with TUNSETOFFLOAD declared before attaching the backend, listing every offload bit the interface understands: TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 | TUN_F_USO4 | TUN_F_USO6 | TUN_F_UDP_TUNNEL_GSO | TUN_F_UDP_TUNNEL_GSO_CSUM TUNSETOFFLOAD succeeds (0 is returned, so tun accepted all of them, including the UDP tunnel GSO bits). The result is unchanged: features[0] = 0x108000000, features[1] = 0xa (tunnel bits on) VHOST_SET_FEATURES_ARRAY ok TUNSETOFFLOAD ok --- RX buffer first 32 bytes (initially all 0xAA) --- hdr: 00 00 00 00 00 00 00 00 00 00 01 00 aa aa aa aa aa aa aa aa aa aa aa aa <-- offsets 12..23 33 33 00 00 ... Offsets 12..23 still contain the stale 0xAA fill. The reason is that vhost_net_set_features() computes vhost_hlen purely from the feature bits passed via VHOST_SET_FEATURES(_ARRAY): hdr_len = ... sizeof(struct virtio_net_hdr_v1_hash_tunnel) when HOST/GUEST_UDP_TUNNEL_GSO is set ... if (test_bit(VHOST_NET_F_VIRTIO_NET_HDR)) vhost_hlen = hdr_len; TUNSETOFFLOAD only updates tun->set_features and the tap device's wanted_features; it does not feed back into the vhost feature bits or into vhost_hlen. handle_rx() then writes vhost_hlen bytes of the virtio-net header into the guest buffer while handle_tx() / the GSO path never touches those 12 bytes for a header vhost itself built. I could not find TUN_VNET_TNL_SIZE anywhere in 7.3.0-rc7 or in linux-next (drivers/net/tun.c, drivers/vhost/net.c, include/uapi/linux/ if_tun.h, include/uapi/linux/vhost.h) — is that an interface from a tree/series I'm missing? If it is meant to gate vhost_hlen I'd be happy to re-test with it. Meanwhile the stale 12 bytes are observable with a plain tun backend that has declared full tunnel offload support, so I believe the patch (Zero-initialize the largest header layout and copy vhost_hlen bytes) is still needed. Happy to re-test under whatever backend setup you had in mind. Best, Guikun Yang