diff mbox series

[nfs-utils,v2,2/2] nfsdctl: tweak the nfs.conf version handling

Message ID 20250110201746.869995-3-smayhew@redhat.com (mailing list archive)
State Handled Elsewhere
Headers show
Series nfsdctl version handling fixes | expand

Commit Message

Scott Mayhew Jan. 10, 2025, 8:17 p.m. UTC
I noticed I was getting different results when comparing nfsdctl's
config file handling versus rpc.nfsd's.

First, the vers4 config option was being treated as a mask, e.g. if
vers4=n and vers4.2=y then end result was still that all minorversions
were disabled.  Change it so that vers4=n would initially toggle off all
minorversions, but individual v4.x=y would turn that minorversion back
on.

Second, don't make assumptions about what default should be passed to
conf_get_bool.  Instead, test both possible values and only update the
nfsd_versions array if an option was explicitly specified.

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
---
 utils/nfsdctl/nfsdctl.c | 33 +++++++++++++++++++++++++++------
 1 file changed, 27 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/utils/nfsdctl/nfsdctl.c b/utils/nfsdctl/nfsdctl.c
index 38c22225..49de55ab 100644
--- a/utils/nfsdctl/nfsdctl.c
+++ b/utils/nfsdctl/nfsdctl.c
@@ -1305,13 +1305,34 @@  read_nfsd_conf(void)
 
 static void configure_versions(void)
 {
-	bool v4 = conf_get_bool("nfsd", "vers4", true);
+	int i, j, max_minor;
+	char tag[20];
+
+	max_minor = get_max_minorversion();
+
+	for (i = 2; i <= 4; ++i) {
+		sprintf(tag, "vers%d", i);
+		if (!conf_get_bool("nfsd", tag, true)) {
+			update_nfsd_version(i, 0, false);
+			if (i == 4)
+				for (j = 0; j <= max_minor; ++j)
+					update_nfsd_version(4, j, false);
+		}
+		if (conf_get_bool("nfsd", tag, false)) {
+			update_nfsd_version(i, 0, true);
+			if (i == 4)
+				for (j = 0; j <= max_minor; ++j)
+					update_nfsd_version(4, j, true);
+		}
+	}
 
-	update_nfsd_version(2, 0, conf_get_bool("nfsd", "vers2", false));
-	update_nfsd_version(3, 0, conf_get_bool("nfsd", "vers3", true));
-	update_nfsd_version(4, 0, v4 && conf_get_bool("nfsd", "vers4.0", true));
-	update_nfsd_version(4, 1, v4 && conf_get_bool("nfsd", "vers4.1", true));
-	update_nfsd_version(4, 2, v4 && conf_get_bool("nfsd", "vers4.2", true));
+	for (i = 0; i <= max_minor; ++i) {
+		sprintf(tag, "vers4.%d", i);
+		if (!conf_get_bool("nfsd", tag, true))
+			update_nfsd_version(4, i, false);
+		if (conf_get_bool("nfsd", tag, false))
+			update_nfsd_version(4, i, true);
+	}
 }
 
 static void configure_listeners(void)