1191783Srmacklem/*- 2191783Srmacklem * Copyright (c) 1989, 1993 3191783Srmacklem * The Regents of the University of California. All rights reserved. 4191783Srmacklem * 5191783Srmacklem * This code is derived from software contributed to Berkeley by 6191783Srmacklem * Rick Macklem at The University of Guelph. 7191783Srmacklem * 8191783Srmacklem * Redistribution and use in source and binary forms, with or without 9191783Srmacklem * modification, are permitted provided that the following conditions 10191783Srmacklem * are met: 11191783Srmacklem * 1. Redistributions of source code must retain the above copyright 12191783Srmacklem * notice, this list of conditions and the following disclaimer. 13191783Srmacklem * 2. Redistributions in binary form must reproduce the above copyright 14191783Srmacklem * notice, this list of conditions and the following disclaimer in the 15191783Srmacklem * documentation and/or other materials provided with the distribution. 16191783Srmacklem * 4. Neither the name of the University nor the names of its contributors 17191783Srmacklem * may be used to endorse or promote products derived from this software 18191783Srmacklem * without specific prior written permission. 19191783Srmacklem * 20191783Srmacklem * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21191783Srmacklem * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22191783Srmacklem * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23191783Srmacklem * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24191783Srmacklem * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25191783Srmacklem * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26191783Srmacklem * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27191783Srmacklem * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28191783Srmacklem * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29191783Srmacklem * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30191783Srmacklem * SUCH DAMAGE. 31191783Srmacklem * 32191783Srmacklem * $FreeBSD: releng/10.3/sys/fs/nfs/nfs.h 292223 2015-12-14 21:21:43Z rmacklem $ 33191783Srmacklem */ 34191783Srmacklem 35191783Srmacklem#ifndef _NFS_NFS_H_ 36191783Srmacklem#define _NFS_NFS_H_ 37191783Srmacklem/* 38191783Srmacklem * Tunable constants for nfs 39191783Srmacklem */ 40191783Srmacklem 41191783Srmacklem#define NFS_MAXIOVEC 34 42221523Smav#define NFS_TICKINTVL 500 /* Desired time for a tick (msec) */ 43191783Srmacklem#define NFS_HZ (hz / nfscl_ticks) /* Ticks/sec */ 44191783Srmacklem#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */ 45191783Srmacklem#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */ 46191783Srmacklem#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */ 47191783Srmacklem#define NFS_TCPTIMEO 300 /* TCP timeout */ 48191783Srmacklem#define NFS_MAXRCVTIMEO 60 /* 1 minute in seconds */ 49191783Srmacklem#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/ 50191783Srmacklem#define NFS_MAXREXMIT 100 /* Stop counting after this many */ 51191783Srmacklem#define NFSV4_CALLBACKTIMEO (2 * NFS_HZ) /* Timeout in ticks */ 52191783Srmacklem#define NFSV4_CALLBACKRETRY 5 /* Number of retries before failure */ 53269398Srmacklem#define NFSV4_SLOTS 64 /* Number of slots, fore channel */ 54269398Srmacklem#define NFSV4_CBSLOTS 8 /* Number of slots, back channel */ 55191783Srmacklem#define NFSV4_CBRETRYCNT 4 /* # of CBRecall retries upon err */ 56191783Srmacklem#define NFSV4_UPCALLTIMEO (15 * NFS_HZ) /* Timeout in ticks for upcalls */ 57191783Srmacklem /* to gssd or nfsuserd */ 58191783Srmacklem#define NFSV4_UPCALLRETRY 4 /* Number of retries before failure */ 59191783Srmacklem#define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */ 60191783Srmacklem#define NFS_RETRANS 10 /* Num of retrans for soft mounts */ 61220739Srmacklem#define NFS_RETRANS_TCP 2 /* Num of retrans for TCP soft mounts */ 62191783Srmacklem#define NFS_MAXGRPS 16 /* Max. size of groups list */ 63191783Srmacklem#define NFS_TRYLATERDEL 15 /* Maximum delay timeout (sec) */ 64191783Srmacklem#ifndef NFS_REMOVETIMEO 65191783Srmacklem#define NFS_REMOVETIMEO 15 /* # sec to wait for delegret in local syscall */ 66191783Srmacklem#endif 67191783Srmacklem#ifndef NFS_MINATTRTIMO 68191783Srmacklem#define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */ 69191783Srmacklem#endif 70191783Srmacklem#ifndef NFS_MAXATTRTIMO 71191783Srmacklem#define NFS_MAXATTRTIMO 60 72191783Srmacklem#endif 73191783Srmacklem#define NFS_WSIZE 8192 /* Def. write data size <= 8192 */ 74191783Srmacklem#define NFS_RSIZE 8192 /* Def. read data size <= 8192 */ 75191783Srmacklem#define NFS_READDIRSIZE 8192 /* Def. readdir size */ 76220683Srmacklem#define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */ 77220683Srmacklem#define NFS_MAXRAHEAD 16 /* Max. read ahead # blocks */ 78220683Srmacklem#define NFS_MAXASYNCDAEMON 64 /* Max. number async_daemons runnable */ 79191783Srmacklem#define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */ 80191783Srmacklem#ifndef NFSRV_LEASE 81191783Srmacklem#define NFSRV_LEASE 120 /* Lease time in seconds for V4 */ 82191783Srmacklem#endif /* assigned to nfsrv_lease */ 83191783Srmacklem#ifndef NFSRV_STALELEASE 84191783Srmacklem#define NFSRV_STALELEASE (5 * nfsrv_lease) 85191783Srmacklem#endif 86191783Srmacklem#ifndef NFSRV_MOULDYLEASE 87191783Srmacklem#define NFSRV_MOULDYLEASE 604800 /* One week (in sec) */ 88191783Srmacklem#endif 89191783Srmacklem#ifndef NFSCLIENTHASHSIZE 90191783Srmacklem#define NFSCLIENTHASHSIZE 20 /* Size of server client hash table */ 91191783Srmacklem#endif 92191783Srmacklem#ifndef NFSLOCKHASHSIZE 93191783Srmacklem#define NFSLOCKHASHSIZE 20 /* Size of server nfslock hash table */ 94191783Srmacklem#endif 95269398Srmacklem#ifndef NFSSESSIONHASHSIZE 96269398Srmacklem#define NFSSESSIONHASHSIZE 20 /* Size of server session hash table */ 97269398Srmacklem#endif 98191783Srmacklem#define NFSSTATEHASHSIZE 10 /* Size of server stateid hash table */ 99191783Srmacklem#ifndef NFSCLDELEGHIGHWATER 100191783Srmacklem#define NFSCLDELEGHIGHWATER 10000 /* limit for client delegations */ 101191783Srmacklem#endif 102244042Srmacklem#ifndef NFSCLLAYOUTHIGHWATER 103244042Srmacklem#define NFSCLLAYOUTHIGHWATER 10000 /* limit for client pNFS layouts */ 104244042Srmacklem#endif 105191783Srmacklem#ifndef NFSNOOPEN /* Inactive open owner (sec) */ 106191783Srmacklem#define NFSNOOPEN 120 107191783Srmacklem#endif 108191783Srmacklem#define NFSRV_LEASEDELTA 15 /* # of seconds to delay beyond lease */ 109191783Srmacklem#define NFS_IDMAXSIZE 4 /* max sizeof (in_addr_t) */ 110191783Srmacklem#ifndef NFSRVCACHE_UDPTIMEOUT 111191783Srmacklem#define NFSRVCACHE_UDPTIMEOUT 30 /* # of sec to hold cached rpcs(udp) */ 112191783Srmacklem#endif 113191783Srmacklem#ifndef NFSRVCACHE_UDPHIGHWATER 114191783Srmacklem#define NFSRVCACHE_UDPHIGHWATER 500 /* Max # of udp cache entries */ 115191783Srmacklem#endif 116191783Srmacklem#ifndef NFSRVCACHE_TCPTIMEOUT 117191783Srmacklem#define NFSRVCACHE_TCPTIMEOUT (3600*12) /*#of sec to hold cached rpcs(tcp) */ 118191783Srmacklem#endif 119191783Srmacklem#ifndef NFSRVCACHE_FLOODLEVEL 120191783Srmacklem#define NFSRVCACHE_FLOODLEVEL 16384 /* Very high water mark for cache */ 121191783Srmacklem#endif 122191783Srmacklem#ifndef NFSRV_CLIENTHIGHWATER 123191783Srmacklem#define NFSRV_CLIENTHIGHWATER 1000 124191783Srmacklem#endif 125191783Srmacklem#ifndef NFSRV_MAXDUMPLIST 126191783Srmacklem#define NFSRV_MAXDUMPLIST 10000 127191783Srmacklem#endif 128191783Srmacklem#ifndef NFS_ACCESSCACHESIZE 129191783Srmacklem#define NFS_ACCESSCACHESIZE 8 130191783Srmacklem#endif 131191783Srmacklem#define NFSV4_CBPORT 7745 /* Callback port for testing */ 132191783Srmacklem 133191783Srmacklem/* 134191783Srmacklem * This macro defines the high water mark for issuing V4 delegations. 135284216Srmacklem * (It is currently set at a conservative 20% of nfsrv_v4statelimit. This 136191783Srmacklem * may want to increase when clients can make more effective use of 137191783Srmacklem * delegations.) 138191783Srmacklem */ 139284216Srmacklem#define NFSRV_V4DELEGLIMIT(c) (((c) * 5) > nfsrv_v4statelimit) 140191783Srmacklem 141191783Srmacklem#define NFS_READDIRBLKSIZ DIRBLKSIZ /* Minimal nm_readdirsize */ 142191783Srmacklem 143191783Srmacklem/* 144191783Srmacklem * Oddballs 145191783Srmacklem */ 146191783Srmacklem#define NFS_CMPFH(n, f, s) \ 147191783Srmacklem ((n)->n_fhp->nfh_len == (s) && !NFSBCMP((n)->n_fhp->nfh_fh, (caddr_t)(f), (s))) 148191783Srmacklem#define NFSRV_CMPFH(nf, ns, f, s) \ 149191783Srmacklem ((ns) == (s) && !NFSBCMP((caddr_t)(nf), (caddr_t)(f), (s))) 150191783Srmacklem#define NFS_CMPTIME(t1, t2) \ 151191783Srmacklem ((t1).tv_sec == (t2).tv_sec && (t1).tv_nsec == (t2).tv_nsec) 152191783Srmacklem#define NFS_SETTIME(t) do { \ 153191783Srmacklem (t).tv_sec = time.tv_sec; (t).tv_nsec = 1000 * time.tv_usec; } while (0) 154191783Srmacklem#define NFS_SRVMAXDATA(n) \ 155191783Srmacklem (((n)->nd_flag & (ND_NFSV3 | ND_NFSV4)) ? \ 156282271Srmacklem NFS_SRVMAXIO : NFS_V2MAXDATA) 157191783Srmacklem#define NFS64BITSSET 0xffffffffffffffffull 158191783Srmacklem#define NFS64BITSMINUS1 0xfffffffffffffffeull 159191783Srmacklem 160191783Srmacklem/* 161191783Srmacklem * Structures for the nfssvc(2) syscall. Not that anyone but nfsd, mount_nfs 162191783Srmacklem * and nfsloaduser should ever try and use it. 163191783Srmacklem */ 164192000Srmacklemstruct nfsd_addsock_args { 165191783Srmacklem int sock; /* Socket to serve */ 166191783Srmacklem caddr_t name; /* Client addr for connection based sockets */ 167191783Srmacklem int namelen; /* Length of name */ 168191783Srmacklem}; 169191783Srmacklem 170191783Srmacklem/* 171191783Srmacklem * nfsd argument for new krpc. 172191783Srmacklem */ 173191783Srmacklemstruct nfsd_nfsd_args { 174191783Srmacklem const char *principal; /* GSS-API service principal name */ 175191783Srmacklem int minthreads; /* minimum service thread count */ 176191783Srmacklem int maxthreads; /* maximum service thread count */ 177191783Srmacklem}; 178191783Srmacklem 179191783Srmacklem/* 180191783Srmacklem * Arguments for use by the callback daemon. 181191783Srmacklem */ 182191783Srmacklemstruct nfsd_nfscbd_args { 183191783Srmacklem const char *principal; /* GSS-API service principal name */ 184191783Srmacklem}; 185191783Srmacklem 186191783Srmacklemstruct nfscbd_args { 187191783Srmacklem int sock; /* Socket to serve */ 188191783Srmacklem caddr_t name; /* Client addr for connection based sockets */ 189191783Srmacklem int namelen; /* Length of name */ 190191783Srmacklem u_short port; /* Port# for callbacks */ 191191783Srmacklem}; 192191783Srmacklem 193191783Srmacklemstruct nfsd_idargs { 194191783Srmacklem int nid_flag; /* Flags (see below) */ 195191783Srmacklem uid_t nid_uid; /* user/group id */ 196191783Srmacklem gid_t nid_gid; 197191783Srmacklem int nid_usermax; /* Upper bound on user name cache */ 198191783Srmacklem int nid_usertimeout;/* User name timeout (minutes) */ 199191783Srmacklem u_char *nid_name; /* Name */ 200191783Srmacklem int nid_namelen; /* and its length */ 201292223Srmacklem gid_t *nid_grps; /* and the list */ 202292223Srmacklem int nid_ngroup; /* Size of groups list */ 203191783Srmacklem}; 204191783Srmacklem 205292223Srmacklemstruct nfsd_oidargs { 206292223Srmacklem int nid_flag; /* Flags (see below) */ 207292223Srmacklem uid_t nid_uid; /* user/group id */ 208292223Srmacklem gid_t nid_gid; 209292223Srmacklem int nid_usermax; /* Upper bound on user name cache */ 210292223Srmacklem int nid_usertimeout;/* User name timeout (minutes) */ 211292223Srmacklem u_char *nid_name; /* Name */ 212292223Srmacklem int nid_namelen; /* and its length */ 213292223Srmacklem}; 214292223Srmacklem 215191783Srmacklemstruct nfsd_clid { 216191783Srmacklem int nclid_idlen; /* Length of client id */ 217191783Srmacklem u_char nclid_id[NFSV4_OPAQUELIMIT]; /* and name */ 218191783Srmacklem}; 219191783Srmacklem 220191783Srmacklemstruct nfsd_dumplist { 221191783Srmacklem int ndl_size; /* Number of elements */ 222191783Srmacklem void *ndl_list; /* and the list of elements */ 223191783Srmacklem}; 224191783Srmacklem 225191783Srmacklemstruct nfsd_dumpclients { 226191783Srmacklem u_int32_t ndcl_flags; /* LCL_xxx flags */ 227191783Srmacklem u_int32_t ndcl_nopenowners; /* Number of openowners */ 228191783Srmacklem u_int32_t ndcl_nopens; /* and opens */ 229191783Srmacklem u_int32_t ndcl_nlockowners; /* and of lockowners */ 230191783Srmacklem u_int32_t ndcl_nlocks; /* and of locks */ 231191783Srmacklem u_int32_t ndcl_ndelegs; /* and of delegations */ 232191783Srmacklem u_int32_t ndcl_nolddelegs; /* and old delegations */ 233191783Srmacklem sa_family_t ndcl_addrfam; /* Callback address */ 234191783Srmacklem union { 235191783Srmacklem struct in_addr sin_addr; 236191783Srmacklem struct in6_addr sin6_addr; 237191783Srmacklem } ndcl_cbaddr; 238191783Srmacklem struct nfsd_clid ndcl_clid; /* and client id */ 239191783Srmacklem}; 240191783Srmacklem 241191783Srmacklemstruct nfsd_dumplocklist { 242191783Srmacklem char *ndllck_fname; /* File Name */ 243191783Srmacklem int ndllck_size; /* Number of elements */ 244191783Srmacklem void *ndllck_list; /* and the list of elements */ 245191783Srmacklem}; 246191783Srmacklem 247191783Srmacklemstruct nfsd_dumplocks { 248191783Srmacklem u_int32_t ndlck_flags; /* state flags NFSLCK_xxx */ 249191783Srmacklem nfsv4stateid_t ndlck_stateid; /* stateid */ 250191783Srmacklem u_int64_t ndlck_first; /* lock byte range */ 251191783Srmacklem u_int64_t ndlck_end; 252191783Srmacklem struct nfsd_clid ndlck_owner; /* Owner of open/lock */ 253191783Srmacklem sa_family_t ndlck_addrfam; /* Callback address */ 254191783Srmacklem union { 255191783Srmacklem struct in_addr sin_addr; 256191783Srmacklem struct in6_addr sin6_addr; 257191783Srmacklem } ndlck_cbaddr; 258191783Srmacklem struct nfsd_clid ndlck_clid; /* and client id */ 259191783Srmacklem}; 260191783Srmacklem 261191783Srmacklem/* 262191783Srmacklem * Structure for referral information. 263191783Srmacklem */ 264191783Srmacklemstruct nfsreferral { 265191783Srmacklem u_char *nfr_srvlist; /* List of servers */ 266191783Srmacklem int nfr_srvcnt; /* number of servers */ 267191783Srmacklem vnode_t nfr_vp; /* vnode for referral */ 268191783Srmacklem u_int32_t nfr_dfileno; /* assigned dir inode# */ 269191783Srmacklem}; 270191783Srmacklem 271191783Srmacklem/* 272191783Srmacklem * Flags for lc_flags and opsflags for nfsrv_getclient(). 273191783Srmacklem */ 274191783Srmacklem#define LCL_NEEDSCONFIRM 0x00000001 275191783Srmacklem#define LCL_DONTCLEAN 0x00000002 276191783Srmacklem#define LCL_WAKEUPWANTED 0x00000004 277191783Srmacklem#define LCL_TCPCALLBACK 0x00000008 278191783Srmacklem#define LCL_CALLBACKSON 0x00000010 279191783Srmacklem#define LCL_INDEXNOTOK 0x00000020 280191783Srmacklem#define LCL_STAMPEDSTABLE 0x00000040 281191783Srmacklem#define LCL_EXPIREIT 0x00000080 282191783Srmacklem#define LCL_CBDOWN 0x00000100 283191783Srmacklem#define LCL_KERBV 0x00000400 284191783Srmacklem#define LCL_NAME 0x00000800 285191783Srmacklem#define LCL_NEEDSCBNULL 0x00001000 286191783Srmacklem#define LCL_GSSINTEGRITY 0x00002000 287191783Srmacklem#define LCL_GSSPRIVACY 0x00004000 288191783Srmacklem#define LCL_ADMINREVOKED 0x00008000 289269398Srmacklem#define LCL_RECLAIMCOMPLETE 0x00010000 290269398Srmacklem#define LCL_NFSV41 0x00020000 291191783Srmacklem 292191783Srmacklem#define LCL_GSS LCL_KERBV /* Or of all mechs */ 293191783Srmacklem 294191783Srmacklem/* 295191783Srmacklem * Bits for flags in nfslock and nfsstate. 296191783Srmacklem * The access, deny, NFSLCK_READ and NFSLCK_WRITE bits must be defined as 297191783Srmacklem * below, in the correct order, so the shifts work for tests. 298191783Srmacklem */ 299191783Srmacklem#define NFSLCK_READACCESS 0x00000001 300191783Srmacklem#define NFSLCK_WRITEACCESS 0x00000002 301191783Srmacklem#define NFSLCK_ACCESSBITS (NFSLCK_READACCESS | NFSLCK_WRITEACCESS) 302191783Srmacklem#define NFSLCK_SHIFT 2 303191783Srmacklem#define NFSLCK_READDENY 0x00000004 304191783Srmacklem#define NFSLCK_WRITEDENY 0x00000008 305191783Srmacklem#define NFSLCK_DENYBITS (NFSLCK_READDENY | NFSLCK_WRITEDENY) 306191783Srmacklem#define NFSLCK_SHAREBITS \ 307191783Srmacklem (NFSLCK_READACCESS|NFSLCK_WRITEACCESS|NFSLCK_READDENY|NFSLCK_WRITEDENY) 308191783Srmacklem#define NFSLCK_LOCKSHIFT 4 309191783Srmacklem#define NFSLCK_READ 0x00000010 310191783Srmacklem#define NFSLCK_WRITE 0x00000020 311191783Srmacklem#define NFSLCK_BLOCKING 0x00000040 312191783Srmacklem#define NFSLCK_RECLAIM 0x00000080 313191783Srmacklem#define NFSLCK_OPENTOLOCK 0x00000100 314191783Srmacklem#define NFSLCK_TEST 0x00000200 315191783Srmacklem#define NFSLCK_LOCK 0x00000400 316191783Srmacklem#define NFSLCK_UNLOCK 0x00000800 317191783Srmacklem#define NFSLCK_OPEN 0x00001000 318191783Srmacklem#define NFSLCK_CLOSE 0x00002000 319191783Srmacklem#define NFSLCK_CHECK 0x00004000 320191783Srmacklem#define NFSLCK_RELEASE 0x00008000 321191783Srmacklem#define NFSLCK_NEEDSCONFIRM 0x00010000 322191783Srmacklem#define NFSLCK_CONFIRM 0x00020000 323191783Srmacklem#define NFSLCK_DOWNGRADE 0x00040000 324191783Srmacklem#define NFSLCK_DELEGREAD 0x00080000 325191783Srmacklem#define NFSLCK_DELEGWRITE 0x00100000 326191783Srmacklem#define NFSLCK_DELEGCUR 0x00200000 327191783Srmacklem#define NFSLCK_DELEGPREV 0x00400000 328191783Srmacklem#define NFSLCK_OLDDELEG 0x00800000 329191783Srmacklem#define NFSLCK_DELEGRECALL 0x01000000 330191783Srmacklem#define NFSLCK_SETATTR 0x02000000 331191783Srmacklem#define NFSLCK_DELEGPURGE 0x04000000 332191783Srmacklem#define NFSLCK_DELEGRETURN 0x08000000 333269398Srmacklem#define NFSLCK_WANTWDELEG 0x10000000 334269398Srmacklem#define NFSLCK_WANTRDELEG 0x20000000 335269398Srmacklem#define NFSLCK_WANTNODELEG 0x40000000 336269398Srmacklem#define NFSLCK_WANTBITS \ 337269398Srmacklem (NFSLCK_WANTWDELEG | NFSLCK_WANTRDELEG | NFSLCK_WANTNODELEG) 338191783Srmacklem 339191783Srmacklem/* And bits for nid_flag */ 340191783Srmacklem#define NFSID_INITIALIZE 0x0001 341191783Srmacklem#define NFSID_ADDUID 0x0002 342191783Srmacklem#define NFSID_DELUID 0x0004 343191783Srmacklem#define NFSID_ADDUSERNAME 0x0008 344191783Srmacklem#define NFSID_DELUSERNAME 0x0010 345191783Srmacklem#define NFSID_ADDGID 0x0020 346191783Srmacklem#define NFSID_DELGID 0x0040 347191783Srmacklem#define NFSID_ADDGROUPNAME 0x0080 348191783Srmacklem#define NFSID_DELGROUPNAME 0x0100 349191783Srmacklem 350191783Srmacklem/* 351191783Srmacklem * fs.nfs sysctl(3) identifiers 352191783Srmacklem */ 353191783Srmacklem#define NFS_NFSSTATS 1 /* struct: struct nfsstats */ 354191783Srmacklem 355191783Srmacklem/* 356191783Srmacklem * Here is the definition of the attribute bits array and macros that 357191783Srmacklem * manipulate it. 358191783Srmacklem * THE MACROS MUST BE MANUALLY MODIFIED IF NFSATTRBIT_MAXWORDS CHANGES!! 359191783Srmacklem * It is (NFSATTRBIT_MAX + 31) / 32. 360191783Srmacklem */ 361269398Srmacklem#define NFSATTRBIT_MAXWORDS 3 362191783Srmacklem 363191783Srmacklemtypedef struct { 364191783Srmacklem u_int32_t bits[NFSATTRBIT_MAXWORDS]; 365191783Srmacklem} nfsattrbit_t; 366191783Srmacklem 367269398Srmacklem#define NFSZERO_ATTRBIT(b) do { \ 368269398Srmacklem (b)->bits[0] = 0; \ 369269398Srmacklem (b)->bits[1] = 0; \ 370269398Srmacklem (b)->bits[2] = 0; \ 371269398Srmacklem} while (0) 372269398Srmacklem 373269398Srmacklem#define NFSSET_ATTRBIT(t, f) do { \ 374269398Srmacklem (t)->bits[0] = (f)->bits[0]; \ 375269398Srmacklem (t)->bits[1] = (f)->bits[1]; \ 376269398Srmacklem (t)->bits[2] = (f)->bits[2]; \ 377269398Srmacklem} while (0) 378269398Srmacklem 379191783Srmacklem#define NFSSETSUPP_ATTRBIT(b) do { \ 380191783Srmacklem (b)->bits[0] = NFSATTRBIT_SUPP0; \ 381269398Srmacklem (b)->bits[1] = (NFSATTRBIT_SUPP1 | NFSATTRBIT_SUPPSETONLY); \ 382269398Srmacklem (b)->bits[2] = NFSATTRBIT_SUPP2; \ 383269398Srmacklem} while (0) 384269398Srmacklem 385191783Srmacklem#define NFSISSET_ATTRBIT(b, p) ((b)->bits[(p) / 32] & (1 << ((p) % 32))) 386191783Srmacklem#define NFSSETBIT_ATTRBIT(b, p) ((b)->bits[(p) / 32] |= (1 << ((p) % 32))) 387191783Srmacklem#define NFSCLRBIT_ATTRBIT(b, p) ((b)->bits[(p) / 32] &= ~(1 << ((p) % 32))) 388269398Srmacklem 389191783Srmacklem#define NFSCLRALL_ATTRBIT(b, a) do { \ 390269398Srmacklem (b)->bits[0] &= ~((a)->bits[0]); \ 391269398Srmacklem (b)->bits[1] &= ~((a)->bits[1]); \ 392269398Srmacklem (b)->bits[2] &= ~((a)->bits[2]); \ 393269398Srmacklem} while (0) 394269398Srmacklem 395191783Srmacklem#define NFSCLRNOT_ATTRBIT(b, a) do { \ 396269398Srmacklem (b)->bits[0] &= ((a)->bits[0]); \ 397269398Srmacklem (b)->bits[1] &= ((a)->bits[1]); \ 398269398Srmacklem (b)->bits[2] &= ((a)->bits[2]); \ 399269398Srmacklem} while (0) 400269398Srmacklem 401191783Srmacklem#define NFSCLRNOTFILLABLE_ATTRBIT(b) do { \ 402269398Srmacklem (b)->bits[0] &= NFSATTRBIT_SUPP0; \ 403269398Srmacklem (b)->bits[1] &= NFSATTRBIT_SUPP1; \ 404269398Srmacklem (b)->bits[2] &= NFSATTRBIT_SUPP2; \ 405269398Srmacklem} while (0) 406269398Srmacklem 407191783Srmacklem#define NFSCLRNOTSETABLE_ATTRBIT(b) do { \ 408269398Srmacklem (b)->bits[0] &= NFSATTRBIT_SETABLE0; \ 409269398Srmacklem (b)->bits[1] &= NFSATTRBIT_SETABLE1; \ 410269398Srmacklem (b)->bits[2] &= NFSATTRBIT_SETABLE2; \ 411269398Srmacklem} while (0) 412269398Srmacklem 413269398Srmacklem#define NFSNONZERO_ATTRBIT(b) ((b)->bits[0] || (b)->bits[1] || (b)->bits[2]) 414269398Srmacklem#define NFSEQUAL_ATTRBIT(b, p) ((b)->bits[0] == (p)->bits[0] && \ 415269398Srmacklem (b)->bits[1] == (p)->bits[1] && (b)->bits[2] == (p)->bits[2]) 416269398Srmacklem 417191783Srmacklem#define NFSGETATTR_ATTRBIT(b) do { \ 418269398Srmacklem (b)->bits[0] = NFSATTRBIT_GETATTR0; \ 419269398Srmacklem (b)->bits[1] = NFSATTRBIT_GETATTR1; \ 420269398Srmacklem (b)->bits[2] = NFSATTRBIT_GETATTR2; \ 421269398Srmacklem} while (0) 422269398Srmacklem 423191783Srmacklem#define NFSWCCATTR_ATTRBIT(b) do { \ 424269398Srmacklem (b)->bits[0] = NFSATTRBIT_WCCATTR0; \ 425269398Srmacklem (b)->bits[1] = NFSATTRBIT_WCCATTR1; \ 426269398Srmacklem (b)->bits[2] = NFSATTRBIT_WCCATTR2; \ 427269398Srmacklem} while (0) 428269398Srmacklem 429191783Srmacklem#define NFSWRITEGETATTR_ATTRBIT(b) do { \ 430269398Srmacklem (b)->bits[0] = NFSATTRBIT_WRITEGETATTR0; \ 431269398Srmacklem (b)->bits[1] = NFSATTRBIT_WRITEGETATTR1; \ 432269398Srmacklem (b)->bits[2] = NFSATTRBIT_WRITEGETATTR2; \ 433269398Srmacklem} while (0) 434269398Srmacklem 435191783Srmacklem#define NFSCBGETATTR_ATTRBIT(b, c) do { \ 436269398Srmacklem (c)->bits[0] = ((b)->bits[0] & NFSATTRBIT_CBGETATTR0); \ 437269398Srmacklem (c)->bits[1] = ((b)->bits[1] & NFSATTRBIT_CBGETATTR1); \ 438269398Srmacklem (c)->bits[2] = ((b)->bits[2] & NFSATTRBIT_CBGETATTR2); \ 439269398Srmacklem} while (0) 440269398Srmacklem 441191783Srmacklem#define NFSPATHCONF_GETATTRBIT(b) do { \ 442269398Srmacklem (b)->bits[0] = NFSGETATTRBIT_PATHCONF0; \ 443269398Srmacklem (b)->bits[1] = NFSGETATTRBIT_PATHCONF1; \ 444269398Srmacklem (b)->bits[2] = NFSGETATTRBIT_PATHCONF2; \ 445269398Srmacklem} while (0) 446269398Srmacklem 447191783Srmacklem#define NFSSTATFS_GETATTRBIT(b) do { \ 448269398Srmacklem (b)->bits[0] = NFSGETATTRBIT_STATFS0; \ 449269398Srmacklem (b)->bits[1] = NFSGETATTRBIT_STATFS1; \ 450269398Srmacklem (b)->bits[2] = NFSGETATTRBIT_STATFS2; \ 451269398Srmacklem} while (0) 452269398Srmacklem 453191783Srmacklem#define NFSISSETSTATFS_ATTRBIT(b) \ 454191783Srmacklem (((b)->bits[0] & NFSATTRBIT_STATFS0) || \ 455269398Srmacklem ((b)->bits[1] & NFSATTRBIT_STATFS1) || \ 456269398Srmacklem ((b)->bits[2] & NFSATTRBIT_STATFS2)) 457269398Srmacklem 458191783Srmacklem#define NFSCLRSTATFS_ATTRBIT(b) do { \ 459269398Srmacklem (b)->bits[0] &= ~NFSATTRBIT_STATFS0; \ 460269398Srmacklem (b)->bits[1] &= ~NFSATTRBIT_STATFS1; \ 461269398Srmacklem (b)->bits[2] &= ~NFSATTRBIT_STATFS2; \ 462269398Srmacklem} while (0) 463269398Srmacklem 464191783Srmacklem#define NFSREADDIRPLUS_ATTRBIT(b) do { \ 465269398Srmacklem (b)->bits[0] = NFSATTRBIT_READDIRPLUS0; \ 466269398Srmacklem (b)->bits[1] = NFSATTRBIT_READDIRPLUS1; \ 467269398Srmacklem (b)->bits[2] = NFSATTRBIT_READDIRPLUS2; \ 468269398Srmacklem} while (0) 469269398Srmacklem 470191783Srmacklem#define NFSREFERRAL_ATTRBIT(b) do { \ 471269398Srmacklem (b)->bits[0] = NFSATTRBIT_REFERRAL0; \ 472269398Srmacklem (b)->bits[1] = NFSATTRBIT_REFERRAL1; \ 473269398Srmacklem (b)->bits[2] = NFSATTRBIT_REFERRAL2; \ 474269398Srmacklem} while (0) 475191783Srmacklem 476191783Srmacklem/* 477194523Srmacklem * Store uid, gid creds that were used when the stateid was acquired. 478194541Srmacklem * The RPC layer allows NFS_MAXGRPS + 1 groups to go out on the wire, 479194523Srmacklem * so that's how many gets stored here. 480191783Srmacklem */ 481191783Srmacklemstruct nfscred { 482191783Srmacklem uid_t nfsc_uid; 483194541Srmacklem gid_t nfsc_groups[NFS_MAXGRPS + 1]; 484191783Srmacklem int nfsc_ngroups; 485191783Srmacklem}; 486191783Srmacklem 487191783Srmacklem/* 488191783Srmacklem * Constants that define the file handle for the V4 root directory. 489191783Srmacklem * (The FSID must never be used by other file systems that are exported.) 490191783Srmacklem */ 491191783Srmacklem#define NFSV4ROOT_FSID0 ((int32_t) -1) 492191783Srmacklem#define NFSV4ROOT_FSID1 ((int32_t) -1) 493191783Srmacklem#define NFSV4ROOT_REFERRAL ((int32_t) -2) 494191783Srmacklem#define NFSV4ROOT_INO 2 /* It's traditional */ 495191783Srmacklem#define NFSV4ROOT_GEN 1 496191783Srmacklem 497191783Srmacklem/* 498191783Srmacklem * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts. 499191783Srmacklem * What should be in this set is open to debate, but I believe that since 500191783Srmacklem * I/O system calls on ufs are never interrupted by signals the set should 501191783Srmacklem * be minimal. My reasoning is that many current programs that use signals 502191783Srmacklem * such as SIGALRM will not expect file I/O system calls to be interrupted 503191783Srmacklem * by them and break. 504191783Srmacklem */ 505191783Srmacklem#if defined(_KERNEL) || defined(KERNEL) 506191783Srmacklem 507191783Srmacklemstruct uio; struct buf; struct vattr; struct nameidata; /* XXX */ 508191783Srmacklem 509191783Srmacklem/* 510191783Srmacklem * Socket errors ignored for connectionless sockets? 511191783Srmacklem * For now, ignore them all 512191783Srmacklem */ 513191783Srmacklem#define NFSIGNORE_SOERROR(s, e) \ 514191783Srmacklem ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \ 515191783Srmacklem ((s) & PR_CONNREQUIRED) == 0) 516191783Srmacklem 517191783Srmacklem 518191783Srmacklem/* 519191783Srmacklem * This structure holds socket information for a connection. Used by the 520191783Srmacklem * client and the server for callbacks. 521191783Srmacklem */ 522191783Srmacklemstruct nfssockreq { 523191783Srmacklem NFSSOCKADDR_T nr_nam; 524191783Srmacklem int nr_sotype; 525191783Srmacklem int nr_soproto; 526191783Srmacklem int nr_soflags; 527191783Srmacklem struct ucred *nr_cred; 528191783Srmacklem int nr_lock; 529191783Srmacklem NFSMUTEX_T nr_mtx; 530191783Srmacklem u_int32_t nr_prog; 531191783Srmacklem u_int32_t nr_vers; 532191783Srmacklem struct __rpc_client *nr_client; 533253049Srmacklem AUTH *nr_auth; 534191783Srmacklem}; 535191783Srmacklem 536191783Srmacklem/* 537191783Srmacklem * And associated nr_lock bits. 538191783Srmacklem */ 539191783Srmacklem#define NFSR_SNDLOCK 0x01 540191783Srmacklem#define NFSR_WANTSND 0x02 541191783Srmacklem#define NFSR_RCVLOCK 0x04 542191783Srmacklem#define NFSR_WANTRCV 0x08 543191783Srmacklem#define NFSR_RESERVEDPORT 0x10 544191783Srmacklem#define NFSR_LOCALHOST 0x20 545191783Srmacklem 546191783Srmacklem/* 547191783Srmacklem * Queue head for nfsreq's 548191783Srmacklem */ 549191783SrmacklemTAILQ_HEAD(nfsreqhead, nfsreq); 550191783Srmacklem 551192581Srmacklem/* This is the only nfsreq R_xxx flag still used. */ 552191783Srmacklem#define R_DONTRECOVER 0x00000100 /* don't initiate recovery when this 553191783Srmacklem rpc gets a stale state reply */ 554191783Srmacklem 555191783Srmacklem/* 556191783Srmacklem * Network address hash list element 557191783Srmacklem */ 558191783Srmacklemunion nethostaddr { 559191783Srmacklem struct in_addr had_inet; 560191783Srmacklem struct in6_addr had_inet6; 561191783Srmacklem}; 562191783Srmacklem 563191783Srmacklem/* 564191783Srmacklem * Structure of list of mechanisms. 565191783Srmacklem */ 566191783Srmacklemstruct nfsgss_mechlist { 567191783Srmacklem int len; 568191783Srmacklem const u_char *str; 569191783Srmacklem int totlen; 570191783Srmacklem}; 571191783Srmacklem#define KERBV_MECH 0 /* position in list */ 572191783Srmacklem 573191783Srmacklem/* 574191783Srmacklem * This structure is used by the server for describing each request. 575191783Srmacklem */ 576191783Srmacklemstruct nfsrv_descript { 577191783Srmacklem mbuf_t nd_mrep; /* Request mbuf list */ 578191783Srmacklem mbuf_t nd_md; /* Current dissect mbuf */ 579191783Srmacklem mbuf_t nd_mreq; /* Reply mbuf list */ 580191783Srmacklem mbuf_t nd_mb; /* Current build mbuf */ 581191783Srmacklem NFSSOCKADDR_T nd_nam; /* and socket addr */ 582191783Srmacklem NFSSOCKADDR_T nd_nam2; /* return socket addr */ 583191783Srmacklem caddr_t nd_dpos; /* Current dissect pos */ 584191783Srmacklem caddr_t nd_bpos; /* Current build pos */ 585191783Srmacklem u_int16_t nd_procnum; /* RPC # */ 586191783Srmacklem u_int32_t nd_flag; /* nd_flag */ 587191783Srmacklem u_int32_t nd_repstat; /* Reply status */ 588191783Srmacklem int *nd_errp; /* Pointer to ret status */ 589191783Srmacklem u_int32_t nd_retxid; /* Reply xid */ 590191783Srmacklem struct nfsrvcache *nd_rp; /* Assoc. cache entry */ 591191783Srmacklem fhandle_t nd_fh; /* File handle */ 592191783Srmacklem struct ucred *nd_cred; /* Credentials */ 593191783Srmacklem uid_t nd_saveduid; /* Saved uid */ 594191783Srmacklem u_int64_t nd_sockref; /* Rcv socket ref# */ 595191783Srmacklem u_int64_t nd_compref; /* Compound RPC ref# */ 596191783Srmacklem time_t nd_tcpconntime; /* Time TCP connection est. */ 597191783Srmacklem nfsquad_t nd_clientid; /* Implied clientid */ 598191783Srmacklem int nd_gssnamelen; /* principal name length */ 599191783Srmacklem char *nd_gssname; /* principal name */ 600244042Srmacklem uint32_t *nd_slotseq; /* ptr to slot seq# in req */ 601269398Srmacklem uint8_t nd_sessionid[NFSX_V4SESSIONID]; /* Session id */ 602269398Srmacklem uint32_t nd_slotid; /* Slotid for this RPC */ 603269398Srmacklem SVCXPRT *nd_xprt; /* Server RPC handle */ 604191783Srmacklem}; 605191783Srmacklem 606191783Srmacklem#define nd_princlen nd_gssnamelen 607191783Srmacklem#define nd_principal nd_gssname 608191783Srmacklem 609191783Srmacklem/* Bits for "nd_flag" */ 610191783Srmacklem#define ND_DONTSAVEREPLY 0x00000001 611191783Srmacklem#define ND_SAVEREPLY 0x00000002 612191783Srmacklem#define ND_NFSV2 0x00000004 613191783Srmacklem#define ND_NFSV3 0x00000008 614191783Srmacklem#define ND_NFSV4 0x00000010 615191783Srmacklem#define ND_KERBV 0x00000020 616191783Srmacklem#define ND_GSSINTEGRITY 0x00000040 617191783Srmacklem#define ND_GSSPRIVACY 0x00000080 618191783Srmacklem#define ND_WINDOWVERF 0x00000100 619191783Srmacklem#define ND_GSSINITREPLY 0x00000200 620191783Srmacklem#define ND_STREAMSOCK 0x00000400 621191783Srmacklem#define ND_PUBLOOKUP 0x00000800 622191783Srmacklem#define ND_USEGSSNAME 0x00001000 623191783Srmacklem#define ND_SAMETCPCONN 0x00002000 624191783Srmacklem#define ND_IMPLIEDCLID 0x00004000 625191783Srmacklem#define ND_NOMOREDATA 0x00008000 626191783Srmacklem#define ND_V4WCCATTR 0x00010000 627191783Srmacklem#define ND_NFSCB 0x00020000 628191783Srmacklem#define ND_AUTHNONE 0x00040000 629192121Srmacklem#define ND_EXAUTHSYS 0x00080000 630192121Srmacklem#define ND_EXGSS 0x00100000 631192121Srmacklem#define ND_EXGSSINTEGRITY 0x00200000 632192121Srmacklem#define ND_EXGSSPRIVACY 0x00400000 633192121Srmacklem#define ND_INCRSEQID 0x00800000 634240720Srmacklem#define ND_NFSCL 0x01000000 635244042Srmacklem#define ND_NFSV41 0x02000000 636244042Srmacklem#define ND_HASSEQUENCE 0x04000000 637269398Srmacklem#define ND_CACHETHIS 0x08000000 638269398Srmacklem#define ND_LASTOP 0x10000000 639191783Srmacklem 640191783Srmacklem/* 641191783Srmacklem * ND_GSS should be the "or" of all GSS type authentications. 642191783Srmacklem */ 643191783Srmacklem#define ND_GSS (ND_KERBV) 644191783Srmacklem 645191783Srmacklemstruct nfsv4_opflag { 646191783Srmacklem int retfh; 647191783Srmacklem int needscfh; 648191783Srmacklem int savereply; 649191783Srmacklem int modifyfs; 650216700Srmacklem int lktype; 651244042Srmacklem int needsseq; 652191783Srmacklem}; 653191783Srmacklem 654191783Srmacklem/* 655191783Srmacklem * Flags used to indicate what to do w.r.t. seqid checking. 656191783Srmacklem */ 657191783Srmacklem#define NFSRVSEQID_FIRST 0x01 658191783Srmacklem#define NFSRVSEQID_LAST 0x02 659191783Srmacklem#define NFSRVSEQID_OPEN 0x04 660191783Srmacklem 661191783Srmacklem/* 662191783Srmacklem * assign a doubly linked list to a new head 663191783Srmacklem * and prepend one list into another. 664191783Srmacklem */ 665191783Srmacklem#define LIST_NEWHEAD(nhead, ohead, field) do { \ 666191783Srmacklem if (((nhead)->lh_first = (ohead)->lh_first) != NULL) \ 667191783Srmacklem (ohead)->lh_first->field.le_prev = &(nhead)->lh_first; \ 668191783Srmacklem (ohead)->lh_first = NULL; \ 669191783Srmacklem } while (0) 670191783Srmacklem 671191783Srmacklem#define LIST_PREPEND(head, phead, lelm, field) do { \ 672191783Srmacklem if ((head)->lh_first != NULL) { \ 673191783Srmacklem (lelm)->field.le_next = (head)->lh_first; \ 674191783Srmacklem (lelm)->field.le_next->field.le_prev = \ 675191783Srmacklem &(lelm)->field.le_next; \ 676191783Srmacklem } \ 677191783Srmacklem (head)->lh_first = (phead)->lh_first; \ 678191783Srmacklem (head)->lh_first->field.le_prev = &(head)->lh_first; \ 679191783Srmacklem } while (0) 680191783Srmacklem 681191783Srmacklem/* 682191783Srmacklem * File handle structure for client. Malloc'd to the correct length with 683191783Srmacklem * malloc type M_NFSFH. 684191783Srmacklem */ 685191783Srmacklemstruct nfsfh { 686191783Srmacklem u_int16_t nfh_len; /* Length of file handle */ 687191783Srmacklem u_int8_t nfh_fh[1]; /* and the file handle */ 688191783Srmacklem}; 689191783Srmacklem 690191783Srmacklem/* 691191783Srmacklem * File handle structure for server. The NFSRV_MAXFH constant is 692191783Srmacklem * set in nfsdport.h. I use a 32bit length, so that alignment is 693191783Srmacklem * preserved. 694191783Srmacklem */ 695191783Srmacklemstruct nfsrvfh { 696191783Srmacklem u_int32_t nfsrvfh_len; 697191783Srmacklem u_int8_t nfsrvfh_data[NFSRV_MAXFH]; 698191783Srmacklem}; 699191783Srmacklem 700191783Srmacklem/* 701191783Srmacklem * This structure is used for sleep locks on the NFSv4 nfsd threads and 702191783Srmacklem * NFSv4 client data structures. 703191783Srmacklem */ 704191783Srmacklemstruct nfsv4lock { 705191783Srmacklem u_int32_t nfslock_usecnt; 706191783Srmacklem u_int8_t nfslock_lock; 707191783Srmacklem}; 708191783Srmacklem#define NFSV4LOCK_LOCK 0x01 709191783Srmacklem#define NFSV4LOCK_LOCKWANTED 0x02 710191783Srmacklem#define NFSV4LOCK_WANTED 0x04 711191783Srmacklem 712191783Srmacklem/* 713191783Srmacklem * Values for the override argument for nfsvno_accchk(). 714191783Srmacklem */ 715191783Srmacklem#define NFSACCCHK_NOOVERRIDE 0 716191783Srmacklem#define NFSACCCHK_ALLOWROOT 1 717191783Srmacklem#define NFSACCCHK_ALLOWOWNER 2 718191783Srmacklem 719191783Srmacklem/* 720191783Srmacklem * and values for the vpislocked argument for nfsvno_accchk(). 721191783Srmacklem */ 722191783Srmacklem#define NFSACCCHK_VPNOTLOCKED 0 723191783Srmacklem#define NFSACCCHK_VPISLOCKED 1 724191783Srmacklem 725244042Srmacklem/* 726244042Srmacklem * Slot for the NFSv4.1 Sequence Op. 727244042Srmacklem */ 728244042Srmacklemstruct nfsslot { 729244042Srmacklem int nfssl_inprog; 730244042Srmacklem uint32_t nfssl_seq; 731244042Srmacklem struct mbuf *nfssl_reply; 732244042Srmacklem}; 733244042Srmacklem 734191783Srmacklem#endif /* _KERNEL */ 735191783Srmacklem 736191783Srmacklem#endif /* _NFS_NFS_H */ 737