Linux NFS development
 help / color / mirror / Atom feed
From: Steve Dickson <steved@redhat.com>
To: Linux NFS Mailing list <linux-nfs@vger.kernel.org>
Subject: [PATCH v2 3/3] mount: Remove NFS v2 support from mount.nfs
Date: Wed,  8 Dec 2021 11:30:57 -0500	[thread overview]
Message-ID: <20211208163057.954500-4-steved@redhat.com> (raw)
In-Reply-To: <20211208163057.954500-1-steved@redhat.com>

This patch removes the ability to do NFS v2
mounts. They will now fail with EOPNOTSUPP.

Signed-off-by: Steve Dickson <steved@redhat.com>
---
 utils/mount/configfile.c  |  2 +-
 utils/mount/network.c     |  4 ++--
 utils/mount/nfsmount.conf |  2 +-
 utils/mount/stropts.c     | 10 +++++++++-
 4 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/utils/mount/configfile.c b/utils/mount/configfile.c
index 3d3684ef..1d88cbfc 100644
--- a/utils/mount/configfile.c
+++ b/utils/mount/configfile.c
@@ -71,7 +71,7 @@ struct mnt_alias {
 int mnt_alias_sz = (sizeof(mnt_alias_tab)/sizeof(mnt_alias_tab[0]));
 
 static const char *version_keys[] = {
-	"v2", "v3", "v4", "vers", "nfsvers", "minorversion", NULL
+	"v3", "v4", "vers", "nfsvers", "minorversion", NULL
 };
 
 static int strict;
diff --git a/utils/mount/network.c b/utils/mount/network.c
index 35261171..bfda5c41 100644
--- a/utils/mount/network.c
+++ b/utils/mount/network.c
@@ -97,7 +97,7 @@ static const char *nfs_transport_opttbl[] = {
 };
 
 static const char *nfs_version_opttbl[] = {
-	"v2",
+	"v2", /* no longer supported */
 	"v3",
 	"v4",
 	"vers",
@@ -1286,7 +1286,7 @@ nfs_nfs_version(char *type, struct mount_options *options, struct nfs_version *v
 	else if (found < 0)
 		return 1;
 	else if (found <= 2 ) {
-		/* v2, v3, v4 */
+		/* v3, v4 */
 		version_val = version_key + 1;
 		version->v_mode = V_SPECIFIC;
 	} else if (found > 2 ) {
diff --git a/utils/mount/nfsmount.conf b/utils/mount/nfsmount.conf
index 6bdc225a..342063f7 100644
--- a/utils/mount/nfsmount.conf
+++ b/utils/mount/nfsmount.conf
@@ -28,7 +28,7 @@
 # This statically named section defines global mount 
 # options that can be applied on all NFS mount.
 #
-# Protocol Version [2,3,4]
+# Protocol Version [3,4]
 # This defines the default protocol version which will
 # be used to start the negotiation with the server.
 # Defaultvers=4
diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
index fa67a66f..3c4e218a 100644
--- a/utils/mount/stropts.c
+++ b/utils/mount/stropts.c
@@ -357,6 +357,7 @@ static int nfs_insert_sloppy_option(struct mount_options *options)
 
 static int nfs_set_version(struct nfsmount_info *mi)
 {
+
 	if (!nfs_nfs_version(mi->type, mi->options, &mi->version))
 		return 0;
 
@@ -1016,7 +1017,6 @@ static int nfs_try_mount(struct nfsmount_info *mi)
 	}
 
 	switch (mi->version.major) {
-		case 2:
 		case 3:
 			result = nfs_try_mount_v3v2(mi, FALSE);
 			break;
@@ -1247,6 +1247,14 @@ static int nfsmount_start(struct nfsmount_info *mi)
 	if (!nfs_validate_options(mi))
 		return EX_FAIL;
 
+	/* 
+	 * NFS v2 has been deprecated
+	 */
+	if (mi->version.major == 2) {
+		mount_error(mi->spec, mi->node, EOPNOTSUPP);
+		return EX_FAIL;
+	}
+
 	/*
 	 * Avoid retry and negotiation logic when remounting
 	 */
-- 
2.31.1


  parent reply	other threads:[~2021-12-08 16:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-08 16:30 [PATCH v2 0/3] Remove NFS v2 support from the client and server Steve Dickson
2021-12-08 16:30 ` [PATCH 1/3] nfsd: Remove the ability to enable NFS v2 Steve Dickson
2021-12-08 16:30 ` [PATCH 2/3] nfs.man: Remove references to NFS v2 from the man pages Steve Dickson
2021-12-08 16:30 ` Steve Dickson [this message]
2022-01-10 15:06 ` [PATCH v2 0/3] Remove NFS v2 support from the client and server Steve Dickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211208163057.954500-4-steved@redhat.com \
    --to=steved@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox