Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 May 2009 17:09:32 GMT
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 162657 for review
Message-ID:  <200905241709.n4OH9Wtx076730@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=162657

Change 162657 by trasz@trasz_victim on 2009/05/24 17:08:47

	IFC.

Affected files ...

.. //depot/projects/soc2008/trasz_nfs4acl/UPDATING#28 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/bin/chflags/chflags.c#2 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/bin/ps/print.c#5 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libstand/stand.h#4 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/share/man/man9/acl.9#6 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/sys/arm/xscale/ixp425/if_npe.c#6 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c#20 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/sys/fs/nfs/nfs_commonkrpc.c#4 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/sys/fs/nfsclient/nfs_clvfsops.c#3 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/sys/fs/nwfs/nwfs_io.c#4 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/sys/kern/kern_lockf.c#5 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/sys/kern/kern_vimage.c#7 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/sys/kern/tty.c#22 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/sys/kgssapi/gsstest.c#3 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/sys/mips/mips/pmap.c#12 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/sys/net/if_clone.c#4 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/sys/net/if_loop.c#12 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/sys/net/vnet.h#8 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/sys/nfsclient/nfs_krpc.c#6 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/sys/nfsserver/nfs_srvkrpc.c#5 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/sys/sys/lockf.h#3 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/sys/sys/param.h#26 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/sys/sys/vimage.h#11 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/tools/tools/README#5 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/tools/tools/nanobsd/gateworks/common#3 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/tools/tools/npe/Makefile#1 branch
.. //depot/projects/soc2008/trasz_nfs4acl/tools/tools/npe/npestats/Makefile#1 branch
.. //depot/projects/soc2008/trasz_nfs4acl/tools/tools/npe/npestats/main.c#1 branch
.. //depot/projects/soc2008/trasz_nfs4acl/tools/tools/npe/npestats/npestats.c#1 branch
.. //depot/projects/soc2008/trasz_nfs4acl/tools/tools/npe/npestats/npestats.h#1 branch
.. //depot/projects/soc2008/trasz_nfs4acl/tools/tools/npe/npestats/statfoo.c#1 branch
.. //depot/projects/soc2008/trasz_nfs4acl/tools/tools/npe/npestats/statfoo.h#1 branch
.. //depot/projects/soc2008/trasz_nfs4acl/usr.sbin/nfsd/Makefile#2 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/usr.sbin/nfsd/nfsd.8#2 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/usr.sbin/nfsd/nfsd.c#3 integrate
.. //depot/projects/soc2008/trasz_nfs4acl/usr.sbin/nfsd/nfsv4.4#1 branch
.. //depot/projects/soc2008/trasz_nfs4acl/usr.sbin/nfsd/stablerestart.5#1 branch

Differences ...

==== //depot/projects/soc2008/trasz_nfs4acl/UPDATING#28 (text+ko) ====

@@ -23,6 +23,11 @@
 	ln -s aj /etc/malloc.conf.)
 
 20090523:
+	The layout of struct vnet_net has changed, therefore modules
+	need to be rebuilt.
+	Bump __FreeBSD_version to 800090.
+
+20090523:
 	The newly imported zic(8) produces a new format in the
 	output. Please run tzsetup(8) to install the newly created
 	data to /etc/localtime.
@@ -1530,4 +1535,4 @@
 Contact Warner Losh if you have any questions about your use of
 this document.
 
-$FreeBSD: src/UPDATING,v 1.603 2009/05/23 09:24:07 joel Exp $
+$FreeBSD: src/UPDATING,v 1.604 2009/05/23 21:43:44 zec Exp $

==== //depot/projects/soc2008/trasz_nfs4acl/bin/chflags/chflags.c#2 (text+ko) ====

@@ -40,7 +40,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/bin/chflags/chflags.c,v 1.24 2008/03/09 12:10:24 rwatson Exp $");
+__FBSDID("$FreeBSD: src/bin/chflags/chflags.c,v 1.25 2009/05/24 15:27:25 jilles Exp $");
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -115,7 +115,7 @@
 			fts_options |= FTS_LOGICAL;
 		}
 	} else
-		fts_options = FTS_LOGICAL;
+		fts_options = hflag ? FTS_PHYSICAL : FTS_LOGICAL;
 
 	/* XXX: Why don't chflags and lchflags have compatible prototypes? */
 	if (hflag)

==== //depot/projects/soc2008/trasz_nfs4acl/bin/ps/print.c#5 (text+ko) ====

@@ -34,7 +34,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/bin/ps/print.c,v 1.99 2009/05/17 04:00:43 brian Exp $");
+__FBSDID("$FreeBSD: src/bin/ps/print.c,v 1.100 2009/05/24 15:32:34 jilles Exp $");
 
 #include <sys/param.h>
 #include <sys/time.h>
@@ -596,6 +596,10 @@
 	char obuff[128];
 
 	v = ve->var;
