🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #3763

[PATCH net v4 5/5] ptp: vclock: preserve missing hardware timestamps

#3763
From: James Hilliard
Date: Thu, 15 Oct 2026 23:33
50 lines
10103 bytes
Socket timestamp delivery converts hardware timestamps to a bound
virtual clock before checking whether a hardware timestamp is present.
A zero timestamp means that the packet has no hardware timestamp, but
timecounter_cyc2time() can turn that zero into a nonzero virtual time.
The socket then reports a hardware timestamp which was never supplied.

Return zero without conversion when the input timestamp is absent.
This also covers skb_get_tx_timestamp(), which checks for an absent
timestamp after the same conversion.

This was identified during review of virtual clock sampling changes.

Fixes: d7c088265588 ("net: socket: support hardware timestamp conversion to PHC bound")
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
 drivers/ptp/ptp_vclock.c         | 2 ++
 include/linux/ptp_clock_kernel.h | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/ptp/ptp_vclock.c b/drivers/ptp/ptp_vclock.c
index 88161be5eabc..39c3276ded77 100644
--- a/drivers/ptp/ptp_vclock.c
+++ b/drivers/ptp/ptp_vclock.c
@@ -312,6 +312,8 @@ ktime_t ptp_convert_timestamp(const ktime_t *hwtstamp, int vclock_index)
 	u64 ns;
 
 	ns = ktime_to_ns(*hwtstamp);
+	if (!ns)
+		return 0;
 
 	srcu_idx = srcu_read_lock(&vclock_srcu);
 
diff --git a/include/linux/ptp_clock_kernel.h b/include/linux/ptp_clock_kernel.h
index 36a27a910595..56f6ab1855d3 100644
--- a/include/linux/ptp_clock_kernel.h
+++ b/include/linux/ptp_clock_kernel.h
@@ -496,7 +496,7 @@ int ptp_get_vclocks_index(int pclock_index, int **vclock_index);
  * @hwtstamp:     timestamp
  * @vclock_index: phc index of ptp vclock.
  *
- * Returns: converted timestamp, or 0 on error.
+ * Returns: converted timestamp, or 0 if @hwtstamp is zero or on error.
  */
 ktime_t ptp_convert_timestamp(const ktime_t *hwtstamp, int vclock_index);
 #else

-- 
2.53.0
Technical Details
Message-ID: <20261015-ptp-vclock-sampling-v4-5-cba6ffc8ceb6@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-346977-linux-kernel-netdev=dewy.ru
References: <20261015-ptp-vclock-sampling-v4-0-cba6ffc8ceb6@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-346977-linux-kernel-netdev=dewy.ru
From: james.hilliard1@gmail.com (James Hilliard)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v4 5/5] ptp: vclock: preserve missing hardware
 timestamps
Date: Thu, 15 Oct 2026 17:33:35 -0600
Organization: Usenet Network
Message-ID: <20261015-ptp-vclock-sampling-v4-5-cba6ffc8ceb6@gmail.com>
References: <20261015-ptp-vclock-sampling-v4-0-cba6ffc8ceb6@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="2645758"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:CxS6zJV8zy9GDx6Cs4rTxGlaFSc= sha256:rpsrs6EukYzewUu8v1z4LMQL1bBGkdbT9G6Zn0em+js=
	sha1:53eykVG91bpFLMhp7qQ09kZX/fk= sha256:TkLY8F00x+nPemMcLFYkvKcBS+F+2291AoXOpB4UHnU=
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 245D71103F2; Fri, 16 Oct 2026 02:36:13 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -0.748
X-Spam-Status: No, score=-0.748 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	MAILING_LIST_MULTI=-1, 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=gmail.com
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 k-Y2i9HtNAHa;
	Fri, 16 Oct 2026 02:36:11 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-346977-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 9825C11001D; Fri, 16 Oct 2026 02:36:02 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sea.lore.kernel.org (Postfix) with ESMTP id CC50842C7B; Thu, 15 Oct 2026 23:33:50 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id AD0DE4A1DE4;
	Thu, 15 Oct 2026 23:33:50 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KLrDUoUW"
