From 9e91e1c7f50f884876ceef1a45c95acd1c878756 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Tue, 6 Jan 2004 20:17:13 -0800 Subject: [PATCH] [COMPAT]: Handle SO_TIMESTAMP cmsgs. --- net/compat.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/net/compat.c b/net/compat.c index 213402ccc3c5e..a226e128d8beb 100644 --- a/net/compat.c +++ b/net/compat.c @@ -215,15 +215,25 @@ out_free_efault: int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data) { + struct compat_timeval ctv; struct compat_cmsghdr *cm = (struct compat_cmsghdr *) kmsg->msg_control; struct compat_cmsghdr cmhdr; - int cmlen = CMSG_COMPAT_LEN(len); + int cmlen; if(cm == NULL || kmsg->msg_controllen < sizeof(*cm)) { kmsg->msg_flags |= MSG_CTRUNC; return 0; /* XXX: return error? check spec. */ } + if (level == SOL_SOCKET && type == SO_TIMESTAMP) { + struct timeval *tv = (struct timeval *)data; + ctv.tv_sec = tv->tv_sec; + ctv.tv_usec = tv->tv_usec; + data = &ctv; + len = sizeof(struct compat_timeval); + } + + cmlen = CMSG_COMPAT_LEN(len); if(kmsg->msg_controllen < cmlen) { kmsg->msg_flags |= MSG_CTRUNC; cmlen = kmsg->msg_controllen; -- 2.53.0