PERFORCE change 94617 for review

Marcel Moolenaar marcel at FreeBSD.org
Tue Apr 4 17:38:40 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=94617

Change 94617 by marcel at marcel_nfs on 2006/04/04 17:38:04

	IFC @94616

Affected files ...

.. //depot/projects/uart/amd64/amd64/gdb_machdep.c#4 integrate
.. //depot/projects/uart/amd64/include/gdb_machdep.h#3 integrate
.. //depot/projects/uart/dev/acpica/Osd/OsdHardware.c#9 integrate
.. //depot/projects/uart/dev/hwpmc/hwpmc_x86.c#3 integrate
.. //depot/projects/uart/dev/iicbus/iic.c#4 integrate
.. //depot/projects/uart/dev/scc/scc_bfe.h#17 integrate
.. //depot/projects/uart/dev/scc/scc_core.c#21 integrate
.. //depot/projects/uart/i386/i386/exception.s#8 integrate
.. //depot/projects/uart/kern/vfs_bio.c#23 integrate
.. //depot/projects/uart/kern/vfs_subr.c#27 integrate
.. //depot/projects/uart/netinet/in_pcb.c#14 integrate
.. //depot/projects/uart/netinet/tcp_input.c#21 integrate
.. //depot/projects/uart/netinet/tcp_subr.c#18 integrate
.. //depot/projects/uart/netipsec/ipsec.c#10 integrate
.. //depot/projects/uart/netipsec/keysock.c#9 integrate
.. //depot/projects/uart/sys/umtx.h#8 integrate

Differences ...

==== //depot/projects/uart/amd64/amd64/gdb_machdep.c#4 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/gdb_machdep.c,v 1.5 2005/09/27 21:10:10 peter Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/gdb_machdep.c,v 1.6 2006/04/04 03:00:20 marcel Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -91,3 +91,27 @@
 			kdb_frame->tf_rip = *(register_t *)val;
 	}
 }
+
+int
+gdb_cpu_signal(int type, int code)
+{
+
+	switch (type & ~T_USER) {
+	case 0: return (SIGFPE);	/* Divide by zero. */
+	case 1: return (SIGTRAP);	/* Debug exception. */
+	case 3: return (SIGTRAP);	/* Breakpoint. */
+	case 4: return (SIGSEGV);	/* into instr. (overflow). */
+	case 5: return (SIGURG);	/* bound instruction. */
+	case 6: return (SIGILL);	/* Invalid opcode. */
+	case 7: return (SIGFPE);	/* Coprocessor not present. */
+	case 8: return (SIGEMT);	/* Double fault. */
+	case 9: return (SIGSEGV);	/* Coprocessor segment overrun. */
+	case 10: return (SIGTRAP);	/* Invalid TSS (also single-step). */
+	case 11: return (SIGSEGV);	/* Segment not present. */
+	case 12: return (SIGSEGV);	/* Stack exception. */
+	case 13: return (SIGSEGV);	/* General protection. */
+	case 14: return (SIGSEGV);	/* Page fault. */
+	case 16: return (SIGEMT);	/* Coprocessor error. */
+	}
+	return (SIGEMT);
+}

==== //depot/projects/uart/amd64/include/gdb_machdep.h#3 (text+ko) ====

@@ -23,7 +23,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/amd64/include/gdb_machdep.h,v 1.3 2005/01/05 20:17:20 imp Exp $
+ * $FreeBSD: src/sys/amd64/include/gdb_machdep.h,v 1.5 2006/04/04 03:00:20 marcel Exp $
  */
 
 #ifndef _MACHINE_GDB_MACHDEP_H_
@@ -31,7 +31,7 @@
 
 #define	GDB_BUFSZ	500
 #define	GDB_NREGS	56
-#define	GDB_REG_PC	18
+#define	GDB_REG_PC	16
 
 static __inline size_t
 gdb_cpu_regsz(int regnum)
@@ -40,12 +40,6 @@
 }
 
 static __inline int
