xref: /netbsd-src/sys/fs/nfs/common/nfs.h (revision 0342d5080b4aa2e64ad6d1da61f9e3e072466754)
1*0342d508Spgoyette /*	$NetBSD: nfs.h,v 1.2 2016/12/13 22:52:46 pgoyette Exp $	*/
26ca35587Sdholland /*-
36ca35587Sdholland  * Copyright (c) 1989, 1993
46ca35587Sdholland  *	The Regents of the University of California.  All rights reserved.
56ca35587Sdholland  *
66ca35587Sdholland  * This code is derived from software contributed to Berkeley by
76ca35587Sdholland  * Rick Macklem at The University of Guelph.
86ca35587Sdholland  *
96ca35587Sdholland  * Redistribution and use in source and binary forms, with or without
106ca35587Sdholland  * modification, are permitted provided that the following conditions
116ca35587Sdholland  * are met:
126ca35587Sdholland  * 1. Redistributions of source code must retain the above copyright
136ca35587Sdholland  *    notice, this list of conditions and the following disclaimer.
146ca35587Sdholland  * 2. Redistributions in binary form must reproduce the above copyright
156ca35587Sdholland  *    notice, this list of conditions and the following disclaimer in the
166ca35587Sdholland  *    documentation and/or other materials provided with the distribution.
176ca35587Sdholland  * 4. Neither the name of the University nor the names of its contributors
186ca35587Sdholland  *    may be used to endorse or promote products derived from this software
196ca35587Sdholland  *    without specific prior written permission.
206ca35587Sdholland  *
216ca35587Sdholland  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
226ca35587Sdholland  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
236ca35587Sdholland  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
246ca35587Sdholland  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
256ca35587Sdholland  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
266ca35587Sdholland  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
276ca35587Sdholland  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
286ca35587Sdholland  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
296ca35587Sdholland  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
306ca35587Sdholland  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
316ca35587Sdholland  * SUCH DAMAGE.
326ca35587Sdholland  *
33e81f0ea2Spgoyette  * FreeBSD: head/sys/fs/nfs/nfs.h 291527 2015-11-30 21:54:27Z rmacklem
34*0342d508Spgoyette  * $NetBSD: nfs.h,v 1.2 2016/12/13 22:52:46 pgoyette Exp $
356ca35587Sdholland  */
366ca35587Sdholland 
376ca35587Sdholland #ifndef _NFS_NFS_H_
386ca35587Sdholland #define	_NFS_NFS_H_
396ca35587Sdholland /*
406ca35587Sdholland  * Tunable constants for nfs
416ca35587Sdholland  */
426ca35587Sdholland 
436ca35587Sdholland #define	NFS_MAXIOVEC	34
446ca35587Sdholland #define	NFS_TICKINTVL	500		/* Desired time for a tick (msec) */
456ca35587Sdholland #define	NFS_HZ		(hz / nfscl_ticks) /* Ticks/sec */
466ca35587Sdholland #define	NFS_TIMEO	(1 * NFS_HZ)	/* Default timeout = 1 second */
476ca35587Sdholland #define	NFS_MINTIMEO	(1 * NFS_HZ)	/* Min timeout to use */
486ca35587Sdholland #define	NFS_MAXTIMEO	(60 * NFS_HZ)	/* Max timeout to backoff to */
496ca35587Sdholland #define	NFS_TCPTIMEO	300		/* TCP timeout */
506ca35587Sdholland #define	NFS_MAXRCVTIMEO	60		/* 1 minute in seconds */
516ca35587Sdholland #define	NFS_MINIDEMTIMEO (5 * NFS_HZ)	/* Min timeout for non-idempotent ops*/
526ca35587Sdholland #define	NFS_MAXREXMIT	100		/* Stop counting after this many */
536ca35587Sdholland #define	NFSV4_CALLBACKTIMEO (2 * NFS_HZ) /* Timeout in ticks */
546ca35587Sdholland #define	NFSV4_CALLBACKRETRY 5		/* Number of retries before failure */
55e81f0ea2Spgoyette #define	NFSV4_SLOTS	64		/* Number of slots, fore channel */
56e81f0ea2Spgoyette #define	NFSV4_CBSLOTS	8		/* Number of slots, back channel */
576ca35587Sdholland #define	NFSV4_CBRETRYCNT 4		/* # of CBRecall retries upon err */
586ca35587Sdholland #define	NFSV4_UPCALLTIMEO (15 * NFS_HZ)	/* Timeout in ticks for upcalls */
596ca35587Sdholland 					/* to gssd or nfsuserd */
606ca35587Sdholland #define	NFSV4_UPCALLRETRY 4		/* Number of retries before failure */
616ca35587Sdholland #define	NFS_MAXWINDOW	1024		/* Max number of outstanding requests */
626ca35587Sdholland #define	NFS_RETRANS	10		/* Num of retrans for soft mounts */
636ca35587Sdholland #define	NFS_RETRANS_TCP	2		/* Num of retrans for TCP soft mounts */
646ca35587Sdholland #define	NFS_MAXGRPS	16		/* Max. size of groups list */
656ca35587Sdholland #define	NFS_TRYLATERDEL	15		/* Maximum delay timeout (sec) */
666ca35587Sdholland #ifndef NFS_REMOVETIMEO
676ca35587Sdholland #define	NFS_REMOVETIMEO 15  /* # sec to wait for delegret in local syscall */
686ca35587Sdholland #endif
696ca35587Sdholland #ifndef NFS_MINATTRTIMO
706ca35587Sdholland #define	NFS_MINATTRTIMO 5		/* Attribute cache timeout in sec */
716ca35587Sdholland #endif
726ca35587Sdholland #ifndef NFS_MAXATTRTIMO
736ca35587Sdholland #define	NFS_MAXATTRTIMO 60
746ca35587Sdholland #endif
75*0342d508Spgoyette #if 0	/* Defined in NetBSD in machine/param.h */
766ca35587Sdholland #define	NFS_WSIZE	8192		/* Def. write data size <= 8192 */
776ca35587Sdholland #define	NFS_RSIZE	8192		/* Def. read data size <= 8192 */
78*0342d508Spgoyette #endif
796ca35587Sdholland #define	NFS_READDIRSIZE	8192		/* Def. readdir size */
806ca35587Sdholland #define	NFS_DEFRAHEAD	1		/* Def. read ahead # blocks */
816ca35587Sdholland #define	NFS_MAXRAHEAD	16		/* Max. read ahead # blocks */
826ca35587Sdholland #define	NFS_MAXASYNCDAEMON 	64	/* Max. number async_daemons runnable */
836ca35587Sdholland #define	NFS_MAXUIDHASH	64		/* Max. # of hashed uid entries/mp */
846ca35587Sdholland #ifndef	NFSRV_LEASE
856ca35587Sdholland #define	NFSRV_LEASE		120	/* Lease time in seconds for V4 */
866ca35587Sdholland #endif					/* assigned to nfsrv_lease */
876ca35587Sdholland #ifndef NFSRV_STALELEASE
886ca35587Sdholland #define	NFSRV_STALELEASE	(5 * nfsrv_lease)
896ca35587Sdholland #endif
906ca35587Sdholland #ifndef NFSRV_MOULDYLEASE
916ca35587Sdholland #define	NFSRV_MOULDYLEASE	604800	/* One week (in sec) */
926ca35587Sdholland #endif
936ca35587Sdholland #ifndef NFSCLIENTHASHSIZE
946ca35587Sdholland #define	NFSCLIENTHASHSIZE	20	/* Size of server client hash table */
956ca35587Sdholland #endif
966ca35587Sdholland #ifndef NFSLOCKHASHSIZE
976ca35587Sdholland #define	NFSLOCKHASHSIZE		20	/* Size of server nfslock hash table */
986ca35587Sdholland #endif
99e81f0ea2Spgoyette #ifndef NFSSESSIONHASHSIZE
100e81f0ea2Spgoyette #define	NFSSESSIONHASHSIZE	20	/* Size of server session hash table */
101e81f0ea2Spgoyette #endif
1026ca35587Sdholland #define	NFSSTATEHASHSIZE	10	/* Size of server stateid hash table */
1036ca35587Sdholland #ifndef	NFSCLDELEGHIGHWATER
1046ca35587Sdholland #define	NFSCLDELEGHIGHWATER	10000	/* limit for client delegations */
1056ca35587Sdholland #endif
1066ca35587Sdholland #ifndef	NFSCLLAYOUTHIGHWATER
1076ca35587Sdholland #define	NFSCLLAYOUTHIGHWATER	10000	/* limit for client pNFS layouts */
1086ca35587Sdholland #endif
1096ca35587Sdholland #ifndef NFSNOOPEN			/* Inactive open owner (sec) */
1106ca35587Sdholland #define	NFSNOOPEN		120
1116ca35587Sdholland #endif
1126ca35587Sdholland #define	NFSRV_LEASEDELTA	15	/* # of seconds to delay beyond lease */
1136ca35587Sdholland #define	NFS_IDMAXSIZE		4	/* max sizeof (in_addr_t) */
1146ca35587Sdholland #ifndef NFSRVCACHE_UDPTIMEOUT
1156ca35587Sdholland #define	NFSRVCACHE_UDPTIMEOUT	30	/* # of sec to hold cached rpcs(udp) */
1166ca35587Sdholland #endif
1176ca35587Sdholland #ifndef NFSRVCACHE_UDPHIGHWATER
1186ca35587Sdholland #define	NFSRVCACHE_UDPHIGHWATER	500	/* Max # of udp cache entries */
1196ca35587Sdholland #endif
1206ca35587Sdholland #ifndef NFSRVCACHE_TCPTIMEOUT
1216ca35587Sdholland #define	NFSRVCACHE_TCPTIMEOUT	(3600*12) /*#of sec to hold cached rpcs(tcp) */
1226ca35587Sdholland #endif
1236ca35587Sdholland #ifndef	NFSRVCACHE_FLOODLEVEL
1246ca35587Sdholland #define	NFSRVCACHE_FLOODLEVEL	16384	/* Very high water mark for cache */
1256ca35587Sdholland #endif
1266ca35587Sdholland #ifndef	NFSRV_CLIENTHIGHWATER
1276ca35587Sdholland #define	NFSRV_CLIENTHIGHWATER	1000
1286ca35587Sdholland #endif
1296ca35587Sdholland #ifndef	NFSRV_MAXDUMPLIST
1306ca35587Sdholland #define	NFSRV_MAXDUMPLIST	10000
1316ca35587Sdholland #endif
1326ca35587Sdholland #ifndef NFS_ACCESSCACHESIZE
1336ca35587Sdholland #define	NFS_ACCESSCACHESIZE	8
1346ca35587Sdholland #endif
1356ca35587Sdholland #define	NFSV4_CBPORT	7745		/* Callback port for testing */
1366ca35587Sdholland 
1376ca35587Sdholland /*
1386ca35587Sdholland  * This macro defines the high water mark for issuing V4 delegations.
139e81f0ea2Spgoyette  * (It is currently set at a conservative 20% of nfsrv_v4statelimit. This
1406ca35587Sdholland  *  may want to increase when clients can make more effective use of
1416ca35587Sdholland  *  delegations.)
1426ca35587Sdholland  */
143e81f0ea2Spgoyette #define	NFSRV_V4DELEGLIMIT(c) (((c) * 5) > nfsrv_v4statelimit)
1446ca35587Sdholland 
1456ca35587Sdholland #define	NFS_READDIRBLKSIZ	DIRBLKSIZ	/* Minimal nm_readdirsize */
1466ca35587Sdholland 
1476ca35587Sdholland /*
1486ca35587Sdholland  * Oddballs
1496ca35587Sdholland  */
1506ca35587Sdholland #define	NFS_CMPFH(n, f, s) 						\
151*0342d508Spgoyette     ((n)->n_fhp->nfh_len == (s) && !NFSBCMP((n)->n_fhp->nfh_fh, (void *)(f), (s)))
1526ca35587Sdholland #define	NFSRV_CMPFH(nf, ns, f, s) 					\
153*0342d508Spgoyette 	((ns) == (s) && !NFSBCMP((void *)(nf), (void *)(f), (s)))
1546ca35587Sdholland #define	NFS_CMPTIME(t1, t2) 						\
1556ca35587Sdholland 	((t1).tv_sec == (t2).tv_sec && (t1).tv_nsec == (t2).tv_nsec)
1566ca35587Sdholland #define	NFS_SETTIME(t) do { 						\
1576ca35587Sdholland 	(t).tv_sec = time.tv_sec; (t).tv_nsec = 1000 * time.tv_usec; } while (0)
1586ca35587Sdholland #define	NFS_SRVMAXDATA(n) 						\
1596ca35587Sdholland 		(((n)->nd_flag & (ND_NFSV3 | ND_NFSV4)) ? 		\
160e81f0ea2Spgoyette 		 NFS_SRVMAXIO : NFS_V2MAXDATA)
1616ca35587Sdholland #define	NFS64BITSSET	0xffffffffffffffffull
1626ca35587Sdholland #define	NFS64BITSMINUS1	0xfffffffffffffffeull
1636ca35587Sdholland 
1646ca35587Sdholland /*
1656ca35587Sdholland  * Structures for the nfssvc(2) syscall. Not that anyone but nfsd, mount_nfs
1666ca35587Sdholland  * and nfsloaduser should ever try and use it.
1676ca35587Sdholland  */
1686ca35587Sdholland struct nfsd_addsock_args {
1696ca35587Sdholland 	int	sock;		/* Socket to serve */
170*0342d508Spgoyette 	char	*name;		/* Client addr for connection based sockets */
1716ca35587Sdholland 	int	namelen;	/* Length of name */
1726ca35587Sdholland };
1736ca35587Sdholland 
1746ca35587Sdholland /*
1756ca35587Sdholland  * nfsd argument for new krpc.
1766ca35587Sdholland  */
1776ca35587Sdholland struct nfsd_nfsd_args {
1786ca35587Sdholland 	const char *principal;	/* GSS-API service principal name */
1796ca35587Sdholland 	int	minthreads;	/* minimum service thread count */
1806ca35587Sdholland 	int	maxthreads;	/* maximum service thread count */
1816ca35587Sdholland };
1826ca35587Sdholland 
1836ca35587Sdholland /*
1846ca35587Sdholland  * Arguments for use by the callback daemon.
1856ca35587Sdholland  */
1866ca35587Sdholland struct nfsd_nfscbd_args {
1876ca35587Sdholland 	const char *principal;	/* GSS-API service principal name */
1886ca35587Sdholland };
1896ca35587Sdholland 
1906ca35587Sdholland struct nfscbd_args {
1916ca35587Sdholland 	int	sock;		/* Socket to serve */
192*0342d508Spgoyette 	char	*name;		/* Client addr for connection based sockets */
1936ca35587Sdholland 	int	namelen;	/* Length of name */
1946ca35587Sdholland 	u_short	port;		/* Port# for callbacks */
1956ca35587Sdholland };
1966ca35587Sdholland 
1976ca35587Sdholland struct nfsd_idargs {
1986ca35587Sdholland 	int		nid_flag;	/* Flags (see below) */
1996ca35587Sdholland 	uid_t		nid_uid;	/* user/group id */
2006ca35587Sdholland 	gid_t		nid_gid;
2016ca35587Sdholland 	int		nid_usermax;	/* Upper bound on user name cache */
2026ca35587Sdholland 	int		nid_usertimeout;/* User name timeout (minutes) */
2036ca35587Sdholland 	u_char		*nid_name;	/* Name */
2046ca35587Sdholland 	int		nid_namelen;	/* and its length */
205e81f0ea2Spgoyette 	gid_t		*nid_grps;	/* and the list */
206e81f0ea2Spgoyette 	int		nid_ngroup;	/* Size of groups list */
207e81f0ea2Spgoyette };
208e81f0ea2Spgoyette 
209e81f0ea2Spgoyette struct nfsd_oidargs {
210e81f0ea2Spgoyette 	int		nid_flag;	/* Flags (see below) */
211e81f0ea2Spgoyette 	uid_t		nid_uid;	/* user/group id */
212e81f0ea2Spgoyette 	gid_t		nid_gid;
213e81f0ea2Spgoyette 	int		nid_usermax;	/* Upper bound on user name cache */
214e81f0ea2Spgoyette 	int		nid_usertimeout;/* User name timeout (minutes) */
215e81f0ea2Spgoyette 	u_char		*nid_name;	/* Name */
216e81f0ea2Spgoyette 	int		nid_namelen;	/* and its length */
2176ca35587Sdholland };
2186ca35587Sdholland 
2196ca35587Sdholland struct nfsd_clid {
2206ca35587Sdholland 	int		nclid_idlen;	/* Length of client id */
2216ca35587Sdholland 	u_char		nclid_id[NFSV4_OPAQUELIMIT]; /* and name */
2226ca35587Sdholland };
2236ca35587Sdholland 
2246ca35587Sdholland struct nfsd_dumplist {
2256ca35587Sdholland 	int		ndl_size;	/* Number of elements */
2266ca35587Sdholland 	void		*ndl_list;	/* and the list of elements */
2276ca35587Sdholland };
2286ca35587Sdholland 
2296ca35587Sdholland struct nfsd_dumpclients {
2306ca35587Sdholland 	u_int32_t	ndcl_flags;		/* LCL_xxx flags */
2316ca35587Sdholland 	u_int32_t	ndcl_nopenowners;	/* Number of openowners */
2326ca35587Sdholland 	u_int32_t	ndcl_nopens;		/* and opens */
2336ca35587Sdholland 	u_int32_t	ndcl_nlockowners;	/* and of lockowners */
2346ca35587Sdholland 	u_int32_t	ndcl_nlocks;		/* and of locks */
2356ca35587Sdholland 	u_int32_t	ndcl_ndelegs;		/* and of delegations */
2366ca35587Sdholland 	u_int32_t	ndcl_nolddelegs;	/* and old delegations */
2376ca35587Sdholland 	sa_family_t	ndcl_addrfam;		/* Callback address */
2386ca35587Sdholland 	union {
2396ca35587Sdholland 		struct in_addr sin_addr;
2406ca35587Sdholland 		struct in6_addr sin6_addr;
2416ca35587Sdholland 	} ndcl_cbaddr;
2426ca35587Sdholland 	struct nfsd_clid ndcl_clid;	/* and client id */
2436ca35587Sdholland };
2446ca35587Sdholland 
2456ca35587Sdholland struct nfsd_dumplocklist {
2466ca35587Sdholland 	char		*ndllck_fname;	/* File Name */
2476ca35587Sdholland 	int		ndllck_size;	/* Number of elements */
2486ca35587Sdholland 	void		*ndllck_list;	/* and the list of elements */
2496ca35587Sdholland };
2506ca35587Sdholland 
2516ca35587Sdholland struct nfsd_dumplocks {
2526ca35587Sdholland 	u_int32_t	ndlck_flags;		/* state flags NFSLCK_xxx */
2536ca35587Sdholland 	nfsv4stateid_t	ndlck_stateid;		/* stateid */
2546ca35587Sdholland 	u_int64_t	ndlck_first;		/* lock byte range */
2556ca35587Sdholland 	u_int64_t	ndlck_end;
2566ca35587Sdholland 	struct nfsd_clid ndlck_owner;		/* Owner of open/lock */
2576ca35587Sdholland 	sa_family_t	ndlck_addrfam;		/* Callback address */
2586ca35587Sdholland 	union {
2596ca35587Sdholland 		struct in_addr sin_addr;
2606ca35587Sdholland 		struct in6_addr sin6_addr;
2616ca35587Sdholland 	} ndlck_cbaddr;
2626ca35587Sdholland 	struct nfsd_clid ndlck_clid;	/* and client id */
2636ca35587Sdholland };
2646ca35587Sdholland 
2656ca35587Sdholland /*
2666ca35587Sdholland  * Structure for referral information.
2676ca35587Sdholland  */
2686ca35587Sdholland struct nfsreferral {
2696ca35587Sdholland 	u_char		*nfr_srvlist;	/* List of servers */
2706ca35587Sdholland 	int		nfr_srvcnt;	/* number of servers */
2716ca35587Sdholland 	vnode_t		nfr_vp;	/* vnode for referral */
2726ca35587Sdholland 	u_int32_t	nfr_dfileno;	/* assigned dir inode# */
2736ca35587Sdholland };
2746ca35587Sdholland 
2756ca35587Sdholland /*
2766ca35587Sdholland  * Flags for lc_flags and opsflags for nfsrv_getclient().
2776ca35587Sdholland  */
2786ca35587Sdholland #define	LCL_NEEDSCONFIRM	0x00000001
2796ca35587Sdholland #define	LCL_DONTCLEAN		0x00000002
2806ca35587Sdholland #define	LCL_WAKEUPWANTED	0x00000004
2816ca35587Sdholland #define	LCL_TCPCALLBACK		0x00000008
2826ca35587Sdholland #define	LCL_CALLBACKSON		0x00000010
2836ca35587Sdholland #define	LCL_INDEXNOTOK		0x00000020
2846ca35587Sdholland #define	LCL_STAMPEDSTABLE	0x00000040
2856ca35587Sdholland #define	LCL_EXPIREIT		0x00000080
2866ca35587Sdholland #define	LCL_CBDOWN		0x00000100
2876ca35587Sdholland #define	LCL_KERBV		0x00000400
2886ca35587Sdholland #define	LCL_NAME		0x00000800
2896ca35587Sdholland #define	LCL_NEEDSCBNULL		0x00001000
2906ca35587Sdholland #define	LCL_GSSINTEGRITY	0x00002000
2916ca35587Sdholland #define	LCL_GSSPRIVACY		0x00004000
2926ca35587Sdholland #define	LCL_ADMINREVOKED	0x00008000
293e81f0ea2Spgoyette #define	LCL_RECLAIMCOMPLETE	0x00010000
294e81f0ea2Spgoyette #define	LCL_NFSV41		0x00020000
2956ca35587Sdholland 
2966ca35587Sdholland #define	LCL_GSS		LCL_KERBV	/* Or of all mechs */
2976ca35587Sdholland 
2986ca35587Sdholland /*
2996ca35587Sdholland  * Bits for flags in nfslock and nfsstate.
3006ca35587Sdholland  * The access, deny, NFSLCK_READ and NFSLCK_WRITE bits must be defined as
3016ca35587Sdholland  * below, in the correct order, so the shifts work for tests.
3026ca35587Sdholland  */
3036ca35587Sdholland #define	NFSLCK_READACCESS	0x00000001
3046ca35587Sdholland #define	NFSLCK_WRITEACCESS	0x00000002
3056ca35587Sdholland #define	NFSLCK_ACCESSBITS	(NFSLCK_READACCESS | NFSLCK_WRITEACCESS)
3066ca35587Sdholland #define	NFSLCK_SHIFT		2
3076ca35587Sdholland #define	NFSLCK_READDENY		0x00000004
3086ca35587Sdholland #define	NFSLCK_WRITEDENY	0x00000008
3096ca35587Sdholland #define	NFSLCK_DENYBITS		(NFSLCK_READDENY | NFSLCK_WRITEDENY)
3106ca35587Sdholland #define	NFSLCK_SHAREBITS 						\
3116ca35587Sdholland     (NFSLCK_READACCESS|NFSLCK_WRITEACCESS|NFSLCK_READDENY|NFSLCK_WRITEDENY)
3126ca35587Sdholland #define	NFSLCK_LOCKSHIFT	4
3136ca35587Sdholland #define	NFSLCK_READ		0x00000010
3146ca35587Sdholland #define	NFSLCK_WRITE		0x00000020
3156ca35587Sdholland #define	NFSLCK_BLOCKING		0x00000040
3166ca35587Sdholland #define	NFSLCK_RECLAIM		0x00000080
3176ca35587Sdholland #define	NFSLCK_OPENTOLOCK	0x00000100
3186ca35587Sdholland #define	NFSLCK_TEST		0x00000200
3196ca35587Sdholland #define	NFSLCK_LOCK		0x00000400
3206ca35587Sdholland #define	NFSLCK_UNLOCK		0x00000800
3216ca35587Sdholland #define	NFSLCK_OPEN		0x00001000
3226ca35587Sdholland #define	NFSLCK_CLOSE		0x00002000
3236ca35587Sdholland #define	NFSLCK_CHECK		0x00004000
3246ca35587Sdholland #define	NFSLCK_RELEASE		0x00008000
3256ca35587Sdholland #define	NFSLCK_NEEDSCONFIRM	0x00010000
3266ca35587Sdholland #define	NFSLCK_CONFIRM		0x00020000
3276ca35587Sdholland #define	NFSLCK_DOWNGRADE	0x00040000
3286ca35587Sdholland #define	NFSLCK_DELEGREAD	0x00080000
3296ca35587Sdholland #define	NFSLCK_DELEGWRITE	0x00100000
3306ca35587Sdholland #define	NFSLCK_DELEGCUR		0x00200000
3316ca35587Sdholland #define	NFSLCK_DELEGPREV	0x00400000
3326ca35587Sdholland #define	NFSLCK_OLDDELEG		0x00800000
3336ca35587Sdholland #define	NFSLCK_DELEGRECALL	0x01000000
3346ca35587Sdholland #define	NFSLCK_SETATTR		0x02000000
3356ca35587Sdholland #define	NFSLCK_DELEGPURGE	0x04000000
3366ca35587Sdholland #define	NFSLCK_DELEGRETURN	0x08000000
337e81f0ea2Spgoyette #define	NFSLCK_WANTWDELEG	0x10000000
338e81f0ea2Spgoyette #define	NFSLCK_WANTRDELEG	0x20000000
339e81f0ea2Spgoyette #define	NFSLCK_WANTNODELEG	0x40000000
340e81f0ea2Spgoyette #define	NFSLCK_WANTBITS							\
341e81f0ea2Spgoyette     (NFSLCK_WANTWDELEG | NFSLCK_WANTRDELEG | NFSLCK_WANTNODELEG)
3426ca35587Sdholland 
3436ca35587Sdholland /* And bits for nid_flag */
3446ca35587Sdholland #define	NFSID_INITIALIZE	0x0001
3456ca35587Sdholland #define	NFSID_ADDUID		0x0002
3466ca35587Sdholland #define	NFSID_DELUID		0x0004
3476ca35587Sdholland #define	NFSID_ADDUSERNAME	0x0008
3486ca35587Sdholland #define	NFSID_DELUSERNAME	0x0010
3496ca35587Sdholland #define	NFSID_ADDGID		0x0020
3506ca35587Sdholland #define	NFSID_DELGID		0x0040
3516ca35587Sdholland #define	NFSID_ADDGROUPNAME	0x0080
3526ca35587Sdholland #define	NFSID_DELGROUPNAME	0x0100
3536ca35587Sdholland 
3546ca35587Sdholland /*
3556ca35587Sdholland  * fs.nfs sysctl(3) identifiers
3566ca35587Sdholland  */
3576ca35587Sdholland #define	NFS_NFSSTATS	1		/* struct: struct nfsstats */
3586ca35587Sdholland 
3596ca35587Sdholland /*
3606ca35587Sdholland  * Here is the definition of the attribute bits array and macros that
3616ca35587Sdholland  * manipulate it.
3626ca35587Sdholland  * THE MACROS MUST BE MANUALLY MODIFIED IF NFSATTRBIT_MAXWORDS CHANGES!!
3636ca35587Sdholland  * It is (NFSATTRBIT_MAX + 31) / 32.
3646ca35587Sdholland  */
365e81f0ea2Spgoyette #define	NFSATTRBIT_MAXWORDS	3
3666ca35587Sdholland 
3676ca35587Sdholland typedef struct {
3686ca35587Sdholland 	u_int32_t bits[NFSATTRBIT_MAXWORDS];
3696ca35587Sdholland } nfsattrbit_t;
3706ca35587Sdholland 
371e81f0ea2Spgoyette #define	NFSZERO_ATTRBIT(b) do {						\
372e81f0ea2Spgoyette 	(b)->bits[0] = 0;						\
373e81f0ea2Spgoyette 	(b)->bits[1] = 0;						\
374e81f0ea2Spgoyette 	(b)->bits[2] = 0;						\
375e81f0ea2Spgoyette } while (0)
376e81f0ea2Spgoyette 
377e81f0ea2Spgoyette #define	NFSSET_ATTRBIT(t, f) do {					\
378e81f0ea2Spgoyette 	(t)->bits[0] = (f)->bits[0];			 		\
379e81f0ea2Spgoyette 	(t)->bits[1] = (f)->bits[1];					\
380e81f0ea2Spgoyette 	(t)->bits[2] = (f)->bits[2];					\
381e81f0ea2Spgoyette } while (0)
382e81f0ea2Spgoyette 
3836ca35587Sdholland #define	NFSSETSUPP_ATTRBIT(b) do { 					\
3846ca35587Sdholland 	(b)->bits[0] = NFSATTRBIT_SUPP0; 				\
385e81f0ea2Spgoyette 	(b)->bits[1] = (NFSATTRBIT_SUPP1 | NFSATTRBIT_SUPPSETONLY);	\
386e81f0ea2Spgoyette 	(b)->bits[2] = NFSATTRBIT_SUPP2;				\
387e81f0ea2Spgoyette } while (0)
388e81f0ea2Spgoyette 
3896ca35587Sdholland #define	NFSISSET_ATTRBIT(b, p)	((b)->bits[(p) / 32] & (1 << ((p) % 32)))
3906ca35587Sdholland #define	NFSSETBIT_ATTRBIT(b, p)	((b)->bits[(p) / 32] |= (1 << ((p) % 32)))
3916ca35587Sdholland #define	NFSCLRBIT_ATTRBIT(b, p)	((b)->bits[(p) / 32] &= ~(1 << ((p) % 32)))
392e81f0ea2Spgoyette 
3936ca35587Sdholland #define	NFSCLRALL_ATTRBIT(b, a)	do { 					\
3946ca35587Sdholland 	(b)->bits[0] &= ~((a)->bits[0]);	 			\
3956ca35587Sdholland 	(b)->bits[1] &= ~((a)->bits[1]);	 			\
396e81f0ea2Spgoyette 	(b)->bits[2] &= ~((a)->bits[2]);				\
3976ca35587Sdholland } while (0)
398e81f0ea2Spgoyette 
3996ca35587Sdholland #define	NFSCLRNOT_ATTRBIT(b, a)	do { 					\
4006ca35587Sdholland 	(b)->bits[0] &= ((a)->bits[0]);		 			\
4016ca35587Sdholland 	(b)->bits[1] &= ((a)->bits[1]);		 			\
402e81f0ea2Spgoyette 	(b)->bits[2] &= ((a)->bits[2]);		 			\
4036ca35587Sdholland } while (0)
404e81f0ea2Spgoyette 
4056ca35587Sdholland #define	NFSCLRNOTFILLABLE_ATTRBIT(b) do { 				\
4066ca35587Sdholland 	(b)->bits[0] &= NFSATTRBIT_SUPP0;	 			\
407e81f0ea2Spgoyette 	(b)->bits[1] &= NFSATTRBIT_SUPP1;				\
408e81f0ea2Spgoyette 	(b)->bits[2] &= NFSATTRBIT_SUPP2;				\
409e81f0ea2Spgoyette } while (0)
410e81f0ea2Spgoyette 
4116ca35587Sdholland #define	NFSCLRNOTSETABLE_ATTRBIT(b) do { 				\
4126ca35587Sdholland 	(b)->bits[0] &= NFSATTRBIT_SETABLE0;	 			\
413e81f0ea2Spgoyette 	(b)->bits[1] &= NFSATTRBIT_SETABLE1;				\
414e81f0ea2Spgoyette 	(b)->bits[2] &= NFSATTRBIT_SETABLE2;				\
415e81f0ea2Spgoyette } while (0)
416e81f0ea2Spgoyette 
417e81f0ea2Spgoyette #define	NFSNONZERO_ATTRBIT(b)	((b)->bits[0] || (b)->bits[1] || (b)->bits[2])
418e81f0ea2Spgoyette #define	NFSEQUAL_ATTRBIT(b, p)	((b)->bits[0] == (p)->bits[0] &&	\
419e81f0ea2Spgoyette 	(b)->bits[1] == (p)->bits[1] && (b)->bits[2] == (p)->bits[2])
420e81f0ea2Spgoyette 
4216ca35587Sdholland #define	NFSGETATTR_ATTRBIT(b) do { 					\
4226ca35587Sdholland 	(b)->bits[0] = NFSATTRBIT_GETATTR0;	 			\
423e81f0ea2Spgoyette 	(b)->bits[1] = NFSATTRBIT_GETATTR1;				\
424e81f0ea2Spgoyette 	(b)->bits[2] = NFSATTRBIT_GETATTR2;				\
425e81f0ea2Spgoyette } while (0)
426e81f0ea2Spgoyette 
4276ca35587Sdholland #define	NFSWCCATTR_ATTRBIT(b) do { 					\
4286ca35587Sdholland 	(b)->bits[0] = NFSATTRBIT_WCCATTR0;	 			\
429e81f0ea2Spgoyette 	(b)->bits[1] = NFSATTRBIT_WCCATTR1;				\
430e81f0ea2Spgoyette 	(b)->bits[2] = NFSATTRBIT_WCCATTR2;				\
431e81f0ea2Spgoyette } while (0)
432e81f0ea2Spgoyette 
4336ca35587Sdholland #define	NFSWRITEGETATTR_ATTRBIT(b) do { 				\
4346ca35587Sdholland 	(b)->bits[0] = NFSATTRBIT_WRITEGETATTR0;			\
435e81f0ea2Spgoyette 	(b)->bits[1] = NFSATTRBIT_WRITEGETATTR1;			\
436e81f0ea2Spgoyette 	(b)->bits[2] = NFSATTRBIT_WRITEGETATTR2;			\
437e81f0ea2Spgoyette } while (0)
438e81f0ea2Spgoyette 
4396ca35587Sdholland #define	NFSCBGETATTR_ATTRBIT(b, c) do { 				\
4406ca35587Sdholland 	(c)->bits[0] = ((b)->bits[0] & NFSATTRBIT_CBGETATTR0);		\
441e81f0ea2Spgoyette 	(c)->bits[1] = ((b)->bits[1] & NFSATTRBIT_CBGETATTR1);		\
442e81f0ea2Spgoyette 	(c)->bits[2] = ((b)->bits[2] & NFSATTRBIT_CBGETATTR2);		\
443e81f0ea2Spgoyette } while (0)
444e81f0ea2Spgoyette 
4456ca35587Sdholland #define	NFSPATHCONF_GETATTRBIT(b) do { 					\
4466ca35587Sdholland 	(b)->bits[0] = NFSGETATTRBIT_PATHCONF0;		 		\
447e81f0ea2Spgoyette 	(b)->bits[1] = NFSGETATTRBIT_PATHCONF1;				\
448e81f0ea2Spgoyette 	(b)->bits[2] = NFSGETATTRBIT_PATHCONF2;				\
449e81f0ea2Spgoyette } while (0)
450e81f0ea2Spgoyette 
4516ca35587Sdholland #define	NFSSTATFS_GETATTRBIT(b)	do { 					\
4526ca35587Sdholland 	(b)->bits[0] = NFSGETATTRBIT_STATFS0;	 			\
453e81f0ea2Spgoyette 	(b)->bits[1] = NFSGETATTRBIT_STATFS1;				\
454e81f0ea2Spgoyette 	(b)->bits[2] = NFSGETATTRBIT_STATFS2;				\
455e81f0ea2Spgoyette } while (0)
456e81f0ea2Spgoyette 
4576ca35587Sdholland #define	NFSISSETSTATFS_ATTRBIT(b) 					\
4586ca35587Sdholland 		(((b)->bits[0] & NFSATTRBIT_STATFS0) || 		\
459e81f0ea2Spgoyette 		 ((b)->bits[1] & NFSATTRBIT_STATFS1) ||			\
460e81f0ea2Spgoyette 		 ((b)->bits[2] & NFSATTRBIT_STATFS2))
461e81f0ea2Spgoyette 
4626ca35587Sdholland #define	NFSCLRSTATFS_ATTRBIT(b)	do { 					\
4636ca35587Sdholland 	(b)->bits[0] &= ~NFSATTRBIT_STATFS0;	 			\
464e81f0ea2Spgoyette 	(b)->bits[1] &= ~NFSATTRBIT_STATFS1;				\
465e81f0ea2Spgoyette 	(b)->bits[2] &= ~NFSATTRBIT_STATFS2;				\
466e81f0ea2Spgoyette } while (0)
467e81f0ea2Spgoyette 
4686ca35587Sdholland #define	NFSREADDIRPLUS_ATTRBIT(b) do { 					\
4696ca35587Sdholland 	(b)->bits[0] = NFSATTRBIT_READDIRPLUS0;		 		\
470e81f0ea2Spgoyette 	(b)->bits[1] = NFSATTRBIT_READDIRPLUS1;				\
471e81f0ea2Spgoyette 	(b)->bits[2] = NFSATTRBIT_READDIRPLUS2;				\
472e81f0ea2Spgoyette } while (0)
473e81f0ea2Spgoyette 
4746ca35587Sdholland #define	NFSREFERRAL_ATTRBIT(b) do { 					\
4756ca35587Sdholland 	(b)->bits[0] = NFSATTRBIT_REFERRAL0;		 		\
476e81f0ea2Spgoyette 	(b)->bits[1] = NFSATTRBIT_REFERRAL1;				\
477e81f0ea2Spgoyette 	(b)->bits[2] = NFSATTRBIT_REFERRAL2;				\
478e81f0ea2Spgoyette } while (0)
4796ca35587Sdholland 
4806ca35587Sdholland /*
4816ca35587Sdholland  * Store uid, gid creds that were used when the stateid was acquired.
4826ca35587Sdholland  * The RPC layer allows NFS_MAXGRPS + 1 groups to go out on the wire,
4836ca35587Sdholland  * so that's how many gets stored here.
4846ca35587Sdholland  */
4856ca35587Sdholland struct nfscred {
4866ca35587Sdholland 	uid_t 		nfsc_uid;
4876ca35587Sdholland 	gid_t		nfsc_groups[NFS_MAXGRPS + 1];
4886ca35587Sdholland 	int		nfsc_ngroups;
4896ca35587Sdholland };
4906ca35587Sdholland 
4916ca35587Sdholland /*
4926ca35587Sdholland  * Constants that define the file handle for the V4 root directory.
4936ca35587Sdholland  * (The FSID must never be used by other file systems that are exported.)
4946ca35587Sdholland  */
4956ca35587Sdholland #define	NFSV4ROOT_FSID0		((int32_t) -1)
4966ca35587Sdholland #define	NFSV4ROOT_FSID1		((int32_t) -1)
4976ca35587Sdholland #define	NFSV4ROOT_REFERRAL	((int32_t) -2)
4986ca35587Sdholland #define	NFSV4ROOT_INO		2	/* It's traditional */
4996ca35587Sdholland #define	NFSV4ROOT_GEN		1
5006ca35587Sdholland 
5016ca35587Sdholland /*
5026ca35587Sdholland  * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
5036ca35587Sdholland  * What should be in this set is open to debate, but I believe that since
5046ca35587Sdholland  * I/O system calls on ufs are never interrupted by signals the set should
5056ca35587Sdholland  * be minimal. My reasoning is that many current programs that use signals
5066ca35587Sdholland  * such as SIGALRM will not expect file I/O system calls to be interrupted
5076ca35587Sdholland  * by them and break.
5086ca35587Sdholland  */
5096ca35587Sdholland #if defined(_KERNEL) || defined(KERNEL)
5106ca35587Sdholland 
5116ca35587Sdholland struct uio; struct buf; struct vattr; struct nameidata;	/* XXX */
5126ca35587Sdholland 
5136ca35587Sdholland /*
5146ca35587Sdholland  * Socket errors ignored for connectionless sockets?
5156ca35587Sdholland  * For now, ignore them all
5166ca35587Sdholland  */
5176ca35587Sdholland #define	NFSIGNORE_SOERROR(s, e) 					\
5186ca35587Sdholland 		((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
5196ca35587Sdholland 		((s) & PR_CONNREQUIRED) == 0)
5206ca35587Sdholland 
5216ca35587Sdholland 
5226ca35587Sdholland /*
5236ca35587Sdholland  * This structure holds socket information for a connection. Used by the
5246ca35587Sdholland  * client and the server for callbacks.
5256ca35587Sdholland  */
5266ca35587Sdholland struct nfssockreq {
5276ca35587Sdholland 	NFSSOCKADDR_T	nr_nam;
5286ca35587Sdholland 	int		nr_sotype;
5296ca35587Sdholland 	int		nr_soproto;
5306ca35587Sdholland 	int		nr_soflags;
5316ca35587Sdholland 	struct ucred	*nr_cred;
5326ca35587Sdholland 	int		nr_lock;
5336ca35587Sdholland 	NFSMUTEX_T	nr_mtx;
5346ca35587Sdholland 	u_int32_t	nr_prog;
5356ca35587Sdholland 	u_int32_t	nr_vers;
5366ca35587Sdholland 	struct __rpc_client *nr_client;
5376ca35587Sdholland 	AUTH		*nr_auth;
5386ca35587Sdholland };
5396ca35587Sdholland 
5406ca35587Sdholland /*
5416ca35587Sdholland  * And associated nr_lock bits.
5426ca35587Sdholland  */
5436ca35587Sdholland #define	NFSR_SNDLOCK		0x01
5446ca35587Sdholland #define	NFSR_WANTSND		0x02
5456ca35587Sdholland #define	NFSR_RCVLOCK		0x04
5466ca35587Sdholland #define	NFSR_WANTRCV		0x08
5476ca35587Sdholland #define	NFSR_RESERVEDPORT	0x10
5486ca35587Sdholland #define	NFSR_LOCALHOST		0x20
5496ca35587Sdholland 
5506ca35587Sdholland /*
5516ca35587Sdholland  * Queue head for nfsreq's
5526ca35587Sdholland  */
5536ca35587Sdholland TAILQ_HEAD(nfsreqhead, nfsreq);
5546ca35587Sdholland 
5556ca35587Sdholland /* This is the only nfsreq R_xxx flag still used. */
5566ca35587Sdholland #define	R_DONTRECOVER	0x00000100	/* don't initiate recovery when this
5576ca35587Sdholland 					   rpc gets a stale state reply */
5586ca35587Sdholland 
5596ca35587Sdholland /*
5606ca35587Sdholland  * Network address hash list element
5616ca35587Sdholland  */
5626ca35587Sdholland union nethostaddr {
5636ca35587Sdholland 	struct in_addr	had_inet;
5646ca35587Sdholland 	struct in6_addr had_inet6;
5656ca35587Sdholland };
5666ca35587Sdholland 
5676ca35587Sdholland /*
5686ca35587Sdholland  * Structure of list of mechanisms.
5696ca35587Sdholland  */
5706ca35587Sdholland struct nfsgss_mechlist {
5716ca35587Sdholland 	int	len;
5726ca35587Sdholland 	const u_char	*str;
5736ca35587Sdholland 	int	totlen;
5746ca35587Sdholland };
5756ca35587Sdholland #define	KERBV_MECH	0	/* position in list */
5766ca35587Sdholland 
5776ca35587Sdholland /*
5786ca35587Sdholland  * This structure is used by the server for describing each request.
5796ca35587Sdholland  */
5806ca35587Sdholland struct nfsrv_descript {
5816ca35587Sdholland 	mbuf_t			nd_mrep;	/* Request mbuf list */
5826ca35587Sdholland 	mbuf_t			nd_md;		/* Current dissect mbuf */
5836ca35587Sdholland 	mbuf_t			nd_mreq;	/* Reply mbuf list */
5846ca35587Sdholland 	mbuf_t			nd_mb;		/* Current build mbuf */
5856ca35587Sdholland 	NFSSOCKADDR_T		nd_nam;		/* and socket addr */
5866ca35587Sdholland 	NFSSOCKADDR_T		nd_nam2;	/* return socket addr */
587*0342d508Spgoyette 	char			*nd_dpos;	/* Current dissect pos */
588*0342d508Spgoyette 	char			*nd_bpos;	/* Current build pos */
5896ca35587Sdholland 	u_int16_t		nd_procnum;	/* RPC # */
5906ca35587Sdholland 	u_int32_t		nd_flag;	/* nd_flag */
5916ca35587Sdholland 	u_int32_t		nd_repstat;	/* Reply status */
5926ca35587Sdholland 	int			*nd_errp;	/* Pointer to ret status */
5936ca35587Sdholland 	u_int32_t		nd_retxid;	/* Reply xid */
5946ca35587Sdholland 	struct nfsrvcache	*nd_rp;		/* Assoc. cache entry */
5956ca35587Sdholland 	fhandle_t		nd_fh;		/* File handle */
5966ca35587Sdholland 	struct ucred		*nd_cred;	/* Credentials */
5976ca35587Sdholland 	uid_t			nd_saveduid;	/* Saved uid */
5986ca35587Sdholland 	u_int64_t		nd_sockref;	/* Rcv socket ref# */
5996ca35587Sdholland 	u_int64_t		nd_compref;	/* Compound RPC ref# */
6006ca35587Sdholland 	time_t			nd_tcpconntime;	/* Time TCP connection est. */
6016ca35587Sdholland 	nfsquad_t		nd_clientid;	/* Implied clientid */
6026ca35587Sdholland 	int			nd_gssnamelen;	/* principal name length */
6036ca35587Sdholland 	char			*nd_gssname;	/* principal name */
6046ca35587Sdholland 	uint32_t		*nd_slotseq;	/* ptr to slot seq# in req */
605e81f0ea2Spgoyette 	uint8_t			nd_sessionid[NFSX_V4SESSIONID];	/* Session id */
606e81f0ea2Spgoyette 	uint32_t		nd_slotid;	/* Slotid for this RPC */
607e81f0ea2Spgoyette 	SVCXPRT			*nd_xprt;	/* Server RPC handle */
6086ca35587Sdholland };
6096ca35587Sdholland 
6106ca35587Sdholland #define	nd_princlen	nd_gssnamelen
6116ca35587Sdholland #define	nd_principal	nd_gssname
6126ca35587Sdholland 
6136ca35587Sdholland /* Bits for "nd_flag" */
6146ca35587Sdholland #define	ND_DONTSAVEREPLY 	0x00000001
6156ca35587Sdholland #define	ND_SAVEREPLY		0x00000002
6166ca35587Sdholland #define	ND_NFSV2		0x00000004
6176ca35587Sdholland #define	ND_NFSV3		0x00000008
6186ca35587Sdholland #define	ND_NFSV4		0x00000010
6196ca35587Sdholland #define	ND_KERBV		0x00000020
6206ca35587Sdholland #define	ND_GSSINTEGRITY		0x00000040
6216ca35587Sdholland #define	ND_GSSPRIVACY		0x00000080
6226ca35587Sdholland #define	ND_WINDOWVERF		0x00000100
6236ca35587Sdholland #define	ND_GSSINITREPLY		0x00000200
6246ca35587Sdholland #define	ND_STREAMSOCK		0x00000400
6256ca35587Sdholland #define	ND_PUBLOOKUP		0x00000800
6266ca35587Sdholland #define	ND_USEGSSNAME		0x00001000
6276ca35587Sdholland #define	ND_SAMETCPCONN		0x00002000
6286ca35587Sdholland #define	ND_IMPLIEDCLID		0x00004000
6296ca35587Sdholland #define	ND_NOMOREDATA		0x00008000
6306ca35587Sdholland #define	ND_V4WCCATTR		0x00010000
6316ca35587Sdholland #define	ND_NFSCB		0x00020000
6326ca35587Sdholland #define	ND_AUTHNONE		0x00040000
6336ca35587Sdholland #define	ND_EXAUTHSYS		0x00080000
6346ca35587Sdholland #define	ND_EXGSS		0x00100000
6356ca35587Sdholland #define	ND_EXGSSINTEGRITY	0x00200000
6366ca35587Sdholland #define	ND_EXGSSPRIVACY		0x00400000
6376ca35587Sdholland #define	ND_INCRSEQID		0x00800000
6386ca35587Sdholland #define	ND_NFSCL		0x01000000
6396ca35587Sdholland #define	ND_NFSV41		0x02000000
6406ca35587Sdholland #define	ND_HASSEQUENCE		0x04000000
641e81f0ea2Spgoyette #define	ND_CACHETHIS		0x08000000
642e81f0ea2Spgoyette #define	ND_LASTOP		0x10000000
6436ca35587Sdholland 
6446ca35587Sdholland /*
6456ca35587Sdholland  * ND_GSS should be the "or" of all GSS type authentications.
6466ca35587Sdholland  */
6476ca35587Sdholland #define	ND_GSS		(ND_KERBV)
6486ca35587Sdholland 
6496ca35587Sdholland struct nfsv4_opflag {
6506ca35587Sdholland 	int	retfh;
6516ca35587Sdholland 	int	needscfh;
6526ca35587Sdholland 	int	savereply;
6536ca35587Sdholland 	int	modifyfs;
6546ca35587Sdholland 	int	lktype;
6556ca35587Sdholland 	int	needsseq;
6566ca35587Sdholland };
6576ca35587Sdholland 
6586ca35587Sdholland /*
6596ca35587Sdholland  * Flags used to indicate what to do w.r.t. seqid checking.
6606ca35587Sdholland  */
6616ca35587Sdholland #define	NFSRVSEQID_FIRST	0x01
6626ca35587Sdholland #define	NFSRVSEQID_LAST		0x02
6636ca35587Sdholland #define	NFSRVSEQID_OPEN		0x04
6646ca35587Sdholland 
6656ca35587Sdholland /*
6666ca35587Sdholland  * assign a doubly linked list to a new head
6676ca35587Sdholland  * and prepend one list into another.
6686ca35587Sdholland  */
6696ca35587Sdholland #define	LIST_NEWHEAD(nhead, ohead, field) do { 				\
6706ca35587Sdholland 	if (((nhead)->lh_first = (ohead)->lh_first) != NULL) 		\
6716ca35587Sdholland 		(ohead)->lh_first->field.le_prev = &(nhead)->lh_first; 	\
6726ca35587Sdholland 	(ohead)->lh_first = NULL; 					\
6736ca35587Sdholland     } while (0)
6746ca35587Sdholland 
6756ca35587Sdholland #define	LIST_PREPEND(head, phead, lelm, field) do {			\
6766ca35587Sdholland 	if ((head)->lh_first != NULL) {					\
6776ca35587Sdholland 		(lelm)->field.le_next = (head)->lh_first;		\
6786ca35587Sdholland 		(lelm)->field.le_next->field.le_prev =			\
6796ca35587Sdholland 		    &(lelm)->field.le_next;				\
6806ca35587Sdholland 	}								\
6816ca35587Sdholland 	(head)->lh_first = (phead)->lh_first;				\
6826ca35587Sdholland 	(head)->lh_first->field.le_prev = &(head)->lh_first;		\
6836ca35587Sdholland     } while (0)
6846ca35587Sdholland 
6856ca35587Sdholland /*
6866ca35587Sdholland  * File handle structure for client. Malloc'd to the correct length with
6876ca35587Sdholland  * malloc type M_NFSFH.
6886ca35587Sdholland  */
6896ca35587Sdholland struct nfsfh {
6906ca35587Sdholland 	u_int16_t	nfh_len;	/* Length of file handle */
6916ca35587Sdholland 	u_int8_t	nfh_fh[1];	/* and the file handle */
6926ca35587Sdholland };
6936ca35587Sdholland 
6946ca35587Sdholland /*
6956ca35587Sdholland  * File handle structure for server. The NFSRV_MAXFH constant is
6966ca35587Sdholland  * set in nfsdport.h. I use a 32bit length, so that alignment is
6976ca35587Sdholland  * preserved.
6986ca35587Sdholland  */
6996ca35587Sdholland struct nfsrvfh {
7006ca35587Sdholland 	u_int32_t	nfsrvfh_len;
7016ca35587Sdholland 	u_int8_t	nfsrvfh_data[NFSRV_MAXFH];
7026ca35587Sdholland };
7036ca35587Sdholland 
7046ca35587Sdholland /*
7056ca35587Sdholland  * This structure is used for sleep locks on the NFSv4 nfsd threads and
7066ca35587Sdholland  * NFSv4 client data structures.
7076ca35587Sdholland  */
7086ca35587Sdholland struct nfsv4lock {
7096ca35587Sdholland 	u_int32_t	nfslock_usecnt;
7106ca35587Sdholland 	u_int8_t	nfslock_lock;
7116ca35587Sdholland };
7126ca35587Sdholland #define	NFSV4LOCK_LOCK		0x01
7136ca35587Sdholland #define	NFSV4LOCK_LOCKWANTED	0x02
7146ca35587Sdholland #define	NFSV4LOCK_WANTED	0x04
7156ca35587Sdholland 
7166ca35587Sdholland /*
7176ca35587Sdholland  * Values for the override argument for nfsvno_accchk().
7186ca35587Sdholland  */
7196ca35587Sdholland #define	NFSACCCHK_NOOVERRIDE		0
7206ca35587Sdholland #define	NFSACCCHK_ALLOWROOT		1
7216ca35587Sdholland #define	NFSACCCHK_ALLOWOWNER		2
7226ca35587Sdholland 
7236ca35587Sdholland /*
7246ca35587Sdholland  * and values for the vpislocked argument for nfsvno_accchk().
7256ca35587Sdholland  */
7266ca35587Sdholland #define	NFSACCCHK_VPNOTLOCKED		0
7276ca35587Sdholland #define	NFSACCCHK_VPISLOCKED		1
7286ca35587Sdholland 
7296ca35587Sdholland /*
7306ca35587Sdholland  * Slot for the NFSv4.1 Sequence Op.
7316ca35587Sdholland  */
7326ca35587Sdholland struct nfsslot {
7336ca35587Sdholland 	int		nfssl_inprog;
7346ca35587Sdholland 	uint32_t	nfssl_seq;
7356ca35587Sdholland 	struct mbuf	*nfssl_reply;
7366ca35587Sdholland };
7376ca35587Sdholland 
7386ca35587Sdholland #endif	/* _KERNEL */
7396ca35587Sdholland 
7406ca35587Sdholland #endif	/* _NFS_NFS_H */
741