Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Sep 2008 21:13:19 GMT
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 149974 for review
Message-ID:  <200809172113.m8HLDJpi042248@repoman.freebsd.org>

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

Change 149974 by peter@peter_daintree on 2008/09/17 21:12:20

	IFC @149966

Affected files ...

.. //depot/projects/hammer/ObsoleteFiles.inc#60 integrate
.. //depot/projects/hammer/contrib/libpcap/pcap-bpf.c#12 integrate
.. //depot/projects/hammer/contrib/libpcap/pcap-int.h#8 integrate
.. //depot/projects/hammer/contrib/libpcap/pcap.c#8 integrate
.. //depot/projects/hammer/etc/defaults/rc.conf#90 integrate
.. //depot/projects/hammer/etc/rc.d/jail#24 integrate
.. //depot/projects/hammer/include/uuid.h#3 integrate
.. //depot/projects/hammer/lib/libc/rpc/clnt_dg.c#8 integrate
.. //depot/projects/hammer/lib/libc/uuid/Symbol.map#3 integrate
.. //depot/projects/hammer/lib/libpmc/Makefile#5 integrate
.. //depot/projects/hammer/lib/libpmc/libpmc.c#10 integrate
.. //depot/projects/hammer/lib/libpmc/pmc.3#16 integrate
.. //depot/projects/hammer/lib/libpmc/pmc.k7.3#1 branch
.. //depot/projects/hammer/lib/libpmc/pmc.k8.3#1 branch
.. //depot/projects/hammer/lib/libpmc/pmc.p4.3#1 branch
.. //depot/projects/hammer/lib/libpmc/pmc.p5.3#1 branch
.. //depot/projects/hammer/lib/libpmc/pmc.p6.3#1 branch
.. //depot/projects/hammer/lib/libpmc/pmc.tsc.3#1 branch
.. //depot/projects/hammer/libexec/rtld-elf/rtld_lock.c#6 integrate
.. //depot/projects/hammer/release/doc/zh_CN.GB2312/Makefile#4 integrate
.. //depot/projects/hammer/release/doc/zh_CN.GB2312/errata/Makefile#3 integrate
.. //depot/projects/hammer/release/doc/zh_CN.GB2312/errata/article.sgml#5 integrate
.. //depot/projects/hammer/release/doc/zh_CN.GB2312/hardware/Makefile#3 integrate
.. //depot/projects/hammer/release/doc/zh_CN.GB2312/hardware/article.sgml#2 integrate
.. //depot/projects/hammer/release/doc/zh_CN.GB2312/readme/Makefile#2 integrate
.. //depot/projects/hammer/release/doc/zh_CN.GB2312/readme/article.sgml#4 integrate
.. //depot/projects/hammer/release/doc/zh_CN.GB2312/relnotes/Makefile#4 integrate
.. //depot/projects/hammer/release/doc/zh_CN.GB2312/relnotes/article.sgml#2 integrate
.. //depot/projects/hammer/release/doc/zh_CN.GB2312/share/sgml/catalog#2 integrate
.. //depot/projects/hammer/release/doc/zh_CN.GB2312/share/sgml/release.dsl#3 integrate
.. //depot/projects/hammer/sbin/fsck_ffs/fsck_ffs.8#10 integrate
.. //depot/projects/hammer/share/man/man4/ddb.4#20 integrate
.. //depot/projects/hammer/share/man/man4/snd_hda.4#10 integrate
.. //depot/projects/hammer/share/man/man5/rc.conf.5#93 integrate
.. //depot/projects/hammer/share/man/man9/DB_COMMAND.9#1 branch
.. //depot/projects/hammer/share/man/man9/Makefile#86 integrate
.. //depot/projects/hammer/share/man/man9/priv.9#5 integrate
.. //depot/projects/hammer/share/man/man9/suser.9#14 delete
.. //depot/projects/hammer/share/man/man9/ucred.9#4 integrate
.. //depot/projects/hammer/share/man/man9/vfs_suser.9#4 integrate
.. //depot/projects/hammer/share/zoneinfo/africa#10 integrate
.. //depot/projects/hammer/share/zoneinfo/asia#16 integrate
.. //depot/projects/hammer/share/zoneinfo/europe#14 integrate
.. //depot/projects/hammer/share/zoneinfo/southamerica#18 integrate
.. //depot/projects/hammer/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c#3 integrate
.. //depot/projects/hammer/sys/compat/freebsd32/freebsd32_misc.c#57 integrate
.. //depot/projects/hammer/sys/compat/freebsd32/freebsd32_proto.h#57 integrate
.. //depot/projects/hammer/sys/compat/freebsd32/freebsd32_syscall.h#54 integrate
.. //depot/projects/hammer/sys/compat/freebsd32/freebsd32_syscalls.c#54 integrate
.. //depot/projects/hammer/sys/compat/freebsd32/freebsd32_sysent.c#54 integrate
.. //depot/projects/hammer/sys/compat/freebsd32/syscalls.master#59 integrate
.. //depot/projects/hammer/sys/compat/svr4/svr4_stream.c#22 integrate
.. //depot/projects/hammer/sys/compat/svr4/svr4_sysvec.c#20 integrate
.. //depot/projects/hammer/sys/ddb/db_command.c#24 integrate
.. //depot/projects/hammer/sys/ddb/ddb.h#17 integrate
.. //depot/projects/hammer/sys/dev/aic7xxx/aic79xx_osm.c#23 integrate
.. //depot/projects/hammer/sys/dev/cxgb/common/cxgb_t3_hw.c#10 integrate
.. //depot/projects/hammer/sys/dev/cxgb/cxgb_adapter.h#20 integrate
.. //depot/projects/hammer/sys/dev/cxgb/cxgb_config.h#7 integrate
.. //depot/projects/hammer/sys/dev/cxgb/cxgb_include.h#5 integrate
.. //depot/projects/hammer/sys/dev/cxgb/cxgb_main.c#24 integrate
.. //depot/projects/hammer/sys/dev/cxgb/cxgb_offload.h#10 integrate
.. //depot/projects/hammer/sys/dev/cxgb/cxgb_osdep.h#12 integrate
.. //depot/projects/hammer/sys/dev/cxgb/cxgb_sge.c#22 integrate
.. //depot/projects/hammer/sys/dev/cxgb/sys/cxgb_support.c#6 integrate
.. //depot/projects/hammer/sys/dev/cxgb/sys/mbufq.h#4 integrate
.. //depot/projects/hammer/sys/dev/cxgb/ulp/toecore/cxgb_toedev.h#3 integrate
.. //depot/projects/hammer/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#10 integrate
.. //depot/projects/hammer/sys/dev/cxgb/ulp/tom/cxgb_cpl_socket.c#10 integrate
.. //depot/projects/hammer/sys/dev/cxgb/ulp/tom/cxgb_ddp.c#6 integrate
.. //depot/projects/hammer/sys/dev/cxgb/ulp/tom/cxgb_tom.c#6 integrate
.. //depot/projects/hammer/sys/dev/pci/vga_pci.c#3 integrate
.. //depot/projects/hammer/sys/dev/ppbus/if_plip.c#18 integrate
.. //depot/projects/hammer/sys/dev/ppbus/lpt.c#15 integrate
.. //depot/projects/hammer/sys/dev/ppbus/ppbconf.c#7 integrate
.. //depot/projects/hammer/sys/dev/ppbus/ppbconf.h#4 integrate
.. //depot/projects/hammer/sys/dev/ppbus/ppi.c#12 integrate
.. //depot/projects/hammer/sys/dev/ppbus/pps.c#15 integrate
.. //depot/projects/hammer/sys/dev/ppc/ppc.c#14 integrate
.. //depot/projects/hammer/sys/dev/ppc/ppc_acpi.c#3 integrate
.. //depot/projects/hammer/sys/dev/ppc/ppc_isa.c#3 integrate
.. //depot/projects/hammer/sys/dev/ppc/ppc_pci.c#2 integrate
.. //depot/projects/hammer/sys/dev/ppc/ppc_puc.c#4 integrate
.. //depot/projects/hammer/sys/dev/ppc/ppcreg.h#4 integrate
.. //depot/projects/hammer/sys/dev/ppc/ppcvar.h#5 integrate
.. //depot/projects/hammer/sys/dev/sound/pci/hda/hdac.c#21 integrate
.. //depot/projects/hammer/sys/gnu/fs/ext2fs/ext2_inode.c#5 integrate
.. //depot/projects/hammer/sys/gnu/fs/xfs/FreeBSD/support/kdb.c#4 integrate
.. //depot/projects/hammer/sys/i386/conf/GENERIC#72 integrate
.. //depot/projects/hammer/sys/i386/i386/identcpu.c#44 integrate
.. //depot/projects/hammer/sys/i386/include/specialreg.h#19 integrate
.. //depot/projects/hammer/sys/i386/xen/xen_machdep.c#3 integrate
.. //depot/projects/hammer/sys/kern/kern_intr.c#53 integrate
.. //depot/projects/hammer/sys/kern/kern_priv.c#5 integrate
.. //depot/projects/hammer/sys/kern/kern_proc.c#71 integrate
.. //depot/projects/hammer/sys/kern/subr_pcpu.c#7 integrate
.. //depot/projects/hammer/sys/kern/subr_rman.c#26 integrate
.. //depot/projects/hammer/sys/kern/subr_sleepqueue.c#33 integrate
.. //depot/projects/hammer/sys/kern/subr_turnstile.c#30 integrate
.. //depot/projects/hammer/sys/kern/subr_witness.c#76 integrate
.. //depot/projects/hammer/sys/kern/tty.c#62 integrate
.. //depot/projects/hammer/sys/kern/vfs_bio.c#91 integrate
.. //depot/projects/hammer/sys/kern/vfs_vnops.c#57 integrate
.. //depot/projects/hammer/sys/modules/svr4/Makefile#7 integrate
.. //depot/projects/hammer/sys/modules/wlan/Makefile#11 integrate
.. //depot/projects/hammer/sys/netipx/ipx.c#9 integrate
.. //depot/projects/hammer/sys/nfsserver/nfs.h#15 integrate
.. //depot/projects/hammer/sys/nfsserver/nfs_serv.c#44 integrate
.. //depot/projects/hammer/sys/nfsserver/nfs_srvsock.c#26 integrate
.. //depot/projects/hammer/sys/nfsserver/nfs_srvsubs.c#34 integrate
.. //depot/projects/hammer/sys/nfsserver/nfs_syscalls.c#27 integrate
.. //depot/projects/hammer/sys/powerpc/aim/clock.c#5 integrate
.. //depot/projects/hammer/sys/powerpc/aim/mmu_oea.c#6 integrate
.. //depot/projects/hammer/sys/powerpc/aim/mp_cpudep.c#3 integrate
.. //depot/projects/hammer/sys/powerpc/aim/swtch.S#4 integrate
.. //depot/projects/hammer/sys/powerpc/aim/trap_subr.S#4 integrate
.. //depot/projects/hammer/sys/powerpc/include/cpufunc.h#9 integrate
.. //depot/projects/hammer/sys/powerpc/include/smp.h#3 integrate
.. //depot/projects/hammer/sys/powerpc/powerpc/mp_machdep.c#9 integrate
.. //depot/projects/hammer/sys/security/mac_bsdextended/mac_bsdextended.c#32 integrate
.. //depot/projects/hammer/sys/sys/interrupt.h#20 integrate
.. //depot/projects/hammer/sys/sys/mount.h#56 integrate
.. //depot/projects/hammer/sys/sys/param.h#118 integrate
.. //depot/projects/hammer/sys/sys/priv.h#11 integrate
.. //depot/projects/hammer/sys/sys/proc.h#123 integrate
.. //depot/projects/hammer/sys/sys/ttydisc.h#2 integrate
.. //depot/projects/hammer/sys/sys/vnode.h#83 integrate
.. //depot/projects/hammer/sys/ufs/ffs/ffs_extern.h#18 integrate
.. //depot/projects/hammer/sys/ufs/ffs/ffs_inode.c#21 integrate
.. //depot/projects/hammer/sys/ufs/ffs/ffs_snapshot.c#56 integrate
.. //depot/projects/hammer/sys/ufs/ffs/ffs_softdep.c#56 integrate
.. //depot/projects/hammer/sys/ufs/ffs/ffs_vfsops.c#78 integrate
.. //depot/projects/hammer/sys/ufs/ufs/dirhash.h#5 integrate
.. //depot/projects/hammer/sys/ufs/ufs/inode.h#15 integrate
.. //depot/projects/hammer/sys/ufs/ufs/ufs_dirhash.c#11 integrate
.. //depot/projects/hammer/sys/ufs/ufs/ufs_inode.c#22 integrate
.. //depot/projects/hammer/sys/ufs/ufs/ufs_lookup.c#25 integrate
.. //depot/projects/hammer/sys/ufs/ufs/ufs_vnops.c#56 integrate
.. //depot/projects/hammer/sys/ufs/ufs/ufsmount.h#12 integrate
.. //depot/projects/hammer/usr.sbin/portsnap/portsnap/portsnap.8#8 integrate
.. //depot/projects/hammer/usr.sbin/ypbind/yp_ping.c#4 integrate

