1 /*- 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Rick Macklem at The University of Guelph. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 4. Neither the name of the University nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * $FreeBSD$ 33 */ 34 35 #ifndef _NFS_NFS_H_ 36 #define _NFS_NFS_H_ 37 /* 38 * Tunable constants for nfs 39 */ 40 41 #define NFS_MAXIOVEC 34 42 #define NFS_TICKINTVL 500 /* Desired time for a tick (msec) */ 43 #define NFS_HZ (hz / nfscl_ticks) /* Ticks/sec */ 44 #define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */ 45 #define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */ 46 #define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */ 47 #define NFS_TCPTIMEO 300 /* TCP timeout */ 48 #define NFS_MAXRCVTIMEO 60 /* 1 minute in seconds */ 49 #define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/ 50 #define NFS_MAXREXMIT 100 /* Stop counting after this many */ 51 #define NFSV4_CALLBACKTIMEO (2 * NFS_HZ) /* Timeout in ticks */ 52 #define NFSV4_CALLBACKRETRY 5 /* Number of retries before failure */ 53 #define NFSV4_CBSLOTS 8 /* Number of slots for session */ 54 #define NFSV4_CBRETRYCNT 4 /* # of CBRecall retries upon err */ 55 #define NFSV4_UPCALLTIMEO (15 * NFS_HZ) /* Timeout in ticks for upcalls */ 56 /* to gssd or nfsuserd */ 57 #define NFSV4_UPCALLRETRY 4 /* Number of retries before failure */ 58 #define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */ 59 #define NFS_RETRANS 10 /* Num of retrans for soft mounts */ 60 #define NFS_RETRANS_TCP 2 /* Num of retrans for TCP soft mounts */ 61 #define NFS_MAXGRPS 16 /* Max. size of groups list */ 62 #define NFS_TRYLATERDEL 15 /* Maximum delay timeout (sec) */ 63 #ifndef NFS_REMOVETIMEO 64 #define NFS_REMOVETIMEO 15 /* # sec to wait for delegret in local syscall */ 65 #endif 66 #ifndef NFS_MINATTRTIMO 67 #define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */ 68 #endif 69 #ifndef NFS_MAXATTRTIMO 70 #define NFS_MAXATTRTIMO 60 71 #endif 72 #define NFS_WSIZE 8192 /* Def. write data size <= 8192 */ 73 #define NFS_RSIZE 8192 /* Def. read data size <= 8192 */ 74 #define NFS_READDIRSIZE 8192 /* Def. readdir size */ 75 #define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */ 76 #define NFS_MAXRAHEAD 16 /* Max. read ahead # blocks */ 77 #define NFS_MAXASYNCDAEMON 64 /* Max. number async_daemons runnable */ 78 #define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */ 79 #ifndef NFSRV_LEASE 80 #define NFSRV_LEASE 120 /* Lease time in seconds for V4 */ 81 #endif /* assigned to nfsrv_lease */ 82 #ifndef NFSRV_STALELEASE 83 #define NFSRV_STALELEASE (5 * nfsrv_lease) 84 #endif 85 #ifndef NFSRV_MOULDYLEASE 86 #define NFSRV_MOULDYLEASE 604800 /* One week (in sec) */ 87 #endif 88 #ifndef NFSCLIENTHASHSIZE 89 #define NFSCLIENTHASHSIZE 20 /* Size of server client hash table */ 90 #endif 91 #ifndef NFSLOCKHASHSIZE 92 #define NFSLOCKHASHSIZE 20 /* Size of server nfslock hash table */ 93 #endif 94 #define NFSSTATEHASHSIZE 10 /* Size of server stateid hash table */ 95 #ifndef NFSUSERHASHSIZE 96 #define NFSUSERHASHSIZE 30 /* Size of user id hash table */ 97 #endif 98 #ifndef NFSGROUPHASHSIZE 99 #define NFSGROUPHASHSIZE 5 /* Size of group id hash table */ 100 #endif 101 #ifndef NFSCLDELEGHIGHWATER 102 #define NFSCLDELEGHIGHWATER 10000 /* limit for client delegations */ 103 #endif 104 #ifndef NFSCLLAYOUTHIGHWATER 105 #define NFSCLLAYOUTHIGHWATER 10000 /* limit for client pNFS layouts */ 106 #endif 107 #ifndef NFSNOOPEN /* Inactive open owner (sec) */ 108 #define NFSNOOPEN 120 109 #endif 110 #define NFSRV_LEASEDELTA 15 /* # of seconds to delay beyond lease */ 111 #define NFS_IDMAXSIZE 4 /* max sizeof (in_addr_t) */ 112 #ifndef NFSRVCACHE_UDPTIMEOUT 113 #define NFSRVCACHE_UDPTIMEOUT 30 /* # of sec to hold cached rpcs(udp) */ 114 #endif 115 #ifndef NFSRVCACHE_UDPHIGHWATER 116 #define NFSRVCACHE_UDPHIGHWATER 500 /* Max # of udp cache entries */ 117 #endif 118 #ifndef NFSRVCACHE_TCPTIMEOUT 119 #define NFSRVCACHE_TCPTIMEOUT (3600*12) /*#of sec to hold cached rpcs(tcp) */ 120 #endif 121 #ifndef NFSRVCACHE_FLOODLEVEL 122 #define NFSRVCACHE_FLOODLEVEL 16384 /* Very high water mark for cache */ 123 #endif 124 #ifndef NFSRV_CLIENTHIGHWATER 125 #define NFSRV_CLIENTHIGHWATER 1000 126 #endif 127 #ifndef NFSRV_MAXDUMPLIST 128 #define NFSRV_MAXDUMPLIST 10000 129 #endif 130 #ifndef NFS_ACCESSCACHESIZE 131 #define NFS_ACCESSCACHESIZE 8 132 #endif 133 #define NFSV4_CBPORT 7745 /* Callback port for testing */ 134 135 /* 136 * This macro defines the high water mark for issuing V4 delegations. 137 * (It is currently set at a conservative 20% of NFSRV_V4STATELIMIT. This 138 * may want to increase when clients can make more effective use of 139 * delegations.) 140 */ 141 #define NFSRV_V4DELEGLIMIT(c) (((c) * 5) > NFSRV_V4STATELIMIT) 142 143 #define NFS_READDIRBLKSIZ DIRBLKSIZ /* Minimal nm_readdirsize */ 144 145 /* 146 * Oddballs 147 */ 148 #define NFS_CMPFH(n, f, s) \ 149 ((n)->n_fhp->nfh_len == (s) && !NFSBCMP((n)->n_fhp->nfh_fh, (caddr_t)(f), (s))) 150 #define NFSRV_CMPFH(nf, ns, f, s) \ 151 ((ns) == (s) && !NFSBCMP((caddr_t)(nf), (caddr_t)(f), (s))) 152 #define NFS_CMPTIME(t1, t2) \ 153 ((t1).tv_sec == (t2).tv_sec && (t1).tv_nsec == (t2).tv_nsec) 154 #define NFS_SETTIME(t) do { \ 155 (t).tv_sec = time.tv_sec; (t).tv_nsec = 1000 * time.tv_usec; } while (0) 156 #define NFS_SRVMAXDATA(n) \ 157 (((n)->nd_flag & (ND_NFSV3 | ND_NFSV4)) ? \ 158 NFS_MAXDATA : NFS_V2MAXDATA) 159 #define NFS64BITSSET 0xffffffffffffffffull 160 #define NFS64BITSMINUS1 0xfffffffffffffffeull 161 162 /* 163 * Structures for the nfssvc(2) syscall. Not that anyone but nfsd, mount_nfs 164 * and nfsloaduser should ever try and use it. 165 */ 166 struct nfsd_addsock_args { 167 int sock; /* Socket to serve */ 168 caddr_t name; /* Client addr for connection based sockets */ 169 int namelen; /* Length of name */ 170 }; 171 172 /* 173 * nfsd argument for new krpc. 174 */ 175 struct nfsd_nfsd_args { 176 const char *principal; /* GSS-API service principal name */ 177 int minthreads; /* minimum service thread count */ 178 int maxthreads; /* maximum service thread count */ 179 }; 180 181 /* 182 * Arguments for use by the callback daemon. 183 */ 184 struct nfsd_nfscbd_args { 185 const char *principal; /* GSS-API service principal name */ 186 }; 187 188 struct nfscbd_args { 189 int sock; /* Socket to serve */ 190 caddr_t name; /* Client addr for connection based sockets */ 191 int namelen; /* Length of name */ 192 u_short port; /* Port# for callbacks */ 193 }; 194 195 struct nfsd_idargs { 196 int nid_flag; /* Flags (see below) */ 197 uid_t nid_uid; /* user/group id */ 198 gid_t nid_gid; 199 int nid_usermax; /* Upper bound on user name cache */ 200 int nid_usertimeout;/* User name timeout (minutes) */ 201 u_char *nid_name; /* Name */ 202 int nid_namelen; /* and its length */ 203 }; 204 205 struct nfsd_clid { 206 int nclid_idlen; /* Length of client id */ 207 u_char nclid_id[NFSV4_OPAQUELIMIT]; /* and name */ 208 }; 209 210 struct nfsd_dumplist { 211 int ndl_size; /* Number of elements */ 212 void *ndl_list; /* and the list of elements */ 213 }; 214 215 struct nfsd_dumpclients { 216 u_int32_t ndcl_flags; /* LCL_xxx flags */ 217 u_int32_t ndcl_nopenowners; /* Number of openowners */ 218 u_int32_t ndcl_nopens; /* and opens */ 219 u_int32_t ndcl_nlockowners; /* and of lockowners */ 220 u_int32_t ndcl_nlocks; /* and of locks */ 221 u_int32_t ndcl_ndelegs; /* and of delegations */ 222 u_int32_t ndcl_nolddelegs; /* and old delegations */ 223 sa_family_t ndcl_addrfam; /* Callback address */ 224 union { 225 struct in_addr sin_addr; 226 struct in6_addr sin6_addr; 227 } ndcl_cbaddr; 228 struct nfsd_clid ndcl_clid; /* and client id */ 229 }; 230 231 struct nfsd_dumplocklist { 232 char *ndllck_fname; /* File Name */ 233 int ndllck_size; /* Number of elements */ 234 void *ndllck_list; /* and the list of elements */ 235 }; 236 237 struct nfsd_dumplocks { 238 u_int32_t ndlck_flags; /* state flags NFSLCK_xxx */ 239 nfsv4stateid_t ndlck_stateid; /* stateid */ 240 u_int64_t ndlck_first; /* lock byte range */ 241 u_int64_t ndlck_end; 242 struct nfsd_clid ndlck_owner; /* Owner of open/lock */ 243 sa_family_t ndlck_addrfam; /* Callback address */ 244 union { 245 struct in_addr sin_addr; 246 struct in6_addr sin6_addr; 247 } ndlck_cbaddr; 248 struct nfsd_clid ndlck_clid; /* and client id */ 249 }; 250 251 /* 252 * Structure for referral information. 253 */ 254 struct nfsreferral { 255 u_char *nfr_srvlist; /* List of servers */ 256 int nfr_srvcnt; /* number of servers */ 257 vnode_t nfr_vp; /* vnode for referral */ 258 u_int32_t nfr_dfileno; /* assigned dir inode# */ 259 }; 260 261 /* 262 * Flags for lc_flags and opsflags for nfsrv_getclient(). 263 */ 264 #define LCL_NEEDSCONFIRM 0x00000001 265 #define LCL_DONTCLEAN 0x00000002 266 #define LCL_WAKEUPWANTED 0x00000004 267 #define LCL_TCPCALLBACK 0x00000008 268 #define LCL_CALLBACKSON 0x00000010 269 #define LCL_INDEXNOTOK 0x00000020 270 #define LCL_STAMPEDSTABLE 0x00000040 271 #define LCL_EXPIREIT 0x00000080 272 #define LCL_CBDOWN 0x00000100 273 #define LCL_KERBV 0x00000400 274 #define LCL_NAME 0x00000800 275 #define LCL_NEEDSCBNULL 0x00001000 276 #define LCL_GSSINTEGRITY 0x00002000 277 #define LCL_GSSPRIVACY 0x00004000 278 #define LCL_ADMINREVOKED 0x00008000 279 280 #define LCL_GSS LCL_KERBV /* Or of all mechs */ 281 282 /* 283 * Bits for flags in nfslock and nfsstate. 284 * The access, deny, NFSLCK_READ and NFSLCK_WRITE bits must be defined as 285 * below, in the correct order, so the shifts work for tests. 286 */ 287 #define NFSLCK_READACCESS 0x00000001 288 #define NFSLCK_WRITEACCESS 0x00000002 289 #define NFSLCK_ACCESSBITS (NFSLCK_READACCESS | NFSLCK_WRITEACCESS) 290 #define NFSLCK_SHIFT 2 291 #define NFSLCK_READDENY 0x00000004 292 #define NFSLCK_WRITEDENY 0x00000008 293 #define NFSLCK_DENYBITS (NFSLCK_READDENY | NFSLCK_WRITEDENY) 294 #define NFSLCK_SHAREBITS \ 295 (NFSLCK_READACCESS|NFSLCK_WRITEACCESS|NFSLCK_READDENY|NFSLCK_WRITEDENY) 296 #define NFSLCK_LOCKSHIFT 4 297 #define NFSLCK_READ 0x00000010 298 #define NFSLCK_WRITE 0x00000020 299 #define NFSLCK_BLOCKING 0x00000040 300 #define NFSLCK_RECLAIM 0x00000080 301 #define NFSLCK_OPENTOLOCK 0x00000100 302 #define NFSLCK_TEST 0x00000200 303 #define NFSLCK_LOCK 0x00000400 304 #define NFSLCK_UNLOCK 0x00000800 305 #define NFSLCK_OPEN 0x00001000 306 #define NFSLCK_CLOSE 0x00002000 307 #define NFSLCK_CHECK 0x00004000 308 #define NFSLCK_RELEASE 0x00008000 309 #define NFSLCK_NEEDSCONFIRM 0x00010000 310 #define NFSLCK_CONFIRM 0x00020000 311 #define NFSLCK_DOWNGRADE 0x00040000 312 #define NFSLCK_DELEGREAD 0x00080000 313 #define NFSLCK_DELEGWRITE 0x00100000 314 #define NFSLCK_DELEGCUR 0x00200000 315 #define NFSLCK_DELEGPREV 0x00400000 316 #define NFSLCK_OLDDELEG 0x00800000 317 #define NFSLCK_DELEGRECALL 0x01000000 318 #define NFSLCK_SETATTR 0x02000000 319 #define NFSLCK_DELEGPURGE 0x04000000 320 #define NFSLCK_DELEGRETURN 0x08000000 321 322 /* And bits for nid_flag */ 323 #define NFSID_INITIALIZE 0x0001 324 #define NFSID_ADDUID 0x0002 325 #define NFSID_DELUID 0x0004 326 #define NFSID_ADDUSERNAME 0x0008 327 #define NFSID_DELUSERNAME 0x0010 328 #define NFSID_ADDGID 0x0020 329 #define NFSID_DELGID 0x0040 330 #define NFSID_ADDGROUPNAME 0x0080 331 #define NFSID_DELGROUPNAME 0x0100 332 333 /* 334 * fs.nfs sysctl(3) identifiers 335 */ 336 #define NFS_NFSSTATS 1 /* struct: struct nfsstats */ 337 338 /* 339 * Here is the definition of the attribute bits array and macros that 340 * manipulate it. 341 * THE MACROS MUST BE MANUALLY MODIFIED IF NFSATTRBIT_MAXWORDS CHANGES!! 342 * It is (NFSATTRBIT_MAX + 31) / 32. 343 */ 344 #define NFSATTRBIT_MAXWORDS 2 345 346 typedef struct { 347 u_int32_t bits[NFSATTRBIT_MAXWORDS]; 348 } nfsattrbit_t; 349 350 #define NFSZERO_ATTRBIT(b) do { (b)->bits[0] = 0; (b)->bits[1] = 0; } while (0) 351 #define NFSSET_ATTRBIT(t, f) do { (t)->bits[0] = (f)->bits[0]; \ 352 (t)->bits[1] = (f)->bits[1]; } while (0) 353 #define NFSSETSUPP_ATTRBIT(b) do { \ 354 (b)->bits[0] = NFSATTRBIT_SUPP0; \ 355 (b)->bits[1] = (NFSATTRBIT_SUPP1 | NFSATTRBIT_SUPPSETONLY); } while (0) 356 #define NFSISSET_ATTRBIT(b, p) ((b)->bits[(p) / 32] & (1 << ((p) % 32))) 357 #define NFSSETBIT_ATTRBIT(b, p) ((b)->bits[(p) / 32] |= (1 << ((p) % 32))) 358 #define NFSCLRBIT_ATTRBIT(b, p) ((b)->bits[(p) / 32] &= ~(1 << ((p) % 32))) 359 #define NFSCLRALL_ATTRBIT(b, a) do { \ 360 (b)->bits[0] &= ~((a)->bits[0]); \ 361 (b)->bits[1] &= ~((a)->bits[1]); \ 362 } while (0) 363 #define NFSCLRNOT_ATTRBIT(b, a) do { \ 364 (b)->bits[0] &= ((a)->bits[0]); \ 365 (b)->bits[1] &= ((a)->bits[1]); \ 366 } while (0) 367 #define NFSCLRNOTFILLABLE_ATTRBIT(b) do { \ 368 (b)->bits[0] &= NFSATTRBIT_SUPP0; \ 369 (b)->bits[1] &= NFSATTRBIT_SUPP1; } while (0) 370 #define NFSCLRNOTSETABLE_ATTRBIT(b) do { \ 371 (b)->bits[0] &= NFSATTRBIT_SETABLE0; \ 372 (b)->bits[1] &= NFSATTRBIT_SETABLE1; } while (0) 373 #define NFSNONZERO_ATTRBIT(b) ((b)->bits[0] || (b)->bits[1]) 374 #define NFSEQUAL_ATTRBIT(b, p) \ 375 ((b)->bits[0] == (p)->bits[0] && (b)->bits[1] == (p)->bits[1]) 376 #define NFSGETATTR_ATTRBIT(b) do { \ 377 (b)->bits[0] = NFSATTRBIT_GETATTR0; \ 378 (b)->bits[1] = NFSATTRBIT_GETATTR1; } while (0) 379 #define NFSWCCATTR_ATTRBIT(b) do { \ 380 (b)->bits[0] = NFSATTRBIT_WCCATTR0; \ 381 (b)->bits[1] = NFSATTRBIT_WCCATTR1; } while (0) 382 #define NFSWRITEGETATTR_ATTRBIT(b) do { \ 383 (b)->bits[0] = NFSATTRBIT_WRITEGETATTR0; \ 384 (b)->bits[1] = NFSATTRBIT_WRITEGETATTR1; } while (0) 385 #define NFSCBGETATTR_ATTRBIT(b, c) do { \ 386 (c)->bits[0] = ((b)->bits[0] & NFSATTRBIT_CBGETATTR0); \ 387 (c)->bits[1] = ((b)->bits[1] & NFSATTRBIT_CBGETATTR1); } while (0) 388 #define NFSPATHCONF_GETATTRBIT(b) do { \ 389 (b)->bits[0] = NFSGETATTRBIT_PATHCONF0; \ 390 (b)->bits[1] = NFSGETATTRBIT_PATHCONF1; } while (0) 391 #define NFSSTATFS_GETATTRBIT(b) do { \ 392 (b)->bits[0] = NFSGETATTRBIT_STATFS0; \ 393 (b)->bits[1] = NFSGETATTRBIT_STATFS1; } while (0) 394 #define NFSISSETSTATFS_ATTRBIT(b) \ 395 (((b)->bits[0] & NFSATTRBIT_STATFS0) || \ 396 ((b)->bits[1] & NFSATTRBIT_STATFS1)) 397 #define NFSCLRSTATFS_ATTRBIT(b) do { \ 398 (b)->bits[0] &= ~NFSATTRBIT_STATFS0; \ 399 (b)->bits[1] &= ~NFSATTRBIT_STATFS1; } while (0) 400 #define NFSREADDIRPLUS_ATTRBIT(b) do { \ 401 (b)->bits[0] = NFSATTRBIT_READDIRPLUS0; \ 402 (b)->bits[1] = NFSATTRBIT_READDIRPLUS1; } while (0) 403 #define NFSREFERRAL_ATTRBIT(b) do { \ 404 (b)->bits[0] = NFSATTRBIT_REFERRAL0; \ 405 (b)->bits[1] = NFSATTRBIT_REFERRAL1; } while (0) 406 407 /* 408 * Store uid, gid creds that were used when the stateid was acquired. 409 * The RPC layer allows NFS_MAXGRPS + 1 groups to go out on the wire, 410 * so that's how many gets stored here. 411 */ 412 struct nfscred { 413 uid_t nfsc_uid; 414 gid_t nfsc_groups[NFS_MAXGRPS + 1]; 415 int nfsc_ngroups; 416 }; 417 418 /* 419 * Constants that define the file handle for the V4 root directory. 420 * (The FSID must never be used by other file systems that are exported.) 421 */ 422 #define NFSV4ROOT_FSID0 ((int32_t) -1) 423 #define NFSV4ROOT_FSID1 ((int32_t) -1) 424 #define NFSV4ROOT_REFERRAL ((int32_t) -2) 425 #define NFSV4ROOT_INO 2 /* It's traditional */ 426 #define NFSV4ROOT_GEN 1 427 428 /* 429 * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts. 430 * What should be in this set is open to debate, but I believe that since 431 * I/O system calls on ufs are never interrupted by signals the set should 432 * be minimal. My reasoning is that many current programs that use signals 433 * such as SIGALRM will not expect file I/O system calls to be interrupted 434 * by them and break. 435 */ 436 #if defined(_KERNEL) || defined(KERNEL) 437 438 struct uio; struct buf; struct vattr; struct nameidata; /* XXX */ 439 440 /* 441 * Socket errors ignored for connectionless sockets? 442 * For now, ignore them all 443 */ 444 #define NFSIGNORE_SOERROR(s, e) \ 445 ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \ 446 ((s) & PR_CONNREQUIRED) == 0) 447 448 449 /* 450 * This structure holds socket information for a connection. Used by the 451 * client and the server for callbacks. 452 */ 453 struct nfssockreq { 454 NFSSOCKADDR_T nr_nam; 455 int nr_sotype; 456 int nr_soproto; 457 int nr_soflags; 458 struct ucred *nr_cred; 459 int nr_lock; 460 NFSMUTEX_T nr_mtx; 461 u_int32_t nr_prog; 462 u_int32_t nr_vers; 463 struct __rpc_client *nr_client; 464 AUTH *nr_auth; 465 }; 466 467 /* 468 * And associated nr_lock bits. 469 */ 470 #define NFSR_SNDLOCK 0x01 471 #define NFSR_WANTSND 0x02 472 #define NFSR_RCVLOCK 0x04 473 #define NFSR_WANTRCV 0x08 474 #define NFSR_RESERVEDPORT 0x10 475 #define NFSR_LOCALHOST 0x20 476 477 /* 478 * Queue head for nfsreq's 479 */ 480 TAILQ_HEAD(nfsreqhead, nfsreq); 481 482 /* This is the only nfsreq R_xxx flag still used. */ 483 #define R_DONTRECOVER 0x00000100 /* don't initiate recovery when this 484 rpc gets a stale state reply */ 485 486 /* 487 * Network address hash list element 488 */ 489 union nethostaddr { 490 struct in_addr had_inet; 491 struct in6_addr had_inet6; 492 }; 493 494 /* 495 * Structure of list of mechanisms. 496 */ 497 struct nfsgss_mechlist { 498 int len; 499 const u_char *str; 500 int totlen; 501 }; 502 #define KERBV_MECH 0 /* position in list */ 503 504 /* 505 * This structure is used by the server for describing each request. 506 */ 507 struct nfsrv_descript { 508 mbuf_t nd_mrep; /* Request mbuf list */ 509 mbuf_t nd_md; /* Current dissect mbuf */ 510 mbuf_t nd_mreq; /* Reply mbuf list */ 511 mbuf_t nd_mb; /* Current build mbuf */ 512 NFSSOCKADDR_T nd_nam; /* and socket addr */ 513 NFSSOCKADDR_T nd_nam2; /* return socket addr */ 514 caddr_t nd_dpos; /* Current dissect pos */ 515 caddr_t nd_bpos; /* Current build pos */ 516 u_int16_t nd_procnum; /* RPC # */ 517 u_int32_t nd_flag; /* nd_flag */ 518 u_int32_t nd_repstat; /* Reply status */ 519 int *nd_errp; /* Pointer to ret status */ 520 u_int32_t nd_retxid; /* Reply xid */ 521 struct nfsrvcache *nd_rp; /* Assoc. cache entry */ 522 fhandle_t nd_fh; /* File handle */ 523 struct ucred *nd_cred; /* Credentials */ 524 uid_t nd_saveduid; /* Saved uid */ 525 u_int64_t nd_sockref; /* Rcv socket ref# */ 526 u_int64_t nd_compref; /* Compound RPC ref# */ 527 time_t nd_tcpconntime; /* Time TCP connection est. */ 528 nfsquad_t nd_clientid; /* Implied clientid */ 529 int nd_gssnamelen; /* principal name length */ 530 char *nd_gssname; /* principal name */ 531 uint32_t *nd_slotseq; /* ptr to slot seq# in req */ 532 }; 533 534 #define nd_princlen nd_gssnamelen 535 #define nd_principal nd_gssname 536 537 /* Bits for "nd_flag" */ 538 #define ND_DONTSAVEREPLY 0x00000001 539 #define ND_SAVEREPLY 0x00000002 540 #define ND_NFSV2 0x00000004 541 #define ND_NFSV3 0x00000008 542 #define ND_NFSV4 0x00000010 543 #define ND_KERBV 0x00000020 544 #define ND_GSSINTEGRITY 0x00000040 545 #define ND_GSSPRIVACY 0x00000080 546 #define ND_WINDOWVERF 0x00000100 547 #define ND_GSSINITREPLY 0x00000200 548 #define ND_STREAMSOCK 0x00000400 549 #define ND_PUBLOOKUP 0x00000800 550 #define ND_USEGSSNAME 0x00001000 551 #define ND_SAMETCPCONN 0x00002000 552 #define ND_IMPLIEDCLID 0x00004000 553 #define ND_NOMOREDATA 0x00008000 554 #define ND_V4WCCATTR 0x00010000 555 #define ND_NFSCB 0x00020000 556 #define ND_AUTHNONE 0x00040000 557 #define ND_EXAUTHSYS 0x00080000 558 #define ND_EXGSS 0x00100000 559 #define ND_EXGSSINTEGRITY 0x00200000 560 #define ND_EXGSSPRIVACY 0x00400000 561 #define ND_INCRSEQID 0x00800000 562 #define ND_NFSCL 0x01000000 563 #define ND_NFSV41 0x02000000 564 #define ND_HASSEQUENCE 0x04000000 565 566 /* 567 * ND_GSS should be the "or" of all GSS type authentications. 568 */ 569 #define ND_GSS (ND_KERBV) 570 571 struct nfsv4_opflag { 572 int retfh; 573 int needscfh; 574 int savereply; 575 int modifyfs; 576 int lktype; 577 int needsseq; 578 }; 579 580 /* 581 * Flags used to indicate what to do w.r.t. seqid checking. 582 */ 583 #define NFSRVSEQID_FIRST 0x01 584 #define NFSRVSEQID_LAST 0x02 585 #define NFSRVSEQID_OPEN 0x04 586 587 /* 588 * assign a doubly linked list to a new head 589 * and prepend one list into another. 590 */ 591 #define LIST_NEWHEAD(nhead, ohead, field) do { \ 592 if (((nhead)->lh_first = (ohead)->lh_first) != NULL) \ 593 (ohead)->lh_first->field.le_prev = &(nhead)->lh_first; \ 594 (ohead)->lh_first = NULL; \ 595 } while (0) 596 597 #define LIST_PREPEND(head, phead, lelm, field) do { \ 598 if ((head)->lh_first != NULL) { \ 599 (lelm)->field.le_next = (head)->lh_first; \ 600 (lelm)->field.le_next->field.le_prev = \ 601 &(lelm)->field.le_next; \ 602 } \ 603 (head)->lh_first = (phead)->lh_first; \ 604 (head)->lh_first->field.le_prev = &(head)->lh_first; \ 605 } while (0) 606 607 /* 608 * File handle structure for client. Malloc'd to the correct length with 609 * malloc type M_NFSFH. 610 */ 611 struct nfsfh { 612 u_int16_t nfh_len; /* Length of file handle */ 613 u_int8_t nfh_fh[1]; /* and the file handle */ 614 }; 615 616 /* 617 * File handle structure for server. The NFSRV_MAXFH constant is 618 * set in nfsdport.h. I use a 32bit length, so that alignment is 619 * preserved. 620 */ 621 struct nfsrvfh { 622 u_int32_t nfsrvfh_len; 623 u_int8_t nfsrvfh_data[NFSRV_MAXFH]; 624 }; 625 626 /* 627 * This structure is used for sleep locks on the NFSv4 nfsd threads and 628 * NFSv4 client data structures. 629 */ 630 struct nfsv4lock { 631 u_int32_t nfslock_usecnt; 632 u_int8_t nfslock_lock; 633 }; 634 #define NFSV4LOCK_LOCK 0x01 635 #define NFSV4LOCK_LOCKWANTED 0x02 636 #define NFSV4LOCK_WANTED 0x04 637 638 /* 639 * Values for the override argument for nfsvno_accchk(). 640 */ 641 #define NFSACCCHK_NOOVERRIDE 0 642 #define NFSACCCHK_ALLOWROOT 1 643 #define NFSACCCHK_ALLOWOWNER 2 644 645 /* 646 * and values for the vpislocked argument for nfsvno_accchk(). 647 */ 648 #define NFSACCCHK_VPNOTLOCKED 0 649 #define NFSACCCHK_VPISLOCKED 1 650 651 /* 652 * Slot for the NFSv4.1 Sequence Op. 653 */ 654 struct nfsslot { 655 int nfssl_inprog; 656 uint32_t nfssl_seq; 657 struct mbuf *nfssl_reply; 658 }; 659 660 #endif /* _KERNEL */ 661 662 #endif /* _NFS_NFS_H */ 663