From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.zx2c4.com (lists.zx2c4.com [165.227.139.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 003F8C61DC6 for ; Thu, 27 Aug 2026 13:36:28 +0000 (UTC) Received: by lists.zx2c4.com (OpenSMTPD) with ESMTP id b4a98a1d; Thu, 27 Aug 2026 13:35:52 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by lists.zx2c4.com (OpenSMTPD) with ESMTPS id 65123cdf (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Thu, 27 Aug 2026 13:35:48 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 3BB3A40693; Thu, 27 Aug 2026 13:35:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10D3E1F00ACA; Thu, 27 Aug 2026 13:35:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1787837739; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=yuRBr7NNsy1QcjiJOCE3QJ91c/zgrK86l/zJYhNe9Sg=; b=mr+M29FgzvxVykz3RmfI15QjTH+ctTJTkVyxyzBHjuGH3Fw6BG5o+/Cwc//j7NDkQPDItw HuJzfEpcz3cibyvNX5pbvdxo8MK4mv4b4KfNUU4J7Vvl3k08X97M+Ys9SMzVE/zoUDbdPr KjsvHJU1IgHPXiElHRu4GbjOFjJKqdE= Received: by mail.zx2c4.com (OpenSMTPD) with ESMTPSA id 65acf2cf (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 27 Aug 2026 13:35:39 +0000 (UTC) Date: Thu, 27 Aug 2026 15:35:33 +0200 From: "Jason A. Donenfeld" To: ramses@well-founded.dev Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Martin KaFai Lau , wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net] wireguard: queueing: preserve tstamp_type in wg_reset_packet() Message-ID: References: <20260827-wg-tstamp-v1-1-4acfebb855ef@well-founded.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20260827-wg-tstamp-v1-1-4acfebb855ef@well-founded.dev> X-BeenThere: wireguard@lists.zx2c4.com X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: Development discussion of WireGuard List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: wireguard-bounces@lists.zx2c4.com Sender: "WireGuard" On Thu, Aug 27, 2026 at 01:52:56PM +0200, Ramses de Norre via B4 Relay wrote: > From: Ramses de Norre > > Sending traffic through a wireguard tunnel on a host using the fq > qdisc fills the log with: > > fq: likely mono tstamp with tstamp_type 0 > > An skb carries a timestamp in skb->tstamp and, separately, a > skb->tstamp_type field recording which clock that timestamp came from. > The two have to agree. > > When wireguard encapsulates a packet it calls wg_reset_packet(), which > clears the fields that must not leak from the inner packet into the > tunnel packet. It does so in two steps: > > skb_scrub_packet(skb, true); > memset(&skb->headers, 0, sizeof(skb->headers)); > > skb_scrub_packet() deliberately keeps skb->tstamp when it holds a > monotonic timestamp: that value is the time the packet is scheduled to > be sent, and the qdisc still needs it. The memset then zeroes > skb->tstamp_type, because that field sits inside the headers group > while skb->tstamp does not. The packet therefore leaves wireguard > carrying a monotonic timestamp labelled as a realtime one. > > Nothing noticed until commit c4f796c4f16b ("net_sched: sch_fq: convert > skb->tstamp if not monotonic"): fq used to assume every timestamp was > monotonic. It now consults tstamp_type, spots the mismatch, warns, and > falls back to treating the value as monotonic. Pacing still ends up > correct, so the log spam is the actual problem. > > Save tstamp_type before the memset and restore it when encapsulating, > next to the hash fields that are already carried over this way. When > decapsulating it stays zeroed, which is right: an incoming packet's > timestamp is a realtime receive timestamp. > > Fixes: de799101519a ("net: Add skb_clear_tstamp() to keep the mono delivery_time") > Signed-off-by: Ramses de Norre > --- > drivers/net/wireguard/queueing.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/net/wireguard/queueing.h b/drivers/net/wireguard/queueing.h > index 79b6d70de236b..663b19b783953 100644 > --- a/drivers/net/wireguard/queueing.h > +++ b/drivers/net/wireguard/queueing.h > @@ -78,12 +78,14 @@ static inline void wg_reset_packet(struct sk_buff *skb, bool encapsulating) > u8 l4_hash = skb->l4_hash; > u8 sw_hash = skb->sw_hash; > u32 hash = skb->hash; > + u8 tstamp_type = skb->tstamp_type; > skb_scrub_packet(skb, true); > memset(&skb->headers, 0, sizeof(skb->headers)); > if (encapsulating) { > skb->l4_hash = l4_hash; > skb->sw_hash = sw_hash; > skb->hash = hash; > + skb->tstamp_type = tstamp_type; > } > skb->queue_mapping = 0; > skb->nohdr = 0; Seems reasonable to me. I'll put this through the paces testing and queue it up when I'm back at my laptop on Monday. Jason