linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benny Halevy <bhalevy@panasas.com>
To: Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: Andy Adamson <andros@netapp.com>,
	pnfs@linux-nfs.org, linux-next@vger.kernel.org,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	Benny Halevy <bhalevy@panasas.com>
Subject: [PATCH 5/6] nfs41: refactor decoding of channel attributes
Date: Thu,  7 May 2009 19:00:54 +0300	[thread overview]
Message-ID: <1241712054-30480-1-git-send-email-bhalevy@panasas.com> (raw)
In-Reply-To: <4A0304C7.2090003@panasas.com>

Also, verify ca_rdma_ird value and print a warning if > 1.

Signed-off-by: Benny Halevy <bhalevy@panasas.com>
---
 fs/nfs/nfs4xdr.c |   60 +++++++++++++++++++++++++----------------------------
 1 files changed, 28 insertions(+), 32 deletions(-)

diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index ea16df2..e4c0209 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -4226,12 +4226,35 @@ static int decode_exchange_id(struct xdr_stream *xdr,
 	return 0;
 }
 
+static int decode_chan_attrs(struct xdr_stream *xdr,
+			     struct nfs4_channel_attrs *attrs)
+{
+	__be32 *p;
+	u32 nr_attrs;
+
+	READ_BUF(28);
+	READ32(attrs->headerpadsz);
+	READ32(attrs->max_rqst_sz);
+	READ32(attrs->max_resp_sz);
+	READ32(attrs->max_resp_sz_cached);
+	READ32(attrs->max_ops);
+	READ32(attrs->max_reqs);
+	READ32(nr_attrs);
+	if (unlikely(nr_attrs > 1)) {
+		printk(KERN_WARNING "%s: Invalid rdma channel attrs count %u\n",
+			__func__, nr_attrs);
+		return -EINVAL;
+	}
+	if (nr_attrs == 1)
+		READ_BUF(4); /* skip rdma_attrs */
+	return 0;
+}
+
 static int decode_create_session(struct xdr_stream *xdr,
 				 struct nfs41_create_session_res *res)
 {
 	__be32 *p;
 	int status;
-	u32 nr_attrs;
 	struct nfs_client *clp = res->client;
 	struct nfs4_session *session = clp->cl_session;
 
@@ -4250,37 +4273,10 @@ static int decode_create_session(struct xdr_stream *xdr,
 	READ32(session->flags);
 
 	/* Channel attributes */
-	/* fore channel */
-	READ_BUF(24);
-	READ32(session->fc_attrs.headerpadsz);
-	READ32(session->fc_attrs.max_rqst_sz);
-	READ32(session->fc_attrs.max_resp_sz);
-	READ32(session->fc_attrs.max_resp_sz_cached);
-	READ32(session->fc_attrs.max_ops);
-	READ32(session->fc_attrs.max_reqs);
-	READ_BUF(4);
-	READ32(nr_attrs);
-	if (nr_attrs == 1) {
-		READ_BUF(4);
-		p++; /* skip rdma_attrs */
-	}
-
-	/* back channel */
-	READ_BUF(24);
-	READ32(session->bc_attrs.headerpadsz);
-	READ32(session->bc_attrs.max_rqst_sz);
-	READ32(session->bc_attrs.max_resp_sz);
-	READ32(session->bc_attrs.max_resp_sz_cached);
-	READ32(session->bc_attrs.max_ops);
-	READ32(session->bc_attrs.max_reqs);
-	READ_BUF(4);
-	READ32(nr_attrs);
-	if (nr_attrs == 1) {
-		READ_BUF(4);
-		p++; /* skip rdma_attrs */
-	}
-
-	return 0;
+	status = decode_chan_attrs(xdr, &session->fc_attrs);
+	if (!status)
+		status = decode_chan_attrs(xdr, &session->bc_attrs);
+	return status;
 }
 
 static int decode_destroy_session(struct xdr_stream *xdr, void *dummy)
-- 
1.6.2.1

  parent reply	other threads:[~2009-05-07 16:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-01  3:15 linux-next: nfs tree build warning Stephen Rothwell
2009-05-01  3:22 ` Trond Myklebust
2009-05-01 12:19   ` Benny Halevy
2009-05-01 14:56     ` William A. (Andy) Adamson
2009-05-01 20:14       ` [PATCH] nfs41: get rid of unused struct nfs41_exchange_id_res members Benny Halevy
2009-05-05 19:34         ` Trond Myklebust
2009-05-05 19:39           ` Trond Myklebust
2009-05-05 19:41             ` Trond Myklebust
2009-05-05 20:28               ` Benny Halevy
2009-05-05 20:35                 ` Benny Halevy
2009-05-05 22:12                   ` Trond Myklebust
2009-05-05 22:15                     ` Benny Halevy
2009-05-05 22:39                       ` Trond Myklebust
2009-05-07 15:56                         ` Benny Halevy
2009-05-07 16:00                           ` [PATCH 1/6] nfs41: Ignoring impid in decode_exchange_id is missing a READ_BUF Benny Halevy
2009-05-07 16:00                           ` [PATCH 2/6] nfs41: fix Xcode_exchange_id's xdr Xcoding pointer type Benny Halevy
2009-05-07 16:00                           ` [PATCH 3/6] nfs41: get rid of unused struct nfs41_exchange_id_res members Benny Halevy
2009-05-07 16:00                           ` [PATCH 4/6] nfs41: fix Xcode_create_session's xdr Xcoding pointer type Benny Halevy
2009-05-07 16:00                           ` Benny Halevy [this message]
2009-05-07 16:01                           ` [PATCH 6/6] nfs41: fix encode_destroy_session's " Benny Halevy
2009-05-05 22:43                       ` [pnfs] [PATCH] nfs41: get rid of unused struct nfs41_exchange_id_res members J. Bruce Fields
2009-06-09  9:13 ` linux-next: nfs tree build warning Stephen Rothwell

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=1241712054-30480-1-git-send-email-bhalevy@panasas.com \
    --to=bhalevy@panasas.com \
    --cc=andros@netapp.com \
    --cc=linux-next@vger.kernel.org \
    --cc=pnfs@linux-nfs.org \
    --cc=sfr@canb.auug.org.au \
    --cc=trond.myklebust@fys.uio.no \
    /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 NNTP newsgroup(s).