public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "Albert ARIBAUD (3ADEV)" <albert.aribaud@3adev.fr>
To: libc-alpha@sourceware.org
Cc: "Albert ARIBAUD (3ADEV)" <albert.aribaud@3adev.fr>
Subject: [RFC PATCH 51/52] Y2038: add RPC functions
Date: Fri, 08 Sep 2017 17:49:00 -0000	[thread overview]
Message-ID: <20170908174909.28192-2-albert.aribaud@3adev.fr> (raw)
In-Reply-To: <20170908174909.28192-1-albert.aribaud@3adev.fr>

Three functions in RPC have a struct timeval in their arguments:
pmap_rmtcall, clntudp_create, and clntudp_bufcreate.

Since these struct timeval arguments contain relative timeouts, and
since RPC timeouts can reasonably be expected to be small enough to
still fit in 32-bit representations, the implementations of these
functions just verify that the 64-bit timeout they received can fit
in 32 bits, convert it to 32 bit, and pass it to their 32-bit-time
counterparts.

Signed-off-by: Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>
---
 sunrpc/clnt_udp.c      | 27 +++++++++++++++++++++++++++
 sunrpc/pmap_rmt.c      | 23 +++++++++++++++++++++++
 sunrpc/rpc/clnt.h      | 24 ++++++++++++++++++++++++
 sunrpc/rpc/pmap_clnt.h | 15 +++++++++++++++
 4 files changed, 89 insertions(+)

diff --git a/sunrpc/clnt_udp.c b/sunrpc/clnt_udp.c
index df21e28f64..b02b80e2c4 100644
--- a/sunrpc/clnt_udp.c
+++ b/sunrpc/clnt_udp.c
@@ -644,3 +644,30 @@ clntudp_destroy (CLIENT *cl)
   mem_free ((caddr_t) cu, (sizeof (*cu) + cu->cu_sendsz + cu->cu_recvsz));
   mem_free ((caddr_t) cl, sizeof (CLIENT));
 }
+
+/* 64-bit time versions */
+
+CLIENT *
+__clntudp_create64 (struct sockaddr_in *raddr, u_long program, u_long version,
+		    struct __timeval64 wait, int *sockp)
+{
+  struct timeval wait32;
+  if (wait.tv_sec > INT_MAX)
+  {
+    return NULL;
+  }  
+  return clntudp_create (raddr, program, version, wait32, sockp);
+}
+
+CLIENT *
+__clntudp_bufcreate64 (struct sockaddr_in *raddr, u_long program, u_long version,
+		       struct __timeval64 wait, int *sockp, u_int sendsz,
+		       u_int recvsz)
+{
+  struct timeval wait32;
+  if (wait.tv_sec > INT_MAX)
+  {
+    return NULL;
+  }  
+  return clntudp_bufcreate (raddr, program, version, wait32, sockp, sendsz, recvsz);
+}
diff --git a/sunrpc/pmap_rmt.c b/sunrpc/pmap_rmt.c
index 6d4ed7206c..6dd360edcd 100644
--- a/sunrpc/pmap_rmt.c
+++ b/sunrpc/pmap_rmt.c
@@ -391,3 +391,26 @@ done_broad:
   return stat;
 }
 libc_hidden_nolink_sunrpc (clnt_broadcast, GLIBC_2_0)
