All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nfs-utils: add mountproto= mount option to force mount protocol
@ 2007-06-22 14:27 Jeff Layton
  0 siblings, 0 replies; only message in thread
From: Jeff Layton @ 2007-06-22 14:27 UTC (permalink / raw)
  To: nfs

Recently some changes were made to mount.nfs to make mount.nfs use UDP
by default to talk to mountd. If someone specifies tcp or proto=tcp as
an option, then the communication with mountd is also done via TCP.
Most people can just remove these options to work around this since TCP
is the new default. If someone is using shared automount maps on a
network that hosts a mix of clients with different protocol defaults,
then they can't do this without making the old clients fall back to
using UDP.

This patch adds a new mount option "mountproto" that forces the client
to use a specific network protocol when talking to mountd, and updates
the nfs manpage to describe the new option. It should apply cleanly to
current nfs-utils git tree.

Signed-off-by: Jeff Layton <jlayton@redhat.com>

diff --git a/utils/mount/nfs.man b/utils/mount/nfs.man
index 673556c..bcc1a13 100644
--- a/utils/mount/nfs.man
+++ b/utils/mount/nfs.man
@@ -170,6 +170,20 @@ for hosts that can run multiple NFS servers.
 The default value is 100005 which is the standard RPC
 mount daemon program number.
 .TP 1.5i
+.I mountproto=n
+Force the mount call to use a specific network protocol
+independent of the NFS protocol used.
+Valid protocol types are
+.IR udp
+and
+.IR tcp .
+The default is to use UDP and then fall back to TCP if the
+server doesn't respond. If the
+.IR proto=tcp
+or
+.IR tcp
+options are specified, then the default is to just use TCP.
+.TP 1.5i
 .I mountvers=n
 Use an alternate RPC version number to contact the
 mount daemon on the remote host.  This option is useful
diff --git a/utils/mount/nfsmount.c b/utils/mount/nfsmount.c
index 815064a..ec54c99 100644
--- a/utils/mount/nfsmount.c
+++ b/utils/mount/nfsmount.c
@@ -547,6 +547,7 @@ parse_options(char *old_opts, struct nfs_mount_data *data,
 	struct sockaddr_in *mnt_saddr = &mnt_server->saddr;
 	struct pmap *mnt_pmap = &mnt_server->pmap;
 	struct pmap *nfs_pmap = &nfs_server->pmap;
+	unsigned long mountproto = 0;
 	int len;
 	char *opt, *opteq, *p, *opt_b;
 	char *mounthost = NULL;
@@ -714,6 +715,18 @@ parse_options(char *old_opts, struct nfs_mount_data *data,
 				else
 					strncpy(data->context, context,
 							NFS_MAX_CONTEXT_LEN);
+			} else if  (!strcmp(opt, "mountproto")) {
+				if (!strcmp(opteq+1, "udp"))
+					mountproto = IPPROTO_UDP;
+#if NFS_MOUNT_VERSION >= 2
+				else if (!strcmp(opteq+1, "tcp") &&
+					   nfs_mount_version > 2)
+					mountproto = IPPROTO_TCP;
+#endif
+				else if (sloppy)
+					continue;
+				else
+					goto bad_parameter;
  			} else if (sloppy)
 				continue;
 			else
@@ -822,6 +835,11 @@ parse_options(char *old_opts, struct nfs_mount_data *data,
 		}
 		strcat(new_opts, cbuf);
 	}
+
+	/* override mount protocol if it was specified */
+	if (mountproto)
+		mnt_pmap->pm_prot = mountproto;
+
 	/* See if the nfs host = mount host. */
 	if (mounthost) {
 		if (!nfs_gethostbyname(mounthost, mnt_saddr))

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2007-06-22 14:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-22 14:27 [PATCH] nfs-utils: add mountproto= mount option to force mount protocol Jeff Layton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.