From patchwork Mon Jan 13 23:13:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Mayhew X-Patchwork-Id: 13938210 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0ED81F9ED5 for ; Mon, 13 Jan 2025 23:13:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736810008; cv=none; b=JgQbu1K7Qw11VgrK+z4qEvdMPA/Bx3F9r/HFOfY8iFNxlmOF5TkPLLIx7NygGdeQEFYORaO4p5NPOzPAwsXs3+pHf5q2RkeFhIIMyd7GuognwZK5OaZoVV3uVc9y0t1d9zU0rFcBHBmTvzNhc0mB97Yp32FavjD0ONSW9tOAB9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736810008; c=relaxed/simple; bh=uvnlJVJ9Pe8jma4qd+CjRbhn5BfP7p/0sfujal2qTC8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eGZ1SeVDxEEkvrMUYrIQYEKJh0NNyNxkGhqplQ3HVWkPW8Kdk9/IK61PsQK9U5HEayxKfyxhhMQY9+DdYLITlUG4iTow3QlaJrq0xqIGy3WQ/Aqsid0s27sdrqulPbTBVZAUcHT+IgCGcjbx5kyzP1SO7omcfBCNTtmfRV+FwYE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=bW9Zznb1; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bW9Zznb1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736810005; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RdIDgQ/Eo5aILZciaFRhUOxgFcG0RvZdN4Jl3Jl0UN8=; b=bW9Zznb1CXJHXCk1Mc/cSfUcBUbVsXOsbTUuZ8R20okOM/3J/2irO0Pi8w7UgUxdmErSTm 03+2pR2/bxEbAaqu+ylRdTzw0+U3NURR7FnrFrFkM59JCUhSXoc2Mr309+rytSRXhTu4t5 8YDvz+0TjC2l0aCGUwGSx9mcU4mO5qg= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-178-odIo0wtfNdGngZWSIOw5kw-1; Mon, 13 Jan 2025 18:13:22 -0500 X-MC-Unique: odIo0wtfNdGngZWSIOw5kw-1 X-Mimecast-MFC-AGG-ID: odIo0wtfNdGngZWSIOw5kw Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4A6E219560B0; Mon, 13 Jan 2025 23:13:21 +0000 (UTC) Received: from aion.redhat.com (unknown [10.22.64.152]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1D36530001BE; Mon, 13 Jan 2025 23:13:21 +0000 (UTC) Received: from aion.redhat.com (localhost [IPv6:::1]) by aion.redhat.com (Postfix) with ESMTP id BCB212EA88D; Mon, 13 Jan 2025 18:13:19 -0500 (EST) From: Scott Mayhew To: steved@redhat.com Cc: jlayton@kernel.org, yoyang@redhat.com, linux-nfs@vger.kernel.org Subject: [nfs-utils PATCH v3 1/3] nfsdctl: tweak the version subcommand behavior Date: Mon, 13 Jan 2025 18:13:17 -0500 Message-ID: <20250113231319.951885-2-smayhew@redhat.com> In-Reply-To: <20250113231319.951885-1-smayhew@redhat.com> References: <20250113231319.951885-1-smayhew@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 The section for the 'nfsdctl version' subcommand on the man page states that the minorversion is optional, and if omitted it will cause all minorversions to be enabled/disabled. Make it work that way. Signed-off-by: Scott Mayhew --- utils/nfsdctl/nfsdctl.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/utils/nfsdctl/nfsdctl.c b/utils/nfsdctl/nfsdctl.c index 003daba5..88b728e0 100644 --- a/utils/nfsdctl/nfsdctl.c +++ b/utils/nfsdctl/nfsdctl.c @@ -783,6 +783,19 @@ static int update_nfsd_version(int major, int minor, bool enabled) return -EINVAL; } +static int get_max_minorversion(void) +{ + int i, max = 0; + + for (i = 0; i < MAX_NFS_VERSIONS; ++i) { + if (nfsd_versions[i].major == 0) + break; + if (nfsd_versions[i].major == 4 && nfsd_versions[i].minor > max) + max = nfsd_versions[i].minor; + } + return max; +} + static void version_usage(void) { printf("Usage: %s version { {+,-}major.minor } ...\n", taskname); @@ -800,7 +813,7 @@ static void version_usage(void) static int version_func(struct nl_sock *sock, int argc, char ** argv) { - int ret, i; + int ret, i, j, max_minor; /* help is only valid as first argument after command */ if (argc > 1 && @@ -814,6 +827,8 @@ static int version_func(struct nl_sock *sock, int argc, char ** argv) return ret; if (argc > 1) { + max_minor = get_max_minorversion(); + for (i = 1; i < argc; ++i) { int ret, major, minor = 0; char sign = '\0', *str = argv[i]; @@ -837,9 +852,22 @@ static int version_func(struct nl_sock *sock, int argc, char ** argv) return -EINVAL; } - ret = update_nfsd_version(major, minor, enabled); - if (ret) - return ret; + /* + * The minorversion field is optional. If omitted, it should + * cause all the minor versions for that major version to be + * enabled/disabled. + */ + if (major == 4 && ret == 2) { + for (j = 0; j <= max_minor; ++j) { + ret = update_nfsd_version(major, j, enabled); + if (ret) + return ret; + } + } else { + ret = update_nfsd_version(major, minor, enabled); + if (ret) + return ret; + } } return set_nfsd_versions(sock); } From patchwork Mon Jan 13 23:13:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Mayhew X-Patchwork-Id: 13938211 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0E7E1F9ECE for ; Mon, 13 Jan 2025 23:13:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736810008; cv=none; b=UlTaEFVB4lEXjSfZ97Lw5cYZOxMGU4LAT75usXDyUDb3gV9f6K8KRFrz5GP4weEPUEY91Rj4cFlf8+slO+n5qh5XSyRwQ8bxtdH94gEoagvJ7I9koij2DWDbSUFrq3tYRYmXIPW+PvKCOjYZEl5n/6auk/HxxEOGDWXx+5VUgak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736810008; c=relaxed/simple; bh=nEqeSqXcwXULdwjNsru0XHWuK09sT9zO1oRd8riTGH8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RP4dwKDJO2LeNRuIOTHfe+kAxJZVCnPh3MK+2Wp+kuI5ZduPqx/O/ldAm/YOq4Z6Kq2Hmq4lAScT3A7/foQQBdFI6i6o2Mba4PEV4yYxdWSbgdOcpFbMCgL1cHEatojYJX7DAfaAJeadTvfcj7YZtNt7n42RJy8Tq3EXXo7Asoo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LIKzk9UY; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LIKzk9UY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736810005; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aUyWMIMIxmSIACL9HKmHg5znT0xyGnVWjVAOAfPZcQE=; b=LIKzk9UY/55g+aaDnOlFnmrMe93mnUZl2vn1iB+SjttbDJxdhjUNjcGucDJfxUKnuCzfuf FbtreGbx72ru7ZhKNsPEqW5lzttxEcwT2M8m8HvDk4qYcebTqJ0fpTJcQolKDN+HpAUmwv 9ECpUvF7VNrRsB8SngO4XkdacfW1kQ4= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-178-mfUSi9BmMLurEfeojLazhQ-1; Mon, 13 Jan 2025 18:13:22 -0500 X-MC-Unique: mfUSi9BmMLurEfeojLazhQ-1 X-Mimecast-MFC-AGG-ID: mfUSi9BmMLurEfeojLazhQ Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 700801956053; Mon, 13 Jan 2025 23:13:21 +0000 (UTC) Received: from aion.redhat.com (unknown [10.22.64.152]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 43E7319560A3; Mon, 13 Jan 2025 23:13:21 +0000 (UTC) Received: from aion.redhat.com (localhost [IPv6:::1]) by aion.redhat.com (Postfix) with ESMTP id C95E92EA88E; Mon, 13 Jan 2025 18:13:19 -0500 (EST) From: Scott Mayhew To: steved@redhat.com Cc: jlayton@kernel.org, yoyang@redhat.com, linux-nfs@vger.kernel.org Subject: [nfs-utils PATCH v3 2/3] nfsdctl: tweak the nfs.conf version handling Date: Mon, 13 Jan 2025 18:13:18 -0500 Message-ID: <20250113231319.951885-3-smayhew@redhat.com> In-Reply-To: <20250113231319.951885-1-smayhew@redhat.com> References: <20250113231319.951885-1-smayhew@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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. Finally, add a check so that 'nfsdctl autostart' will error out if no versions or minorversions are enabled. Signed-off-by: Scott Mayhew --- utils/nfsdctl/nfsdctl.c | 50 ++++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/utils/nfsdctl/nfsdctl.c b/utils/nfsdctl/nfsdctl.c index 88b728e0..78200624 100644 --- a/utils/nfsdctl/nfsdctl.c +++ b/utils/nfsdctl/nfsdctl.c @@ -1457,15 +1457,47 @@ read_nfsd_conf(void) xlog_set_debug("nfsd"); } -static void configure_versions(void) +static int configure_versions(void) { - bool v4 = conf_get_bool("nfsd", "vers4", true); + int i, j, max_minor = get_max_minorversion(); + bool found_one = false; + char tag[20]; + + 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); + } + + for (i = 0; i < MAX_NFS_VERSIONS; ++i) { + if (nfsd_versions[i].enabled) { + found_one = true; + break; + } + } + if (!found_one) { + xlog(L_ERROR, "no version specified"); + return 1; + } + return 0; } static void configure_listeners(void) @@ -1556,7 +1588,9 @@ static int autostart_func(struct nl_sock *sock, int argc, char ** argv) ret = fetch_nfsd_versions(sock); if (ret) return ret; - configure_versions(); + ret = configure_versions(); + if (ret) + return ret; ret = set_nfsd_versions(sock); if (ret) return ret; From patchwork Mon Jan 13 23:13:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Mayhew X-Patchwork-Id: 13938212 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C13431F9EDA for ; Mon, 13 Jan 2025 23:13:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736810008; cv=none; b=VsWMNK7Azi/VAmyO/OuA5TwcM/N4Bu5fjxCtpCKjcSpkbrMq3Wxxa5oOViyVlyJkc/0sgASmxQawGpbIZaDMnqWws9A02/jKYkX5T8Pa72kIiNVtKRUrzbAjzhj2TD/Wld4eE+jCkVk/inweM6mWS6zMW69kIWAT4JEhqTton14= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736810008; c=relaxed/simple; bh=XhgFMIFwVqUTEs6YxgV9n7oiBr1tqvuPCo3S6zh7Lks=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JwfnfEaBu+cAkPWRk8KJkezl90BRjxaVIoovqAhkKjDlHJTnMyzyjVip2GhtoyLGhikP6FR06EB3epH9CWEusLu536Jtc05ANrNYbtoRckggtcJZyll7J2A+CcINA4KRRkVKIDiVaW8hk+bwV//gqCRjMBEJ/lAdeCuAZTsFJA0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=VSrfczTE; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VSrfczTE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736810005; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=49SXEE6H2w3mYGYc3t04GkCD6JiGs9OgABSGQCy3gZM=; b=VSrfczTEj/SxYpwlb32PFlyQVI+RQdmVSIZUcQBpRGcj9LcsC3JWsdzSxZoCMNwSghR7zQ kVJD3UulfbOhXisiXCJJgnET+5pmUltQcet1SrM+ebQ88BUTSnwsUNqFy6Bb859Bu0R5Th z6f78tzYN5HWi6Hn9ghD5lKiLiyolPA= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-511-Wku_ZuM7On6ScdR52z5ajQ-1; Mon, 13 Jan 2025 18:13:22 -0500 X-MC-Unique: Wku_ZuM7On6ScdR52z5ajQ-1 X-Mimecast-MFC-AGG-ID: Wku_ZuM7On6ScdR52z5ajQ Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 832D01956048; Mon, 13 Jan 2025 23:13:21 +0000 (UTC) Received: from aion.redhat.com (unknown [10.22.64.152]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 540F319560BC; Mon, 13 Jan 2025 23:13:21 +0000 (UTC) Received: from aion.redhat.com (localhost [IPv6:::1]) by aion.redhat.com (Postfix) with ESMTP id D615C2EA88F; Mon, 13 Jan 2025 18:13:19 -0500 (EST) From: Scott Mayhew To: steved@redhat.com Cc: jlayton@kernel.org, yoyang@redhat.com, linux-nfs@vger.kernel.org Subject: [nfs-utils PATCH v3 3/3] nfsd: fix version sanity check Date: Mon, 13 Jan 2025 18:13:19 -0500 Message-ID: <20250113231319.951885-4-smayhew@redhat.com> In-Reply-To: <20250113231319.951885-1-smayhew@redhat.com> References: <20250113231319.951885-1-smayhew@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 rpc.nfsd's version sanity check needs to check both the major and minor versions before failing with a "no version specified" error. Signed-off-by: Scott Mayhew --- utils/nfsd/nfsd.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/utils/nfsd/nfsd.c b/utils/nfsd/nfsd.c index f787583e..a4056499 100644 --- a/utils/nfsd/nfsd.c +++ b/utils/nfsd/nfsd.c @@ -68,7 +68,7 @@ read_nfsd_conf(void) int main(int argc, char **argv) { - int count = NFSD_NPROC, c, i, error = 0, portnum, fd, found_one; + int count = NFSD_NPROC, c, i, j, error = 0, portnum, fd, found_one; char *p, *progname, *port, *rdma_port = NULL; char **haddr = NULL; char *scope = NULL; @@ -330,11 +330,30 @@ main(int argc, char **argv) exit(1); } - /* make sure that at least one version is enabled */ + /* + * Make sure that at least one version is enabled. Note that we might + * need to check the minorvers bit field twice - first while handling + * major version 4 in versbits, and again if no major verions were + * enabled in versbits. + */ found_one = 0; - for (c = NFSD_MINVERS; c <= NFSD_MAXVERS; c++) { - if (NFSCTL_VERISSET(versbits, c)) - found_one = 1; + for (i = NFSD_MINVERS; i <= NFSD_MAXVERS; i++) { + if (NFSCTL_VERISSET(versbits, i)) { + if (i == 4) { + for (j = NFS4_MINMINOR; j <= NFS4_MAXMINOR; j++) { + if (NFSCTL_MINORISSET(minorvers, j)) + found_one = 1; + } + } else { + found_one = 1; + } + } + } + if (!found_one) { + for (i = NFS4_MINMINOR; i <= NFS4_MAXMINOR; i++) { + if (NFSCTL_MINORISSET(minorvers, i)) + found_one = 1; + } } if (!found_one) { xlog(L_ERROR, "no version specified");