+	if (!k->ki_valid) {
+		(void)printf("%-*s", v->width, "-");
+		return;
+	}
 	val = now - k->ki_p->ki_start.tv_sec;
 	days = val / (24 * 60 * 60);
 	val %= 24 * 60 * 60;

==== //depot/projects/soc2008/trasz_nfs4acl/lib/libstand/stand.h#4 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libstand/stand.h,v 1.44 2008/11/06 16:30:32 raj Exp $
+ * $FreeBSD: src/lib/libstand/stand.h,v 1.45 2009/05/24 11:37:10 dfr Exp $
  * From	$NetBSD: stand.h,v 1.22 1997/06/26 19:17:40 drochner Exp $	
  */
 
@@ -167,7 +167,7 @@
 #define SOPEN_RASIZE	512
 };
 
-#define	SOPEN_MAX	8
+#define	SOPEN_MAX	64
 extern struct open_file files[];
 
 /* f_flags values */

==== //depot/projects/soc2008/trasz_nfs4acl/share/man/man9/acl.9#6 (text+ko) ====

@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: src/share/man/man9/acl.9,v 1.16 2009/04/11 10:37:04 trasz Exp $
+.\" $FreeBSD: src/share/man/man9/acl.9,v 1.17 2009/05/24 09:42:53 trasz Exp $
 .\"
 .Dd December 23, 1999
 .Os
@@ -59,7 +59,9 @@
 structure, defined as follows:
 .Bd -literal -offset indent
 struct acl {
-        int                     acl_cnt;
+        unsigned int            acl_maxcnt;
+        unsigned int            acl_cnt;
+        int                     acl_spare[4];
         struct acl_entry        acl_entry[ACL_MAX_ENTRIES];
 };
 .Ed
@@ -67,6 +69,10 @@
 An ACL is constructed from a fixed size array of ACL entries,
 each of which consists of a set of permissions, principal namespace,
 and principal identifier.
+In this implementation, the
+.Vt acl_maxcnt
+field is always set to
+.Dv ACL_MAX_ENTRIES .
 .Pp
 Each individual ACL entry is of the type
 .Vt acl_entry_t ,
@@ -107,7 +113,7 @@
 .Dv ACL_OTHER .
 .It Dv ACL_EVERYONE
 Discretionary access rights for all users.
-This is only valid for NFS4 ACLs.
+This is only valid for NFSv4 ACLs.
 .El
 .Pp
 Each POSIX.1e ACL must contain exactly one
@@ -126,6 +132,12 @@
 entry should be present.
 .It Vt uid_t Va ae_id
 The ID of user for whom this ACL describes access permissions.
+For entries other than
+.Dv ACL_USER
+and
+.Dv ACL_GROUP ,
+this field should be set to
+.Dv ACL_UNDEFINED_ID .
 .It Vt acl_perm_t Va ae_perm
 This field defines what kind of access the process matching this ACL has
 for accessing the associated file.
@@ -142,13 +154,15 @@
 to the associated file.
 .El
 .Pp
-For NFS4 ACLs, the following are valid:
+For NFSv4 ACLs, the following are valid:
 .Bl -tag -width ".Dv ACL_WRITE_NAMED_ATTRS"
 .It Dv ACL_READ_DATA
+The process may read from the associated file.
 .It Dv ACL_LIST_DIRECTORY
 Same as
 .Dv ACL_READ_DATA .
 .It Dv ACL_WRITE_DATA
+The process may write to the associated file.
 .It Dv ACL_ADD_FILE
 Same as
 .Dv ACL_ACL_WRITE_DATA .
@@ -157,8 +171,11 @@
 Same as
 .Dv ACL_APPEND_DATA .
 .It Dv ACL_READ_NAMED_ATTRS
+Ignored.
 .It Dv ACL_WRITE_NAMED_ATTRS
+Ignored.
 .It Dv ACL_EXECUTE
+The process may execute the associated file.
 .It Dv ACL_DELETE_CHILD
 .It Dv ACL_READ_ATTRIBUTES
 .It Dv ACL_WRITE_ATTRIBUTES
@@ -167,17 +184,18 @@
 .It Dv ACL_WRITE_ACL
 .It Dv ACL_WRITE_OWNER
 .It Dv ACL_SYNCHRONIZE
+Ignored.
 .El
-.It Vt acl_extended_t Va ae_extended
-This field defines the type of NFS4 ACL entry.
+.It Vt acl_entry_type_t Va ae_entry_type
+This field defines the type of NFSv4 ACL entry.
 It is not used with POSIX.1e ACLs.
 The following values are valid:
 .Bl -tag -width ".Dv ACL_WRITE_NAMED_ATTRS"
-.It Dv ACL_EXTENDED_ALLOW
-.It Dv ACL_EXTENDED_DENY
+.It Dv ACL_ENTRY_TYPE_ALLOW
+.It Dv ACL_ENTRY_TYPE_DENY
 .El
 .It Vt acl_flag_t Va ae_flags