Differences ...

==== //depot/projects/hammer/ObsoleteFiles.inc#60 (text+ko) ====

@@ -1,5 +1,5 @@
 #
-# $FreeBSD: src/ObsoleteFiles.inc,v 1.160 2008/09/14 17:49:46 antoine Exp $
+# $FreeBSD: src/ObsoleteFiles.inc,v 1.161 2008/09/17 15:49:44 attilio Exp $
 #
 # This file lists old files (OLD_FILES), libraries (OLD_LIBS) and
 # directories (OLD_DIRS) which should get removed at an update. Recently
@@ -14,6 +14,8 @@
 # The file is partitioned: OLD_FILES first, then OLD_LIBS and OLD_DIRS last.
 #
 
+# 20080917: removal of manpage for axed kernel primitive suser(9)
+OLD_FILES+=usr/share/man/man9/suser.9
 # 20080913: pax removed from rescue
 OLD_FILES+=rescue/pax
 # 20080823: removal of unneeded pt_chown, to implement grantpt(3)

==== //depot/projects/hammer/contrib/libpcap/pcap-bpf.c#12 (text+ko) ====

@@ -18,7 +18,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * $FreeBSD: src/contrib/libpcap/pcap-bpf.c,v 1.4 2007/10/16 02:07:55 mlaier Exp $
+ * $FreeBSD: src/contrib/libpcap/pcap-bpf.c,v 1.5 2008/09/16 20:32:29 csjp Exp $
  */
 #ifndef lint
 static const char rcsid[] _U_ =