-gdb_cpu_signal(int type, int code __unused)
-{
-	return (type);
-}
-
-static __inline int
 gdb_cpu_query(void)
 {
 	return (0);
@@ -53,5 +47,6 @@
 
 void *gdb_cpu_getreg(int, size_t *);
 void gdb_cpu_setreg(int, void *);
+int gdb_cpu_signal(int, int);
 
 #endif /* !_MACHINE_GDB_MACHDEP_H_ */

==== //depot/projects/uart/dev/acpica/Osd/OsdHardware.c#9 (text+ko) ====

@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpica/Osd/OsdHardware.c,v 1.19 2006/03/29 18:47:59 njl Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpica/Osd/OsdHardware.c,v 1.20 2006/04/04 02:22:38 njl Exp $");
 
 #include <contrib/dev/acpica/acpi.h>
 
@@ -41,9 +41,9 @@
 
 /*
  * ACPICA's rather gung-ho approach to hardware resource ownership is a little
- * troublesome insofar as there is no easy way for us to know in advance 
+ * troublesome insofar as there is no easy way for us to know in advance
  * exactly which I/O resources it's going to want to use.
- * 
+ *
  * In order to deal with this, we ignore resource ownership entirely, and simply
  * use the native I/O space accessor functionality.  This is Evil, but it works.
  *
@@ -107,7 +107,7 @@
 	error = 0;
 	for (port = illegal_bios_ports; *port != -1; port += 2) {
 		if ((addr >= port[0] && addr <= port[1]) ||
-		    (addr < port[0] && addr + (width / 8) >= port[0])) {
+		    (addr < port[0] && addr + (width / 8) > port[0])) {
 			if (block_bad_io)
 			    error = -1;
 			else
@@ -209,7 +209,7 @@
 	/* debug trap goes here */
 	break;
     }
-    
+
     return (AE_OK);
 }
 
@@ -256,7 +256,7 @@
     status = AcpiGetParent(curr, &parent);
     if (ACPI_FAILURE(status))
 	return (bus);
-    
+
     /* First, recurse up the tree until we find the host bus. */
     bus = acpi_bus_number(root, parent, PciId);
 

==== //depot/projects/uart/dev/hwpmc/hwpmc_x86.c#3 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/hwpmc/hwpmc_x86.c,v 1.4 2005/11/18 16:47:24 ps Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/hwpmc/hwpmc_x86.c,v 1.5 2006/04/04 02:36:04 ps Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -91,7 +91,7 @@
 #if	defined(__i386__) || defined(__amd64__)
 	case 0xF00:		/* P4 */
 		model = ((cpu_id & 0xF0000) >> 12) | ((cpu_id & 0xF0) >> 4);
-		if (model >= 0 && model <= 4) /* known models */
+		if (model >= 0 && model <= 6) /* known models */
 			cputype = PMC_CPU_INTEL_PIV;
 		break;
 	}

==== //depot/projects/uart/dev/iicbus/iic.c#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/sys/dev/iicbus/iic.c,v 1.32 2004/06/16 09:46:45 phk Exp $
+ * $FreeBSD: src/sys/dev/iicbus/iic.c,v 1.33 2006/04/04 17:08:40 imp Exp $
  *
  */
 #include <sys/param.h>
@@ -276,7 +276,7 @@
 		break;
 
 	case I2CRSTCARD:
-		error = iicbus_reset(parent, 0, 0, NULL);
+		error = iicbus_reset(parent, IIC_UNKNOWN, 0, NULL);
 		break;
 
 	case I2CWRITE:

==== //depot/projects/uart/dev/scc/scc_bfe.h#17 (text+ko) ====

@@ -23,7 +23,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/scc/scc_bfe.h,v 1.2 2006/04/01 04:51:56 marcel Exp $
+ * $FreeBSD: src/sys/dev/scc/scc_bfe.h,v 1.3 2006/04/04 17:33:08 marcel Exp $
  */
 
 #ifndef _DEV_SCC_BFE_H_
@@ -85,6 +85,10 @@
 	struct resource ch_rres;
 	struct resource_list ch_rlist;
 
+	struct resource *ch_ires;	/* Interrupt resource. */
+	void		*ch_icookie;
+	int		ch_irid;
+
 	struct scc_mode	ch_mode[SCC_NMODES];
 
 	u_int		ch_nr;
@@ -119,9 +123,6 @@
 	struct resource	*sc_rres;	/* Register resource. */
 	int		sc_rrid;
 	int		sc_rtype;	/* SYS_RES_{IOPORT|MEMORY}. */
-	struct resource *sc_ires;	/* Interrupt resource. */
-	void		*sc_icookie;
-	int		sc_irid;
 
 	struct scc_chan	*sc_chan;
 

