| [chrony-dev] [PATCH v2] socket: ignore zero if_index in timestamping pktinfo |
[ Thread Index |
Date Index
| More chrony.tuxfamily.org/chrony-dev Archives
]
- To: chrony-dev@xxxxxxxxxxxxxxxxxxxx
- Subject: [chrony-dev] [PATCH v2] socket: ignore zero if_index in timestamping pktinfo
- From: JR Lanteigne <root@xxxxxxxx>
- Date: Mon, 24 Aug 2026 07:24:38 -0300
- Cc: Miroslav Lichvar <mlichvar@xxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dnim.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1787567079; x=1787653479; bh=fBZqG1J+Qgo/fA29LCQVDDZC7chVuE3q1KX4GtsRuak=; b= SlN77+6Lx5BmB7nIoYmydJGqRuxwmNBrREwYNiOPDoT4Mc6LM6wM+MwMYHn7qxim i0BwY8+TJB0US1d9CUMdg5bDCKz10PVEnY+hHw0eTXNNqhgxFxYKopgNyesa9cyz Og9/+aalAcZb0t0GK3Ni6M5As0atNhLCCOE7IUZv3roKsCReWDvXaA6Q5vE2ReOr CgAbjJhRuVlND+xyPLv9d9564xMyfxIF014y6oMbBfMVzZd6Pln034TjTBVkEhID XiKvFt6BGsHYNE5bQprCVJNavRWpmFXXC6daQvsrrzFBLcpmEP7yFj9zbdNQDEM0 KHK1W2y3C9r9eOZOKdpisw==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1787567079; x= 1787653479; bh=fBZqG1J+Qgo/fA29LCQVDDZC7chVuE3q1KX4GtsRuak=; b=j QqDqicox4yjaDmdel7fmION0I48dNYD2r9nJXtcuDV1lsTLIOaAYA2fDVR18NbqN 35a6ubnA9+F9wO6ft7D8BUklL4w84FfDpjc90Pxeje/+xVH2oKTmVeNhsR6SaRus ypJFAyMO4xh3vRL+F3xtewMgkM/ajneeRPAo/q5e0d2tRLE5ILgryZ7HZ6QCUDrw ztWlIIXHDeIaQqjMoZBQMHZiql6hkHT4AJG0w5CuHU5uktZ3batlI2cwGW/Z0ccD HBoiXpDtpOi7E8f7JpS6O3HyghgZcdznAxCqRIrwAAloIhuMkRmdS8lYg0GWrOUj 6C/87HysuF2IGSxKmO1Sg==
- 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. Ignore it when extracting the
control messages, so the timestamping if_index keeps its
INVALID_IF_INDEX initialization and the existing fallback to the
if_index of the message itself applies.
---
v2: moved the check from ntp_io_linux.c to the control message
extraction in socket.c, as suggested.
socket.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/socket.c b/socket.c
index e217e31..000e62e 100644
--- a/socket.c
+++ b/socket.c
@@ -997,7 +997,8 @@ process_header(struct msghdr *msg, int msg_length, int sock_fd, int flags,
struct scm_ts_pktinfo ts_pktinfo;
memcpy(&ts_pktinfo, CMSG_DATA(cmsg), sizeof (ts_pktinfo));
- message->timestamp.if_index = ts_pktinfo.if_index;
+ if (ts_pktinfo.if_index != 0)
+ message->timestamp.if_index = ts_pktinfo.if_index;
message->timestamp.l2_length = ts_pktinfo.pkt_length;
}
#endif
--
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.