@@ -30,6 +30,7 @@
 #endif
 
 #include <sys/param.h>			/* optionally get BSD define */
+#include <sys/mman.h>
 #include <sys/time.h>
 #include <sys/timeb.h>
 #include <sys/socket.h>
@@ -86,6 +87,10 @@
 
 #endif /* _AIX */
 
+#ifdef BIOCSETBUFMODE
+#include <machine/atomic.h>
+#endif
+
 #include <ctype.h>
 #include <errno.h>
 #include <netdb.h>
@@ -139,6 +144,159 @@
 	return (0);
 }
 
+#ifdef BIOCGETBUFMODE
+/*
+ * Zero-copy BPF buffer routines to check for and acknowledge BPF data in
+ * shared memory buffers.
+ *
+ * pcap_next_zbuf_shm(): Check for a newly available shared memory buffer,
+ * and set up p->buffer and cc to reflect one if available.  Notice that if
+ * there was no prior buffer, we select zbuf1 as this will be the first
+ * buffer filled for a fresh BPF session.
+ */
+static int
+pcap_next_zbuf_shm(pcap_t *p, int *cc)
+{
+	struct bpf_zbuf_header *bzh;
+
+	if (p->zbuffer == p->zbuf2 || p->zbuffer == NULL) {
+		bzh = (struct bpf_zbuf_header *)p->zbuf1;
+		if (bzh->bzh_user_gen !=
+		    atomic_load_acq_int(&bzh->bzh_kernel_gen)) {
+			p->bzh = bzh;
+			p->zbuffer = (u_char *)p->zbuf1;
+			p->buffer = p->zbuffer + sizeof(*bzh);
+			*cc = bzh->bzh_kernel_len;
+			return (1);
+		}
+	} else if (p->zbuffer == p->zbuf1) {
+		bzh = (struct bpf_zbuf_header *)p->zbuf2;
+		if (bzh->bzh_user_gen !=
+		    atomic_load_acq_int(&bzh->bzh_kernel_gen)) {
+			p->bzh = bzh;
+			p->zbuffer = (u_char *)p->zbuf2;
+			p->buffer = p->zbuffer + sizeof(*bzh);
+			*cc = bzh->bzh_kernel_len;
+			return (1);
+		}
+	}
+	*cc = 0;
+	return (0);
+}
+
+/*
+ * pcap_next_zbuf() -- Similar to pcap_next_zbuf_shm(), except wait using
+ * select() for data or a timeout, and possibly force rotation of the buffer
+ * in the event we time out or are in immediate mode.  Invoke the shared
+ * memory check before doing system calls in order to avoid doing avoidable
+ * work.
+ */
+static int
+pcap_next_zbuf(pcap_t *p, int *cc)
+{
+	struct bpf_zbuf bz;
+	struct timeval tv;
+	struct timespec cur;
+	fd_set r_set;
+	int data, r;
+	int tmout, expire;
+
+#define TSTOMILLI(ts) (((ts)->tv_sec * 1000) + ((ts)->tv_nsec / 1000000))
+	/*
+	 * Start out by seeing whether anything is waiting by checking the
+	 * next shared memory buffer for data.
+	 */
+	data = pcap_next_zbuf_shm(p, cc);
+	if (data)
+		return (data);
+	/*
+	 * If a previous sleep was interrupted due to signal delivery, make
+	 * sure that the timeout gets adjusted accordingly.  This requires
+	 * that we analyze when the timeout should be been expired, and
+	 * subtract the current time from that.  If after this operation,
+	 * our timeout is less then or equal to zero, handle it like a
+	 * regular timeout.
+	 */
+	tmout = p->to_ms;
+	if (tmout)
+		(void) clock_gettime(CLOCK_MONOTONIC, &cur);
+	if (p->interrupted && p->to_ms) {
+		expire = TSTOMILLI(&p->firstsel) + p->to_ms;
+		tmout = expire - TSTOMILLI(&cur);
+#undef TSTOMILLI
+		if (tmout <= 0) {
+			p->interrupted = 0;
+			data = pcap_next_zbuf_shm(p, cc);
+			if (data)
+				return (data);
+			if (ioctl(p->fd, BIOCROTZBUF, &bz) < 0) {
+				(void) snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+				    "BIOCROTZBUF: %s", strerror(errno));
+				return (-1);
+			}
+			return (pcap_next_zbuf_shm(p, cc));
+		}
+	}
+	/*
+	 * No data in the buffer, so must use select() to wait for data or
+	 * the next timeout.
+	 */
+	FD_ZERO(&r_set);
+	FD_SET(p->fd, &r_set);
+	if (tmout != 0) {
+		tv.tv_sec = tmout / 1000;
+		tv.tv_usec = (tmout * 1000) % 1000000;
+	}
+	r = select(p->fd + 1, &r_set, NULL, NULL, p->to_ms != 0 ? &tv :
+	    NULL);
+	if (r < 0 && errno == EINTR) {
+		if (!p->interrupted && p->to_ms) {
+			p->interrupted = 1;
+			p->firstsel = cur;
+		}
+		return (0);
+	} else if (r < 0) {
+		(void) snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+		    "select: %s", strerror(errno));
+		return (-1);
+	}
+	p->interrupted = 0;
+	/*
+	 * Check again for data, which may exist now that we've either been
+	 * woken up as a result of data or timed out.  Try the "there's data"
+	 * case first since it doesn't require a system call.
+	 */
+	data = pcap_next_zbuf_shm(p, cc);
+	if (data)
+		return (data);
+
+	/*
+	 * Try forcing a buffer rotation to dislodge timed out or immediate
+	 * data.
+	 */
+	if (ioctl(p->fd, BIOCROTZBUF, &bz) < 0) {
+		(void) snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+		    "BIOCROTZBUF: %s", strerror(errno));
+		return (-1);
+	}
+	return (pcap_next_zbuf_shm(p, cc));
+}
+
+/*
+ * Notify kernel that we are done with the buffer.  We don't reset zbuffer so
+ * that we know which buffer to use next time around.
+ */
+static int
+pcap_ack_zbuf(pcap_t *p)
+{
+
+	atomic_store_rel_int(&p->bzh->bzh_user_gen, p->bzh->bzh_kernel_gen);
+	p->bzh = NULL;
+	p->buffer = NULL;
+	return (0);
+}
+#endif
+
 static int
 pcap_read_bpf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
 {
@@ -147,6 +305,9 @@
 	register u_char *bp, *ep;
 	u_char *datap;
 	struct bpf_insn *fcode;
+#ifdef BIOCSETBUFMODE
+	int i;
+#endif
 #ifdef PCAP_FDDIPAD
 	register int pad;
 #endif
@@ -167,7 +328,27 @@
 	}
 	cc = p->cc;
 	if (p->cc == 0) {
-		cc = read(p->fd, (char *)p->buffer, p->bufsize);
+		/*
+		 * When reading without zero-copy from a file descriptor, we
+		 * use a single buffer and return a length of data in the
+		 * buffer.  With zero-copy, we update the p->buffer pointer
+		 * to point at whatever underlying buffer contains the next
+		 * data and update cc to reflect the data found in the
+		 * buffer.
+		 */
+#ifdef BIOCSETBUFMODE
+		if (p->zerocopy) {
+			if (p->buffer != NULL)
+				pcap_ack_zbuf(p);
+			i = pcap_next_zbuf(p, &cc);
+			if (i == 0)
+				goto again;
+			if (i < 0)
+				return (-1);
+		} else
+#endif
+			cc = read(p->fd, (char *)p->buffer, p->bufsize);
+
 		if (cc < 0) {
 			/* Don't choke when we get ptraced */
 			switch (errno) {
@@ -609,6 +790,10 @@
 	struct bpf_insn total_insn;
 	struct bpf_program total_prog;
 	struct utsname osinfo;
+#ifdef BIOCSETBUFMODE
+	struct bpf_zbuf bz;
+	u_int bufmode, zbufmax;
+#endif
 
 #ifdef HAVE_DAG_API
 	if (strstr(device, "dag")) {
@@ -646,41 +831,105 @@
 		goto bad;
 	}
 
+#ifdef BIOCSETBUFMODE
 	/*
-	 * Try finding a good size for the buffer; 32768 may be too
-	 * big, so keep cutting it in half until we find a size
-	 * that works, or run out of sizes to try.  If the default
-	 * is larger, don't make it smaller.
-	 *
-	 * XXX - there should be a user-accessible hook to set the
-	 * initial buffer size.
+	 * If the BPF extension to set buffer mode is present, try setting
+	 * the mode to zero-copy.  If that fails, use regular buffering.  If
+	 * it succeeds but other setup fails, return an error to the user.
 	 */
-	if ((ioctl(fd, BIOCGBLEN, (caddr_t)&v) < 0) || v < 32768)
-		v = 32768;
-	for ( ; v != 0; v >>= 1) {
-		/* Ignore the return value - this is because the call fails
-		 * on BPF systems that don't have kernel malloc.  And if
-		 * the call fails, it's no big deal, we just continue to
-		 * use the standard buffer size.
+	bufmode = BPF_BUFMODE_ZBUF;
+	if (ioctl(fd, BIOCSETBUFMODE, (caddr_t)&bufmode) == 0) {
+		p->zerocopy = 1;
+
+		/*
+		 * How to pick a buffer size: first, query the maximum buffer
+		 * size supported by zero-copy.  This also lets us quickly
+		 * determine whether the kernel generally supports zero-copy.
+		 * Then, query the default buffer size, which reflects kernel
+		 * policy for a desired default.  Round to the nearest page
+		 * size.
 		 */
-		(void) ioctl(fd, BIOCSBLEN, (caddr_t)&v);
-
+		if (ioctl(fd, BIOCGETZMAX, (caddr_t)&zbufmax) < 0) {
+			snprintf(ebuf, PCAP_ERRBUF_SIZE, "BIOCGETZMAX: %s",
+			    pcap_strerror(errno));
+			goto bad;
+		}
+		if ((ioctl(fd, BIOCGBLEN, (caddr_t)&v) < 0) || v < 32768)
+			v = 32768;
+#ifndef roundup
+#define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))  /* to any y */
+#endif
+		p->zbufsize = roundup(v, getpagesize());
+		if (p->zbufsize > zbufmax)
+			p->zbufsize = zbufmax;
+		p->zbuf1 = mmap(NULL, p->zbufsize, PROT_READ | PROT_WRITE,
+		    MAP_ANON, -1, 0);
+		p->zbuf2 = mmap(NULL, p->zbufsize, PROT_READ | PROT_WRITE,
+		    MAP_ANON, -1, 0);
+		if (p->zbuf1 == MAP_FAILED || p->zbuf2 == MAP_FAILED) {
+			snprintf(ebuf, PCAP_ERRBUF_SIZE, "mmap: %s",
+			    pcap_strerror(errno));
+			goto bad;
+		}
+		bzero(&bz, sizeof(bz));
+		bz.bz_bufa = p->zbuf1;
+		bz.bz_bufb = p->zbuf2;
+		bz.bz_buflen = p->zbufsize;
+		if (ioctl(fd, BIOCSETZBUF, (caddr_t)&bz) < 0) {
+			snprintf(ebuf, PCAP_ERRBUF_SIZE, "BIOCSETZBUF: %s",
+			    pcap_strerror(errno));
+			goto bad;
+		}
 		(void)strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
-		if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) >= 0)
-			break;	/* that size worked; we're done */
-
-		if (errno != ENOBUFS) {
+		if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) {
 			snprintf(ebuf, PCAP_ERRBUF_SIZE, "BIOCSETIF: %s: %s",
 			    device, pcap_strerror(errno));
 			goto bad;
 		}
-	}
+		v = p->zbufsize - sizeof(struct bpf_zbuf_header);
+	} else {
+#endif
+
+		/*
+		 * Try finding a good size for the buffer; 32768 may be too
+		 * big, so keep cutting it in half until we find a size
+		 * that works, or run out of sizes to try.  If the default
+		 * is larger, don't make it smaller.
+		 *
+		 * XXX - there should be a user-accessible hook to set the
+		 * initial buffer size.
+		 */
+		if ((ioctl(fd, BIOCGBLEN, (caddr_t)&v) < 0) || v < 32768)
+			v = 32768;
+		for ( ; v != 0; v >>= 1) {
+			/* Ignore the return value - this is because the call
+			 * fails on BPF systems that don't have kernel
+			 * malloc.  And if the call fails, it's no big deal,
+			 * we just continue to use the standard buffer size.
+			 */
+			(void) ioctl(fd, BIOCSBLEN, (caddr_t)&v);
+
+			(void)strncpy(ifr.ifr_name, device,
+			    sizeof(ifr.ifr_name));
+			if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) >= 0)
+				break;	/* that size worked; we're done */
+
+			if (errno != ENOBUFS) {
+				snprintf(ebuf, PCAP_ERRBUF_SIZE,
+				    "BIOCSETIF: %s: %s",
+				    device, pcap_strerror(errno));
+				goto bad;
+			}
+		}
 