+
+/* 64-bit-time version */
+
+/* The 64-bit-time version of pmap_rmtcall.
+ * Only handles 64-bit-time timeouts smaller than 2^^31 seconds.
+ */
+enum clnt_stat
+__pmap_rmtcall_t64 (struct sockaddr_in *addr, u_long prog, u_long vers,
+		    u_long proc, xdrproc_t xdrargs, caddr_t argsp,
+		    xdrproc_t xdrres, caddr_t resp,
+		    struct __timeval64 tout, u_long *port_ptr)
+{
+  struct timeval tout32;
+  if (tout.tv_sec > INT_MAX)
+  {
+    return RPC_SYSTEMERROR;
+  }
+  tout32.tv_sec = tout.tv_sec;
+  tout32.tv_usec = tout.tv_usec;
+  
+  return pmap_rmtcall (addr, prog, vers, proc, xdrargs, argsp, xdrres,
+                       resp, tout32, port_ptr);
+}
diff --git a/sunrpc/rpc/clnt.h b/sunrpc/rpc/clnt.h
index f4d4a941c7..e559242eeb 100644
--- a/sunrpc/rpc/clnt.h
+++ b/sunrpc/rpc/clnt.h
@@ -329,9 +329,33 @@ extern CLIENT *clnttcp_create (struct sockaddr_in *__raddr, u_long __prog,
  *	u_int sendsz;
  *	u_int recvsz;
  */
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern CLIENT * __REDIRECT (clntudp_create,(struct sockaddr_in *__raddr,
+                                            u_long __program,
+					    u_long __version,
+					    struct timeval __wait_resend,
+					    int *__sockp),
+                            __clntudp_create_t64) __THROW;
+# else
+# define clntudp_create __clntudp_create_t64
+# endif
+#endif
 extern CLIENT *clntudp_create (struct sockaddr_in *__raddr, u_long __program,
 			       u_long __version, struct timeval __wait_resend,
 			       int *__sockp) __THROW;
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern CLIENT * __REDIRECT (clntudp_bufcreate,(struct sockaddr_in *__raddr,
+				               u_long __program, u_long __version,
+				               struct __timeval64 __wait_resend,
+					       int *__sockp, u_int __sendsz,
+					       u_int __recvsz),
+                            __clntudp_bufcreate_t64) __THROW;
+# else
+# define clntudp_bufcreate __clntudp_bufcreate_t64
+# endif
+#endif
 extern CLIENT *clntudp_bufcreate (struct sockaddr_in *__raddr,
 				  u_long __program, u_long __version,
 				  struct timeval __wait_resend, int *__sockp,
diff --git a/sunrpc/rpc/pmap_clnt.h b/sunrpc/rpc/pmap_clnt.h
index 1cc94b8fee..70ec89b723 100644
--- a/sunrpc/rpc/pmap_clnt.h
+++ b/sunrpc/rpc/pmap_clnt.h
@@ -71,6 +71,21 @@ extern bool_t pmap_set (const u_long __program, const u_long __vers,
 extern bool_t pmap_unset (const u_long __program, const u_long __vers)
      __THROW;
 extern struct pmaplist *pmap_getmaps (struct sockaddr_in *__address) __THROW;
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern enum clnt_stat __REDIRECT (pmap_rmtcall, (struct sockaddr_in *__addr,
+                                                 const u_long __prog,
+                                                 const u_long __vers,
+                                                 const u_long __proc,
+                                                 xdrproc_t __xdrargs,
+                                                 caddr_t __argsp, xdrproc_t __xdrres,
+                                                 caddr_t __resp, struct timeval __tout,
+                                                 u_long *__port_ptr),
+                                  __pmap_rmtcall_t64) __THROW;
+# else
+# define pmap_rmtcall __pmap_rmtcall_t64
+# endif
+#endif
 extern enum clnt_stat pmap_rmtcall (struct sockaddr_in *__addr,
 				    const u_long __prog,
 				    const u_long __vers,
-- 
2.11.0

  reply	other threads:[~2017-09-08 17:49 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-07 22:42 [RFC PATCH 00/52] Make GLIBC Y2038-proof Albert ARIBAUD (3ADEV)
2017-09-07 22:42 ` [RFC PATCH 01/52] Y2038: add type __time64_t Albert ARIBAUD (3ADEV)
2017-09-07 22:42   ` [RFC PATCH 02/52] Y2038: add function __difftime64 Albert ARIBAUD (3ADEV)
2017-09-07 22:42     ` [RFC PATCH 03/52] Y2038: add functions using struct tm Albert ARIBAUD (3ADEV)
2017-09-07 22:42       ` [RFC PATCH 04/52] Y2038: add function __mktime64 (and timelocal) Albert ARIBAUD (3ADEV)
2017-09-07 22:42         ` [RFC PATCH 05/52] Y2038: add function __timegm64 Albert ARIBAUD (3ADEV)
2017-09-07 22:42           ` [RFC PATCH 06/52] Y2038: add struct __timespec64 Albert ARIBAUD (3ADEV)
2017-09-07 22:42             ` [RFC PATCH 07/52] Y2038: add function __clock_gettime64 Albert ARIBAUD (3ADEV)
2017-09-07 22:43               ` [RFC PATCH 08/52] Y2038: add function __clock_settime64 Albert ARIBAUD (3ADEV)
2017-09-07 22:43                 ` [RFC PATCH 09/52] Y2038: add function __clock_getres64 Albert ARIBAUD (3ADEV)
2017-09-07 22:43                   ` [RFC PATCH 10/52] Y2038: add function __clock_nanosleep64 Albert ARIBAUD (3ADEV)
2017-09-07 22:43                     ` [RFC PATCH 11/52] Y2038: add function __timespec_get64 Albert ARIBAUD (3ADEV)
2017-09-07 22:43                       ` [RFC PATCH 12/52] Y2038: add function __futimens64 Albert ARIBAUD (3ADEV)
2017-09-07 22:43                         ` [RFC PATCH 13/52] Y2038: add function __utimensat64 Albert ARIBAUD (3ADEV)
2017-09-07 22:43                           ` [RFC PATCH 14/52] Y2038: add function __sigtimedwait64 Albert ARIBAUD (3ADEV)
2017-09-07 22:43                             ` [RFC PATCH 15/52] Y2038: add struct __timeval64 Albert ARIBAUD (3ADEV)
2017-09-07 22:43                               ` [RFC PATCH 16/52] Y2038: add function __futimes64 Albert ARIBAUD (3ADEV)
2017-09-07 22:43                                 ` [RFC PATCH 17/52] Y2038: add function __lutimes64 Albert ARIBAUD (3ADEV)
2017-09-07 22:43                                   ` [RFC PATCH 18/52] Y2038: add struct __itimerspec64 Albert ARIBAUD (3ADEV)
2017-09-07 22:43                                     ` [RFC PATCH 19/52] Y2038: add function __timer_gettime64 Albert ARIBAUD (3ADEV)
2017-09-07 22:43                                       ` [RFC PATCH 20/52] Y2038: add function __timer_settime64 Albert ARIBAUD (3ADEV)
2017-09-07 22:43                                         ` [RFC PATCH 21/52] Y2038: add function __timerfd_gettime64 Albert ARIBAUD (3ADEV)
2017-09-07 22:44                                           ` [RFC PATCH 22/52] Y2038: add function __timerfd_settime64 Albert ARIBAUD (3ADEV)
2017-09-07 22:44                                             ` [RFC PATCH 23/52] Y2038: add struct __stat64_t64 Albert ARIBAUD (3ADEV)
2017-09-07 22:44                                               ` [RFC PATCH 24/52] Y2038: add function __fstat64_t64 (and __fxstat64_t64) Albert ARIBAUD (3ADEV)
2017-09-07 22:44                                                 ` [RFC PATCH 25/52] Y2038: add function __stat64_t64 (and __xstat64_t64) Albert ARIBAUD (3ADEV)
2017-09-07 22:44                                                   ` [RFC PATCH 26/52] Y2038: add function __lstat64_t64 (and __lxstat64_t64) Albert ARIBAUD (3ADEV)
2017-09-07 22:44                                                     ` [RFC PATCH 27/52] Y2038: add function __fstatat64_t64 (and __fxstatat_t64) Albert ARIBAUD (3ADEV)
2017-09-07 22:44                                                       ` [RFC PATCH 28/52] Y2038: add function __time_t64 Albert ARIBAUD (3ADEV)
2017-09-07 22:44                                                         ` [RFC PATCH 29/52] Y2038: add function __stime_t64 Albert ARIBAUD (3ADEV)
2017-09-07 22:44                                                           ` [RFC PATCH 30/52] Y2038: add function __utimes_t64 Albert ARIBAUD (3ADEV)
2017-09-07 22:44                                                             ` [RFC PATCH 31/52] Y2038: add function __gettimeofday_t64 Albert ARIBAUD (3ADEV)
2017-09-07 22:44                                                               ` [RFC PATCH 32/52] Y2038: add function __settimeofday_t64 Albert ARIBAUD (3ADEV)
2017-09-07 22:44                                                                 ` [RFC PATCH 33/52] Y2038: add function __mq_timedsend_t64 Albert ARIBAUD (3ADEV)
2017-09-07 22:44                                                                   ` [RFC PATCH 34/52] Y2038: add function __mq_timedreceive_t64 Albert ARIBAUD (3ADEV)
2017-09-07 22:44                                                                     ` [RFC PATCH 35/52] Y2038: add function __msgctl_t64 Albert ARIBAUD (3ADEV)
2017-09-07 22:45                                                                       ` [RFC PATCH 36/52] Y2038: add function __sched_rr_get_interval_t64 Albert ARIBAUD (3ADEV)
2017-09-07 22:45                                                                         ` [RFC PATCH 37/52] Y2038: add function __nanosleep64_t64 Albert ARIBAUD (3ADEV)
2017-09-07 22:45                                                                           ` [RFC PATCH 38/52] Y2038: add function __adjtime_t64 Albert ARIBAUD (3ADEV)
2017-09-07 22:45                                                                             ` [RFC PATCH 39/52] Y2038: add function __utime_t64 Albert ARIBAUD (3ADEV)
2017-09-07 22:45                                                                               ` [RFC PATCH 40/52] Y2038: add struct __itimerval_t64 Albert ARIBAUD (3ADEV)
2017-09-07 22:45                                                                                 ` [RFC PATCH 41/52] Y2038: add function __getitimer_t64 Albert ARIBAUD (3ADEV)
2017-09-07 22:45                                                                                   ` [RFC PATCH 42/52] Y2038: add function __setitimer_t64 Albert ARIBAUD (3ADEV)
2017-09-07 22:45                                                                                     ` [RFC PATCH 43/52] Y2038: add functions using futexes Albert ARIBAUD (3ADEV)
2017-09-07 22:45                                                                                       ` [RFC PATCH 44/52] Y2038: add function __getrusage_t64 Albert ARIBAUD (3ADEV)
2017-09-07 22:45                                                                                         ` [RFC PATCH 45/52] Y2038: add struct __ntp_timeval_t64 Albert ARIBAUD (3ADEV)
2017-09-07 22:45                                                                                           ` [RFC PATCH 46/52] Y2038: add function __ntp_gettime_t64 Albert ARIBAUD (3ADEV)
2017-09-07 22:45                                                                                             ` [RFC PATCH 47/52] Y2038: add function __ntp_gettimex_t64 Albert ARIBAUD (3ADEV)
2017-09-07 22:45                                                                                               ` [RFC PATCH 48/52] Y2038: add function __adjtimex_t64 (and __ntp_adjtime_t64) Albert ARIBAUD (3ADEV)
2017-09-07 22:46                                                                                                 ` [RFC PATCH 49/52] Y2038: add function pselect Albert ARIBAUD (3ADEV)
2017-09-08 17:49                                                                                                   ` [RFC PATCH 50/52] Y2038: add function select Albert ARIBAUD (3ADEV)
2017-09-08 17:49                                                                                                     ` Albert ARIBAUD (3ADEV) [this message]
2017-09-08 17:49                                                                                                       ` [RFC PATCH 52/52] Y2038: add _TIME_BITS==64 support Albert ARIBAUD (3ADEV)
2017-09-08 19:47                                                                                                         ` Joseph Myers
2017-09-08 19:47                                                                                                       ` [RFC PATCH 51/52] Y2038: add RPC functions Joseph Myers
2017-09-08 19:59                                                                                                       ` Paul Eggert
2017-09-09 14:37                                                                                                         ` Albert ARIBAUD
2017-09-11  6:33                                                                                                           ` Paul Eggert
2017-09-11  7:06                                                                                                         ` Paul Eggert
2017-09-11 14:07                                                                                                           ` Paul Eggert
2017-09-11 15:59                                                                                                             ` Albert ARIBAUD
2017-09-07 23:21 ` [RFC PATCH 00/52] Make GLIBC Y2038-proof Joseph Myers
2017-09-08 16:19   ` Zack Weinberg
2017-09-08 16:43     ` Joseph Myers
2017-09-08 16:54       ` Paul Eggert
2017-09-08 17:01       ` Zack Weinberg
2017-09-08 17:24         ` Joseph Myers
2017-09-08 18:32           ` Zack Weinberg
2017-09-08 17:42     ` Albert ARIBAUD
2017-09-08 17:59       ` Joseph Myers
2017-09-08 18:16         ` Albert ARIBAUD
2017-09-08 18:36           ` Zack Weinberg
2017-09-08 17:08   ` Albert ARIBAUD
2017-09-08 17:26     ` Joseph Myers
2017-09-08 19:19       ` Albert ARIBAUD
2017-09-08  4:23 ` Albert ARIBAUD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170908174909.28192-2-albert.aribaud@3adev.fr \
    --to=albert.aribaud@3adev.fr \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).