]> git.proxmox.com Git - mirror_ubuntu-jammy-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)
committerPaolo Pisati <paolo.pisati@canonical.com>
Fri, 28 Jan 2022 09:59:48 +0000 (10:59 +0100)
commit9f7d49f84bdd4d23a065e7e1b23662cb4d1195a8
tree1b02b755a44511accfba6611691267424859c9bd
parentee7c965c1ee037f27a081d420619a760ed788f7b
net: fix SOF_TIMESTAMPING_BIND_PHC to work with multiple sockets

BugLink: https://bugs.launchpad.net/bugs/1959376
[ Upstream commit 007747a984ea5e895b7d8b056b24ebf431e1e71d ]

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: d7c088265588 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/ptp/ptp_vclock.c
include/linux/ptp_clock_kernel.h
net/socket.c