nfs: Fix compiler warning when calling svc_getcaller

Summary:
When using libtirpc instead of glibc rpc the result needs to be
cast to (struct sockaddr_in *)

This diff was originally a cherry-pick of D3111554 to 3.8

Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Signed-off-by: Shreyas Siravara <sshreyas@fb.com>
Change-Id: If4c27dbe6c032f9e278ea08cd3c96a4d07bcc5f9
BUG: 1428073
Reviewed-on: http://review.gluster.org/16179
Tested-by: Shreyas Siravara <sshreyas@fb.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Smoke: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Kevin Vigor <kvigor@fb.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-on: https://review.gluster.org/16804
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Kevin Vigor 2016-03-29 14:08:38 -07:00 committed by Niels de Vos
parent 78c4e657dc
commit 10a797c26f
2 changed files with 39 additions and 1 deletions

View File

@ -1740,7 +1740,19 @@ mnt3_check_client_net_udp (struct svc_req *req, char *volname, xlator_t *nfsx)
if ((!req) || (!volname) || (!nfsx))
goto err;
#if !defined(_TIRPC_SVC_H)
sin = svc_getcaller (req->rq_xprt);
#else
sin = (struct sockaddr_in *)svc_getcaller (req->rq_xprt);
/* TIRPC's svc_getcaller() returns a pointer to a sockaddr_in6, even
* though it might actually be an IPv4 address. It ought return a
* struct sockaddr and make the caller upcast it to the proper
* address family. Sigh.
*/
#endif
/* And let's make sure that it's actually an IPv4 address. */
GF_ASSERT (sin->sin_family == AF_INET);
if (!sin)
goto err;
@ -2817,7 +2829,21 @@ __mnt3udp_get_export_subdir_inode (struct svc_req *req, char *subdir,
/* AUTH check for subdir i.e. nfs.export-dir */
if (exp->hostspec) {
struct sockaddr_in *sin = svc_getcaller (req->rq_xprt);
struct sockaddr_in *sin = NULL;
#if !defined(_TIRPC_SVC_H)
sin = svc_getcaller (req->rq_xprt);
#else
sin = (struct sockaddr_in *)svc_getcaller (req->rq_xprt);
/* TIRPC's svc_getcaller() returns a pointer to a
* sockaddr_in6, even though it might actually be an
* IPv4 address. It ought return a struct sockaddr and
* make the caller upcast it to the proper address family.
*/
#endif
/* And let's make sure that it's actually an IPv4 address. */
GF_ASSERT (sin->sin_family == AF_INET);
ret = mnt3_verify_auth (sin, exp);
if (ret) {
gf_msg (GF_MNT, GF_LOG_ERROR, EACCES,

View File

@ -133,7 +133,19 @@ mountudp_program_3(struct svc_req *rqstp, register SVCXPRT *transp)
mountres3 *res = NULL;
struct sockaddr_in *sin = NULL;
#if !defined(_TIRPC_SVC_H)
sin = svc_getcaller (transp);
#else
sin = (struct sockaddr_in *)svc_getcaller (transp);
/* TIRPC's svc_getcaller() returns a pointer to a sockaddr_in6, even
* though it might actually be an IPv4 address. It ought return a
* struct sockaddr and make the caller upcast it to the proper
* address family. Sigh.
*/
#endif
/* And let's make sure that it's actually an IPv4 address. */
GF_ASSERT (sin->sin_family == AF_INET);
inet_ntop (AF_INET, &sin->sin_addr, mnthost, INET_ADDRSTRLEN+1);
switch (rqstp->rq_proc) {