-This field defines the inheritance flags of NFS4 ACL entry.
+This field defines the inheritance flags of NFSv4 ACL entry.
 It is not used with POSIX.1e ACLs.
 The following values are valid:
 .Bl -tag -width ".Dv ACL_ENTRY_DIRECTORY_INHERIT"

==== //depot/projects/soc2008/trasz_nfs4acl/sys/arm/xscale/ixp425/if_npe.c#6 (text+ko) ====

@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/arm/xscale/ixp425/if_npe.c,v 1.14 2009/03/10 19:35:37 sam Exp $");
+__FBSDID("$FreeBSD: src/sys/arm/xscale/ixp425/if_npe.c,v 1.15 2009/05/23 19:14:20 sam Exp $");
 
 /*
  * Intel XScale NPE Ethernet driver.
@@ -143,6 +143,7 @@
 	struct npestats	*sc_stats;
 	bus_dmamap_t	sc_stats_map;
 	bus_addr_t	sc_stats_phys;	/* phys addr of sc_stats */
+	struct npestats	sc_totals;	/* accumulated sc_stats */
 };
 
 /*
@@ -374,6 +375,8 @@
 	    CTLFLAG_RW, &sc->sc_debug, 0, "control debugging printfs");
 	SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "tickinterval",
 	    CTLFLAG_RW, &sc->sc_tickinterval, 0, "periodic work frequency");
+	SYSCTL_ADD_STRUCT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "stats",
+	    CTLFLAG_RD, &sc->sc_totals, npestats, "onboard stats");
 
 	ether_ifattach(ifp, eaddr);
 	return 0;
@@ -867,12 +870,24 @@
 static void
 npe_addstats(struct npe_softc *sc)
 {
-#define	MIBADD(x)	sc->mibdata.x += be32toh(ns->x)
+#define	NPEADD(x)	sc->sc_totals.x += be32toh(ns->x)
+#define	MIBADD(x) do { sc->mibdata.x += be32toh(ns->x); NPEADD(x); } while (0)
 	struct ifnet *ifp = sc->sc_ifp;
 	struct npestats *ns = sc->sc_stats;
 
 	MIBADD(dot3StatsAlignmentErrors);
 	MIBADD(dot3StatsFCSErrors);
+	MIBADD(dot3StatsInternalMacReceiveErrors);
+	NPEADD(RxOverrunDiscards);
+	NPEADD(RxLearnedEntryDiscards);
+	NPEADD(RxLargeFramesDiscards);
+	NPEADD(RxSTPBlockedDiscards);
+	NPEADD(RxVLANTypeFilterDiscards);
+	NPEADD(RxVLANIdFilterDiscards);
+	NPEADD(RxInvalidSourceDiscards);
+	NPEADD(RxBlackListDiscards);
+	NPEADD(RxWhiteListDiscards);
+	NPEADD(RxUnderflowEntryDiscards);
 	MIBADD(dot3StatsSingleCollisionFrames);
 	MIBADD(dot3StatsMultipleCollisionFrames);
 	MIBADD(dot3StatsDeferredTransmissions);
@@ -880,10 +895,12 @@
 	MIBADD(dot3StatsExcessiveCollisions);
 	MIBADD(dot3StatsInternalMacTransmitErrors);
 	MIBADD(dot3StatsCarrierSenseErrors);
+	NPEADD(TxLargeFrameDiscards);
+	NPEADD(TxVLANIdFilterDiscards);
+
 	sc->mibdata.dot3StatsFrameTooLongs +=
 	      be32toh(ns->RxLargeFramesDiscards)
 	    + be32toh(ns->TxLargeFrameDiscards);
-	MIBADD(dot3StatsInternalMacReceiveErrors);
 	sc->mibdata.dot3StatsMissedFrames +=
 	      be32toh(ns->RxOverrunDiscards)
 	    + be32toh(ns->RxUnderflowEntryDiscards);
@@ -902,6 +919,7 @@
 		  be32toh(ns->dot3StatsSingleCollisionFrames)
 		+ be32toh(ns->dot3StatsMultipleCollisionFrames)
 		;
+#undef NPEADD
 #undef MIBADD
 }
 

==== //depot/projects/soc2008/trasz_nfs4acl/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c#20 (text+ko) ====


==== //depot/projects/soc2008/trasz_nfs4acl/sys/fs/nfs/nfs_commonkrpc.c#4 (text+ko) ====

@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/fs/nfs/nfs_commonkrpc.c,v 1.4 2009/05/23 00:40:17 rmacklem Exp $");
+__FBSDID("$FreeBSD: src/sys/fs/nfs/nfs_commonkrpc.c,v 1.5 2009/05/24 03:22:49 rmacklem Exp $");
 
 /*
  * Socket operations for use by nfs
@@ -341,7 +341,9 @@
 		else
 			auth = NULL;
 #endif
-		return (auth);
+		if (auth != NULL)
+			return (auth);
+		/* fallthrough */
 #endif	/* KGSSAPI */
 	case AUTH_SYS:
 	default:
