diff options
Diffstat (limited to 'fs/lockd/mon.c')
-rw-r--r-- | fs/lockd/mon.c | 39 |
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 | ||
154 | static __be32 *xdr_encode_nsm_string(__be32 *p, char *string) | 157 | static __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 | ||
218 | static __be32 * | ||
219 | xdr_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 | |||
245 | static int | 221 | static int |
246 | xdr_encode_mon(struct rpc_rqst *rqstp, __be32 *p, struct nsm_args *argp) | 222 | xdr_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) | |||
261 | static int | 237 | static int |
262 | xdr_encode_unmon(struct rpc_rqst *rqstp, __be32 *p, struct nsm_args *argp) | 238 | xdr_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 |