From: Giuseppe Piscitelli <ooonea@gmail.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH nfs-utils] nfsdctl: inspect only the command request policy
Date: Mon, 26 Oct 2026 21:12:36 +0100 [thread overview]
Message-ID: <20261026201258.663687-1-ooonea@gmail.com> (raw)
CTRL_CMD_GETPOLICY also describes nested attribute policies. Counting
those attributes as command capabilities can enable unsupported flags.
Select the do-operation policy index before computing its maximum, and
keep that index across dump messages.
Signed-off-by: Giuseppe Piscitelli <ooonea@gmail.com>
Assisted-by: OpenAI Codex
---
A four-case callback harness passed with this change (one case passed
before). An isolated Linux 7.3 VM passed nfsdctl threads 0/autostart and
NFSv3/v4.2 write/read, sync and root-squash checks with nfs-utils 3.1.1.
These results are from October 23; no new build or runtime test was run.
utils/nfsdctl/nfsdctl.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/utils/nfsdctl/nfsdctl.c b/utils/nfsdctl/nfsdctl.c
index 505b38d..67e2a0b 100644
--- a/utils/nfsdctl/nfsdctl.c
+++ b/utils/nfsdctl/nfsdctl.c
@@ -561,10 +561,15 @@ static int nfsd_nl_family_setup(struct nl_sock *sock)
return nfsd_nl_family;
}
+struct nfsd_cmd_policy {
+ int *max_nlattr;
+ int policy_index;
+};
+
static int getpolicy_handler(struct nl_msg *msg, void *arg)
{
struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
- int *max_nlattr = arg;
+ struct nfsd_cmd_policy *policy = arg;
struct nlattr *attr;
int rem;
@@ -572,13 +577,23 @@ static int getpolicy_handler(struct nl_msg *msg, void *arg)
struct nlattr *a, *b;
int i, j;
+ if (nla_type(attr) == CTRL_ATTR_OP_POLICY) {
+ nla_for_each_nested(a, attr, i) {
+ b = nla_find(nla_data(a), nla_len(a),
+ CTRL_ATTR_POLICY_DO);
+ if (b)
+ policy->policy_index = nla_get_u32(b);
+ }
+ }
if (nla_type(attr) == CTRL_ATTR_POLICY) {
nla_for_each_nested(a, attr, i) {
+ if (nla_type(a) != policy->policy_index)
+ continue;
nla_for_each_nested(b, a, j) {
int idx = nla_type(b);
- if (*max_nlattr < idx)
- *max_nlattr = idx;
+ if (*policy->max_nlattr < idx)
+ *policy->max_nlattr = idx;
}
}
}
@@ -589,6 +604,7 @@ static int getpolicy_handler(struct nl_msg *msg, void *arg)
static int query_nfsd_nl_cmd_policy(struct nl_sock *sock, int cmd,
int *max_nlattr)
{
+ struct nfsd_cmd_policy policy = { max_nlattr, -1 };
struct genlmsghdr *ghdr;
struct nlmsghdr *nlh;
struct nl_msg *msg;
@@ -625,7 +641,7 @@ static int query_nfsd_nl_cmd_policy(struct nl_sock *sock, int cmd,
nl_cb_err(cb, NL_CB_CUSTOM, error_handler, &ret);
nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, &ret);
nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &ret);
- nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, getpolicy_handler, max_nlattr);
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, getpolicy_handler, &policy);
while (ret > 0)
nl_recvmsgs(sock, cb);
--
2.54.0
reply other threads:[~2026-10-26 20:13 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261026201258.663687-1-ooonea@gmail.com \
--to=ooonea@gmail.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