| [chrony-dev] [PATCH] ntp: fall back to message if_index if timestamping if_index is 0 |
[ Thread Index |
Date Index
| More chrony.tuxfamily.org/chrony-dev Archives
]
- To: chrony-dev@xxxxxxxxxxxxxxxxxxxx
- Subject: [chrony-dev] [PATCH] ntp: fall back to message if_index if timestamping if_index is 0
- From: JR Lanteigne <root@xxxxxxxx>
- Date: Sun, 23 Aug 2026 01:55:47 -0300
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dnim.dev; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:message-id:mime-version:reply-to:subject :subject:to:to; s=fm3; t=1787460948; x=1787547348; bh=tizI0PefCI dwTwEy83J4OvjBy6rZQW0S/d20xjo953g=; b=S8T56TmUjeR/lghfI8YrVK5qho rmwk+DpfJqIttojqbu2LLlx8SxP7Rf0o9e8ZmQ2wLBdsNVeFQ0R+292uW2/S51As FhCUwX2IJqZAF+6OplrulhfEdHC9tg7z917F0PsFq4UcVuyzTB/JZgz7Mx/ncCkS uXfX8wJjdlKcSkTtzH2zImyEm2y3Ghj8tOoFVjN5RnZoADZgtQWNtdRzMUBnvqwf JC7Vhcw5OHqD1i2wxHGIWX3ApS85XsBTDb4hadlct6W73tkwC8Q0d2gJMJ2qMoMI 3M9nU/j7qPJjZim15d9FVFCSiWZ3a730kR19EnE101u0AOez10BrrYLh66uw==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1787460948; x=1787547348; bh=tizI0PefCIdwTwEy83J4OvjBy6rZQW0S/d2 0xjo953g=; b=XSVPSgBGH+1xotYlvoRU+4vltDAWaW6GsloEh6in8dZlDsDoZUS vv78OrI0a/BTGFg8xYHnJWSPGx/IuhdunTND6cADHz2N2OxV2BbiI5Yh8J3nQmTK KWGoZdwU6TMRCecIbqIafsOONnhMTf34n1PWZLxxPTY2+u7IJi7TwRDsWGAtxrI+ RjxGO4uNV+9SSKwNSRQiIGTWZh1nB987KmTwq1BMrqcxmXXtiie5HL+ekXrkRotP fUXSRNI/QGyt3VNHlZ+nEO42INYh0X9tikWfTRsgJWH4lxA2Wo4SV4BB4lnoCjZ2 Oecb6Dd2PxT29+DjEVaGo4/UCKU1EszlsDA==
- Feedback-id: i14ee4b4c:Fastmail
The kernel fills the if_index of SCM_TIMESTAMPING_PKTINFO from the
napi id of the packet (put_ts_pktinfo() in net/socket.c). Some drivers
keep their napi instances on an internal dummy device (e.g. ti cpsw).
Kernels without CONFIG_NET_RX_BUSY_POLL cannot resolve any napi id.
In both cases the lookup fails and the if_index is 0.
get_interface() then failed. Valid HW timestamps were dropped. The
less accurate kernel timestamps were used instead.
Zero is not a valid interface index. Treat it like a missing
timestamping if_index and use the if_index of the message itself.
---
Seen on a BeagleBone Black (ti cpsw, 6.6-rt kernel). chronyd accepts
hwtimestamp eth0, then logs "HW clock not found for interface 0" for
every packet. Every measurement silently degrades to kernel timestamps
(K in measurements.log).
The fix treats 0 like a missing if_index and uses the message if_index
instead. Zero is never a valid interface index, so nothing valid is
lost. On a bonded interface the message if_index names the bond. The
bond has no HW clock, so the timestamp is dropped there, same as
before this change.
Validated on the affected hardware: measurements.log flips from "K K"
to "H H". Offsets against two GPS-disciplined observers on the same
switch improve from ~100 us of kernel latency noise to under 1 us.
ntp_io_linux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ntp_io_linux.c b/ntp_io_linux.c
index 3144246..ab62d06 100644
--- a/ntp_io_linux.c
+++ b/ntp_io_linux.c
@@ -846,7 +846,7 @@ NIO_Linux_ProcessMessage(SCK_Message *message, NTP_Local_Address *local_addr,
iface = NULL;
ts_if_index = message->timestamp.if_index;
- if (ts_if_index == INVALID_IF_INDEX)
+ if (ts_if_index == INVALID_IF_INDEX || ts_if_index == 0)
ts_if_index = message->if_index;
l2_length = message->timestamp.l2_length;
--
2.43.0
--
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble? Email listmaster@xxxxxxxxxxxxxxxxxxxx.