diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2020-09-08 09:08:10 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2021-06-15 10:42:10 -0300 |
commit | 4a30a71401db8844c548ae16809284f7138df02e (patch) | |
tree | 41fcb33b198db84f35a25c61c5747e6f0b40c54e /sysdeps/unix/sysv | |
parent | 13c51549e2077f2f3bf84e8fd0b46d8b0c615912 (diff) | |
download | glibc-4a30a71401db8844c548ae16809284f7138df02e.tar glibc-4a30a71401db8844c548ae16809284f7138df02e.tar.gz glibc-4a30a71401db8844c548ae16809284f7138df02e.tar.bz2 glibc-4a30a71401db8844c548ae16809284f7138df02e.zip |
linux: Add recvvmsg fallback for 64-bit time_t SO_TIMESTAMP{NS}
Handle the SO_TIMESTAMP{NS} similar to recvmsg: for
!__ASSUME_TIME64_SYSCALLS it converts the first 32-bit time SO_TIMESTAMP
or SO_TIMESTAMPNS and appends it to the control buffer if has extra
space or returns MSG_CTRUNC otherwise. The 32-bit time field is kept
as-is.
Also for !__ASSUME_TIME64_SYSCALLS it limits the maximum number of
'struct mmsghdr *' to IOV_MAX (and also increases the stack size
requirement to IOV_MAX times sizeof (socklen_t)). The Linux imposes
a similar limit to sendmmsg, so bound the array size on recvmmsg is not
unreasonable. And this will be used only on older when building with
32-bit time support.
Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
kernel).
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'sysdeps/unix/sysv')
-rw-r--r-- | sysdeps/unix/sysv/linux/recvmmsg.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c index 672ba20332..5cd107ffa9 100644 --- a/sysdeps/unix/sysv/linux/recvmmsg.c +++ b/sysdeps/unix/sysv/linux/recvmmsg.c @@ -44,13 +44,26 @@ __recvmmsg64 (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, ts32 = valid_timespec64_to_timespec (*timeout); pts32 = &ts32; } + + socklen_t csize[IOV_MAX]; + if (vlen > IOV_MAX) + vlen = IOV_MAX; + for (int i = 0; i < vlen; i++) + csize[i] = vmessages[i].msg_hdr.msg_controllen; + # ifdef __ASSUME_RECVMMSG_SYSCALL r = SYSCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, pts32); # else r = SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, pts32); # endif - if (r >= 0 && timeout != NULL) - *timeout = valid_timespec_to_timespec64 (ts32); + if (r >= 0) + { + if (timeout != NULL) + *timeout = valid_timespec_to_timespec64 (ts32); + + for (int i=0; i < r; i++) + __convert_scm_timestamps (&vmessages[i].msg_hdr, csize[i]); + } #endif /* __ASSUME_TIME64_SYSCALLS */ return r; } |