aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2008-03-14 14:26:01 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-03-19 18:01:07 -0400
commit2ca7754d4c96d68e1475690422a202ba5f0443d8 (patch)
treec67f12d715492e78e371861afde95604d1aaf3bb /fs
parentea72a7f170e686baf00ceee57b6197bef686889c (diff)
lockd: Fix up incorrect RPC buffer size calculations.
Switch to using the new mon_id encoder function. Now that we've refactored the encoding of SM_MON requests, we've discovered that the pre-computed buffer length maximums are incorrect! Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/lockd/mon.c39
1 files changed, 8 insertions, 31 deletions
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index 3935d7b604f5..f2507fec7c6f 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -149,6 +149,9 @@ nsm_create(void)
149 149
150/* 150/*
151 * XDR functions for NSM. 151 * XDR functions for NSM.
152 *
153 * See http://www.opengroup.org/ for details on the Network
154 * Status Monitor wire protocol.
152 */ 155 */
153 156
154static __be32 *xdr_encode_nsm_string(__be32 *p, char *string) 157static __be32 *xdr_encode_nsm_string(__be32 *p, char *string)
@@ -215,37 +218,10 @@ static __be32 *xdr_encode_mon_id(__be32 *p, struct nsm_args *argp)
215 return xdr_encode_my_id(p, argp); 218 return xdr_encode_my_id(p, argp);
216} 219}
217 220
218static __be32 *
219xdr_encode_common(struct rpc_rqst *rqstp, __be32 *p, struct nsm_args *argp)
220{
221 char buffer[20], *name;
222
223 /*
224 * Use the dotted-quad IP address of the remote host as
225 * identifier. Linux statd always looks up the canonical
226 * hostname first for whatever remote hostname it receives,
227 * so this works alright.
228 */
229 if (nsm_use_hostnames) {
230 name = argp->mon_name;
231 } else {
232 sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(argp->addr));
233 name = buffer;
234 }
235 if (!(p = xdr_encode_string(p, name))
236 || !(p = xdr_encode_string(p, utsname()->nodename)))
237 return ERR_PTR(-EIO);
238 *p++ = htonl(argp->prog);
239 *p++ = htonl(argp->vers);
240 *p++ = htonl(argp->proc);
241
242 return p;
243}
244
245static int 221static int
246xdr_encode_mon(struct rpc_rqst *rqstp, __be32 *p, struct nsm_args *argp) 222xdr_encode_mon(struct rpc_rqst *rqstp, __be32 *p, struct nsm_args *argp)
247{ 223{
248 p = xdr_encode_common(rqstp, p, argp); 224 p = xdr_encode_mon_id(p, argp);
249 if (IS_ERR(p)) 225 if (IS_ERR(p))
250 return PTR_ERR(p); 226 return PTR_ERR(p);
251 227
@@ -261,7 +237,7 @@ xdr_encode_mon(struct rpc_rqst *rqstp, __be32 *p, struct nsm_args *argp)
261static int 237static int
262xdr_encode_unmon(struct rpc_rqst *rqstp, __be32 *p, struct nsm_args *argp) 238xdr_encode_unmon(struct rpc_rqst *rqstp, __be32 *p, struct nsm_args *argp)
263{ 239{
264 p = xdr_encode_common(rqstp, p, argp); 240 p = xdr_encode_mon_id(p, argp);
265 if (IS_ERR(p)) 241 if (IS_ERR(p))
266 return PTR_ERR(p); 242 return PTR_ERR(p);
267 rqstp->rq_slen = xdr_adjust_iovec(rqstp->rq_svec, p); 243 rqstp->rq_slen = xdr_adjust_iovec(rqstp->rq_svec, p);
@@ -286,8 +262,9 @@ xdr_decode_stat(struct rpc_rqst *rqstp, __be32 *p, struct nsm_res *resp)
286} 262}
287 263
288#define SM_my_name_sz (1+XDR_QUADLEN(SM_MAXSTRLEN)) 264#define SM_my_name_sz (1+XDR_QUADLEN(SM_MAXSTRLEN))
289#define SM_my_id_sz (3+1+SM_my_name_sz) 265#define SM_my_id_sz (SM_my_name_sz+3)
290#define SM_mon_id_sz (1+XDR_QUADLEN(20)+SM_my_id_sz) 266#define SM_mon_name_sz (1+XDR_QUADLEN(SM_MAXSTRLEN))
267#define SM_mon_id_sz (SM_mon_name_sz+SM_my_id_sz)
291#define SM_mon_sz (SM_mon_id_sz+4) 268#define SM_mon_sz (SM_mon_id_sz+4)
292#define SM_monres_sz 2 269#define SM_monres_sz 2
293#define SM_unmonres_sz 1 270#define SM_unmonres_sz 1