aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepa Dinamani <deepa.kernel@gmail.com>2019-02-02 10:34:53 -0500
committerDavid S. Miller <davem@davemloft.net>2019-02-03 14:17:31 -0500
commit45bdc66159d49bfc7f75fe02d25bc74f5d2660cf (patch)
treec27075f4ceb91aa226fe4648f1ca507f37b002a6
parent9dd49211b8ca85dfe7ee9054f2695fe790fa0874 (diff)
socket: Rename SO_RCVTIMEO/ SO_SNDTIMEO with _OLD suffixes
SO_RCVTIMEO and SO_SNDTIMEO socket options use struct timeval as the time format. struct timeval is not y2038 safe. The subsequent patches in the series add support for new socket timeout options with _NEW suffix that will use y2038 safe data structures. Although the existing struct timeval layout is sufficiently wide to represent timeouts, because of the way libc will interpret time_t based on user defined flag, these new flags provide a way of having a structure that is the same for all architectures consistently. Rename the existing options with _OLD suffix forms so that the right option is enabled for userspace applications according to the architecture and time_t definition of libc. Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com> Acked-by: Willem de Bruijn <willemb@google.com> Cc: ccaulfie@redhat.com Cc: deller@gmx.de Cc: paulus@samba.org Cc: ralf@linux-mips.org Cc: rth@twiddle.net Cc: cluster-devel@redhat.com Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-alpha@vger.kernel.org Cc: linux-arch@vger.kernel.org Cc: linux-mips@vger.kernel.org Cc: linux-parisc@vger.kernel.org Cc: sparclinux@vger.kernel.org Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--arch/alpha/include/uapi/asm/socket.h7
-rw-r--r--arch/mips/include/uapi/asm/socket.h6
-rw-r--r--arch/parisc/include/uapi/asm/socket.h6
-rw-r--r--arch/powerpc/include/uapi/asm/socket.h4
-rw-r--r--arch/sparc/include/uapi/asm/socket.h7
-rw-r--r--fs/dlm/lowcomms.c4
-rw-r--r--include/uapi/asm-generic/socket.h6
-rw-r--r--net/core/sock.c4
8 files changed, 28 insertions, 16 deletions
diff --git a/arch/alpha/include/uapi/asm/socket.h b/arch/alpha/include/uapi/asm/socket.h
index 934ea6268f1a..9826d1db71d0 100644
--- a/arch/alpha/include/uapi/asm/socket.h
+++ b/arch/alpha/include/uapi/asm/socket.h
@@ -31,8 +31,8 @@
31#define SO_RCVBUFFORCE 0x100b 31#define SO_RCVBUFFORCE 0x100b
32#define SO_RCVLOWAT 0x1010 32#define SO_RCVLOWAT 0x1010
33#define SO_SNDLOWAT 0x1011 33#define SO_SNDLOWAT 0x1011
34#define SO_RCVTIMEO 0x1012 34#define SO_RCVTIMEO_OLD 0x1012
35#define SO_SNDTIMEO 0x1013 35#define SO_SNDTIMEO_OLD 0x1013
36#define SO_ACCEPTCONN 0x1014 36#define SO_ACCEPTCONN 0x1014
37#define SO_PROTOCOL 0x1028 37#define SO_PROTOCOL 0x1028
38#define SO_DOMAIN 0x1029 38#define SO_DOMAIN 0x1029
@@ -121,6 +121,9 @@
121 121
122#if !defined(__KERNEL__) 122#if !defined(__KERNEL__)
123 123
124#define SO_RCVTIMEO SO_RCVTIMEO_OLD
125#define SO_SNDTIMEO SO_SNDTIMEO_OLD
126
124#if __BITS_PER_LONG == 64 127#if __BITS_PER_LONG == 64
125#define SO_TIMESTAMP SO_TIMESTAMP_OLD 128#define SO_TIMESTAMP SO_TIMESTAMP_OLD
126#define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD 129#define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD
diff --git a/arch/mips/include/uapi/asm/socket.h b/arch/mips/include/uapi/asm/socket.h
index 110f9506d64f..96cc0e907f12 100644
--- a/arch/mips/include/uapi/asm/socket.h
+++ b/arch/mips/include/uapi/asm/socket.h
@@ -39,8 +39,8 @@
39#define SO_RCVBUF 0x1002 /* Receive buffer. */ 39#define SO_RCVBUF 0x1002 /* Receive buffer. */
40#define SO_SNDLOWAT 0x1003 /* send low-water mark */ 40#define SO_SNDLOWAT 0x1003 /* send low-water mark */
41#define SO_RCVLOWAT 0x1004 /* receive low-water mark */ 41#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
42#define SO_SNDTIMEO 0x1005 /* send timeout */ 42#define SO_SNDTIMEO_OLD 0x1005 /* send timeout */
43#define SO_RCVTIMEO 0x1006 /* receive timeout */ 43#define SO_RCVTIMEO_OLD 0x1006 /* receive timeout */
44#define SO_ACCEPTCONN 0x1009 44#define SO_ACCEPTCONN 0x1009
45#define SO_PROTOCOL 0x1028 /* protocol type */ 45#define SO_PROTOCOL 0x1028 /* protocol type */
46#define SO_DOMAIN 0x1029 /* domain/socket family */ 46#define SO_DOMAIN 0x1029 /* domain/socket family */
@@ -132,6 +132,8 @@
132 132
133#if !defined(__KERNEL__) 133#if !defined(__KERNEL__)
134 134
135#define SO_RCVTIMEO SO_RCVTIMEO_OLD
136#define SO_SNDTIMEO SO_SNDTIMEO_OLD
135#if __BITS_PER_LONG == 64 137#if __BITS_PER_LONG == 64
136#define SO_TIMESTAMP SO_TIMESTAMP_OLD 138#define SO_TIMESTAMP SO_TIMESTAMP_OLD
137#define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD 139#define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD
diff --git a/arch/parisc/include/uapi/asm/socket.h b/arch/parisc/include/uapi/asm/socket.h
index bee2a9dde656..046f0cd9cce4 100644
--- a/arch/parisc/include/uapi/asm/socket.h
+++ b/arch/parisc/include/uapi/asm/socket.h
@@ -22,8 +22,8 @@
22#define SO_RCVBUFFORCE 0x100b 22#define SO_RCVBUFFORCE 0x100b
23#define SO_SNDLOWAT 0x1003 23#define SO_SNDLOWAT 0x1003
24#define SO_RCVLOWAT 0x1004 24#define SO_RCVLOWAT 0x1004
25#define SO_SNDTIMEO 0x1005 25#define SO_SNDTIMEO_OLD 0x1005
26#define SO_RCVTIMEO 0x1006 26#define SO_RCVTIMEO_OLD 0x1006
27#define SO_ERROR 0x1007 27#define SO_ERROR 0x1007
28#define SO_TYPE 0x1008 28#define SO_TYPE 0x1008
29#define SO_PROTOCOL 0x1028 29#define SO_PROTOCOL 0x1028
@@ -113,6 +113,8 @@
113 113
114#if !defined(__KERNEL__) 114#if !defined(__KERNEL__)
115 115
116#define SO_RCVTIMEO SO_RCVTIMEO_OLD
117#define SO_SNDTIMEO SO_SNDTIMEO_OLD
116#if __BITS_PER_LONG == 64 118#if __BITS_PER_LONG == 64
117#define SO_TIMESTAMP SO_TIMESTAMP_OLD 119#define SO_TIMESTAMP SO_TIMESTAMP_OLD
118#define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD 120#define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD
diff --git a/arch/powerpc/include/uapi/asm/socket.h b/arch/powerpc/include/uapi/asm/socket.h
index 94de465e0920..12aa0c43e775 100644
--- a/arch/powerpc/include/uapi/asm/socket.h
+++ b/arch/powerpc/include/uapi/asm/socket.h
@@ -11,8 +11,8 @@
11 11
12#define SO_RCVLOWAT 16 12#define SO_RCVLOWAT 16
13#define SO_SNDLOWAT 17 13#define SO_SNDLOWAT 17
14#define SO_RCVTIMEO 18 14#define SO_RCVTIMEO_OLD 18
15#define SO_SNDTIMEO 19 15#define SO_SNDTIMEO_OLD 19
16#define SO_PASSCRED 20 16#define SO_PASSCRED 20
17#define SO_PEERCRED 21 17#define SO_PEERCRED 21
18 18
diff --git a/arch/sparc/include/uapi/asm/socket.h b/arch/sparc/include/uapi/asm/socket.h
index 2b38dda51426..342ffdc3b424 100644
--- a/arch/sparc/include/uapi/asm/socket.h
+++ b/arch/sparc/include/uapi/asm/socket.h
@@ -21,8 +21,8 @@
21#define SO_BSDCOMPAT 0x0400 21#define SO_BSDCOMPAT 0x0400
22#define SO_RCVLOWAT 0x0800 22#define SO_RCVLOWAT 0x0800
23#define SO_SNDLOWAT 0x1000 23#define SO_SNDLOWAT 0x1000
24#define SO_RCVTIMEO 0x2000 24#define SO_RCVTIMEO_OLD 0x2000
25#define SO_SNDTIMEO 0x4000 25#define SO_SNDTIMEO_OLD 0x4000
26#define SO_ACCEPTCONN 0x8000 26#define SO_ACCEPTCONN 0x8000
27 27
28#define SO_SNDBUF 0x1001 28#define SO_SNDBUF 0x1001
@@ -114,6 +114,9 @@
114 114
115#if !defined(__KERNEL__) 115#if !defined(__KERNEL__)
116 116
117#define SO_RCVTIMEO SO_RCVTIMEO_OLD
118#define SO_SNDTIMEO SO_SNDTIMEO_OLD
119
117#if __BITS_PER_LONG == 64 120#if __BITS_PER_LONG == 64
118#define SO_TIMESTAMP SO_TIMESTAMP_OLD 121#define SO_TIMESTAMP SO_TIMESTAMP_OLD
119#define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD 122#define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 76976d6e50f9..c98ad9777ad9 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -1089,12 +1089,12 @@ static void sctp_connect_to_sock(struct connection *con)
1089 * since O_NONBLOCK argument in connect() function does not work here, 1089 * since O_NONBLOCK argument in connect() function does not work here,
1090 * then, we should restore the default value of this attribute. 1090 * then, we should restore the default value of this attribute.
1091 */ 1091 */
1092 kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, 1092 kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO_OLD, (char *)&tv,
1093 sizeof(tv)); 1093 sizeof(tv));
1094 result = sock->ops->connect(sock, (struct sockaddr *)&daddr, addr_len, 1094 result = sock->ops->connect(sock, (struct sockaddr *)&daddr, addr_len,
1095 0); 1095 0);
1096 memset(&tv, 0, sizeof(tv)); 1096 memset(&tv, 0, sizeof(tv));
1097 kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, 1097 kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO_OLD, (char *)&tv,
1098 sizeof(tv)); 1098 sizeof(tv));
1099 1099
1100 if (result == -EINPROGRESS) 1100 if (result == -EINPROGRESS)
diff --git a/include/uapi/asm-generic/socket.h b/include/uapi/asm-generic/socket.h
index 2713e0fa68ef..c56b8b487c12 100644
--- a/include/uapi/asm-generic/socket.h
+++ b/include/uapi/asm-generic/socket.h
@@ -30,8 +30,8 @@
30#define SO_PEERCRED 17 30#define SO_PEERCRED 17
31#define SO_RCVLOWAT 18 31#define SO_RCVLOWAT 18
32#define SO_SNDLOWAT 19 32#define SO_SNDLOWAT 19
33#define SO_RCVTIMEO 20 33#define SO_RCVTIMEO_OLD 20
34#define SO_SNDTIMEO 21 34#define SO_SNDTIMEO_OLD 21
35#endif 35#endif
36 36
37/* Security levels - as per NRL IPv6 - don't actually do anything */ 37/* Security levels - as per NRL IPv6 - don't actually do anything */
@@ -116,6 +116,8 @@
116 116
117#if !defined(__KERNEL__) 117#if !defined(__KERNEL__)
118 118
119#define SO_RCVTIMEO SO_RCVTIMEO_OLD
120#define SO_SNDTIMEO SO_SNDTIMEO_OLD
119#if __BITS_PER_LONG == 64 || (defined(__x86_64__) && defined(__ILP32__)) 121#if __BITS_PER_LONG == 64 || (defined(__x86_64__) && defined(__ILP32__))
120/* on 64-bit and x32, avoid the ?: operator */ 122/* on 64-bit and x32, avoid the ?: operator */
121#define SO_TIMESTAMP SO_TIMESTAMP_OLD 123#define SO_TIMESTAMP SO_TIMESTAMP_OLD
diff --git a/net/core/sock.c b/net/core/sock.c
index a9d1ecce96e5..27b40002b780 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -941,11 +941,11 @@ set_rcvbuf:
941 sk->sk_rcvlowat = val ? : 1; 941 sk->sk_rcvlowat = val ? : 1;
942 break; 942 break;
943 943
944 case SO_RCVTIMEO: 944 case SO_RCVTIMEO_OLD:
945 ret = sock_set_timeout(&sk->sk_rcvtimeo, optval, optlen); 945 ret = sock_set_timeout(&sk->sk_rcvtimeo, optval, optlen);
946 break; 946 break;
947 947
948 case SO_SNDTIMEO: 948 case SO_SNDTIMEO_OLD:
949 ret = sock_set_timeout(&sk->sk_sndtimeo, optval, optlen); 949 ret = sock_set_timeout(&sk->sk_sndtimeo, optval, optlen);
950 break; 950 break;