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$ 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 NFSUSERHASHSIZE 100191783Srmacklem#define NFSUSERHASHSIZE 30 /* Size of user id hash table */ 101191783Srmacklem#endif 102191783Srmacklem#ifndef NFSGROUPHASHSIZE 103191783Srmacklem#define NFSGROUPHASHSIZE 5 /* Size of group id hash table */ 104191783Srmacklem#endif 105191783Srmacklem#ifndef NFSCLDELEGHIGHWATER 106191783Srmacklem#define NFSCLDELEGHIGHWATER 10000 /* limit for client delegations */ 107191783Srmacklem#endif 108244042Srmacklem#ifndef NFSCLLAYOUTHIGHWATER 109244042Srmacklem#define NFSCLLAYOUTHIGHWATER 10000 /* limit for client pNFS layouts */ 110244042Srmacklem#endif 111191783Srmacklem#ifndef NFSNOOPEN /* Inactive open owner (sec) */ 112191783Srmacklem#define NFSNOOPEN 120 113191783Srmacklem#endif 114191783Srmacklem#define NFSRV_LEASEDELTA 15 /* # of seconds to delay beyond lease */ 115191783Srmacklem#define NFS_IDMAXSIZE 4 /* max sizeof (in_addr_t) */ 116191783Srmacklem#ifndef NFSRVCACHE_UDPTIMEOUT 117191783Srmacklem#define NFSRVCACHE_UDPTIMEOUT 30 /* # of sec to hold cached rpcs(udp) */ 118191783Srmacklem#endif 119191783Srmacklem#ifndef NFSRVCACHE_UDPHIGHWATER 120191783Srmacklem#define NFSRVCACHE_UDPHIGHWATER 500 /* Max # of udp cache entries */ 121191783Srmacklem#endif 122191783Srmacklem#ifndef NFSRVCACHE_TCPTIMEOUT 123191783Srmacklem#define NFSRVCACHE_TCPTIMEOUT (3600*12) /*#of sec to hold cached rpcs(tcp) */ 124191783Srmacklem#endif 125191783Srmacklem#ifndef NFSRVCACHE_FLOODLEVEL 126191783Srmacklem#define NFSRVCACHE_FLOODLEVEL 16384 /* Very high water mark for cache */ 127191783Srmacklem#endif 128191783Srmacklem#ifndef NFSRV_CLIENTHIGHWATER 129191783Srmacklem#define NFSRV_CLIENTHIGHWATER 1000 130191783Srmacklem#endif 131191783Srmacklem#ifndef NFSRV_MAXDUMPLIST 132191783Srmacklem#define NFSRV_MAXDUMPLIST 10000 133191783Srmacklem#endif 134191783Srmacklem#ifndef NFS_ACCESSCACHESIZE 135191783Srmacklem#define NFS_ACCESSCACHESIZE 8 136191783Srmacklem#endif 137191783Srmacklem#define NFSV4_CBPORT 7745 /* Callback port for testing */ 138191783Srmacklem 139191783Srmacklem/* 140191783Srmacklem * This macro defines the high water mark for issuing V4 delegations. 141191783Srmacklem * (It is currently set at a conservative 20% of NFSRV_V4STATELIMIT. This 142191783Srmacklem * may want to increase when clients can make more effective use of 143191783Srmacklem * delegations.) 144191783Srmacklem */ 145191783Srmacklem#define NFSRV_V4DELEGLIMIT(c) (((c) * 5) > NFSRV_V4STATELIMIT) 146191783Srmacklem 147191783Srmacklem#define NFS_READDIRBLKSIZ DIRBLKSIZ /* Minimal nm_readdirsize */ 148191783Srmacklem 149191783Srmacklem/* 150191783Srmacklem * Oddballs 151191783Srmacklem */ 152191783Srmacklem#define NFS_CMPFH(n, f, s) \ 153191783Srmacklem ((n)->n_fhp->nfh_len == (s) && !NFSBCMP((n)->n_fhp->nfh_fh, (caddr_t)(f), (s))) 154191783Srmacklem#define NFSRV_CMPFH(nf, ns, f, s) \ 155191783Srmacklem ((ns) == (s) && !NFSBCMP((caddr_t)(nf), (caddr_t)(f), (s))) 156191783Srmacklem#define NFS_CMPTIME(t1, t2) \ 157191783Srmacklem ((t1).tv_sec == (t2).tv_sec && (t1).tv_nsec == (t2).tv_nsec) 158191783Srmacklem#define NFS_SETTIME(t) do { \ 159191783Srmacklem (t).tv_sec = time.tv_sec; (t).tv_nsec = 1000 * time.tv_usec; } while (0) 160191783Srmacklem#define NFS_SRVMAXDATA(n) \ 161191783Srmacklem (((n)->nd_flag & (ND_NFSV3 | ND_NFSV4)) ? \ 162191783Srmacklem NFS_MAXDATA : NFS_V2MAXDATA) 163191783Srmacklem#define NFS64BITSSET 0xffffffffffffffffull 164191783Srmacklem#define NFS64BITSMINUS1 0xfffffffffffffffeull 165191783Srmacklem 166191783Srmacklem/* 167191783Srmacklem * Structures for the nfssvc(2) syscall. Not that anyone but nfsd, mount_nfs 168191783Srmacklem * and nfsloaduser should ever try and use it. 169191783Srmacklem */ 170192000Srmacklemstruct nfsd_addsock_args { 171191783Srmacklem int sock; /* Socket to serve */ 172191783Srmacklem caddr_t name; /* Client addr for connection based sockets */ 173191783Srmacklem int namelen; /* Length of name */ 174191783Srmacklem}; 175191783Srmacklem 176191783Srmacklem/* 177191783Srmacklem * nfsd argument for new krpc. 178191783Srmacklem */ 179191783Srmacklemstruct nfsd_nfsd_args { 180191783Srmacklem const char *principal; /* GSS-API service principal name */ 181191783Srmacklem int minthreads; /* minimum service thread count */ 182191783Srmacklem int maxthreads; /* maximum service thread count */ 183191783Srmacklem}; 184191783Srmacklem 185191783Srmacklem/* 186191783Srmacklem * Arguments for use by the callback daemon. 187191783Srmacklem */ 188191783Srmacklemstruct nfsd_nfscbd_args { 189191783Srmacklem const char *principal; /* GSS-API service principal name */ 190191783Srmacklem}; 191191783Srmacklem 192191783Srmacklemstruct nfscbd_args { 193191783Srmacklem int sock; /* Socket to serve */ 194191783Srmacklem caddr_t name; /* Client addr for connection based sockets */ 195191783Srmacklem int namelen; /* Length of name */ 196191783Srmacklem u_short port; /* Port# for callbacks */ 197191783Srmacklem}; 198191783Srmacklem 199191783Srmacklemstruct nfsd_idargs { 200191783Srmacklem int nid_flag; /* Flags (see below) */ 201191783Srmacklem uid_t nid_uid; /* user/group id */ 202191783Srmacklem gid_t nid_gid; 203191783Srmacklem int nid_usermax; /* Upper bound on user name cache */ 204191783Srmacklem int nid_usertimeout;/* User name timeout (minutes) */ 205191783Srmacklem u_char *nid_name; /* Name */ 206191783Srmacklem int nid_namelen; /* and its length */ 207191783Srmacklem}; 208191783Srmacklem 209191783Srmacklemstruct nfsd_clid { 210191783Srmacklem int nclid_idlen; /* Length of client id */ 211191783Srmacklem u_char nclid_id[NFSV4_OPAQUELIMIT]; /* and name */ 212191783Srmacklem}; 213191783Srmacklem 214191783Srmacklemstruct nfsd_dumplist { 215191783Srmacklem int ndl_size; /* Number of elements */ 216191783Srmacklem void *ndl_list; /* and the list of elements */ 217191783Srmacklem}; 218191783Srmacklem 219191783Srmacklemstruct nfsd_dumpclients { 220191783Srmacklem u_int32_t ndcl_flags; /* LCL_xxx flags */ 221191783Srmacklem u_int32_t ndcl_nopenowners; /* Number of openowners */ 222191783Srmacklem u_int32_t ndcl_nopens; /* and opens */ 223191783Srmacklem u_int32_t ndcl_nlockowners; /* and of lockowners */ 224191783Srmacklem u_int32_t ndcl_nlocks; /* and of locks */ 225191783Srmacklem u_int32_t ndcl_ndelegs; /* and of delegations */ 226191783Srmacklem u_int32_t ndcl_nolddelegs; /* and old delegations */ 227191783Srmacklem sa_family_t ndcl_addrfam; /* Callback address */ 228191783Srmacklem union { 229191783Srmacklem struct in_addr sin_addr; 230191783Srmacklem struct in6_addr sin6_addr; 231191783Srmacklem } ndcl_cbaddr; 232191783Srmacklem struct nfsd_clid ndcl_clid; /* and client id */ 233191783Srmacklem}; 234191783Srmacklem 235191783Srmacklemstruct nfsd_dumplocklist { 236191783Srmacklem char *ndllck_fname; /* File Name */ 237191783Srmacklem int ndllck_size; /* Number of elements */ 238191783Srmacklem void *ndllck_list; /* and the list of elements */ 239191783Srmacklem}; 240191783Srmacklem 241191783Srmacklemstruct nfsd_dumplocks { 242191783Srmacklem u_int32_t ndlck_flags; /* state flags NFSLCK_xxx */ 243191783Srmacklem nfsv4stateid_t ndlck_stateid; /* stateid */ 244191783Srmacklem u_int64_t ndlck_first; /* lock byte range */ 245191783Srmacklem u_int64_t ndlck_end; 246191783Srmacklem struct nfsd_clid ndlck_owner; /* Owner of open/lock */ 247191783Srmacklem sa_family_t ndlck_addrfam; /* Callback address */ 248191783Srmacklem union { 249191783Srmacklem struct in_addr sin_addr; 250191783Srmacklem struct in6_addr sin6_addr; 251191783Srmacklem } ndlck_cbaddr; 252191783Srmacklem struct nfsd_clid ndlck_clid; /* and client id */ 253191783Srmacklem}; 254191783Srmacklem 255191783Srmacklem/* 256191783Srmacklem * Structure for referral information. 257191783Srmacklem */ 258191783Srmacklemstruct nfsreferral { 259191783Srmacklem u_char *nfr_srvlist; /* List of servers */ 260191783Srmacklem int nfr_srvcnt; /* number of servers */ 261191783Srmacklem vnode_t nfr_vp; /* vnode for referral */ 262191783Srmacklem u_int32_t nfr_dfileno; /* assigned dir inode# */ 263191783Srmacklem}; 264191783Srmacklem 265191783Srmacklem/* 266191783Srmacklem * Flags for lc_flags and opsflags for nfsrv_getclient(). 267191783Srmacklem */ 268191783Srmacklem#define LCL_NEEDSCONFIRM 0x00000001 269191783Srmacklem#define LCL_DONTCLEAN 0x00000002 270191783Srmacklem#define LCL_WAKEUPWANTED 0x00000004 271191783Srmacklem#define LCL_TCPCALLBACK 0x00000008 272191783Srmacklem#define LCL_CALLBACKSON 0x00000010 273191783Srmacklem#define LCL_INDEXNOTOK 0x00000020 274191783Srmacklem#define LCL_STAMPEDSTABLE 0x00000040 275191783Srmacklem#define LCL_EXPIREIT 0x00000080 276191783Srmacklem#define LCL_CBDOWN 0x00000100 277191783Srmacklem#define LCL_KERBV 0x00000400 278191783Srmacklem#define LCL_NAME 0x00000800 279191783Srmacklem#define LCL_NEEDSCBNULL 0x00001000 280191783Srmacklem#define LCL_GSSINTEGRITY 0x00002000 281191783Srmacklem#define LCL_GSSPRIVACY 0x00004000 282191783Srmacklem#define LCL_ADMINREVOKED 0x00008000 283269398Srmacklem#define LCL_RECLAIMCOMPLETE 0x00010000 284269398Srmacklem#define LCL_NFSV41 0x00020000 285191783Srmacklem 286191783Srmacklem#define LCL_GSS LCL_KERBV /* Or of all mechs */ 287191783Srmacklem 288191783Srmacklem/* 289191783Srmacklem * Bits for flags in nfslock and nfsstate. 290191783Srmacklem * The access, deny, NFSLCK_READ and NFSLCK_WRITE bits must be defined as 291191783Srmacklem * below, in the correct order, so the shifts work for tests. 292191783Srmacklem */ 293191783Srmacklem#define NFSLCK_READACCESS 0x00000001 294191783Srmacklem#define NFSLCK_WRITEACCESS 0x00000002 295191783Srmacklem#define NFSLCK_ACCESSBITS (NFSLCK_READACCESS | NFSLCK_WRITEACCESS) 296191783Srmacklem#define NFSLCK_SHIFT 2 297191783Srmacklem#define NFSLCK_READDENY 0x00000004 298191783Srmacklem#define NFSLCK_WRITEDENY 0x00000008 299191783Srmacklem#define NFSLCK_DENYBITS (NFSLCK_READDENY | NFSLCK_WRITEDENY) 300191783Srmacklem#define NFSLCK_SHAREBITS \ 301191783Srmacklem (NFSLCK_READACCESS|NFSLCK_WRITEACCESS|NFSLCK_READDENY|NFSLCK_WRITEDENY) 302191783Srmacklem#define NFSLCK_LOCKSHIFT 4 303191783Srmacklem#define NFSLCK_READ 0x00000010 304191783Srmacklem#define NFSLCK_WRITE 0x00000020 305191783Srmacklem#define NFSLCK_BLOCKING 0x00000040 306191783Srmacklem#define NFSLCK_RECLAIM 0x00000080 307191783Srmacklem#define NFSLCK_OPENTOLOCK 0x00000100 308191783Srmacklem#define NFSLCK_TEST 0x00000200 309191783Srmacklem#define NFSLCK_LOCK 0x00000400 310191783Srmacklem#define NFSLCK_UNLOCK 0x00000800 311191783Srmacklem#define NFSLCK_OPEN 0x00001000 312191783Srmacklem#define NFSLCK_CLOSE 0x00002000 313191783Srmacklem#define NFSLCK_CHECK 0x00004000 314191783Srmacklem#define NFSLCK_RELEASE 0x00008000 315191783Srmacklem#define NFSLCK_NEEDSCONFIRM 0x00010000 316191783Srmacklem#define NFSLCK_CONFIRM 0x00020000 317191783Srmacklem#define NFSLCK_DOWNGRADE 0x00040000 318191783Srmacklem#define NFSLCK_DELEGREAD 0x00080000 319191783Srmacklem#define NFSLCK_DELEGWRITE 0x00100000 320191783Srmacklem#define NFSLCK_DELEGCUR 0x00200000 321191783Srmacklem#define NFSLCK_DELEGPREV 0x00400000 322191783Srmacklem#define NFSLCK_OLDDELEG 0x00800000 323191783Srmacklem#define NFSLCK_DELEGRECALL 0x01000000 324191783Srmacklem#define NFSLCK_SETATTR 0x02000000 325191783Srmacklem#define NFSLCK_DELEGPURGE 0x04000000 326191783Srmacklem#define NFSLCK_DELEGRETURN 0x08000000 327269398Srmacklem#define NFSLCK_WANTWDELEG 0x10000000 328269398Srmacklem#define NFSLCK_WANTRDELEG 0x20000000 329269398Srmacklem#define NFSLCK_WANTNODELEG 0x40000000 330269398Srmacklem#define NFSLCK_WANTBITS \ 331269398Srmacklem (NFSLCK_WANTWDELEG | NFSLCK_WANTRDELEG | NFSLCK_WANTNODELEG) 332191783Srmacklem 333191783Srmacklem/* And bits for nid_flag */ 334191783Srmacklem#define NFSID_INITIALIZE 0x0001 335191783Srmacklem#define NFSID_ADDUID 0x0002 336191783Srmacklem#define NFSID_DELUID 0x0004 337191783Srmacklem#define NFSID_ADDUSERNAME 0x0008 338191783Srmacklem#define NFSID_DELUSERNAME 0x0010 339191783Srmacklem#define NFSID_ADDGID 0x0020 340191783Srmacklem#define NFSID_DELGID 0x0040 341191783Srmacklem#define NFSID_ADDGROUPNAME 0x0080 342191783Srmacklem#define NFSID_DELGROUPNAME 0x0100 343191783Srmacklem 344191783Srmacklem/* 345191783Srmacklem * fs.nfs sysctl(3) identifiers 346191783Srmacklem */ 347191783Srmacklem#define NFS_NFSSTATS 1 /* struct: struct nfsstats */ 348191783Srmacklem 349191783Srmacklem/* 350191783Srmacklem * Here is the definition of the attribute bits array and macros that 351191783Srmacklem * manipulate it. 352191783Srmacklem * THE MACROS MUST BE MANUALLY MODIFIED IF NFSATTRBIT_MAXWORDS CHANGES!! 353191783Srmacklem * It is (NFSATTRBIT_MAX + 31) / 32. 354191783Srmacklem */ 355269398Srmacklem#define NFSATTRBIT_MAXWORDS 3 356191783Srmacklem 357191783Srmacklemtypedef struct { 358191783Srmacklem u_int32_t bits[NFSATTRBIT_MAXWORDS]; 359191783Srmacklem} nfsattrbit_t; 360191783Srmacklem 361269398Srmacklem#define NFSZERO_ATTRBIT(b) do { \ 362269398Srmacklem (b)->bits[0] = 0; \ 363269398Srmacklem (b)->bits[1] = 0; \ 364269398Srmacklem (b)->bits[2] = 0; \ 365269398Srmacklem} while (0) 366269398Srmacklem 367269398Srmacklem#define NFSSET_ATTRBIT(t, f) do { \ 368269398Srmacklem (t)->bits[0] = (f)->bits[0]; \ 369269398Srmacklem (t)->bits[1] = (f)->bits[1]; \ 370269398Srmacklem (t)->bits[2] = (f)->bits[2]; \ 371269398Srmacklem} while (0) 372269398Srmacklem 373191783Srmacklem#define NFSSETSUPP_ATTRBIT(b) do { \ 374191783Srmacklem (b)->bits[0] = NFSATTRBIT_SUPP0; \ 375269398Srmacklem (b)->bits[1] = (NFSATTRBIT_SUPP1 | NFSATTRBIT_SUPPSETONLY); \ 376269398Srmacklem (b)->bits[2] = NFSATTRBIT_SUPP2; \ 377269398Srmacklem} while (0) 378269398Srmacklem 379191783Srmacklem#define NFSISSET_ATTRBIT(b, p) ((b)->bits[(p) / 32] & (1 << ((p) % 32))) 380191783Srmacklem#define NFSSETBIT_ATTRBIT(b, p) ((b)->bits[(p) / 32] |= (1 << ((p) % 32))) 381191783Srmacklem#define NFSCLRBIT_ATTRBIT(b, p) ((b)->bits[(p) / 32] &= ~(1 << ((p) % 32))) 382269398Srmacklem 383191783Srmacklem#define NFSCLRALL_ATTRBIT(b, a) do { \ 384269398Srmacklem (b)->bits[0] &= ~((a)->bits[0]); \ 385269398Srmacklem (b)->bits[1] &= ~((a)->bits[1]); \ 386269398Srmacklem (b)->bits[2] &= ~((a)->bits[2]); \ 387269398Srmacklem} while (0) 388269398Srmacklem 389191783Srmacklem#define NFSCLRNOT_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 NFSCLRNOTFILLABLE_ATTRBIT(b) do { \ 396269398Srmacklem (b)->bits[0] &= NFSATTRBIT_SUPP0; \ 397269398Srmacklem (b)->bits[1] &= NFSATTRBIT_SUPP1; \ 398269398Srmacklem (b)->bits[2] &= NFSATTRBIT_SUPP2; \ 399269398Srmacklem} while (0) 400269398Srmacklem 401191783Srmacklem#define NFSCLRNOTSETABLE_ATTRBIT(b) do { \ 402269398Srmacklem (b)->bits[0] &= NFSATTRBIT_SETABLE0; \ 403269398Srmacklem (b)->bits[1] &= NFSATTRBIT_SETABLE1; \ 404269398Srmacklem (b)->bits[2] &= NFSATTRBIT_SETABLE2; \ 405269398Srmacklem} while (0) 406269398Srmacklem 407269398Srmacklem#define NFSNONZERO_ATTRBIT(b) ((b)->bits[0] || (b)->bits[1] || (b)->bits[2]) 408269398Srmacklem#define NFSEQUAL_ATTRBIT(b, p) ((b)->bits[0] == (p)->bits[0] && \ 409269398Srmacklem (b)->bits[1] == (p)->bits[1] && (b)->bits[2] == (p)->bits[2]) 410269398Srmacklem 411191783Srmacklem#define NFSGETATTR_ATTRBIT(b) do { \ 412269398Srmacklem (b)->bits[0] = NFSATTRBIT_GETATTR0; \ 413269398Srmacklem (b)->bits[1] = NFSATTRBIT_GETATTR1; \ 414269398Srmacklem (b)->bits[2] = NFSATTRBIT_GETATTR2; \ 415269398Srmacklem} while (0) 416269398Srmacklem 417191783Srmacklem#define NFSWCCATTR_ATTRBIT(b) do { \ 418269398Srmacklem (b)->bits[0] = NFSATTRBIT_WCCATTR0; \ 419269398Srmacklem (b)->bits[1] = NFSATTRBIT_WCCATTR1; \ 420269398Srmacklem (b)->bits[2] = NFSATTRBIT_WCCATTR2; \ 421269398Srmacklem} while (0) 422269398Srmacklem 423191783Srmacklem#define NFSWRITEGETATTR_ATTRBIT(b) do { \ 424269398Srmacklem (b)->bits[0] = NFSATTRBIT_WRITEGETATTR0; \ 425269398Srmacklem (b)->bits[1] = NFSATTRBIT_WRITEGETATTR1; \ 426269398Srmacklem (b)->bits[2] = NFSATTRBIT_WRITEGETATTR2; \ 427269398Srmacklem} while (0) 428269398Srmacklem 429191783Srmacklem#define NFSCBGETATTR_ATTRBIT(b, c) do { \ 430269398Srmacklem (c)->bits[0] = ((b)->bits[0] & NFSATTRBIT_CBGETATTR0); \ 431269398Srmacklem (c)->bits[1] = ((b)->bits[1] & NFSATTRBIT_CBGETATTR1); \ 432269398Srmacklem (c)->bits[2] = ((b)->bits[2] & NFSATTRBIT_CBGETATTR2); \ 433269398Srmacklem} while (0) 434269398Srmacklem 435191783Srmacklem#define NFSPATHCONF_GETATTRBIT(b) do { \ 436269398Srmacklem (b)->bits[0] = NFSGETATTRBIT_PATHCONF0; \ 437269398Srmacklem (b)->bits[1] = NFSGETATTRBIT_PATHCONF1; \ 438269398Srmacklem (b)->bits[2] = NFSGETATTRBIT_PATHCONF2; \ 439269398Srmacklem} while (0) 440269398Srmacklem 441191783Srmacklem#define NFSSTATFS_GETATTRBIT(b) do { \ 442269398Srmacklem (b)->bits[0] = NFSGETATTRBIT_STATFS0; \ 443269398Srmacklem (b)->bits[1] = NFSGETATTRBIT_STATFS1; \ 444269398Srmacklem (b)->bits[2] = NFSGETATTRBIT_STATFS2; \ 445269398Srmacklem} while (0) 446269398Srmacklem 447191783Srmacklem#define NFSISSETSTATFS_ATTRBIT(b) \ 448191783Srmacklem (((b)->bits[0] & NFSATTRBIT_STATFS0) || \ 449269398Srmacklem ((b)->bits[1] & NFSATTRBIT_STATFS1) || \ 450269398Srmacklem ((b)->bits[2] & NFSATTRBIT_STATFS2)) 451269398Srmacklem 452191783Srmacklem#define NFSCLRSTATFS_ATTRBIT(b) do { \ 453269398Srmacklem (b)->bits[0] &= ~NFSATTRBIT_STATFS0; \ 454269398Srmacklem (b)->bits[1] &= ~NFSATTRBIT_STATFS1; \ 455269398Srmacklem (b)->bits[2] &= ~NFSATTRBIT_STATFS2; \ 456269398Srmacklem} while (0) 457269398Srmacklem 458191783Srmacklem#define NFSREADDIRPLUS_ATTRBIT(b) do { \ 459269398Srmacklem (b)->bits[0] = NFSATTRBIT_READDIRPLUS0; \ 460269398Srmacklem (b)->bits[1] = NFSATTRBIT_READDIRPLUS1; \ 461269398Srmacklem (b)->bits[2] = NFSATTRBIT_READDIRPLUS2; \ 462269398Srmacklem} while (0) 463269398Srmacklem 464191783Srmacklem#define NFSREFERRAL_ATTRBIT(b) do { \ 465269398Srmacklem (b)->bits[0] = NFSATTRBIT_REFERRAL0; \ 466269398Srmacklem (b)->bits[1] = NFSATTRBIT_REFERRAL1; \ 467269398Srmacklem (b)->bits[2] = NFSATTRBIT_REFERRAL2; \ 468269398Srmacklem} while (0) 469191783Srmacklem 470191783Srmacklem/* 471194523Srmacklem * Store uid, gid creds that were used when the stateid was acquired. 472194541Srmacklem * The RPC layer allows NFS_MAXGRPS + 1 groups to go out on the wire, 473194523Srmacklem * so that's how many gets stored here. 474191783Srmacklem */ 475191783Srmacklemstruct nfscred { 476191783Srmacklem uid_t nfsc_uid; 477194541Srmacklem gid_t nfsc_groups[NFS_MAXGRPS + 1]; 478191783Srmacklem int nfsc_ngroups; 479191783Srmacklem}; 480191783Srmacklem 481191783Srmacklem/* 482191783Srmacklem * Constants that define the file handle for the V4 root directory. 483191783Srmacklem * (The FSID must never be used by other file systems that are exported.) 484191783Srmacklem */ 485191783Srmacklem#define NFSV4ROOT_FSID0 ((int32_t) -1) 486191783Srmacklem#define NFSV4ROOT_FSID1 ((int32_t) -1) 487191783Srmacklem#define NFSV4ROOT_REFERRAL ((int32_t) -2) 488191783Srmacklem#define NFSV4ROOT_INO 2 /* It's traditional */ 489191783Srmacklem#define NFSV4ROOT_GEN 1 490191783Srmacklem 491191783Srmacklem/* 492191783Srmacklem * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts. 493191783Srmacklem * What should be in this set is open to debate, but I believe that since 494191783Srmacklem * I/O system calls on ufs are never interrupted by signals the set should 495191783Srmacklem * be minimal. My reasoning is that many current programs that use signals 496191783Srmacklem * such as SIGALRM will not expect file I/O system calls to be interrupted 497191783Srmacklem * by them and break. 498191783Srmacklem */ 499191783Srmacklem#if defined(_KERNEL) || defined(KERNEL) 500191783Srmacklem 501191783Srmacklemstruct uio; struct buf; struct vattr; struct nameidata; /* XXX */ 502191783Srmacklem 503191783Srmacklem/* 504191783Srmacklem * Socket errors ignored for connectionless sockets? 505191783Srmacklem * For now, ignore them all 506191783Srmacklem */ 507191783Srmacklem#define NFSIGNORE_SOERROR(s, e) \ 508191783Srmacklem ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \ 509191783Srmacklem ((s) & PR_CONNREQUIRED) == 0) 510191783Srmacklem 511191783Srmacklem 512191783Srmacklem/* 513191783Srmacklem * This structure holds socket information for a connection. Used by the 514191783Srmacklem * client and the server for callbacks. 515191783Srmacklem */ 516191783Srmacklemstruct nfssockreq { 517191783Srmacklem NFSSOCKADDR_T nr_nam; 518191783Srmacklem int nr_sotype; 519191783Srmacklem int nr_soproto; 520191783Srmacklem int nr_soflags; 521191783Srmacklem struct ucred *nr_cred; 522191783Srmacklem int nr_lock; 523191783Srmacklem NFSMUTEX_T nr_mtx; 524191783Srmacklem u_int32_t nr_prog; 525191783Srmacklem u_int32_t nr_vers; 526191783Srmacklem struct __rpc_client *nr_client; 527253049Srmacklem AUTH *nr_auth; 528191783Srmacklem}; 529191783Srmacklem 530191783Srmacklem/* 531191783Srmacklem * And associated nr_lock bits. 532191783Srmacklem */ 533191783Srmacklem#define NFSR_SNDLOCK 0x01 534191783Srmacklem#define NFSR_WANTSND 0x02 535191783Srmacklem#define NFSR_RCVLOCK 0x04 536191783Srmacklem#define NFSR_WANTRCV 0x08 537191783Srmacklem#define NFSR_RESERVEDPORT 0x10 538191783Srmacklem#define NFSR_LOCALHOST 0x20 539191783Srmacklem 540191783Srmacklem/* 541191783Srmacklem * Queue head for nfsreq's 542191783Srmacklem */ 543191783SrmacklemTAILQ_HEAD(nfsreqhead, nfsreq); 544191783Srmacklem 545192581Srmacklem/* This is the only nfsreq R_xxx flag still used. */ 546191783Srmacklem#define R_DONTRECOVER 0x00000100 /* don't initiate recovery when this 547191783Srmacklem rpc gets a stale state reply */ 548191783Srmacklem 549191783Srmacklem/* 550191783Srmacklem * Network address hash list element 551191783Srmacklem */ 552191783Srmacklemunion nethostaddr { 553191783Srmacklem struct in_addr had_inet; 554191783Srmacklem struct in6_addr had_inet6; 555191783Srmacklem}; 556191783Srmacklem 557191783Srmacklem/* 558191783Srmacklem * Structure of list of mechanisms. 559191783Srmacklem */ 560191783Srmacklemstruct nfsgss_mechlist { 561191783Srmacklem int len; 562191783Srmacklem const u_char *str; 563191783Srmacklem int totlen; 564191783Srmacklem}; 565191783Srmacklem#define KERBV_MECH 0 /* position in list */ 566191783Srmacklem 567191783Srmacklem/* 568191783Srmacklem * This structure is used by the server for describing each request. 569191783Srmacklem */ 570191783Srmacklemstruct nfsrv_descript { 571191783Srmacklem mbuf_t nd_mrep; /* Request mbuf list */ 572191783Srmacklem mbuf_t nd_md; /* Current dissect mbuf */ 573191783Srmacklem mbuf_t nd_mreq; /* Reply mbuf list */ 574191783Srmacklem mbuf_t nd_mb; /* Current build mbuf */ 575191783Srmacklem NFSSOCKADDR_T nd_nam; /* and socket addr */ 576191783Srmacklem NFSSOCKADDR_T nd_nam2; /* return socket addr */ 577191783Srmacklem caddr_t nd_dpos; /* Current dissect pos */ 578191783Srmacklem caddr_t nd_bpos; /* Current build pos */ 579191783Srmacklem u_int16_t nd_procnum; /* RPC # */ 580191783Srmacklem u_int32_t nd_flag; /* nd_flag */ 581191783Srmacklem u_int32_t nd_repstat; /* Reply status */ 582191783Srmacklem int *nd_errp; /* Pointer to ret status */ 583191783Srmacklem u_int32_t nd_retxid; /* Reply xid */ 584191783Srmacklem struct nfsrvcache *nd_rp; /* Assoc. cache entry */ 585191783Srmacklem fhandle_t nd_fh; /* File handle */ 586191783Srmacklem struct ucred *nd_cred; /* Credentials */ 587191783Srmacklem uid_t nd_saveduid; /* Saved uid */ 588191783Srmacklem u_int64_t nd_sockref; /* Rcv socket ref# */ 589191783Srmacklem u_int64_t nd_compref; /* Compound RPC ref# */ 590191783Srmacklem time_t nd_tcpconntime; /* Time TCP connection est. */ 591191783Srmacklem nfsquad_t nd_clientid; /* Implied clientid */ 592191783Srmacklem int nd_gssnamelen; /* principal name length */ 593191783Srmacklem char *nd_gssname; /* principal name */ 594244042Srmacklem uint32_t *nd_slotseq; /* ptr to slot seq# in req */ 595269398Srmacklem uint8_t nd_sessionid[NFSX_V4SESSIONID]; /* Session id */ 596269398Srmacklem uint32_t nd_slotid; /* Slotid for this RPC */ 597269398Srmacklem SVCXPRT *nd_xprt; /* Server RPC handle */ 598191783Srmacklem}; 599191783Srmacklem 600191783Srmacklem#define nd_princlen nd_gssnamelen 601191783Srmacklem#define nd_principal nd_gssname 602191783Srmacklem 603191783Srmacklem/* Bits for "nd_flag" */ 604191783Srmacklem#define ND_DONTSAVEREPLY 0x00000001 605191783Srmacklem#define ND_SAVEREPLY 0x00000002 606191783Srmacklem#define ND_NFSV2 0x00000004 607191783Srmacklem#define ND_NFSV3 0x00000008 608191783Srmacklem#define ND_NFSV4 0x00000010 609191783Srmacklem#define ND_KERBV 0x00000020 610191783Srmacklem#define ND_GSSINTEGRITY 0x00000040 611191783Srmacklem#define ND_GSSPRIVACY 0x00000080 612191783Srmacklem#define ND_WINDOWVERF 0x00000100 613191783Srmacklem#define ND_GSSINITREPLY 0x00000200 614191783Srmacklem#define ND_STREAMSOCK 0x00000400 615191783Srmacklem#define ND_PUBLOOKUP 0x00000800 616191783Srmacklem#define ND_USEGSSNAME 0x00001000 617191783Srmacklem#define ND_SAMETCPCONN 0x00002000 618191783Srmacklem#define ND_IMPLIEDCLID 0x00004000 619191783Srmacklem#define ND_NOMOREDATA 0x00008000 620191783Srmacklem#define ND_V4WCCATTR 0x00010000 621191783Srmacklem#define ND_NFSCB 0x00020000 622191783Srmacklem#define ND_AUTHNONE 0x00040000 623192121Srmacklem#define ND_EXAUTHSYS 0x00080000 624192121Srmacklem#define ND_EXGSS 0x00100000 625192121Srmacklem#define ND_EXGSSINTEGRITY 0x00200000 626192121Srmacklem#define ND_EXGSSPRIVACY 0x00400000 627192121Srmacklem#define ND_INCRSEQID 0x00800000 628240720Srmacklem#define ND_NFSCL 0x01000000 629244042Srmacklem#define ND_NFSV41 0x02000000 630244042Srmacklem#define ND_HASSEQUENCE 0x04000000 631269398Srmacklem#define ND_CACHETHIS 0x08000000 632269398Srmacklem#define ND_LASTOP 0x10000000 633191783Srmacklem 634191783Srmacklem/* 635191783Srmacklem * ND_GSS should be the "or" of all GSS type authentications. 636191783Srmacklem */ 637191783Srmacklem#define ND_GSS (ND_KERBV) 638191783Srmacklem 639191783Srmacklemstruct nfsv4_opflag { 640191783Srmacklem int retfh; 641191783Srmacklem int needscfh; 642191783Srmacklem int savereply; 643191783Srmacklem int modifyfs; 644216700Srmacklem int lktype; 645244042Srmacklem int needsseq; 646191783Srmacklem}; 647191783Srmacklem 648191783Srmacklem/* 649191783Srmacklem * Flags used to indicate what to do w.r.t. seqid checking. 650191783Srmacklem */ 651191783Srmacklem#define NFSRVSEQID_FIRST 0x01 652191783Srmacklem#define NFSRVSEQID_LAST 0x02 653191783Srmacklem#define NFSRVSEQID_OPEN 0x04 654191783Srmacklem 655191783Srmacklem/* 656191783Srmacklem * assign a doubly linked list to a new head 657191783Srmacklem * and prepend one list into another. 658191783Srmacklem */ 659191783Srmacklem#define LIST_NEWHEAD(nhead, ohead, field) do { \ 660191783Srmacklem if (((nhead)->lh_first = (ohead)->lh_first) != NULL) \ 661191783Srmacklem (ohead)->lh_first->field.le_prev = &(nhead)->lh_first; \ 662191783Srmacklem (ohead)->lh_first = NULL; \ 663191783Srmacklem } while (0) 664191783Srmacklem 665191783Srmacklem#define LIST_PREPEND(head, phead, lelm, field) do { \ 666191783Srmacklem if ((head)->lh_first != NULL) { \ 667191783Srmacklem (lelm)->field.le_next = (head)->lh_first; \ 668191783Srmacklem (lelm)->field.le_next->field.le_prev = \ 669191783Srmacklem &(lelm)->field.le_next; \ 670191783Srmacklem } \ 671191783Srmacklem (head)->lh_first = (phead)->lh_first; \ 672191783Srmacklem (head)->lh_first->field.le_prev = &(head)->lh_first; \ 673191783Srmacklem } while (0) 674191783Srmacklem 675191783Srmacklem/* 676191783Srmacklem * File handle structure for client. Malloc'd to the correct length with 677191783Srmacklem * malloc type M_NFSFH. 678191783Srmacklem */ 679191783Srmacklemstruct nfsfh { 680191783Srmacklem u_int16_t nfh_len; /* Length of file handle */ 681191783Srmacklem u_int8_t nfh_fh[1]; /* and the file handle */ 682191783Srmacklem}; 683191783Srmacklem 684191783Srmacklem/* 685191783Srmacklem * File handle structure for server. The NFSRV_MAXFH constant is 686191783Srmacklem * set in nfsdport.h. I use a 32bit length, so that alignment is 687191783Srmacklem * preserved. 688191783Srmacklem */ 689191783Srmacklemstruct nfsrvfh { 690191783Srmacklem u_int32_t nfsrvfh_len; 691191783Srmacklem u_int8_t nfsrvfh_data[NFSRV_MAXFH]; 692191783Srmacklem}; 693191783Srmacklem 694191783Srmacklem/* 695191783Srmacklem * This structure is used for sleep locks on the NFSv4 nfsd threads and 696191783Srmacklem * NFSv4 client data structures. 697191783Srmacklem */ 698191783Srmacklemstruct nfsv4lock { 699191783Srmacklem u_int32_t nfslock_usecnt; 700191783Srmacklem u_int8_t nfslock_lock; 701191783Srmacklem}; 702191783Srmacklem#define NFSV4LOCK_LOCK 0x01 703191783Srmacklem#define NFSV4LOCK_LOCKWANTED 0x02 704191783Srmacklem#define NFSV4LOCK_WANTED 0x04 705191783Srmacklem 706191783Srmacklem/* 707191783Srmacklem * Values for the override argument for nfsvno_accchk(). 708191783Srmacklem */ 709191783Srmacklem#define NFSACCCHK_NOOVERRIDE 0 710191783Srmacklem#define NFSACCCHK_ALLOWROOT 1 711191783Srmacklem#define NFSACCCHK_ALLOWOWNER 2 712191783Srmacklem 713191783Srmacklem/* 714191783Srmacklem * and values for the vpislocked argument for nfsvno_accchk(). 715191783Srmacklem */ 716191783Srmacklem#define NFSACCCHK_VPNOTLOCKED 0 717191783Srmacklem#define NFSACCCHK_VPISLOCKED 1 718191783Srmacklem 719244042Srmacklem/* 720244042Srmacklem * Slot for the NFSv4.1 Sequence Op. 721244042Srmacklem */ 722244042Srmacklemstruct nfsslot { 723244042Srmacklem int nfssl_inprog; 724244042Srmacklem uint32_t nfssl_seq; 725244042Srmacklem struct mbuf *nfssl_reply; 726244042Srmacklem}; 727244042Srmacklem 728191783Srmacklem#endif /* _KERNEL */ 729191783Srmacklem 730191783Srmacklem#endif /* _NFS_NFS_H */ 731