]> git.baikalelectronics.ru Git - kernel.git/commit
net: fix SOF_TIMESTAMPING_BIND_PHC to work with multiple sockets
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 5 Jan 2022 10:33:26 +0000 (11:33 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 6 Jan 2022 12:18:08 +0000 (12:18 +0000)
commite02e896904c7d477b5668f063daa48d50fba24c1
tree219ac440129b5f84954ac55c7dc63d47554f3750
parent39d0fc6c494f2ef37bf3e25f89bf515b0ea51627
net: fix SOF_TIMESTAMPING_BIND_PHC to work with multiple sockets

When multiple sockets using the SOF_TIMESTAMPING_BIND_PHC flag received
a packet with a hardware timestamp (e.g. multiple PTP instances in
different PTP domains using the UDPv4/v6 multicast or L2 transport),
the timestamps received on some sockets were corrupted due to repeated
conversion of the same timestamp (by the same or different vclocks).

Fix ptp_convert_timestamp() to not modify the shared skb timestamp
and return the converted timestamp as a ktime_t instead. If the
conversion fails, return 0 to not confuse the application with
timestamps corresponding to an unexpected PHC.

Fixes: fe495d8097cd ("net: socket: support hardware timestamp conversion to PHC bound")
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Cc: Yangbo Lu <yangbo.lu@nxp.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/ptp/ptp_vclock.c
include/linux/ptp_clock_kernel.h
net/socket.c