-	if (v == 0) {
-		snprintf(ebuf, PCAP_ERRBUF_SIZE,
-			 "BIOCSBLEN: %s: No buffer size worked", device);
-		goto bad;
+		if (v == 0) {
+			snprintf(ebuf, PCAP_ERRBUF_SIZE,
+			    "BIOCSBLEN: %s: No buffer size worked", device);
+			goto bad;
+		}
+#ifdef BIOCSETBUFMODE
 	}
+#endif
 
 	/* Get the data link layer type. */
 	if (ioctl(fd, BIOCGDLT, (caddr_t)&v) < 0) {
@@ -855,7 +1104,8 @@
 	}
 #endif
 	/* set timeout */
-	if (to_ms != 0) {
+	p->to_ms = to_ms;
+	if (to_ms != 0 && !p->zerocopy) {
 		/*
 		 * XXX - is this seconds/nanoseconds in AIX?
 		 * (Treating it as such doesn't fix the timeout
@@ -870,6 +1120,9 @@
 			goto bad;
 		}
 	}
+#ifdef BIOCSETBUFMODE
+	p->timeout = to_ms;
+#endif
 
 #ifdef _AIX
 #ifdef	BIOCIMMEDIATE
@@ -942,16 +1195,22 @@
 		goto bad;
 	}
 	p->bufsize = v;
-	p->buffer = (u_char *)malloc(p->bufsize);
-	if (p->buffer == NULL) {
-		snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s",
-		    pcap_strerror(errno));
-		goto bad;
+#ifdef BIOCSETBUFMODE
+	if (!p->zerocopy) {
+#endif
+		p->buffer = (u_char *)malloc(p->bufsize);
+		if (p->buffer == NULL) {
+			snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s",
+			    pcap_strerror(errno));
+			goto bad;
+		}
+#ifdef _AIX
+		/* For some strange reason this seems to prevent the EFAULT 
+		 * problems we have experienced from AIX BPF. */
+		memset(p->buffer, 0x0, p->bufsize);
+#endif
+#ifdef BIOCSETBUFMODE
 	}
-#ifdef _AIX
-	/* For some strange reason this seems to prevent the EFAULT 
-	 * problems we have experienced from AIX BPF. */
-	memset(p->buffer, 0x0, p->bufsize);
 #endif
 
 	/*
@@ -1036,7 +1295,22 @@
 
 	return (p);
  bad:
+
 	(void)close(fd);
+#ifdef BIOCSETBUFMODE
+	/*
+	 * In zero-copy mode, p->buffer is just a pointer into one of the two
+	 * memory-mapped buffers, so no need to free it.
+	 */
+	if (p->zerocopy) {
+		if (p->zbuf1 != MAP_FAILED && p->zbuf1 != NULL)
+			munmap(p->zbuf1, p->zbufsize);
+		if (p->zbuf2 != MAP_FAILED && p->zbuf2 != NULL)
+			munmap(p->zbuf2, p->zbufsize);
+	} else
+#endif
+	if (p->buffer != NULL)
+		free(p->buffer);
 	if (p->dlt_list != NULL)
 		free(p->dlt_list);
 	free(p);

==== //depot/projects/hammer/contrib/libpcap/pcap-int.h#8 (text+ko) ====

@@ -30,7 +30,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/contrib/libpcap/pcap-int.h,v 1.13 2007/10/16 02:07:55 mlaier Exp $
+ * $FreeBSD: src/contrib/libpcap/pcap-int.h,v 1.14 2008/09/16 20:32:29 csjp Exp $
  * @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.68.2.11 2007/06/22 06:43:58 guy Exp $ (LBL)
  */
 
@@ -167,12 +167,36 @@
 	struct pcap_md md;
 
 	/*
-	 * Read buffer.
+	 * Read buffer -- for file descriptor read buffer model.
 	 */
 	int bufsize;
 	u_char *buffer;
 	u_char *bp;
 	int cc;
+	int to_ms;
+
+	/*
+	 * Zero-copy read buffer -- for zero-copy BPF.  'buffer' above will
+	 * alternative between these two actual mmap'd buffers as required.
+	 * As there is a header on the front size of the mmap'd buffer, only
+	 * some of the buffer is exposed to libpcap as a whole via bufsize;
+	 * zbufsize is the true size.  zbuffer tracks the current zbuf
+	 * assocated with buffer so that it can be used to decide which the
+	 * next buffer to read will be.
+	 */
+	u_char *zbuf1, *zbuf2, *zbuffer;
+	u_int zbufsize;
+	u_int timeout;
+	u_int zerocopy;
+	u_int interrupted;
+	struct timespec firstsel;
+
+	/*
+	 * If there's currently a buffer being actively processed, then it is
+	 * referenced here; 'buffer' is also pointed at it, but offset by the
+	 * size of the header.
+	 */
+	struct bpf_zbuf_header *bzh;
 
 	/*
 	 * Place holder for pcap_next().

==== //depot/projects/hammer/contrib/libpcap/pcap.c#8 (text+ko) ====

@@ -44,6 +44,7 @@
 #include <pcap-stdinc.h>
 #else /* WIN32 */
 #include <sys/types.h>
+#include <sys/mman.h>
 #endif /* WIN32 */
 
 #include <stdio.h>
@@ -738,6 +739,24 @@
 void
 pcap_close_common(pcap_t *p)
 {
+#ifdef BIOCSETBUFMODE
+	/*
+	 * Check to see if this pcap instance was using the zerocopy buffer
+	 * mode.  If it was, delete the mappings.  Note that p->buffer
+	 * gets initialized to one of the mmaped regions in this case, so
+	 * do not try and free it directly.
+	 *
+	 * If the regular buffer mode was selected, then it is safe to free
+	 * this memory.
+	 */
+	if (p->zerocopy) {
+		if (p->zbuf1 != MAP_FAILED && p->zbuf1 != NULL)
+			munmap(p->zbuf1, p->zbufsize);
+		if (p->zbuf2 != MAP_FAILED && p->zbuf2 != NULL)
+			munmap(p->zbuf2, p->zbufsize);
+		p->buffer = NULL;
+	} else
+#endif
 	if (p->buffer != NULL)
 		free(p->buffer);
 #if !defined(WIN32) && !defined(MSDOS)

==== //depot/projects/hammer/etc/defaults/rc.conf#90 (text+ko) ====

@@ -15,7 +15,7 @@
 # For a more detailed explanation of all the rc.conf variables, please
 # refer to the rc.conf(5) manual page.
 #
-# $FreeBSD: src/etc/defaults/rc.conf,v 1.344 2008/08/29 20:30:30 jhb Exp $
+# $FreeBSD: src/etc/defaults/rc.conf,v 1.345 2008/09/16 20:18:25 thompsa Exp $
 
 ##############################################################
 ###  Important initial Boot-time options  ####################
@@ -621,6 +621,7 @@
 #jail_example_hostname="default.domain.com"	# Jail's hostname
 #jail_example_ip="192.168.0.10"			# Jail's IP number
 #jail_example_interface=""			# Interface to create the IP alias on
+#jail_example_fib="0"				# routing table for setfib(1) 
 #jail_example_exec_start="/bin/sh /etc/rc"		# command to execute in jail for starting
 #jail_example_exec_afterstart0="/bin/sh command"	# command to execute after the one for 
 							# starting the jail. More than one can be

==== //depot/projects/hammer/etc/rc.d/jail#24 (text+ko) ====

@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $FreeBSD: src/etc/rc.d/jail,v 1.38 2008/01/13 14:27:53 simon Exp $
+# $FreeBSD: src/etc/rc.d/jail,v 1.39 2008/09/16 20:18:25 thompsa Exp $
 #
 
 # PROVIDE: jail
@@ -83,6 +83,7 @@
 	[ -z "${_flags}" ] && _flags="-l -U root"
 	eval _consolelog=\"\${jail_${_j}_consolelog:-${jail_consolelog}}\"
 	[ -z "${_consolelog}" ] && _consolelog="/var/log/jail_${_j}_console.log"
+	eval _fib=\"\${jail_${_j}_fib:-${jail_fib}}\"
 
 	# Debugging aid
 	#
@@ -93,6 +94,7 @@
 	debug "$_j hostname: $_hostname"
 	debug "$_j ip: $_ip"
 	debug "$_j interface: $_interface"
+	debug "$_j fib: $_fib"
 	debug "$_j root: $_rootdir"
 	debug "$_j devdir: $_devdir"
 	debug "$_j fdescdir: $_fdescdir"
@@ -297,6 +299,11 @@
 		if [ -n "${_interface}" ]; then
 			ifconfig ${_interface} alias ${_ip} netmask 255.255.255.255
 		fi
+		if [ -n "${_fib}" ]; then
+			_setfib="setfib -F '${_fib}'"
+		else
+			_setfib=""
+		fi
 		if checkyesno _mount; then
 			info "Mounting fstab for jail ${_jail} (${_fstab})"
 			if [ ! -f "${_fstab}" ]; then
@@ -350,7 +357,7 @@
 			fi
 		fi
 		_tmp_jail=${_tmp_dir}/jail.$$
-		eval jail ${_flags} -i ${_rootdir} ${_hostname} \
+		eval ${_setfib} jail ${_flags} -i ${_rootdir} ${_hostname} \
 			${_ip} ${_exec_start} > ${_tmp_jail} 2>&1
 
 		if [ "$?" -eq 0 ] ; then

==== //depot/projects/hammer/include/uuid.h#3 (text+ko) ====

@@ -24,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/include/uuid.h,v 1.3 2005/01/03 02:56:15 marcel Exp $
+ * $FreeBSD: src/include/uuid.h,v 1.4 2008/09/15 23:47:19 emax Exp $
  */
 
 #ifndef _UUID_H_
@@ -54,6 +54,10 @@
 uint16_t uuid_hash(const uuid_t *, uint32_t *);
 int32_t	uuid_is_nil(const uuid_t *, uint32_t *);
 void	uuid_to_string(const uuid_t *, char **, uint32_t *);
+void	uuid_enc_le(void *, const uuid_t *);
+void	uuid_dec_le(const void *, uuid_t *);
+void	uuid_enc_be(void *, const uuid_t *);
+void	uuid_dec_be(const void *, uuid_t *);
 __END_DECLS
 
 #endif	/* _UUID_H_ */

==== //depot/projects/hammer/lib/libc/rpc/clnt_dg.c#8 (text+ko) ====

@@ -37,7 +37,7 @@
 static char sccsid[] = "@(#)clnt_dg.c 1.19 89/03/16 Copyr 1988 Sun Micro";
 #endif
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/rpc/clnt_dg.c,v 1.20 2008/08/06 14:02:05 dfr Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/rpc/clnt_dg.c,v 1.21 2008/09/15 14:02:49 dfr Exp $");
 
 /*
  * Implements a connectionless client side RPC.
@@ -383,6 +383,8 @@
 	kin_len = 1;
 
 call_again:
+	if (cu->cu_async == TRUE && xargs == NULL)
+		goto get_reply;
 	/*
 	 * the transaction is the first thing in the out buffer
 	 * XXX Yes, and it's in network byte order, so we should to
@@ -393,8 +395,6 @@
 	*(u_int32_t *)(void *)(cu->cu_outhdr) = htonl(xid);
 call_again_same_xid:
 	xdrs = &(cu->cu_outxdrs);
-	if (cu->cu_async == TRUE && xargs == NULL)
-		goto get_reply;
 	xdrs->x_op = XDR_ENCODE;
 	XDR_SETPOS(xdrs, 0);
 

==== //depot/projects/hammer/lib/libc/uuid/Symbol.map#3 (text) ====

@@ -1,5 +1,5 @@
 /*
- * $FreeBSD: src/lib/libc/uuid/Symbol.map,v 1.2 2007/04/29 14:05:20 deischen Exp $
+ * $FreeBSD: src/lib/libc/uuid/Symbol.map,v 1.3 2008/09/15 23:54:55 emax Exp $
  */
 
 FBSD_1.0 {
@@ -11,4 +11,8 @@
 	uuid_create_nil;
 	uuid_create;
 	uuid_compare;
+	uuid_enc_le;
+	uuid_dec_le;
+	uuid_enc_be;
+	uuid_dec_be;
 };

==== //depot/projects/hammer/lib/libpmc/Makefile#5 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/lib/libpmc/Makefile,v 1.10 2007/11/25 06:38:55 jkoshy Exp $
+# $FreeBSD: src/lib/libpmc/Makefile,v 1.11 2008/09/16 16:57:14 jkoshy Exp $
 
 LIB=	pmc
 
@@ -23,6 +23,14 @@
 MAN+=	pmc_start.3
 MAN+=	pmclog.3
 
+# PMC-dependent manual pages
+MAN+=	pmc.k7.3
+MAN+=	pmc.k8.3
+MAN+=	pmc.p4.3
+MAN+=	pmc.p5.3
+MAN+=	pmc.p6.3
+MAN+=	pmc.tsc.3
+
 MLINKS+= \
 	pmc_allocate.3 pmc_release.3 \
 	pmc_attach.3 pmc_detach.3 \

==== //depot/projects/hammer/lib/libpmc/libpmc.c#10 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libpmc/libpmc.c,v 1.13 2008/03/12 15:51:32 jkoshy Exp $");
+__FBSDID("$FreeBSD: src/lib/libpmc/libpmc.c,v 1.16 2008/09/17 04:13:14 jkoshy Exp $");
 
 #include <sys/types.h>
 #include <sys/module.h>
@@ -162,7 +162,7 @@
 
 	if (pmask == NULL)	/* no mask keywords */
 		return (-1);
-	q = strchr(p, '='); 	/* skip '=' */
+	q = strchr(p, '=');	/* skip '=' */
 	if (*++q == '\0')	/* no more data */
 		return (-1);
 	c = 0;			/* count of mask keywords seen */
@@ -192,7 +192,7 @@
 	EV_ALIAS("branches",		"k7-retired-branches"),
 	EV_ALIAS("branch-mispredicts",	"k7-retired-branches-mispredicted"),
 	EV_ALIAS("cycles",		"tsc"),
-	EV_ALIAS("dc-misses",		"k7-dc-misses,mask=moesi"),
+	EV_ALIAS("dc-misses",		"k7-dc-misses"),
 	EV_ALIAS("ic-misses",		"k7-ic-misses"),
 	EV_ALIAS("instructions",	"k7-retired-instructions"),
 	EV_ALIAS("interrupts",		"k7-hardware-interrupts"),
@@ -210,8 +210,8 @@
 k7_allocate_pmc(enum pmc_event pe, char *ctrspec,
     struct pmc_op_pmcallocate *pmc_config)
 {
-	char 		*e, *p, *q;
-	int 		c, has_unitmask;
+	char		*e, *p, *q;
+	int		c, has_unitmask;
 	uint32_t	count, unitmask;
 
 	pmc_config->pm_md.pm_amd.pm_amd_config = 0;
@@ -315,7 +315,7 @@
 	EV_ALIAS("cycles",		"tsc"),
 	EV_ALIAS("dc-misses",		"k8-dc-miss"),
 	EV_ALIAS("ic-misses",		"k8-ic-miss"),
-	EV_ALIAS("instructions", 	"k8-fr-retired-x86-instructions"),
+	EV_ALIAS("instructions",	"k8-fr-retired-x86-instructions"),
 	EV_ALIAS("interrupts",		"k8-fr-taken-hardware-interrupts"),
 	EV_ALIAS("unhalted-cycles",	"k8-bu-cpu-clk-unhalted"),
 	EV_ALIAS(NULL, NULL)
@@ -490,7 +490,7 @@
 /* nb hypertransport bus bandwidth */
 static const struct pmc_masks k8_mask_nhbb[] = { /* HT bus bandwidth */
 	__K8MASK(command,	0),
-	__K8MASK(data, 	1),
+	__K8MASK(data,	1),
 	__K8MASK(buffer-release, 2),
 	__K8MASK(nop,	3),
 	NULLMASK
@@ -509,8 +509,8 @@
 k8_allocate_pmc(enum pmc_event pe, char *ctrspec,
     struct pmc_op_pmcallocate *pmc_config)
 {
-	char 		*e, *p, *q;
-	int 		n;
+	char		*e, *p, *q;
+	int		n;
 	uint32_t	count, evmask;
 	const struct pmc_masks	*pm, *pmask;
 
@@ -1023,7 +1023,7 @@
 	pmc_config->pm_caps |= PMC_CAP_WRITE;
 
 #define	__P4SETMASK(M) do {				\
-	pmask = p4_mask_##M; 				\
+	pmask = p4_mask_##M;				\
 } while (0)
 
 	switch (pe) {
@@ -1264,7 +1264,7 @@
 		if ((evmask & (evmask - 1)) != 0)
 			return (-1);
 		if (evmask == 0) {
-			evmask = 0x1; 	/* 'CLEAR' */
+			evmask = 0x1;	/* 'CLEAR' */
 			pmc_config->pm_caps |= PMC_CAP_QUALIFIER;
 		}
 		break;
@@ -1291,7 +1291,14 @@
  */
 
 static struct pmc_event_alias p5_aliases[] = {
-	EV_ALIAS("cycles", "tsc"),
+	EV_ALIAS("branches",		"p5-taken-branches"),
+	EV_ALIAS("cycles",		"tsc"),
+	EV_ALIAS("dc-misses",		"p5-data-read-miss-or-write-miss"),
+	EV_ALIAS("ic-misses",		"p5-code-cache-miss"),
+	EV_ALIAS("instructions",	"p5-instructions-executed"),
+	EV_ALIAS("interrupts",		"p5-hardware-interrupts"),
+	EV_ALIAS("unhalted-cycles",
+	    "p5-number-of-cycles-not-in-halt-state"),
 	EV_ALIAS(NULL, NULL)
 };
 
@@ -1450,7 +1457,7 @@
 #define	P6MASKSET(M)	pmask = p6_mask_ ## M
 
 	switch(pe) {
-	case PMC_EV_P6_L2_IFETCH: 	P6MASKSET(mesi); break;
+	case PMC_EV_P6_L2_IFETCH:	P6MASKSET(mesi); break;
 	case PMC_EV_P6_L2_LD:		P6MASKSET(mesi); break;
 	case PMC_EV_P6_L2_ST:		P6MASKSET(mesi); break;
 	case PMC_EV_P6_L2_RQSTS:	P6MASKSET(mesi); break;

==== //depot/projects/hammer/lib/libpmc/pmc.3#16 (text+ko) ====

@@ -21,9 +21,9 @@
 .\" out of the use of this software, even if advised of the possibility of
 .\" such damage.
 .\"
-.\" $FreeBSD: src/lib/libpmc/pmc.3,v 1.17 2008/03/14 06:22:03 jkoshy Exp $
+.\" $FreeBSD: src/lib/libpmc/pmc.3,v 1.18 2008/09/16 16:58:24 jkoshy Exp $
 .\"
-.Dd March 14, 2008
+.Dd September 16, 2008
 .Os
 .Dt PMC 3
 .Sh NAME
@@ -163,8 +163,6 @@
 enumeration.
 Supported PMC kinds include:
 .Bl -tag -width PMC_CLASS_TSC -compact
-.It PMC_CLASS_TSC
-The timestamp counter on i386 and amd64 architecture CPUs.
 .It PMC_CLASS_K7

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



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