diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2009-06-17 21:02:12 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2009-06-17 21:02:12 -0400 |
commit | a14017db2852f9393a401a0f64053c331003babf (patch) | |
tree | 2b9b0859a6435ad4412882a6b469ed4c426136c5 /fs/nfs | |
parent | 4fdcd9966d8469be26a6f12122ac21ffce19fc20 (diff) |
NFS: add XDR decoder for mountd version 3 auth-flavor lists
Introduce an xdr_stream-based XDR decoder that can unpack the auth-
flavor list returned in a MNT3 reply.
The nfs_mount() function's caller allocates an array, and passes the
size and a pointer to it. The decoder decodes all the flavors it can
into the array, and returns the number of decoded flavors.
If the caller is not interested in the auth flavors, it can pass a
value of zero as the size of the pre-allocated array.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/internal.h | 6 | ||||
-rw-r--r-- | fs/nfs/mount_clnt.c | 37 |
2 files changed, 43 insertions, 0 deletions
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index e4d6a8348adf..0207758de44a 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h | |||
@@ -30,6 +30,12 @@ struct nfs_clone_mount { | |||
30 | }; | 30 | }; |
31 | 31 | ||
32 | /* | 32 | /* |
33 | * Note: RFC 1813 doesn't limit the number of auth flavors that | ||
34 | * a server can return, so make something up. | ||
35 | */ | ||
36 | #define NFS_MAX_SECFLAVORS (12) | ||
37 | |||
38 | /* | ||
33 | * In-kernel mount arguments | 39 | * In-kernel mount arguments |
34 | */ | 40 | */ |
35 | struct nfs_parsed_mount_data { | 41 | struct nfs_parsed_mount_data { |
diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c index dd8c6f448eaa..ed0a27ed538d 100644 --- a/fs/nfs/mount_clnt.c +++ b/fs/nfs/mount_clnt.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #define MNT_fhs_status_sz (1) | 33 | #define MNT_fhs_status_sz (1) |
34 | #define MNT_fhandle_sz XDR_QUADLEN(NFS2_FHSIZE) | 34 | #define MNT_fhandle_sz XDR_QUADLEN(NFS2_FHSIZE) |
35 | #define MNT_fhandle3_sz (1 + XDR_QUADLEN(NFS3_FHSIZE)) | 35 | #define MNT_fhandle3_sz (1 + XDR_QUADLEN(NFS3_FHSIZE)) |
36 | #define MNT_authflav3_sz (1 + NFS_MAX_SECFLAVORS) | ||
36 | 37 | ||
37 | /* | 38 | /* |
38 | * XDR argument and result sizes | 39 | * XDR argument and result sizes |
@@ -122,6 +123,8 @@ static struct { | |||
122 | struct mountres { | 123 | struct mountres { |
123 | int errno; | 124 | int errno; |
124 | struct nfs_fh *fh; | 125 | struct nfs_fh *fh; |
126 | unsigned int *auth_count; | ||
127 | rpc_authflavor_t *auth_flavors; | ||
125 | }; | 128 | }; |
126 | 129 | ||
127 | struct mnt_fhstatus { | 130 | struct mnt_fhstatus { |
@@ -334,6 +337,40 @@ static int decode_fhandle3(struct xdr_stream *xdr, struct mountres *res) | |||
334 | return 0; | 337 | return 0; |
335 | } | 338 | } |
336 | 339 | ||
340 | static int decode_auth_flavors(struct xdr_stream *xdr, struct mountres *res) | ||
341 | { | ||
342 | rpc_authflavor_t *flavors = res->auth_flavors; | ||
343 | unsigned int *count = res->auth_count; | ||
344 | u32 entries, i; | ||
345 | __be32 *p; | ||
346 | |||
347 | if (*count == 0) | ||
348 | return 0; | ||
349 | |||
350 | p = xdr_inline_decode(xdr, sizeof(entries)); | ||
351 | if (unlikely(p == NULL)) | ||
352 | return -EIO; | ||
353 | entries = ntohl(*p); | ||
354 | dprintk("NFS: received %u auth flavors\n", entries); | ||
355 | if (entries > NFS_MAX_SECFLAVORS) | ||
356 | entries = NFS_MAX_SECFLAVORS; | ||
357 | |||
358 | p = xdr_inline_decode(xdr, sizeof(u32) * entries); | ||
359 | if (unlikely(p == NULL)) | ||
360 | return -EIO; | ||
361 | |||
362 | if (entries > *count) | ||
363 | entries = *count; | ||
364 | |||
365 | for (i = 0; i < entries; i++) { | ||
366 | flavors[i] = ntohl(*p++); | ||
367 | dprintk("NFS:\tflavor %u: %d\n", i, flavors[i]); | ||
368 | } | ||
369 | *count = i; | ||
370 | |||
371 | return 0; | ||
372 | } | ||
373 | |||
337 | static int xdr_decode_fhstatus3(struct rpc_rqst *req, __be32 *p, | 374 | static int xdr_decode_fhstatus3(struct rpc_rqst *req, __be32 *p, |
338 | struct mnt_fhstatus *res) | 375 | struct mnt_fhstatus *res) |
339 | { | 376 | { |