@@ -402,7 +404,7 @@
 {
 	u_int32_t *tl;
 	time_t waituntil;
-	int i, j;
+	int i, j, set_uid = 0;
 	int trycnt, error = 0, usegssname = 0, secflavour = AUTH_SYS;
 	u_int16_t procnum;
 	u_int trylater_delay = 1;
@@ -413,6 +415,7 @@
 	enum clnt_stat stat;
 	struct nfsreq *rep = NULL;
 	char *srv_principal = NULL;
+	uid_t saved_uid = (uid_t)-1;
 
 	if (xidp != NULL)
 		*xidp = 0;
@@ -423,6 +426,14 @@
 	}
 
 	/*
+	 * XXX if not already connected call nfs_connect now. Longer
+	 * term, change nfs_mount to call nfs_connect unconditionally
+	 * and let clnt_reconnect_create handle reconnects.
+	 */
+	if (nrp->nr_client == NULL)
+		newnfs_connect(nmp, nrp, cred, td, 0);
+
+	/*
 	 * For a client side mount, nmp is != NULL and clp == NULL. For
 	 * server calls (callbacks or upcalls), nmp == NULL.
 	 */
@@ -442,8 +453,30 @@
 	     nd->nd_procnum != NFSPROC_NULL) {
 		if (NFSHASALLGSSNAME(nmp) && nmp->nm_krbnamelen > 0)
 			nd->nd_flag |= ND_USEGSSNAME;
-		if ((nd->nd_flag & ND_USEGSSNAME) && nmp->nm_krbnamelen > 0)
-			usegssname = 1;
+		if ((nd->nd_flag & ND_USEGSSNAME) != 0) {
+			/*
+			 * If there is a client side host based credential,
+			 * use that, otherwise use the system uid, if set.
+			 */
+			if (nmp->nm_krbnamelen > 0) {
+				usegssname = 1;
+			} else if (nmp->nm_uid != (uid_t)-1) {
+				saved_uid = cred->cr_uid;
+				cred->cr_uid = nmp->nm_uid;
+				set_uid = 1;
+			}
+		} else if (nmp->nm_krbnamelen == 0 &&
+		    nmp->nm_uid != (uid_t)-1 && cred->cr_uid == (uid_t)0) {
+			/*
+			 * If there is no host based principal name and
+			 * the system uid is set and this is root, use the
+			 * system uid, since root won't have user
+			 * credentials in a credentials cache file.
+			 */
+			saved_uid = cred->cr_uid;
+			cred->cr_uid = nmp->nm_uid;
+			set_uid = 1;
+		}
 		if (NFSHASINTEGRITY(nmp))
 			secflavour = RPCSEC_GSS_KRB5I;
 		else if (NFSHASPRIVACY(nmp))
@@ -462,14 +495,6 @@
 		    ((nmp->nm_tprintf_delay)-(nmp->nm_tprintf_initial_delay));
 	}
 
-	/*
-	 * XXX if not already connected call nfs_connect now. Longer
-	 * term, change nfs_mount to call nfs_connect unconditionally
-	 * and let clnt_reconnect_create handle reconnects.
-	 */
-	if (nrp->nr_client == NULL)
-		newnfs_connect(nmp, nrp, cred, td, 0);
-
 	if (nd->nd_procnum == NFSPROC_NULL)
 		auth = authnone_create();
 	else if (usegssname)
@@ -478,6 +503,8 @@
 	else
 		auth = nfs_getauth(nrp, secflavour, NULL,
 		    srv_principal, NULL, cred);
+	if (set_uid)
+		cred->cr_uid = saved_uid;
 	if (auth == NULL) {
 		m_freem(nd->nd_mreq);
 		return (EACCES);

==== //depot/projects/soc2008/trasz_nfs4acl/sys/fs/nfsclient/nfs_clvfsops.c#3 (text+ko) ====

@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/fs/nfsclient/nfs_clvfsops.c,v 1.4 2009/05/22 15:08:12 rmacklem Exp $");
+__FBSDID("$FreeBSD: src/sys/fs/nfsclient/nfs_clvfsops.c,v 1.5 2009/05/24 03:22:49 rmacklem Exp $");
 
 
 #include "opt_bootp.h"
@@ -1062,20 +1062,20 @@
 		nmp->nm_krbnamelen = argp->krbnamelen;
 		nmp->nm_dirpathlen = argp->dirlen;
 		nmp->nm_srvkrbnamelen = argp->srvkrbnamelen;
-		if (nmp->nm_dirpathlen > 0) {
+		if (td->td_ucred->cr_uid != (uid_t)0) {
 			/*
-			 * Since we will be doing dirpath as root,
-			 * set nm_uid to the real uid doing the mount,
-			 * since that is normally the user with a valid TGT.
+			 * nm_uid is used to get KerberosV credentials for
+			 * the nfsv4 state handling operations if there is
+			 * no host based principal set. Use the uid of
+			 * this user if not root, since they are doing the
+			 * mount. I don't think setting this for root will
+			 * work, since root normally does not have user
+			 * credentials in a credentials cache.
 			 */
-			nmp->nm_uid = td->td_ucred->cr_ruid;
+			nmp->nm_uid = td->td_ucred->cr_uid;
 		} else {
 			/*
-			 * Just set to -1, so the first Op
-			 * will set it later, to the uid of
-			 * the process doing that (usually
-			 * from a first open in the mount
-			 * point).
+			 * Just set to -1, so it won't be used.
 			 */
 			nmp->nm_uid = (uid_t)-1;
 		}

==== //depot/projects/soc2008/trasz_nfs4acl/sys/fs/nwfs/nwfs_io.c#4 (text+ko) ====

@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/fs/nwfs/nwfs_io.c,v 1.48 2008/10/10 21:23:50 attilio Exp $
+ * $FreeBSD: src/sys/fs/nwfs/nwfs_io.c,v 1.49 2009/05/23 18:25:11 alc Exp $
  *
  */
 #include <sys/param.h>
@@ -463,10 +463,13 @@
 
 		if (nextoff <= size) {
 			m->valid = VM_PAGE_BITS_ALL;
-			m->dirty = 0;
+			KASSERT(m->dirty == 0,
+			    ("nwfs_getpages: page %p is dirty", m));
 		} else {
 			int nvalid = ((size + DEV_BSIZE - 1) - toff) & ~(DEV_BSIZE - 1);
-			vm_page_set_validclean(m, 0, nvalid);
+			vm_page_set_valid(m, 0, nvalid);
+			KASSERT((m->dirty & vm_page_bits(0, nvalid)) == 0,
+			    ("nwfs_getpages: page %p is dirty", m));
 		}
 
 		if (i != ap->a_reqpage) {

==== //depot/projects/soc2008/trasz_nfs4acl/sys/kern/kern_lockf.c#5 (text+ko) ====

@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_lockf.c,v 1.67 2008/11/27 04:40:37 ganbold Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_lockf.c,v 1.71 2009/05/24 12:39:38 kib Exp $");
 
 #include "opt_debug_lockf.h"
 
@@ -106,7 +106,7 @@
     int);
 static struct lockf_entry *
 		 lf_alloc_lock(struct lock_owner *);
-static void	 lf_free_lock(struct lockf_entry *);
+static int	 lf_free_lock(struct lockf_entry *);
 static int	 lf_clearlock(struct lockf *, struct lockf_entry *);
 static int	 lf_overlaps(struct lockf_entry *, struct lockf_entry *);
 static int	 lf_blocks(struct lockf_entry *, struct lockf_entry *);
@@ -347,9 +347,13 @@
 	return (lf);
 }
 
-static void
+static int
 lf_free_lock(struct lockf_entry *lock)
 {
+
+	KASSERT(lock->lf_refs > 0, ("lockf_entry negative ref count %p", lock));
+	if (--lock->lf_refs > 0)
+		return (0);
 	/*
 	 * Adjust the lock_owner reference count and
 	 * reclaim the entry if this is the last lock
@@ -394,6 +398,7 @@
 		printf("Freed lock %p\n", lock);
 #endif
 	free(lock, M_LOCKF);
+	return (1);
 }
 
 /*
@@ -540,6 +545,7 @@
 	 * the lf_lock_owners_lock tax twice.
 	 */
 	lock = lf_alloc_lock(NULL);
+	lock->lf_refs = 1;
 	lock->lf_start = start;
 	lock->lf_end = end;
 	lock->lf_owner = lo;
@@ -633,7 +639,20 @@
 	}
 
 	sx_xlock(&state->ls_lock);
-	switch(ap->a_op) {
+	/*
+	 * Recheck the doomed vnode after state->ls_lock is
+	 * locked. lf_purgelocks() requires that no new threads add
+	 * pending locks when vnode is marked by VI_DOOMED flag.
+	 */
+	VI_LOCK(vp);
+	if (vp->v_iflag & VI_DOOMED) {
+		VI_UNLOCK(vp);
+		lf_free_lock(lock);
+		return (ENOENT);
+	}
+	VI_UNLOCK(vp);
+
+	switch (ap->a_op) {
 	case F_SETLK:
 		error = lf_setlock(state, lock, vp, ap->a_cookiep);
 		break;
@@ -755,8 +774,11 @@
 	 * the remaining locks.
 	 */
 	VI_LOCK(vp);
+	KASSERT(vp->v_iflag & VI_DOOMED,
+	    ("lf_purgelocks: vp %p has not vgone yet", vp));
 	state = *statep;
 	if (state) {
+		*statep = NULL;
 		state->ls_threads++;
 		VI_UNLOCK(vp);
 
@@ -789,7 +811,6 @@
 		VI_LOCK(vp);
 		while (state->ls_threads > 1)
 			msleep(state, VI_MTX(vp), 0, "purgelocks", 0);
-		*statep = 0;
 		VI_UNLOCK(vp);
 
 		/*
@@ -798,7 +819,9 @@
 		 * above). We don't need to bother locking since we
 		 * are the last thread using this state structure.
 		 */
-		LIST_FOREACH_SAFE(lock, &state->ls_pending, lf_link, nlock) {
+		KASSERT(LIST_EMPTY(&state->ls_pending),
+		    ("lock pending for %p", state));
+		LIST_FOREACH_SAFE(lock, &state->ls_active, lf_link, nlock) {
 			LIST_REMOVE(lock, lf_link);
 			lf_free_lock(lock);
 		}
@@ -1361,7 +1384,7 @@
 	/*
 	 * Scan lock list for this file looking for locks that would block us.
 	 */
-	while (lf_getblock(state, lock)) {
+	if (lf_getblock(state, lock)) {
 		/*
 		 * Free the structure and return if nonblocking.
 		 */
@@ -1430,7 +1453,13 @@
 			goto out;
 		}
 
+		lock->lf_refs++;
 		error = sx_sleep(lock, &state->ls_lock, priority, lockstr, 0);
+		if (lf_free_lock(lock)) {
+			error = EINTR;
+			goto out;
+		}
+
 		/*
 		 * We may have been awakened by a signal and/or by a
 		 * debugger continuing us (in which cases we must
@@ -1792,6 +1821,7 @@
 	 */
 	splitlock = lf_alloc_lock(lock1->lf_owner);
 	memcpy(splitlock, lock1, sizeof *splitlock);
+	splitlock->lf_refs = 1;
 	if (splitlock->lf_flags & F_REMOTE)
 		vref(splitlock->lf_vnode);
 

==== //depot/projects/soc2008/trasz_nfs4acl/sys/kern/kern_vimage.c#7 (text+ko) ====

@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_vimage.c,v 1.7 2009/05/22 22:09:00 zec Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_vimage.c,v 1.8 2009/05/23 21:43:44 zec Exp $");
 
 #include "opt_ddb.h"
 
@@ -66,6 +66,10 @@
 #endif
 #endif
 
+#ifdef VIMAGE
+struct vnet *vnet0;
+#endif
+
 void
 vnet_mod_register(const struct vnet_modinfo *vmi)
 {
@@ -331,6 +335,7 @@
 	LIST_INSERT_HEAD(&vnet_head, vnet, vnet_le);
 	vnet->vnet_magic_n = VNET_MAGIC_N;
 	vip->v_net = vnet;
+	vnet0 = vnet;
 
 	/* We MUST clear curvnet in vi_init_done before going SMP. */
 	curvnet = LIST_FIRST(&vnet_head);

==== //depot/projects/soc2008/trasz_nfs4acl/sys/kern/tty.c#22 (text+ko) ====

@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/tty.c,v 1.314 2009/05/14 03:24:22 jeff Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/tty.c,v 1.315 2009/05/24 12:32:03 ed Exp $");
 
 #include "opt_compat.h"
 
@@ -206,6 +206,7 @@
 		ttydevsw_close(tp);
 
 	tp->t_flags &= ~TF_OPENCLOSE;
+	cv_broadcast(&tp->t_dcdwait);
 	tty_rel_free(tp);
 }
 
@@ -231,13 +232,17 @@
 		tty_unlock(tp);
 		return (ENXIO);
 	}
+
 	/*
-	 * Prevent the TTY from being opened when being torn down or
-	 * built up by unrelated processes.
+	 * Block when other processes are currently opening or closing
+	 * the TTY.
 	 */
-	if (tp->t_flags & TF_OPENCLOSE) {
-		tty_unlock(tp);
-		return (EBUSY);
+	while (tp->t_flags & TF_OPENCLOSE) {
+		error = tty_wait(tp, &tp->t_dcdwait);
+		if (error != 0) {
+			tty_unlock(tp);
+			return (error);
+		}
 	}
 	tp->t_flags |= TF_OPENCLOSE;
 
@@ -299,6 +304,7 @@
 		tp->t_flags |= TF_OPENED_IN;
 
 done:	tp->t_flags &= ~TF_OPENCLOSE;
+	cv_broadcast(&tp->t_dcdwait);
 	ttydev_leave(tp);
 
 	return (error);

==== //depot/projects/soc2008/trasz_nfs4acl/sys/kgssapi/gsstest.c#3 (text+ko) ====

@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kgssapi/gsstest.c,v 1.2 2008/11/12 15:31:05 dfr Exp $");
+__FBSDID("$FreeBSD: src/sys/kgssapi/gsstest.c,v 1.3 2009/05/24 11:10:27 dfr Exp $");
 
 #include <sys/ctype.h>
 #include <sys/param.h>
@@ -38,6 +38,7 @@
 #include <sys/socketvar.h>
 #include <sys/sysent.h>
 #include <sys/sysproto.h>
+#include <sys/vimage.h>
 
 #include <kgssapi/gssapi.h>
 #include <kgssapi/gssapi_impl.h>
@@ -227,7 +228,7 @@
 
 	{
 		static char sbuf[512];
-		snprintf(sbuf, sizeof(sbuf), "nfs@%s", hostname);
+		snprintf(sbuf, sizeof(sbuf), "nfs@%s", V_hostname);
 		name_desc.value = sbuf;
 	}
 
@@ -430,7 +431,7 @@
 	case 1:
 		if (server_context == GSS_C_NO_CONTEXT) {
 			static char sbuf[512];
-			snprintf(sbuf, sizeof(sbuf), "nfs@%s", hostname);
+			snprintf(sbuf, sizeof(sbuf), "nfs@%s", V_hostname);
 			name_desc.value = sbuf;
 			name_desc.length = strlen((const char *)
 			    name_desc.value);
@@ -811,7 +812,7 @@
 		return(1);
 	}
 
-	snprintf(service, sizeof(service), "host@%s", hostname);
+	snprintf(service, sizeof(service), "host@%s", V_hostname);
 
 	auth = rpc_gss_seccreate(client, curthread->td_ucred,
 	    service, "kerberosv5", rpc_gss_svc_privacy,
@@ -881,7 +882,7 @@
 	const char **mechs;
 	static rpc_gss_callback_t cb;
 
-	snprintf(principal, sizeof(principal), "host@%s", hostname);
+	snprintf(principal, sizeof(principal), "host@%s", V_hostname);
 
 	mechs = rpc_gss_get_mechanisms();
 	while (*mechs) {

==== //depot/projects/soc2008/trasz_nfs4acl/sys/mips/mips/pmap.c#12 (text+ko) ====

@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/mips/mips/pmap.c,v 1.16 2009/05/23 07:58:56 alc Exp $");
+__FBSDID("$FreeBSD: src/sys/mips/mips/pmap.c,v 1.19 2009/05/23 22:05:14 alc Exp $");
 
 #include "opt_ddb.h"
 #include "opt_msgbuf.h"
@@ -1729,8 +1729,8 @@
  *	insert this page into the given map NOW.
  */
 void
-pmap_enter(pmap_t pmap, vm_offset_t va, vm_prot_t fault_type, vm_page_t m, vm_prot_t prot,
-    boolean_t wired)
+pmap_enter(pmap_t pmap, vm_offset_t va, vm_prot_t access, vm_page_t m,
+    vm_prot_t prot, boolean_t wired)
 {
 	vm_offset_t pa, opa;
 	register pt_entry_t *pte;
@@ -3116,10 +3116,12 @@
 			 */
 			rw = PTE_RWPAGE;
 			vm_page_dirty(m);
-		} else if ((m->md.pv_flags & PV_TABLE_MOD) || m->dirty)
+		} else if ((m->md.pv_flags & PV_TABLE_MOD) ||
+		    m->dirty == VM_PAGE_BITS_ALL)
 			rw = PTE_RWPAGE;
 		else
 			rw = PTE_CWPAGE;
+		vm_page_flag_set(m, PG_WRITEABLE);
 	}
 	return rw;
 }

==== //depot/projects/soc2008/trasz_nfs4acl/sys/net/if_clone.c#4 (text+ko) ====

@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)if.c	8.5 (Berkeley) 1/9/95
- * $FreeBSD: src/sys/net/if_clone.c,v 1.13 2009/05/05 10:56:12 zec Exp $
+ * $FreeBSD: src/sys/net/if_clone.c,v 1.14 2009/05/23 21:43:44 zec Exp $
  */
 
 #include <sys/param.h>
@@ -55,10 +55,13 @@
 static void	if_clone_free(struct if_clone *ifc);
 static int	if_clone_createif(struct if_clone *ifc, char *name, size_t len,
 		    caddr_t params);
+static int	vnet_clone_iattach(const void *);
 
 static struct mtx	if_cloners_mtx;
+#ifdef VIMAGE_GLOBALS
 static int		if_cloners_count;
-LIST_HEAD(, if_clone)	if_cloners = LIST_HEAD_INITIALIZER(if_cloners);
+LIST_HEAD(, if_clone)	if_cloners;
+#endif
 
 #define IF_CLONERS_LOCK_INIT()		\
     mtx_init(&if_cloners_mtx, "if_cloners lock", NULL, MTX_DEF)
@@ -112,10 +115,32 @@
 
 static MALLOC_DEFINE(M_CLONE, "clone", "interface cloning framework");
 
+#ifndef VIMAGE_GLOBALS
+static const vnet_modinfo_t vnet_clone_modinfo = {
+	.vmi_id		= VNET_MOD_IF_CLONE,
+	.vmi_name	= "if_clone",
+	.vmi_iattach	= vnet_clone_iattach
+};
+#endif /* !VIMAGE_GLOBALS */
+
+static int vnet_clone_iattach(const void *unused __unused)
+{
+	INIT_VNET_NET(curvnet);
+
+	LIST_INIT(&V_if_cloners);
+	return (0);
+}
+
 void
 if_clone_init(void)
 {
+
 	IF_CLONERS_LOCK_INIT();
+#ifndef VIMAGE_GLOBALS
+	vnet_mod_register(&vnet_clone_modinfo);
+#else
+	vnet_clone_iattach(NULL);
+#endif
 }
 
 /*
@@ -124,15 +149,27 @@
 int
 if_clone_create(char *name, size_t len, caddr_t params)
 {
+	INIT_VNET_NET(curvnet);
 	struct if_clone *ifc;
 
 	/* Try to find an applicable cloner for this request */
 	IF_CLONERS_LOCK();
-	LIST_FOREACH(ifc, &if_cloners, ifc_list) {
+	LIST_FOREACH(ifc, &V_if_cloners, ifc_list) {
 		if (ifc->ifc_match(ifc, name)) {
 			break;
 		}
 	}
+#ifdef VIMAGE
+	if (ifc == NULL && !IS_DEFAULT_VNET(curvnet)) {
+		CURVNET_SET_QUIET(vnet0);
+		INIT_VNET_NET(vnet0);
+		LIST_FOREACH(ifc, &V_if_cloners, ifc_list) {
+			if (ifc->ifc_match(ifc, name))
+				break;
+		}
+		CURVNET_RESTORE();
+	}
+#endif
 	IF_CLONERS_UNLOCK();
 
 	if (ifc == NULL)
@@ -176,6 +213,7 @@
 int
 if_clone_destroy(const char *name)
 {
+	INIT_VNET_NET(curvnet);
 	struct if_clone *ifc;
 	struct ifnet *ifp;
 
@@ -185,11 +223,22 @@
 
 	/* Find the cloner for this interface */
 	IF_CLONERS_LOCK();
-	LIST_FOREACH(ifc, &if_cloners, ifc_list) {
+	LIST_FOREACH(ifc, &V_if_cloners, ifc_list) {
 		if (strcmp(ifc->ifc_name, ifp->if_dname) == 0) {
 			break;
 		}
 	}
+#ifdef VIMAGE
+	if (ifc == NULL && !IS_DEFAULT_VNET(curvnet)) {
+		CURVNET_SET_QUIET(vnet0);
+		INIT_VNET_NET(vnet0);
+		LIST_FOREACH(ifc, &V_if_cloners, ifc_list) {
+			if (ifc->ifc_match(ifc, name))
+				break;
+		}
+		CURVNET_RESTORE();
+	}
+#endif
 	IF_CLONERS_UNLOCK();
 	if (ifc == NULL)
 		return (EINVAL);
@@ -208,11 +257,17 @@
 	if (ifc->ifc_destroy == NULL)
 		return(EOPNOTSUPP);
 
+	/*
+	 * Given that the cloned ifnet might be attached to a different
+	 * vnet from where its cloner was registered, we have to
+	 * switch to the vnet context of the target vnet.
+	 */
+	CURVNET_SET_QUIET(ifp->if_vnet);
+
 	IF_CLONE_LOCK(ifc);
 	IFC_IFLIST_REMOVE(ifc, ifp);
 	IF_CLONE_UNLOCK(ifc);
 
-	CURVNET_SET_QUIET(ifp->if_vnet);
 	if_delgroup(ifp, ifc->ifc_name);
 
 	err =  (*ifc->ifc_destroy)(ifc, ifp);
@@ -234,6 +289,7 @@
 void
 if_clone_attach(struct if_clone *ifc)
 {
+	INIT_VNET_NET(curvnet);
 	int len, maxclone;
 
 	/*
@@ -249,8 +305,8 @@
 	IF_CLONE_ADDREF(ifc);
 
 	IF_CLONERS_LOCK();
-	LIST_INSERT_HEAD(&if_cloners, ifc, ifc_list);
-	if_cloners_count++;
+	LIST_INSERT_HEAD(&V_if_cloners, ifc, ifc_list);
+	V_if_cloners_count++;
 	IF_CLONERS_UNLOCK();
 
 	LIST_INIT(&ifc->ifc_iflist);
@@ -266,11 +322,12 @@
 void
 if_clone_detach(struct if_clone *ifc)
 {
+	INIT_VNET_NET(curvnet);
 	struct ifc_simple_data *ifcs = ifc->ifc_data;
 
 	IF_CLONERS_LOCK();
 	LIST_REMOVE(ifc, ifc_list);
-	if_cloners_count--;
+	V_if_cloners_count--;
 	IF_CLONERS_UNLOCK();
 
 	/* Allow all simples to be destroyed */
@@ -305,6 +362,7 @@
 int
 if_clone_list(struct if_clonereq *ifcr)
 {
+	INIT_VNET_NET(curvnet);
 	char *buf, *dst, *outbuf = NULL;
 	struct if_clone *ifc;
 	int buf_count, count, err = 0;
@@ -321,23 +379,23 @@
 	 * could be because that would let arbitrary users cause us to
 	 * allocate abritrary amounts of kernel memory.
 	 */
-	buf_count = (if_cloners_count < ifcr->ifcr_count) ?

>>> TRUNCATED FOR MAIL (1000 lines) <<<



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905241709.n4OH9Wtx076730>