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

From: Vadim Fedorenko

Date: Tue Oct 13 2026 - 17:53:48 EST


On 13/10/2026 20:19, James Hilliard wrote:
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")
Signed-off-by: James Hilliard <james.hilliard1@xxxxxxxxx>
---
drivers/ptp/ptp_vclock.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/ptp/ptp_vclock.c b/drivers/ptp/ptp_vclock.c
index 6675466bc307..4a62047f0ce0 100644
--- a/drivers/ptp/ptp_vclock.c
+++ b/drivers/ptp/ptp_vclock.c
@@ -307,6 +307,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);


Reviewed-by: Vadim Fedorenko <vadim.fedorenko@xxxxxxxxx>