Changeset View
Changeset View
Standalone View
Standalone View
sys/fs/nfsserver/nfs_nfsdsubs.c
Show All 38 Lines | |||||
/* | /* | ||||
* These functions support the macros and help fiddle mbuf chains for | * These functions support the macros and help fiddle mbuf chains for | ||||
* the nfs op functions. They do things like create the rpc header and | * the nfs op functions. They do things like create the rpc header and | ||||
* copy data between mbuf chains and uio lists. | * copy data between mbuf chains and uio lists. | ||||
*/ | */ | ||||
#include <fs/nfs/nfsport.h> | #include <fs/nfs/nfsport.h> | ||||
extern u_int32_t newnfs_true, newnfs_false; | extern u_int32_t newnfs_true, newnfs_false; | ||||
extern int nfs_rootfhset; | |||||
extern int nfs_pubfhset; | extern int nfs_pubfhset; | ||||
extern struct nfsclienthashhead *nfsclienthash; | |||||
extern int nfsrv_clienthashsize; | extern int nfsrv_clienthashsize; | ||||
extern struct nfslockhashhead *nfslockhash; | |||||
extern int nfsrv_lockhashsize; | extern int nfsrv_lockhashsize; | ||||
extern struct nfssessionhash *nfssessionhash; | |||||
extern int nfsrv_sessionhashsize; | extern int nfsrv_sessionhashsize; | ||||
extern int nfsrv_useacl; | extern int nfsrv_useacl; | ||||
extern uid_t nfsrv_defaultuid; | extern uid_t nfsrv_defaultuid; | ||||
extern gid_t nfsrv_defaultgid; | extern gid_t nfsrv_defaultgid; | ||||
VNET_DECLARE(struct nfsclienthashhead *, nfsclienthash); | |||||
VNET_DECLARE(struct nfslockhashhead *, nfslockhash); | |||||
VNET_DECLARE(struct nfssessionhash *, nfssessionhash); | |||||
VNET_DECLARE(int, nfs_rootfhset); | |||||
VNET_DEFINE(struct nfsdontlisthead, nfsrv_dontlisthead); | |||||
char nfs_v2pubfh[NFSX_V2FH]; | char nfs_v2pubfh[NFSX_V2FH]; | ||||
struct nfsdontlisthead nfsrv_dontlisthead; | |||||
struct nfslayouthead nfsrv_recalllisthead; | struct nfslayouthead nfsrv_recalllisthead; | ||||
static nfstype newnfsv2_type[9] = { NFNON, NFREG, NFDIR, NFBLK, NFCHR, NFLNK, | static nfstype newnfsv2_type[9] = { NFNON, NFREG, NFDIR, NFBLK, NFCHR, NFLNK, | ||||
NFNON, NFCHR, NFNON }; | NFNON, NFCHR, NFNON }; | ||||
extern nfstype nfsv34_type[9]; | extern nfstype nfsv34_type[9]; | ||||
static u_int32_t nfsrv_isannfserr(u_int32_t); | static u_int32_t nfsrv_isannfserr(u_int32_t); | ||||
SYSCTL_DECL(_vfs_nfsd); | SYSCTL_DECL(_vfs_nfsd); | ||||
▲ Show 20 Lines • Show All 2,006 Lines • ▼ Show 20 Lines | nfsmout: | ||||
NFSEXITCODE2(error, nd); | NFSEXITCODE2(error, nd); | ||||
return (error); | return (error); | ||||
} | } | ||||
void | void | ||||
nfsd_init(void) | nfsd_init(void) | ||||
{ | { | ||||
int i; | int i; | ||||
static int inited = 0; | |||||
if (inited) | |||||
return; | |||||
inited = 1; | |||||
/* | /* | ||||
* Initialize client queues. Don't free/reinitialize | * Initialize client queues. Don't free/reinitialize | ||||
* them when nfsds are restarted. | * them when nfsds are restarted. | ||||
*/ | */ | ||||
nfsclienthash = malloc(sizeof(struct nfsclienthashhead) * | VNET(nfsclienthash) = malloc(sizeof(struct nfsclienthashhead) * | ||||
nfsrv_clienthashsize, M_NFSDCLIENT, M_WAITOK | M_ZERO); | nfsrv_clienthashsize, M_NFSDCLIENT, M_WAITOK | M_ZERO); | ||||
for (i = 0; i < nfsrv_clienthashsize; i++) | for (i = 0; i < nfsrv_clienthashsize; i++) | ||||
LIST_INIT(&nfsclienthash[i]); | LIST_INIT(&VNET(nfsclienthash)[i]); | ||||
nfslockhash = malloc(sizeof(struct nfslockhashhead) * | VNET(nfslockhash) = malloc(sizeof(struct nfslockhashhead) * | ||||
nfsrv_lockhashsize, M_NFSDLOCKFILE, M_WAITOK | M_ZERO); | nfsrv_lockhashsize, M_NFSDLOCKFILE, M_WAITOK | M_ZERO); | ||||
for (i = 0; i < nfsrv_lockhashsize; i++) | for (i = 0; i < nfsrv_lockhashsize; i++) | ||||
LIST_INIT(&nfslockhash[i]); | LIST_INIT(&VNET(nfslockhash)[i]); | ||||
nfssessionhash = malloc(sizeof(struct nfssessionhash) * | VNET(nfssessionhash) = malloc(sizeof(struct nfssessionhash) * | ||||
nfsrv_sessionhashsize, M_NFSDSESSION, M_WAITOK | M_ZERO); | nfsrv_sessionhashsize, M_NFSDSESSION, M_WAITOK | M_ZERO); | ||||
for (i = 0; i < nfsrv_sessionhashsize; i++) { | for (i = 0; i < nfsrv_sessionhashsize; i++) { | ||||
mtx_init(&nfssessionhash[i].mtx, "nfssm", NULL, MTX_DEF); | mtx_init(&VNET(nfssessionhash)[i].mtx, "nfssm", NULL, MTX_DEF); | ||||
LIST_INIT(&nfssessionhash[i].list); | LIST_INIT(&VNET(nfssessionhash)[i].list); | ||||
} | } | ||||
LIST_INIT(&nfsrv_dontlisthead); | LIST_INIT(&VNET(nfsrv_dontlisthead)); | ||||
TAILQ_INIT(&nfsrv_recalllisthead); | TAILQ_INIT(&nfsrv_recalllisthead); | ||||
/* and the v2 pubfh should be all zeros */ | /* and the v2 pubfh should be all zeros */ | ||||
NFSBZERO(nfs_v2pubfh, NFSX_V2FH); | NFSBZERO(nfs_v2pubfh, NFSX_V2FH); | ||||
} | } | ||||
/* | /* | ||||
* Check the v4 root exports. | * Check the v4 root exports. | ||||
* Return 0 if ok, 1 otherwise. | * Return 0 if ok, 1 otherwise. | ||||
*/ | */ | ||||
int | int | ||||
nfsd_checkrootexp(struct nfsrv_descript *nd) | nfsd_checkrootexp(struct nfsrv_descript *nd) | ||||
{ | { | ||||
if (nfs_rootfhset == 0) | if (VNET(nfs_rootfhset) == 0) | ||||
return (NFSERR_AUTHERR | AUTH_FAILED); | return (NFSERR_AUTHERR | AUTH_FAILED); | ||||
if ((nd->nd_flag & (ND_GSS | ND_EXAUTHSYS)) == ND_EXAUTHSYS) | if ((nd->nd_flag & (ND_GSS | ND_EXAUTHSYS)) == ND_EXAUTHSYS) | ||||
goto checktls; | goto checktls; | ||||
if ((nd->nd_flag & (ND_GSSINTEGRITY | ND_EXGSSINTEGRITY)) == | if ((nd->nd_flag & (ND_GSSINTEGRITY | ND_EXGSSINTEGRITY)) == | ||||
(ND_GSSINTEGRITY | ND_EXGSSINTEGRITY)) | (ND_GSSINTEGRITY | ND_EXGSSINTEGRITY)) | ||||
goto checktls; | goto checktls; | ||||
if ((nd->nd_flag & (ND_GSSPRIVACY | ND_EXGSSPRIVACY)) == | if ((nd->nd_flag & (ND_GSSPRIVACY | ND_EXGSSPRIVACY)) == | ||||
(ND_GSSPRIVACY | ND_EXGSSPRIVACY)) | (ND_GSSPRIVACY | ND_EXGSSPRIVACY)) | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |