11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * linux/fs/nfs/callback_xdr.c 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * Copyright (C) 2004 Trond Myklebust 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * NFSv4 callback encode/decode procedures 71da177e4SLinus Torvalds */ 81da177e4SLinus Torvalds #include <linux/kernel.h> 91da177e4SLinus Torvalds #include <linux/sunrpc/svc.h> 101da177e4SLinus Torvalds #include <linux/nfs4.h> 111da177e4SLinus Torvalds #include <linux/nfs_fs.h> 129a3ba432STrond Myklebust #include <linux/ratelimit.h> 139a3ba432STrond Myklebust #include <linux/printk.h> 145a0e3ad6STejun Heo #include <linux/slab.h> 15c36fca52SAndy Adamson #include <linux/sunrpc/bc_xprt.h> 164ce79717STrond Myklebust #include "nfs4_fs.h" 171da177e4SLinus Torvalds #include "callback.h" 18c36fca52SAndy Adamson #include "internal.h" 1976e697baSTrond Myklebust #include "nfs4session.h" 201da177e4SLinus Torvalds 211da177e4SLinus Torvalds #define CB_OP_TAGLEN_MAXSZ (512) 2245724e8aSKinglong Mee #define CB_OP_HDR_RES_MAXSZ (2 * 4) // opcode, status 2345724e8aSKinglong Mee #define CB_OP_GETATTR_BITMAP_MAXSZ (4 * 4) // bitmap length, 3 bitmaps 241da177e4SLinus Torvalds #define CB_OP_GETATTR_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ + \ 251da177e4SLinus Torvalds CB_OP_GETATTR_BITMAP_MAXSZ + \ 2645724e8aSKinglong Mee /* change, size, ctime, mtime */\ 2745724e8aSKinglong Mee (2 + 2 + 3 + 3) * 4) 281da177e4SLinus Torvalds #define CB_OP_RECALL_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) 291da177e4SLinus Torvalds 304aece6a1SBenny Halevy #if defined(CONFIG_NFS_V4_1) 31f2a62561SFred Isaman #define CB_OP_LAYOUTRECALL_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) 321be5683bSMarc Eshel #define CB_OP_DEVICENOTIFY_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) 334aece6a1SBenny Halevy #define CB_OP_SEQUENCE_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ + \ 3445724e8aSKinglong Mee NFS4_MAX_SESSIONID_LEN + \ 3545724e8aSKinglong Mee (1 + 3) * 4) // seqid, 3 slotids 3631f09607SAlexandros Batsakis #define CB_OP_RECALLANY_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) 37b9efa1b2SAndy Adamson #define CB_OP_RECALLSLOT_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) 38db783688SJeff Layton #define CB_OP_NOTIFY_LOCK_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) 394aece6a1SBenny Halevy #endif /* CONFIG_NFS_V4_1 */ 404aece6a1SBenny Halevy 411da177e4SLinus Torvalds #define NFSDBG_FACILITY NFSDBG_CALLBACK 421da177e4SLinus Torvalds 4331d2b435SAndy Adamson /* Internal error code */ 4431d2b435SAndy Adamson #define NFS4ERR_RESOURCE_HDR 11050 4531d2b435SAndy Adamson 46c36fca52SAndy Adamson typedef __be32 (*callback_process_op_t)(void *, void *, 47c36fca52SAndy Adamson struct cb_process_state *); 48e6f684f6SAl Viro typedef __be32 (*callback_decode_arg_t)(struct svc_rqst *, struct xdr_stream *, void *); 49e6f684f6SAl Viro typedef __be32 (*callback_encode_res_t)(struct svc_rqst *, struct xdr_stream *, void *); 501da177e4SLinus Torvalds 511da177e4SLinus Torvalds 521da177e4SLinus Torvalds struct callback_op { 531da177e4SLinus Torvalds callback_process_op_t process_op; 541da177e4SLinus Torvalds callback_decode_arg_t decode_args; 551da177e4SLinus Torvalds callback_encode_res_t encode_res; 561da177e4SLinus Torvalds long res_maxsize; 571da177e4SLinus Torvalds }; 581da177e4SLinus Torvalds 591da177e4SLinus Torvalds static struct callback_op callback_ops[]; 601da177e4SLinus Torvalds 617111c66eSAl Viro static __be32 nfs4_callback_null(struct svc_rqst *rqstp, void *argp, void *resp) 621da177e4SLinus Torvalds { 631da177e4SLinus Torvalds return htonl(NFS4_OK); 641da177e4SLinus Torvalds } 651da177e4SLinus Torvalds 665704fdebSAl Viro static int nfs4_decode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy) 671da177e4SLinus Torvalds { 681da177e4SLinus Torvalds return xdr_argsize_check(rqstp, p); 691da177e4SLinus Torvalds } 701da177e4SLinus Torvalds 715704fdebSAl Viro static int nfs4_encode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy) 721da177e4SLinus Torvalds { 731da177e4SLinus Torvalds return xdr_ressize_check(rqstp, p); 741da177e4SLinus Torvalds } 751da177e4SLinus Torvalds 76b60475c9SJeff Layton static __be32 *read_buf(struct xdr_stream *xdr, size_t nbytes) 771da177e4SLinus Torvalds { 785704fdebSAl Viro __be32 *p; 791da177e4SLinus Torvalds 801da177e4SLinus Torvalds p = xdr_inline_decode(xdr, nbytes); 811da177e4SLinus Torvalds if (unlikely(p == NULL)) 82756b9b37STrond Myklebust printk(KERN_WARNING "NFS: NFSv4 callback reply buffer overflowed!\n"); 831da177e4SLinus Torvalds return p; 841da177e4SLinus Torvalds } 851da177e4SLinus Torvalds 86e6f684f6SAl Viro static __be32 decode_string(struct xdr_stream *xdr, unsigned int *len, const char **str) 871da177e4SLinus Torvalds { 885704fdebSAl Viro __be32 *p; 891da177e4SLinus Torvalds 901da177e4SLinus Torvalds p = read_buf(xdr, 4); 911da177e4SLinus Torvalds if (unlikely(p == NULL)) 921da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 931da177e4SLinus Torvalds *len = ntohl(*p); 941da177e4SLinus Torvalds 951da177e4SLinus Torvalds if (*len != 0) { 961da177e4SLinus Torvalds p = read_buf(xdr, *len); 971da177e4SLinus Torvalds if (unlikely(p == NULL)) 981da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 991da177e4SLinus Torvalds *str = (const char *)p; 1001da177e4SLinus Torvalds } else 1011da177e4SLinus Torvalds *str = NULL; 1021da177e4SLinus Torvalds 1031da177e4SLinus Torvalds return 0; 1041da177e4SLinus Torvalds } 1051da177e4SLinus Torvalds 106e6f684f6SAl Viro static __be32 decode_fh(struct xdr_stream *xdr, struct nfs_fh *fh) 1071da177e4SLinus Torvalds { 1085704fdebSAl Viro __be32 *p; 1091da177e4SLinus Torvalds 1101da177e4SLinus Torvalds p = read_buf(xdr, 4); 1111da177e4SLinus Torvalds if (unlikely(p == NULL)) 1121da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 1131da177e4SLinus Torvalds fh->size = ntohl(*p); 1141da177e4SLinus Torvalds if (fh->size > NFS4_FHSIZE) 1151da177e4SLinus Torvalds return htonl(NFS4ERR_BADHANDLE); 1161da177e4SLinus Torvalds p = read_buf(xdr, fh->size); 1171da177e4SLinus Torvalds if (unlikely(p == NULL)) 1181da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 1191da177e4SLinus Torvalds memcpy(&fh->data[0], p, fh->size); 1201da177e4SLinus Torvalds memset(&fh->data[fh->size], 0, sizeof(fh->data) - fh->size); 1211da177e4SLinus Torvalds return 0; 1221da177e4SLinus Torvalds } 1231da177e4SLinus Torvalds 124e6f684f6SAl Viro static __be32 decode_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) 1251da177e4SLinus Torvalds { 1265704fdebSAl Viro __be32 *p; 1271da177e4SLinus Torvalds unsigned int attrlen; 1281da177e4SLinus Torvalds 1291da177e4SLinus Torvalds p = read_buf(xdr, 4); 1301da177e4SLinus Torvalds if (unlikely(p == NULL)) 1311da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 1321da177e4SLinus Torvalds attrlen = ntohl(*p); 1331da177e4SLinus Torvalds p = read_buf(xdr, attrlen << 2); 1341da177e4SLinus Torvalds if (unlikely(p == NULL)) 1351da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 1361da177e4SLinus Torvalds if (likely(attrlen > 0)) 1371da177e4SLinus Torvalds bitmap[0] = ntohl(*p++); 1381da177e4SLinus Torvalds if (attrlen > 1) 1391da177e4SLinus Torvalds bitmap[1] = ntohl(*p); 1401da177e4SLinus Torvalds return 0; 1411da177e4SLinus Torvalds } 1421da177e4SLinus Torvalds 143e6f684f6SAl Viro static __be32 decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) 1441da177e4SLinus Torvalds { 1455704fdebSAl Viro __be32 *p; 1461da177e4SLinus Torvalds 1472d2f24adSTrond Myklebust p = read_buf(xdr, NFS4_STATEID_SIZE); 1481da177e4SLinus Torvalds if (unlikely(p == NULL)) 1491da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 15093b717fdSTrond Myklebust memcpy(stateid->data, p, NFS4_STATEID_SIZE); 1511da177e4SLinus Torvalds return 0; 1521da177e4SLinus Torvalds } 1531da177e4SLinus Torvalds 15493b717fdSTrond Myklebust static __be32 decode_delegation_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) 15593b717fdSTrond Myklebust { 15693b717fdSTrond Myklebust stateid->type = NFS4_DELEGATION_STATEID_TYPE; 15793b717fdSTrond Myklebust return decode_stateid(xdr, stateid); 15893b717fdSTrond Myklebust } 15993b717fdSTrond Myklebust 160e6f684f6SAl Viro static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound_hdr_arg *hdr) 1611da177e4SLinus Torvalds { 1625704fdebSAl Viro __be32 *p; 163e6f684f6SAl Viro __be32 status; 1641da177e4SLinus Torvalds 1651da177e4SLinus Torvalds status = decode_string(xdr, &hdr->taglen, &hdr->tag); 1661da177e4SLinus Torvalds if (unlikely(status != 0)) 1671da177e4SLinus Torvalds return status; 1681da177e4SLinus Torvalds /* We do not like overly long tags! */ 169403889c0SKinglong Mee if (hdr->taglen > CB_OP_TAGLEN_MAXSZ) { 170a030889aSWeston Andros Adamson printk("NFS: NFSv4 CALLBACK %s: client sent tag of length %u\n", 1713110ff80SHarvey Harrison __func__, hdr->taglen); 1721da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 1731da177e4SLinus Torvalds } 1741da177e4SLinus Torvalds p = read_buf(xdr, 12); 1751da177e4SLinus Torvalds if (unlikely(p == NULL)) 1761da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 177b8f2ef84SBenny Halevy hdr->minorversion = ntohl(*p++); 178459de2edSBryan Schumaker /* Check for minor version support */ 179459de2edSBryan Schumaker if (hdr->minorversion <= NFS4_MAX_MINOR_VERSION) { 18042c2c424SSteve Dickson hdr->cb_ident = ntohl(*p++); /* ignored by v4.1 and v4.2 */ 18148a9e2d2SBenny Halevy } else { 1829a3ba432STrond Myklebust pr_warn_ratelimited("NFS: %s: NFSv4 server callback with " 183b8f2ef84SBenny Halevy "illegal minor version %u!\n", 184b8f2ef84SBenny Halevy __func__, hdr->minorversion); 1851da177e4SLinus Torvalds return htonl(NFS4ERR_MINOR_VERS_MISMATCH); 1861da177e4SLinus Torvalds } 1871da177e4SLinus Torvalds hdr->nops = ntohl(*p); 188b8f2ef84SBenny Halevy dprintk("%s: minorversion %d nops %d\n", __func__, 189b8f2ef84SBenny Halevy hdr->minorversion, hdr->nops); 1901da177e4SLinus Torvalds return 0; 1911da177e4SLinus Torvalds } 1921da177e4SLinus Torvalds 193e6f684f6SAl Viro static __be32 decode_op_hdr(struct xdr_stream *xdr, unsigned int *op) 1941da177e4SLinus Torvalds { 1955704fdebSAl Viro __be32 *p; 1961da177e4SLinus Torvalds p = read_buf(xdr, 4); 1971da177e4SLinus Torvalds if (unlikely(p == NULL)) 19831d2b435SAndy Adamson return htonl(NFS4ERR_RESOURCE_HDR); 1991da177e4SLinus Torvalds *op = ntohl(*p); 2001da177e4SLinus Torvalds return 0; 2011da177e4SLinus Torvalds } 2021da177e4SLinus Torvalds 203e6f684f6SAl Viro static __be32 decode_getattr_args(struct svc_rqst *rqstp, struct xdr_stream *xdr, struct cb_getattrargs *args) 2041da177e4SLinus Torvalds { 205e6f684f6SAl Viro __be32 status; 2061da177e4SLinus Torvalds 2071da177e4SLinus Torvalds status = decode_fh(xdr, &args->fh); 2081da177e4SLinus Torvalds if (unlikely(status != 0)) 2091da177e4SLinus Torvalds goto out; 2101da177e4SLinus Torvalds status = decode_bitmap(xdr, args->bitmap); 2111da177e4SLinus Torvalds out: 2123110ff80SHarvey Harrison dprintk("%s: exit with status = %d\n", __func__, ntohl(status)); 2131da177e4SLinus Torvalds return status; 2141da177e4SLinus Torvalds } 2151da177e4SLinus Torvalds 216e6f684f6SAl Viro static __be32 decode_recall_args(struct svc_rqst *rqstp, struct xdr_stream *xdr, struct cb_recallargs *args) 2171da177e4SLinus Torvalds { 2185704fdebSAl Viro __be32 *p; 219e6f684f6SAl Viro __be32 status; 2201da177e4SLinus Torvalds 22193b717fdSTrond Myklebust status = decode_delegation_stateid(xdr, &args->stateid); 2221da177e4SLinus Torvalds if (unlikely(status != 0)) 2231da177e4SLinus Torvalds goto out; 2241da177e4SLinus Torvalds p = read_buf(xdr, 4); 2251da177e4SLinus Torvalds if (unlikely(p == NULL)) { 2261da177e4SLinus Torvalds status = htonl(NFS4ERR_RESOURCE); 2271da177e4SLinus Torvalds goto out; 2281da177e4SLinus Torvalds } 2291da177e4SLinus Torvalds args->truncate = ntohl(*p); 2301da177e4SLinus Torvalds status = decode_fh(xdr, &args->fh); 2311da177e4SLinus Torvalds out: 2323110ff80SHarvey Harrison dprintk("%s: exit with status = %d\n", __func__, ntohl(status)); 2333873bc50SAlexey Dobriyan return status; 2341da177e4SLinus Torvalds } 2351da177e4SLinus Torvalds 2364aece6a1SBenny Halevy #if defined(CONFIG_NFS_V4_1) 23793b717fdSTrond Myklebust static __be32 decode_layout_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) 23893b717fdSTrond Myklebust { 23993b717fdSTrond Myklebust stateid->type = NFS4_LAYOUT_STATEID_TYPE; 24093b717fdSTrond Myklebust return decode_stateid(xdr, stateid); 24193b717fdSTrond Myklebust } 2424aece6a1SBenny Halevy 243f2a62561SFred Isaman static __be32 decode_layoutrecall_args(struct svc_rqst *rqstp, 244f2a62561SFred Isaman struct xdr_stream *xdr, 245f2a62561SFred Isaman struct cb_layoutrecallargs *args) 246f2a62561SFred Isaman { 247f2a62561SFred Isaman __be32 *p; 248f2a62561SFred Isaman __be32 status = 0; 249f2a62561SFred Isaman uint32_t iomode; 250f2a62561SFred Isaman 251f2a62561SFred Isaman p = read_buf(xdr, 4 * sizeof(uint32_t)); 252f2a62561SFred Isaman if (unlikely(p == NULL)) { 253f2a62561SFred Isaman status = htonl(NFS4ERR_BADXDR); 254f2a62561SFred Isaman goto out; 255f2a62561SFred Isaman } 256f2a62561SFred Isaman 257f2a62561SFred Isaman args->cbl_layout_type = ntohl(*p++); 258f2a62561SFred Isaman /* Depite the spec's xdr, iomode really belongs in the FILE switch, 25925985edcSLucas De Marchi * as it is unusable and ignored with the other types. 260f2a62561SFred Isaman */ 261f2a62561SFred Isaman iomode = ntohl(*p++); 262f2a62561SFred Isaman args->cbl_layoutchanged = ntohl(*p++); 263f2a62561SFred Isaman args->cbl_recall_type = ntohl(*p++); 264f2a62561SFred Isaman 265f2a62561SFred Isaman if (args->cbl_recall_type == RETURN_FILE) { 266f2a62561SFred Isaman args->cbl_range.iomode = iomode; 267f2a62561SFred Isaman status = decode_fh(xdr, &args->cbl_fh); 268f2a62561SFred Isaman if (unlikely(status != 0)) 269f2a62561SFred Isaman goto out; 270f2a62561SFred Isaman 271f2a62561SFred Isaman p = read_buf(xdr, 2 * sizeof(uint64_t)); 272f2a62561SFred Isaman if (unlikely(p == NULL)) { 273f2a62561SFred Isaman status = htonl(NFS4ERR_BADXDR); 274f2a62561SFred Isaman goto out; 275f2a62561SFred Isaman } 276f2a62561SFred Isaman p = xdr_decode_hyper(p, &args->cbl_range.offset); 277f2a62561SFred Isaman p = xdr_decode_hyper(p, &args->cbl_range.length); 27893b717fdSTrond Myklebust status = decode_layout_stateid(xdr, &args->cbl_stateid); 279f2a62561SFred Isaman if (unlikely(status != 0)) 280f2a62561SFred Isaman goto out; 281f2a62561SFred Isaman } else if (args->cbl_recall_type == RETURN_FSID) { 282f2a62561SFred Isaman p = read_buf(xdr, 2 * sizeof(uint64_t)); 283f2a62561SFred Isaman if (unlikely(p == NULL)) { 284f2a62561SFred Isaman status = htonl(NFS4ERR_BADXDR); 285f2a62561SFred Isaman goto out; 286f2a62561SFred Isaman } 287f2a62561SFred Isaman p = xdr_decode_hyper(p, &args->cbl_fsid.major); 288f2a62561SFred Isaman p = xdr_decode_hyper(p, &args->cbl_fsid.minor); 289f2a62561SFred Isaman } else if (args->cbl_recall_type != RETURN_ALL) { 290f2a62561SFred Isaman status = htonl(NFS4ERR_BADXDR); 291f2a62561SFred Isaman goto out; 292f2a62561SFred Isaman } 293f2a62561SFred Isaman dprintk("%s: ltype 0x%x iomode %d changed %d recall_type %d\n", 294f2a62561SFred Isaman __func__, 295f2a62561SFred Isaman args->cbl_layout_type, iomode, 296f2a62561SFred Isaman args->cbl_layoutchanged, args->cbl_recall_type); 297f2a62561SFred Isaman out: 298f2a62561SFred Isaman dprintk("%s: exit with status = %d\n", __func__, ntohl(status)); 299f2a62561SFred Isaman return status; 300f2a62561SFred Isaman } 301f2a62561SFred Isaman 3021be5683bSMarc Eshel static 3031be5683bSMarc Eshel __be32 decode_devicenotify_args(struct svc_rqst *rqstp, 3041be5683bSMarc Eshel struct xdr_stream *xdr, 3051be5683bSMarc Eshel struct cb_devicenotifyargs *args) 3061be5683bSMarc Eshel { 3071be5683bSMarc Eshel __be32 *p; 3081be5683bSMarc Eshel __be32 status = 0; 3091be5683bSMarc Eshel u32 tmp; 3101be5683bSMarc Eshel int n, i; 3111be5683bSMarc Eshel args->ndevs = 0; 3121be5683bSMarc Eshel 3131be5683bSMarc Eshel /* Num of device notifications */ 3141be5683bSMarc Eshel p = read_buf(xdr, sizeof(uint32_t)); 3151be5683bSMarc Eshel if (unlikely(p == NULL)) { 3161be5683bSMarc Eshel status = htonl(NFS4ERR_BADXDR); 3171be5683bSMarc Eshel goto out; 3181be5683bSMarc Eshel } 3191be5683bSMarc Eshel n = ntohl(*p++); 3201be5683bSMarc Eshel if (n <= 0) 3211be5683bSMarc Eshel goto out; 322363e0df0SDan Carpenter if (n > ULONG_MAX / sizeof(*args->devs)) { 323363e0df0SDan Carpenter status = htonl(NFS4ERR_BADXDR); 324363e0df0SDan Carpenter goto out; 325363e0df0SDan Carpenter } 3261be5683bSMarc Eshel 327a4f743a6STrond Myklebust args->devs = kmalloc_array(n, sizeof(*args->devs), GFP_KERNEL); 3281be5683bSMarc Eshel if (!args->devs) { 3291be5683bSMarc Eshel status = htonl(NFS4ERR_DELAY); 3301be5683bSMarc Eshel goto out; 3311be5683bSMarc Eshel } 3321be5683bSMarc Eshel 3331be5683bSMarc Eshel /* Decode each dev notification */ 3341be5683bSMarc Eshel for (i = 0; i < n; i++) { 3351be5683bSMarc Eshel struct cb_devicenotifyitem *dev = &args->devs[i]; 3361be5683bSMarc Eshel 3371be5683bSMarc Eshel p = read_buf(xdr, (4 * sizeof(uint32_t)) + NFS4_DEVICEID4_SIZE); 3381be5683bSMarc Eshel if (unlikely(p == NULL)) { 3391be5683bSMarc Eshel status = htonl(NFS4ERR_BADXDR); 3401be5683bSMarc Eshel goto err; 3411be5683bSMarc Eshel } 3421be5683bSMarc Eshel 3431be5683bSMarc Eshel tmp = ntohl(*p++); /* bitmap size */ 3441be5683bSMarc Eshel if (tmp != 1) { 3451be5683bSMarc Eshel status = htonl(NFS4ERR_INVAL); 3461be5683bSMarc Eshel goto err; 3471be5683bSMarc Eshel } 3481be5683bSMarc Eshel dev->cbd_notify_type = ntohl(*p++); 3491be5683bSMarc Eshel if (dev->cbd_notify_type != NOTIFY_DEVICEID4_CHANGE && 3501be5683bSMarc Eshel dev->cbd_notify_type != NOTIFY_DEVICEID4_DELETE) { 3511be5683bSMarc Eshel status = htonl(NFS4ERR_INVAL); 3521be5683bSMarc Eshel goto err; 3531be5683bSMarc Eshel } 3541be5683bSMarc Eshel 3551be5683bSMarc Eshel tmp = ntohl(*p++); /* opaque size */ 3561be5683bSMarc Eshel if (((dev->cbd_notify_type == NOTIFY_DEVICEID4_CHANGE) && 3571be5683bSMarc Eshel (tmp != NFS4_DEVICEID4_SIZE + 8)) || 3581be5683bSMarc Eshel ((dev->cbd_notify_type == NOTIFY_DEVICEID4_DELETE) && 3591be5683bSMarc Eshel (tmp != NFS4_DEVICEID4_SIZE + 4))) { 3601be5683bSMarc Eshel status = htonl(NFS4ERR_INVAL); 3611be5683bSMarc Eshel goto err; 3621be5683bSMarc Eshel } 3631be5683bSMarc Eshel dev->cbd_layout_type = ntohl(*p++); 3641be5683bSMarc Eshel memcpy(dev->cbd_dev_id.data, p, NFS4_DEVICEID4_SIZE); 3651be5683bSMarc Eshel p += XDR_QUADLEN(NFS4_DEVICEID4_SIZE); 3661be5683bSMarc Eshel 3671be5683bSMarc Eshel if (dev->cbd_layout_type == NOTIFY_DEVICEID4_CHANGE) { 3681be5683bSMarc Eshel p = read_buf(xdr, sizeof(uint32_t)); 3691be5683bSMarc Eshel if (unlikely(p == NULL)) { 3701be5683bSMarc Eshel status = htonl(NFS4ERR_BADXDR); 3711be5683bSMarc Eshel goto err; 3721be5683bSMarc Eshel } 3731be5683bSMarc Eshel dev->cbd_immediate = ntohl(*p++); 3741be5683bSMarc Eshel } else { 3751be5683bSMarc Eshel dev->cbd_immediate = 0; 3761be5683bSMarc Eshel } 3771be5683bSMarc Eshel 3781be5683bSMarc Eshel args->ndevs++; 3791be5683bSMarc Eshel 3801be5683bSMarc Eshel dprintk("%s: type %d layout 0x%x immediate %d\n", 3811be5683bSMarc Eshel __func__, dev->cbd_notify_type, dev->cbd_layout_type, 3821be5683bSMarc Eshel dev->cbd_immediate); 3831be5683bSMarc Eshel } 3841be5683bSMarc Eshel out: 3851be5683bSMarc Eshel dprintk("%s: status %d ndevs %d\n", 3861be5683bSMarc Eshel __func__, ntohl(status), args->ndevs); 3871be5683bSMarc Eshel return status; 3881be5683bSMarc Eshel err: 3891be5683bSMarc Eshel kfree(args->devs); 3901be5683bSMarc Eshel goto out; 3911be5683bSMarc Eshel } 3921be5683bSMarc Eshel 3939733f0d9SAndy Adamson static __be32 decode_sessionid(struct xdr_stream *xdr, 3944aece6a1SBenny Halevy struct nfs4_sessionid *sid) 3954aece6a1SBenny Halevy { 3969733f0d9SAndy Adamson __be32 *p; 3974aece6a1SBenny Halevy 398590184a6SKinglong Mee p = read_buf(xdr, NFS4_MAX_SESSIONID_LEN); 3994aece6a1SBenny Halevy if (unlikely(p == NULL)) 400a419aef8SJoe Perches return htonl(NFS4ERR_RESOURCE); 4014aece6a1SBenny Halevy 402590184a6SKinglong Mee memcpy(sid->data, p, NFS4_MAX_SESSIONID_LEN); 4034aece6a1SBenny Halevy return 0; 4044aece6a1SBenny Halevy } 4054aece6a1SBenny Halevy 4069733f0d9SAndy Adamson static __be32 decode_rc_list(struct xdr_stream *xdr, 4074aece6a1SBenny Halevy struct referring_call_list *rc_list) 4084aece6a1SBenny Halevy { 4099733f0d9SAndy Adamson __be32 *p; 4104aece6a1SBenny Halevy int i; 4119733f0d9SAndy Adamson __be32 status; 4124aece6a1SBenny Halevy 4134aece6a1SBenny Halevy status = decode_sessionid(xdr, &rc_list->rcl_sessionid); 4144aece6a1SBenny Halevy if (status) 4154aece6a1SBenny Halevy goto out; 4164aece6a1SBenny Halevy 4174aece6a1SBenny Halevy status = htonl(NFS4ERR_RESOURCE); 4184aece6a1SBenny Halevy p = read_buf(xdr, sizeof(uint32_t)); 4194aece6a1SBenny Halevy if (unlikely(p == NULL)) 4204aece6a1SBenny Halevy goto out; 4214aece6a1SBenny Halevy 4224aece6a1SBenny Halevy rc_list->rcl_nrefcalls = ntohl(*p++); 4234aece6a1SBenny Halevy if (rc_list->rcl_nrefcalls) { 4244aece6a1SBenny Halevy p = read_buf(xdr, 4254aece6a1SBenny Halevy rc_list->rcl_nrefcalls * 2 * sizeof(uint32_t)); 4264aece6a1SBenny Halevy if (unlikely(p == NULL)) 4274aece6a1SBenny Halevy goto out; 428a4f743a6STrond Myklebust rc_list->rcl_refcalls = kmalloc_array(rc_list->rcl_nrefcalls, 4294aece6a1SBenny Halevy sizeof(*rc_list->rcl_refcalls), 4304aece6a1SBenny Halevy GFP_KERNEL); 4314aece6a1SBenny Halevy if (unlikely(rc_list->rcl_refcalls == NULL)) 4324aece6a1SBenny Halevy goto out; 4334aece6a1SBenny Halevy for (i = 0; i < rc_list->rcl_nrefcalls; i++) { 4344aece6a1SBenny Halevy rc_list->rcl_refcalls[i].rc_sequenceid = ntohl(*p++); 4354aece6a1SBenny Halevy rc_list->rcl_refcalls[i].rc_slotid = ntohl(*p++); 4364aece6a1SBenny Halevy } 4374aece6a1SBenny Halevy } 4384aece6a1SBenny Halevy status = 0; 4394aece6a1SBenny Halevy 4404aece6a1SBenny Halevy out: 4414aece6a1SBenny Halevy return status; 4424aece6a1SBenny Halevy } 4434aece6a1SBenny Halevy 4449733f0d9SAndy Adamson static __be32 decode_cb_sequence_args(struct svc_rqst *rqstp, 4454aece6a1SBenny Halevy struct xdr_stream *xdr, 4464aece6a1SBenny Halevy struct cb_sequenceargs *args) 4474aece6a1SBenny Halevy { 4489733f0d9SAndy Adamson __be32 *p; 4494aece6a1SBenny Halevy int i; 4509733f0d9SAndy Adamson __be32 status; 4514aece6a1SBenny Halevy 4524aece6a1SBenny Halevy status = decode_sessionid(xdr, &args->csa_sessionid); 4534aece6a1SBenny Halevy if (status) 4544aece6a1SBenny Halevy goto out; 4554aece6a1SBenny Halevy 4564aece6a1SBenny Halevy status = htonl(NFS4ERR_RESOURCE); 4574aece6a1SBenny Halevy p = read_buf(xdr, 5 * sizeof(uint32_t)); 4584aece6a1SBenny Halevy if (unlikely(p == NULL)) 4594aece6a1SBenny Halevy goto out; 4604aece6a1SBenny Halevy 46165fc64e5SRicardo Labiaga args->csa_addr = svc_addr(rqstp); 4624aece6a1SBenny Halevy args->csa_sequenceid = ntohl(*p++); 4634aece6a1SBenny Halevy args->csa_slotid = ntohl(*p++); 4644aece6a1SBenny Halevy args->csa_highestslotid = ntohl(*p++); 4654aece6a1SBenny Halevy args->csa_cachethis = ntohl(*p++); 4664aece6a1SBenny Halevy args->csa_nrclists = ntohl(*p++); 4674aece6a1SBenny Halevy args->csa_rclists = NULL; 4684aece6a1SBenny Halevy if (args->csa_nrclists) { 4690439f31cSDan Carpenter args->csa_rclists = kmalloc_array(args->csa_nrclists, 4704aece6a1SBenny Halevy sizeof(*args->csa_rclists), 4714aece6a1SBenny Halevy GFP_KERNEL); 4724aece6a1SBenny Halevy if (unlikely(args->csa_rclists == NULL)) 4734aece6a1SBenny Halevy goto out; 4744aece6a1SBenny Halevy 4754aece6a1SBenny Halevy for (i = 0; i < args->csa_nrclists; i++) { 4764aece6a1SBenny Halevy status = decode_rc_list(xdr, &args->csa_rclists[i]); 477d8ba1f97STrond Myklebust if (status) { 478d8ba1f97STrond Myklebust args->csa_nrclists = i; 4794aece6a1SBenny Halevy goto out_free; 4804aece6a1SBenny Halevy } 4814aece6a1SBenny Halevy } 482d8ba1f97STrond Myklebust } 4834aece6a1SBenny Halevy status = 0; 4844aece6a1SBenny Halevy 4854aece6a1SBenny Halevy dprintk("%s: sessionid %x:%x:%x:%x sequenceid %u slotid %u " 4864aece6a1SBenny Halevy "highestslotid %u cachethis %d nrclists %u\n", 4874aece6a1SBenny Halevy __func__, 4884aece6a1SBenny Halevy ((u32 *)&args->csa_sessionid)[0], 4894aece6a1SBenny Halevy ((u32 *)&args->csa_sessionid)[1], 4904aece6a1SBenny Halevy ((u32 *)&args->csa_sessionid)[2], 4914aece6a1SBenny Halevy ((u32 *)&args->csa_sessionid)[3], 4924aece6a1SBenny Halevy args->csa_sequenceid, args->csa_slotid, 4934aece6a1SBenny Halevy args->csa_highestslotid, args->csa_cachethis, 4944aece6a1SBenny Halevy args->csa_nrclists); 4954aece6a1SBenny Halevy out: 4964aece6a1SBenny Halevy dprintk("%s: exit with status = %d\n", __func__, ntohl(status)); 4974aece6a1SBenny Halevy return status; 4984aece6a1SBenny Halevy 4994aece6a1SBenny Halevy out_free: 5004aece6a1SBenny Halevy for (i = 0; i < args->csa_nrclists; i++) 5014aece6a1SBenny Halevy kfree(args->csa_rclists[i].rcl_refcalls); 5024aece6a1SBenny Halevy kfree(args->csa_rclists); 5034aece6a1SBenny Halevy goto out; 5044aece6a1SBenny Halevy } 5054aece6a1SBenny Halevy 5069733f0d9SAndy Adamson static __be32 decode_recallany_args(struct svc_rqst *rqstp, 50731f09607SAlexandros Batsakis struct xdr_stream *xdr, 50831f09607SAlexandros Batsakis struct cb_recallanyargs *args) 50931f09607SAlexandros Batsakis { 510d743c3c9SPeng Tao uint32_t bitmap[2]; 511d743c3c9SPeng Tao __be32 *p, status; 51231f09607SAlexandros Batsakis 51331f09607SAlexandros Batsakis p = read_buf(xdr, 4); 51431f09607SAlexandros Batsakis if (unlikely(p == NULL)) 51531f09607SAlexandros Batsakis return htonl(NFS4ERR_BADXDR); 51631f09607SAlexandros Batsakis args->craa_objs_to_keep = ntohl(*p++); 517d743c3c9SPeng Tao status = decode_bitmap(xdr, bitmap); 518d743c3c9SPeng Tao if (unlikely(status)) 519d743c3c9SPeng Tao return status; 520d743c3c9SPeng Tao args->craa_type_mask = bitmap[0]; 52131f09607SAlexandros Batsakis 52231f09607SAlexandros Batsakis return 0; 52331f09607SAlexandros Batsakis } 52431f09607SAlexandros Batsakis 5259733f0d9SAndy Adamson static __be32 decode_recallslot_args(struct svc_rqst *rqstp, 526b9efa1b2SAndy Adamson struct xdr_stream *xdr, 527b9efa1b2SAndy Adamson struct cb_recallslotargs *args) 528b9efa1b2SAndy Adamson { 529b9efa1b2SAndy Adamson __be32 *p; 530b9efa1b2SAndy Adamson 531b9efa1b2SAndy Adamson p = read_buf(xdr, 4); 532b9efa1b2SAndy Adamson if (unlikely(p == NULL)) 533b9efa1b2SAndy Adamson return htonl(NFS4ERR_BADXDR); 534d5fb4ce3STrond Myklebust args->crsa_target_highest_slotid = ntohl(*p++); 535b9efa1b2SAndy Adamson return 0; 536b9efa1b2SAndy Adamson } 537b9efa1b2SAndy Adamson 538db783688SJeff Layton static __be32 decode_lockowner(struct xdr_stream *xdr, struct cb_notify_lock_args *args) 539db783688SJeff Layton { 540db783688SJeff Layton __be32 *p; 541db783688SJeff Layton unsigned int len; 542db783688SJeff Layton 543db783688SJeff Layton p = read_buf(xdr, 12); 544db783688SJeff Layton if (unlikely(p == NULL)) 545db783688SJeff Layton return htonl(NFS4ERR_BADXDR); 546db783688SJeff Layton 547db783688SJeff Layton p = xdr_decode_hyper(p, &args->cbnl_owner.clientid); 548db783688SJeff Layton len = be32_to_cpu(*p); 549db783688SJeff Layton 550db783688SJeff Layton p = read_buf(xdr, len); 551db783688SJeff Layton if (unlikely(p == NULL)) 552db783688SJeff Layton return htonl(NFS4ERR_BADXDR); 553db783688SJeff Layton 554db783688SJeff Layton /* Only try to decode if the length is right */ 555db783688SJeff Layton if (len == 20) { 556db783688SJeff Layton p += 2; /* skip "lock id:" */ 557db783688SJeff Layton args->cbnl_owner.s_dev = be32_to_cpu(*p++); 558db783688SJeff Layton xdr_decode_hyper(p, &args->cbnl_owner.id); 559db783688SJeff Layton args->cbnl_valid = true; 560db783688SJeff Layton } else { 561db783688SJeff Layton args->cbnl_owner.s_dev = 0; 562db783688SJeff Layton args->cbnl_owner.id = 0; 563db783688SJeff Layton args->cbnl_valid = false; 564db783688SJeff Layton } 565db783688SJeff Layton return 0; 566db783688SJeff Layton } 567db783688SJeff Layton 568db783688SJeff Layton static __be32 decode_notify_lock_args(struct svc_rqst *rqstp, struct xdr_stream *xdr, struct cb_notify_lock_args *args) 569db783688SJeff Layton { 570db783688SJeff Layton __be32 status; 571db783688SJeff Layton 572db783688SJeff Layton status = decode_fh(xdr, &args->cbnl_fh); 573db783688SJeff Layton if (unlikely(status != 0)) 574db783688SJeff Layton goto out; 575db783688SJeff Layton status = decode_lockowner(xdr, args); 576db783688SJeff Layton out: 577db783688SJeff Layton dprintk("%s: exit with status = %d\n", __func__, ntohl(status)); 578db783688SJeff Layton return status; 579db783688SJeff Layton } 580db783688SJeff Layton 5814aece6a1SBenny Halevy #endif /* CONFIG_NFS_V4_1 */ 5824aece6a1SBenny Halevy 583e6f684f6SAl Viro static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) 5841da177e4SLinus Torvalds { 5855704fdebSAl Viro __be32 *p; 5861da177e4SLinus Torvalds 5871da177e4SLinus Torvalds p = xdr_reserve_space(xdr, 4 + len); 5881da177e4SLinus Torvalds if (unlikely(p == NULL)) 5891da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 5901da177e4SLinus Torvalds xdr_encode_opaque(p, str, len); 5911da177e4SLinus Torvalds return 0; 5921da177e4SLinus Torvalds } 5931da177e4SLinus Torvalds 5941da177e4SLinus Torvalds #define CB_SUPPORTED_ATTR0 (FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE) 5951da177e4SLinus Torvalds #define CB_SUPPORTED_ATTR1 (FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY) 5965704fdebSAl Viro static __be32 encode_attr_bitmap(struct xdr_stream *xdr, const uint32_t *bitmap, __be32 **savep) 5971da177e4SLinus Torvalds { 5985704fdebSAl Viro __be32 bm[2]; 5995704fdebSAl Viro __be32 *p; 6001da177e4SLinus Torvalds 6011da177e4SLinus Torvalds bm[0] = htonl(bitmap[0] & CB_SUPPORTED_ATTR0); 6021da177e4SLinus Torvalds bm[1] = htonl(bitmap[1] & CB_SUPPORTED_ATTR1); 6031da177e4SLinus Torvalds if (bm[1] != 0) { 6041da177e4SLinus Torvalds p = xdr_reserve_space(xdr, 16); 6051da177e4SLinus Torvalds if (unlikely(p == NULL)) 6061da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 6071da177e4SLinus Torvalds *p++ = htonl(2); 6081da177e4SLinus Torvalds *p++ = bm[0]; 6091da177e4SLinus Torvalds *p++ = bm[1]; 6101da177e4SLinus Torvalds } else if (bm[0] != 0) { 6111da177e4SLinus Torvalds p = xdr_reserve_space(xdr, 12); 6121da177e4SLinus Torvalds if (unlikely(p == NULL)) 6131da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 6141da177e4SLinus Torvalds *p++ = htonl(1); 6151da177e4SLinus Torvalds *p++ = bm[0]; 6161da177e4SLinus Torvalds } else { 6171da177e4SLinus Torvalds p = xdr_reserve_space(xdr, 8); 6181da177e4SLinus Torvalds if (unlikely(p == NULL)) 6191da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 6201da177e4SLinus Torvalds *p++ = htonl(0); 6211da177e4SLinus Torvalds } 6221da177e4SLinus Torvalds *savep = p; 6231da177e4SLinus Torvalds return 0; 6241da177e4SLinus Torvalds } 6251da177e4SLinus Torvalds 626e6f684f6SAl Viro static __be32 encode_attr_change(struct xdr_stream *xdr, const uint32_t *bitmap, uint64_t change) 6271da177e4SLinus Torvalds { 6285704fdebSAl Viro __be32 *p; 6291da177e4SLinus Torvalds 6301da177e4SLinus Torvalds if (!(bitmap[0] & FATTR4_WORD0_CHANGE)) 6311da177e4SLinus Torvalds return 0; 6321da177e4SLinus Torvalds p = xdr_reserve_space(xdr, 8); 63390dc7d27SHarvey Harrison if (unlikely(!p)) 6341da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 6351da177e4SLinus Torvalds p = xdr_encode_hyper(p, change); 6361da177e4SLinus Torvalds return 0; 6371da177e4SLinus Torvalds } 6381da177e4SLinus Torvalds 639e6f684f6SAl Viro static __be32 encode_attr_size(struct xdr_stream *xdr, const uint32_t *bitmap, uint64_t size) 6401da177e4SLinus Torvalds { 6415704fdebSAl Viro __be32 *p; 6421da177e4SLinus Torvalds 6431da177e4SLinus Torvalds if (!(bitmap[0] & FATTR4_WORD0_SIZE)) 6441da177e4SLinus Torvalds return 0; 6451da177e4SLinus Torvalds p = xdr_reserve_space(xdr, 8); 64690dc7d27SHarvey Harrison if (unlikely(!p)) 6471da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 6481da177e4SLinus Torvalds p = xdr_encode_hyper(p, size); 6491da177e4SLinus Torvalds return 0; 6501da177e4SLinus Torvalds } 6511da177e4SLinus Torvalds 652e6f684f6SAl Viro static __be32 encode_attr_time(struct xdr_stream *xdr, const struct timespec *time) 6531da177e4SLinus Torvalds { 6545704fdebSAl Viro __be32 *p; 6551da177e4SLinus Torvalds 6561da177e4SLinus Torvalds p = xdr_reserve_space(xdr, 12); 65790dc7d27SHarvey Harrison if (unlikely(!p)) 6581da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 6591da177e4SLinus Torvalds p = xdr_encode_hyper(p, time->tv_sec); 6601da177e4SLinus Torvalds *p = htonl(time->tv_nsec); 6611da177e4SLinus Torvalds return 0; 6621da177e4SLinus Torvalds } 6631da177e4SLinus Torvalds 664e6f684f6SAl Viro static __be32 encode_attr_ctime(struct xdr_stream *xdr, const uint32_t *bitmap, const struct timespec *time) 6651da177e4SLinus Torvalds { 6661da177e4SLinus Torvalds if (!(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) 6671da177e4SLinus Torvalds return 0; 6681da177e4SLinus Torvalds return encode_attr_time(xdr,time); 6691da177e4SLinus Torvalds } 6701da177e4SLinus Torvalds 671e6f684f6SAl Viro static __be32 encode_attr_mtime(struct xdr_stream *xdr, const uint32_t *bitmap, const struct timespec *time) 6721da177e4SLinus Torvalds { 6731da177e4SLinus Torvalds if (!(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) 6741da177e4SLinus Torvalds return 0; 6751da177e4SLinus Torvalds return encode_attr_time(xdr,time); 6761da177e4SLinus Torvalds } 6771da177e4SLinus Torvalds 678e6f684f6SAl Viro static __be32 encode_compound_hdr_res(struct xdr_stream *xdr, struct cb_compound_hdr_res *hdr) 6791da177e4SLinus Torvalds { 680e6f684f6SAl Viro __be32 status; 6811da177e4SLinus Torvalds 6821da177e4SLinus Torvalds hdr->status = xdr_reserve_space(xdr, 4); 6831da177e4SLinus Torvalds if (unlikely(hdr->status == NULL)) 6841da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 6851da177e4SLinus Torvalds status = encode_string(xdr, hdr->taglen, hdr->tag); 6861da177e4SLinus Torvalds if (unlikely(status != 0)) 6871da177e4SLinus Torvalds return status; 6881da177e4SLinus Torvalds hdr->nops = xdr_reserve_space(xdr, 4); 6891da177e4SLinus Torvalds if (unlikely(hdr->nops == NULL)) 6901da177e4SLinus Torvalds return htonl(NFS4ERR_RESOURCE); 6911da177e4SLinus Torvalds return 0; 6921da177e4SLinus Torvalds } 6931da177e4SLinus Torvalds 694e6f684f6SAl Viro static __be32 encode_op_hdr(struct xdr_stream *xdr, uint32_t op, __be32 res) 6951da177e4SLinus Torvalds { 6965704fdebSAl Viro __be32 *p; 6971da177e4SLinus Torvalds 6981da177e4SLinus Torvalds p = xdr_reserve_space(xdr, 8); 6991da177e4SLinus Torvalds if (unlikely(p == NULL)) 70031d2b435SAndy Adamson return htonl(NFS4ERR_RESOURCE_HDR); 7011da177e4SLinus Torvalds *p++ = htonl(op); 7021da177e4SLinus Torvalds *p = res; 7031da177e4SLinus Torvalds return 0; 7041da177e4SLinus Torvalds } 7051da177e4SLinus Torvalds 706e6f684f6SAl Viro static __be32 encode_getattr_res(struct svc_rqst *rqstp, struct xdr_stream *xdr, const struct cb_getattrres *res) 7071da177e4SLinus Torvalds { 7085704fdebSAl Viro __be32 *savep = NULL; 709e6f684f6SAl Viro __be32 status = res->status; 7101da177e4SLinus Torvalds 7111da177e4SLinus Torvalds if (unlikely(status != 0)) 7121da177e4SLinus Torvalds goto out; 7131da177e4SLinus Torvalds status = encode_attr_bitmap(xdr, res->bitmap, &savep); 7141da177e4SLinus Torvalds if (unlikely(status != 0)) 7151da177e4SLinus Torvalds goto out; 7161da177e4SLinus Torvalds status = encode_attr_change(xdr, res->bitmap, res->change_attr); 7171da177e4SLinus Torvalds if (unlikely(status != 0)) 7181da177e4SLinus Torvalds goto out; 7191da177e4SLinus Torvalds status = encode_attr_size(xdr, res->bitmap, res->size); 7201da177e4SLinus Torvalds if (unlikely(status != 0)) 7211da177e4SLinus Torvalds goto out; 7221da177e4SLinus Torvalds status = encode_attr_ctime(xdr, res->bitmap, &res->ctime); 7231da177e4SLinus Torvalds if (unlikely(status != 0)) 7241da177e4SLinus Torvalds goto out; 7251da177e4SLinus Torvalds status = encode_attr_mtime(xdr, res->bitmap, &res->mtime); 7261da177e4SLinus Torvalds *savep = htonl((unsigned int)((char *)xdr->p - (char *)(savep+1))); 7271da177e4SLinus Torvalds out: 7283110ff80SHarvey Harrison dprintk("%s: exit with status = %d\n", __func__, ntohl(status)); 7291da177e4SLinus Torvalds return status; 7301da177e4SLinus Torvalds } 7311da177e4SLinus Torvalds 73234bc47c9SBenny Halevy #if defined(CONFIG_NFS_V4_1) 73334bc47c9SBenny Halevy 7349733f0d9SAndy Adamson static __be32 encode_sessionid(struct xdr_stream *xdr, 7354aece6a1SBenny Halevy const struct nfs4_sessionid *sid) 7364aece6a1SBenny Halevy { 7379733f0d9SAndy Adamson __be32 *p; 7384aece6a1SBenny Halevy 739590184a6SKinglong Mee p = xdr_reserve_space(xdr, NFS4_MAX_SESSIONID_LEN); 7404aece6a1SBenny Halevy if (unlikely(p == NULL)) 7414aece6a1SBenny Halevy return htonl(NFS4ERR_RESOURCE); 7424aece6a1SBenny Halevy 743590184a6SKinglong Mee memcpy(p, sid, NFS4_MAX_SESSIONID_LEN); 7444aece6a1SBenny Halevy return 0; 7454aece6a1SBenny Halevy } 7464aece6a1SBenny Halevy 7479733f0d9SAndy Adamson static __be32 encode_cb_sequence_res(struct svc_rqst *rqstp, 7484aece6a1SBenny Halevy struct xdr_stream *xdr, 7494aece6a1SBenny Halevy const struct cb_sequenceres *res) 7504aece6a1SBenny Halevy { 7519733f0d9SAndy Adamson __be32 *p; 752e216c8c7SDan Carpenter __be32 status = res->csr_status; 7534aece6a1SBenny Halevy 7544aece6a1SBenny Halevy if (unlikely(status != 0)) 7554aece6a1SBenny Halevy goto out; 7564aece6a1SBenny Halevy 757e0a63c0bSKinglong Mee status = encode_sessionid(xdr, &res->csr_sessionid); 758e0a63c0bSKinglong Mee if (status) 759e0a63c0bSKinglong Mee goto out; 7604aece6a1SBenny Halevy 7614aece6a1SBenny Halevy p = xdr_reserve_space(xdr, 4 * sizeof(uint32_t)); 7624aece6a1SBenny Halevy if (unlikely(p == NULL)) 7634aece6a1SBenny Halevy return htonl(NFS4ERR_RESOURCE); 7644aece6a1SBenny Halevy 7654aece6a1SBenny Halevy *p++ = htonl(res->csr_sequenceid); 7664aece6a1SBenny Halevy *p++ = htonl(res->csr_slotid); 7674aece6a1SBenny Halevy *p++ = htonl(res->csr_highestslotid); 7684aece6a1SBenny Halevy *p++ = htonl(res->csr_target_highestslotid); 7694aece6a1SBenny Halevy out: 7704aece6a1SBenny Halevy dprintk("%s: exit with status = %d\n", __func__, ntohl(status)); 7714aece6a1SBenny Halevy return status; 7724aece6a1SBenny Halevy } 7734aece6a1SBenny Halevy 77434bc47c9SBenny Halevy static __be32 77534bc47c9SBenny Halevy preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op) 77634bc47c9SBenny Halevy { 777281fe15dSBenny Halevy if (op_nr == OP_CB_SEQUENCE) { 778281fe15dSBenny Halevy if (nop != 0) 779281fe15dSBenny Halevy return htonl(NFS4ERR_SEQUENCE_POS); 780281fe15dSBenny Halevy } else { 781281fe15dSBenny Halevy if (nop == 0) 782281fe15dSBenny Halevy return htonl(NFS4ERR_OP_NOT_IN_SESSION); 783281fe15dSBenny Halevy } 784281fe15dSBenny Halevy 78534bc47c9SBenny Halevy switch (op_nr) { 78634bc47c9SBenny Halevy case OP_CB_GETATTR: 78734bc47c9SBenny Halevy case OP_CB_RECALL: 7884aece6a1SBenny Halevy case OP_CB_SEQUENCE: 78931f09607SAlexandros Batsakis case OP_CB_RECALL_ANY: 790b9efa1b2SAndy Adamson case OP_CB_RECALL_SLOT: 791f2a62561SFred Isaman case OP_CB_LAYOUTRECALL: 7921be5683bSMarc Eshel case OP_CB_NOTIFY_DEVICEID: 793db783688SJeff Layton case OP_CB_NOTIFY_LOCK: 79434bc47c9SBenny Halevy *op = &callback_ops[op_nr]; 79534bc47c9SBenny Halevy break; 79634bc47c9SBenny Halevy 79734bc47c9SBenny Halevy case OP_CB_NOTIFY: 79834bc47c9SBenny Halevy case OP_CB_PUSH_DELEG: 79934bc47c9SBenny Halevy case OP_CB_RECALLABLE_OBJ_AVAIL: 80034bc47c9SBenny Halevy case OP_CB_WANTS_CANCELLED: 80134bc47c9SBenny Halevy return htonl(NFS4ERR_NOTSUPP); 80234bc47c9SBenny Halevy 80334bc47c9SBenny Halevy default: 80434bc47c9SBenny Halevy return htonl(NFS4ERR_OP_ILLEGAL); 80534bc47c9SBenny Halevy } 80634bc47c9SBenny Halevy 80734bc47c9SBenny Halevy return htonl(NFS_OK); 80834bc47c9SBenny Halevy } 80934bc47c9SBenny Halevy 810810d82e6STrond Myklebust static void nfs4_callback_free_slot(struct nfs4_session *session, 811810d82e6STrond Myklebust struct nfs4_slot *slot) 81242acd021SAndy Adamson { 81342acd021SAndy Adamson struct nfs4_slot_table *tbl = &session->bc_slot_table; 81442acd021SAndy Adamson 81542acd021SAndy Adamson spin_lock(&tbl->slot_tbl_lock); 81642acd021SAndy Adamson /* 81742acd021SAndy Adamson * Let the state manager know callback processing done. 81842acd021SAndy Adamson * A single slot, so highest used slotid is either 0 or -1 81942acd021SAndy Adamson */ 820810d82e6STrond Myklebust nfs4_free_slot(tbl, slot); 821774d5f14SAndy Adamson nfs4_slot_tbl_drain_complete(tbl); 82242acd021SAndy Adamson spin_unlock(&tbl->slot_tbl_lock); 82342acd021SAndy Adamson } 82442acd021SAndy Adamson 82555a67399STrond Myklebust static void nfs4_cb_free_slot(struct cb_process_state *cps) 82642acd021SAndy Adamson { 827810d82e6STrond Myklebust if (cps->slot) { 828810d82e6STrond Myklebust nfs4_callback_free_slot(cps->clp->cl_session, cps->slot); 829810d82e6STrond Myklebust cps->slot = NULL; 830810d82e6STrond Myklebust } 83142acd021SAndy Adamson } 83242acd021SAndy Adamson 83334bc47c9SBenny Halevy #else /* CONFIG_NFS_V4_1 */ 83434bc47c9SBenny Halevy 83534bc47c9SBenny Halevy static __be32 83634bc47c9SBenny Halevy preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op) 83734bc47c9SBenny Halevy { 83834bc47c9SBenny Halevy return htonl(NFS4ERR_MINOR_VERS_MISMATCH); 83934bc47c9SBenny Halevy } 84034bc47c9SBenny Halevy 84155a67399STrond Myklebust static void nfs4_cb_free_slot(struct cb_process_state *cps) 84242acd021SAndy Adamson { 84342acd021SAndy Adamson } 84434bc47c9SBenny Halevy #endif /* CONFIG_NFS_V4_1 */ 84534bc47c9SBenny Halevy 8466b140b85SBryan Schumaker #ifdef CONFIG_NFS_V4_2 8476b140b85SBryan Schumaker static __be32 8486b140b85SBryan Schumaker preprocess_nfs42_op(int nop, unsigned int op_nr, struct callback_op **op) 8496b140b85SBryan Schumaker { 8506b140b85SBryan Schumaker __be32 status = preprocess_nfs41_op(nop, op_nr, op); 8516b140b85SBryan Schumaker if (status != htonl(NFS4ERR_OP_ILLEGAL)) 8526b140b85SBryan Schumaker return status; 8536b140b85SBryan Schumaker 8546b140b85SBryan Schumaker if (op_nr == OP_CB_OFFLOAD) 8556b140b85SBryan Schumaker return htonl(NFS4ERR_NOTSUPP); 8566b140b85SBryan Schumaker return htonl(NFS4ERR_OP_ILLEGAL); 8576b140b85SBryan Schumaker } 8586b140b85SBryan Schumaker #else /* CONFIG_NFS_V4_2 */ 8596b140b85SBryan Schumaker static __be32 8606b140b85SBryan Schumaker preprocess_nfs42_op(int nop, unsigned int op_nr, struct callback_op **op) 8616b140b85SBryan Schumaker { 8626b140b85SBryan Schumaker return htonl(NFS4ERR_MINOR_VERS_MISMATCH); 8636b140b85SBryan Schumaker } 8646b140b85SBryan Schumaker #endif /* CONFIG_NFS_V4_2 */ 8656b140b85SBryan Schumaker 86634bc47c9SBenny Halevy static __be32 86734bc47c9SBenny Halevy preprocess_nfs4_op(unsigned int op_nr, struct callback_op **op) 86834bc47c9SBenny Halevy { 86934bc47c9SBenny Halevy switch (op_nr) { 87034bc47c9SBenny Halevy case OP_CB_GETATTR: 87134bc47c9SBenny Halevy case OP_CB_RECALL: 87234bc47c9SBenny Halevy *op = &callback_ops[op_nr]; 87334bc47c9SBenny Halevy break; 87434bc47c9SBenny Halevy default: 87534bc47c9SBenny Halevy return htonl(NFS4ERR_OP_ILLEGAL); 87634bc47c9SBenny Halevy } 87734bc47c9SBenny Halevy 87834bc47c9SBenny Halevy return htonl(NFS_OK); 87934bc47c9SBenny Halevy } 88034bc47c9SBenny Halevy 881459de2edSBryan Schumaker static __be32 process_op(int nop, struct svc_rqst *rqstp, 8821da177e4SLinus Torvalds struct xdr_stream *xdr_in, void *argp, 883c36fca52SAndy Adamson struct xdr_stream *xdr_out, void *resp, 884c36fca52SAndy Adamson struct cb_process_state *cps) 8851da177e4SLinus Torvalds { 886a162a6b8STrond Myklebust struct callback_op *op = &callback_ops[0]; 88731d2b435SAndy Adamson unsigned int op_nr; 88834bc47c9SBenny Halevy __be32 status; 8891da177e4SLinus Torvalds long maxlen; 890e6f684f6SAl Viro __be32 res; 8911da177e4SLinus Torvalds 8923110ff80SHarvey Harrison dprintk("%s: start\n", __func__); 8931da177e4SLinus Torvalds status = decode_op_hdr(xdr_in, &op_nr); 89431d2b435SAndy Adamson if (unlikely(status)) 89531d2b435SAndy Adamson return status; 8961da177e4SLinus Torvalds 89734bc47c9SBenny Halevy dprintk("%s: minorversion=%d nop=%d op_nr=%u\n", 898459de2edSBryan Schumaker __func__, cps->minorversion, nop, op_nr); 89934bc47c9SBenny Halevy 9006b140b85SBryan Schumaker switch (cps->minorversion) { 9016b140b85SBryan Schumaker case 0: 9026b140b85SBryan Schumaker status = preprocess_nfs4_op(op_nr, &op); 9036b140b85SBryan Schumaker break; 9046b140b85SBryan Schumaker case 1: 9056b140b85SBryan Schumaker status = preprocess_nfs41_op(nop, op_nr, &op); 9066b140b85SBryan Schumaker break; 9076b140b85SBryan Schumaker case 2: 9086b140b85SBryan Schumaker status = preprocess_nfs42_op(nop, op_nr, &op); 9096b140b85SBryan Schumaker break; 9106b140b85SBryan Schumaker default: 9116b140b85SBryan Schumaker status = htonl(NFS4ERR_MINOR_VERS_MISMATCH); 9126b140b85SBryan Schumaker } 9136b140b85SBryan Schumaker 91434bc47c9SBenny Halevy if (status == htonl(NFS4ERR_OP_ILLEGAL)) 91534bc47c9SBenny Halevy op_nr = OP_CB_ILLEGAL; 916b92b3019SAndy Adamson if (status) 917b92b3019SAndy Adamson goto encode_hdr; 91831d2b435SAndy Adamson 919c36fca52SAndy Adamson if (cps->drc_status) { 920c36fca52SAndy Adamson status = cps->drc_status; 9214911096fSAndy Adamson goto encode_hdr; 9224911096fSAndy Adamson } 9234911096fSAndy Adamson 9241da177e4SLinus Torvalds maxlen = xdr_out->end - xdr_out->p; 9251da177e4SLinus Torvalds if (maxlen > 0 && maxlen < PAGE_SIZE) { 9261da177e4SLinus Torvalds status = op->decode_args(rqstp, xdr_in, argp); 927e95e60daSAndy Adamson if (likely(status == 0)) 928c36fca52SAndy Adamson status = op->process_op(argp, resp, cps); 9291da177e4SLinus Torvalds } else 9301da177e4SLinus Torvalds status = htonl(NFS4ERR_RESOURCE); 9311da177e4SLinus Torvalds 932b92b3019SAndy Adamson encode_hdr: 9331da177e4SLinus Torvalds res = encode_op_hdr(xdr_out, op_nr, status); 93431d2b435SAndy Adamson if (unlikely(res)) 93531d2b435SAndy Adamson return res; 9361da177e4SLinus Torvalds if (op->encode_res != NULL && status == 0) 9371da177e4SLinus Torvalds status = op->encode_res(rqstp, xdr_out, resp); 9383110ff80SHarvey Harrison dprintk("%s: done, status = %d\n", __func__, ntohl(status)); 9391da177e4SLinus Torvalds return status; 9401da177e4SLinus Torvalds } 9411da177e4SLinus Torvalds 9421da177e4SLinus Torvalds /* 9431da177e4SLinus Torvalds * Decode, process and encode a COMPOUND 9441da177e4SLinus Torvalds */ 9457111c66eSAl Viro static __be32 nfs4_callback_compound(struct svc_rqst *rqstp, void *argp, void *resp) 9461da177e4SLinus Torvalds { 9473a6258e1STrond Myklebust struct cb_compound_hdr_arg hdr_arg = { 0 }; 9483a6258e1STrond Myklebust struct cb_compound_hdr_res hdr_res = { NULL }; 9491da177e4SLinus Torvalds struct xdr_stream xdr_in, xdr_out; 950c36fca52SAndy Adamson __be32 *p, status; 951c36fca52SAndy Adamson struct cb_process_state cps = { 952c36fca52SAndy Adamson .drc_status = 0, 953c36fca52SAndy Adamson .clp = NULL, 9549695c705SStanislav Kinsbursky .net = SVC_NET(rqstp), 955c36fca52SAndy Adamson }; 9563a6258e1STrond Myklebust unsigned int nops = 0; 9571da177e4SLinus Torvalds 9583110ff80SHarvey Harrison dprintk("%s: start\n", __func__); 9591da177e4SLinus Torvalds 960756b9b37STrond Myklebust xdr_init_decode(&xdr_in, &rqstp->rq_arg, rqstp->rq_arg.head[0].iov_base); 9611da177e4SLinus Torvalds 9625704fdebSAl Viro p = (__be32*)((char *)rqstp->rq_res.head[0].iov_base + rqstp->rq_res.head[0].iov_len); 9631da177e4SLinus Torvalds xdr_init_encode(&xdr_out, &rqstp->rq_res, p); 9641da177e4SLinus Torvalds 9653a6258e1STrond Myklebust status = decode_compound_hdr_arg(&xdr_in, &hdr_arg); 9664ed0d83dSVaishali Thakkar if (status == htonl(NFS4ERR_RESOURCE)) 9673a6258e1STrond Myklebust return rpc_garbage_args; 9683a6258e1STrond Myklebust 969c36fca52SAndy Adamson if (hdr_arg.minorversion == 0) { 9709695c705SStanislav Kinsbursky cps.clp = nfs4_find_client_ident(SVC_NET(rqstp), hdr_arg.cb_ident); 971778be232SAndy Adamson if (!cps.clp || !check_gss_callback_principal(cps.clp, rqstp)) 972a4e187d8SChuck Lever goto out_invalidcred; 973778be232SAndy Adamson } 974c36fca52SAndy Adamson 975459de2edSBryan Schumaker cps.minorversion = hdr_arg.minorversion; 9761da177e4SLinus Torvalds hdr_res.taglen = hdr_arg.taglen; 9771da177e4SLinus Torvalds hdr_res.tag = hdr_arg.tag; 9783a6258e1STrond Myklebust if (encode_compound_hdr_res(&xdr_out, &hdr_res) != 0) 9793a6258e1STrond Myklebust return rpc_system_err; 9801da177e4SLinus Torvalds 9813a6258e1STrond Myklebust while (status == 0 && nops != hdr_arg.nops) { 982459de2edSBryan Schumaker status = process_op(nops, rqstp, &xdr_in, 983459de2edSBryan Schumaker argp, &xdr_out, resp, &cps); 9841da177e4SLinus Torvalds nops++; 9851da177e4SLinus Torvalds } 9863a6258e1STrond Myklebust 98731d2b435SAndy Adamson /* Buffer overflow in decode_ops_hdr or encode_ops_hdr. Return 98831d2b435SAndy Adamson * resource error in cb_compound status without returning op */ 98931d2b435SAndy Adamson if (unlikely(status == htonl(NFS4ERR_RESOURCE_HDR))) { 99031d2b435SAndy Adamson status = htonl(NFS4ERR_RESOURCE); 99131d2b435SAndy Adamson nops--; 99231d2b435SAndy Adamson } 99331d2b435SAndy Adamson 9941da177e4SLinus Torvalds *hdr_res.status = status; 9951da177e4SLinus Torvalds *hdr_res.nops = htonl(nops); 99655a67399STrond Myklebust nfs4_cb_free_slot(&cps); 997c36fca52SAndy Adamson nfs_put_client(cps.clp); 9983110ff80SHarvey Harrison dprintk("%s: done, status = %u\n", __func__, ntohl(status)); 9991da177e4SLinus Torvalds return rpc_success; 1000a4e187d8SChuck Lever 1001a4e187d8SChuck Lever out_invalidcred: 1002a4e187d8SChuck Lever pr_warn_ratelimited("NFS: NFSv4 callback contains invalid cred\n"); 1003a4e187d8SChuck Lever return rpc_autherr_badcred; 10041da177e4SLinus Torvalds } 10051da177e4SLinus Torvalds 10061da177e4SLinus Torvalds /* 10071da177e4SLinus Torvalds * Define NFS4 callback COMPOUND ops. 10081da177e4SLinus Torvalds */ 10091da177e4SLinus Torvalds static struct callback_op callback_ops[] = { 10101da177e4SLinus Torvalds [0] = { 10111da177e4SLinus Torvalds .res_maxsize = CB_OP_HDR_RES_MAXSZ, 10121da177e4SLinus Torvalds }, 10131da177e4SLinus Torvalds [OP_CB_GETATTR] = { 10141da177e4SLinus Torvalds .process_op = (callback_process_op_t)nfs4_callback_getattr, 10151da177e4SLinus Torvalds .decode_args = (callback_decode_arg_t)decode_getattr_args, 10161da177e4SLinus Torvalds .encode_res = (callback_encode_res_t)encode_getattr_res, 10171da177e4SLinus Torvalds .res_maxsize = CB_OP_GETATTR_RES_MAXSZ, 10181da177e4SLinus Torvalds }, 10191da177e4SLinus Torvalds [OP_CB_RECALL] = { 10201da177e4SLinus Torvalds .process_op = (callback_process_op_t)nfs4_callback_recall, 10211da177e4SLinus Torvalds .decode_args = (callback_decode_arg_t)decode_recall_args, 10221da177e4SLinus Torvalds .res_maxsize = CB_OP_RECALL_RES_MAXSZ, 10234aece6a1SBenny Halevy }, 10244aece6a1SBenny Halevy #if defined(CONFIG_NFS_V4_1) 1025f2a62561SFred Isaman [OP_CB_LAYOUTRECALL] = { 1026f2a62561SFred Isaman .process_op = (callback_process_op_t)nfs4_callback_layoutrecall, 1027f2a62561SFred Isaman .decode_args = 1028f2a62561SFred Isaman (callback_decode_arg_t)decode_layoutrecall_args, 1029f2a62561SFred Isaman .res_maxsize = CB_OP_LAYOUTRECALL_RES_MAXSZ, 1030f2a62561SFred Isaman }, 10311be5683bSMarc Eshel [OP_CB_NOTIFY_DEVICEID] = { 10321be5683bSMarc Eshel .process_op = (callback_process_op_t)nfs4_callback_devicenotify, 10331be5683bSMarc Eshel .decode_args = 10341be5683bSMarc Eshel (callback_decode_arg_t)decode_devicenotify_args, 10351be5683bSMarc Eshel .res_maxsize = CB_OP_DEVICENOTIFY_RES_MAXSZ, 10361be5683bSMarc Eshel }, 10374aece6a1SBenny Halevy [OP_CB_SEQUENCE] = { 10384aece6a1SBenny Halevy .process_op = (callback_process_op_t)nfs4_callback_sequence, 10394aece6a1SBenny Halevy .decode_args = (callback_decode_arg_t)decode_cb_sequence_args, 10404aece6a1SBenny Halevy .encode_res = (callback_encode_res_t)encode_cb_sequence_res, 10414aece6a1SBenny Halevy .res_maxsize = CB_OP_SEQUENCE_RES_MAXSZ, 10424aece6a1SBenny Halevy }, 104331f09607SAlexandros Batsakis [OP_CB_RECALL_ANY] = { 104431f09607SAlexandros Batsakis .process_op = (callback_process_op_t)nfs4_callback_recallany, 104531f09607SAlexandros Batsakis .decode_args = (callback_decode_arg_t)decode_recallany_args, 104631f09607SAlexandros Batsakis .res_maxsize = CB_OP_RECALLANY_RES_MAXSZ, 104731f09607SAlexandros Batsakis }, 1048b9efa1b2SAndy Adamson [OP_CB_RECALL_SLOT] = { 1049b9efa1b2SAndy Adamson .process_op = (callback_process_op_t)nfs4_callback_recallslot, 1050b9efa1b2SAndy Adamson .decode_args = (callback_decode_arg_t)decode_recallslot_args, 1051b9efa1b2SAndy Adamson .res_maxsize = CB_OP_RECALLSLOT_RES_MAXSZ, 1052b9efa1b2SAndy Adamson }, 1053db783688SJeff Layton [OP_CB_NOTIFY_LOCK] = { 1054db783688SJeff Layton .process_op = (callback_process_op_t)nfs4_callback_notify_lock, 1055db783688SJeff Layton .decode_args = (callback_decode_arg_t)decode_notify_lock_args, 1056db783688SJeff Layton .res_maxsize = CB_OP_NOTIFY_LOCK_RES_MAXSZ, 1057db783688SJeff Layton }, 10584aece6a1SBenny Halevy #endif /* CONFIG_NFS_V4_1 */ 10591da177e4SLinus Torvalds }; 10601da177e4SLinus Torvalds 10611da177e4SLinus Torvalds /* 10621da177e4SLinus Torvalds * Define NFS4 callback procedures 10631da177e4SLinus Torvalds */ 10641da177e4SLinus Torvalds static struct svc_procedure nfs4_callback_procedures1[] = { 10651da177e4SLinus Torvalds [CB_NULL] = { 10661da177e4SLinus Torvalds .pc_func = nfs4_callback_null, 10671da177e4SLinus Torvalds .pc_decode = (kxdrproc_t)nfs4_decode_void, 10681da177e4SLinus Torvalds .pc_encode = (kxdrproc_t)nfs4_encode_void, 10691da177e4SLinus Torvalds .pc_xdrressize = 1, 10701da177e4SLinus Torvalds }, 10711da177e4SLinus Torvalds [CB_COMPOUND] = { 10721da177e4SLinus Torvalds .pc_func = nfs4_callback_compound, 10731da177e4SLinus Torvalds .pc_encode = (kxdrproc_t)nfs4_encode_void, 10741da177e4SLinus Torvalds .pc_argsize = 256, 10751da177e4SLinus Torvalds .pc_ressize = 256, 10761da177e4SLinus Torvalds .pc_xdrressize = NFS4_CALLBACK_BUFSIZE, 10771da177e4SLinus Torvalds } 10781da177e4SLinus Torvalds }; 10791da177e4SLinus Torvalds 10801da177e4SLinus Torvalds struct svc_version nfs4_callback_version1 = { 10811da177e4SLinus Torvalds .vs_vers = 1, 10821da177e4SLinus Torvalds .vs_nproc = ARRAY_SIZE(nfs4_callback_procedures1), 10831da177e4SLinus Torvalds .vs_proc = nfs4_callback_procedures1, 10841da177e4SLinus Torvalds .vs_xdrsize = NFS4_CALLBACK_XDRSIZE, 10851da177e4SLinus Torvalds .vs_dispatch = NULL, 108605a45a2dSJeff Layton .vs_hidden = true, 10875283b03eSJeff Layton .vs_need_cong_ctrl = true, 10881da177e4SLinus Torvalds }; 10891da177e4SLinus Torvalds 109007bccc2dSAlexandros Batsakis struct svc_version nfs4_callback_version4 = { 109107bccc2dSAlexandros Batsakis .vs_vers = 4, 109207bccc2dSAlexandros Batsakis .vs_nproc = ARRAY_SIZE(nfs4_callback_procedures1), 109307bccc2dSAlexandros Batsakis .vs_proc = nfs4_callback_procedures1, 109407bccc2dSAlexandros Batsakis .vs_xdrsize = NFS4_CALLBACK_XDRSIZE, 109507bccc2dSAlexandros Batsakis .vs_dispatch = NULL, 109605a45a2dSJeff Layton .vs_hidden = true, 10975283b03eSJeff Layton .vs_need_cong_ctrl = true, 109807bccc2dSAlexandros Batsakis }; 1099