Deleted Added
full compact
nfsstats.h (34961) nfsstats.h (36176)
1/*
2 * Copyright (c) 1989, 1993, 1995
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 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)nfs.h 8.4 (Berkeley) 5/1/95
1/*
2 * Copyright (c) 1989, 1993, 1995
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 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)nfs.h 8.4 (Berkeley) 5/1/95
37 * $Id: nfs.h,v 1.33 1998/02/01 21:23:29 bde Exp $
37 * $Id: nfs.h,v 1.34 1998/03/30 09:53:43 phk Exp $
38 */
39
40#ifndef _NFS_NFS_H_
41#define _NFS_NFS_H_
42
43/*
44 * Tunable constants for nfs
45 */
46
47#define NFS_MAXIOVEC 34
48#define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */
49#define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */
50#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */
51#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */
52#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */
53#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/
54#define NFS_MAXREXMIT 100 /* Stop counting after this many */
55#define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */
56#define NFS_RETRANS 10 /* Num of retrans for soft mounts */
57#define NFS_MAXGRPS 16 /* Max. size of groups list */
58#ifndef NFS_MINATTRTIMO
38 */
39
40#ifndef _NFS_NFS_H_
41#define _NFS_NFS_H_
42
43/*
44 * Tunable constants for nfs
45 */
46
47#define NFS_MAXIOVEC 34
48#define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */
49#define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */
50#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */
51#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */
52#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */
53#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/
54#define NFS_MAXREXMIT 100 /* Stop counting after this many */
55#define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */
56#define NFS_RETRANS 10 /* Num of retrans for soft mounts */
57#define NFS_MAXGRPS 16 /* Max. size of groups list */
58#ifndef NFS_MINATTRTIMO
59#define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */
59#define NFS_MINATTRTIMO 3 /* VREG attrib cache timeout in sec */
60#endif
61#ifndef NFS_MAXATTRTIMO
62#define NFS_MAXATTRTIMO 60
63#endif
60#endif
61#ifndef NFS_MAXATTRTIMO
62#define NFS_MAXATTRTIMO 60
63#endif
64#ifndef NFS_MINDIRATTRTIMO
65#define NFS_MINDIRATTRTIMO 30 /* VDIR attrib cache timeout in sec */
66#endif
67#ifndef NFS_MAXDIRATTRTIMO
68#define NFS_MAXDIRATTRTIMO 60
69#endif
64#define NFS_WSIZE 8192 /* Def. write data size <= 8192 */
65#define NFS_RSIZE 8192 /* Def. read data size <= 8192 */
66#define NFS_READDIRSIZE 8192 /* Def. readdir size */
67#define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */
68#define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */
69#define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */
70#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runnable */
71#define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */
72#ifndef NFS_GATHERDELAY
73#define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */
74#endif
75#define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */
76#ifdef KERNEL
77#define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */
78#endif
79
80/*
81 * Oddballs
82 */
83#define NMOD(a) ((a) % nfs_asyncdaemons)
84#define NFS_CMPFH(n, f, s) \
85 ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s)))
86#define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
87#define NFS_SRVMAXDATA(n) \
88 (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \
89 NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA)
90
91/*
92 * XXX
93 * The B_INVAFTERWRITE flag should be set to whatever is required by the
94 * buffer cache code to say "Invalidate the block after it is written back".
95 */
96#define B_INVAFTERWRITE B_NOCACHE
97
98/*
99 * The IO_METASYNC flag should be implemented for local file systems.
100 * (Until then, it is nothin at all.)
101 */
102#ifndef IO_METASYNC
103#define IO_METASYNC 0
104#endif
105
106/*
70#define NFS_WSIZE 8192 /* Def. write data size <= 8192 */
71#define NFS_RSIZE 8192 /* Def. read data size <= 8192 */
72#define NFS_READDIRSIZE 8192 /* Def. readdir size */
73#define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */
74#define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */
75#define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */
76#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runnable */
77#define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */
78#ifndef NFS_GATHERDELAY
79#define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */
80#endif
81#define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */
82#ifdef KERNEL
83#define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */
84#endif
85
86/*
87 * Oddballs
88 */
89#define NMOD(a) ((a) % nfs_asyncdaemons)
90#define NFS_CMPFH(n, f, s) \
91 ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s)))
92#define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
93#define NFS_SRVMAXDATA(n) \
94 (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \
95 NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA)
96
97/*
98 * XXX
99 * The B_INVAFTERWRITE flag should be set to whatever is required by the
100 * buffer cache code to say "Invalidate the block after it is written back".
101 */
102#define B_INVAFTERWRITE B_NOCACHE
103
104/*
105 * The IO_METASYNC flag should be implemented for local file systems.
106 * (Until then, it is nothin at all.)
107 */
108#ifndef IO_METASYNC
109#define IO_METASYNC 0
110#endif
111
112/*
107 * Set the attribute timeout based on how recently the file has been modified.
108 */
109#define NFS_ATTRTIMEO(np) \
110 ((((np)->n_flag & NMODIFIED) || \
111 (time_second - (np)->n_mtime) / 10 < NFS_MINATTRTIMO) ? NFS_MINATTRTIMO : \
112 ((time_second - (np)->n_mtime) / 10 > NFS_MAXATTRTIMO ? NFS_MAXATTRTIMO : \
113 (time_second - (np)->n_mtime) / 10))
114
115/*
116 * Expected allocation sizes for major data structures. If the actual size
117 * of the structure exceeds these sizes, then malloc() will be allocating
118 * almost twice the memory required. This is used in nfs_init() to warn
119 * the sysadmin that the size of a structure should be reduced.
120 * (These sizes are always a power of 2. If the kernel malloc() changes
121 * to one that does not allocate space in powers of 2 size, then this all
122 * becomes bunk!)
123 */
124#define NFS_NODEALLOC 256
125#define NFS_MNTALLOC 512
126#define NFS_SVCALLOC 256
127#define NFS_UIDALLOC 128
128
129/*
130 * Arguments to mount NFS
131 */
132#define NFS_ARGSVERSION 3 /* change when nfs_args changes */
133struct nfs_args {
134 int version; /* args structure version number */
135 struct sockaddr *addr; /* file server address */
136 int addrlen; /* length of address */
137 int sotype; /* Socket type */
138 int proto; /* and Protocol */
139 u_char *fh; /* File handle to be mounted */
140 int fhsize; /* Size, in bytes, of fh */
141 int flags; /* flags */
142 int wsize; /* write size in bytes */
143 int rsize; /* read size in bytes */
144 int readdirsize; /* readdir size in bytes */
145 int timeo; /* initial timeout in .1 secs */
146 int retrans; /* times to retry send */
147 int maxgrouplist; /* Max. size of group list */
148 int readahead; /* # of blocks to readahead */
149 int leaseterm; /* Term (sec) of lease */
150 int deadthresh; /* Retrans threshold */
151 char *hostname; /* server's name */
113 * Expected allocation sizes for major data structures. If the actual size
114 * of the structure exceeds these sizes, then malloc() will be allocating
115 * almost twice the memory required. This is used in nfs_init() to warn
116 * the sysadmin that the size of a structure should be reduced.
117 * (These sizes are always a power of 2. If the kernel malloc() changes
118 * to one that does not allocate space in powers of 2 size, then this all
119 * becomes bunk!)
120 */
121#define NFS_NODEALLOC 256
122#define NFS_MNTALLOC 512
123#define NFS_SVCALLOC 256
124#define NFS_UIDALLOC 128
125
126/*
127 * Arguments to mount NFS
128 */
129#define NFS_ARGSVERSION 3 /* change when nfs_args changes */
130struct nfs_args {
131 int version; /* args structure version number */
132 struct sockaddr *addr; /* file server address */
133 int addrlen; /* length of address */
134 int sotype; /* Socket type */
135 int proto; /* and Protocol */
136 u_char *fh; /* File handle to be mounted */
137 int fhsize; /* Size, in bytes, of fh */
138 int flags; /* flags */
139 int wsize; /* write size in bytes */
140 int rsize; /* read size in bytes */
141 int readdirsize; /* readdir size in bytes */
142 int timeo; /* initial timeout in .1 secs */
143 int retrans; /* times to retry send */
144 int maxgrouplist; /* Max. size of group list */
145 int readahead; /* # of blocks to readahead */
146 int leaseterm; /* Term (sec) of lease */
147 int deadthresh; /* Retrans threshold */
148 char *hostname; /* server's name */
149 int acregmin; /* cache attrs for reg files min time */
150 int acregmax; /* cache attrs for reg files max time */
151 int acdirmin; /* cache attrs for dirs min time */
152 int acdirmax; /* cache attrs for dirs max time */
152};
153
154/*
155 * NFS mount option flags
156 */
157#define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */
158#define NFSMNT_WSIZE 0x00000002 /* set write size */
159#define NFSMNT_RSIZE 0x00000004 /* set read size */
160#define NFSMNT_TIMEO 0x00000008 /* set initial timeout */
161#define NFSMNT_RETRANS 0x00000010 /* set number of request retries */
162#define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */
163#define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */
164#define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */
165#define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */
166#define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */
167#define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */
168#define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */
169#define NFSMNT_LEASETERM 0x00001000 /* set lease term (nqnfs) */
170#define NFSMNT_READAHEAD 0x00002000 /* set read ahead */
171#define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */
172#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */
173#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */
174#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */
153};
154
155/*
156 * NFS mount option flags
157 */
158#define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */
159#define NFSMNT_WSIZE 0x00000002 /* set write size */
160#define NFSMNT_RSIZE 0x00000004 /* set read size */
161#define NFSMNT_TIMEO 0x00000008 /* set initial timeout */
162#define NFSMNT_RETRANS 0x00000010 /* set number of request retries */
163#define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */
164#define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */
165#define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */
166#define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */
167#define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */
168#define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */
169#define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */
170#define NFSMNT_LEASETERM 0x00001000 /* set lease term (nqnfs) */
171#define NFSMNT_READAHEAD 0x00002000 /* set read ahead */
172#define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */
173#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */
174#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */
175#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */
175#define NFSMNT_INTERNAL 0xfffc0000 /* Bits set internally */
176#define NFSMNT_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
177#define NFSMNT_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
178#define NFSMNT_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
179#define NFSMNT_MNTD 0x00200000 /* Mnt server for mnt point */
180#define NFSMNT_DISMINPROG 0x00400000 /* Dismount in progress */
181#define NFSMNT_DISMNT 0x00800000 /* Dismounted */
182#define NFSMNT_SNDLOCK 0x01000000 /* Send socket lock */
183#define NFSMNT_WANTSND 0x02000000 /* Want above */
184#define NFSMNT_RCVLOCK 0x04000000 /* Rcv socket lock */
185#define NFSMNT_WANTRCV 0x08000000 /* Want above */
186#define NFSMNT_WAITAUTH 0x10000000 /* Wait for authentication */
187#define NFSMNT_HASAUTH 0x20000000 /* Has authenticator */
188#define NFSMNT_WANTAUTH 0x40000000 /* Wants an authenticator */
189#define NFSMNT_AUTHERR 0x80000000 /* Authentication error */
176#define NFSMNT_ACREGMIN 0x00040000
177#define NFSMNT_ACREGMAX 0x00080000
178#define NFSMNT_ACDIRMIN 0x00100000
179#define NFSMNT_ACDIRMAX 0x00200000
190
180
181#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
182#define NFSSTA_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
183#define NFSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
184#define NFSSTA_MNTD 0x00200000 /* Mnt server for mnt point */
185#define NFSSTA_DISMINPROG 0x00400000 /* Dismount in progress */
186#define NFSSTA_DISMNT 0x00800000 /* Dismounted */
187#define NFSSTA_SNDLOCK 0x01000000 /* Send socket lock */
188#define NFSSTA_WANTSND 0x02000000 /* Want above */
189#define NFSSTA_RCVLOCK 0x04000000 /* Rcv socket lock */
190#define NFSSTA_WANTRCV 0x08000000 /* Want above */
191#define NFSSTA_WAITAUTH 0x10000000 /* Wait for authentication */
192#define NFSSTA_HASAUTH 0x20000000 /* Has authenticator */
193#define NFSSTA_WANTAUTH 0x40000000 /* Wants an authenticator */
194#define NFSSTA_AUTHERR 0x80000000 /* Authentication error */
195
191/*
192 * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs
193 * should ever try and use it.
194 */
195struct nfsd_args {
196 int sock; /* Socket to serve */
197 caddr_t name; /* Client addr for connection based sockets */
198 int namelen; /* Length of name */
199};
200
201struct nfsd_srvargs {
202 struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */
203 uid_t nsd_uid; /* Effective uid mapped to cred */
204 u_long nsd_haddr; /* Ip address of client */
205 struct ucred nsd_cr; /* Cred. uid maps to */
206 int nsd_authlen; /* Length of auth string (ret) */
207 u_char *nsd_authstr; /* Auth string (ret) */
208 int nsd_verflen; /* and the verfier */
209 u_char *nsd_verfstr;
210 struct timeval nsd_timestamp; /* timestamp from verifier */
211 u_long nsd_ttl; /* credential ttl (sec) */
212 NFSKERBKEY_T nsd_key; /* Session key */
213};
214
215struct nfsd_cargs {
216 char *ncd_dirp; /* Mount dir path */
217 uid_t ncd_authuid; /* Effective uid */
218 int ncd_authtype; /* Type of authenticator */
219 int ncd_authlen; /* Length of authenticator string */
220 u_char *ncd_authstr; /* Authenticator string */
221 int ncd_verflen; /* and the verifier */
222 u_char *ncd_verfstr;
223 NFSKERBKEY_T ncd_key; /* Session key */
224};
225
226/*
227 * XXX to allow amd to include nfs.h without nfsproto.h
228 */
229#ifdef NFS_NPROCS
230/*
231 * Stats structure
232 */
233struct nfsstats {
234 int attrcache_hits;
235 int attrcache_misses;
236 int lookupcache_hits;
237 int lookupcache_misses;
238 int direofcache_hits;
239 int direofcache_misses;
240 int biocache_reads;
241 int read_bios;
242 int read_physios;
243 int biocache_writes;
244 int write_bios;
245 int write_physios;
246 int biocache_readlinks;
247 int readlink_bios;
248 int biocache_readdirs;
249 int readdir_bios;
250 int rpccnt[NFS_NPROCS];
251 int rpcretries;
252 int srvrpccnt[NFS_NPROCS];
253 int srvrpc_errs;
254 int srv_errs;
255 int rpcrequests;
256 int rpctimeouts;
257 int rpcunexpected;
258 int rpcinvalid;
259 int srvcache_inproghits;
260 int srvcache_idemdonehits;
261 int srvcache_nonidemdonehits;
262 int srvcache_misses;
263 int srvnqnfs_leases;
264 int srvnqnfs_maxleases;
265 int srvnqnfs_getleases;
266 int srvvop_writes;
267};
268#endif
269
270/*
271 * Flags for nfssvc() system call.
272 */
273#define NFSSVC_BIOD 0x002
274#define NFSSVC_NFSD 0x004
275#define NFSSVC_ADDSOCK 0x008
276#define NFSSVC_AUTHIN 0x010
277#define NFSSVC_GOTAUTH 0x040
278#define NFSSVC_AUTHINFAIL 0x080
279#define NFSSVC_MNTD 0x100
280
281/*
282 * fs.nfs sysctl(3) identifiers
283 */
284#define NFS_NFSSTATS 1 /* struct: struct nfsstats */
285#define NFS_NFSPRIVPORT 2 /* int: prohibit nfs to resvports */
286
287#define FS_NFS_NAMES { \
288 { 0, 0 }, \
289 { "nfsstats", CTLTYPE_STRUCT }, \
290 { "nfsprivport", CTLTYPE_INT }, \
291}
292
293/*
294 * Network address hash list element
295 */
296union nethostaddr {
297 u_long had_inetaddr;
298 struct sockaddr *had_nam;
299};
300
301#ifdef KERNEL
302
303#ifdef MALLOC_DECLARE
304MALLOC_DECLARE(M_NFSREQ);
305MALLOC_DECLARE(M_NFSMNT);
306MALLOC_DECLARE(M_NFSDIROFF);
307MALLOC_DECLARE(M_NFSRVDESC);
308MALLOC_DECLARE(M_NFSUID);
309MALLOC_DECLARE(M_NQLEASE);
310MALLOC_DECLARE(M_NFSD);
311MALLOC_DECLARE(M_NFSBIGFH);
312#endif
313
314struct uio; struct buf; struct vattr; struct nameidata; /* XXX */
315
316/*
317 * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
318 * What should be in this set is open to debate, but I believe that since
319 * I/O system calls on ufs are never interrupted by signals the set should
320 * be minimal. My reasoning is that many current programs that use signals
321 * such as SIGALRM will not expect file I/O system calls to be interrupted
322 * by them and break.
323 */
324#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
325 sigmask(SIGHUP)|sigmask(SIGQUIT))
326
327/*
328 * Socket errors ignored for connectionless sockets??
329 * For now, ignore them all
330 */
331#define NFSIGNORE_SOERROR(s, e) \
332 ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
333 ((s) & PR_CONNREQUIRED) == 0)
334
335/*
336 * Nfs outstanding request list element
337 */
338struct nfsreq {
339 TAILQ_ENTRY(nfsreq) r_chain;
340 struct mbuf *r_mreq;
341 struct mbuf *r_mrep;
342 struct mbuf *r_md;
343 caddr_t r_dpos;
344 struct nfsmount *r_nmp;
345 struct vnode *r_vp;
346 u_long r_xid;
347 int r_flags; /* flags on request, see below */
348 int r_retry; /* max retransmission count */
349 int r_rexmit; /* current retrans count */
350 int r_timer; /* tick counter on reply */
351 u_int32_t r_procnum; /* NFS procedure number */
352 int r_rtt; /* RTT for rpc */
353 struct proc *r_procp; /* Proc that did I/O system call */
354};
355
356/*
357 * Queue head for nfsreq's
358 */
359extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq;
360
361/* Flag values for r_flags */
362#define R_TIMING 0x01 /* timing request (in mntp) */
363#define R_SENT 0x02 /* request has been sent */
364#define R_SOFTTERM 0x04 /* soft mnt, too many retries */
365#define R_INTR 0x08 /* intr mnt, signal pending */
366#define R_SOCKERR 0x10 /* Fatal error on socket */
367#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */
368#define R_MUSTRESEND 0x40 /* Must resend request */
369#define R_GETONEREP 0x80 /* Probe for one reply only */
370
371/*
372 * A list of nfssvc_sock structures is maintained with all the sockets
373 * that require service by the nfsd.
374 * The nfsuid structs hang off of the nfssvc_sock structs in both lru
375 * and uid hash lists.
376 */
377#ifndef NFS_UIDHASHSIZ
378#define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */
379#endif
380#define NUIDHASH(sock, uid) \
381 (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ])
382#ifndef NFS_WDELAYHASHSIZ
383#define NFS_WDELAYHASHSIZ 16 /* and with this */
384#endif
385#define NWDELAYHASH(sock, f) \
386 (&(sock)->ns_wdelayhashtbl[(*((u_long *)(f))) % NFS_WDELAYHASHSIZ])
387#ifndef NFS_MUIDHASHSIZ
388#define NFS_MUIDHASHSIZ 63 /* Tune the size of nfsmount with this */
389#endif
390#define NMUIDHASH(nmp, uid) \
391 (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ])
392#define NFSNOHASH(fhsum) \
393 (&nfsnodehashtbl[(fhsum) & nfsnodehash])
394
395struct nfsuid {
396 TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */
397 LIST_ENTRY(nfsuid) nu_hash; /* Hash list */
398 int nu_flag; /* Flags */
399 union nethostaddr nu_haddr; /* Host addr. for dgram sockets */
400 struct ucred nu_cr; /* Cred uid mapped to */
401 int nu_expire; /* Expiry time (sec) */
402 struct timeval nu_timestamp; /* Kerb. timestamp */
403 u_long nu_nickname; /* Nickname on server */
404 NFSKERBKEY_T nu_key; /* and session key */
405};
406
407#define nu_inetaddr nu_haddr.had_inetaddr
408#define nu_nam nu_haddr.had_nam
409/* Bits for nu_flag */
410#define NU_INETADDR 0x1
411#define NU_NAM 0x2
412#define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO)
413
414struct nfsrv_rec {
415 STAILQ_ENTRY(nfsrv_rec) nr_link;
416 struct sockaddr *nr_address;
417 struct mbuf *nr_packet;
418};
419
420struct nfssvc_sock {
421 TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */
422 TAILQ_HEAD(, nfsuid) ns_uidlruhead;
423 struct file *ns_fp;
424 struct socket *ns_so;
425 struct sockaddr *ns_nam;
426 struct mbuf *ns_raw;
427 struct mbuf *ns_rawend;
428 STAILQ_HEAD(, nfsrv_rec) ns_rec;
429 struct mbuf *ns_frag;
430 int ns_flag;
431 int ns_solock;
432 int ns_cc;
433 int ns_reclen;
434 int ns_numuids;
435 u_long ns_sref;
436 LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */
437 LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ];
438 LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ];
439};
440
441/* Bits for "ns_flag" */
442#define SLP_VALID 0x01
443#define SLP_DOREC 0x02
444#define SLP_NEEDQ 0x04
445#define SLP_DISCONN 0x08
446#define SLP_GETSTREAM 0x10
447#define SLP_LASTFRAG 0x20
448#define SLP_ALLFLAGS 0xff
449
450extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead;
451extern int nfssvc_sockhead_flag;
452#define SLP_INIT 0x01
453#define SLP_WANTINIT 0x02
454
455/*
456 * One of these structures is allocated for each nfsd.
457 */
458struct nfsd {
459 TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */
460 int nfsd_flag; /* NFSD_ flags */
461 struct nfssvc_sock *nfsd_slp; /* Current socket */
462 int nfsd_authlen; /* Authenticator len */
463 u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */
464 int nfsd_verflen; /* and the Verifier */
465 u_char nfsd_verfstr[RPCVERF_MAXSIZ];
466 struct proc *nfsd_procp; /* Proc ptr */
467 struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */
468};
469
470/* Bits for "nfsd_flag" */
471#define NFSD_WAITING 0x01
472#define NFSD_REQINPROG 0x02
473#define NFSD_NEEDAUTH 0x04
474#define NFSD_AUTHFAIL 0x08
475
476/*
477 * This structure is used by the server for describing each request.
478 * Some fields are used only when write request gathering is performed.
479 */
480struct nfsrv_descript {
481 u_quad_t nd_time; /* Write deadline (usec) */
482 off_t nd_off; /* Start byte offset */
483 off_t nd_eoff; /* and end byte offset */
484 LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */
485 LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */
486 LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */
487 struct mbuf *nd_mrep; /* Request mbuf list */
488 struct mbuf *nd_md; /* Current dissect mbuf */
489 struct mbuf *nd_mreq; /* Reply mbuf list */
490 struct sockaddr *nd_nam; /* and socket addr */
491 struct sockaddr *nd_nam2; /* return socket addr */
492 caddr_t nd_dpos; /* Current dissect pos */
493 u_int32_t nd_procnum; /* RPC # */
494 int nd_stable; /* storage type */
495 int nd_flag; /* nd_flag */
496 int nd_len; /* Length of this write */
497 int nd_repstat; /* Reply status */
498 u_long nd_retxid; /* Reply xid */
499 u_long nd_duration; /* Lease duration */
500 struct timeval nd_starttime; /* Time RPC initiated */
501 fhandle_t nd_fh; /* File handle */
502 struct ucred nd_cr; /* Credentials */
503};
504
505/* Bits for "nd_flag" */
506#define ND_READ LEASE_READ
507#define ND_WRITE LEASE_WRITE
508#define ND_CHECK 0x04
509#define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK)
510#define ND_NFSV3 0x08
511#define ND_NQNFS 0x10
512#define ND_KERBNICK 0x20
513#define ND_KERBFULL 0x40
514#define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL)
515
516extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head;
517extern int nfsd_head_flag;
518#define NFSD_CHECKSLP 0x01
519
520/*
521 * These macros compare nfsrv_descript structures.
522 */
523#define NFSW_CONTIG(o, n) \
524 ((o)->nd_eoff >= (n)->nd_off && \
525 !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH))
526
527#define NFSW_SAMECRED(o, n) \
528 (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \
529 !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \
530 sizeof (struct ucred)))
531
532/*
533 * Defines for WebNFS
534 */
535
536#define WEBNFS_ESC_CHAR '%'
537#define WEBNFS_SPECCHAR_START 0x80
538
539#define WEBNFS_NATIVE_CHAR 0x80
540/*
541 * ..
542 * Possibly more here in the future.
543 */
544
545/*
546 * Macro for converting escape characters in WebNFS pathnames.
547 * Should really be in libkern.
548 */
549
550#define HEXTOC(c) \
551 ((c) >= 'a' ? ((c) - ('a' - 10)) : \
552 ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '0')))
553#define HEXSTRTOI(p) \
554 ((HEXTOC(p[0]) << 4) + HEXTOC(p[1]))
555
556#ifdef NFS_DEBUG
557
558extern int nfs_debug;
559#define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */
560#define NFS_DEBUG_WG 2 /* server write gathering */
561#define NFS_DEBUG_RC 4 /* server request caching */
562
563#define NFS_DPF(cat, args) \
564 do { \
565 if (nfs_debug & NFS_DEBUG_##cat) printf args; \
566 } while (0)
567
568#else
569
570#define NFS_DPF(cat, args)
571
572#endif
573
574u_quad_t nfs_curusec __P((void));
575int nfs_init __P((struct vfsconf *vfsp));
576int nfs_reply __P((struct nfsreq *));
577int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int));
578int nfs_send __P((struct socket *, struct sockaddr *, struct mbuf *,
579 struct nfsreq *));
580int nfs_rephead __P((int, struct nfsrv_descript *, struct nfssvc_sock *,
581 int, int, u_quad_t *, struct mbuf **, struct mbuf **,
582 caddr_t *));
196/*
197 * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs
198 * should ever try and use it.
199 */
200struct nfsd_args {
201 int sock; /* Socket to serve */
202 caddr_t name; /* Client addr for connection based sockets */
203 int namelen; /* Length of name */
204};
205
206struct nfsd_srvargs {
207 struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */
208 uid_t nsd_uid; /* Effective uid mapped to cred */
209 u_long nsd_haddr; /* Ip address of client */
210 struct ucred nsd_cr; /* Cred. uid maps to */
211 int nsd_authlen; /* Length of auth string (ret) */
212 u_char *nsd_authstr; /* Auth string (ret) */
213 int nsd_verflen; /* and the verfier */
214 u_char *nsd_verfstr;
215 struct timeval nsd_timestamp; /* timestamp from verifier */
216 u_long nsd_ttl; /* credential ttl (sec) */
217 NFSKERBKEY_T nsd_key; /* Session key */
218};
219
220struct nfsd_cargs {
221 char *ncd_dirp; /* Mount dir path */
222 uid_t ncd_authuid; /* Effective uid */
223 int ncd_authtype; /* Type of authenticator */
224 int ncd_authlen; /* Length of authenticator string */
225 u_char *ncd_authstr; /* Authenticator string */
226 int ncd_verflen; /* and the verifier */
227 u_char *ncd_verfstr;
228 NFSKERBKEY_T ncd_key; /* Session key */
229};
230
231/*
232 * XXX to allow amd to include nfs.h without nfsproto.h
233 */
234#ifdef NFS_NPROCS
235/*
236 * Stats structure
237 */
238struct nfsstats {
239 int attrcache_hits;
240 int attrcache_misses;
241 int lookupcache_hits;
242 int lookupcache_misses;
243 int direofcache_hits;
244 int direofcache_misses;
245 int biocache_reads;
246 int read_bios;
247 int read_physios;
248 int biocache_writes;
249 int write_bios;
250 int write_physios;
251 int biocache_readlinks;
252 int readlink_bios;
253 int biocache_readdirs;
254 int readdir_bios;
255 int rpccnt[NFS_NPROCS];
256 int rpcretries;
257 int srvrpccnt[NFS_NPROCS];
258 int srvrpc_errs;
259 int srv_errs;
260 int rpcrequests;
261 int rpctimeouts;
262 int rpcunexpected;
263 int rpcinvalid;
264 int srvcache_inproghits;
265 int srvcache_idemdonehits;
266 int srvcache_nonidemdonehits;
267 int srvcache_misses;
268 int srvnqnfs_leases;
269 int srvnqnfs_maxleases;
270 int srvnqnfs_getleases;
271 int srvvop_writes;
272};
273#endif
274
275/*
276 * Flags for nfssvc() system call.
277 */
278#define NFSSVC_BIOD 0x002
279#define NFSSVC_NFSD 0x004
280#define NFSSVC_ADDSOCK 0x008
281#define NFSSVC_AUTHIN 0x010
282#define NFSSVC_GOTAUTH 0x040
283#define NFSSVC_AUTHINFAIL 0x080
284#define NFSSVC_MNTD 0x100
285
286/*
287 * fs.nfs sysctl(3) identifiers
288 */
289#define NFS_NFSSTATS 1 /* struct: struct nfsstats */
290#define NFS_NFSPRIVPORT 2 /* int: prohibit nfs to resvports */
291
292#define FS_NFS_NAMES { \
293 { 0, 0 }, \
294 { "nfsstats", CTLTYPE_STRUCT }, \
295 { "nfsprivport", CTLTYPE_INT }, \
296}
297
298/*
299 * Network address hash list element
300 */
301union nethostaddr {
302 u_long had_inetaddr;
303 struct sockaddr *had_nam;
304};
305
306#ifdef KERNEL
307
308#ifdef MALLOC_DECLARE
309MALLOC_DECLARE(M_NFSREQ);
310MALLOC_DECLARE(M_NFSMNT);
311MALLOC_DECLARE(M_NFSDIROFF);
312MALLOC_DECLARE(M_NFSRVDESC);
313MALLOC_DECLARE(M_NFSUID);
314MALLOC_DECLARE(M_NQLEASE);
315MALLOC_DECLARE(M_NFSD);
316MALLOC_DECLARE(M_NFSBIGFH);
317#endif
318
319struct uio; struct buf; struct vattr; struct nameidata; /* XXX */
320
321/*
322 * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
323 * What should be in this set is open to debate, but I believe that since
324 * I/O system calls on ufs are never interrupted by signals the set should
325 * be minimal. My reasoning is that many current programs that use signals
326 * such as SIGALRM will not expect file I/O system calls to be interrupted
327 * by them and break.
328 */
329#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
330 sigmask(SIGHUP)|sigmask(SIGQUIT))
331
332/*
333 * Socket errors ignored for connectionless sockets??
334 * For now, ignore them all
335 */
336#define NFSIGNORE_SOERROR(s, e) \
337 ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
338 ((s) & PR_CONNREQUIRED) == 0)
339
340/*
341 * Nfs outstanding request list element
342 */
343struct nfsreq {
344 TAILQ_ENTRY(nfsreq) r_chain;
345 struct mbuf *r_mreq;
346 struct mbuf *r_mrep;
347 struct mbuf *r_md;
348 caddr_t r_dpos;
349 struct nfsmount *r_nmp;
350 struct vnode *r_vp;
351 u_long r_xid;
352 int r_flags; /* flags on request, see below */
353 int r_retry; /* max retransmission count */
354 int r_rexmit; /* current retrans count */
355 int r_timer; /* tick counter on reply */
356 u_int32_t r_procnum; /* NFS procedure number */
357 int r_rtt; /* RTT for rpc */
358 struct proc *r_procp; /* Proc that did I/O system call */
359};
360
361/*
362 * Queue head for nfsreq's
363 */
364extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq;
365
366/* Flag values for r_flags */
367#define R_TIMING 0x01 /* timing request (in mntp) */
368#define R_SENT 0x02 /* request has been sent */
369#define R_SOFTTERM 0x04 /* soft mnt, too many retries */
370#define R_INTR 0x08 /* intr mnt, signal pending */
371#define R_SOCKERR 0x10 /* Fatal error on socket */
372#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */
373#define R_MUSTRESEND 0x40 /* Must resend request */
374#define R_GETONEREP 0x80 /* Probe for one reply only */
375
376/*
377 * A list of nfssvc_sock structures is maintained with all the sockets
378 * that require service by the nfsd.
379 * The nfsuid structs hang off of the nfssvc_sock structs in both lru
380 * and uid hash lists.
381 */
382#ifndef NFS_UIDHASHSIZ
383#define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */
384#endif
385#define NUIDHASH(sock, uid) \
386 (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ])
387#ifndef NFS_WDELAYHASHSIZ
388#define NFS_WDELAYHASHSIZ 16 /* and with this */
389#endif
390#define NWDELAYHASH(sock, f) \
391 (&(sock)->ns_wdelayhashtbl[(*((u_long *)(f))) % NFS_WDELAYHASHSIZ])
392#ifndef NFS_MUIDHASHSIZ
393#define NFS_MUIDHASHSIZ 63 /* Tune the size of nfsmount with this */
394#endif
395#define NMUIDHASH(nmp, uid) \
396 (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ])
397#define NFSNOHASH(fhsum) \
398 (&nfsnodehashtbl[(fhsum) & nfsnodehash])
399
400struct nfsuid {
401 TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */
402 LIST_ENTRY(nfsuid) nu_hash; /* Hash list */
403 int nu_flag; /* Flags */
404 union nethostaddr nu_haddr; /* Host addr. for dgram sockets */
405 struct ucred nu_cr; /* Cred uid mapped to */
406 int nu_expire; /* Expiry time (sec) */
407 struct timeval nu_timestamp; /* Kerb. timestamp */
408 u_long nu_nickname; /* Nickname on server */
409 NFSKERBKEY_T nu_key; /* and session key */
410};
411
412#define nu_inetaddr nu_haddr.had_inetaddr
413#define nu_nam nu_haddr.had_nam
414/* Bits for nu_flag */
415#define NU_INETADDR 0x1
416#define NU_NAM 0x2
417#define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO)
418
419struct nfsrv_rec {
420 STAILQ_ENTRY(nfsrv_rec) nr_link;
421 struct sockaddr *nr_address;
422 struct mbuf *nr_packet;
423};
424
425struct nfssvc_sock {
426 TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */
427 TAILQ_HEAD(, nfsuid) ns_uidlruhead;
428 struct file *ns_fp;
429 struct socket *ns_so;
430 struct sockaddr *ns_nam;
431 struct mbuf *ns_raw;
432 struct mbuf *ns_rawend;
433 STAILQ_HEAD(, nfsrv_rec) ns_rec;
434 struct mbuf *ns_frag;
435 int ns_flag;
436 int ns_solock;
437 int ns_cc;
438 int ns_reclen;
439 int ns_numuids;
440 u_long ns_sref;
441 LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */
442 LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ];
443 LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ];
444};
445
446/* Bits for "ns_flag" */
447#define SLP_VALID 0x01
448#define SLP_DOREC 0x02
449#define SLP_NEEDQ 0x04
450#define SLP_DISCONN 0x08
451#define SLP_GETSTREAM 0x10
452#define SLP_LASTFRAG 0x20
453#define SLP_ALLFLAGS 0xff
454
455extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead;
456extern int nfssvc_sockhead_flag;
457#define SLP_INIT 0x01
458#define SLP_WANTINIT 0x02
459
460/*
461 * One of these structures is allocated for each nfsd.
462 */
463struct nfsd {
464 TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */
465 int nfsd_flag; /* NFSD_ flags */
466 struct nfssvc_sock *nfsd_slp; /* Current socket */
467 int nfsd_authlen; /* Authenticator len */
468 u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */
469 int nfsd_verflen; /* and the Verifier */
470 u_char nfsd_verfstr[RPCVERF_MAXSIZ];
471 struct proc *nfsd_procp; /* Proc ptr */
472 struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */
473};
474
475/* Bits for "nfsd_flag" */
476#define NFSD_WAITING 0x01
477#define NFSD_REQINPROG 0x02
478#define NFSD_NEEDAUTH 0x04
479#define NFSD_AUTHFAIL 0x08
480
481/*
482 * This structure is used by the server for describing each request.
483 * Some fields are used only when write request gathering is performed.
484 */
485struct nfsrv_descript {
486 u_quad_t nd_time; /* Write deadline (usec) */
487 off_t nd_off; /* Start byte offset */
488 off_t nd_eoff; /* and end byte offset */
489 LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */
490 LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */
491 LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */
492 struct mbuf *nd_mrep; /* Request mbuf list */
493 struct mbuf *nd_md; /* Current dissect mbuf */
494 struct mbuf *nd_mreq; /* Reply mbuf list */
495 struct sockaddr *nd_nam; /* and socket addr */
496 struct sockaddr *nd_nam2; /* return socket addr */
497 caddr_t nd_dpos; /* Current dissect pos */
498 u_int32_t nd_procnum; /* RPC # */
499 int nd_stable; /* storage type */
500 int nd_flag; /* nd_flag */
501 int nd_len; /* Length of this write */
502 int nd_repstat; /* Reply status */
503 u_long nd_retxid; /* Reply xid */
504 u_long nd_duration; /* Lease duration */
505 struct timeval nd_starttime; /* Time RPC initiated */
506 fhandle_t nd_fh; /* File handle */
507 struct ucred nd_cr; /* Credentials */
508};
509
510/* Bits for "nd_flag" */
511#define ND_READ LEASE_READ
512#define ND_WRITE LEASE_WRITE
513#define ND_CHECK 0x04
514#define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK)
515#define ND_NFSV3 0x08
516#define ND_NQNFS 0x10
517#define ND_KERBNICK 0x20
518#define ND_KERBFULL 0x40
519#define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL)
520
521extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head;
522extern int nfsd_head_flag;
523#define NFSD_CHECKSLP 0x01
524
525/*
526 * These macros compare nfsrv_descript structures.
527 */
528#define NFSW_CONTIG(o, n) \
529 ((o)->nd_eoff >= (n)->nd_off && \
530 !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH))
531
532#define NFSW_SAMECRED(o, n) \
533 (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \
534 !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \
535 sizeof (struct ucred)))
536
537/*
538 * Defines for WebNFS
539 */
540
541#define WEBNFS_ESC_CHAR '%'
542#define WEBNFS_SPECCHAR_START 0x80
543
544#define WEBNFS_NATIVE_CHAR 0x80
545/*
546 * ..
547 * Possibly more here in the future.
548 */
549
550/*
551 * Macro for converting escape characters in WebNFS pathnames.
552 * Should really be in libkern.
553 */
554
555#define HEXTOC(c) \
556 ((c) >= 'a' ? ((c) - ('a' - 10)) : \
557 ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '0')))
558#define HEXSTRTOI(p) \
559 ((HEXTOC(p[0]) << 4) + HEXTOC(p[1]))
560
561#ifdef NFS_DEBUG
562
563extern int nfs_debug;
564#define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */
565#define NFS_DEBUG_WG 2 /* server write gathering */
566#define NFS_DEBUG_RC 4 /* server request caching */
567
568#define NFS_DPF(cat, args) \
569 do { \
570 if (nfs_debug & NFS_DEBUG_##cat) printf args; \
571 } while (0)
572
573#else
574
575#define NFS_DPF(cat, args)
576
577#endif
578
579u_quad_t nfs_curusec __P((void));
580int nfs_init __P((struct vfsconf *vfsp));
581int nfs_reply __P((struct nfsreq *));
582int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int));
583int nfs_send __P((struct socket *, struct sockaddr *, struct mbuf *,
584 struct nfsreq *));
585int nfs_rephead __P((int, struct nfsrv_descript *, struct nfssvc_sock *,
586 int, int, u_quad_t *, struct mbuf **, struct mbuf **,
587 caddr_t *));
583int nfs_sndlock __P((int *, struct nfsreq *));
584void nfs_sndunlock __P((int *flagp));
588int nfs_sndlock __P((int *, int *, struct nfsreq *));
589void nfs_sndunlock __P((int *, int *));
585int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
586int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *,
587 int));
588int nfs_readrpc __P((struct vnode *, struct uio *, struct ucred *));
589int nfs_writerpc __P((struct vnode *, struct uio *, struct ucred *, int *,
590 int *));
591int nfs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *));
592int nfs_asyncio __P((struct buf *, struct ucred *));
593int nfs_doio __P((struct buf *, struct ucred *, struct proc *));
594int nfs_readlinkrpc __P((struct vnode *, struct uio *, struct ucred *));
595int nfs_sigintr __P((struct nfsmount *, struct nfsreq *, struct proc *));
596int nfs_readdirplusrpc __P((struct vnode *, struct uio *, struct ucred *));
597int nfsm_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
598void nfsm_srvfattr __P((struct nfsrv_descript *, struct vattr *,
599 struct nfs_fattr *));
600void nfsm_srvwcc __P((struct nfsrv_descript *, int, struct vattr *, int,
601 struct vattr *, struct mbuf **, char **));
602void nfsm_srvpostopattr __P((struct nfsrv_descript *, int, struct vattr *,
603 struct mbuf **, char **));
604int netaddr_match __P((int, union nethostaddr *, struct sockaddr *));
605int nfs_request __P((struct vnode *, struct mbuf *, int, struct proc *,
606 struct ucred *, struct mbuf **, struct mbuf **,
607 caddr_t *));
608int nfs_loadattrcache __P((struct vnode **, struct mbuf **, caddr_t *,
609 struct vattr *));
610int nfs_namei __P((struct nameidata *, fhandle_t *, int,
611 struct nfssvc_sock *, struct sockaddr *, struct mbuf **,
612 caddr_t *, struct vnode **, struct proc *, int, int));
613void nfsm_adj __P((struct mbuf *, int, int));
614int nfsm_mbuftouio __P((struct mbuf **, struct uio *, int, caddr_t *));
615void nfsrv_initcache __P((void));
616int nfs_getauth __P((struct nfsmount *, struct nfsreq *, struct ucred *,
617 char **, int *, char *, int *, NFSKERBKEY_T));
618int nfs_getnickauth __P((struct nfsmount *, struct ucred *, char **,
619 int *, char *, int));
620int nfs_savenickauth __P((struct nfsmount *, struct ucred *, int,
621 NFSKERBKEY_T, struct mbuf **, char **,
622 struct mbuf *));
623int nfs_adv __P((struct mbuf **, caddr_t *, int, int));
624void nfs_nhinit __P((void));
625void nfs_timer __P((void*));
626u_long nfs_hash __P((nfsfh_t *, int));
627int nfsrv_dorec __P((struct nfssvc_sock *, struct nfsd *,
628 struct nfsrv_descript **));
629int nfsrv_getcache __P((struct nfsrv_descript *, struct nfssvc_sock *,
630 struct mbuf **));
631void nfsrv_updatecache __P((struct nfsrv_descript *, int, struct mbuf *));
632void nfsrv_cleancache __P((void));
633int nfs_connect __P((struct nfsmount *, struct nfsreq *));
634void nfs_disconnect __P((struct nfsmount *));
635int nfs_getattrcache __P((struct vnode *, struct vattr *));
636int nfsm_strtmbuf __P((struct mbuf **, char **, char *, long));
637int nfs_bioread __P((struct vnode *, struct uio *, int, struct ucred *,
638 int));
639int nfsm_uiotombuf __P((struct uio *, struct mbuf **, int, caddr_t *));
640void nfsrv_init __P((int));
641void nfs_clearcommit __P((struct mount *));
642int nfsrv_errmap __P((struct nfsrv_descript *, int));
643void nfsrvw_sort __P((gid_t *, int));
644void nfsrv_setcred __P((struct ucred *, struct ucred *));
645int nfs_writebp __P((struct buf *, int));
646int nfsrv_object_create __P((struct vnode *));
647void nfsrv_wakenfsd __P((struct nfssvc_sock *slp));
648int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *,
649 struct proc *, struct mbuf **));
650int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *,
651 struct proc *p));
652
653int nfsrv3_access __P((struct nfsrv_descript *nfsd,
654 struct nfssvc_sock *slp,
655 struct proc *procp, struct mbuf **mrq));
656int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
657 struct proc *procp, struct mbuf **mrq));
658int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
659 struct proc *procp, struct mbuf **mrq));
660int nfsrv_fhtovp __P((fhandle_t *, int, struct vnode **, struct ucred *,
661 struct nfssvc_sock *, struct sockaddr *, int *,
662 int, int));
663int nfsrv_setpublicfs __P((struct mount *, struct netexport *,
664 struct export_args *));
665int nfs_ispublicfh __P((fhandle_t *));
666int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
667 struct proc *procp, struct mbuf **mrq));
668int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
669 struct proc *procp, struct mbuf **mrq));
670int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
671 struct proc *procp, struct mbuf **mrq));
672int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
673 struct proc *procp, struct mbuf **mrq));
674int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
675 struct proc *procp, struct mbuf **mrq));
676int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
677 struct proc *procp, struct mbuf **mrq));
678int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
679 struct proc *procp, struct mbuf **mrq));
680int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
681 struct proc *procp, struct mbuf **mrq));
682int nfsrv_pathconf __P((struct nfsrv_descript *nfsd,
683 struct nfssvc_sock *slp, struct proc *procp,
684 struct mbuf **mrq));
685int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
686 struct proc *procp, struct mbuf **mrq));
687int nfsrv_readdir __P((struct nfsrv_descript *nfsd,
688 struct nfssvc_sock *slp,
689 struct proc *procp, struct mbuf **mrq));
690int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd,
691 struct nfssvc_sock *slp, struct proc *procp,
692 struct mbuf **mrq));
693int nfsrv_readlink __P((struct nfsrv_descript *nfsd,
694 struct nfssvc_sock *slp, struct proc *procp,
695 struct mbuf **mrq));
696int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
697 struct proc *procp, struct mbuf **mrq));
698int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
699 struct proc *procp, struct mbuf **mrq));
700int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
701 struct proc *procp, struct mbuf **mrq));
702int nfsrv_setattr __P((struct nfsrv_descript *nfsd,
703 struct nfssvc_sock *slp,
704 struct proc *procp, struct mbuf **mrq));
705int nfsrv_statfs __P((struct nfsrv_descript *nfsd,
706 struct nfssvc_sock *slp,
707 struct proc *procp, struct mbuf **mrq));
708int nfsrv_symlink __P((struct nfsrv_descript *nfsd,
709 struct nfssvc_sock *slp,
710 struct proc *procp, struct mbuf **mrq));
711int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
712 struct proc *procp, struct mbuf **mrq));
713void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag));
714void nfsrv_slpderef __P((struct nfssvc_sock *slp));
715#endif /* KERNEL */
716
717#endif
590int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
591int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *,
592 int));
593int nfs_readrpc __P((struct vnode *, struct uio *, struct ucred *));
594int nfs_writerpc __P((struct vnode *, struct uio *, struct ucred *, int *,
595 int *));
596int nfs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *));
597int nfs_asyncio __P((struct buf *, struct ucred *));
598int nfs_doio __P((struct buf *, struct ucred *, struct proc *));
599int nfs_readlinkrpc __P((struct vnode *, struct uio *, struct ucred *));
600int nfs_sigintr __P((struct nfsmount *, struct nfsreq *, struct proc *));
601int nfs_readdirplusrpc __P((struct vnode *, struct uio *, struct ucred *));
602int nfsm_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
603void nfsm_srvfattr __P((struct nfsrv_descript *, struct vattr *,
604 struct nfs_fattr *));
605void nfsm_srvwcc __P((struct nfsrv_descript *, int, struct vattr *, int,
606 struct vattr *, struct mbuf **, char **));
607void nfsm_srvpostopattr __P((struct nfsrv_descript *, int, struct vattr *,
608 struct mbuf **, char **));
609int netaddr_match __P((int, union nethostaddr *, struct sockaddr *));
610int nfs_request __P((struct vnode *, struct mbuf *, int, struct proc *,
611 struct ucred *, struct mbuf **, struct mbuf **,
612 caddr_t *));
613int nfs_loadattrcache __P((struct vnode **, struct mbuf **, caddr_t *,
614 struct vattr *));
615int nfs_namei __P((struct nameidata *, fhandle_t *, int,
616 struct nfssvc_sock *, struct sockaddr *, struct mbuf **,
617 caddr_t *, struct vnode **, struct proc *, int, int));
618void nfsm_adj __P((struct mbuf *, int, int));
619int nfsm_mbuftouio __P((struct mbuf **, struct uio *, int, caddr_t *));
620void nfsrv_initcache __P((void));
621int nfs_getauth __P((struct nfsmount *, struct nfsreq *, struct ucred *,
622 char **, int *, char *, int *, NFSKERBKEY_T));
623int nfs_getnickauth __P((struct nfsmount *, struct ucred *, char **,
624 int *, char *, int));
625int nfs_savenickauth __P((struct nfsmount *, struct ucred *, int,
626 NFSKERBKEY_T, struct mbuf **, char **,
627 struct mbuf *));
628int nfs_adv __P((struct mbuf **, caddr_t *, int, int));
629void nfs_nhinit __P((void));
630void nfs_timer __P((void*));
631u_long nfs_hash __P((nfsfh_t *, int));
632int nfsrv_dorec __P((struct nfssvc_sock *, struct nfsd *,
633 struct nfsrv_descript **));
634int nfsrv_getcache __P((struct nfsrv_descript *, struct nfssvc_sock *,
635 struct mbuf **));
636void nfsrv_updatecache __P((struct nfsrv_descript *, int, struct mbuf *));
637void nfsrv_cleancache __P((void));
638int nfs_connect __P((struct nfsmount *, struct nfsreq *));
639void nfs_disconnect __P((struct nfsmount *));
640int nfs_getattrcache __P((struct vnode *, struct vattr *));
641int nfsm_strtmbuf __P((struct mbuf **, char **, char *, long));
642int nfs_bioread __P((struct vnode *, struct uio *, int, struct ucred *,
643 int));
644int nfsm_uiotombuf __P((struct uio *, struct mbuf **, int, caddr_t *));
645void nfsrv_init __P((int));
646void nfs_clearcommit __P((struct mount *));
647int nfsrv_errmap __P((struct nfsrv_descript *, int));
648void nfsrvw_sort __P((gid_t *, int));
649void nfsrv_setcred __P((struct ucred *, struct ucred *));
650int nfs_writebp __P((struct buf *, int));
651int nfsrv_object_create __P((struct vnode *));
652void nfsrv_wakenfsd __P((struct nfssvc_sock *slp));
653int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *,
654 struct proc *, struct mbuf **));
655int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *,
656 struct proc *p));
657
658int nfsrv3_access __P((struct nfsrv_descript *nfsd,
659 struct nfssvc_sock *slp,
660 struct proc *procp, struct mbuf **mrq));
661int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
662 struct proc *procp, struct mbuf **mrq));
663int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
664 struct proc *procp, struct mbuf **mrq));
665int nfsrv_fhtovp __P((fhandle_t *, int, struct vnode **, struct ucred *,
666 struct nfssvc_sock *, struct sockaddr *, int *,
667 int, int));
668int nfsrv_setpublicfs __P((struct mount *, struct netexport *,
669 struct export_args *));
670int nfs_ispublicfh __P((fhandle_t *));
671int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
672 struct proc *procp, struct mbuf **mrq));
673int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
674 struct proc *procp, struct mbuf **mrq));
675int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
676 struct proc *procp, struct mbuf **mrq));
677int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
678 struct proc *procp, struct mbuf **mrq));
679int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
680 struct proc *procp, struct mbuf **mrq));
681int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
682 struct proc *procp, struct mbuf **mrq));
683int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
684 struct proc *procp, struct mbuf **mrq));
685int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
686 struct proc *procp, struct mbuf **mrq));
687int nfsrv_pathconf __P((struct nfsrv_descript *nfsd,
688 struct nfssvc_sock *slp, struct proc *procp,
689 struct mbuf **mrq));
690int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
691 struct proc *procp, struct mbuf **mrq));
692int nfsrv_readdir __P((struct nfsrv_descript *nfsd,
693 struct nfssvc_sock *slp,
694 struct proc *procp, struct mbuf **mrq));
695int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd,
696 struct nfssvc_sock *slp, struct proc *procp,
697 struct mbuf **mrq));
698int nfsrv_readlink __P((struct nfsrv_descript *nfsd,
699 struct nfssvc_sock *slp, struct proc *procp,
700 struct mbuf **mrq));
701int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
702 struct proc *procp, struct mbuf **mrq));
703int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
704 struct proc *procp, struct mbuf **mrq));
705int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
706 struct proc *procp, struct mbuf **mrq));
707int nfsrv_setattr __P((struct nfsrv_descript *nfsd,
708 struct nfssvc_sock *slp,
709 struct proc *procp, struct mbuf **mrq));
710int nfsrv_statfs __P((struct nfsrv_descript *nfsd,
711 struct nfssvc_sock *slp,
712 struct proc *procp, struct mbuf **mrq));
713int nfsrv_symlink __P((struct nfsrv_descript *nfsd,
714 struct nfssvc_sock *slp,
715 struct proc *procp, struct mbuf **mrq));
716int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
717 struct proc *procp, struct mbuf **mrq));
718void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag));
719void nfsrv_slpderef __P((struct nfssvc_sock *slp));
720#endif /* KERNEL */
721
722#endif