From patchwork Fri Sep 8 17:49:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Albert ARIBAUD X-Patchwork-Id: 22767 Received: (qmail 121422 invoked by alias); 8 Sep 2017 17:49:41 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 121310 invoked by uid 89); 8 Sep 2017 17:49:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy= X-HELO: smtp6-g21.free.fr From: "Albert ARIBAUD (3ADEV)" To: libc-alpha@sourceware.org Cc: "Albert ARIBAUD (3ADEV)" Subject: [RFC PATCH 51/52] Y2038: add RPC functions Date: Fri, 8 Sep 2017 19:49:08 +0200 Message-Id: <20170908174909.28192-2-albert.aribaud@3adev.fr> In-Reply-To: <20170908174909.28192-1-albert.aribaud@3adev.fr> References: <20170907224219.12483-50-albert.aribaud@3adev.fr> <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) --- 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,