X-Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.48])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FD0A3F410D
	for <netdev@vger.kernel.org>; Thu, 15 Oct 2026 23:33:47 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.48
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1792107230; cv=none; b=m9Ia3wcMaiebb18bEZzw+yOYCP1hAf8KkN4PepaFWozEAWgO6bYn8Ydd9J4hzhlo2MyR7KQPgtZcdu/qm/Dbd6YO3mM1JT1m15wIg6TfOTpZ9U0UDPwXphLiIrj0Ve1CQvjnMDX1GmcTRnPgBkqdvQldIXLE10ag4kC8IpfT4T8=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1792107230; c=relaxed/simple;
	bh=BSZQsz4AaktraRMPo+kte0Fmcp27FfRs07kAnpmG6i4=;
	h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References:
	 In-Reply-To:To:Cc; b=It6mDIQsuGIgmIRn56WsoIJ29SdsObAelp48D6DllU/7nBoE3+t7vw+yTMVy+h031U3LAXf/UqgunBN34JgcYJrOWmeV7W8UNUrqusDcxswPv6YE2UfT8/zu+d+7ZAFjeZBSiP0sLCVYB1oCLQuSL9tunaCSaVshS6XIPLIbvRI=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KLrDUoUW; arc=none smtp.client-ip=209.85.161.48
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-6f8a519e215so480200eaf.1
        for <netdev@vger.kernel.org>; Thu, 15 Oct 2026 16:33:47 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1792107226; x=1792712026; darn=vger.kernel.org;
        h=cc:to:in-reply-to:references:message-id:content-transfer-encoding
         :content-type:mime-version:subject:date:from:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=8FV6Q2SmXqF6b78Av68WgjEHjZ+64cqPVR4bTm+D2U4=;
        b=KLrDUoUW5UT88MtsY54o7EK8IOXjZdJzjSN3Homu0icuHQkEZkepFPcG++9YNAYd3E
         j89y2OU8i74DE+SEVCSUxtOJS/VDHAHw0buG30mUS/MuydKr47LZ7rSoIKH+NelwOxOH
         vzw4UH+RKmpdzMdHJ35aOkYnCfJg8KvCqbZ2zhq2G7X3zfxGAJsy0l36XEipM5Wao8d0
         +UlQjaAlRxmr5s6duDEoDPhdTB++3J9mvNIkwOYiN+AiJdL65nK34eeR8v4yMbPtoqQW
         w9kpMXRQYQSIjZgt1+10KIlQP459WU7S/qc+6zNL3hmMdG9paofiW5uwIOJXDmzP+d4w
         9gaw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1792107226; x=1792712026;
        h=cc:to:in-reply-to:references:message-id:content-transfer-encoding
         :content-type:mime-version:subject:date:from:x-gm-gg
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=8FV6Q2SmXqF6b78Av68WgjEHjZ+64cqPVR4bTm+D2U4=;
        b=YuqL2DKseysu6HzYWCqyS3x6/VfObDA9whEu+ef6wQZWmJe92Lzw55TWxYiz67X+Jl
         O6GKu5NRMhrPFLFjmf8QjYC1vv1/b+WgH5ols0pg5sflzZLcaNdF9dkdwIoK18sLsMOE
         tLvDQv1g6lyfpRv1gHPPmRN+vCzs8FRxJKALma3c4hlY1Qk1VSOSE4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bc7-7010c368679mr753319eaf.1.1792107226429;
        Thu, 15 Oct 2026 16:33:46 -0700 (PDT)
X-Received: from [127.0.1.1] (174-29-1-49.hlrn.qwest.net. [174.29.1.49])
        by smtp.gmail.com with ESMTPSA id 006d021491bc7-70188bd9ecdsm525519eaf.2.2026.10.15.16.33.45
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 15 Oct 2026 16:33:45 -0700 (PDT)
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-In-Reply-To: <20261015-ptp-vclock-sampling-v4-0-cba6ffc8ceb6@gmail.com>
X-Cc: Eric Dumazet <edumazet@kernel.org>, 
 "David S. Miller" <davem@davemloft.net>, linux-kernel@vger.kernel.org, 
 Vadim Fedorenko <vadim.fedorenko@linux.dev>, 
 James Hilliard <james.hilliard1@gmail.com>
X-Mailer: b4 0.15.2