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 ]


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.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/