From 1f6b0f5cfc5abebe3a8facfb8b72e5554c1314d2 Mon Sep 17 00:00:00 2001 From: Rajesh Joseph Date: Thu, 3 Oct 2013 15:08:34 +0530 Subject: NFS: showmount timesout on fetching export list Bug: 1015184 Issue: showmount timesout on fetching export list. Socket writev function is failing. Cause: XDR encoding of export list is failing. The calling function without checking the error returned by xdr_serialize_exports function is going ahead and writting into the socket causing the NFS process to hang. xdr_serialize_exports function returns -1 on error and message length on success. Fix: Caller should check if the function is returning -1 (error) or not before proceeding. Change-Id: Ic3a5a9356e47b2ac938dd3e429cf2b71c0a0c715 Signed-off-by: Rajesh Joseph Reviewed-on: http://review.gluster.org/6030 Reviewed-by: Santosh Pradhan Reviewed-by: Niels de Vos Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/nfs/server/src/acl3.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'xlators/nfs/server/src/acl3.c') diff --git a/xlators/nfs/server/src/acl3.c b/xlators/nfs/server/src/acl3.c index bb3b95216..e10123e69 100644 --- a/xlators/nfs/server/src/acl3.c +++ b/xlators/nfs/server/src/acl3.c @@ -140,10 +140,11 @@ nfs3_fh_to_xlator (struct nfs3_state *nfs3, struct nfs3_fh *fh); int acl3svc_submit_reply (rpcsvc_request_t *req, void *arg, acl3_serializer sfunc) { - struct iovec outmsg = {0, }; - struct iobuf *iob = NULL; - struct nfs3_state *nfs3 = NULL; - int ret = -1; + struct iovec outmsg = {0, }; + struct iobuf *iob = NULL; + struct nfs3_state *nfs3 = NULL; + int ret = -1; + ssize_t msglen = 0; struct iobref *iobref = NULL; if (!req) @@ -168,7 +169,12 @@ acl3svc_submit_reply (rpcsvc_request_t *req, void *arg, acl3_serializer sfunc) /* Use the given serializer to translate the give C structure in arg * to XDR format which will be written into the buffer in outmsg. */ - outmsg.iov_len = sfunc (outmsg, arg); + msglen = sfunc (outmsg, arg); + if (msglen < 0) { + gf_log (GF_ACL, GF_LOG_ERROR, "Failed to encode message"); + goto ret; + } + outmsg.iov_len = msglen; iobref = iobref_new (); if (iobref == NULL) { @@ -176,7 +182,11 @@ acl3svc_submit_reply (rpcsvc_request_t *req, void *arg, acl3_serializer sfunc) goto ret; } - iobref_add (iobref, iob); + ret = iobref_add (iobref, iob); + if (ret) { + gf_log (GF_ACL, GF_LOG_ERROR, "Failed to add iob to iobref"); + goto ret; + } /* Then, submit the message for transmission. */ ret = rpcsvc_submit_message (req, &outmsg, 1, NULL, 0, iobref); -- cgit