==== //depot/projects/uart/dev/scc/scc_core.c#21 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/scc/scc_core.c,v 1.2 2006/04/01 04:51:56 marcel Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/scc/scc_core.c,v 1.3 2006/04/04 17:33:08 marcel Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -134,17 +134,24 @@
 	sc->sc_bas.bsh = rman_get_bushandle(sc->sc_rres);
 	sc->sc_bas.bst = rman_get_bustag(sc->sc_rres);
 
-	sc->sc_irid = 0;
-	sc->sc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->sc_irid,
-	    RF_ACTIVE | RF_SHAREABLE);
+	/*
+	 * Allocate interrupt resources. There may be a different interrupt
+	 * per channel. We allocate them all...
+	 */
+	sc->sc_chan = malloc(sizeof(struct scc_chan) * cl->cl_channels,
+	    M_SCC, M_WAITOK | M_ZERO);
+	for (c = 0; c < cl->cl_channels; c++) {
+		ch = &sc->sc_chan[c];
+		ch->ch_irid = c;
+		ch->ch_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ,
+		    &ch->ch_irid, RF_ACTIVE | RF_SHAREABLE);
+	}
 
 	/*
 	 * Create the control structures for our children. Probe devices
 	 * and query them to see if we can reset the hardware.
 	 */
 	sysdev = 0;
