Series short description
Subsystems (2)
cover Series short description
Hi Trond-
In-kernel MNT client changes proposed for 2.6.31. Comments?
---
Chuck Lever (8):
NFS: Remove unused XDR decoder functions
NFS: Update MNT and MNT3 reply decoding functions
NFS: add XDR decoder for mountd version 3 auth-flavor lists
NFS: add new file handle decoders to in-kernel mountd client
NFS: Add separate mountd status code decoders for each mountd version
NFS: remove unused function in fs/nfs/mount_clnt.c
NFS: Use xdr_stream-based XDR encoder for MNT's dirpath argument
NFS: Clean up MNT program definitions
fs/nfs/internal.h | 8 + fs/nfs/mount_clnt.c | 354 ++++++++++++++++++++++++++++++++++++++++++++------ fs/nfs/nfsroot.c | 5 + fs/nfs/super.c | 2 include/linux/nfs.h | 5 - include/linux/nfs2.h | 7 - include/linux/nfs3.h | 5 - 7 files changed, 331 insertions(+), 55 deletions(-)
Signature · 1 line
Chuck Lever <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20090501163507.25681.14463.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org
PATCH 1/8 NFS: Clean up MNT program definitions
Clean up: Relocate MNT program procedure number definitions to the only file that uses them. Relocate the version number definitions, which are shared, to nfs.h. Remove duplicate program number definitions.
---
fs/nfs/mount_clnt.c | 32 ++++++++++++++++++++++++++++---- fs/nfs/nfsroot.c | 3 +++ include/linux/nfs.h | 5 +++-- include/linux/nfs2.h | 7 ------- include/linux/nfs3.h | 5 ----- 5 files changed, 34 insertions(+), 18 deletions(-)
fs/nfs/mount_clnt.c +28 -4
@@ -20,6 +20,30 @@# define NFSDBG_FACILITY NFSDBG_MOUNT#endif +/* +* Defined by RFC 1094, section A.5 +*/ +enum { +MOUNTPROC_NULL =0 , +MOUNTPROC_MNT =1 , +MOUNTPROC_DUMP =2 , +MOUNTPROC_UMNT =3 , +MOUNTPROC_UMNTALL =4 , +MOUNTPROC_EXPORT =5 , +}; + +/* +* Defined by RFC 1813, section 5.2 +*/ +enum { +MOUNTPROC3_NULL =0 , +MOUNTPROC3_MNT =1 , +MOUNTPROC3_DUMP =2 , +MOUNTPROC3_UMNT =3 , +MOUNTPROC3_UMNTALL =4 , +MOUNTPROC3_EXPORT =5 , +}; +static struct rpc_program mnt_program;struct mnt_fhstatus {
@@ -68,7 +92,7 @@ int nfs_mount(struct nfs_mount_request *info)if (info->version ==NFS_MNT3_VERSION ) msg.rpc_proc = &mnt_clnt->cl_procinfo[MOUNTPROC3_MNT ];else - msg.rpc_proc = &mnt_clnt->cl_procinfo[MNTPROC_MNT ]; + msg.rpc_proc = &mnt_clnt->cl_procinfo[MOUNTPROC_MNT ]; status =rpc_call_sync (mnt_clnt, &msg,0 );rpc_shutdown_client (mnt_clnt);
@@ -145,13 +169,13 @@ static int xdr_decode_fhstatus3(struct rpc_rqst *req, __be32 *p,#define MNT_fhstatus3_sz (1 + 16)static struct rpc_procinfo mnt_procedures[] = { - [MNTPROC_MNT ] = { - .p_proc =MNTPROC_MNT , + [MOUNTPROC_MNT ] = { + .p_proc =MOUNTPROC_MNT , .p_encode = (kxdrproc_t ) xdr_encode_dirpath, .p_decode = (kxdrproc_t ) xdr_decode_fhstatus, .p_arglen = MNT_dirpath_sz, .p_replen = MNT_fhstatus_sz, - .p_statidx =MNTPROC_MNT , + .p_statidx =MOUNTPROC_MNT , .p_name ="MOUNT" , }, };
fs/nfs/nfsroot.c +3 -0
@@ -92,6 +92,9 @@#undef NFSROOT_DEBUG#define NFSDBG_FACILITY NFSDBG_ROOT +/* Default port to use if server is not running a portmapper */ +#define NFS_MNT_PORT 627 +/* Default path we try to mount. "%s" gets replaced by our IP address */ #define NFS_ROOT "/tftpboot/%s"
include/linux/nfs.h +3 -2
@@ -25,8 +25,9 @@#define NFSMODE_SOCK 0140000#define NFSMODE_FIFO 0010000 -#define NFS_MNT_PROGRAM 100005 -#define NFS_MNT_PORT 627 +#define NFS_MNT_PROGRAM 100005 +#define NFS_MNT_VERSION 1 +#define NFS_MNT3_VERSION 3/* * NFS stats. The good thing with these values is that NFSv3 errors are
include/linux/nfs2.h +0 -7
@@ -64,11 +64,4 @@ struct nfs2_fh {#define NFSPROC_READDIR 16#define NFSPROC_STATFS 17 -#define NFS_MNT_PROGRAM 100005 -#define NFS_MNT_VERSION 1 -#define MNTPROC_NULL 0 -#define MNTPROC_MNT 1 -#define MNTPROC_UMNT 3 -#define MNTPROC_UMNTALL 4 -#endif /* _LINUX_NFS2_H */
include/linux/nfs3.h +0 -5
@@ -88,12 +88,7 @@ struct nfs3_fh {#define NFS3PROC_PATHCONF 20#define NFS3PROC_COMMIT 21 -#define NFS_MNT3_PROGRAM 100005#define NFS_MNT3_VERSION 3 -#define MOUNTPROC3_NULL 0 -#define MOUNTPROC3_MNT 1 -#define MOUNTPROC3_UMNT 3 -#define MOUNTPROC3_UMNTALL 4#if defined(__KERNEL__)
PATCH 2/8 NFS: Use xdr_stream-based XDR encoder for MNT's dirpath argument
In reply to a message not in the archiveCheck the length of the supplied dirpath, and see that it fits properly in the RPC buffer.
---
fs/nfs/mount_clnt.c | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 44 insertions(+), 5 deletions(-)
fs/nfs/mount_clnt.c +44 -5
@@ -21,6 +21,21 @@#endif /* +* Defined by RFC 1094, section A.3; and RFC 1813, section 5.1.4 +*/ +#define MNTPATHLEN (1024) + +/* +* XDR data type sizes +*/ +#define encode_dirpath_sz XDR_QUADLEN(sizeof(u32) + MNTPATHLEN) + +/* +* XDR argument and result sizes +*/ +#define MNT_enc_dirpath_sz encode_dirpath_sz + +/* * Defined by RFC 1094, section A.5 */ enum {
@@ -135,6 +150,31 @@ static int xdr_encode_dirpath(struct rpc_rqst *req, __be32 *p,return 0 ; } +static int encode_mntdirpath (struct xdr_stream *xdr,const char *pathname) +{ +const u32 pathname_len =strlen (pathname); +__be32 *p; + +if (unlikely (pathname_len >MNTPATHLEN )) +return -EIO ; + + p =xdr_reserve_space (xdr,sizeof (u32) + pathname_len); +if (unlikely (p ==NULL )) +return -EIO ; +xdr_encode_opaque (p, pathname, pathname_len); + +return 0 ; +} + +static int mnt_enc_dirpath (struct rpc_rqst *req,__be32 *p, +const char *dirpath) +{ +struct xdr_stream xdr; + +xdr_init_encode (&xdr, &req->rq_snd_buf, p); +return encode_mntdirpath (&xdr, dirpath); +} +static int xdr_decode_fhstatus (struct rpc_rqst *req,__be32 *p,struct mnt_fhstatus *res) {
@@ -164,16 +204,15 @@ static int xdr_decode_fhstatus3(struct rpc_rqst *req, __be32 *p,return 0 ; } -#define MNT_dirpath_sz (1 + 256)#define MNT_fhstatus_sz (1 + 8)#define MNT_fhstatus3_sz (1 + 16)static struct rpc_procinfo mnt_procedures[] = { [MOUNTPROC_MNT ] = { .p_proc =MOUNTPROC_MNT , - .p_encode = (kxdrproc_t ) xdr_encode_dirpath, + .p_encode = (kxdrproc_t )mnt_enc_dirpath, .p_decode = (kxdrproc_t ) xdr_decode_fhstatus, - .p_arglen = MNT_dirpath_sz, + .p_arglen = MNT_enc_dirpath_sz, .p_replen = MNT_fhstatus_sz, .p_statidx =MOUNTPROC_MNT , .p_name ="MOUNT" ,
@@ -183,9 +222,9 @@ static struct rpc_procinfo mnt_procedures[] = {static struct rpc_procinfo mnt3_procedures[] = { [MOUNTPROC3_MNT ] = { .p_proc =MOUNTPROC3_MNT , - .p_encode = (kxdrproc_t ) xdr_encode_dirpath, + .p_encode = (kxdrproc_t )mnt_enc_dirpath, .p_decode = (kxdrproc_t ) xdr_decode_fhstatus3, - .p_arglen = MNT_dirpath_sz, + .p_arglen = MNT_enc_dirpath_sz, .p_replen = MNT_fhstatus3_sz, .p_statidx =MOUNTPROC3_MNT , .p_name ="MOUNT" ,
PATCH 3/8 NFS: remove unused function in fs/nfs/mount_clnt.c
In reply to a message not in the archiveClean up: remove xdr_encode_dirpath() now that it has been replaced.
---
fs/nfs/mount_clnt.c | 8 -------- 1 files changed, 0 insertions(+), 8 deletions(-)
fs/nfs/mount_clnt.c +0 -8
@@ -141,14 +141,6 @@ out_mnt_err:/* * XDR encode/decode functions for MOUNT */ -static int xdr_encode_dirpath (struct rpc_rqst *req,__be32 *p, -const char *path) -{ - p =xdr_encode_string (p, path); - - req->rq_slen =xdr_adjust_iovec (req->rq_svec, p); -return 0 ; -}static int encode_mntdirpath (struct xdr_stream *xdr,const char *pathname) {
PATCH 4/8 NFS: Add separate mountd status code decoders for each mountd version
In reply to a message not in the archiveIntroduce data structures and xdr_stream-based decoding functions for unmarshalling mountd status codes properly.
Mountd version 3 uses specific standard error return codes that are not errno values and not NFS3ERR_ values. These have a well-defined standard mapping to local errno values. Introduce data structures and a decoder function that map these status codes to local errno values properly. This is new functionality (but not used yet).
Version 1 mountd status values are defined by RFC 1094 as UNIX error values (errno values). Errno values on heterogeneous systems do not necessarily match each other. To avoid exposing possibly incorrect errno values to upper layers, the current XDR decoder converts all non-zero MNT version 1 status codes to -EACCES.
The OpenGroup XNFS standard provides a mapping similar to but smaller than the version 3 error codes. Implement a decoder that uses the XNFS error codes, replacing the current decoder.
For both mountd protocol versions, map unrecognized errors to -EACCES.
Finally we introduce a replacement data structure for mnt_fhstatus at this time, which is used by the new XDR decoders. In addition to documenting that the status value returned by the XDR decoders is always an errno, this new structure will be expanded in subsequent patches.
---
fs/nfs/mount_clnt.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 134 insertions(+), 0 deletions(-)
fs/nfs/mount_clnt.c +134 -0
@@ -29,6 +29,8 @@* XDR data type sizes */ #define encode_dirpath_sz XDR_QUADLEN(sizeof(u32) + MNTPATHLEN) +#define MNT_status_sz XDR_QUADLEN(sizeof(u32)) +#define MNT_fhs_status_sz XDR_QUADLEN(sizeof(u32))/* * XDR argument and result sizes
@@ -61,6 +63,83 @@ enum {static struct rpc_program mnt_program; +/* +* Defined by OpenGroup XNFS Version 3W, chapter 8 +*/ +enum mountstat { +MNT_OK =0 , +MNT_EPERM =1 , +MNT_ENOENT =2 , +MNT_EACCES =13 , +MNT_EINVAL =22 , +}; + +#define MNT_MAPERRNO (name) \ + { \ + .status = MNT_E##name, \ + .errno = -E##name, \ + } + +static struct { +u32 status; +int errno; +} mnt_errtbl[] = { + { + .status =MNT_OK , + .errno =0 , + }, +MNT_MAPERRNO (PERM ), +MNT_MAPERRNO (NOENT ), +MNT_MAPERRNO (ACCES ), +MNT_MAPERRNO (INVAL ), +}; + +/* +* Defined by RFC 1813, section 5.1.5 +*/ +enum mountstat3 { +MNT3_OK =0 ,/* no error */ +MNT3ERR_PERM =1 ,/* Not owner */ +MNT3ERR_NOENT =2 ,/* No such file or directory */ +MNT3ERR_IO =5 ,/* I/O error */ +MNT3ERR_ACCES =13 ,/* Permission denied */ +MNT3ERR_NOTDIR =20 ,/* Not a directory */ +MNT3ERR_INVAL =22 ,/* Invalid argument */ +MNT3ERR_NAMETOOLONG =63 ,/* Filename too long */ +MNT3ERR_NOTSUPP =10004 ,/* Operation not supported */ +MNT3ERR_SERVERFAULT =10006 ,/* A failure on the server */ +}; + +#define MNT3_MAPERRNO (name) \ + { \ + .status = MNT3ERR_##name, \ + .errno = -E##name, \ + } + +static struct { +u32 status; +int errno; +} mnt3_errtbl[] = { + { + .status =MNT3_OK , + .errno =0 , + }, +MNT3_MAPERRNO (PERM ), +MNT3_MAPERRNO (NOENT ), +MNT3_MAPERRNO (IO ), +MNT3_MAPERRNO (ACCES ), +MNT3_MAPERRNO (NOTDIR ), +MNT3_MAPERRNO (INVAL ), +MNT3_MAPERRNO (NAMETOOLONG ), +MNT3_MAPERRNO (NOTSUPP ), +MNT3_MAPERRNO (SERVERFAULT ), +}; + +struct mountres { +int errno; +struct nfs_fh *fh; +}; +struct mnt_fhstatus {u32 status;struct nfs_fh *fh;
@@ -179,6 +258,61 @@ static int xdr_decode_fhstatus(struct rpc_rqst *req, __be32 *p,return 0 ; } +/* +* RFC 1094: "A non-zero status indicates some sort of error. In this +* case, the status is a UNIX error number." This can be problematic +* if the server and client use different errno values for the same +* error. +* +* However, the OpenGroup XNFS spec provides a simple mapping that is +* independent of local errno values on the server and the client. +*/ +static int decode_status (struct xdr_stream *xdr,struct mountres *res) +{ +unsigned int i; +u32 status; +__be32 *p; + + p =xdr_inline_decode (xdr,sizeof (status)); +if (unlikely (p ==NULL )) +return -EIO ; + status =ntohl (*p); + +for (i =0 ; i <=ARRAY_SIZE (mnt_errtbl); i++) { +if (mnt_errtbl[i].status == status) { + res->errno = mnt_errtbl[i].errno; +return 0 ; + } + } + +dprintk ("NFS: unrecognized MNT status code: %u\n" , status); + res->errno = -EACCES ; +return 0 ; +} + +static int decode_fhs_status (struct xdr_stream *xdr,struct mountres *res) +{ +unsigned int i; +u32 status; +__be32 *p; + + p =xdr_inline_decode (xdr,sizeof (status)); +if (unlikely (p ==NULL )) +return -EIO ; + status =ntohl (*p); + +for (i =0 ; i <=ARRAY_SIZE (mnt3_errtbl); i++) { +if (mnt3_errtbl[i].status == status) { + res->errno = mnt3_errtbl[i].errno; +return 0 ; + } + } + +dprintk ("NFS: unrecognized MNT3 status code: %u\n" , status); + res->errno = -EACCES ; +return 0 ; +} +static int xdr_decode_fhstatus3 (struct rpc_rqst *req,__be32 *p,struct mnt_fhstatus *res) {
A message that is not in the archive (sent off-list or not yet received): 20090501163651.25681.95115.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org
Re: [PATCH 4/8] NFS: Add separate mountd status code decoders for each mountd version
Quoted 38 lines · Chuck Lever
Introduce data structures and xdr_stream-based decoding functions for unmarshalling mountd status codes properly.
Mountd version 3 uses specific standard error return codes that are not errno values and not
NFS3ERR_values. These have a well-defined standard mapping to local errno values. Introduce data structures and a decoder function that map these status codes to local errno values properly. This is new functionality (but not used yet).Version 1 mountd status values are defined by RFC 1094 as UNIX error values (errno values). Errno values on heterogeneous systems do not necessarily match each other. To avoid exposing possibly incorrect errno values to upper layers, the current XDR decoder converts all non-zero MNT version 1 status codes to
-EACCES.The OpenGroup XNFS standard provides a mapping similar to but smaller than the version 3 error codes. Implement a decoder that uses the XNFS error codes, replacing the current decoder.
For both mountd protocol versions, map unrecognized errors to
-EACCES.Finally we introduce a replacement data structure for
mnt_fhstatusat this time, which is used by the new XDR decoders. In addition to documenting that the status value returned by the XDR decoders is always an errno, this new structure will be expanded in subsequent patches.Signed-off-by Chuck Lever <[email protected]>---
fs/nfs/mount_clnt.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 134 insertions(+), 0 deletions(-)fs/nfs/mount_clnt.c +0
-0
fs/nfs/mount_clnt.c line 33
Quoted 5 lines
fs/nfs/mount_clnt.c +2
-0@@ -29,6 +29,8 @@* XDR data type sizes */ #define encode_dirpath_sz XDR_QUADLEN(sizeof(u32) + MNTPATHLEN) +#define MNT_status_sz XDR_QUADLEN(sizeof(u32)) +#define MNT_fhs_status_sz XDR_QUADLEN(sizeof(u32))
XDR_QUADLEN() applies to strings only. Please just use naked numbers here. I've already fixed up the previous patch that did this.
Quoted 13 lines
fs/nfs/mount_clnt.c +6
-0/* * XDR argument and result sizes @@ -61,6 +63,83 @@ enum {static struct rpc_program mnt_program; +/* +* Defined by OpenGroup XNFS Version 3W, chapter 8 +*/ +enum mountstat { +MNT_OK =0 , +MNT_EPERM =1 ,
fs/nfs/mount_clnt.c enum { · line 81
Quoted 10 lines
fs/nfs/mount_clnt.c +10
-0+MNT_ENOENT =2 , +MNT_EACCES =13 , + MNT_EINVAL = 22, +}; + +#define MNT_MAPERRNO (name) \ + { \ + .status = MNT_E##name, \ + .errno = -E##name, \ + }
It would be nice to avoid this kind of macro. Please inline instead.
Quoted 26 lines
fs/nfs/mount_clnt.c +26
-0+ +static struct { +u32 status; +int errno; +} mnt_errtbl[] = { + { + .status =MNT_OK , + .errno =0 , + }, +MNT_MAPERRNO (PERM ), +MNT_MAPERRNO (NOENT ), +MNT_MAPERRNO (ACCES ), +MNT_MAPERRNO (INVAL ), +}; + +/* +* Defined by RFC 1813, section 5.1.5 +*/ +enum mountstat3 { +MNT3_OK =0 ,/* no error */ +MNT3ERR_PERM =1 ,/* Not owner */ +MNT3ERR_NOENT =2 ,/* No such file or directory */ +MNT3ERR_IO =5 ,/* I/O error */ +MNT3ERR_ACCES =13 ,/* Permission denied */ +MNT3ERR_NOTDIR =20 ,/* Not a directory */ +MNT3ERR_INVAL =22 ,/* Invalid argument */
fs/nfs/mount_clnt.c enum { · line 117
Quoted 10 lines
fs/nfs/mount_clnt.c +10
-0+MNT3ERR_NAMETOOLONG =63 ,/* Filename too long */ +MNT3ERR_NOTSUPP =10004 ,/* Operation not supported */ + MNT3ERR_SERVERFAULT = 10006, /* A failure on the server */ +}; + +#define MNT3_MAPERRNO (name) \ + { \ + .status = MNT3ERR_##name, \ + .errno = -E##name, \ + }
See above
Quoted 90 lines
fs/nfs/mount_clnt.c +79
-0+static struct { +u32 status; +int errno; +} mnt3_errtbl[] = { + { + .status =MNT3_OK , + .errno =0 , + }, +MNT3_MAPERRNO (PERM ), +MNT3_MAPERRNO (NOENT ), +MNT3_MAPERRNO (IO ), +MNT3_MAPERRNO (ACCES ), +MNT3_MAPERRNO (NOTDIR ), +MNT3_MAPERRNO (INVAL ), +MNT3_MAPERRNO (NAMETOOLONG ), +MNT3_MAPERRNO (NOTSUPP ), +MNT3_MAPERRNO (SERVERFAULT ), +}; + +struct mountres { +int errno; +struct nfs_fh *fh; +}; +struct mnt_fhstatus {u32 status;struct nfs_fh *fh;@@ -179,6 +258,61 @@ static int xdr_decode_fhstatus(struct rpc_rqst *req, __be32 *p,return 0 ; } +/* +* RFC 1094: "A non-zero status indicates some sort of error. In this +* case, the status is a UNIX error number." This can be problematic +* if the server and client use different errno values for the same +* error. +* +* However, the OpenGroup XNFS spec provides a simple mapping that is +* independent of local errno values on the server and the client. +*/ +static int decode_status (struct xdr_stream *xdr,struct mountres *res) +{ +unsigned int i; +u32 status; +__be32 *p; + + p =xdr_inline_decode (xdr,sizeof (status)); +if (unlikely (p ==NULL )) +return -EIO ; + status =ntohl (*p); + +for (i =0 ; i <=ARRAY_SIZE (mnt_errtbl); i++) { +if (mnt_errtbl[i].status == status) { + res->errno = mnt_errtbl[i].errno; +return 0 ; + } + } + +dprintk ("NFS: unrecognized MNT status code: %u\n" , status); + res->errno = -EACCES ; +return 0 ; +} + +static int decode_fhs_status (struct xdr_stream *xdr,struct mountres *res) +{ +unsigned int i; +u32 status; +__be32 *p; + + p =xdr_inline_decode (xdr,sizeof (status)); +if (unlikely (p ==NULL )) +return -EIO ; + status =ntohl (*p); + +for (i =0 ; i <=ARRAY_SIZE (mnt3_errtbl); i++) { +if (mnt3_errtbl[i].status == status) { + res->errno = mnt3_errtbl[i].errno; +return 0 ; + } + } + +dprintk ("NFS: unrecognized MNT3 status code: %u\n" , status); + res->errno = -EACCES ; +return 0 ; +} +static int xdr_decode_fhstatus3 (struct rpc_rqst *req,__be32 *p,struct mnt_fhstatus *res) {
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
A message that is not in the archive (sent off-list or not yet received): 1244840137.32257.4.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org
Re: [PATCH 4/8] NFS: Add separate mountd status code decoders for each mountd version
Quoted 35 lines · Trond Myklebust
Quoted 34 lines · Chuck Lever
Introduce data structures and xdr_stream-based decoding functions for unmarshalling mountd status codes properly.
Mountd version 3 uses specific standard error return codes that are not errno values and not
NFS3ERR_values. These have a well-defined standard mapping to local errno values. Introduce data structures and a decoder function that map these status codes to local errno values properly. This is new functionality (but not used yet).Version 1 mountd status values are defined by RFC 1094 as UNIX error values (errno values). Errno values on heterogeneous systems do not necessarily match each other. To avoid exposing possibly incorrect errno values to upper layers, the current XDR decoder converts all non-zero MNT version 1 status codes to
-EACCES.The OpenGroup XNFS standard provides a mapping similar to but smaller than the version 3 error codes. Implement a decoder that uses the XNFS error codes, replacing the current decoder.
For both mountd protocol versions, map unrecognized errors to
-EACCES.Finally we introduce a replacement data structure for
mnt_fhstatusat this time, which is used by the new XDR decoders. In addition to documenting that the status value returned by the XDR decoders is always an errno, this new structure will be expanded in subsequent patches.Signed-off-by Chuck Lever <[email protected]>---
fs/nfs/mount_clnt.c| 134 +++++++++++++++++++++++++++++++++++++++++
++++++++++1 files changed, 134 insertions(+), 0 deletions(-)
Quoted 13 lines
fs/nfs/mount_clnt.c line 33
Quoted 10 lines
fs/nfs/mount_clnt.c +2
-0@@ -29,6 +29,8 @@* XDR data type sizes */ #define encode_dirpath_sz XDR_QUADLEN(sizeof(u32) + MNTPATHLEN) +#define MNT_status_sz XDR_QUADLEN(sizeof(u32)) +#define MNT_fhs_status_sz XDR_QUADLEN(sizeof(u32))
XDR_QUADLEN()applies to strings only. Please just use naked numbers here. I've already fixed up the previous patch that did this.
OK, I'll fix these up. So the redriven patch applies, did you change encode_dirpath_sz to be:
#define encode_dirpath_sz (1 + XDR_QUADLEN(MNTPATHLEN))
Actually, just send what you have so I can see what exactly you want here.
But, where does it say XDR_QUADLEN applies to strings only? The documenting comment just says "Buffer adjustment".
Quoted 16 lines
Quoted 16 lines
fs/nfs/mount_clnt.c +10
-0/* * XDR argument and result sizes @@ -61,6 +63,83 @@ enum {static struct rpc_program mnt_program; +/* +* Defined by OpenGroup XNFS Version 3W, chapter 8 +*/ +enum mountstat { +MNT_OK =0 , +MNT_EPERM =1 , +MNT_ENOENT =2 , +MNT_EACCES =13 , +MNT_EINVAL =22 , +};
Quoted 8 lines
fs/nfs/mount_clnt.c enum { · line 81
Quoted 6 lines
fs/nfs/mount_clnt.c +6
-0+ +#define MNT_MAPERRNO (name) \ + { \ + .status = MNT_E##name, \ + .errno = -E##name, \ + }It would be nice to avoid this kind of macro. Please inline instead.
Would you like the PROC macro replaced with open code as well?
Quoted 127 lines
Quoted 26 lines
fs/nfs/mount_clnt.c +26
-0+ +static struct { +u32 status; +int errno; +} mnt_errtbl[] = { + { + .status =MNT_OK , + .errno =0 , + }, +MNT_MAPERRNO (PERM ), +MNT_MAPERRNO (NOENT ), +MNT_MAPERRNO (ACCES ), +MNT_MAPERRNO (INVAL ), +}; + +/* +* Defined by RFC 1813, section 5.1.5 +*/ +enum mountstat3 { +MNT3_OK =0 ,/* no error */ +MNT3ERR_PERM =1 ,/* Not owner */ +MNT3ERR_NOENT =2 ,/* No such file or directory */ +MNT3ERR_IO =5 ,/* I/O error */ +MNT3ERR_ACCES =13 ,/* Permission denied */ +MNT3ERR_NOTDIR =20 ,/* Not a directory */ +MNT3ERR_INVAL =22 ,/* Invalid argument */ fs/nfs/mount_clnt.c enum { · line 117
Quoted 10 lines
fs/nfs/mount_clnt.c +10
-0+MNT3ERR_NAMETOOLONG =63 ,/* Filename too long */ +MNT3ERR_NOTSUPP =10004 ,/* Operation not supported */ + MNT3ERR_SERVERFAULT = 10006, /* A failure on the server */ +}; + +#define MNT3_MAPERRNO (name) \ + { \ + .status = MNT3ERR_##name, \ + .errno = -E##name, \ + }See above
Quoted 88 lines
fs/nfs/mount_clnt.c +26
-0+static struct { +u32 status; +int errno; +} mnt3_errtbl[] = { + { + .status =MNT3_OK , + .errno =0 , + }, +MNT3_MAPERRNO (PERM ), +MNT3_MAPERRNO (NOENT ), +MNT3_MAPERRNO (IO ), +MNT3_MAPERRNO (ACCES ), +MNT3_MAPERRNO (NOTDIR ), +MNT3_MAPERRNO (INVAL ), +MNT3_MAPERRNO (NAMETOOLONG ), +MNT3_MAPERRNO (NOTSUPP ), +MNT3_MAPERRNO (SERVERFAULT ), +}; + +struct mountres { +int errno; +struct nfs_fh *fh; +}; +struct mnt_fhstatus {u32 status;struct nfs_fh *fh;@@ -179,6 +258,61 @@ static int xdr_decode_fhstatus(struct rpc_rqst *req, __be32 *p, return 0; } +/* +* RFC 1094: "A non-zero status indicates some sort of error. In this
+ * case, the status is a UNIX error number." This can be problematic
+ * if the server and client use different errno values for the same
+ * error.
+ *
+ * However, the OpenGroup XNFS spec provides a simple mapping that is
+ * independent of local errno values on the server and the client.
+ */
+static intdecode_status(struct xdr_stream *xdr, struct mountres *res)fs/nfs/mount_clnt.c +23
-0+{ +unsigned int i; +u32 status; +__be32 *p; + + p =xdr_inline_decode (xdr,sizeof (status)); +if (unlikely (p ==NULL )) +return -EIO ; + status =ntohl (*p); + +for (i =0 ; i <=ARRAY_SIZE (mnt_errtbl); i++) { +if (mnt_errtbl[i].status == status) { + res->errno = mnt_errtbl[i].errno; +return 0 ; + } + } + +dprintk ("NFS: unrecognized MNT status code: %u\n" , status); + res->errno = -EACCES ; +return 0 ; +} + +static int decode_fhs_status(struct xdr_stream *xdr, structmountres *res)
fs/nfs/mount_clnt.c +18
-0+{ +unsigned int i; +u32 status; +__be32 *p; + + p =xdr_inline_decode (xdr,sizeof (status)); +if (unlikely (p ==NULL )) +return -EIO ; + status =ntohl (*p); + +for (i =0 ; i <=ARRAY_SIZE (mnt3_errtbl); i++) { +if (mnt3_errtbl[i].status == status) { + res->errno = mnt3_errtbl[i].errno; +return 0 ; + } + } + +dprintk ("NFS: unrecognized MNT3 status code: %u\n" , status);
Quoted 16 lines
Quoted 8 lines
fs/nfs/mount_clnt.c +4
-0+ res->errno = -EACCES ; +return 0 ; +} +static int xdr_decode_fhstatus3(struct
rpc_rqst*req,__be32*p,
structmnt_fhstatus*res)
{Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 4/8] NFS: Add separate mountd status code decoders for each mountd version
Quoted 53 lines · Chuck Lever
Quoted 37 lines · Trond Myklebust
Quoted 36 lines · Chuck Lever
Introduce data structures and xdr_stream-based decoding functions for unmarshalling mountd status codes properly.
Mountd version 3 uses specific standard error return codes that are not errno values and not
NFS3ERR_values. These have a well-defined standard mapping to local errno values. Introduce data structures and a decoder function that map these status codes to local errno values properly. This is new functionality (but not used yet).Version 1 mountd status values are defined by RFC 1094 as UNIX error values (errno values). Errno values on heterogeneous systems do not necessarily match each other. To avoid exposing possibly incorrect errno values to upper layers, the current XDR decoder converts all non-zero MNT version 1 status codes to
-EACCES.The OpenGroup XNFS standard provides a mapping similar to but smaller than the version 3 error codes. Implement a decoder that uses the XNFS
error codes, replacing the current decoder.For both mountd protocol versions, map unrecognized errors to - EACCES.
Finally we introduce a replacement data structure for
mnt_fhstatusat this time, which is used by the new XDR decoders. In addition to documenting that the status value returned by the XDR decoders is always an errno, this new structure will be expanded in subsequent patches.Signed-off-by Chuck Lever <[email protected]>---
fs/nfs/mount_clnt.c| 134 +++++++++++++++++++++++++++++++++++++++++
++++++++++1 files changed, 134 insertions(+), 0 deletions(-)Quoted 13 lines
fs/nfs/mount_clnt.c line 33
Quoted 10 lines
fs/nfs/mount_clnt.c +2
-0@@ -29,6 +29,8 @@* XDR data type sizes */ #define encode_dirpath_sz XDR_QUADLEN(sizeof(u32) + MNTPATHLEN) +#define MNT_status_sz XDR_QUADLEN(sizeof(u32)) +#define MNT_fhs_status_sz XDR_QUADLEN(sizeof(u32))
XDR_QUADLEN()applies to strings only. Please just use naked numbers here. I've already fixed up the previous patch that did this.
Quoted 4 lines
OK, I'll fix these up. So the redriven patch applies, did you change
encode_dirpath_szto be:#define
encode_dirpath_sz(1 +XDR_QUADLEN(MNTPATHLEN))
Yep. That's precisely what I did. See attachment.
Quoted 5 lines
Actually, just send what you have so I can see what exactly you want here.
But, where does it say
XDR_QUADLENapplies to strings only? The documenting comment just says "Buffer adjustment".
We should probably fix the comment then. The point of XDR_QUADLEN() is to pad an array so that it is correctly aligned, and then convert it into a count of words.
Quoted 25 lines
Quoted 16 lines
Quoted 16 lines
fs/nfs/mount_clnt.c +10
-0/* * XDR argument and result sizes @@ -61,6 +63,83 @@ enum {static struct rpc_program mnt_program; +/* +* Defined by OpenGroup XNFS Version 3W, chapter 8 +*/ +enum mountstat { +MNT_OK =0 , +MNT_EPERM =1 , +MNT_ENOENT =2 , +MNT_EACCES =13 , +MNT_EINVAL =22 , +};Quoted 8 lines
fs/nfs/mount_clnt.c enum { · line 81
Quoted 6 lines
fs/nfs/mount_clnt.c +6
-0+ +#define MNT_MAPERRNO (name) \ + { \ + .status = MNT_E##name, \ + .errno = -E##name, \ + }It would be nice to avoid this kind of macro. Please inline instead.
Quoted 1 line
Would you like the PROC macro replaced with open code as well?
Yes please. I know the PROC macro has a longer history, but it is tough to read if you're a newbie nfs developer...
Quoted 147 lines
Quoted 127 lines
Quoted 26 lines
fs/nfs/mount_clnt.c +26
-0+ +static struct { +u32 status; +int errno; +} mnt_errtbl[] = { + { + .status =MNT_OK , + .errno =0 , + }, +MNT_MAPERRNO (PERM ), +MNT_MAPERRNO (NOENT ), +MNT_MAPERRNO (ACCES ), +MNT_MAPERRNO (INVAL ), +}; + +/* +* Defined by RFC 1813, section 5.1.5 +*/ +enum mountstat3 { +MNT3_OK =0 ,/* no error */ +MNT3ERR_PERM =1 ,/* Not owner */ +MNT3ERR_NOENT =2 ,/* No such file or directory */ +MNT3ERR_IO =5 ,/* I/O error */ +MNT3ERR_ACCES =13 ,/* Permission denied */ +MNT3ERR_NOTDIR =20 ,/* Not a directory */ +MNT3ERR_INVAL =22 ,/* Invalid argument */ fs/nfs/mount_clnt.c enum { · line 117
Quoted 10 lines
fs/nfs/mount_clnt.c +10
-0+MNT3ERR_NAMETOOLONG =63 ,/* Filename too long */ +MNT3ERR_NOTSUPP =10004 ,/* Operation not supported */ + MNT3ERR_SERVERFAULT = 10006, /* A failure on the server */ +}; + +#define MNT3_MAPERRNO (name) \ + { \ + .status = MNT3ERR_##name, \ + .errno = -E##name, \ + }See above
Quoted 88 lines
fs/nfs/mount_clnt.c +26
-0+static struct { +u32 status; +int errno; +} mnt3_errtbl[] = { + { + .status =MNT3_OK , + .errno =0 , + }, +MNT3_MAPERRNO (PERM ), +MNT3_MAPERRNO (NOENT ), +MNT3_MAPERRNO (IO ), +MNT3_MAPERRNO (ACCES ), +MNT3_MAPERRNO (NOTDIR ), +MNT3_MAPERRNO (INVAL ), +MNT3_MAPERRNO (NAMETOOLONG ), +MNT3_MAPERRNO (NOTSUPP ), +MNT3_MAPERRNO (SERVERFAULT ), +}; + +struct mountres { +int errno; +struct nfs_fh *fh; +}; +struct mnt_fhstatus {u32 status;struct nfs_fh *fh;@@ -179,6 +258,61 @@ static int xdr_decode_fhstatus(struct rpc_rqst *req, __be32 *p, return 0; } +/* +* RFC 1094: "A non-zero status indicates some sort of error. In this
+ * case, the status is a UNIX error number." This can be problematic
+ * if the server and client use different errno values for the same
+ * error.
+ *
+ * However, the OpenGroup XNFS spec provides a simple mapping that is
+ * independent of local errno values on the server and the client.
+ */
+static intdecode_status(struct xdr_stream *xdr, struct mountres *res)fs/nfs/mount_clnt.c +23
-0+{ +unsigned int i; +u32 status; +__be32 *p; + + p =xdr_inline_decode (xdr,sizeof (status)); +if (unlikely (p ==NULL )) +return -EIO ; + status =ntohl (*p); + +for (i =0 ; i <=ARRAY_SIZE (mnt_errtbl); i++) { +if (mnt_errtbl[i].status == status) { + res->errno = mnt_errtbl[i].errno; +return 0 ; + } + } + +dprintk ("NFS: unrecognized MNT status code: %u\n" , status); + res->errno = -EACCES ; +return 0 ; +} + +static int decode_fhs_status(struct xdr_stream *xdr, structmountres *res)
fs/nfs/mount_clnt.c +18
-0+{ +unsigned int i; +u32 status; +__be32 *p; + + p =xdr_inline_decode (xdr,sizeof (status)); +if (unlikely (p ==NULL )) +return -EIO ; + status =ntohl (*p); + +for (i =0 ; i <=ARRAY_SIZE (mnt3_errtbl); i++) { +if (mnt3_errtbl[i].status == status) { + res->errno = mnt3_errtbl[i].errno; +return 0 ; + } + } + +dprintk ("NFS: unrecognized MNT3 status code: %u\n" , status);Quoted 16 lines
Quoted 8 lines
fs/nfs/mount_clnt.c +4
-0+ res->errno = -EACCES ; +return 0 ; +} +static int xdr_decode_fhstatus3(struct
rpc_rqst*req,__be32*p,
structmnt_fhstatus*res)
{Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
Check the length of the supplied dirpath, and see that it fits properly in the RPC buffer.
---
fs/nfs/mount_clnt.c | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 44 insertions(+), 5 deletions(-)
fs/nfs/mount_clnt.c +44 -5
@@ -21,6 +21,21 @@#endif /* +* Defined by RFC 1094, section A.3; and RFC 1813, section 5.1.4 +*/ +#define MNTPATHLEN (1024) + +/* +* XDR data type sizes +*/ +#define encode_dirpath_sz (1 + XDR_QUADLEN(MNTPATHLEN)) + +/* +* XDR argument and result sizes +*/ +#define MNT_enc_dirpath_sz encode_dirpath_sz + +/* * Defined by RFC 1094, section A.5 */ enum {
@@ -135,6 +150,31 @@ static int xdr_encode_dirpath(struct rpc_rqst *req, __be32 *p,return 0 ; } +static int encode_mntdirpath (struct xdr_stream *xdr,const char *pathname) +{ +const u32 pathname_len =strlen (pathname); +__be32 *p; + +if (unlikely (pathname_len >MNTPATHLEN )) +return -EIO ; + + p =xdr_reserve_space (xdr,sizeof (u32) + pathname_len); +if (unlikely (p ==NULL )) +return -EIO ; +xdr_encode_opaque (p, pathname, pathname_len); + +return 0 ; +} + +static int mnt_enc_dirpath (struct rpc_rqst *req,__be32 *p, +const char *dirpath) +{ +struct xdr_stream xdr; + +xdr_init_encode (&xdr, &req->rq_snd_buf, p); +return encode_mntdirpath (&xdr, dirpath); +} +static int xdr_decode_fhstatus (struct rpc_rqst *req,__be32 *p,struct mnt_fhstatus *res) {
@@ -164,16 +204,15 @@ static int xdr_decode_fhstatus3(struct rpc_rqst *req, __be32 *p,return 0 ; } -#define MNT_dirpath_sz (1 + 256)#define MNT_fhstatus_sz (1 + 8)#define MNT_fhstatus3_sz (1 + 16)static struct rpc_procinfo mnt_procedures[] = { [MOUNTPROC_MNT ] = { .p_proc =MOUNTPROC_MNT , - .p_encode = (kxdrproc_t ) xdr_encode_dirpath, + .p_encode = (kxdrproc_t )mnt_enc_dirpath, .p_decode = (kxdrproc_t ) xdr_decode_fhstatus, - .p_arglen = MNT_dirpath_sz, + .p_arglen = MNT_enc_dirpath_sz, .p_replen = MNT_fhstatus_sz, .p_statidx =MOUNTPROC_MNT , .p_name ="MOUNT" ,
@@ -183,9 +222,9 @@ static struct rpc_procinfo mnt_procedures[] = {static struct rpc_procinfo mnt3_procedures[] = { [MOUNTPROC3_MNT ] = { .p_proc =MOUNTPROC3_MNT , - .p_encode = (kxdrproc_t ) xdr_encode_dirpath, + .p_encode = (kxdrproc_t )mnt_enc_dirpath, .p_decode = (kxdrproc_t ) xdr_decode_fhstatus3, - .p_arglen = MNT_dirpath_sz, + .p_arglen = MNT_enc_dirpath_sz, .p_replen = MNT_fhstatus3_sz, .p_statidx =MOUNTPROC3_MNT , .p_name ="MOUNT" ,
A message that is not in the archive (sent off-list or not yet received): 1244841689.32257.10.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org
Re: [PATCH 4/8] NFS: Add separate mountd status code decoders for each mountd version
Quoted 64 lines · Trond Myklebust
Quoted 53 lines · Chuck Lever
Quoted 38 lines · Trond Myklebust
Quoted 37 lines · Chuck Lever
Introduce data structures and xdr_stream-based decoding functions for unmarshalling mountd status codes properly.
Mountd version 3 uses specific standard error return codes that are not errno values and not
NFS3ERR_values. These have a well-defined standard mapping to local errno values. Introduce data structures and a decoder function that map these status codes to local errno values properly. This is new functionality (but not used yet).Version 1 mountd status values are defined by RFC 1094 as UNIX error values (errno values). Errno values on heterogeneous systems do not necessarily match each other. To avoid exposing possibly incorrect errno values to upper layers, the current XDR decoder converts all non-zero MNT version 1 status codes to
-EACCES.The OpenGroup XNFS standard provides a mapping similar to but smaller than the version 3 error codes. Implement a decoder that uses the XNFS
error codes, replacing the current decoder.For both mountd protocol versions, map unrecognized errors to - EACCES.
Finally we introduce a replacement data structure for
mnt_fhstatusat this time, which is used by the new XDR decoders. In addition to documenting that the status value returned by the XDR decoders is always an errno, this new structure will be expanded in subsequent patches.Signed-off-by Chuck Lever <[email protected]>---
fs/nfs/mount_clnt.c| 134 +++++++++++++++++++++++++++++++++++++++ ++
++++++++++1 files changed, 134 insertions(+), 0 deletions(-)Quoted 13 lines
fs/nfs/mount_clnt.c line 33
Quoted 10 lines
fs/nfs/mount_clnt.c +2
-0@@ -29,6 +29,8 @@* XDR data type sizes */ #define encode_dirpath_sz XDR_QUADLEN(sizeof(u32) + MNTPATHLEN) +#define MNT_status_sz XDR_QUADLEN(sizeof(u32)) +#define MNT_fhs_status_sz XDR_QUADLEN(sizeof(u32))
XDR_QUADLEN()applies to strings only. Please just use naked numbers here. I've already fixed up the previous patch that did this.Quoted 4 lines
OK, I'll fix these up. So the redriven patch applies, did you change
encode_dirpath_szto be:#define
encode_dirpath_sz(1 +XDR_QUADLEN(MNTPATHLEN))Yep. That's precisely what I did. See attachment.
Quoted 3 lines
Actually, just send what you have so I can see what exactly you want here.
Quoted 6 lines
Quoted 2 lines
But, where does it say
XDR_QUADLENapplies to strings only? The documenting comment just says "Buffer adjustment".We should probably fix the comment then. The point of
XDR_QUADLEN()is to pad an array so that it is correctly aligned, and then convert it into a count of words.
I'll leave that to you...
Quoted 25 lines
Quoted 25 lines
Quoted 24 lines
Quoted 12 lines
fs/nfs/mount_clnt.c +6
-0/* * XDR argument and result sizes @@ -61,6 +63,83 @@ enum {static struct rpc_program mnt_program; +/* +* Defined by OpenGroup XNFS Version 3W, chapter 8 +*/ +enum mountstat { +MNT_OK =0 , +MNT_EPERM =1 ,fs/nfs/mount_clnt.c enum { · line 81
Quoted 10 lines
fs/nfs/mount_clnt.c +10
-0+MNT_ENOENT =2 , +MNT_EACCES =13 , + MNT_EINVAL = 22, +}; + +#define MNT_MAPERRNO (name) \ + { \ + .status = MNT_E##name, \ + .errno = -E##name, \ + }It would be nice to avoid this kind of macro. Please inline instead.
Quoted 4 lines
Quoted 1 line
Would you like the PROC macro replaced with open code as well?
Yes please. I know the PROC macro has a longer history, but it is tough to read if you're a newbie nfs developer...
np, i'll send a patch that goes on the end of this series that replaces the PROC macro in mount_clnt.c.
Quoted 258 lines
Quoted 148 lines
Quoted 128 lines
Quoted 26 lines
fs/nfs/mount_clnt.c +26
-0+ +static struct { +u32 status; +int errno; +} mnt_errtbl[] = { + { + .status =MNT_OK , + .errno =0 , + }, +MNT_MAPERRNO (PERM ), +MNT_MAPERRNO (NOENT ), +MNT_MAPERRNO (ACCES ), +MNT_MAPERRNO (INVAL ), +}; + +/* +* Defined by RFC 1813, section 5.1.5 +*/ +enum mountstat3 { +MNT3_OK =0 ,/* no error */ +MNT3ERR_PERM =1 ,/* Not owner */ +MNT3ERR_NOENT =2 ,/* No such file or directory */ +MNT3ERR_IO =5 ,/* I/O error */ +MNT3ERR_ACCES =13 ,/* Permission denied */ +MNT3ERR_NOTDIR =20 ,/* Not a directory */ +MNT3ERR_INVAL =22 ,/* Invalid argument */ fs/nfs/mount_clnt.c enum { · line 117
Quoted 10 lines
fs/nfs/mount_clnt.c +10
-0+MNT3ERR_NAMETOOLONG =63 ,/* Filename too long */ +MNT3ERR_NOTSUPP =10004 ,/* Operation not supported */ + MNT3ERR_SERVERFAULT = 10006, /* A failure on the server */ +}; + +#define MNT3_MAPERRNO (name) \ + { \ + .status = MNT3ERR_##name, \ + .errno = -E##name, \ + }See above
Quoted 89 lines
fs/nfs/mount_clnt.c +26
-0+static struct { +u32 status; +int errno; +} mnt3_errtbl[] = { + { + .status =MNT3_OK , + .errno =0 , + }, +MNT3_MAPERRNO (PERM ), +MNT3_MAPERRNO (NOENT ), +MNT3_MAPERRNO (IO ), +MNT3_MAPERRNO (ACCES ), +MNT3_MAPERRNO (NOTDIR ), +MNT3_MAPERRNO (INVAL ), +MNT3_MAPERRNO (NAMETOOLONG ), +MNT3_MAPERRNO (NOTSUPP ), +MNT3_MAPERRNO (SERVERFAULT ), +}; + +struct mountres { +int errno; +struct nfs_fh *fh; +}; +struct mnt_fhstatus {u32 status;struct nfs_fh *fh;@@ -179,6 +258,61 @@ static int xdr_decode_fhstatus(struct rpc_rqst *req, __be32 *p, return 0; } +/* +* RFC 1094: "A non-zero status indicates some sort of error. In this
+ * case, the status is a UNIX error number." This can be problematic
+ * if the server and client use different errno values for the same
+ * error.
+ *
+ * However, the OpenGroup XNFS spec provides a simple mapping that is
+ * independent of local errno values on the server and the client.
+ */
+static intdecode_status(struct xdr_stream *xdr, struct mountres *res)fs/nfs/mount_clnt.c +23
-0+{ +unsigned int i; +u32 status; +__be32 *p; + + p =xdr_inline_decode (xdr,sizeof (status)); +if (unlikely (p ==NULL )) +return -EIO ; + status =ntohl (*p); + +for (i =0 ; i <=ARRAY_SIZE (mnt_errtbl); i++) { +if (mnt_errtbl[i].status == status) { + res->errno = mnt_errtbl[i].errno; +return 0 ; + } + } + +dprintk ("NFS: unrecognized MNT status code: %u\n" , status); + res->errno = -EACCES ; +return 0 ; +} + +static int decode_fhs_status(struct xdr_stream *xdr, structmountres *res)
fs/nfs/mount_clnt.c +18
-0+{ +unsigned int i; +u32 status; +__be32 *p; + + p =xdr_inline_decode (xdr,sizeof (status)); +if (unlikely (p ==NULL )) +return -EIO ; + status =ntohl (*p); + +for (i =0 ; i <=ARRAY_SIZE (mnt3_errtbl); i++) { +if (mnt3_errtbl[i].status == status) { + res->errno = mnt3_errtbl[i].errno; +return 0 ; + } + } + +dprintk ("NFS: unrecognized MNT3 status code: %u\n" , status);Quoted 16 lines
Quoted 8 lines
fs/nfs/mount_clnt.c +4
-0+ res->errno = -EACCES ; +return 0 ; +} +static int xdr_decode_fhstatus3(struct
rpc_rqst*req,__be32*p,
structmnt_fhstatus*res)
{Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com--
Chuck Lever
chuck[dot]lever[at]oracle[dot]comSignature · 22 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com From: Chuck Lever <[email protected]> Subject: No Subject Check the length of the supplied dirpath, and see that it fits properly in the RPC buffer. Signed-off-by: Chuck Lever <[email protected]> [[email protected]: fixed up definition of encode_dirpath_sz] Signed-off-by: Trond Myklebust <[email protected]> --- fs/nfs/mount_clnt.c | 49 ++++++++++++++++++++++++++++++++++++++++++ ++----- 1 files changed, 44 insertions(+), 5 deletions(-)fs/nfs/mount_clnt.c +40
-0@@ -21,6 +21,21 @@#endif /* +* Defined by RFC 1094, section A.3; and RFC 1813, section 5.1.4 +*/ +#define MNTPATHLEN (1024) + +/* +* XDR data type sizes +*/ +#define encode_dirpath_sz (1 + XDR_QUADLEN(MNTPATHLEN)) + +/* +* XDR argument and result sizes +*/ +#define MNT_enc_dirpath_sz encode_dirpath_sz + +/* * Defined by RFC 1094, section A.5 */ enum {@@ -135,6 +150,31 @@ static int xdr_encode_dirpath(struct rpc_rqst *req, __be32 *p, return 0; } +static int encode_mntdirpath (struct xdr_stream *xdr,const char *pathname) +{ +const u32 pathname_len =strlen (pathname); +__be32 *p; + +if (unlikely (pathname_len >MNTPATHLEN )) +return -EIO ; + + p =xdr_reserve_space (xdr,sizeof (u32) + pathname_len); +if (unlikely (p ==NULL )) +return -EIO ; +xdr_encode_opaque (p, pathname, pathname_len); + +return 0 ; +} + +static int mnt_enc_dirpath (struct rpc_rqst *req,__be32 *p, +const char *dirpath) +{ +struct xdr_stream xdr; + +xdr_init_encode (&xdr, &req->rq_snd_buf, p); +return encode_mntdirpath (&xdr, dirpath); +} + static int xdr_decode_fhstatus(struct rpc_rqst *req, __be32 *p,struct
mnt_fhstatus*res)
{fs/nfs/mount_clnt.c +2
-3@@ -164,16 +204,15 @@ static int xdr_decode_fhstatus3(struct rpc_rqst *req, __be32 *p, return 0; } -#define MNT_dirpath_sz (1 + 256)#define MNT_fhstatus_sz (1 + 8)#define MNT_fhstatus3_sz (1 + 16)static struct rpc_procinfo mnt_procedures[] = { [MOUNTPROC_MNT ] = { .p_proc =MOUNTPROC_MNT , - .p_encode = (kxdrproc_t ) xdr_encode_dirpath, + .p_encode = (kxdrproc_t )mnt_enc_dirpath, .p_decode = (kxdrproc_t ) xdr_decode_fhstatus, - .p_arglen = MNT_dirpath_sz, + .p_arglen = MNT_enc_dirpath_sz, .p_replen = MNT_fhstatus_sz, .p_statidx =MOUNTPROC_MNT ,.p_name = "MOUNT",fs/nfs/mount_clnt.c +0
-0@@ -183,9 +222,9 @@ static struct rpc_procinfo mnt_procedures[] = {static struct rpc_procinfo mnt3_procedures[] = {
fs/nfs/mount_clnt.c static struct rpc_procinfo mnt_procedures[] = { · line 230
Quoted 10 lines
fs/nfs/mount_clnt.c +2
-2[MOUNTPROC3_MNT] = { .p_proc = MOUNTPROC3_MNT, - .p_encode = (kxdrproc_t) xdr_encode_dirpath, + .p_encode = (kxdrproc_t)mnt_enc_dirpath, .p_decode = (kxdrproc_t) xdr_decode_fhstatus3, - .p_arglen = MNT_dirpath_sz, + .p_arglen = MNT_enc_dirpath_sz, .p_replen = MNT_fhstatus3_sz, .p_statidx = MOUNTPROC3_MNT, .p_name = "MOUNT",
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 4/8] NFS: Add separate mountd status code decoders for each mountd version
In reply to a message not in the archiveQuoted 97 lines · Trond Myklebust
Quoted 54 lines · Chuck Lever
Quoted 38 lines · Trond Myklebust
Quoted 37 lines · Chuck Lever
Introduce data structures and xdr_stream-based decoding functions for unmarshalling mountd status codes properly.
Mountd version 3 uses specific standard error return codes that are not errno values and not
NFS3ERR_values. These have a well-defined standard mapping to local errno values. Introduce data structures and a decoder function that map these status codes to local errno values properly. This is new functionality (but not used yet).Version 1 mountd status values are defined by RFC 1094 as UNIX error values (errno values). Errno values on heterogeneous systems do not necessarily match each other. To avoid exposing possibly incorrect errno values to upper layers, the current XDR decoder converts all non-zero MNT version 1 status codes to
-EACCES.The OpenGroup XNFS standard provides a mapping similar to but smaller than the version 3 error codes. Implement a decoder that uses the XNFS
error codes, replacing the current decoder.For both mountd protocol versions, map unrecognized errors to - EACCES.
Finally we introduce a replacement data structure for
mnt_fhstatusat this time, which is used by the new XDR decoders. In addition to documenting that the status value returned by the XDR decoders is always an errno, this new structure will be expanded in subsequent patches.Signed-off-by Chuck Lever <[email protected]>---
fs/nfs/mount_clnt.c| 134 +++++++++++++++++++++++++++++++++++++++ ++
++++++++++1 files changed, 134 insertions(+), 0 deletions(-)Quoted 13 lines
fs/nfs/mount_clnt.c line 33
Quoted 10 lines
fs/nfs/mount_clnt.c +2
-0@@ -29,6 +29,8 @@* XDR data type sizes */ #define encode_dirpath_sz XDR_QUADLEN(sizeof(u32) + MNTPATHLEN) +#define MNT_status_sz XDR_QUADLEN(sizeof(u32)) +#define MNT_fhs_status_sz XDR_QUADLEN(sizeof(u32))
XDR_QUADLEN()applies to strings only. Please just use naked numbers here. I've already fixed up the previous patch that did this.Quoted 4 lines
OK, I'll fix these up. So the redriven patch applies, did you change
encode_dirpath_szto be:#define
encode_dirpath_sz(1 +XDR_QUADLEN(MNTPATHLEN))Yep. That's precisely what I did. See attachment.
Quoted 5 lines
Actually, just send what you have so I can see what exactly you want here.
But, where does it say
XDR_QUADLENapplies to strings only? The documenting comment just says "Buffer adjustment".We should probably fix the comment then. The point of
XDR_QUADLEN()is to pad an array so that it is correctly aligned, and then convert it into a count of words.Quoted 25 lines
Quoted 24 lines
Quoted 12 lines
fs/nfs/mount_clnt.c +6
-0/* * XDR argument and result sizes @@ -61,6 +63,83 @@ enum {static struct rpc_program mnt_program; +/* +* Defined by OpenGroup XNFS Version 3W, chapter 8 +*/ +enum mountstat { +MNT_OK =0 , +MNT_EPERM =1 ,fs/nfs/mount_clnt.c enum { · line 81
Quoted 10 lines
fs/nfs/mount_clnt.c +10
-0+MNT_ENOENT =2 , +MNT_EACCES =13 , + MNT_EINVAL = 22, +}; + +#define MNT_MAPERRNO (name) \ + { \ + .status = MNT_E##name, \ + .errno = -E##name, \ + }It would be nice to avoid this kind of macro. Please inline instead.
Quoted 4 lines
Quoted 1 line
Would you like the PROC macro replaced with open code as well?
Yes please. I know the PROC macro has a longer history, but it is tough to read if you're a newbie nfs developer...
Oh, hah. mount_clnt already doesn't have one. rpcb does, and I can remove that one (for later, perhaps 2.6.32).
Quoted 258 lines
Quoted 148 lines
Quoted 128 lines
Quoted 26 lines
fs/nfs/mount_clnt.c +26
-0+ +static struct { +u32 status; +int errno; +} mnt_errtbl[] = { + { + .status =MNT_OK , + .errno =0 , + }, +MNT_MAPERRNO (PERM ), +MNT_MAPERRNO (NOENT ), +MNT_MAPERRNO (ACCES ), +MNT_MAPERRNO (INVAL ), +}; + +/* +* Defined by RFC 1813, section 5.1.5 +*/ +enum mountstat3 { +MNT3_OK =0 ,/* no error */ +MNT3ERR_PERM =1 ,/* Not owner */ +MNT3ERR_NOENT =2 ,/* No such file or directory */ +MNT3ERR_IO =5 ,/* I/O error */ +MNT3ERR_ACCES =13 ,/* Permission denied */ +MNT3ERR_NOTDIR =20 ,/* Not a directory */ +MNT3ERR_INVAL =22 ,/* Invalid argument */ fs/nfs/mount_clnt.c enum { · line 117
Quoted 10 lines
fs/nfs/mount_clnt.c +10
-0+MNT3ERR_NAMETOOLONG =63 ,/* Filename too long */ +MNT3ERR_NOTSUPP =10004 ,/* Operation not supported */ + MNT3ERR_SERVERFAULT = 10006, /* A failure on the server */ +}; + +#define MNT3_MAPERRNO (name) \ + { \ + .status = MNT3ERR_##name, \ + .errno = -E##name, \ + }See above
Quoted 89 lines
fs/nfs/mount_clnt.c +26
-0+static struct { +u32 status; +int errno; +} mnt3_errtbl[] = { + { + .status =MNT3_OK , + .errno =0 , + }, +MNT3_MAPERRNO (PERM ), +MNT3_MAPERRNO (NOENT ), +MNT3_MAPERRNO (IO ), +MNT3_MAPERRNO (ACCES ), +MNT3_MAPERRNO (NOTDIR ), +MNT3_MAPERRNO (INVAL ), +MNT3_MAPERRNO (NAMETOOLONG ), +MNT3_MAPERRNO (NOTSUPP ), +MNT3_MAPERRNO (SERVERFAULT ), +}; + +struct mountres { +int errno; +struct nfs_fh *fh; +}; +struct mnt_fhstatus {u32 status;struct nfs_fh *fh;@@ -179,6 +258,61 @@ static int xdr_decode_fhstatus(struct rpc_rqst *req, __be32 *p, return 0; } +/* +* RFC 1094: "A non-zero status indicates some sort of error. In this
+ * case, the status is a UNIX error number." This can be problematic
+ * if the server and client use different errno values for the same
+ * error.
+ *
+ * However, the OpenGroup XNFS spec provides a simple mapping that is
+ * independent of local errno values on the server and the client.
+ */
+static intdecode_status(struct xdr_stream *xdr, struct mountres *res)fs/nfs/mount_clnt.c +23
-0+{ +unsigned int i; +u32 status; +__be32 *p; + + p =xdr_inline_decode (xdr,sizeof (status)); +if (unlikely (p ==NULL )) +return -EIO ; + status =ntohl (*p); + +for (i =0 ; i <=ARRAY_SIZE (mnt_errtbl); i++) { +if (mnt_errtbl[i].status == status) { + res->errno = mnt_errtbl[i].errno; +return 0 ; + } + } + +dprintk ("NFS: unrecognized MNT status code: %u\n" , status); + res->errno = -EACCES ; +return 0 ; +} + +static int decode_fhs_status(struct xdr_stream *xdr, structmountres *res)
fs/nfs/mount_clnt.c +18
-0+{ +unsigned int i; +u32 status; +__be32 *p; + + p =xdr_inline_decode (xdr,sizeof (status)); +if (unlikely (p ==NULL )) +return -EIO ; + status =ntohl (*p); + +for (i =0 ; i <=ARRAY_SIZE (mnt3_errtbl); i++) { +if (mnt3_errtbl[i].status == status) { + res->errno = mnt3_errtbl[i].errno; +return 0 ; + } + } + +dprintk ("NFS: unrecognized MNT3 status code: %u\n" , status);Quoted 16 lines
Quoted 8 lines
fs/nfs/mount_clnt.c +4
-0+ res->errno = -EACCES ; +return 0 ; +} +static int xdr_decode_fhstatus3(struct
rpc_rqst*req,__be32*p,
structmnt_fhstatus*res)
{Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com--
Chuck Lever
chuck[dot]lever[at]oracle[dot]comSignature · 22 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com From: Chuck Lever <[email protected]> Subject: No Subject Check the length of the supplied dirpath, and see that it fits properly in the RPC buffer. Signed-off-by: Chuck Lever <[email protected]> [[email protected]: fixed up definition of encode_dirpath_sz] Signed-off-by: Trond Myklebust <[email protected]> --- fs/nfs/mount_clnt.c | 49 ++++++++++++++++++++++++++++++++++++++++++ ++----- 1 files changed, 44 insertions(+), 5 deletions(-)fs/nfs/mount_clnt.c +40
-0@@ -21,6 +21,21 @@#endif /* +* Defined by RFC 1094, section A.3; and RFC 1813, section 5.1.4 +*/ +#define MNTPATHLEN (1024) + +/* +* XDR data type sizes +*/ +#define encode_dirpath_sz (1 + XDR_QUADLEN(MNTPATHLEN)) + +/* +* XDR argument and result sizes +*/ +#define MNT_enc_dirpath_sz encode_dirpath_sz + +/* * Defined by RFC 1094, section A.5 */ enum {@@ -135,6 +150,31 @@ static int xdr_encode_dirpath(struct rpc_rqst *req, __be32 *p, return 0; } +static int encode_mntdirpath (struct xdr_stream *xdr,const char *pathname) +{ +const u32 pathname_len =strlen (pathname); +__be32 *p; + +if (unlikely (pathname_len >MNTPATHLEN )) +return -EIO ; + + p =xdr_reserve_space (xdr,sizeof (u32) + pathname_len); +if (unlikely (p ==NULL )) +return -EIO ; +xdr_encode_opaque (p, pathname, pathname_len); + +return 0 ; +} + +static int mnt_enc_dirpath (struct rpc_rqst *req,__be32 *p, +const char *dirpath) +{ +struct xdr_stream xdr; + +xdr_init_encode (&xdr, &req->rq_snd_buf, p); +return encode_mntdirpath (&xdr, dirpath); +} + static int xdr_decode_fhstatus(struct rpc_rqst *req, __be32 *p,struct
mnt_fhstatus*res)
{fs/nfs/mount_clnt.c +2
-3@@ -164,16 +204,15 @@ static int xdr_decode_fhstatus3(struct rpc_rqst *req, __be32 *p, return 0; } -#define MNT_dirpath_sz (1 + 256)#define MNT_fhstatus_sz (1 + 8)#define MNT_fhstatus3_sz (1 + 16)static struct rpc_procinfo mnt_procedures[] = { [MOUNTPROC_MNT ] = { .p_proc =MOUNTPROC_MNT , - .p_encode = (kxdrproc_t ) xdr_encode_dirpath, + .p_encode = (kxdrproc_t )mnt_enc_dirpath, .p_decode = (kxdrproc_t ) xdr_decode_fhstatus, - .p_arglen = MNT_dirpath_sz, + .p_arglen = MNT_enc_dirpath_sz, .p_replen = MNT_fhstatus_sz, .p_statidx =MOUNTPROC_MNT ,.p_name = "MOUNT",fs/nfs/mount_clnt.c +0
-0@@ -183,9 +222,9 @@ static struct rpc_procinfo mnt_procedures[] = {static struct rpc_procinfo mnt3_procedures[] = {
fs/nfs/mount_clnt.c static struct rpc_procinfo mnt_procedures[] = { · line 230
Quoted 10 lines
fs/nfs/mount_clnt.c +2
-2[MOUNTPROC3_MNT] = { .p_proc = MOUNTPROC3_MNT, - .p_encode = (kxdrproc_t) xdr_encode_dirpath, + .p_encode = (kxdrproc_t)mnt_enc_dirpath, .p_decode = (kxdrproc_t) xdr_decode_fhstatus3, - .p_arglen = MNT_dirpath_sz, + .p_arglen = MNT_enc_dirpath_sz, .p_replen = MNT_fhstatus3_sz, .p_statidx = MOUNTPROC3_MNT, .p_name = "MOUNT",
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
PATCH 5/8 NFS: add new file handle decoders to in-kernel mountd client
In reply to a message not in the archiveIntroduce xdr_stream-based XDR file handle decoders to the in-kernel mountd client. These are more careful than the existing decoder functions about buffer overflows and data type and range checking.
---
fs/nfs/mount_clnt.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-)
fs/nfs/mount_clnt.c +39 -0
@@ -31,6 +31,8 @@#define encode_dirpath_sz XDR_QUADLEN(sizeof(u32) + MNTPATHLEN)#define MNT_status_sz XDR_QUADLEN(sizeof(u32))#define MNT_fhs_status_sz XDR_QUADLEN(sizeof(u32)) +#define MNT_fhandle_sz XDR_QUADLEN(NFS2_FHSIZE) +#define MNT_fhandle3_sz XDR_QUADLEN(sizeof(u32) + NFS3_FHSIZE)/* * XDR argument and result sizes
@@ -290,6 +292,20 @@ static int decode_status(struct xdr_stream *xdr, struct mountres *res)return 0 ; } +static int decode_fhandle (struct xdr_stream *xdr,struct mountres *res) +{ +struct nfs_fh *fh = res->fh; +__be32 *p; + + p =xdr_inline_decode (xdr,NFS2_FHSIZE ); +if (unlikely (p ==NULL )) +return -EIO ; + + fh->size =NFS2_FHSIZE ; +memcpy (fh->data, p,NFS2_FHSIZE ); +return 0 ; +} +static int decode_fhs_status (struct xdr_stream *xdr,struct mountres *res) {unsigned int i;
@@ -313,6 +329,29 @@ static int decode_fhs_status(struct xdr_stream *xdr, struct mountres *res)return 0 ; } +static int decode_fhandle3 (struct xdr_stream *xdr,struct mountres *res) +{ +struct nfs_fh *fh = res->fh; +u32 size; +__be32 *p; + + p =xdr_inline_decode (xdr,sizeof (size)); +if (unlikely (p ==NULL )) +return -EIO ; + + size =ntohl (*p++); +if (size >NFS3_FHSIZE || size ==0 ) +return -EIO ; + + p =xdr_inline_decode (xdr, size); +if (unlikely (p ==NULL )) +return -EIO ; + + fh->size = size; +memcpy (fh->data, p, size); +return 0 ; +} +static int xdr_decode_fhstatus3 (struct rpc_rqst *req,__be32 *p,struct mnt_fhstatus *res) {
PATCH 6/8 NFS: add XDR decoder for mountd version 3 auth-flavor lists
In reply to a message not in the archiveIntroduce 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.
---
fs/nfs/internal.h | 6 ++++++ fs/nfs/mount_clnt.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 0 deletions(-)
fs/nfs/internal.h +6 -0
@@ -30,6 +30,12 @@ struct nfs_clone_mount { };/* +* Note: RFC 1813 doesn't limit the number of auth flavors that +* a server can return, so make something up. +*/ +#define NFS_MAX_SECFLAVORS (12) + +/* * In-kernel mount arguments */ struct nfs_parsed_mount_data {
fs/nfs/mount_clnt.c +38 -0
@@ -33,6 +33,8 @@#define MNT_fhs_status_sz XDR_QUADLEN(sizeof(u32))#define MNT_fhandle_sz XDR_QUADLEN(NFS2_FHSIZE)#define MNT_fhandle3_sz XDR_QUADLEN(sizeof(u32) + NFS3_FHSIZE) +#define MNT_authflav3_sz XDR_QUADLEN(sizeof(u32) + \ + NFS_MAX_SECFLAVORS * sizeof(u32))/* * XDR argument and result sizes
@@ -140,6 +142,8 @@ static struct {struct mountres {int errno;struct nfs_fh *fh; +unsigned int *auth_count; +rpc_authflavor_t *auth_flavors; };struct mnt_fhstatus {
@@ -352,6 +356,40 @@ static int decode_fhandle3(struct xdr_stream *xdr, struct mountres *res)return 0 ; } +static int decode_auth_flavors (struct xdr_stream *xdr,struct mountres *res) +{ +rpc_authflavor_t *flavors = res->auth_flavors; +unsigned int *count = res->auth_count; +u32 entries, i; +__be32 *p; + +if (*count ==0 ) +return 0 ; + + p =xdr_inline_decode (xdr,sizeof (entries)); +if (unlikely (p ==NULL )) +return -EIO ; + entries =ntohl (*p); +dprintk ("NFS: received %u auth flavors\n" , entries); +if (entries >NFS_MAX_SECFLAVORS ) + entries =NFS_MAX_SECFLAVORS ; + + p =xdr_inline_decode (xdr,sizeof (u32) * entries); +if (unlikely (p ==NULL )) +return -EIO ; + +if (entries > *count) + entries = *count; + +for (i =0 ; i < entries; i++) { + flavors[i] =ntohl (*p++); +dprintk ("NFS:\tflavor %u: %d\n" , i, flavors[i]); + } + *count = i; + +return 0 ; +} +static int xdr_decode_fhstatus3 (struct rpc_rqst *req,__be32 *p,struct mnt_fhstatus *res) {
PATCH 7/8 NFS: Update MNT and MNT3 reply decoding functions
In reply to a message not in the archiveSolder xdr_stream-based XDR decoding functions into the in-kernel mountd client that are more careful about checking data types and watching for buffer overflows. The new MNT3 decoder includes support for auth-flavor list decoding.
The "_sz" macro for MNT3 replies was missing the size of the file handle. I've added this back, and included the size of the auth flavor array.
---
fs/nfs/internal.h | 2 ++ fs/nfs/mount_clnt.c | 61 ++++++++++++++++++++++++++++++++++++++++----------- fs/nfs/nfsroot.c | 2 ++ fs/nfs/super.c | 2 ++ 4 files changed, 54 insertions(+), 13 deletions(-)
fs/nfs/internal.h +2 -0
@@ -83,6 +83,8 @@ struct nfs_mount_request {unsigned short protocol;struct nfs_fh *fh;int noresvport; +unsigned int *auth_flav_len; +rpc_authflavor_t *auth_flavs; };extern int nfs_mount (struct nfs_mount_request *info);
fs/nfs/mount_clnt.c +48 -13
118 lines not on this page · raw message
fs/nfs/nfsroot.c +2 -0
@@ -490,6 +490,7 @@ static int __init root_nfs_get_handle(void) {struct nfs_fh fh;struct sockaddr_in sin; +unsigned int auth_flav_len =0 ;struct nfs_mount_request request = { .sap = (struct sockaddr *)&sin, .salen =sizeof (sin),
@@ -499,6 +500,7 @@ static int __init root_nfs_get_handle(void) .protocol = (nfs_data.flags & NFS_MOUNT_TCP) ? XPRT_TRANSPORT_TCP : XPRT_TRANSPORT_UDP, .fh = &fh, + .auth_flav_len = &auth_flav_len, };int status;
fs/nfs/super.c +2 -0
@@ -1375,6 +1375,7 @@ out_security_failure:static int nfs_try_mount (struct nfs_parsed_mount_data *args,struct nfs_fh *root_fh) { +unsigned int auth_flavor_len =0 ;struct nfs_mount_request request = { .sap = (struct sockaddr *) &args->mount_server.address,
@@ -1382,6 +1383,7 @@ static int nfs_try_mount(struct nfs_parsed_mount_data *args, .protocol = args->mount_server.protocol, .fh = root_fh, .noresvport = args->flags & NFS_MOUNT_NORESVPORT, + .auth_flav_len = &auth_flavor_len, };int status;
PATCH 8/8 NFS: Remove unused XDR decoder functions
In reply to a message not in the archiveClean up: Remove xdr_decode_fhstatus() and xdr_decode_fhstatus3(), now that they are unused.
---
fs/nfs/mount_clnt.c | 29 ----------------------------- 1 files changed, 0 insertions(+), 29 deletions(-)
fs/nfs/mount_clnt.c +0 -29
@@ -257,18 +257,6 @@ static int mnt_enc_dirpath(struct rpc_rqst *req, __be32 *p,return encode_mntdirpath (&xdr, dirpath); } -static int xdr_decode_fhstatus (struct rpc_rqst *req,__be32 *p, -struct mnt_fhstatus *res) -{ -struct nfs_fh *fh = res->fh; - -if ((res->status =ntohl (*p++)) ==0 ) { - fh->size =NFS2_FHSIZE ; -memcpy (fh->data, p,NFS2_FHSIZE ); - } -return 0 ; -} -/* * RFC 1094: "A non-zero status indicates some sort of error. In this * case, the status is a UNIX error number." This can be problematic
@@ -428,23 +416,6 @@ static int mnt_dec_mountres3(struct rpc_rqst *req, __be32 *p,return decode_auth_flavors (&xdr, res); } -static int xdr_decode_fhstatus3 (struct rpc_rqst *req,__be32 *p, -struct mnt_fhstatus *res) -{ -struct nfs_fh *fh = res->fh; -unsigned size; - -if ((res->status =ntohl (*p++)) ==0 ) { - size =ntohl (*p++); -if (size <=NFS3_FHSIZE && size !=0 ) { - fh->size = size; -memcpy (fh->data, p, size); - }else - res->status = -EBADHANDLE ; - } -return 0 ; -} -static struct rpc_procinfo mnt_procedures[] = { [MOUNTPROC_MNT ] = { .p_proc =MOUNTPROC_MNT ,