2005-01-07 01:45:51 +00:00
|
|
|
/*-
|
1997-02-10 02:22:35 +00:00
|
|
|
* Copyright (c) 1989, 1993, 1995
|
1994-05-24 10:09:53 +00:00
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Rick Macklem at The University of Guelph.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1997-02-10 02:22:35 +00:00
|
|
|
* @(#)nfs.h 8.4 (Berkeley) 5/1/95
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
|
2001-09-18 23:32:09 +00:00
|
|
|
#ifndef _NFSCLIENT_NFS_H_
|
|
|
|
#define _NFSCLIENT_NFS_H_
|
1994-08-21 06:50:16 +00:00
|
|
|
|
1999-12-29 05:07:58 +00:00
|
|
|
#ifdef _KERNEL
|
1998-06-30 03:01:37 +00:00
|
|
|
#include "opt_nfs.h"
|
1998-06-30 11:19:22 +00:00
|
|
|
#endif
|
1998-06-30 03:01:37 +00:00
|
|
|
|
2001-09-18 23:32:09 +00:00
|
|
|
#include <nfsclient/nfsargs.h>
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Tunable constants for nfs
|
|
|
|
*/
|
|
|
|
|
2004-03-14 06:21:56 +00:00
|
|
|
#define NFS_TICKINTVL 10 /* Desired time for a tick (msec) */
|
1995-06-27 11:07:30 +00:00
|
|
|
#define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */
|
|
|
|
#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */
|
|
|
|
#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */
|
|
|
|
#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */
|
|
|
|
#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/
|
1994-05-24 10:09:53 +00:00
|
|
|
#define NFS_MAXREXMIT 100 /* Stop counting after this many */
|
2006-05-23 18:48:07 +00:00
|
|
|
#define NFS_RETRANS 10 /* Num of retrans for UDP soft mounts */
|
|
|
|
#define NFS_RETRANS_TCP 2 /* Num of retrans for TCP soft mounts */
|
1994-05-24 10:09:53 +00:00
|
|
|
#define NFS_MAXGRPS 16 /* Max. size of groups list */
|
1994-08-04 06:03:46 +00:00
|
|
|
#ifndef NFS_MINATTRTIMO
|
1998-05-19 07:11:27 +00:00
|
|
|
#define NFS_MINATTRTIMO 3 /* VREG attrib cache timeout in sec */
|
1994-08-04 06:03:46 +00:00
|
|
|
#endif
|
|
|
|
#ifndef NFS_MAXATTRTIMO
|
1994-05-24 10:09:53 +00:00
|
|
|
#define NFS_MAXATTRTIMO 60
|
1994-08-04 06:03:46 +00:00
|
|
|
#endif
|
1998-05-19 07:11:27 +00:00
|
|
|
#ifndef NFS_MINDIRATTRTIMO
|
2009-04-06 19:12:47 +00:00
|
|
|
#define NFS_MINDIRATTRTIMO 3 /* VDIR attrib cache timeout in sec */
|
1998-05-19 07:11:27 +00:00
|
|
|
#endif
|
|
|
|
#ifndef NFS_MAXDIRATTRTIMO
|
|
|
|
#define NFS_MAXDIRATTRTIMO 60
|
|
|
|
#endif
|
2009-03-20 21:12:38 +00:00
|
|
|
#ifndef NFS_ACCESSCACHESIZE
|
|
|
|
#define NFS_ACCESSCACHESIZE 8 /* Per-node access cache entries */
|
|
|
|
#endif
|
1994-05-24 10:09:53 +00:00
|
|
|
#define NFS_WSIZE 8192 /* Def. write data size <= 8192 */
|
|
|
|
#define NFS_RSIZE 8192 /* Def. read data size <= 8192 */
|
1995-06-27 11:07:30 +00:00
|
|
|
#define NFS_READDIRSIZE 8192 /* Def. readdir size */
|
1994-05-24 10:09:53 +00:00
|
|
|
#define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */
|
|
|
|
#define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */
|
2002-01-15 20:57:21 +00:00
|
|
|
#define NFS_MAXASYNCDAEMON 64 /* Max. number async_daemons runnable */
|
1995-06-27 11:07:30 +00:00
|
|
|
#define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */
|
1999-12-29 05:07:58 +00:00
|
|
|
#ifdef _KERNEL
|
1997-03-29 12:34:33 +00:00
|
|
|
#define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */
|
|
|
|
#endif
|
2001-09-18 23:32:09 +00:00
|
|
|
#define NFS_MAXDEADTHRESH 9 /* How long till we say 'server not responding' */
|
1995-06-27 11:07:30 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Oddballs
|
|
|
|
*/
|
|
|
|
#define NFS_CMPFH(n, f, s) \
|
|
|
|
((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s)))
|
|
|
|
#define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
|
2006-05-24 23:06:50 +00:00
|
|
|
#define NFS_ISV4(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV4)
|
1998-05-19 07:11:27 +00:00
|
|
|
|
|
|
|
#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
|
|
|
|
#define NFSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
|
|
|
|
#define NFSSTA_SNDLOCK 0x01000000 /* Send socket lock */
|
|
|
|
#define NFSSTA_WANTSND 0x02000000 /* Want above */
|
2004-07-06 09:12:03 +00:00
|
|
|
#define NFSSTA_TIMEO 0x10000000 /* Experiencing a timeout */
|
2008-06-26 10:21:54 +00:00
|
|
|
#define NFSSTA_LOCKTIMEO 0x20000000 /* Experiencing a lockd timeout */
|
2004-07-06 09:12:03 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
/*
|
|
|
|
* XXX to allow amd to include nfs.h without nfsproto.h
|
|
|
|
*/
|
|
|
|
#ifdef NFS_NPROCS
|
2001-09-18 23:32:09 +00:00
|
|
|
#include <nfsclient/nfsstats.h>
|
1997-02-10 02:22:35 +00:00
|
|
|
#endif
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1994-10-23 23:26:18 +00:00
|
|
|
/*
|
2001-09-18 23:32:09 +00:00
|
|
|
* vfs.nfs sysctl(3) identifiers
|
1994-10-23 23:26:18 +00:00
|
|
|
*/
|
|
|
|
#define NFS_NFSSTATS 1 /* struct: struct nfsstats */
|
|
|
|
|
1999-12-29 05:07:58 +00:00
|
|
|
#ifdef _KERNEL
|
1994-11-02 00:11:00 +00:00
|
|
|
|
1997-10-12 20:26:33 +00:00
|
|
|
#ifdef MALLOC_DECLARE
|
|
|
|
MALLOC_DECLARE(M_NFSREQ);
|
|
|
|
MALLOC_DECLARE(M_NFSDIROFF);
|
|
|
|
MALLOC_DECLARE(M_NFSBIGFH);
|
1998-05-24 14:41:56 +00:00
|
|
|
MALLOC_DECLARE(M_NFSHASH);
|
2004-12-15 22:20:22 +00:00
|
|
|
MALLOC_DECLARE(M_NFSDIRECTIO);
|
1998-05-24 14:41:56 +00:00
|
|
|
#endif
|
|
|
|
|
2002-09-05 14:04:34 +00:00
|
|
|
extern struct uma_zone *nfsmount_zone;
|
1997-10-12 20:26:33 +00:00
|
|
|
|
Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.
The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.
To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.
As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.
Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.
The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.
Sponsored by: Isilon Systems
MFC after: 1 month
2008-11-03 10:38:00 +00:00
|
|
|
#ifdef NFS_LEGACYRPC
|
2004-03-25 21:48:09 +00:00
|
|
|
extern struct callout nfs_callout;
|
Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.
The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.
To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.
As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.
Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.
The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.
Sponsored by: Isilon Systems
MFC after: 1 month
2008-11-03 10:38:00 +00:00
|
|
|
#endif
|
2001-09-18 23:32:09 +00:00
|
|
|
extern struct nfsstats nfsstats;
|
2006-05-19 00:04:24 +00:00
|
|
|
extern struct mtx nfs_iod_mtx;
|
1998-09-07 05:42:15 +00:00
|
|
|
|
2001-09-18 23:32:09 +00:00
|
|
|
extern int nfs_numasync;
|
2004-04-11 13:30:20 +00:00
|
|
|
extern unsigned int nfs_iodmax;
|
2001-09-18 23:32:09 +00:00
|
|
|
extern int nfs_pbuf_freecnt;
|
|
|
|
extern int nfs_ticks;
|
|
|
|
|
|
|
|
/* Data constants in XDR form */
|
|
|
|
extern u_int32_t nfs_true, nfs_false, nfs_xdrneg1;
|
|
|
|
extern u_int32_t rpc_reply, rpc_msgdenied, rpc_mismatch, rpc_vers;
|
|
|
|
extern u_int32_t rpc_auth_unix, rpc_msgaccepted, rpc_call, rpc_autherr;
|
|
|
|
|
|
|
|
extern int nfsv3_procid[NFS_NPROCS];
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Socket errors ignored for connectionless sockets??
|
|
|
|
* For now, ignore them all
|
|
|
|
*/
|
|
|
|
#define NFSIGNORE_SOERROR(s, e) \
|
2004-07-06 09:12:03 +00:00
|
|
|
((e) != EINTR && (e) != EIO && \
|
2006-10-17 22:07:07 +00:00
|
|
|
(e) != ERESTART && (e) != EWOULDBLOCK && \
|
1994-05-24 10:09:53 +00:00
|
|
|
((s) & PR_CONNREQUIRED) == 0)
|
|
|
|
|
Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.
The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.
To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.
As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.
Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.
The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.
Sponsored by: Isilon Systems
MFC after: 1 month
2008-11-03 10:38:00 +00:00
|
|
|
#ifdef NFS_LEGACYRPC
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Nfs outstanding request list element
|
|
|
|
*/
|
|
|
|
struct nfsreq {
|
2000-05-26 02:09:24 +00:00
|
|
|
TAILQ_ENTRY(nfsreq) r_chain;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct mbuf *r_mreq;
|
|
|
|
struct mbuf *r_mrep;
|
|
|
|
struct mbuf *r_md;
|
|
|
|
caddr_t r_dpos;
|
|
|
|
struct nfsmount *r_nmp;
|
|
|
|
struct vnode *r_vp;
|
1998-05-31 20:09:01 +00:00
|
|
|
u_int32_t r_xid;
|
1994-05-24 10:09:53 +00:00
|
|
|
int r_flags; /* flags on request, see below */
|
|
|
|
int r_retry; /* max retransmission count */
|
|
|
|
int r_rexmit; /* current retrans count */
|
|
|
|
int r_timer; /* tick counter on reply */
|
1997-06-03 17:22:47 +00:00
|
|
|
u_int32_t r_procnum; /* NFS procedure number */
|
1994-05-24 10:09:53 +00:00
|
|
|
int r_rtt; /* RTT for rpc */
|
2004-07-06 09:12:03 +00:00
|
|
|
int r_lastmsg; /* last tprintf */
|
2001-09-15 04:41:56 +00:00
|
|
|
struct thread *r_td; /* Proc that did I/O system call */
|
2006-05-19 00:04:24 +00:00
|
|
|
struct mtx r_mtx; /* Protects nfsreq fields */
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
|
|
|
|
1994-10-17 17:47:45 +00:00
|
|
|
/*
|
|
|
|
* Queue head for nfsreq's
|
|
|
|
*/
|
2000-05-26 02:09:24 +00:00
|
|
|
extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq;
|
1994-10-17 17:47:45 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/* Flag values for r_flags */
|
|
|
|
#define R_TIMING 0x01 /* timing request (in mntp) */
|
|
|
|
#define R_SENT 0x02 /* request has been sent */
|
|
|
|
#define R_SOFTTERM 0x04 /* soft mnt, too many retries */
|
2004-07-06 09:12:03 +00:00
|
|
|
#define R_RESENDERR 0x08 /* Resend failed */
|
1994-05-24 10:09:53 +00:00
|
|
|
#define R_SOCKERR 0x10 /* Fatal error on socket */
|
|
|
|
#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */
|
|
|
|
#define R_MUSTRESEND 0x40 /* Must resend request */
|
|
|
|
#define R_GETONEREP 0x80 /* Probe for one reply only */
|
2006-11-20 04:14:23 +00:00
|
|
|
#define R_PIN_REQ 0x100 /* Pin request down (rexmit in prog or other) */
|
1994-05-24 10:09:53 +00:00
|
|
|
|
Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.
The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.
To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.
As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.
Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.
The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.
Sponsored by: Isilon Systems
MFC after: 1 month
2008-11-03 10:38:00 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is only needed to keep things working while we support
|
|
|
|
* compiling for both RPC implementations.
|
|
|
|
*/
|
|
|
|
struct nfsreq;
|
|
|
|
struct nfsmount;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2006-10-17 22:07:07 +00:00
|
|
|
struct buf;
|
|
|
|
struct socket;
|
|
|
|
struct uio;
|
|
|
|
struct vattr;
|
|
|
|
|
2003-11-22 02:21:49 +00:00
|
|
|
/*
|
|
|
|
* Pointers to ops that differ from v3 to v4
|
|
|
|
*/
|
|
|
|
struct nfs_rpcops {
|
2006-10-17 22:07:07 +00:00
|
|
|
int (*nr_readrpc)(struct vnode *vp, struct uio *uiop,
|
|
|
|
struct ucred *cred);
|
|
|
|
int (*nr_writerpc)(struct vnode *vp, struct uio *uiop,
|
|
|
|
struct ucred *cred, int *iomode, int *must_commit);
|
2003-11-22 02:21:49 +00:00
|
|
|
int (*nr_writebp)(struct buf *bp, int force, struct thread *td);
|
2006-10-17 22:07:07 +00:00
|
|
|
int (*nr_readlinkrpc)(struct vnode *vp, struct uio *uiop,
|
|
|
|
struct ucred *cred);
|
2003-11-22 02:21:49 +00:00
|
|
|
void (*nr_invaldir)(struct vnode *vp);
|
|
|
|
int (*nr_commit)(struct vnode *vp, u_quad_t offset, int cnt,
|
2006-10-17 22:07:07 +00:00
|
|
|
struct ucred *cred, struct thread *td);
|
2003-11-22 02:21:49 +00:00
|
|
|
};
|
|
|
|
|
1997-07-16 09:06:30 +00:00
|
|
|
/*
|
|
|
|
* Defines for WebNFS
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define WEBNFS_ESC_CHAR '%'
|
|
|
|
#define WEBNFS_SPECCHAR_START 0x80
|
|
|
|
|
|
|
|
#define WEBNFS_NATIVE_CHAR 0x80
|
|
|
|
/*
|
|
|
|
* ..
|
|
|
|
* Possibly more here in the future.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Macro for converting escape characters in WebNFS pathnames.
|
|
|
|
* Should really be in libkern.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define HEXTOC(c) \
|
|
|
|
((c) >= 'a' ? ((c) - ('a' - 10)) : \
|
|
|
|
((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '0')))
|
|
|
|
#define HEXSTRTOI(p) \
|
|
|
|
((HEXTOC(p[0]) << 4) + HEXTOC(p[1]))
|
|
|
|
|
2004-07-06 09:12:03 +00:00
|
|
|
/* nfs_sigintr() helper, when 'rep' has all we need */
|
|
|
|
#define NFS_SIGREP(rep) nfs_sigintr((rep)->r_nmp, (rep), (rep)->r_td)
|
|
|
|
|
1997-05-10 16:12:03 +00:00
|
|
|
#ifdef NFS_DEBUG
|
|
|
|
|
|
|
|
extern int nfs_debug;
|
|
|
|
#define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */
|
|
|
|
#define NFS_DEBUG_WG 2 /* server write gathering */
|
|
|
|
#define NFS_DEBUG_RC 4 /* server request caching */
|
|
|
|
|
|
|
|
#define NFS_DPF(cat, args) \
|
|
|
|
do { \
|
|
|
|
if (nfs_debug & NFS_DEBUG_##cat) printf args; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define NFS_DPF(cat, args)
|
|
|
|
|
|
|
|
#endif
|
1997-02-10 02:22:35 +00:00
|
|
|
|
2006-05-23 18:33:58 +00:00
|
|
|
/*
|
|
|
|
* On fast networks, the estimator will try to reduce the
|
|
|
|
* timeout lower than the latency of the server's disks,
|
|
|
|
* which results in too many timeouts, so cap the lower
|
|
|
|
* bound.
|
|
|
|
*/
|
|
|
|
#define NFS_MINRTO (NFS_HZ >> 2)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Keep the RTO from increasing to unreasonably large values
|
|
|
|
* when a server is not responding.
|
|
|
|
*/
|
|
|
|
#define NFS_MAXRTO (20 * NFS_HZ)
|
|
|
|
|
|
|
|
enum nfs_rto_timer_t {
|
|
|
|
NFS_DEFAULT_TIMER,
|
|
|
|
NFS_GETATTR_TIMER,
|
|
|
|
NFS_LOOKUP_TIMER,
|
|
|
|
NFS_READ_TIMER,
|
|
|
|
NFS_WRITE_TIMER,
|
|
|
|
};
|
|
|
|
#define NFS_MAX_TIMER (NFS_WRITE_TIMER)
|
|
|
|
|
|
|
|
#define NFS_INITRTT (NFS_HZ << 3)
|
|
|
|
|
2002-08-13 10:05:50 +00:00
|
|
|
vfs_init_t nfs_init;
|
|
|
|
vfs_uninit_t nfs_uninit;
|
2009-05-11 15:33:26 +00:00
|
|
|
int nfs_mountroot(struct mount *mp);
|
2003-11-14 20:54:10 +00:00
|
|
|
|
Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.
The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.
To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.
As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.
Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.
The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.
Sponsored by: Isilon Systems
MFC after: 1 month
2008-11-03 10:38:00 +00:00
|
|
|
#ifdef NFS_LEGACYRPC
|
2003-11-14 20:54:10 +00:00
|
|
|
#ifndef NFS4_USE_RPCCLNT
|
2001-09-18 23:32:09 +00:00
|
|
|
int nfs_send(struct socket *, struct sockaddr *, struct mbuf *,
|
|
|
|
struct nfsreq *);
|
2007-10-12 19:12:21 +00:00
|
|
|
int nfs_connect_lock(struct nfsreq *);
|
|
|
|
void nfs_connect_unlock(struct nfsreq *);
|
Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.
The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.
To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.
As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.
Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.
The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.
Sponsored by: Isilon Systems
MFC after: 1 month
2008-11-03 10:38:00 +00:00
|
|
|
void nfs_up(struct nfsreq *, struct nfsmount *, struct thread *,
|
|
|
|
const char *, int);
|
|
|
|
void nfs_down(struct nfsreq *, struct nfsmount *, struct thread *,
|
|
|
|
const char *, int, int);
|
2003-11-14 20:54:10 +00:00
|
|
|
#endif /* ! NFS4_USE_RPCCLNT */
|
Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.
The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.
To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.
As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.
Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.
The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.
Sponsored by: Isilon Systems
MFC after: 1 month
2008-11-03 10:38:00 +00:00
|
|
|
#endif
|
2003-11-14 20:54:10 +00:00
|
|
|
|
2009-04-06 21:11:08 +00:00
|
|
|
void nfs_purgecache(struct vnode *);
|
2005-01-24 12:31:06 +00:00
|
|
|
int nfs_vinvalbuf(struct vnode *, int, struct thread *, int);
|
2001-09-18 23:32:09 +00:00
|
|
|
int nfs_readrpc(struct vnode *, struct uio *, struct ucred *);
|
|
|
|
int nfs_writerpc(struct vnode *, struct uio *, struct ucred *, int *,
|
|
|
|
int *);
|
|
|
|
int nfs_commit(struct vnode *vp, u_quad_t offset, int cnt,
|
|
|
|
struct ucred *cred, struct thread *td);
|
|
|
|
int nfs_readdirrpc(struct vnode *, struct uio *, struct ucred *);
|
2002-01-14 02:13:46 +00:00
|
|
|
int nfs_nfsiodnew(void);
|
2004-09-07 08:56:43 +00:00
|
|
|
int nfs_asyncio(struct nfsmount *, struct buf *, struct ucred *, struct thread *);
|
2004-09-27 19:44:39 +00:00
|
|
|
int nfs_doio(struct vnode *, struct buf *, struct ucred *, struct thread *);
|
2006-10-17 22:07:07 +00:00
|
|
|
void nfs_doio_directwrite (struct buf *);
|
2001-09-18 23:32:09 +00:00
|
|
|
int nfs_readlinkrpc(struct vnode *, struct uio *, struct ucred *);
|
2002-06-28 21:53:08 +00:00
|
|
|
int nfs_sigintr(struct nfsmount *, struct nfsreq *, struct thread *);
|
2001-09-18 23:32:09 +00:00
|
|
|
int nfs_readdirplusrpc(struct vnode *, struct uio *, struct ucred *);
|
|
|
|
int nfs_request(struct vnode *, struct mbuf *, int, struct thread *,
|
|
|
|
struct ucred *, struct mbuf **, struct mbuf **, caddr_t *);
|
|
|
|
int nfs_loadattrcache(struct vnode **, struct mbuf **, caddr_t *,
|
|
|
|
struct vattr *, int);
|
|
|
|
int nfsm_mbuftouio(struct mbuf **, struct uio *, int, caddr_t *);
|
|
|
|
void nfs_nhinit(void);
|
2004-04-11 13:30:20 +00:00
|
|
|
void nfs_nhuninit(void);
|
2002-01-02 00:41:26 +00:00
|
|
|
int nfs_nmcancelreqs(struct nfsmount *);
|
2001-09-18 23:32:09 +00:00
|
|
|
void nfs_timer(void*);
|
2003-11-14 20:54:10 +00:00
|
|
|
|
2001-09-18 23:32:09 +00:00
|
|
|
int nfs_connect(struct nfsmount *, struct nfsreq *);
|
|
|
|
void nfs_disconnect(struct nfsmount *);
|
|
|
|
void nfs_safedisconnect(struct nfsmount *);
|
|
|
|
int nfs_getattrcache(struct vnode *, struct vattr *);
|
2007-01-25 13:07:25 +00:00
|
|
|
int nfs_iosize(struct nfsmount *nmp);
|
2001-09-18 23:32:09 +00:00
|
|
|
int nfsm_strtmbuf(struct mbuf **, char **, const char *, long);
|
|
|
|
int nfs_bioread(struct vnode *, struct uio *, int, struct ucred *);
|
|
|
|
int nfsm_uiotombuf(struct uio *, struct mbuf **, int, caddr_t *);
|
|
|
|
void nfs_clearcommit(struct mount *);
|
|
|
|
int nfs_writebp(struct buf *, int, struct thread *);
|
|
|
|
int nfs_fsinfo(struct nfsmount *, struct vnode *, struct ucred *,
|
|
|
|
struct thread *);
|
2001-12-14 01:16:57 +00:00
|
|
|
int nfs_meta_setsize (struct vnode *, struct ucred *,
|
|
|
|
struct thread *, u_quad_t);
|
2001-09-18 23:32:09 +00:00
|
|
|
|
2006-10-17 22:07:07 +00:00
|
|
|
void nfs_set_sigmask(struct thread *td, sigset_t *oldset);
|
|
|
|
void nfs_restore_sigmask(struct thread *td, sigset_t *set);
|
|
|
|
int nfs_msleep(struct thread *td, void *ident, struct mtx *mtx,
|
|
|
|
int priority, char *wmesg, int timo);
|
2004-12-06 21:11:15 +00:00
|
|
|
|
1999-12-29 05:07:58 +00:00
|
|
|
#endif /* _KERNEL */
|
1994-08-21 06:50:16 +00:00
|
|
|
|
|
|
|
#endif
|