summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Vigor <kvigor@fb.com>2016-03-29 14:08:38 -0700
committerNiels de Vos <ndevos@redhat.com>2017-04-11 11:25:37 -0400
commit10a797c26f0e9db33b2b5b89263f6cca3709c002 (patch)
treedaf079c147038c7d738969a885c65eef5a28cd72
parent78c4e657dc2e122b00f99912819357c85e35d54d (diff)
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>
-rw-r--r--xlators/nfs/server/src/mount3.c28
-rw-r--r--xlators/nfs/server/src/mount3udp_svc.c12
2 files changed, 39 insertions, 1 deletions
diff --git a/xlators/nfs/server/src/mount3.c b/xlators/nfs/server/src/mount3.c
index 823b94dd3ca..3f6415dba85 100644
--- a/xlators/nfs/server/src/mount3.c
+++ b/xlators/nfs/server/src/mount3.c
@@ -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,
diff --git a/xlators/nfs/server/src/mount3udp_svc.c b/xlators/nfs/server/src/mount3udp_svc.c
index e8e226e953e..8256a5970bb 100644
--- a/xlators/nfs/server/src/mount3udp_svc.c
+++ b/xlators/nfs/server/src/mount3udp_svc.c
@@ -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) {