* [PATCH nfs-utils] nfsdctl: inspect only the command request policy
@ 2026-10-26 20:12 Giuseppe Piscitelli
0 siblings, 0 replies; only message in thread
From: Giuseppe Piscitelli @ 2026-10-26 20:12 UTC (permalink / raw)
To: linux-nfs
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-26 20:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-26 20:12 [PATCH nfs-utils] nfsdctl: inspect only the command request policy Giuseppe Piscitelli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox