PERFORCE change 49927 for review
Robert Watson
rwatson at FreeBSD.org
Mon Mar 29 16:16:03 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=49927
Change 49927 by rwatson at rwatson_paprika on 2004/03/29 16:15:23
Integrate netperf_socket:
Death of umapfs recognized, but NFS will work better.
if_oltr FreeBSD 3.x source compatibility removed.
KSE comments updated.
Loop back of if_tun softc locking from rwatson_netperf.
More kstack size fixes.
Affected files ...
.. //depot/projects/netperf_socket/sys/amd64/amd64/vm_machdep.c#5 integrate
.. //depot/projects/netperf_socket/sys/conf/NOTES#9 integrate
.. //depot/projects/netperf_socket/sys/contrib/dev/oltr/if_oltr.c#3 integrate
.. //depot/projects/netperf_socket/sys/fs/umapfs/umap_vnops.c#2 integrate
.. //depot/projects/netperf_socket/sys/i386/i386/vm_machdep.c#8 integrate
.. //depot/projects/netperf_socket/sys/kern/kern_sig.c#5 integrate
.. //depot/projects/netperf_socket/sys/kern/vfs_default.c#2 integrate
.. //depot/projects/netperf_socket/sys/kern/vfs_subr.c#5 integrate
.. //depot/projects/netperf_socket/sys/libkern/index.c#2 integrate
.. //depot/projects/netperf_socket/sys/libkern/rindex.c#2 integrate
.. //depot/projects/netperf_socket/sys/modules/Makefile#7 integrate
.. //depot/projects/netperf_socket/sys/net/if_tun.c#7 integrate
.. //depot/projects/netperf_socket/sys/powerpc/powerpc/vm_machdep.c#4 integrate
.. //depot/projects/netperf_socket/sys/sys/vnode.h#3 integrate
Differences ...
==== //depot/projects/netperf_socket/sys/amd64/amd64/vm_machdep.c#5 (text+ko) ====
@@ -41,10 +41,9 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/vm_machdep.c,v 1.230 2004/03/25 03:39:38 peter Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/vm_machdep.c,v 1.231 2004/03/29 19:38:05 peter Exp $");
#include "opt_isa.h"
-#include "opt_kstack_pages.h"
#include "opt_cpu.h"
#include <sys/param.h>
==== //depot/projects/netperf_socket/sys/conf/NOTES#9 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/conf/NOTES,v 1.1207 2004/03/18 12:22:31 brueffer Exp $
+# $FreeBSD: src/sys/conf/NOTES,v 1.1208 2004/03/29 22:41:20 peter Exp $
#
# NOTES -- Lines that can be cut/pasted into kernel and hints configs.
#
@@ -701,7 +701,8 @@
options PSEUDOFS #Pseudo-filesystem framework
options SMBFS #SMB/CIFS filesystem
options UDF #Universal Disk Format
-options UMAPFS #UID map filesystem
+#umapfs is seriously (functionally) broken at this point.
+#options UMAPFS #UID map filesystem
options UNIONFS #Union filesystem
# The xFS_ROOT options REQUIRE the associated ``options xFS''
options NFS_ROOT #NFS usable as root device
==== //depot/projects/netperf_socket/sys/contrib/dev/oltr/if_oltr.c#3 (text+ko) ====
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/contrib/dev/oltr/if_oltr.c,v 1.32 2004/03/17 17:50:23 njl Exp $
+ * $FreeBSD: src/sys/contrib/dev/oltr/if_oltr.c,v 1.33 2004/03/29 21:10:05 imp Exp $
*/
#include <sys/param.h>
@@ -50,11 +50,6 @@
#include <net/if_media.h>
#include <net/iso88025.h>
-#if (__FreeBSD_version < 400000)
-#include <bpfilter.h>
-#endif
-
-#if (NBPFILTER > 0) || (__FreeBSD_version > 400000)
#include <net/bpf.h>
#ifndef BPF_MTAP
@@ -63,7 +58,6 @@
bpf_mtap((_ifp), (_m)); \
} while (0)
#endif
-#endif
#include <vm/vm.h> /* for vtophys */
#include <vm/pmap.h> /* for vtophys */
@@ -238,8 +232,6 @@
static int oltr_ifmedia_upd __P((struct ifnet *));
static void oltr_ifmedia_sts __P((struct ifnet *, struct ifmediareq *));
-#if __FreeBSD_version > 400000
-
static int oltr_pci_probe __P((device_t));
static int oltr_pci_attach __P((device_t));
static int oltr_pci_detach __P((device_t));
@@ -488,200 +480,7 @@
return;
}
-#else
-
-static const char *oltr_pci_probe __P((pcici_t, pcidi_t));
-static void oltr_pci_attach __P((pcici_t, int));
-
-static unsigned long oltr_count = 0;
-
-static struct pci_device oltr_device = {
- "oltr",
- oltr_pci_probe,
- oltr_pci_attach,
- &oltr_count,
- NULL
-};
-
-DATA_SET(pcidevice_set, oltr_device);
-
-static const char *
-oltr_pci_probe(pcici_t config_id, pcidi_t device_id)
-{
- int i, rc;
- char PCIConfigHeader[64];
- TRlldAdapterConfig_t config;
-
- if (((device_id & 0xffff) == PCI_VENDOR_OLICOM) && (
- (((device_id >> 16) & 0xffff) == 0x0001) ||
- (((device_id >> 16) & 0xffff) == 0x0004) ||
- (((device_id >> 16) & 0xffff) == 0x0005) ||
- (((device_id >> 16) & 0xffff) == 0x0007) ||
- (((device_id >> 16) & 0xffff) == 0x0008))) {
-
- for (i = 0; i < 64; i++)
- PCIConfigHeader[i] = pci_cfgread(config_id, i, /* bytes */ 1);
-
- rc = TRlldPCIConfig(&LldDriver, &config, PCIConfigHeader);
-
- if (rc == TRLLD_PCICONFIG_FAIL) {
- printf("oltr: TRlldPciConfig failed!\n");
- return(NULL);
- }
- if (rc == TRLLD_PCICONFIG_VERSION) {
- printf("oltr: wrong LLD version.\n");
- return(NULL);
- }
- return(AdapterName[config.type]);
- }
-
- return(NULL);
-}
-
static void
-oltr_pci_attach(pcici_t config_id, int unit)
-{
- int i, s, rc = 0, scratch_size;
- int media = IFM_TOKEN|IFM_TOK_UTP16;
- u_long command;
- char PCIConfigHeader[64];
- struct oltr_softc *sc;
- struct ifnet *ifp; /* = &sc->arpcom.ac_if; */
-
- s = splimp();
-
- sc = malloc(sizeof(struct oltr_softc), M_DEVBUF, M_NOWAIT | M_ZERO);
- if (sc == NULL) {
- printf("oltr%d: no memory for softc struct!\n", unit);
- goto config_failed;
- }
- sc->unit = unit;
- sc->state = OL_UNKNOWN;
- ifp = &sc->arpcom.ac_if;
-
- for (i = 0; i < sizeof(PCIConfigHeader); i++)
- PCIConfigHeader[i] = pci_cfgread(config_id, i, 1);
-
- switch(TRlldPCIConfig(&LldDriver, &sc->config, PCIConfigHeader)) {
- case TRLLD_PCICONFIG_OK:
- break;
- case TRLLD_PCICONFIG_SET_COMMAND:
- printf("oltr%d: enabling bus master mode\n", unit);
- command = pci_conf_read(config_id, PCIR_COMMAND);
- pci_conf_write(config_id, PCIR_COMMAND, (command | PCIM_CMD_BUSMASTEREN));
- command = pci_conf_read(config_id, PCIR_COMMAND);
- if (!(command & PCIM_CMD_BUSMASTEREN)) {
- printf("oltr%d: failed to enable bus master mode\n", unit);
- goto config_failed;
- }
- break;
- case TRLLD_PCICONFIG_FAIL:
- printf("oltr%d: TRlldPciConfig failed!\n", unit);
- goto config_failed;
- break;
- case TRLLD_PCICONFIG_VERSION:
- printf("oltr%d: wrong LLD version\n", unit);
- goto config_failed;
- break;
- }
- printf("oltr%d: MAC address %6D\n", unit, sc->config.macaddress, ":");
-
- scratch_size = TRlldAdapterSize();
- if (bootverbose)
- printf("oltr%d: adapter memory block size %d bytes\n", unit, scratch_size);
- sc->TRlldAdapter = (TRlldAdapter_t)malloc(scratch_size, M_DEVBUF, M_NOWAIT);
- if (sc->TRlldAdapter == NULL) {
- printf("oltr%d: couldn't allocate scratch buffer (%d bytes)\n",unit, scratch_size);
- goto config_failed;
- }
-
- /*
- * Allocate RX/TX Pools
- */
- for (i = 0; i < RING_BUFFER_LEN; i++) {
- sc->rx_ring[i].index = i;
- sc->rx_ring[i].data = (char *)malloc(RX_BUFFER_LEN, M_DEVBUF, M_NOWAIT);
- sc->rx_ring[i].address = vtophys(sc->rx_ring[i].data);
- sc->tx_ring[i].index = i;
- sc->tx_ring[i].data = (char *)malloc(TX_BUFFER_LEN, M_DEVBUF, M_NOWAIT);
- sc->tx_ring[i].address = vtophys(sc->tx_ring[i].data);
- if ((!sc->rx_ring[i].data) || (!sc->tx_ring[i].data)) {
- printf("oltr%d: unable to allocate ring buffers\n", unit);
- while (i > 0) {
- if (sc->rx_ring[i].data)
- free(sc->rx_ring[i].data, M_DEVBUF);
- if (sc->tx_ring[i].data)
- free(sc->tx_ring[i].data, M_DEVBUF);
- i--;
- }
- goto config_failed;
- }
- }
-
- /*
- * Allocate interrupt and DMA channel
- */
- if (!pci_map_int(config_id, oltr_intr, sc, &net_imask)) {
- printf("oltr%d: couldn't setup interrupt\n", unit);
- goto config_failed;
- }
-
- /*
- * Do the ifnet initialization
- */
- ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "oltr";
- ifp->if_output = iso88025_output;
- ifp->if_init = oltr_init;
- ifp->if_start = oltr_start;
- ifp->if_ioctl = oltr_ioctl;
- ifp->if_flags = IFF_BROADCAST;
- bcopy(sc->config.macaddress, sc->arpcom.ac_enaddr, sizeof(sc->config.macaddress));
-
- /*
- * Do ifmedia setup.
- */
- ifmedia_init(&sc->ifmedia, 0, oltr_ifmedia_upd, oltr_ifmedia_sts);
- rc = TRlldSetSpeed(sc->TRlldAdapter, TRLLD_SPEED_16MBPS);
- switch(sc->config.type) {
- case TRLLD_ADAPTER_PCI7: /* OC-3540 */
- ifmedia_add(&sc->ifmedia, IFM_TOKEN|IFM_TOK_UTP100, 0, NULL);
- /* FALL THROUGH */
- case TRLLD_ADAPTER_PCI4: /* OC-3139 */
- case TRLLD_ADAPTER_PCI5: /* OC-3140 */
- case TRLLD_ADAPTER_PCI6: /* OC-3141 */
- ifmedia_add(&sc->ifmedia, IFM_TOKEN|IFM_AUTO, 0, NULL);
- media = IFM_TOKEN|IFM_AUTO;
- rc = TRlldSetSpeed(sc->TRlldAdapter, 0);
- /* FALL THROUGH */
- default:
- ifmedia_add(&sc->ifmedia, IFM_TOKEN|IFM_TOK_UTP4, 0, NULL);
- ifmedia_add(&sc->ifmedia, IFM_TOKEN|IFM_TOK_UTP16, 0, NULL);
- break;
- }
- sc->ifmedia.ifm_media = media;
- ifmedia_set(&sc->ifmedia, media);
-
- /*
- * Attach the interface
- */
- if_attach(ifp);
- ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
- iso88025_ifattach(ifp);
-
- splx(s);
- return;
-
-config_failed:
- (void)splx(s);
-
- return;
-}
-
-#endif
-
-static void
oltr_intr(void *xsc)
{
struct oltr_softc *sc = (struct oltr_softc *)xsc;
@@ -761,9 +560,7 @@
sc->tx_head = RING_BUFFER((sc->tx_head + sc->frame_ring[frame].FragmentCount));
sc->tx_frame++;
-#if (NBPFILTER > 0) || (__FreeBSD_version > 400000)
BPF_MTAP(ifp, m0);
-#endif
/*ifp->if_opackets++;*/
bad:
==== //depot/projects/netperf_socket/sys/fs/umapfs/umap_vnops.c#2 (text+ko) ====
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)umap_vnops.c 8.6 (Berkeley) 5/22/95
- * $FreeBSD: src/sys/fs/umapfs/umap_vnops.c,v 1.38 2003/03/03 19:15:39 njl Exp $
+ * $FreeBSD: src/sys/fs/umapfs/umap_vnops.c,v 1.39 2004/03/29 22:41:20 peter Exp $
*/
/*
@@ -363,6 +363,15 @@
} */ *ap;
{
+ /*
+ * vop_nolock no longer exists. I could have pasted the code
+ * in so that it compiles, but that would be doing our users a
+ * great disservice. umapfs is about 5 years behind the nullfs
+ * code that it is derived from. The stub locking here guarantees
+ * a deadlock the moment a VOP_INACTIVE arrives. There is no point
+ * pasting the code that makes it compile either, because that just
+ * makes it Even More Wrong.
+ */
vop_nolock(ap);
if ((ap->a_flags & LK_TYPE_MASK) == LK_DRAIN)
return (0);
==== //depot/projects/netperf_socket/sys/i386/i386/vm_machdep.c#8 (text+ko) ====
@@ -41,10 +41,9 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.233 2004/03/22 00:28:38 wpaul Exp $");
+__FBSDID("$FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.234 2004/03/29 19:38:05 peter Exp $");
#include "opt_isa.h"
-#include "opt_kstack_pages.h"
#include "opt_npx.h"
#ifdef PC98
#include "opt_pc98.h"
==== //depot/projects/netperf_socket/sys/kern/kern_sig.c#5 (text+ko) ====
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_sig.c,v 1.273 2004/03/05 22:39:53 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_sig.c,v 1.274 2004/03/29 22:46:54 peter Exp $");
#include "opt_compat.h"
#include "opt_ktrace.h"
@@ -1875,10 +1875,8 @@
mtx_unlock_spin(&sched_lock);
goto out;
/*
- * XXXKSE What about threads that are waiting on mutexes?
- * Shouldn't they abort too?
- * No, hopefully mutexes are short lived.. They'll
- * eventually hit thread_suspend_check().
+ * Mutexes are short lived. Threads waiting on them will
+ * hit thread_suspend_check() soon.
*/
} else if (p->p_state == PRS_NORMAL) {
if ((p->p_flag & P_TRACED) || (action != SIG_DFL) ||
==== //depot/projects/netperf_socket/sys/kern/vfs_default.c#2 (text+ko) ====
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/vfs_default.c,v 1.91 2003/11/05 04:30:07 kan Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/vfs_default.c,v 1.92 2004/03/29 22:41:20 peter Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -369,166 +369,6 @@
}
/*
- * Stubs to use when there is no locking to be done on the underlying object.
- * A minimal shared lock is necessary to ensure that the underlying object
- * is not revoked while an operation is in progress. So, an active shared
- * count is maintained in an auxillary vnode lock structure.
- */
-int
-vop_sharedlock(ap)
- struct vop_lock_args /* {
- struct vnode *a_vp;
- int a_flags;
- struct thread *a_td;
- } */ *ap;
-{
- /*
- * This code cannot be used until all the non-locking filesystems
- * (notably NFS) are converted to properly lock and release nodes.
- * Also, certain vnode operations change the locking state within
- * the operation (create, mknod, remove, link, rename, mkdir, rmdir,
- * and symlink). Ideally these operations should not change the
- * lock state, but should be changed to let the caller of the
- * function unlock them. Otherwise all intermediate vnode layers
- * (such as union, umapfs, etc) must catch these functions to do
- * the necessary locking at their layer. Note that the inactive
- * and lookup operations also change their lock state, but this
- * cannot be avoided, so these two operations will always need
- * to be handled in intermediate layers.
- */
- struct vnode *vp = ap->a_vp;
- int vnflags, flags = ap->a_flags;
-
- switch (flags & LK_TYPE_MASK) {
- case LK_DRAIN:
- vnflags = LK_DRAIN;
- break;
- case LK_EXCLUSIVE:
-#ifdef DEBUG_VFS_LOCKS
- /*
- * Normally, we use shared locks here, but that confuses
- * the locking assertions.
- */
- vnflags = LK_EXCLUSIVE;
- break;
-#endif
- case LK_SHARED:
- vnflags = LK_SHARED;
- break;
- case LK_UPGRADE:
- case LK_EXCLUPGRADE:
- case LK_DOWNGRADE:
- return (0);
- case LK_RELEASE:
- default:
- panic("vop_sharedlock: bad operation %d", flags & LK_TYPE_MASK);
- }
- vnflags |= flags & (LK_INTERLOCK | LK_EXTFLG_MASK);
-#ifndef DEBUG_LOCKS
- return (lockmgr(vp->v_vnlock, vnflags, VI_MTX(vp), ap->a_td));
-#else
- return (debuglockmgr(vp->v_vnlock, vnflags, VI_MTX(vp), ap->a_td,
- "vop_sharedlock", vp->filename, vp->line));
-#endif
-}
-
-/*
- * Stubs to use when there is no locking to be done on the underlying object.
- * A minimal shared lock is necessary to ensure that the underlying object
- * is not revoked while an operation is in progress. So, an active shared
- * count is maintained in an auxillary vnode lock structure.
- */
-int
-vop_nolock(ap)
- struct vop_lock_args /* {
- struct vnode *a_vp;
- int a_flags;
- struct thread *a_td;
- } */ *ap;
-{
-#ifdef notyet
- /*
- * This code cannot be used until all the non-locking filesystems
- * (notably NFS) are converted to properly lock and release nodes.
- * Also, certain vnode operations change the locking state within
- * the operation (create, mknod, remove, link, rename, mkdir, rmdir,
- * and symlink). Ideally these operations should not change the
- * lock state, but should be changed to let the caller of the
- * function unlock them. Otherwise all intermediate vnode layers
- * (such as union, umapfs, etc) must catch these functions to do
- * the necessary locking at their layer. Note that the inactive
- * and lookup operations also change their lock state, but this
- * cannot be avoided, so these two operations will always need
- * to be handled in intermediate layers.
- */
- struct vnode *vp = ap->a_vp;
- int vnflags, flags = ap->a_flags;
-
- switch (flags & LK_TYPE_MASK) {
- case LK_DRAIN:
- vnflags = LK_DRAIN;
- break;
- case LK_EXCLUSIVE:
- case LK_SHARED:
- vnflags = LK_SHARED;
- break;
- case LK_UPGRADE:
- case LK_EXCLUPGRADE:
- case LK_DOWNGRADE:
- return (0);
- case LK_RELEASE:
- default:
- panic("vop_nolock: bad operation %d", flags & LK_TYPE_MASK);
- }
- vnflags |= flags & (LK_INTERLOCK | LK_EXTFLG_MASK);
- return(lockmgr(vp->v_vnlock, vnflags, VI_MTX(vp), ap->a_td));
-#else /* for now */
- /*
- * Since we are not using the lock manager, we must clear
- * the interlock here.
- */
- if (ap->a_flags & LK_INTERLOCK)
- VI_UNLOCK(ap->a_vp);
- return (0);
-#endif
-}
-
-/*
- * Do the inverse of vop_nolock, handling the interlock in a compatible way.
- */
-int
-vop_nounlock(ap)
- struct vop_unlock_args /* {
- struct vnode *a_vp;
- int a_flags;
- struct thread *a_td;
- } */ *ap;
-{
-
- /*
- * Since we are not using the lock manager, we must clear
- * the interlock here.
- */
- if (ap->a_flags & LK_INTERLOCK)
- VI_UNLOCK(ap->a_vp);
- return (0);
-}
-
-/*
- * Return whether or not the node is in use.
- */
-int
-vop_noislocked(ap)
- struct vop_islocked_args /* {
- struct vnode *a_vp;
- struct thread *a_td;
- } */ *ap;
-{
-
- return (0);
-}
-
-/*
* Return our mount point, as we will take charge of the writes.
*/
int
==== //depot/projects/netperf_socket/sys/kern/vfs_subr.c#5 (text+ko) ====
@@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/vfs_subr.c,v 1.487 2004/03/11 18:02:35 phk Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/vfs_subr.c,v 1.488 2004/03/29 22:45:33 peter Exp $");
#include "opt_ddb.h"
#include "opt_mac.h"
@@ -532,7 +532,7 @@
struct mount *mp, *nmp;
int done;
struct proc *p = vnlruproc;
- struct thread *td = FIRST_THREAD_IN_PROC(p); /* XXXKSE */
+ struct thread *td = FIRST_THREAD_IN_PROC(p);
mtx_lock(&Giant);
@@ -1487,7 +1487,7 @@
struct vnode *vp;
struct mount *mp;
long starttime;
- struct thread *td = FIRST_THREAD_IN_PROC(updateproc); /* XXXKSE */
+ struct thread *td = FIRST_THREAD_IN_PROC(updateproc);
mtx_lock(&Giant);
@@ -1591,7 +1591,6 @@
* Request the syncer daemon to speed up its work.
* We never push it to speed up more than half of its
* normal turn time, otherwise it could take over the cpu.
- * XXXKSE only one update?
*/
int
speedup_syncer()
==== //depot/projects/netperf_socket/sys/libkern/index.c#2 (text+ko) ====
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/libkern/index.c,v 1.7 2003/06/11 05:23:04 obrien Exp $");
+__FBSDID("$FreeBSD: src/sys/libkern/index.c,v 1.8 2004/03/29 21:15:41 robert Exp $");
#include <sys/param.h>
#include <sys/libkern.h>
@@ -51,7 +51,7 @@
for (;; ++u.p) {
if (*u.p == ch)
return(u.p);
- if (!*u.p)
+ if (*u.p == '\0')
return(NULL);
}
/* NOTREACHED */
==== //depot/projects/netperf_socket/sys/libkern/rindex.c#2 (text+ko) ====
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/libkern/rindex.c,v 1.8 2003/06/11 05:23:04 obrien Exp $");
+__FBSDID("$FreeBSD: src/sys/libkern/rindex.c,v 1.9 2004/03/29 21:15:41 robert Exp $");
#include <sys/param.h>
#include <sys/libkern.h>
@@ -52,7 +52,7 @@
for (save = NULL;; ++u.p) {
if (*u.p == ch)
save = u.p;
- if (!*u.p)
+ if (*u.p == '\0')
return(save);
}
/* NOTREACHED */
==== //depot/projects/netperf_socket/sys/modules/Makefile#7 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/modules/Makefile,v 1.374 2004/03/25 17:20:45 rik Exp $
+# $FreeBSD: src/sys/modules/Makefile,v 1.375 2004/03/29 22:41:21 peter Exp $
# pcic -- currently broken and being worked on out of tree.
# oldcard -- specialized use for debugging only.
@@ -222,7 +222,6 @@
uhid \
ukbd \
ulpt \
- umapfs \
umass \
umct \
umodem \
==== //depot/projects/netperf_socket/sys/net/if_tun.c#7 (text+ko) ====
@@ -13,7 +13,7 @@
* UCL. This driver is based much more on read/write/poll mode of
* operation though.
*
- * $FreeBSD: src/sys/net/if_tun.c,v 1.138 2004/03/29 18:42:51 rwatson Exp $
+ * $FreeBSD: src/sys/net/if_tun.c,v 1.139 2004/03/29 22:16:39 rwatson Exp $
*/
#include "opt_atalk.h"
@@ -55,6 +55,11 @@
#include <sys/queue.h>
+/*
+ * tun_list is protected by global tunmtx. Other mutable fields are
+ * protected by tun->tun_mtx, or by their owning subsystem. tun_dev is
+ * static for the duration of a tunnel interface.
+ */
struct tun_softc {
TAILQ_ENTRY(tun_softc) tun_list;
dev_t tun_dev;
@@ -82,6 +87,7 @@
struct ifnet tun_if; /* the interface */
struct sigio *tun_sigio; /* information for async I/O */
struct selinfo tun_rsel; /* read select */
+ struct mtx tun_mtx; /* protect mutable softc fields */
};
#define TUNDEBUG if (tundebug) if_printf
@@ -158,6 +164,7 @@
{
dev_t dev;
+ /* Unlocked read. */
KASSERT((tp->tun_flags & TUN_OPEN) == 0,
("tununits is out of sync - unit %d", tp->tun_if.if_dunit));
@@ -165,6 +172,7 @@
bpfdetach(&tp->tun_if);
if_detach(&tp->tun_if);
destroy_dev(dev);
+ mtx_destroy(&tp->tun_mtx);
free(tp, M_TUN);
}
@@ -213,12 +221,16 @@
{
struct tun_softc *tp = ifp->if_softc;
+ mtx_lock(&tp->tun_mtx);
if (tp->tun_flags & TUN_RWAIT) {
tp->tun_flags &= ~TUN_RWAIT;
wakeup(tp);
}
- if (tp->tun_flags & TUN_ASYNC && tp->tun_sigio)
+ if (tp->tun_flags & TUN_ASYNC && tp->tun_sigio) {
+ mtx_unlock(&tp->tun_mtx);
pgsigio(&tp->tun_sigio, SIGIO, 0);
+ } else
+ mtx_unlock(&tp->tun_mtx);
selwakeuppri(&tp->tun_rsel, PZERO + 1);
}
@@ -231,6 +243,7 @@
dev->si_flags &= ~SI_CHEAPCLONE;
MALLOC(sc, struct tun_softc *, sizeof(*sc), M_TUN, M_WAITOK | M_ZERO);
+ mtx_init(&sc->tun_mtx, "tun_mtx", NULL, MTX_DEF);
sc->tun_flags = TUN_INITED;
sc->tun_dev = dev;
mtx_lock(&tunmtx);
@@ -258,17 +271,31 @@
struct ifnet *ifp;
struct tun_softc *tp;
+ /*
+ * XXXRW: Non-atomic test and set of dev->si_drv1 requires
+ * synchronization.
+ */
tp = dev->si_drv1;
if (!tp) {
tuncreate(dev);
tp = dev->si_drv1;
}
- if (tp->tun_pid != 0 && tp->tun_pid != td->td_proc->p_pid)
+ /*
+ * XXXRW: This use of tun_pid is subject to error due to the
+ * fact that a reference to the tunnel can live beyond the
+ * death of the process that created it. Can we replace this
+ * with a simple busy flag?
+ */
+ mtx_lock(&tp->tun_mtx);
+ if (tp->tun_pid != 0 && tp->tun_pid != td->td_proc->p_pid) {
+ mtx_unlock(&tp->tun_mtx);
return (EBUSY);
+ }
tp->tun_pid = td->td_proc->p_pid;
tp->tun_flags |= TUN_OPEN;
+ mtx_unlock(&tp->tun_mtx);
ifp = &tp->tun_if;
TUNDEBUG(ifp, "open\n");
@@ -289,8 +316,10 @@
tp = dev->si_drv1;
ifp = &tp->tun_if;
+ mtx_lock(&tp->tun_mtx);
tp->tun_flags &= ~TUN_OPEN;
tp->tun_pid = 0;
+ mtx_unlock(&tp->tun_mtx);
/*
* junk all pending output
@@ -310,6 +339,7 @@
/* find internet addresses and delete routes */
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
if (ifa->ifa_addr->sa_family == AF_INET)
+ /* Unlocked read. */
rtinit(ifa, (int)RTM_DELETE,
tp->tun_flags & TUN_DSTADDR ? RTF_HOST : 0);
ifp->if_flags &= ~IFF_RUNNING;
@@ -345,12 +375,14 @@
struct sockaddr_in *si;
si = (struct sockaddr_in *)ifa->ifa_addr;
+ mtx_lock(&tp->tun_mtx);
if (si->sin_addr.s_addr)
tp->tun_flags |= TUN_IASET;
si = (struct sockaddr_in *)ifa->ifa_dstaddr;
if (si && si->sin_addr.s_addr)
tp->tun_flags |= TUN_DSTADDR;
+ mtx_unlock(&tp->tun_mtx);
}
#endif
}
@@ -373,9 +405,11 @@
switch(cmd) {
case SIOCGIFSTATUS:
ifs = (struct ifstat *)data;
+ mtx_lock(&tp->tun_mtx);
if (tp->tun_pid)
sprintf(ifs->ascii + strlen(ifs->ascii),
"\tOpened by PID %d\n", tp->tun_pid);
+ mtx_unlock(&tp->tun_mtx);
break;
case SIOCSIFADDR:
error = tuninit(ifp);
@@ -411,6 +445,7 @@
struct rtentry *rt)
{
struct tun_softc *tp = ifp->if_softc;
+ u_short cached_tun_flags;
#ifdef MAC
int error;
#endif
@@ -425,7 +460,11 @@
}
#endif
- if ((tp->tun_flags & TUN_READY) != TUN_READY) {
+ /* Could be unlocked read? */
+ mtx_lock(&tp->tun_mtx);
+ cached_tun_flags = tp->tun_flags;
+ mtx_unlock(&tp->tun_mtx);
+ if ((cached_tun_flags & TUN_READY) != TUN_READY) {
TUNDEBUG (ifp, "not ready 0%o\n", tp->tun_flags);
m_freem (m0);
return (EHOSTDOWN);
@@ -450,7 +489,7 @@
}
/* prepend sockaddr? this may abort if the mbuf allocation fails */
- if (tp->tun_flags & TUN_LMODE) {
+ if (cached_tun_flags & TUN_LMODE) {
/* allocate space for sockaddr */
M_PREPEND(m0, dst->sa_len, M_DONTWAIT);
@@ -464,7 +503,7 @@
}
}
- if (tp->tun_flags & TUN_IFHEAD) {
+ if (cached_tun_flags & TUN_IFHEAD) {
/* Prepend the address family */
M_PREPEND(m0, 4, M_DONTWAIT);
@@ -529,21 +568,28 @@
*(int *)data = tundebug;
break;
case TUNSLMODE:
+ mtx_lock(&tp->tun_mtx);
if (*(int *)data) {
tp->tun_flags |= TUN_LMODE;
tp->tun_flags &= ~TUN_IFHEAD;
} else
tp->tun_flags &= ~TUN_LMODE;
+ mtx_unlock(&tp->tun_mtx);
break;
case TUNSIFHEAD:
+ mtx_lock(&tp->tun_mtx);
if (*(int *)data) {
tp->tun_flags |= TUN_IFHEAD;
tp->tun_flags &= ~TUN_LMODE;
} else
tp->tun_flags &= ~TUN_IFHEAD;
+ mtx_unlock(&tp->tun_mtx);
break;
case TUNGIFHEAD:
+ /* Could be unlocked read? */
+ mtx_lock(&tp->tun_mtx);
*(int *)data = (tp->tun_flags & TUN_IFHEAD) ? 1 : 0;
+ mtx_unlock(&tp->tun_mtx);
break;
case TUNSIFMODE:
/* deny this if UP */
@@ -562,15 +608,19 @@
}
break;
case TUNSIFPID:
+ mtx_lock(&tp->tun_mtx);
tp->tun_pid = curthread->td_proc->p_pid;
+ mtx_unlock(&tp->tun_mtx);
break;
case FIONBIO:
break;
case FIOASYNC:
+ mtx_lock(&tp->tun_mtx);
if (*(int *)data)
tp->tun_flags |= TUN_ASYNC;
else
tp->tun_flags &= ~TUN_ASYNC;
+ mtx_unlock(&tp->tun_mtx);
break;
case FIONREAD:
s = splimp();
@@ -617,12 +667,15 @@
int error=0, len, s;
TUNDEBUG (ifp, "read\n");
+ mtx_lock(&tp->tun_mtx);
if ((tp->tun_flags & TUN_READY) != TUN_READY) {
+ mtx_unlock(&tp->tun_mtx);
TUNDEBUG (ifp, "not ready 0%o\n", tp->tun_flags);
return (EHOSTDOWN);
}
tp->tun_flags &= ~TUN_RWAIT;
+ mtx_unlock(&tp->tun_mtx);
s = splimp();
do {
@@ -632,7 +685,9 @@
splx(s);
return (EWOULDBLOCK);
}
+ mtx_lock(&tp->tun_mtx);
tp->tun_flags |= TUN_RWAIT;
+ mtx_unlock(&tp->tun_mtx);
if((error = tsleep(tp, PCATCH | (PZERO + 1),
"tunread", 0)) != 0) {
splx(s);
@@ -719,14 +774,19 @@
mac_create_mbuf_from_ifnet(ifp, top);
#endif
+ /* Could be unlocked read? */
+ mtx_lock(&tp->tun_mtx);
if (tp->tun_flags & TUN_IFHEAD) {
+ mtx_unlock(&tp->tun_mtx);
if (top->m_len < sizeof(family) &&
(top = m_pullup(top, sizeof(family))) == NULL)
return (ENOBUFS);
family = ntohl(*mtod(top, u_int32_t *));
m_adj(top, sizeof(family));
- } else
+ } else {
+ mtx_unlock(&tp->tun_mtx);
family = AF_INET;
+ }
BPF_MTAP2(ifp, &family, sizeof(family), top);
==== //depot/projects/netperf_socket/sys/powerpc/powerpc/vm_machdep.c#4 (text+ko) ====
@@ -38,7 +38,7 @@
*
* from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
* Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
- * $FreeBSD: src/sys/powerpc/powerpc/vm_machdep.c,v 1.98 2004/03/16 19:04:28 alc Exp $
+ * $FreeBSD: src/sys/powerpc/powerpc/vm_machdep.c,v 1.99 2004/03/29 19:38:05 peter Exp $
*/
/*
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -67,8 +67,6 @@
* rights to redistribute these changes.
*/
-#include "opt_kstack_pages.h"
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
@@ -139,8 +137,8 @@
p1 = td1->td_proc;
- pcb = (struct pcb *)((td2->td_kstack + KSTACK_PAGES * PAGE_SIZE -
- sizeof(struct pcb)) & ~0x2fU);
+ pcb = (struct pcb *)((td2->td_kstack +
+ td2->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb)) & ~0x2fU);
td2->td_pcb = pcb;
/* Copy the pcb */
@@ -357,7 +355,7 @@
{
struct pcb *pcb;
- pcb = (struct pcb *)((td->td_kstack + KSTACK_PAGES * PAGE_SIZE -
+ pcb = (struct pcb *)((td->td_kstack + td2->td_kstack_pages * PAGE_SIZE -
sizeof(struct pcb)) & ~0x2fU);
td->td_pcb = pcb;
td->td_frame = (struct trapframe *)pcb - 1;
==== //depot/projects/netperf_socket/sys/sys/vnode.h#3 (text+ko) ====
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)vnode.h 8.7 (Berkeley) 2/4/94
- * $FreeBSD: src/sys/sys/vnode.h,v 1.234 2004/03/11 16:33:11 phk Exp $
+ * $FreeBSD: src/sys/sys/vnode.h,v 1.235 2004/03/29 22:41:21 peter Exp $
*/
#ifndef _SYS_VNODE_H_
@@ -697,14 +697,10 @@
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list