cast_status folds internal lock-daemon sentinels into NLMv1/v3
wire status codes for the v3 reply path. Two variants have
existed since the original kernel import: a strict allowlist
under CONFIG_LOCKD_V4 and a sentinel-translation form for the
!CONFIG_LOCKD_V4 build. The split was never grounded in a
behavioural difference -- nlmsvc_testlock and nlmsvc_lock,
which feed cast_status, return the same set of values in both
configurations -- and recent xdrgen conversions have narrowed
the caller set further: nlm__int__stale_fh and nlm__int__failed
are now translated at their point of origin in nlm3svc_lookup_file,
and the cast_status wraps around nlmsvc_cancel_blocked and
nlmsvc_unlock have been dropped because those functions return
only wire codes.
Collapse the two variants into one. The unified form keeps the
CONFIG_LOCKD_V4 arm's allowlist, retains the nlm__int__deadlock
translation, and folds anything else to nlm_lck_denied_nolocks
after a pr_warn_once so an unexpected sentinel from a future
refactor remains visible in the kernel log instead of being
silently passed to the wire encoder.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
return nlm_granted;
}
-#ifdef CONFIG_LOCKD_V4
static inline __be32 cast_status(__be32 status)
{
switch (status) {
status = nlm_lck_denied;
break;
default:
+ pr_warn_once("lockd: unhandled internal status %u\n",
+ be32_to_cpu(status));
status = nlm_lck_denied_nolocks;
- }
-
- return status;
-}
-#else
-static inline __be32 cast_status(__be32 status)
-{
- switch (status) {
- case nlm__int__deadlock:
- status = nlm_lck_denied;
- break;
- case nlm__int__stale_fh:
- case nlm__int__failed:
- status = nlm_lck_denied_nolocks;
- break;
- default:
- if (be32_to_cpu(status) > be32_to_cpu(nlm__int__drop_reply))
- pr_warn_once("lockd: unhandled internal status %u\n",
- be32_to_cpu(status));
break;
}
return status;
}
-#endif
/**
* nlmsvc_proc_null - NULL: Test for presence of service