From eee7477515bb9a83b2178d70af35837d661cb35e Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Thu, 25 Jun 2026 22:11:38 +0300 Subject: [PATCH] dump_packet_cmsg -- Allow to receive timestamp data A socket may support receiving timestamps from the kernel (see net/socket.c:__sock_recv_timestamp in the kernel), so simply pass up this data to userspace. Signed-off-by: Cyrill Gorcunov (cherry picked from commit 1ecd757bf23831d1574e1dca0566dbe26e0fcb49) Ahmed Elaidy: - ported as a standalone commit (was previously squashed into the unix-sockets ucred support); only the SOL_SOCKET timestamp handling is kept, the netlink pktinfo part of the original is not ported here. Signed-off-by: Ahmed Elaidy Reviewed-by: Alexander Mikhalitsyn --- criu/sk-queue.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/criu/sk-queue.c b/criu/sk-queue.c index 985459fb8..c5b733bd1 100644 --- a/criu/sk-queue.c +++ b/criu/sk-queue.c @@ -207,14 +207,22 @@ static int dump_packet_cmsg(struct msghdr *mh, SkPacketEntry *pe, int flags) continue; } - if (ch->cmsg_len == CMSG_LEN(sizeof(struct ucred)) && - ch->cmsg_type == SCM_CREDENTIALS && - ch->cmsg_level == SOL_SOCKET) { - struct ucred *ucred = (struct ucred *)CMSG_DATA(ch); + if (ch->cmsg_level == SOL_SOCKET) { + if (ch->cmsg_len == CMSG_LEN(sizeof(struct ucred)) && + ch->cmsg_type == SCM_CREDENTIALS) { + struct ucred *ucred = (struct ucred *)CMSG_DATA(ch); - if (dump_sk_creds(ucred, pe, flags)) - return -1; - continue; + if (dump_sk_creds(ucred, pe, flags)) + return -1; + continue; + } else if (ch->cmsg_type == SCM_TIMESTAMP || + ch->cmsg_type == SCM_TIMESTAMPNS || + ch->cmsg_type == SCM_TIMESTAMPING) { + /* + * Allow to receive timestamps from the kernel. + */ + continue; + } } pr_err("cmsg: len %lu type %d level %d\n",