| Re: [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: JR Lanteigne <root@xxxxxxxx>
- Subject: Re: [chrony-dev] [PATCH] ntp: fall back to message if_index if timestamping if_index is 0
- From: Miroslav Lichvar <mlichvar@xxxxxxxxxx>
- Date: Mon, 24 Aug 2026 10:05:00 +0200
- Cc: chrony-dev@xxxxxxxxxxxxxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1787558708; 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=3uYGfZoWo07XS8tF/xmJUTafTcDvyuBRDevoo6/+PYM=; b=Z6mqcAoersmg9EqS/j14Kp1uYWHy8jXXgNbbG8cn4/NXnktNndgW3pJAJkzMRb8DaNSERV maHtjHoALudkwMcFjpO1UDKfJfkYS6Ko/GKk4Dq+r80pIEFowLVxLsPHM8DRhx+harhFWE aYCpJZ/hj7+T21Bm80fcOevBomoGQdo=
On Sun, Aug 23, 2026 at 01:55:47AM -0300, JR Lanteigne wrote:
> 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.
> --- 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;
I think a better place to fix this issue is in socket.c. The code
handling SCM_TIMESTAMPING_PKTINFO should check for zero before
assigning to timestamp.if_index, so it keeps the original value of
INVALID_IF_INDEX.
Thanks,
--
Miroslav Lichvar
--
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.