svn commit: r221014 - in head/sys: fs/nfs fs/nfsclient nfsclient

Rick Macklem rmacklem at FreeBSD.org
Mon Apr 25 13:09:33 UTC 2011


Author: rmacklem
Date: Mon Apr 25 13:09:32 2011
New Revision: 221014
URL: http://svn.freebsd.org/changeset/base/221014

Log:
  Modify the experimental NFS client so that it uses the same
  "struct nfs_args" as the regular NFS client. This is needed
  so that the old mount(2) syscall will work and it makes
  sharing of the diskless NFS root code easier. Eary in the
  porting exercise I introduced a new revision of nfs_args, but
  didn't actually need it, thanks to nmount(2). I re-introduced the
  NFSMNT_KERB flag, since it does essentially the same thing and
  the old one would not have been used because it never worked.
  I also added a few new NFSMNT_xxx flags to sys/nfsclient/nfs_args.h
  that are used by the experimental NFS client.
  
  MFC after:	2 weeks

Deleted:
  head/sys/fs/nfsclient/nfsargs.h
Modified:
  head/sys/fs/nfs/nfsport.h
  head/sys/fs/nfsclient/nfs_clvfsops.c
  head/sys/nfsclient/nfsargs.h

Modified: head/sys/fs/nfs/nfsport.h
==============================================================================
--- head/sys/fs/nfs/nfsport.h	Mon Apr 25 12:36:29 2011	(r221013)
+++ head/sys/fs/nfs/nfsport.h	Mon Apr 25 13:09:32 2011	(r221014)
@@ -372,7 +372,7 @@ struct ext_nfsstats {
 #include <fs/nfs/xdr_subs.h>
 #include <fs/nfs/nfscl.h>
 #include <fs/nfs/nfsclstate.h>
-#include <fs/nfsclient/nfsargs.h>
+#include <nfsclient/nfsargs.h>
 #include <fs/nfsclient/nfsmount.h>
 
 /*

Modified: head/sys/fs/nfsclient/nfs_clvfsops.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clvfsops.c	Mon Apr 25 12:36:29 2011	(r221013)
+++ head/sys/fs/nfsclient/nfs_clvfsops.c	Mon Apr 25 13:09:32 2011	(r221014)
@@ -102,8 +102,9 @@ static void	nfs_decode_args(struct mount
 		    struct nfs_args *argp, const char *, struct ucred *,
 		    struct thread *);
 static int	mountnfs(struct nfs_args *, struct mount *,
-		    struct sockaddr *, char *, u_char *, u_char *, u_char *,
-		    struct vnode **, struct ucred *, struct thread *, int);
+		    struct sockaddr *, char *, u_char *, int, u_char *, int,
+		    u_char *, int, struct vnode **, struct ucred *,
+		    struct thread *, int);
 static void	nfs_getnlminfo(struct vnode *, uint8_t *, size_t *,
 		    struct sockaddr_storage *, int *, off_t *,
 		    struct timeval *);
@@ -503,11 +504,21 @@ nfs_mountdiskless(char *path,
     struct vnode **vpp, struct mount *mp)
 {
 	struct sockaddr *nam;
-	int error;
+	int dirlen, error;
+	char *dirpath;
 
+	/*
+	 * Find the directory path in "path", which also has the server's
+	 * name/ip address in it.
+	 */
+	dirpath = strchr(path, ':');
+	if (dirpath != NULL)
+		dirlen = strlen(++dirpath);
+	else
+		dirlen = 0;
 	nam = sodupsockaddr((struct sockaddr *)sin, M_WAITOK);
-	if ((error = mountnfs(args, mp, nam, path, NULL, NULL, NULL, vpp,
-	    td->td_ucred, td, NFS_DEFAULT_NEGNAMETIMEO)) != 0) {
+	if ((error = mountnfs(args, mp, nam, path, NULL, 0, dirpath, dirlen,
+	    NULL, 0, vpp, td->td_ucred, td, NFS_DEFAULT_NEGNAMETIMEO)) != 0) {
 		printf("nfs_mountroot: mount %s on /: %d\n", path, error);
 		return (error);
 	}
@@ -735,14 +746,10 @@ nfs_mount(struct mount *mp)
 	    .readahead = NFS_DEFRAHEAD,
 	    .wcommitsize = 0,			/* was: NQ_DEFLEASE */
 	    .hostname = NULL,
-	    /* args version 4 */
 	    .acregmin = NFS_MINATTRTIMO,
 	    .acregmax = NFS_MAXATTRTIMO,
 	    .acdirmin = NFS_MINDIRATTRTIMO,
 	    .acdirmax = NFS_MAXDIRATTRTIMO,
-	    .dirlen = 0,
-	    .krbnamelen = 0,
-	    .srvkrbnamelen = 0,
 	};
 	int error = 0, ret, len;
 	struct sockaddr *nam = NULL;
@@ -752,6 +759,7 @@ nfs_mount(struct mount *mp)
 	u_char nfh[NFSX_FHMAX], krbname[100], dirpath[100], srvkrbname[100];
 	char *opt, *name, *secname;
 	int negnametimeo = NFS_DEFAULT_NEGNAMETIMEO;
+	int dirlen, krbnamelen, srvkrbnamelen;
 
 	if (vfs_filteropt(mp->mnt_optnew, nfs_opts)) {
 		error = EINVAL;
@@ -1008,19 +1016,19 @@ nfs_mount(struct mount *mp)
 		strlcpy(srvkrbname, name, sizeof (srvkrbname));
 	else
 		snprintf(srvkrbname, sizeof (srvkrbname), "nfs@%s", hst);
-	args.srvkrbnamelen = strlen(srvkrbname);
+	srvkrbnamelen = strlen(srvkrbname);
 
 	if (vfs_getopt(mp->mnt_optnew, "gssname", (void **)&name, NULL) == 0)
 		strlcpy(krbname, name, sizeof (krbname));
 	else
 		krbname[0] = '\0';
-	args.krbnamelen = strlen(krbname);
+	krbnamelen = strlen(krbname);
 
 	if (vfs_getopt(mp->mnt_optnew, "dirpath", (void **)&name, NULL) == 0)
 		strlcpy(dirpath, name, sizeof (dirpath));
 	else
 		dirpath[0] = '\0';
-	args.dirlen = strlen(dirpath);
+	dirlen = strlen(dirpath);
 
 	if (vfs_getopt(mp->mnt_optnew, "addr", (void **)&args.addr,
 	    &args.addrlen) == 0) {
@@ -1034,8 +1042,9 @@ nfs_mount(struct mount *mp)
 	}
 
 	args.fh = nfh;
-	error = mountnfs(&args, mp, nam, hst, krbname, dirpath, srvkrbname,
-	    &vp, td->td_ucred, td, negnametimeo);
+	error = mountnfs(&args, mp, nam, hst, krbname, krbnamelen, dirpath,
+	    dirlen, srvkrbname, srvkrbnamelen, &vp, td->td_ucred, td,
+	    negnametimeo);
 out:
 	if (!error) {
 		MNT_ILOCK(mp);
@@ -1077,9 +1086,9 @@ nfs_cmount(struct mntarg *ma, void *data
  */
 static int
 mountnfs(struct nfs_args *argp, struct mount *mp, struct sockaddr *nam,
-    char *hst, u_char *krbname, u_char *dirpath, u_char *srvkrbname,
-    struct vnode **vpp, struct ucred *cred, struct thread *td,
-    int negnametimeo)
+    char *hst, u_char *krbname, int krbnamelen, u_char *dirpath, int dirlen,
+    u_char *srvkrbname, int srvkrbnamelen, struct vnode **vpp,
+    struct ucred *cred, struct thread *td, int negnametimeo)
 {
 	struct nfsmount *nmp;
 	struct nfsnode *np;
@@ -1094,17 +1103,15 @@ mountnfs(struct nfs_args *argp, struct m
 		return (0);
 	} else {
 		MALLOC(nmp, struct nfsmount *, sizeof (struct nfsmount) +
-		    argp->krbnamelen + argp->dirlen + argp->srvkrbnamelen + 2,
-		    M_NEWNFSMNT, M_WAITOK);
-		bzero((caddr_t)nmp, sizeof (struct nfsmount) +
-		    argp->krbnamelen + argp->dirlen + argp->srvkrbnamelen + 2);
+		    krbnamelen + dirlen + srvkrbnamelen + 2,
+		    M_NEWNFSMNT, M_WAITOK | M_ZERO);
 		TAILQ_INIT(&nmp->nm_bufq);
 		if (clval == 0)
 			clval = (u_int64_t)nfsboottime.tv_sec;
 		nmp->nm_clval = clval++;
-		nmp->nm_krbnamelen = argp->krbnamelen;
-		nmp->nm_dirpathlen = argp->dirlen;
-		nmp->nm_srvkrbnamelen = argp->srvkrbnamelen;
+		nmp->nm_krbnamelen = krbnamelen;
+		nmp->nm_dirpathlen = dirlen;
+		nmp->nm_srvkrbnamelen = srvkrbnamelen;
 		if (td->td_ucred->cr_uid != (uid_t)0) {
 			/*
 			 * nm_uid is used to get KerberosV credentials for

Modified: head/sys/nfsclient/nfsargs.h
==============================================================================
--- head/sys/nfsclient/nfsargs.h	Mon Apr 25 12:36:29 2011	(r221013)
+++ head/sys/nfsclient/nfsargs.h	Mon Apr 25 13:09:32 2011	(r221014)
@@ -78,7 +78,7 @@ struct nfs_args {
 #define	NFSMNT_NOCONN		0x00000080  /* Don't Connect the socket */
 /* 0x100 free, was NFSMNT_NQNFS */
 #define	NFSMNT_NFSV3		0x00000200  /* Use NFS Version 3 protocol */
-/* 0x400 free, was NFSMNT_KERB */
+#define	NFSMNT_KERB		0x00000400  /* Use RPCSEC_GSS/Krb5 */
 #define	NFSMNT_DUMBTIMR		0x00000800  /* Don't estimate rtt dynamically */
 #define	NFSMNT_WCOMMITSIZE	0x00001000  /* set max write commit size */
 #define	NFSMNT_READAHEAD	0x00002000  /* set read ahead */
@@ -93,5 +93,9 @@ struct nfs_args {
 #define	NFSMNT_NOLOCKD		0x00400000 /* Locks are local */
 #define	NFSMNT_NFSV4		0x00800000 /* Use NFS Version 4 protocol */
 #define	NFSMNT_HASWRITEVERF	0x01000000 /* NFSv4 Write verifier */
+#define	NFSMNT_INTEGRITY	0x02000000 /* Use integrity with RPCSEC_GSS */
+#define	NFSMNT_PRIVACY		0x04000000 /* Use privacy with RPCSEC_GSS */
+#define	NFSMNT_ALLGSSNAME	0x08000000 /* Use principal for all accesses */
+#define	NFSMNT_STRICT3530	0x10000000 /* Adhere strictly to RFC3530 */
 
 #endif


More information about the svn-src-head mailing list