Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
0002 /*
0003  * Upcall description for nfsdcld communication
0004  *
0005  * Copyright (c) 2012 Red Hat, Inc.
0006  * Author(s): Jeff Layton <jlayton@redhat.com>
0007  *
0008  *  This program is free software; you can redistribute it and/or modify
0009  *  it under the terms of the GNU General Public License as published by
0010  *  the Free Software Foundation; either version 2 of the License, or
0011  *  (at your option) any later version.
0012  *
0013  *  This program is distributed in the hope that it will be useful,
0014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0016  *  GNU General Public License for more details.
0017  *
0018  *  You should have received a copy of the GNU General Public License
0019  *  along with this program; if not, write to the Free Software
0020  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
0021  */
0022 
0023 #ifndef _NFSD_CLD_H
0024 #define _NFSD_CLD_H
0025 
0026 #include <linux/types.h>
0027 
0028 /* latest upcall version available */
0029 #define CLD_UPCALL_VERSION 2
0030 
0031 /* defined by RFC3530 */
0032 #define NFS4_OPAQUE_LIMIT 1024
0033 
0034 #ifndef SHA256_DIGEST_SIZE
0035 #define SHA256_DIGEST_SIZE      32
0036 #endif
0037 
0038 enum cld_command {
0039     Cld_Create,     /* create a record for this cm_id */
0040     Cld_Remove,     /* remove record of this cm_id */
0041     Cld_Check,      /* is this cm_id allowed? */
0042     Cld_GraceDone,      /* grace period is complete */
0043     Cld_GraceStart,     /* grace start (upload client records) */
0044     Cld_GetVersion,     /* query max supported upcall version */
0045 };
0046 
0047 /* representation of long-form NFSv4 client ID */
0048 struct cld_name {
0049     __u16       cn_len;             /* length of cm_id */
0050     unsigned char   cn_id[NFS4_OPAQUE_LIMIT];   /* client-provided */
0051 } __attribute__((packed));
0052 
0053 /* sha256 hash of the kerberos principal */
0054 struct cld_princhash {
0055     __u8        cp_len;             /* length of cp_data */
0056     unsigned char   cp_data[SHA256_DIGEST_SIZE];    /* hash of principal */
0057 } __attribute__((packed));
0058 
0059 struct cld_clntinfo {
0060     struct cld_name     cc_name;
0061     struct cld_princhash    cc_princhash;
0062 } __attribute__((packed));
0063 
0064 /* message struct for communication with userspace */
0065 struct cld_msg {
0066     __u8        cm_vers;        /* upcall version */
0067     __u8        cm_cmd;         /* upcall command */
0068     __s16       cm_status;      /* return code */
0069     __u32       cm_xid;         /* transaction id */
0070     union {
0071         __s64       cm_gracetime;   /* grace period start time */
0072         struct cld_name cm_name;
0073         __u8        cm_version; /* for getting max version */
0074     } __attribute__((packed)) cm_u;
0075 } __attribute__((packed));
0076 
0077 /* version 2 message can include hash of kerberos principal */
0078 struct cld_msg_v2 {
0079     __u8        cm_vers;        /* upcall version */
0080     __u8        cm_cmd;         /* upcall command */
0081     __s16       cm_status;      /* return code */
0082     __u32       cm_xid;         /* transaction id */
0083     union {
0084         struct cld_name cm_name;
0085         __u8        cm_version; /* for getting max version */
0086         struct cld_clntinfo cm_clntinfo; /* name & princ hash */
0087     } __attribute__((packed)) cm_u;
0088 } __attribute__((packed));
0089 
0090 struct cld_msg_hdr {
0091     __u8        cm_vers;        /* upcall version */
0092     __u8        cm_cmd;         /* upcall command */
0093     __s16       cm_status;      /* return code */
0094     __u32       cm_xid;         /* transaction id */
0095 } __attribute__((packed));
0096 
0097 #endif /* !_NFSD_CLD_H */