2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 1989, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * Rick Macklem at The University of Guelph.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * Tunable constants for nfs
43 #define NFS_MAXIOVEC 34
44 #define NFS_TICKINTVL 500 /* Desired time for a tick (msec) */
45 #define NFS_HZ (hz / nfscl_ticks) /* Ticks/sec */
46 #define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */
47 #define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */
48 #define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */
49 #define NFS_TCPTIMEO 300 /* TCP timeout */
50 #define NFS_MAXRCVTIMEO 60 /* 1 minute in seconds */
51 #define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/
52 #define NFS_MAXREXMIT 100 /* Stop counting after this many */
53 #define NFSV4_CALLBACKTIMEO (2 * NFS_HZ) /* Timeout in ticks */
54 #define NFSV4_CALLBACKRETRY 5 /* Number of retries before failure */
55 #define NFSV4_SLOTS 64 /* Number of slots, fore channel */
56 #define NFSV4_CBSLOTS 8 /* Number of slots, back channel */
57 #define NFSV4_CBRETRYCNT 4 /* # of CBRecall retries upon err */
58 #define NFSV4_UPCALLTIMEO (15 * NFS_HZ) /* Timeout in ticks for upcalls */
59 /* to gssd or nfsuserd */
60 #define NFSV4_UPCALLRETRY 4 /* Number of retries before failure */
61 #define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */
62 #define NFS_RETRANS 10 /* Num of retrans for soft mounts */
63 #define NFS_RETRANS_TCP 2 /* Num of retrans for TCP soft mounts */
64 #define NFS_MAXGRPS 16 /* Max. size of groups list */
65 #define NFS_TRYLATERDEL 15 /* Maximum delay timeout (sec) */
66 #ifndef NFS_REMOVETIMEO
67 #define NFS_REMOVETIMEO 15 /* # sec to wait for delegret in local syscall */
69 #ifndef NFS_MINATTRTIMO
70 #define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */
72 #ifndef NFS_MAXATTRTIMO
73 #define NFS_MAXATTRTIMO 60
75 #define NFS_WSIZE 8192 /* Def. write data size <= 8192 */
76 #define NFS_RSIZE 8192 /* Def. read data size <= 8192 */
77 #define NFS_READDIRSIZE 8192 /* Def. readdir size */
78 #define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */
79 #define NFS_MAXRAHEAD 16 /* Max. read ahead # blocks */
80 #define NFS_MAXASYNCDAEMON 64 /* Max. number async_daemons runnable */
81 #define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */
83 #define NFSRV_LEASE 120 /* Lease time in seconds for V4 */
84 #endif /* assigned to nfsrv_lease */
85 #ifndef NFSRV_STALELEASE
86 #define NFSRV_STALELEASE (5 * nfsrv_lease)
88 #ifndef NFSRV_MOULDYLEASE
89 #define NFSRV_MOULDYLEASE 604800 /* One week (in sec) */
91 #ifndef NFSCLIENTHASHSIZE
92 #define NFSCLIENTHASHSIZE 20 /* Size of server client hash table */
94 #ifndef NFSLOCKHASHSIZE
95 #define NFSLOCKHASHSIZE 20 /* Size of server nfslock hash table */
97 #ifndef NFSSESSIONHASHSIZE
98 #define NFSSESSIONHASHSIZE 20 /* Size of server session hash table */
100 #define NFSSTATEHASHSIZE 10 /* Size of server stateid hash table */
101 #ifndef NFSCLDELEGHIGHWATER
102 #define NFSCLDELEGHIGHWATER 10000 /* limit for client delegations */
104 #ifndef NFSCLLAYOUTHIGHWATER
105 #define NFSCLLAYOUTHIGHWATER 10000 /* limit for client pNFS layouts */
107 #ifndef NFSNOOPEN /* Inactive open owner (sec) */
108 #define NFSNOOPEN 120
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) */
115 #ifndef NFSRVCACHE_UDPHIGHWATER
116 #define NFSRVCACHE_UDPHIGHWATER 500 /* Max # of udp cache entries */
118 #ifndef NFSRVCACHE_TCPTIMEOUT
119 #define NFSRVCACHE_TCPTIMEOUT (3600*12) /*#of sec to hold cached rpcs(tcp) */
121 #ifndef NFSRVCACHE_FLOODLEVEL
122 #define NFSRVCACHE_FLOODLEVEL 16384 /* Very high water mark for cache */
124 #ifndef NFSRV_CLIENTHIGHWATER
125 #define NFSRV_CLIENTHIGHWATER 1000
127 #ifndef NFSRV_MAXDUMPLIST
128 #define NFSRV_MAXDUMPLIST 10000
130 #ifndef NFS_ACCESSCACHESIZE
131 #define NFS_ACCESSCACHESIZE 8
133 #define NFSV4_CBPORT 7745 /* Callback port for testing */
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
141 #define NFSRV_V4DELEGLIMIT(c) (((c) * 5) > nfsrv_v4statelimit)
143 #define NFS_READDIRBLKSIZ DIRBLKSIZ /* Minimal nm_readdirsize */
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_SRVMAXIO : NFS_V2MAXDATA)
159 #define NFS64BITSSET 0xffffffffffffffffull
160 #define NFS64BITSMINUS1 0xfffffffffffffffeull
163 * Structures for the nfssvc(2) syscall. Not that anyone but nfsd, mount_nfs
164 * and nfsloaduser should ever try and use it.
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 */
173 * nfsd argument for new krpc.
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 */
182 * NFSDEV_MIRRORSTR - string of digits that number the DSs 0->999.
183 * (To support more than 1000 DSs on an MDS, this needs to be increased.)
184 * NFSDEV_MAXMIRRORS - Maximum # of mirrors for a DS.
185 * (Most will only have a single mirror, but this setting allows up to 3.)
186 * NFSDEV_MAXVERS - maximum number of NFS versions supported by Flex File.
188 #define NFSDEV_MIRRORSTR 3
189 #define NFSDEV_MAXMIRRORS 4
190 #define NFSDEV_MAXVERS 4
193 * Arguments for use by the callback daemon.
195 struct nfsd_nfscbd_args {
196 const char *principal; /* GSS-API service principal name */
200 int sock; /* Socket to serve */
201 caddr_t name; /* Client addr for connection based sockets */
202 int namelen; /* Length of name */
203 u_short port; /* Port# for callbacks */
207 int nid_flag; /* Flags (see below) */
208 uid_t nid_uid; /* user/group id */
210 int nid_usermax; /* Upper bound on user name cache */
211 int nid_usertimeout;/* User name timeout (minutes) */
212 u_char *nid_name; /* Name */
213 int nid_namelen; /* and its length */
214 gid_t *nid_grps; /* and the list */
215 int nid_ngroup; /* Size of groups list */
218 struct nfsd_oidargs {
219 int nid_flag; /* Flags (see below) */
220 uid_t nid_uid; /* user/group id */
222 int nid_usermax; /* Upper bound on user name cache */
223 int nid_usertimeout;/* User name timeout (minutes) */
224 u_char *nid_name; /* Name */
225 int nid_namelen; /* and its length */
229 int nclid_idlen; /* Length of client id */
230 u_char nclid_id[NFSV4_OPAQUELIMIT]; /* and name */
233 struct nfsd_dumplist {
234 int ndl_size; /* Number of elements */
235 void *ndl_list; /* and the list of elements */
238 struct nfsd_dumpclients {
239 u_int32_t ndcl_flags; /* LCL_xxx flags */
240 u_int32_t ndcl_nopenowners; /* Number of openowners */
241 u_int32_t ndcl_nopens; /* and opens */
242 u_int32_t ndcl_nlockowners; /* and of lockowners */
243 u_int32_t ndcl_nlocks; /* and of locks */
244 u_int32_t ndcl_ndelegs; /* and of delegations */
245 u_int32_t ndcl_nolddelegs; /* and old delegations */
246 sa_family_t ndcl_addrfam; /* Callback address */
248 struct in_addr sin_addr;
249 struct in6_addr sin6_addr;
251 struct nfsd_clid ndcl_clid; /* and client id */
254 struct nfsd_dumplocklist {
255 char *ndllck_fname; /* File Name */
256 int ndllck_size; /* Number of elements */
257 void *ndllck_list; /* and the list of elements */
260 struct nfsd_dumplocks {
261 u_int32_t ndlck_flags; /* state flags NFSLCK_xxx */
262 nfsv4stateid_t ndlck_stateid; /* stateid */
263 u_int64_t ndlck_first; /* lock byte range */
265 struct nfsd_clid ndlck_owner; /* Owner of open/lock */
266 sa_family_t ndlck_addrfam; /* Callback address */
268 struct in_addr sin_addr;
269 struct in6_addr sin6_addr;
271 struct nfsd_clid ndlck_clid; /* and client id */
275 * Structure for referral information.
278 u_char *nfr_srvlist; /* List of servers */
279 int nfr_srvcnt; /* number of servers */
280 vnode_t nfr_vp; /* vnode for referral */
281 uint64_t nfr_dfileno; /* assigned dir inode# */
285 * Flags for lc_flags and opsflags for nfsrv_getclient().
287 #define LCL_NEEDSCONFIRM 0x00000001
288 #define LCL_DONTCLEAN 0x00000002
289 #define LCL_WAKEUPWANTED 0x00000004
290 #define LCL_TCPCALLBACK 0x00000008
291 #define LCL_CALLBACKSON 0x00000010
292 #define LCL_INDEXNOTOK 0x00000020
293 #define LCL_STAMPEDSTABLE 0x00000040
294 #define LCL_EXPIREIT 0x00000080
295 #define LCL_CBDOWN 0x00000100
296 #define LCL_KERBV 0x00000400
297 #define LCL_NAME 0x00000800
298 #define LCL_NEEDSCBNULL 0x00001000
299 #define LCL_GSSINTEGRITY 0x00002000
300 #define LCL_GSSPRIVACY 0x00004000
301 #define LCL_ADMINREVOKED 0x00008000
302 #define LCL_RECLAIMCOMPLETE 0x00010000
303 #define LCL_NFSV41 0x00020000
305 #define LCL_GSS LCL_KERBV /* Or of all mechs */
308 * Bits for flags in nfslock and nfsstate.
309 * The access, deny, NFSLCK_READ and NFSLCK_WRITE bits must be defined as
310 * below, in the correct order, so the shifts work for tests.
312 #define NFSLCK_READACCESS 0x00000001
313 #define NFSLCK_WRITEACCESS 0x00000002
314 #define NFSLCK_ACCESSBITS (NFSLCK_READACCESS | NFSLCK_WRITEACCESS)
315 #define NFSLCK_SHIFT 2
316 #define NFSLCK_READDENY 0x00000004
317 #define NFSLCK_WRITEDENY 0x00000008
318 #define NFSLCK_DENYBITS (NFSLCK_READDENY | NFSLCK_WRITEDENY)
319 #define NFSLCK_SHAREBITS \
320 (NFSLCK_READACCESS|NFSLCK_WRITEACCESS|NFSLCK_READDENY|NFSLCK_WRITEDENY)
321 #define NFSLCK_LOCKSHIFT 4
322 #define NFSLCK_READ 0x00000010
323 #define NFSLCK_WRITE 0x00000020
324 #define NFSLCK_BLOCKING 0x00000040
325 #define NFSLCK_RECLAIM 0x00000080
326 #define NFSLCK_OPENTOLOCK 0x00000100
327 #define NFSLCK_TEST 0x00000200
328 #define NFSLCK_LOCK 0x00000400
329 #define NFSLCK_UNLOCK 0x00000800
330 #define NFSLCK_OPEN 0x00001000
331 #define NFSLCK_CLOSE 0x00002000
332 #define NFSLCK_CHECK 0x00004000
333 #define NFSLCK_RELEASE 0x00008000
334 #define NFSLCK_NEEDSCONFIRM 0x00010000
335 #define NFSLCK_CONFIRM 0x00020000
336 #define NFSLCK_DOWNGRADE 0x00040000
337 #define NFSLCK_DELEGREAD 0x00080000
338 #define NFSLCK_DELEGWRITE 0x00100000
339 #define NFSLCK_DELEGCUR 0x00200000
340 #define NFSLCK_DELEGPREV 0x00400000
341 #define NFSLCK_OLDDELEG 0x00800000
342 #define NFSLCK_DELEGRECALL 0x01000000
343 #define NFSLCK_SETATTR 0x02000000
344 #define NFSLCK_DELEGPURGE 0x04000000
345 #define NFSLCK_DELEGRETURN 0x08000000
346 #define NFSLCK_WANTWDELEG 0x10000000
347 #define NFSLCK_WANTRDELEG 0x20000000
348 #define NFSLCK_WANTNODELEG 0x40000000
349 #define NFSLCK_WANTBITS \
350 (NFSLCK_WANTWDELEG | NFSLCK_WANTRDELEG | NFSLCK_WANTNODELEG)
352 /* And bits for nid_flag */
353 #define NFSID_INITIALIZE 0x0001
354 #define NFSID_ADDUID 0x0002
355 #define NFSID_DELUID 0x0004
356 #define NFSID_ADDUSERNAME 0x0008
357 #define NFSID_DELUSERNAME 0x0010
358 #define NFSID_ADDGID 0x0020
359 #define NFSID_DELGID 0x0040
360 #define NFSID_ADDGROUPNAME 0x0080
361 #define NFSID_DELGROUPNAME 0x0100
364 * fs.nfs sysctl(3) identifiers
366 #define NFS_NFSSTATS 1 /* struct: struct nfsstats */
369 * Here is the definition of the attribute bits array and macros that
371 * THE MACROS MUST BE MANUALLY MODIFIED IF NFSATTRBIT_MAXWORDS CHANGES!!
372 * It is (NFSATTRBIT_MAX + 31) / 32.
374 #define NFSATTRBIT_MAXWORDS 3
377 u_int32_t bits[NFSATTRBIT_MAXWORDS];
380 #define NFSZERO_ATTRBIT(b) do { \
386 #define NFSSET_ATTRBIT(t, f) do { \
387 (t)->bits[0] = (f)->bits[0]; \
388 (t)->bits[1] = (f)->bits[1]; \
389 (t)->bits[2] = (f)->bits[2]; \
392 #define NFSSETSUPP_ATTRBIT(b) do { \
393 (b)->bits[0] = NFSATTRBIT_SUPP0; \
394 (b)->bits[1] = (NFSATTRBIT_SUPP1 | NFSATTRBIT_SUPPSETONLY); \
395 (b)->bits[2] = NFSATTRBIT_SUPP2; \
398 #define NFSISSET_ATTRBIT(b, p) ((b)->bits[(p) / 32] & (1 << ((p) % 32)))
399 #define NFSSETBIT_ATTRBIT(b, p) ((b)->bits[(p) / 32] |= (1 << ((p) % 32)))
400 #define NFSCLRBIT_ATTRBIT(b, p) ((b)->bits[(p) / 32] &= ~(1 << ((p) % 32)))
402 #define NFSCLRALL_ATTRBIT(b, a) do { \
403 (b)->bits[0] &= ~((a)->bits[0]); \
404 (b)->bits[1] &= ~((a)->bits[1]); \
405 (b)->bits[2] &= ~((a)->bits[2]); \
408 #define NFSCLRNOT_ATTRBIT(b, a) do { \
409 (b)->bits[0] &= ((a)->bits[0]); \
410 (b)->bits[1] &= ((a)->bits[1]); \
411 (b)->bits[2] &= ((a)->bits[2]); \
414 #define NFSCLRNOTFILLABLE_ATTRBIT(b) do { \
415 (b)->bits[0] &= NFSATTRBIT_SUPP0; \
416 (b)->bits[1] &= NFSATTRBIT_SUPP1; \
417 (b)->bits[2] &= NFSATTRBIT_SUPP2; \
420 #define NFSCLRNOTSETABLE_ATTRBIT(b) do { \
421 (b)->bits[0] &= NFSATTRBIT_SETABLE0; \
422 (b)->bits[1] &= NFSATTRBIT_SETABLE1; \
423 (b)->bits[2] &= NFSATTRBIT_SETABLE2; \
426 #define NFSNONZERO_ATTRBIT(b) ((b)->bits[0] || (b)->bits[1] || (b)->bits[2])
427 #define NFSEQUAL_ATTRBIT(b, p) ((b)->bits[0] == (p)->bits[0] && \
428 (b)->bits[1] == (p)->bits[1] && (b)->bits[2] == (p)->bits[2])
430 #define NFSGETATTR_ATTRBIT(b) do { \
431 (b)->bits[0] = NFSATTRBIT_GETATTR0; \
432 (b)->bits[1] = NFSATTRBIT_GETATTR1; \
433 (b)->bits[2] = NFSATTRBIT_GETATTR2; \
436 #define NFSWCCATTR_ATTRBIT(b) do { \
437 (b)->bits[0] = NFSATTRBIT_WCCATTR0; \
438 (b)->bits[1] = NFSATTRBIT_WCCATTR1; \
439 (b)->bits[2] = NFSATTRBIT_WCCATTR2; \
442 #define NFSWRITEGETATTR_ATTRBIT(b) do { \
443 (b)->bits[0] = NFSATTRBIT_WRITEGETATTR0; \
444 (b)->bits[1] = NFSATTRBIT_WRITEGETATTR1; \
445 (b)->bits[2] = NFSATTRBIT_WRITEGETATTR2; \
448 #define NFSCBGETATTR_ATTRBIT(b, c) do { \
449 (c)->bits[0] = ((b)->bits[0] & NFSATTRBIT_CBGETATTR0); \
450 (c)->bits[1] = ((b)->bits[1] & NFSATTRBIT_CBGETATTR1); \
451 (c)->bits[2] = ((b)->bits[2] & NFSATTRBIT_CBGETATTR2); \
454 #define NFSPATHCONF_GETATTRBIT(b) do { \
455 (b)->bits[0] = NFSGETATTRBIT_PATHCONF0; \
456 (b)->bits[1] = NFSGETATTRBIT_PATHCONF1; \
457 (b)->bits[2] = NFSGETATTRBIT_PATHCONF2; \
460 #define NFSSTATFS_GETATTRBIT(b) do { \
461 (b)->bits[0] = NFSGETATTRBIT_STATFS0; \
462 (b)->bits[1] = NFSGETATTRBIT_STATFS1; \
463 (b)->bits[2] = NFSGETATTRBIT_STATFS2; \
466 #define NFSISSETSTATFS_ATTRBIT(b) \
467 (((b)->bits[0] & NFSATTRBIT_STATFS0) || \
468 ((b)->bits[1] & NFSATTRBIT_STATFS1) || \
469 ((b)->bits[2] & NFSATTRBIT_STATFS2))
471 #define NFSCLRSTATFS_ATTRBIT(b) do { \
472 (b)->bits[0] &= ~NFSATTRBIT_STATFS0; \
473 (b)->bits[1] &= ~NFSATTRBIT_STATFS1; \
474 (b)->bits[2] &= ~NFSATTRBIT_STATFS2; \
477 #define NFSREADDIRPLUS_ATTRBIT(b) do { \
478 (b)->bits[0] = NFSATTRBIT_READDIRPLUS0; \
479 (b)->bits[1] = NFSATTRBIT_READDIRPLUS1; \
480 (b)->bits[2] = NFSATTRBIT_READDIRPLUS2; \
483 #define NFSREFERRAL_ATTRBIT(b) do { \
484 (b)->bits[0] = NFSATTRBIT_REFERRAL0; \
485 (b)->bits[1] = NFSATTRBIT_REFERRAL1; \
486 (b)->bits[2] = NFSATTRBIT_REFERRAL2; \
490 * Store uid, gid creds that were used when the stateid was acquired.
491 * The RPC layer allows NFS_MAXGRPS + 1 groups to go out on the wire,
492 * so that's how many gets stored here.
496 gid_t nfsc_groups[NFS_MAXGRPS + 1];
501 * Constants that define the file handle for the V4 root directory.
502 * (The FSID must never be used by other file systems that are exported.)
504 #define NFSV4ROOT_FSID0 ((int32_t) -1)
505 #define NFSV4ROOT_FSID1 ((int32_t) -1)
506 #define NFSV4ROOT_REFERRAL ((int32_t) -2)
507 #define NFSV4ROOT_INO 2 /* It's traditional */
508 #define NFSV4ROOT_GEN 1
511 * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
512 * What should be in this set is open to debate, but I believe that since
513 * I/O system calls on ufs are never interrupted by signals the set should
514 * be minimal. My reasoning is that many current programs that use signals
515 * such as SIGALRM will not expect file I/O system calls to be interrupted
518 #if defined(_KERNEL) || defined(KERNEL)
520 struct uio; struct buf; struct vattr; struct nameidata; /* XXX */
523 * Socket errors ignored for connectionless sockets?
524 * For now, ignore them all
526 #define NFSIGNORE_SOERROR(s, e) \
527 ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
528 ((s) & PR_CONNREQUIRED) == 0)
532 * This structure holds socket information for a connection. Used by the
533 * client and the server for callbacks.
536 NFSSOCKADDR_T nr_nam;
540 struct ucred *nr_cred;
545 struct __rpc_client *nr_client;
550 * And associated nr_lock bits.
552 #define NFSR_SNDLOCK 0x01
553 #define NFSR_WANTSND 0x02
554 #define NFSR_RCVLOCK 0x04
555 #define NFSR_WANTRCV 0x08
556 #define NFSR_RESERVEDPORT 0x10
557 #define NFSR_LOCALHOST 0x20
560 * Queue head for nfsreq's
562 TAILQ_HEAD(nfsreqhead, nfsreq);
564 /* This is the only nfsreq R_xxx flag still used. */
565 #define R_DONTRECOVER 0x00000100 /* don't initiate recovery when this
566 rpc gets a stale state reply */
569 * Network address hash list element
572 struct in_addr had_inet;
573 struct in6_addr had_inet6;
577 * Structure of list of mechanisms.
579 struct nfsgss_mechlist {
584 #define KERBV_MECH 0 /* position in list */
587 * This structure is used by the server for describing each request.
589 struct nfsrv_descript {
590 mbuf_t nd_mrep; /* Request mbuf list */
591 mbuf_t nd_md; /* Current dissect mbuf */
592 mbuf_t nd_mreq; /* Reply mbuf list */
593 mbuf_t nd_mb; /* Current build mbuf */
594 NFSSOCKADDR_T nd_nam; /* and socket addr */
595 NFSSOCKADDR_T nd_nam2; /* return socket addr */
596 caddr_t nd_dpos; /* Current dissect pos */
597 caddr_t nd_bpos; /* Current build pos */
598 u_int16_t nd_procnum; /* RPC # */
599 u_int32_t nd_flag; /* nd_flag */
600 u_int32_t nd_repstat; /* Reply status */
601 int *nd_errp; /* Pointer to ret status */
602 u_int32_t nd_retxid; /* Reply xid */
603 struct nfsrvcache *nd_rp; /* Assoc. cache entry */
604 fhandle_t nd_fh; /* File handle */
605 struct ucred *nd_cred; /* Credentials */
606 uid_t nd_saveduid; /* Saved uid */
607 u_int64_t nd_sockref; /* Rcv socket ref# */
608 u_int64_t nd_compref; /* Compound RPC ref# */
609 time_t nd_tcpconntime; /* Time TCP connection est. */
610 nfsquad_t nd_clientid; /* Implied clientid */
611 int nd_gssnamelen; /* principal name length */
612 char *nd_gssname; /* principal name */
613 uint32_t *nd_slotseq; /* ptr to slot seq# in req */
614 uint8_t nd_sessionid[NFSX_V4SESSIONID]; /* Session id */
615 uint32_t nd_slotid; /* Slotid for this RPC */
616 SVCXPRT *nd_xprt; /* Server RPC handle */
617 uint32_t *nd_sequence; /* Sequence Op. ptr */
620 #define nd_princlen nd_gssnamelen
621 #define nd_principal nd_gssname
623 /* Bits for "nd_flag" */
624 #define ND_DONTSAVEREPLY 0x00000001
625 #define ND_SAVEREPLY 0x00000002
626 #define ND_NFSV2 0x00000004
627 #define ND_NFSV3 0x00000008
628 #define ND_NFSV4 0x00000010
629 #define ND_KERBV 0x00000020
630 #define ND_GSSINTEGRITY 0x00000040
631 #define ND_GSSPRIVACY 0x00000080
632 #define ND_WINDOWVERF 0x00000100
633 #define ND_GSSINITREPLY 0x00000200
634 #define ND_STREAMSOCK 0x00000400
635 #define ND_PUBLOOKUP 0x00000800
636 #define ND_USEGSSNAME 0x00001000
637 #define ND_SAMETCPCONN 0x00002000
638 #define ND_IMPLIEDCLID 0x00004000
639 #define ND_NOMOREDATA 0x00008000
640 #define ND_V4WCCATTR 0x00010000
641 #define ND_NFSCB 0x00020000
642 #define ND_AUTHNONE 0x00040000
643 #define ND_EXAUTHSYS 0x00080000
644 #define ND_EXGSS 0x00100000
645 #define ND_EXGSSINTEGRITY 0x00200000
646 #define ND_EXGSSPRIVACY 0x00400000
647 #define ND_INCRSEQID 0x00800000
648 #define ND_NFSCL 0x01000000
649 #define ND_NFSV41 0x02000000
650 #define ND_HASSEQUENCE 0x04000000
651 #define ND_CACHETHIS 0x08000000
652 #define ND_LASTOP 0x10000000
653 #define ND_LOOPBADSESS 0x20000000
656 * ND_GSS should be the "or" of all GSS type authentications.
658 #define ND_GSS (ND_KERBV)
660 struct nfsv4_opflag {
671 * Flags used to indicate what to do w.r.t. seqid checking.
673 #define NFSRVSEQID_FIRST 0x01
674 #define NFSRVSEQID_LAST 0x02
675 #define NFSRVSEQID_OPEN 0x04
678 * assign a doubly linked list to a new head
679 * and prepend one list into another.
681 #define LIST_NEWHEAD(nhead, ohead, field) do { \
682 if (((nhead)->lh_first = (ohead)->lh_first) != NULL) \
683 (ohead)->lh_first->field.le_prev = &(nhead)->lh_first; \
684 (ohead)->lh_first = NULL; \
687 #define LIST_PREPEND(head, phead, lelm, field) do { \
688 if ((head)->lh_first != NULL) { \
689 (lelm)->field.le_next = (head)->lh_first; \
690 (lelm)->field.le_next->field.le_prev = \
691 &(lelm)->field.le_next; \
693 (head)->lh_first = (phead)->lh_first; \
694 (head)->lh_first->field.le_prev = &(head)->lh_first; \
698 * File handle structure for client. Malloc'd to the correct length with
699 * malloc type M_NFSFH.
702 u_int16_t nfh_len; /* Length of file handle */
703 u_int8_t nfh_fh[1]; /* and the file handle */
707 * File handle structure for server. The NFSRV_MAXFH constant is
708 * set in nfsdport.h. I use a 32bit length, so that alignment is
712 u_int32_t nfsrvfh_len;
713 u_int8_t nfsrvfh_data[NFSRV_MAXFH];
717 * This structure is used for sleep locks on the NFSv4 nfsd threads and
718 * NFSv4 client data structures.
721 u_int32_t nfslock_usecnt;
722 u_int8_t nfslock_lock;
724 #define NFSV4LOCK_LOCK 0x01
725 #define NFSV4LOCK_LOCKWANTED 0x02
726 #define NFSV4LOCK_WANTED 0x04
729 * Values for the override argument for nfsvno_accchk().
731 #define NFSACCCHK_NOOVERRIDE 0
732 #define NFSACCCHK_ALLOWROOT 1
733 #define NFSACCCHK_ALLOWOWNER 2
736 * and values for the vpislocked argument for nfsvno_accchk().
738 #define NFSACCCHK_VPNOTLOCKED 0
739 #define NFSACCCHK_VPISLOCKED 1
742 * Slot for the NFSv4.1 Sequence Op.
747 struct mbuf *nfssl_reply;
752 #endif /* _NFS_NFS_H */