-	sc->sc_chan = malloc(sizeof(struct scc_chan) * cl->cl_channels,
-	    M_SCC, M_WAITOK | M_ZERO);
 	base = rman_get_start(sc->sc_rres);
 	start = base + ((cl->cl_range < 0) ? size * (cl->cl_channels - 1) : 0);
 	for (c = 0; c < cl->cl_channels; c++) {
@@ -163,7 +170,8 @@
 
 		resource_list_add(&ch->ch_rlist, SYS_RES_IRQ, 0, c, c, 1);
 		rle = resource_list_find(&ch->ch_rlist, SYS_RES_IRQ, 0);
-		rle->res = sc->sc_ires;
+		rle->res = (ch->ch_ires != NULL) ? ch->ch_ires :
+			    sc->sc_chan[0].ch_ires;
 
 		for (mode = 0; mode < SCC_NMODES; mode++) {
 			m = &ch->ch_mode[mode];
@@ -204,27 +212,31 @@
 	 * Of course, if we can't setup a fast handler, we make it MPSAFE
 	 * right away.
 	 */
-	if (sc->sc_ires != NULL) {
-		error = bus_setup_intr(dev, sc->sc_ires,
+	for (c = 0; c < cl->cl_channels; c++) {
+		ch = &sc->sc_chan[c];
+		if (ch->ch_ires == NULL)
+			continue;
+		error = bus_setup_intr(dev, ch->ch_ires,
 		    INTR_TYPE_TTY | INTR_FAST, scc_bfe_intr, sc,
-		    &sc->sc_icookie);
+		    &ch->ch_icookie);
 		if (error) {
-			error = bus_setup_intr(dev, sc->sc_ires,
+			error = bus_setup_intr(dev, ch->ch_ires,
 			    INTR_TYPE_TTY | INTR_MPSAFE, scc_bfe_intr, sc,
-			    &sc->sc_icookie);
+			    &ch->ch_icookie);
 		} else
 			sc->sc_fastintr = 1;
 
 		if (error) {
 			device_printf(dev, "could not activate interrupt\n");
-			bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irid,
-			    sc->sc_ires);
-			sc->sc_ires = NULL;
+			bus_release_resource(dev, SYS_RES_IRQ, ch->ch_irid,
+			    ch->ch_ires);
+			ch->ch_ires = NULL;
 		}
 	}
-	if (sc->sc_ires == NULL) {
-		/* XXX no interrupt resource. Force polled mode. */
-		sc->sc_polled = 1;
+	sc->sc_polled = 1;
+	for (c = 0; c < cl->cl_channels; c++) {
+		if (sc->sc_chan[0].ch_ires != NULL)
+			sc->sc_polled = 0;
 	}
 
 	/*
@@ -260,10 +272,12 @@
 	return (0);
 
  fail:
-	if (sc->sc_ires != NULL) {
-		bus_teardown_intr(dev, sc->sc_ires, sc->sc_icookie);
-		bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irid,
-		    sc->sc_ires);
+	for (c = 0; c < cl->cl_channels; c++) {
+		ch = &sc->sc_chan[c];
+		if (ch->ch_ires == NULL)
+			continue;
+		bus_release_resource(dev, SYS_RES_IRQ, ch->ch_irid,
+		    ch->ch_ires);
 	}
 	bus_release_resource(dev, sc->sc_rtype, sc->sc_rrid, sc->sc_rres);
 	return (error);
@@ -299,10 +313,13 @@
 	if (error)
 		return (error);
 
-	if (sc->sc_ires != NULL) {
-		bus_teardown_intr(dev, sc->sc_ires, sc->sc_icookie);
-		bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irid,
-		    sc->sc_ires);
+	for (chan = 0; chan < cl->cl_channels; chan++) {
+		ch = &sc->sc_chan[chan];
+		if (ch->ch_ires == NULL)
+			continue;
+		bus_teardown_intr(dev, ch->ch_ires, ch->ch_icookie);
+		bus_release_resource(dev, SYS_RES_IRQ, ch->ch_irid,
+		    ch->ch_ires);
 	}
 	bus_release_resource(dev, sc->sc_rtype, sc->sc_rrid, sc->sc_rres);
 
@@ -480,9 +497,10 @@
 scc_bus_setup_intr(device_t dev, device_t child, struct resource *r, int flags,
     void (*ihand)(void *), void *arg, void **cookiep)
 {
+	struct scc_chan *ch;
 	struct scc_mode *m;
 	struct scc_softc *sc;
-	int i, isrc;
+	int c, i, isrc;
 
 	if (device_get_parent(child) != dev)
 		return (EINVAL);
@@ -497,9 +515,15 @@
 
 	if (sc->sc_fastintr && !(flags & INTR_FAST)) {
 		sc->sc_fastintr = 0;
-		bus_teardown_intr(dev, sc->sc_ires, sc->sc_icookie);
-		bus_setup_intr(dev, sc->sc_ires, INTR_TYPE_TTY | INTR_MPSAFE,
-		    scc_bfe_intr, sc, &sc->sc_icookie);
+		for (c = 0; c < sc->sc_class->cl_channels; c++) {
+			ch = &sc->sc_chan[c];
+			if (ch->ch_ires == NULL)
+				continue;
+			bus_teardown_intr(dev, ch->ch_ires, ch->ch_icookie);
+			bus_setup_intr(dev, ch->ch_ires,
+			    INTR_TYPE_TTY | INTR_MPSAFE, scc_bfe_intr, sc,
+			    &ch->ch_icookie);
+		}
 	}
 
 	m = device_get_ivars(child);

==== //depot/projects/uart/i386/i386/exception.s#8 (text+ko) ====

@@ -27,7 +27,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/i386/i386/exception.s,v 1.115 2005/12/05 21:44:47 jhb Exp $
+ * $FreeBSD: src/sys/i386/i386/exception.s,v 1.116 2006/04/04 02:26:45 jkoshy Exp $
  */
 
 #include "opt_apic.h"
@@ -118,8 +118,9 @@
 	/*
 	 * alltraps entry point.  Interrupts are enabled if this was a trap
 	 * gate (TGT), else disabled if this was an interrupt gate (IGT).
-	 * Note that int0x80_syscall is a trap gate.  Only page faults
-	 * use an interrupt gate.
+	 * Note that int0x80_syscall is a trap gate.   Interrupt gates are
+	 * used by page faults, non-maskable interrupts, debug and breakpoint
+	 * exceptions.
 	 */
 
 	SUPERALIGN_TEXT

==== //depot/projects/uart/kern/vfs_bio.c#23 (text+ko) ====

@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/vfs_bio.c,v 1.505 2006/03/31 02:56:30 jeff Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/vfs_bio.c,v 1.506 2006/04/04 06:44:21 jeff Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1357,7 +1357,8 @@
 		TAILQ_INSERT_HEAD(&bufqueues[QUEUE_CLEAN], bp, b_freelist);
 	/* remaining buffers */
 	} else {
-		if (bp->b_flags & (B_DELWRI|B_NEEDSGIANT))
+		if ((bp->b_flags & (B_DELWRI|B_NEEDSGIANT)) ==
+		    (B_DELWRI|B_NEEDSGIANT))
 			bp->b_qindex = QUEUE_DIRTY_GIANT;
 		if (bp->b_flags & B_DELWRI)
 			bp->b_qindex = QUEUE_DIRTY;

==== //depot/projects/uart/kern/vfs_subr.c#27 (text+ko) ====

@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/vfs_subr.c,v 1.668 2006/03/31 23:39:26 jeff Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/vfs_subr.c,v 1.669 2006/04/04 06:46:10 jeff Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mac.h"
@@ -640,6 +640,7 @@
 vnlru_free(int count)
 {
 	struct vnode *vp;
+	int vfslocked;
 
 	mtx_assert(&vnode_free_list_mtx, MA_OWNED);
 	for (; count > 0; count--) {
@@ -667,7 +668,9 @@
 		vholdl(vp);
 		mtx_unlock(&vnode_free_list_mtx);
 		VI_UNLOCK(vp);
+		vfslocked = VFS_LOCK_GIANT(vp->v_mount);
 		vtryrecycle(vp);
+		VFS_UNLOCK_GIANT(vfslocked);
 		/*
 		 * If the recycled succeeded this vdrop will actually free
 		 * the vnode.  If not it will simply place it back on

==== //depot/projects/uart/netinet/in_pcb.c#14 (text+ko) ====

@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)in_pcb.c	8.4 (Berkeley) 5/24/95
- * $FreeBSD: src/sys/netinet/in_pcb.c,v 1.171 2006/04/03 13:33:55 rwatson Exp $
+ * $FreeBSD: src/sys/netinet/in_pcb.c,v 1.172 2006/04/04 12:26:07 rwatson Exp $
  */
 
 #include "opt_ipsec.h"
@@ -322,6 +322,8 @@
 		laddr = sin->sin_addr;
 		if (lport) {
 			struct inpcb *t;
+			struct tcptw *tw;
+
 			/* GROSS */
 			if (ntohs(lport) <= ipport_reservedhigh &&
 			    ntohs(lport) >= ipport_reservedlow &&
@@ -355,10 +357,17 @@
 			t = in_pcblookup_local(pcbinfo, sin->sin_addr,
 			    lport, prison ? 0 : wild);
 			if (t && (t->inp_vflag & INP_TIMEWAIT)) {
-				if ((reuseport & intotw(t)->tw_so_options) == 0)
+				/*
+				 * XXXRW: If an incpb has had its timewait
+				 * state recycled, we treat the address as
+				 * being in use (for now).  This is better
+				 * than a panic, but not desirable.
+				 */
+				tw = intotw(inp);
+				if (tw == NULL ||
+				    (reuseport & tw->tw_so_options) == 0)
 					return (EADDRINUSE);
-			} else
-			if (t &&
+			} else if (t &&
 			    (reuseport & t->inp_socket->so_options) == 0) {
 #if defined(INET6)
 				if (ntohl(sin->sin_addr.s_addr) !=
@@ -950,7 +959,8 @@
 				 */
 				if ((inp->inp_vflag & INP_TIMEWAIT) != 0) {
 					tw = intotw(inp);
-					if (tcp_twrecycleable(tw)) {
+					if (tw != NULL &&
+					    tcp_twrecycleable(tw)) {
 						INP_LOCK(inp);
 						tcp_twclose(tw, 0);
 						match = NULL;

==== //depot/projects/uart/netinet/tcp_input.c#21 (text+ko) ====

@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)tcp_input.c	8.12 (Berkeley) 5/24/95
- * $FreeBSD: src/sys/netinet/tcp_input.c,v 1.294 2006/04/03 13:33:55 rwatson Exp $
+ * $FreeBSD: src/sys/netinet/tcp_input.c,v 1.295 2006/04/04 12:26:07 rwatson Exp $
  */
 
 #include "opt_ipfw.h"		/* for ipfw_fwd		*/
@@ -3156,6 +3156,15 @@
 	const int isipv6 = 0;
 #endif
 
+	/*
+	 * XXXRW: Time wait state for inpcb has been recycled, but inpcb is
+	 * still present.  This is undesirable, but temporarily necessary
+	 * until we work out how to handle inpcb's who's timewait state has
+	 * been removed.
+	 */
+	if (tw == NULL)
+		goto drop;
+
 	/* tcbinfo lock required for tcp_twclose(), tcp_2msl_reset. */
 	INP_INFO_WLOCK_ASSERT(&tcbinfo);
 	INP_LOCK_ASSERT(tw->tw_inpcb);

==== //depot/projects/uart/netinet/tcp_subr.c#18 (text+ko) ====

@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)tcp_subr.c	8.2 (Berkeley) 5/24/95
- * $FreeBSD: src/sys/netinet/tcp_subr.c,v 1.244 2006/04/03 14:07:50 rwatson Exp $
+ * $FreeBSD: src/sys/netinet/tcp_subr.c,v 1.246 2006/04/04 14:31:37 glebius Exp $
  */
 
 #include "opt_compat.h"
@@ -177,6 +177,10 @@
 SYSCTL_INT(_net_inet_tcp, OID_AUTO, isn_reseed_interval, CTLFLAG_RW,
     &tcp_isn_reseed_interval, 0, "Seconds between reseeding of ISN secret");
 
+static int	maxtcptw;
+SYSCTL_INT(_net_inet_tcp, OID_AUTO, maxtcptw, CTLFLAG_RDTUN,
+    &maxtcptw, 0, "Maximum number of compressed TCP TIME_WAIT entries");
+
 /*
  * TCP bandwidth limiting sysctls.  Note that the default lower bound of
  * 1024 exists only for debugging.  A good production default would be
@@ -290,9 +294,12 @@
 	tcpcb_zone = uma_zcreate("tcpcb", sizeof(struct tcpcb_mem),
 	    NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
 	uma_zone_set_max(tcpcb_zone, maxsockets);
+	TUNABLE_INT_FETCH("net.inet.tcp.maxtcptw", &maxtcptw);
+	if (maxtcptw == 0)
+		maxtcptw = maxsockets / 5;
 	tcptw_zone = uma_zcreate("tcptw", sizeof(struct tcptw),
 	    NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
-	uma_zone_set_max(tcptw_zone, maxsockets / 5);
+	uma_zone_set_max(tcptw_zone, maxtcptw);
 	tcp_timer_init();
 	syncache_init();
 	tcp_hc_init();
@@ -946,10 +953,13 @@
 			 * TCP state changes, is not quite right, but for
 			 * now, better than nothing.
 			 */
-			if (inp->inp_vflag & INP_TIMEWAIT)
-				error = cr_cansee(req->td->td_ucred,
-				    intotw(inp)->tw_cred);
-			else
+			if (inp->inp_vflag & INP_TIMEWAIT) {
+				if (intotw(inp) != NULL)
+					error = cr_cansee(req->td->td_ucred,
+					    intotw(inp)->tw_cred);
+				else
+					error = EINVAL;	/* Skip this inp. */
+			} else
 				error = cr_canseesocket(req->td->td_ucred,
 				    inp->inp_socket);
 			if (error == 0)
@@ -2323,8 +2333,15 @@
 	if (inp != NULL) {
 		INP_LOCK(inp);
 		if (inp->inp_vflag & INP_TIMEWAIT) {
+			/*
+			 * XXXRW: There currently exists a state where an
+			 * inpcb is present, but its timewait state has been
+			 * discarded.  For now, don't allow dropping of this
+			 * type of inpcb.
+			 */
 			tw = intotw(inp);
-			tcp_twclose(tw, 0);
+			if (tw != NULL)
+				tcp_twclose(tw, 0);
 		} else if (!(inp->inp_vflag & INP_DROPPED) &&
 			   !(inp->inp_socket->so_options & SO_ACCEPTCONN)) {
 			tp = intotcpcb(inp);

==== //depot/projects/uart/netipsec/ipsec.c#10 (text+ko) ====

@@ -1,4 +1,4 @@
-/*	$FreeBSD: src/sys/netipsec/ipsec.c,v 1.13 2006/03/25 13:38:52 gnn Exp $	*/
+/*	$FreeBSD: src/sys/netipsec/ipsec.c,v 1.14 2006/04/04 03:12:21 gnn Exp $	*/
 /*	$KAME: ipsec.c,v 1.103 2001/05/24 07:14:18 sakane Exp $	*/
 
 /*-
@@ -92,7 +92,6 @@
 
 #include <machine/in_cksum.h>
 
-#define IPSEC_DEBUG
 #ifdef IPSEC_DEBUG
 int ipsec_debug = 1;
 #else

==== //depot/projects/uart/netipsec/keysock.c#9 (text+ko) ====

@@ -1,4 +1,4 @@
-/*	$FreeBSD: src/sys/netipsec/keysock.c,v 1.14 2006/04/01 15:42:01 rwatson Exp $	*/
+/*	$FreeBSD: src/sys/netipsec/keysock.c,v 1.15 2006/04/04 10:11:15 dd Exp $	*/
 /*	$KAME: keysock.c,v 1.25 2001/08/13 20:07:41 itojun Exp $	*/
 
 /*-
@@ -460,7 +460,6 @@
 key_detach(struct socket *so)
 {
 	struct keycb *kp = (struct keycb *)sotorawcb(so);
-	int s, error;
 
 	KASSERT(kp != NULL, ("key_detach: kp == NULL"));
 	if (kp->kp_raw.rcb_proto.sp_protocol

==== //depot/projects/uart/sys/umtx.h#8 (text+ko) ====

@@ -23,7 +23,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/sys/umtx.h,v 1.19 2006/03/28 14:32:38 des Exp $
+ * $FreeBSD: src/sys/sys/umtx.h,v 1.20 2006/04/04 02:57:09 davidxu Exp $
  *
  */
 
@@ -40,7 +40,7 @@
 #define	UMTX_CONTESTED	LONG_MIN
 
 struct umtx {
-	void	*u_owner;	/* Owner of the mutex. */
+	uintptr_t	u_owner;	/* Owner of the mutex. */
 };
 
 /* op code for _umtx_op */
@@ -53,8 +53,13 @@
 
 /*
  * System call for userland mutex operations.
+ * Bug: assume sizeof(uintptr_t) == sizeof(long)
  */
-int _umtx_op(struct umtx *umtx, int op, long id, void *uaddr, void *uaddr2);
+int _umtx_wait(struct umtx *umtx, uintptr_t expect,
+	const struct timespec *timeout);
+int _umtx_wake(struct umtx *umtx, int nr_wakeup);
+int _umtx_op(struct umtx *umtx, int op, uintptr_t val,
+	void *uaddr, void *uaddr2);
 
 /*
  * Old (deprecated) userland mutex system calls.
@@ -72,36 +77,33 @@
 	umtx->u_owner = UMTX_UNOWNED;
 }
 
-static __inline long
+static __inline uintptr_t
 umtx_owner(struct umtx *umtx)
 {
-	return ((long)umtx->u_owner & ~LONG_MIN);
+	return (umtx->u_owner & ~LONG_MIN);
 }
 
 static __inline int
-umtx_lock(struct umtx *umtx, long id)
+umtx_lock(struct umtx *umtx, uintptr_t id)
 {
-	if (atomic_cmpset_acq_ptr(&umtx->u_owner, (void *)UMTX_UNOWNED,
-	    (void *)id) == 0)
+	if (atomic_cmpset_acq_ptr(&umtx->u_owner, UMTX_UNOWNED, id) == 0)
 		if (_umtx_lock(umtx) == -1)
 			return (errno);
 	return (0);
 }
 
 static __inline int
-umtx_trylock(struct umtx *umtx, long id)
+umtx_trylock(struct umtx *umtx, uintptr_t id)
 {
-	if (atomic_cmpset_acq_ptr(&umtx->u_owner, (void *)UMTX_UNOWNED,
-	    (void *)id) == 0)
+	if (atomic_cmpset_acq_ptr(&umtx->u_owner, UMTX_UNOWNED, id) == 0)
 		return (EBUSY);
 	return (0);
 }
 
 static __inline int
-umtx_timedlock(struct umtx *umtx, long id, const struct timespec *timeout)
+umtx_timedlock(struct umtx *umtx, uintptr_t id, const struct timespec *timeout)
 {
-	if (atomic_cmpset_acq_ptr(&umtx->u_owner, (void *)UMTX_UNOWNED,
-	    (void *)id) == 0)
+	if (atomic_cmpset_acq_ptr(&umtx->u_owner, UMTX_UNOWNED, id) == 0)
 		if (_umtx_op(umtx, UMTX_OP_LOCK, id, 0,
 		    __DECONST(void *, timeout)) == -1)
 			return (errno);
@@ -109,10 +111,9 @@
 }
 
 static __inline int
-umtx_unlock(struct umtx *umtx, long id)
+umtx_unlock(struct umtx *umtx, uintptr_t id)
 {
-	if (atomic_cmpset_rel_ptr(&umtx->u_owner, (void *)id,
-	    (void *)UMTX_UNOWNED) == 0)
+	if (atomic_cmpset_rel_ptr(&umtx->u_owner, id, UMTX_UNOWNED) == 0)
 		if (_umtx_unlock(umtx) == -1)
 			return (errno);
 	return (0);


More information about the p4-projects mailing list