Skip to contentSkip to conversation

NFS: suppressing showing of default mount port value in /proc fixed

PATCH Superseded Stanislav Kinsbursky 2 participants 2 messages Dec 6, 2010 – Dec 7, 2010

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 NFS: suppressing showing of default mount port value in /proc fixed

Update: added check for zero value as it was before (note: can't simply check mountd_port for positive value because it's typeof unsigned short)

Default value for mount server port is set to NFS_UNSPEC_PORT (-1) and will not be changed during parsing mount options for mound data version 6. This default value will be showed for mountport in /proc/mounts always since current default check is for zero value. This small mistake leads to big problem, because during umount.nfs execution from old user-space utils (at least nfs-utils 1.0.9) this value will be used as the server port to connect to. This request will be rejected (since port is 65535) and thus nfs mount point can't be unmounted.

Note from Chuck Lever ([email protected]): this is only possible if /etc/mtab is a link to /proc/mounts. Not all systems have this configuration.

---
 fs/nfs/super.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
fs/nfs/super.c +3 -1
index 6d6e21d..449024f 100644
@@ -681,7 +681,9 @@ static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss,
 
 	if (nfss->mountd_version || showdefaults)
 		seq_printf(m, ",mountvers=%u", nfss->mountd_version);
-	if (nfss->mountd_port || showdefaults)
+	if ((nfss->mountd_port &&
+		nfss->mountd_port != (unsigned short)NFS_UNSPEC_PORT) || 
+		showdefaults)
 		seq_printf(m, ",mountport=%u", nfss->mountd_port);
 
 	nfs_show_mountd_netid(m, nfss, showdefaults);
#1 lore raw
Quoted 25 lines · Stanislav Kinsbursky

Update: added check for zero value as it was before (note: can't simply check mountd_port for positive value because it's typeof unsigned short)

Default value for mount server port is set to NFS_UNSPEC_PORT (-1) and will not be changed during parsing mount options for mound data version 6. This default value will be showed for mountport in /proc/mounts always since current default check is for zero value. This small mistake leads to big problem, because during umount.nfs execution from old user-space utils (at least nfs-utils 1.0.9) this value will be used as the server port to connect to. This request will be rejected (since port is 65535) and thus nfs mount point can't be unmounted.

Note from Chuck Lever ([email protected]): this is only possible if /etc/mtab is a link to /proc/mounts. Not all systems have this configuration.

---
 fs/nfs/super.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
fs/nfs/super.c +0 -0
index 6d6e21d..449024f 100644

fs/nfs/super.c static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss, · line 689

Quoted 10 lines
fs/nfs/super.c +3 -1
@@ -681,7 +681,9 @@ static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss,
 
 	if (nfss->mountd_version || showdefaults)
 		seq_printf(m, ",mountvers=%u", nfss->mountd_version);
-	if (nfss->mountd_port || showdefaults)
+	if ((nfss->mountd_port &&
+		nfss->mountd_port != (unsigned short)NFS_UNSPEC_PORT) || 
+		showdefaults)
 		seq_printf(m, ",mountport=%u", nfss->mountd_port);
 
 	nfs_show_mountd_netid(m, nfss, showdefaults);

This patch needs a 'Signed-off-by:' before I can apply it.

Cheers
Trond

Signature · 6 lines
Trond Myklebust
Linux NFS client maintainer

NetApp
[email protected]
www.netapp.com