mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-24 13:30:10 +07:00
b24413180f
Many source files in the tree are missing licensing information, which makes it harder for compliance tools to determine the correct license. By default all files without license information are under the default license of the kernel, which is GPL version 2. Update the files which contain no license information with the 'GPL-2.0' SPDX license identifier. The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. This patch is based on work done by Thomas Gleixner and Kate Stewart and Philippe Ombredanne. How this work was done: Patches were generated and checked against linux-4.14-rc6 for a subset of the use cases: - file had no licensing information it it. - file was a */uapi/* one with no licensing information in it, - file was a */uapi/* one with existing licensing information, Further patches will be generated in subsequent months to fix up cases where non-standard license headers were used, and references to license had to be inferred by heuristics based on keywords. The analysis to determine which SPDX License Identifier to be applied to a file was done in a spreadsheet of side by side results from of the output of two independent scanners (ScanCode & Windriver) producing SPDX tag:value files created by Philippe Ombredanne. Philippe prepared the base worksheet, and did an initial spot review of a few 1000 files. The 4.13 kernel was the starting point of the analysis with 60,537 files assessed. Kate Stewart did a file by file comparison of the scanner results in the spreadsheet to determine which SPDX license identifier(s) to be applied to the file. She confirmed any determination that was not immediately clear with lawyers working with the Linux Foundation. Criteria used to select files for SPDX license identifier tagging was: - Files considered eligible had to be source code files. - Make and config files were included as candidates if they contained >5 lines of source - File already had some variant of a license header in it (even if <5 lines). All documentation files were explicitly excluded. The following heuristics were used to determine which SPDX license identifiers to apply. - when both scanners couldn't find any license traces, file was considered to have no license information in it, and the top level COPYING file license applied. For non */uapi/* files that summary was: SPDX license identifier # files ---------------------------------------------------|------- GPL-2.0 11139 and resulted in the first patch in this series. If that file was a */uapi/* path one, it was "GPL-2.0 WITH Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was: SPDX license identifier # files ---------------------------------------------------|------- GPL-2.0 WITH Linux-syscall-note 930 and resulted in the second patch in this series. - if a file had some form of licensing information in it, and was one of the */uapi/* ones, it was denoted with the Linux-syscall-note if any GPL family license was found in the file or had no licensing in it (per prior point). Results summary: SPDX license identifier # files ---------------------------------------------------|------ GPL-2.0 WITH Linux-syscall-note 270 GPL-2.0+ WITH Linux-syscall-note 169 ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21 ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17 LGPL-2.1+ WITH Linux-syscall-note 15 GPL-1.0+ WITH Linux-syscall-note 14 ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5 LGPL-2.0+ WITH Linux-syscall-note 4 LGPL-2.1 WITH Linux-syscall-note 3 ((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3 ((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1 and that resulted in the third patch in this series. - when the two scanners agreed on the detected license(s), that became the concluded license(s). - when there was disagreement between the two scanners (one detected a license but the other didn't, or they both detected different licenses) a manual inspection of the file occurred. - In most cases a manual inspection of the information in the file resulted in a clear resolution of the license that should apply (and which scanner probably needed to revisit its heuristics). - When it was not immediately clear, the license identifier was confirmed with lawyers working with the Linux Foundation. - If there was any question as to the appropriate license identifier, the file was flagged for further research and to be revisited later in time. In total, over 70 hours of logged manual review was done on the spreadsheet to determine the SPDX license identifiers to apply to the source files by Kate, Philippe, Thomas and, in some cases, confirmation by lawyers working with the Linux Foundation. Kate also obtained a third independent scan of the 4.13 code base from FOSSology, and compared selected files where the other two scanners disagreed against that SPDX file, to see if there was new insights. The Windriver scanner is based on an older version of FOSSology in part, so they are related. Thomas did random spot checks in about 500 files from the spreadsheets for the uapi headers and agreed with SPDX license identifier in the files he inspected. For the non-uapi files Thomas did random spot checks in about 15000 files. In initial set of patches against 4.14-rc6, 3 files were found to have copy/paste license identifier errors, and have been fixed to reflect the correct identifier. Additionally Philippe spent 10 hours this week doing a detailed manual inspection and review of the 12,461 patched files from the initial patch version early this week with: - a full scancode scan run, collecting the matched texts, detected license ids and scores - reviewing anything where there was a license detected (about 500+ files) to ensure that the applied SPDX license was correct - reviewing anything where there was no detection but the patch license was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied SPDX license was correct This produced a worksheet with 20 files needing minor correction. This worksheet was then exported into 3 different .csv files for the different types of files to be modified. These .csv files were then reviewed by Greg. Thomas wrote a script to parse the csv files and add the proper SPDX tag to the file, in the format that the file expected. This script was further refined by Greg based on the output to detect more types of files automatically and to distinguish between header and source .c files (which need different comment types.) Finally Greg ran the script using the .csv files to generate the patches. Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
637 lines
14 KiB
C
637 lines
14 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* linux/fs/lockd/clntxdr.c
|
|
*
|
|
* XDR functions to encode/decode NLM version 3 RPC arguments and results.
|
|
* NLM version 3 is backwards compatible with NLM versions 1 and 2.
|
|
*
|
|
* NLM client-side only.
|
|
*
|
|
* Copyright (C) 2010, Oracle. All rights reserved.
|
|
*/
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/sunrpc/xdr.h>
|
|
#include <linux/sunrpc/clnt.h>
|
|
#include <linux/sunrpc/stats.h>
|
|
#include <linux/lockd/lockd.h>
|
|
|
|
#include <uapi/linux/nfs2.h>
|
|
|
|
#define NLMDBG_FACILITY NLMDBG_XDR
|
|
|
|
#if (NLMCLNT_OHSIZE > XDR_MAX_NETOBJ)
|
|
# error "NLM host name cannot be larger than XDR_MAX_NETOBJ!"
|
|
#endif
|
|
|
|
/*
|
|
* Declare the space requirements for NLM arguments and replies as
|
|
* number of 32bit-words
|
|
*/
|
|
#define NLM_cookie_sz (1+(NLM_MAXCOOKIELEN>>2))
|
|
#define NLM_caller_sz (1+(NLMCLNT_OHSIZE>>2))
|
|
#define NLM_owner_sz (1+(NLMCLNT_OHSIZE>>2))
|
|
#define NLM_fhandle_sz (1+(NFS2_FHSIZE>>2))
|
|
#define NLM_lock_sz (3+NLM_caller_sz+NLM_owner_sz+NLM_fhandle_sz)
|
|
#define NLM_holder_sz (4+NLM_owner_sz)
|
|
|
|
#define NLM_testargs_sz (NLM_cookie_sz+1+NLM_lock_sz)
|
|
#define NLM_lockargs_sz (NLM_cookie_sz+4+NLM_lock_sz)
|
|
#define NLM_cancargs_sz (NLM_cookie_sz+2+NLM_lock_sz)
|
|
#define NLM_unlockargs_sz (NLM_cookie_sz+NLM_lock_sz)
|
|
|
|
#define NLM_testres_sz (NLM_cookie_sz+1+NLM_holder_sz)
|
|
#define NLM_res_sz (NLM_cookie_sz+1)
|
|
#define NLM_norep_sz (0)
|
|
|
|
|
|
static s32 loff_t_to_s32(loff_t offset)
|
|
{
|
|
s32 res;
|
|
|
|
if (offset >= NLM_OFFSET_MAX)
|
|
res = NLM_OFFSET_MAX;
|
|
else if (offset <= -NLM_OFFSET_MAX)
|
|
res = -NLM_OFFSET_MAX;
|
|
else
|
|
res = offset;
|
|
return res;
|
|
}
|
|
|
|
static void nlm_compute_offsets(const struct nlm_lock *lock,
|
|
u32 *l_offset, u32 *l_len)
|
|
{
|
|
const struct file_lock *fl = &lock->fl;
|
|
|
|
*l_offset = loff_t_to_s32(fl->fl_start);
|
|
if (fl->fl_end == OFFSET_MAX)
|
|
*l_len = 0;
|
|
else
|
|
*l_len = loff_t_to_s32(fl->fl_end - fl->fl_start + 1);
|
|
}
|
|
|
|
/*
|
|
* Handle decode buffer overflows out-of-line.
|
|
*/
|
|
static void print_overflow_msg(const char *func, const struct xdr_stream *xdr)
|
|
{
|
|
dprintk("lockd: %s prematurely hit the end of our receive buffer. "
|
|
"Remaining buffer length is %tu words.\n",
|
|
func, xdr->end - xdr->p);
|
|
}
|
|
|
|
|
|
/*
|
|
* Encode/decode NLMv3 basic data types
|
|
*
|
|
* Basic NLMv3 data types are not defined in an IETF standards
|
|
* document. X/Open has a description of these data types that
|
|
* is useful. See Chapter 10 of "Protocols for Interworking:
|
|
* XNFS, Version 3W".
|
|
*
|
|
* Not all basic data types have their own encoding and decoding
|
|
* functions. For run-time efficiency, some data types are encoded
|
|
* or decoded inline.
|
|
*/
|
|
|
|
static void encode_bool(struct xdr_stream *xdr, const int value)
|
|
{
|
|
__be32 *p;
|
|
|
|
p = xdr_reserve_space(xdr, 4);
|
|
*p = value ? xdr_one : xdr_zero;
|
|
}
|
|
|
|
static void encode_int32(struct xdr_stream *xdr, const s32 value)
|
|
{
|
|
__be32 *p;
|
|
|
|
p = xdr_reserve_space(xdr, 4);
|
|
*p = cpu_to_be32(value);
|
|
}
|
|
|
|
/*
|
|
* typedef opaque netobj<MAXNETOBJ_SZ>
|
|
*/
|
|
static void encode_netobj(struct xdr_stream *xdr,
|
|
const u8 *data, const unsigned int length)
|
|
{
|
|
__be32 *p;
|
|
|
|
p = xdr_reserve_space(xdr, 4 + length);
|
|
xdr_encode_opaque(p, data, length);
|
|
}
|
|
|
|
static int decode_netobj(struct xdr_stream *xdr,
|
|
struct xdr_netobj *obj)
|
|
{
|
|
u32 length;
|
|
__be32 *p;
|
|
|
|
p = xdr_inline_decode(xdr, 4);
|
|
if (unlikely(p == NULL))
|
|
goto out_overflow;
|
|
length = be32_to_cpup(p++);
|
|
if (unlikely(length > XDR_MAX_NETOBJ))
|
|
goto out_size;
|
|
obj->len = length;
|
|
obj->data = (u8 *)p;
|
|
return 0;
|
|
out_size:
|
|
dprintk("NFS: returned netobj was too long: %u\n", length);
|
|
return -EIO;
|
|
out_overflow:
|
|
print_overflow_msg(__func__, xdr);
|
|
return -EIO;
|
|
}
|
|
|
|
/*
|
|
* netobj cookie;
|
|
*/
|
|
static void encode_cookie(struct xdr_stream *xdr,
|
|
const struct nlm_cookie *cookie)
|
|
{
|
|
encode_netobj(xdr, (u8 *)&cookie->data, cookie->len);
|
|
}
|
|
|
|
static int decode_cookie(struct xdr_stream *xdr,
|
|
struct nlm_cookie *cookie)
|
|
{
|
|
u32 length;
|
|
__be32 *p;
|
|
|
|
p = xdr_inline_decode(xdr, 4);
|
|
if (unlikely(p == NULL))
|
|
goto out_overflow;
|
|
length = be32_to_cpup(p++);
|
|
/* apparently HPUX can return empty cookies */
|
|
if (length == 0)
|
|
goto out_hpux;
|
|
if (length > NLM_MAXCOOKIELEN)
|
|
goto out_size;
|
|
p = xdr_inline_decode(xdr, length);
|
|
if (unlikely(p == NULL))
|
|
goto out_overflow;
|
|
cookie->len = length;
|
|
memcpy(cookie->data, p, length);
|
|
return 0;
|
|
out_hpux:
|
|
cookie->len = 4;
|
|
memset(cookie->data, 0, 4);
|
|
return 0;
|
|
out_size:
|
|
dprintk("NFS: returned cookie was too long: %u\n", length);
|
|
return -EIO;
|
|
out_overflow:
|
|
print_overflow_msg(__func__, xdr);
|
|
return -EIO;
|
|
}
|
|
|
|
/*
|
|
* netobj fh;
|
|
*/
|
|
static void encode_fh(struct xdr_stream *xdr, const struct nfs_fh *fh)
|
|
{
|
|
encode_netobj(xdr, (u8 *)&fh->data, NFS2_FHSIZE);
|
|
}
|
|
|
|
/*
|
|
* enum nlm_stats {
|
|
* LCK_GRANTED = 0,
|
|
* LCK_DENIED = 1,
|
|
* LCK_DENIED_NOLOCKS = 2,
|
|
* LCK_BLOCKED = 3,
|
|
* LCK_DENIED_GRACE_PERIOD = 4
|
|
* };
|
|
*
|
|
*
|
|
* struct nlm_stat {
|
|
* nlm_stats stat;
|
|
* };
|
|
*
|
|
* NB: we don't swap bytes for the NLM status values. The upper
|
|
* layers deal directly with the status value in network byte
|
|
* order.
|
|
*/
|
|
|
|
static void encode_nlm_stat(struct xdr_stream *xdr,
|
|
const __be32 stat)
|
|
{
|
|
__be32 *p;
|
|
|
|
WARN_ON_ONCE(be32_to_cpu(stat) > NLM_LCK_DENIED_GRACE_PERIOD);
|
|
p = xdr_reserve_space(xdr, 4);
|
|
*p = stat;
|
|
}
|
|
|
|
static int decode_nlm_stat(struct xdr_stream *xdr,
|
|
__be32 *stat)
|
|
{
|
|
__be32 *p;
|
|
|
|
p = xdr_inline_decode(xdr, 4);
|
|
if (unlikely(p == NULL))
|
|
goto out_overflow;
|
|
if (unlikely(ntohl(*p) > ntohl(nlm_lck_denied_grace_period)))
|
|
goto out_enum;
|
|
*stat = *p;
|
|
return 0;
|
|
out_enum:
|
|
dprintk("%s: server returned invalid nlm_stats value: %u\n",
|
|
__func__, be32_to_cpup(p));
|
|
return -EIO;
|
|
out_overflow:
|
|
print_overflow_msg(__func__, xdr);
|
|
return -EIO;
|
|
}
|
|
|
|
/*
|
|
* struct nlm_holder {
|
|
* bool exclusive;
|
|
* int uppid;
|
|
* netobj oh;
|
|
* unsigned l_offset;
|
|
* unsigned l_len;
|
|
* };
|
|
*/
|
|
static void encode_nlm_holder(struct xdr_stream *xdr,
|
|
const struct nlm_res *result)
|
|
{
|
|
const struct nlm_lock *lock = &result->lock;
|
|
u32 l_offset, l_len;
|
|
__be32 *p;
|
|
|
|
encode_bool(xdr, lock->fl.fl_type == F_RDLCK);
|
|
encode_int32(xdr, lock->svid);
|
|
encode_netobj(xdr, lock->oh.data, lock->oh.len);
|
|
|
|
p = xdr_reserve_space(xdr, 4 + 4);
|
|
nlm_compute_offsets(lock, &l_offset, &l_len);
|
|
*p++ = cpu_to_be32(l_offset);
|
|
*p = cpu_to_be32(l_len);
|
|
}
|
|
|
|
static int decode_nlm_holder(struct xdr_stream *xdr, struct nlm_res *result)
|
|
{
|
|
struct nlm_lock *lock = &result->lock;
|
|
struct file_lock *fl = &lock->fl;
|
|
u32 exclusive, l_offset, l_len;
|
|
int error;
|
|
__be32 *p;
|
|
s32 end;
|
|
|
|
memset(lock, 0, sizeof(*lock));
|
|
locks_init_lock(fl);
|
|
|
|
p = xdr_inline_decode(xdr, 4 + 4);
|
|
if (unlikely(p == NULL))
|
|
goto out_overflow;
|
|
exclusive = be32_to_cpup(p++);
|
|
lock->svid = be32_to_cpup(p);
|
|
fl->fl_pid = (pid_t)lock->svid;
|
|
|
|
error = decode_netobj(xdr, &lock->oh);
|
|
if (unlikely(error))
|
|
goto out;
|
|
|
|
p = xdr_inline_decode(xdr, 4 + 4);
|
|
if (unlikely(p == NULL))
|
|
goto out_overflow;
|
|
|
|
fl->fl_flags = FL_POSIX;
|
|
fl->fl_type = exclusive != 0 ? F_WRLCK : F_RDLCK;
|
|
l_offset = be32_to_cpup(p++);
|
|
l_len = be32_to_cpup(p);
|
|
end = l_offset + l_len - 1;
|
|
|
|
fl->fl_start = (loff_t)l_offset;
|
|
if (l_len == 0 || end < 0)
|
|
fl->fl_end = OFFSET_MAX;
|
|
else
|
|
fl->fl_end = (loff_t)end;
|
|
error = 0;
|
|
out:
|
|
return error;
|
|
out_overflow:
|
|
print_overflow_msg(__func__, xdr);
|
|
return -EIO;
|
|
}
|
|
|
|
/*
|
|
* string caller_name<LM_MAXSTRLEN>;
|
|
*/
|
|
static void encode_caller_name(struct xdr_stream *xdr, const char *name)
|
|
{
|
|
/* NB: client-side does not set lock->len */
|
|
u32 length = strlen(name);
|
|
__be32 *p;
|
|
|
|
p = xdr_reserve_space(xdr, 4 + length);
|
|
xdr_encode_opaque(p, name, length);
|
|
}
|
|
|
|
/*
|
|
* struct nlm_lock {
|
|
* string caller_name<LM_MAXSTRLEN>;
|
|
* netobj fh;
|
|
* netobj oh;
|
|
* int uppid;
|
|
* unsigned l_offset;
|
|
* unsigned l_len;
|
|
* };
|
|
*/
|
|
static void encode_nlm_lock(struct xdr_stream *xdr,
|
|
const struct nlm_lock *lock)
|
|
{
|
|
u32 l_offset, l_len;
|
|
__be32 *p;
|
|
|
|
encode_caller_name(xdr, lock->caller);
|
|
encode_fh(xdr, &lock->fh);
|
|
encode_netobj(xdr, lock->oh.data, lock->oh.len);
|
|
|
|
p = xdr_reserve_space(xdr, 4 + 4 + 4);
|
|
*p++ = cpu_to_be32(lock->svid);
|
|
|
|
nlm_compute_offsets(lock, &l_offset, &l_len);
|
|
*p++ = cpu_to_be32(l_offset);
|
|
*p = cpu_to_be32(l_len);
|
|
}
|
|
|
|
|
|
/*
|
|
* NLMv3 XDR encode functions
|
|
*
|
|
* NLMv3 argument types are defined in Chapter 10 of The Open Group's
|
|
* "Protocols for Interworking: XNFS, Version 3W".
|
|
*/
|
|
|
|
/*
|
|
* struct nlm_testargs {
|
|
* netobj cookie;
|
|
* bool exclusive;
|
|
* struct nlm_lock alock;
|
|
* };
|
|
*/
|
|
static void nlm_xdr_enc_testargs(struct rpc_rqst *req,
|
|
struct xdr_stream *xdr,
|
|
const void *data)
|
|
{
|
|
const struct nlm_args *args = data;
|
|
const struct nlm_lock *lock = &args->lock;
|
|
|
|
encode_cookie(xdr, &args->cookie);
|
|
encode_bool(xdr, lock->fl.fl_type == F_WRLCK);
|
|
encode_nlm_lock(xdr, lock);
|
|
}
|
|
|
|
/*
|
|
* struct nlm_lockargs {
|
|
* netobj cookie;
|
|
* bool block;
|
|
* bool exclusive;
|
|
* struct nlm_lock alock;
|
|
* bool reclaim;
|
|
* int state;
|
|
* };
|
|
*/
|
|
static void nlm_xdr_enc_lockargs(struct rpc_rqst *req,
|
|
struct xdr_stream *xdr,
|
|
const void *data)
|
|
{
|
|
const struct nlm_args *args = data;
|
|
const struct nlm_lock *lock = &args->lock;
|
|
|
|
encode_cookie(xdr, &args->cookie);
|
|
encode_bool(xdr, args->block);
|
|
encode_bool(xdr, lock->fl.fl_type == F_WRLCK);
|
|
encode_nlm_lock(xdr, lock);
|
|
encode_bool(xdr, args->reclaim);
|
|
encode_int32(xdr, args->state);
|
|
}
|
|
|
|
/*
|
|
* struct nlm_cancargs {
|
|
* netobj cookie;
|
|
* bool block;
|
|
* bool exclusive;
|
|
* struct nlm_lock alock;
|
|
* };
|
|
*/
|
|
static void nlm_xdr_enc_cancargs(struct rpc_rqst *req,
|
|
struct xdr_stream *xdr,
|
|
const void *data)
|
|
{
|
|
const struct nlm_args *args = data;
|
|
const struct nlm_lock *lock = &args->lock;
|
|
|
|
encode_cookie(xdr, &args->cookie);
|
|
encode_bool(xdr, args->block);
|
|
encode_bool(xdr, lock->fl.fl_type == F_WRLCK);
|
|
encode_nlm_lock(xdr, lock);
|
|
}
|
|
|
|
/*
|
|
* struct nlm_unlockargs {
|
|
* netobj cookie;
|
|
* struct nlm_lock alock;
|
|
* };
|
|
*/
|
|
static void nlm_xdr_enc_unlockargs(struct rpc_rqst *req,
|
|
struct xdr_stream *xdr,
|
|
const void *data)
|
|
{
|
|
const struct nlm_args *args = data;
|
|
const struct nlm_lock *lock = &args->lock;
|
|
|
|
encode_cookie(xdr, &args->cookie);
|
|
encode_nlm_lock(xdr, lock);
|
|
}
|
|
|
|
/*
|
|
* struct nlm_res {
|
|
* netobj cookie;
|
|
* nlm_stat stat;
|
|
* };
|
|
*/
|
|
static void nlm_xdr_enc_res(struct rpc_rqst *req,
|
|
struct xdr_stream *xdr,
|
|
const void *data)
|
|
{
|
|
const struct nlm_res *result = data;
|
|
|
|
encode_cookie(xdr, &result->cookie);
|
|
encode_nlm_stat(xdr, result->status);
|
|
}
|
|
|
|
/*
|
|
* union nlm_testrply switch (nlm_stats stat) {
|
|
* case LCK_DENIED:
|
|
* struct nlm_holder holder;
|
|
* default:
|
|
* void;
|
|
* };
|
|
*
|
|
* struct nlm_testres {
|
|
* netobj cookie;
|
|
* nlm_testrply test_stat;
|
|
* };
|
|
*/
|
|
static void encode_nlm_testrply(struct xdr_stream *xdr,
|
|
const struct nlm_res *result)
|
|
{
|
|
if (result->status == nlm_lck_denied)
|
|
encode_nlm_holder(xdr, result);
|
|
}
|
|
|
|
static void nlm_xdr_enc_testres(struct rpc_rqst *req,
|
|
struct xdr_stream *xdr,
|
|
const void *data)
|
|
{
|
|
const struct nlm_res *result = data;
|
|
|
|
encode_cookie(xdr, &result->cookie);
|
|
encode_nlm_stat(xdr, result->status);
|
|
encode_nlm_testrply(xdr, result);
|
|
}
|
|
|
|
|
|
/*
|
|
* NLMv3 XDR decode functions
|
|
*
|
|
* NLMv3 result types are defined in Chapter 10 of The Open Group's
|
|
* "Protocols for Interworking: XNFS, Version 3W".
|
|
*/
|
|
|
|
/*
|
|
* union nlm_testrply switch (nlm_stats stat) {
|
|
* case LCK_DENIED:
|
|
* struct nlm_holder holder;
|
|
* default:
|
|
* void;
|
|
* };
|
|
*
|
|
* struct nlm_testres {
|
|
* netobj cookie;
|
|
* nlm_testrply test_stat;
|
|
* };
|
|
*/
|
|
static int decode_nlm_testrply(struct xdr_stream *xdr,
|
|
struct nlm_res *result)
|
|
{
|
|
int error;
|
|
|
|
error = decode_nlm_stat(xdr, &result->status);
|
|
if (unlikely(error))
|
|
goto out;
|
|
if (result->status == nlm_lck_denied)
|
|
error = decode_nlm_holder(xdr, result);
|
|
out:
|
|
return error;
|
|
}
|
|
|
|
static int nlm_xdr_dec_testres(struct rpc_rqst *req,
|
|
struct xdr_stream *xdr,
|
|
void *data)
|
|
{
|
|
struct nlm_res *result = data;
|
|
int error;
|
|
|
|
error = decode_cookie(xdr, &result->cookie);
|
|
if (unlikely(error))
|
|
goto out;
|
|
error = decode_nlm_testrply(xdr, result);
|
|
out:
|
|
return error;
|
|
}
|
|
|
|
/*
|
|
* struct nlm_res {
|
|
* netobj cookie;
|
|
* nlm_stat stat;
|
|
* };
|
|
*/
|
|
static int nlm_xdr_dec_res(struct rpc_rqst *req,
|
|
struct xdr_stream *xdr,
|
|
void *data)
|
|
{
|
|
struct nlm_res *result = data;
|
|
int error;
|
|
|
|
error = decode_cookie(xdr, &result->cookie);
|
|
if (unlikely(error))
|
|
goto out;
|
|
error = decode_nlm_stat(xdr, &result->status);
|
|
out:
|
|
return error;
|
|
}
|
|
|
|
|
|
/*
|
|
* For NLM, a void procedure really returns nothing
|
|
*/
|
|
#define nlm_xdr_dec_norep NULL
|
|
|
|
#define PROC(proc, argtype, restype) \
|
|
[NLMPROC_##proc] = { \
|
|
.p_proc = NLMPROC_##proc, \
|
|
.p_encode = nlm_xdr_enc_##argtype, \
|
|
.p_decode = nlm_xdr_dec_##restype, \
|
|
.p_arglen = NLM_##argtype##_sz, \
|
|
.p_replen = NLM_##restype##_sz, \
|
|
.p_statidx = NLMPROC_##proc, \
|
|
.p_name = #proc, \
|
|
}
|
|
|
|
static const struct rpc_procinfo nlm_procedures[] = {
|
|
PROC(TEST, testargs, testres),
|
|
PROC(LOCK, lockargs, res),
|
|
PROC(CANCEL, cancargs, res),
|
|
PROC(UNLOCK, unlockargs, res),
|
|
PROC(GRANTED, testargs, res),
|
|
PROC(TEST_MSG, testargs, norep),
|
|
PROC(LOCK_MSG, lockargs, norep),
|
|
PROC(CANCEL_MSG, cancargs, norep),
|
|
PROC(UNLOCK_MSG, unlockargs, norep),
|
|
PROC(GRANTED_MSG, testargs, norep),
|
|
PROC(TEST_RES, testres, norep),
|
|
PROC(LOCK_RES, res, norep),
|
|
PROC(CANCEL_RES, res, norep),
|
|
PROC(UNLOCK_RES, res, norep),
|
|
PROC(GRANTED_RES, res, norep),
|
|
};
|
|
|
|
static unsigned int nlm_version1_counts[ARRAY_SIZE(nlm_procedures)];
|
|
static const struct rpc_version nlm_version1 = {
|
|
.number = 1,
|
|
.nrprocs = ARRAY_SIZE(nlm_procedures),
|
|
.procs = nlm_procedures,
|
|
.counts = nlm_version1_counts,
|
|
};
|
|
|
|
static unsigned int nlm_version3_counts[ARRAY_SIZE(nlm_procedures)];
|
|
static const struct rpc_version nlm_version3 = {
|
|
.number = 3,
|
|
.nrprocs = ARRAY_SIZE(nlm_procedures),
|
|
.procs = nlm_procedures,
|
|
.counts = nlm_version3_counts,
|
|
};
|
|
|
|
static const struct rpc_version *nlm_versions[] = {
|
|
[1] = &nlm_version1,
|
|
[3] = &nlm_version3,
|
|
#ifdef CONFIG_LOCKD_V4
|
|
[4] = &nlm_version4,
|
|
#endif
|
|
};
|
|
|
|
static struct rpc_stat nlm_rpc_stats;
|
|
|
|
const struct rpc_program nlm_program = {
|
|
.name = "lockd",
|
|
.number = NLM_PROGRAM,
|
|
.nrvers = ARRAY_SIZE(nlm_versions),
|
|
.version = nlm_versions,
|
|
.stats = &nlm_rpc_stats,
|
|
};
|