History

vsock: Enable y2038 safe timeval for timeout

Reuse the timeval compat code from core/sock to handle 32-bit and 64-bit timeval structures. Also introduce a new socket option define to allow using y2038 safe timeval under 32-bit. The existing behavior of sock_set_timeout and vsock's timeout setter differ when the time value is out of bounds. vsocks current behavior is retained at the expense of not being able to share the full implementation. This allows the LTP test vsock01 to pass under 32-bit compat mode.

Richard Palethorpe committed 5 years ago

Commit 4c1e34c1 parent 685c3f24 files · +55 −22Browse files

Showing the changes to include/uapi (1 of 4 files). Show all

Unified · Split

include/uapi/linux/vm_sockets.h+12−1
@@ -64,7 +64,7 @@ · 63 unmodified lines
64 * timeout for a STREAM socket.64 * timeout for a STREAM socket.
65 */65 */
66 66
67#define SO_VM_SOCKETS_CONNECT_TIMEOUT 667#define SO_VM_SOCKETS_CONNECT_TIMEOUT_OLD 6
68 68
69/* Option name for using non-blocking send/receive. Use as the option name69/* Option name for using non-blocking send/receive. Use as the option name
70 * for setsockopt(3) or getsockopt(3) to set or get the non-blocking70 * for setsockopt(3) or getsockopt(3) to set or get the non-blocking
@@ -81,6 +81,17 @@ · 10 unmodified lines
81 81
82#define SO_VM_SOCKETS_NONBLOCK_TXRX 782#define SO_VM_SOCKETS_NONBLOCK_TXRX 7
83 83
84#define SO_VM_SOCKETS_CONNECT_TIMEOUT_NEW 8
85
86#if !defined(__KERNEL__)
87#if __BITS_PER_LONG == 64 || (defined(__x86_64__) && defined(__ILP32__))
88#define SO_VM_SOCKETS_CONNECT_TIMEOUT SO_VM_SOCKETS_CONNECT_TIMEOUT_OLD
89#else
90#define SO_VM_SOCKETS_CONNECT_TIMEOUT \
91 (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_VM_SOCKETS_CONNECT_TIMEOUT_OLD : SO_VM_SOCKETS_CONNECT_TIMEOUT_NEW)
92#endif
93#endif
94
84/* The vSocket equivalent of INADDR_ANY. This works for the svm_cid field of95/* The vSocket equivalent of INADDR_ANY. This works for the svm_cid field of
85 * sockaddr_vm and indicates the context ID of the current endpoint.96 * sockaddr_vm and indicates the context ID of the current endpoint.
86 */97 */