🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #17223

Re: [PATCH net-next v5 7/9] vhost-net: support VIRTIO_NET_F_RX_TSTAMP

#17223
From: netdev-bot+sashiko
Date: Mon, 16 Nov 2026 13:55
143 lines
14034 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] vhost-net now always offers VIRTIO_NET_F_RX_TSTAMP ("Device
  sends TAI receive time") through VHOST_GET_FEATURES…
- [Medium] Sizing the vnet header to 40 bytes for VIRTIO_NET_F_RX_TSTAMP
  alone (vhost_net_set_features(), drivers/vhost/net.c:1702-1704) breaks…

--

vhost-net: support VIRTIO_NET_F_RX_TSTAMP

This commit advertises VIRTIO_NET_F_RX_TSTAMP from vhost-net and sizes the
vnet header to 40 bytes when the feature is negotiated. When vhost supplies
the header itself, everything behind the fields it fills in is zeroed, so
the timestamp is left at 0.

> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
> index 435d8ed3851f3..1b171af105a22 100644
> --- a/drivers/vhost/net.c
> +++ b/drivers/vhost/net.c
> @@ -77,7 +77,8 @@ static const int vhost_net_bits[] = {
>  	VIRTIO_F_RING_RESET,
>  	VIRTIO_F_IN_ORDER,
>  	VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO,
> -	VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO
> +	VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO,
> +	VIRTIO_NET_F_RX_TSTAMP
>  };

[Severity: Medium]
Should VIRTIO_NET_F_RX_TSTAMP be offered unconditionally through
VHOST_GET_FEATURES when nothing in the RX path writes a timestamp?

With VHOST_NET_F_VIRTIO_NET_HDR, the new block in handle_rx() zeroes every
byte after hdr_filled, so tstamp is always 0:

    if (unlikely(vhost_hlen > hdr_filled)) {
        size_t rest = vhost_hlen - hdr_filled;

        if (iov_iter_zero(rest, &fixup) != rest) {

With a socket-supplied header, the commit message says tun fills in the
timestamp. But __tun_vnet_hdr_put() in drivers/net/tun_vnet.h copies only
tun_vnet_parse_size(features) bytes (10 or 24) and zeroes the rest:

    unsigned int parsed_size = tun_vnet_parse_size(features);
    ...
    if (iov_iter_zero(sz - parsed_size, iter) != sz - parsed_size)
        return -EFAULT;

tun.c, tap.c and tun_vnet.h don't reference tstamp at all.

The last patch in the series, "tun: add rx timestamp to the vnet header",
is labeled as not intended to be merged. Even with that patch applied, only
tun_put_user() fills in the timestamp. tun_put_user_xdp() and tap_put_user()
still go through tun_vnet_hdr_put() with a zero-initialized
virtio_net_common_hdr, so tstamp stays 0 on those paths.

On the guest side, negotiating the bit sets vi->rx_tstamp_supported.
virtnet_get_ts_info() then reports:

    if (vi->rx_tstamp_supported) {
        info->so_timestamping |=
            SOF_TIMESTAMPING_RX_HARDWARE |
            SOF_TIMESTAMPING_RAW_HARDWARE;

virtnet_hwtstamp_set() also accepts HWTSTAMP_FILTER_ALL. Since every
timestamp is 0, no skb ever gets a hwtstamp. A guest PTP stack that turns
on hardware RX timestamping because of the advertised capability will
never receive any timestamps.

Once the bit is in vhost_net_bits[] it is visible to userspace. Could the
feature be offered only when the attached backend can actually produce a
timestamp?

[ ... ]

> @@ -1684,6 +1699,10 @@ static int vhost_net_set_features(struct vhost_net *n, const u64 *features)
>  				     VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO))
>  		hdr_len = sizeof(struct virtio_net_hdr_v1_hash_tunnel);
>  
> +	/* The header layout is cumulative, tstamp sits behind all other fields. */
> +	if (virtio_features_test_bit(features, VIRTIO_NET_F_RX_TSTAMP))
> +		hdr_len = offsetofend(struct virtio_net_common_hdr, tstamp);
> +

[Severity: Medium]
Does a 40 byte header for RX_TSTAMP alone break the way tun guesses the
guest features?

tun_vnet_hdr_guest_features() in drivers/net/tun_vnet.h infers the tunnel
features from the header size:

    /*
     * Tun is not aware of the negotiated guest features, guess them from the
     * virtio net hdr size
     */
    static inline netdev_features_t tun_vnet_hdr_guest_features(int vnet_hdr_sz)
    {
        if (vnet_hdr_sz >= TUN_VNET_TNL_SIZE)
            return NETIF_F_GSO_UDP_TUNNEL | NETIF_F_GSO_UDP_TUNNEL_CSUM;
        return 0;
    }

Take socket-header mode with a guest that negotiates RX_TSTAMP but neither
HOST_UDP_TUNNEL_GSO nor GUEST_UDP_TUNNEL_GSO. It gets sock_hlen = 40, so
the tap's vnet_hdr_sz is 40. Both guest TX paths then treat the tunnel
features as negotiated:

    tun_get_user()
        features = tun_vnet_hdr_guest_features(vnet_hdr_sz);
        hdr_len = __tun_vnet_hdr_get(vnet_hdr_sz, tun->flags,
                                     features, from, gso);

    vhost_net_build_xdp() ... tun_sendmsg()->tun_xdp_one()
        features = tun_vnet_hdr_guest_features(READ_ONCE(tun->vnet_hdr_sz));
        ...
        tun_vnet_hdr_tnl_to_skb(tun->flags, features, skb, tnl_hdr)

This passes tnl_hdr_negotiated = true and tnl_csum_negotiated = true into
virtio_net_hdr_tnl_to_skb(). As a result, the -EINVAL check for a header
that asks for tunnel GSO without negotiating it is skipped. The
VIRTIO_NET_HDR_F_UDP_TUNNEL_CSUM check is skipped as well.

Could a guest then get UDP tunnel GSO packets, and the tunnel csum flag,
accepted by the host even when the VMM left host UDP tunnel GSO disabled?

Before this patch, only the tunnel features made the vhost-net header 24
bytes or larger, so the heuristic held. Nothing else in the series updates
tun.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112-v6-7-topic-virtio-net-ptp-v5-0-7ab67b572f4f%40pengutronix.de
Technical Details
Message-ID: <179483730723.3136.9748134612882994107@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364395-linux-kernel-netdev=dewy.ru
References: <20261112-v6-7-topic-virtio-net-ptp-v5-7-7ab67b572f4f@pengutronix.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364395-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v5 7/9] vhost-net: support VIRTIO_NET_F_RX_TSTAMP
Date: Mon, 16 Nov 2026 13:55:07 +0000
Organization: Usenet Network
Message-ID: <179483730723.3136.9748134612882994107@kernel.org>
References: <20261112-v6-7-topic-virtio-net-ptp-v5-7-7ab67b572f4f@pengutronix.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2079270"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:PMnHQWpQ3yA+v2xZVDyOBfgzr44= sha256:FEpSW4HJEocUGL5fZuLfvSQMqlspe564Xqignfyk/DI=
	sha1:3fO57mad0eIj8708KTE5o2N9YjA= sha256:+CRCc8wYA/Xz2wfadCjE5J7kEUaYJ7AnLEy7r/EqY48=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 9B9C3114C55; Mon, 16 Nov 2026 16:56:59 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id CSt3Sw8xp_F7;
	Mon, 16 Nov 2026 16:56:55 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-364395-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id A5501114C54; Mon, 16 Nov 2026 16:56:47 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id BF5CF30873; Mon, 16 Nov 2026 13:56:17 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794837310;
	b=BmN5FUfaarQCVqZkNsa3UeQ5XltY185OcN7pgVNdDf6HApEgg3W9jK1Pa4sQiRsTCj4G
	 kL4tRz6VffUjy5xGyRWJNysOdvT1wBKjNICWIUGty5d0S/i6zzgkrB4il4+WDwAgHvR8J
	 b0O3hiIa+RGtZDP8A3AL1s/5ci8YP94gBc0xgYkFdeLoSgEa4uh6YgDOo1AuKd0Dcv5iZ
	 1tvPV1I8O+1rGg2ZcryQTRjGTIRf6XLundt27+gKsRVEdyVrT9iXz5+eA1sux2eubvimp
	 z3OpSf5pb6EexXn5nCJIX+0FaWIqB5Tbe7qs35ev/Oi8mEUz403w7EhzBAy7BIvp66w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794837310;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=tfjYQFYpkytc82LeFrqvPRD/cCN3o6h7XjL0XvsdNrM=;
	b=zKokO99PckWwZCFmVeCQZzHq/CiBm1oW3nzPCkGfVfp0O7GGSH5KZ6l3+Nh46pTtbzPF
	 ssiiYT8u/7igZ1pG3Tw7ibSmxtpKqeuqfoIoG+vld1x2vXN8e0EU+L4RsqGTHZ4eBWxhP
	 OvQ0QwZxHU/sNGbEWcNGX24q2cOjYZ+XQcOlbeo9R98qdGt1B1aYDfrVM5A+3DVjt7gJq
	 TFV2jjOfI97pPaWM8lVMtJBi7rAAQtEJTqDms13OvAnJ+mW1oyQ020eoGi5Ui2a9kHmgr
	 86EwFjmwaYns8QS3sFcy2QuyFcaZW4CyCQnXNuk79mPicR+DVmgZHweJ9O7N4Ud6tsw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XgA8Abrt;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 69D47606A332;
	Mon, 16 Nov 2026 13:55:10 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XgA8Abrt
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794837309;
	b=eqHvUpRop4NL/S9JUNUNG/4UY7nYNPNwzJxjXO6UClTXHwHxHmH/pxu0ctv/vmlblyxO
	 se/xbyLze50QV7htEmr2fCjYMuCtIDdtTER38RQXQq9Wzv/22AbYyoC8S//vY+zB4wpo5
	 /rF+4Tf5OKpjR2hqj3f7PzsaNzu2Tm/ChCnfOJZscdRpv/pT9Yrwod24x0UJyW9XH5SY1
	 6hKSlypKyb9il6DTPDYLZ78ZQriqsueMACd3DSpkOpPMCyZ4JbieWQ8f6PanRPfBJ5P6m
	 jA6tE42DC9SdSlt7azBUSl7MRx7zwbj0XmhAZAS/EycitUn+idzdTr0CSUfEuQieNQg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794837309;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=tfjYQFYpkytc82LeFrqvPRD/cCN3o6h7XjL0XvsdNrM=;
	b=TM8lFRLT7RObRuL++SnSOXM1k6OUzNgUS6kBA/i+Fb6P07TxBz59j4IBRalvExlZWCub
	 HXzd976PURbQoHBBF6pqJwc03NC+TmmcmHjEOmftEbY/DklQWhMO/4uzwCwRsHEby+Ciw
	 X55TvUCEhzOzOSD+xWYlqSSH/JHoVB3jVPJN1O+k0oOQczfCHEr4EipXKFnMdHLSVGocP
	 Cdw2buLM0hxptYlWSgowUnCtXTvIpLAaZPSSB423DTLqevIEhEvCG1iFYXbwBRJ4ZT6cW
	 mh4tmoAXpq96DshRX7xw7hU9Qf/6d+PScSL19fPjCcqvQgFSyhFnsTFdCUXHpJDj0UA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XgA8Abrt;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A495606A881;
	Mon, 16 Nov 2026 13:55:09 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADDD01F000C5;
	Mon, 16 Nov 2026 13:55:07 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794837309;
	bh=tfjYQFYpkytc82LeFrqvPRD/cCN3o6h7XjL0XvsdNrM=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=XgA8AbrtFprnJjQ4xMBE9KanjGxZZnKS8nxLy8/IO17rz0H2AE/r2U6CfimAiaurg
	 ULRsQNORS31dlX1CrjlprKEMbMjnGyxiSXMMQJM3sDsYdLxUlKQ5PKwQ8YRrwHpaxB
	 WpCxO2GfmqwSy+L21LQj6+WoyxhK0ksk1d/8ByXeKZ5FubJPu/Lm5zyTVMpmDsbGet
	 YATKQ8OcIPA9ZkpxZBP5o/n70oaL9vcBV+8leiKIcZcso0Qh3ZvtLS5AKPts5I7eQ3
	 RTFU63kcmsyR3zMi8v0YbnwChX410rFhosDpZSUZEqdY7YeIgMTwQsO7qz94s+uPXk
	 6D+MURG1+KP5A==
X-Cc: mst@redhat.com, xuanzhuo@linux.alibaba.com, davem@davemloft.net,
 kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com,
 willemdebruijn.kernel@gmail.com, andrew+netdev@lunn.ch, eperezma@redhat.com,
 jasowangio@gmail.com, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org,
 john.fastabend@gmail.com, sdf@fomichev.me, edumazet@kernel.org,
 andrew@lunn.ch, horms@kernel.org, kory.maincent@bootlin.com,
 liangchen.linux@gmail.com, hengqi@linux.alibaba.com,
 virtualization@lists.linux.dev, netdev@vger.kernel.org,
 linux-kernel@vger.kernel.org, bpf@vger.kernel.org, kvm@vger.kernel.org,
 kernel@pengutronix.de
X-In-Reply-To: <20261112-v6-7-topic-virtio-net-ptp-v5-7-7ab67b572f4f@pengutronix.de>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list