Date: Wed, 17 Sep 2008 15:36:13 GMT From: Ed Schouten <ed@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 149940 for review Message-ID: <200809171536.m8HFaD3D069914@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=149940 Change 149940 by ed@ed_dull on 2008/09/17 15:35:27 IFC my EdBSD. Affected files ... .. //depot/projects/mpsafetty/ObsoleteFiles.inc#11 integrate .. //depot/projects/mpsafetty/UPDATING#10 integrate .. //depot/projects/mpsafetty/contrib/libpcap/pcap-bpf.c#2 integrate .. //depot/projects/mpsafetty/contrib/libpcap/pcap-int.h#2 integrate .. //depot/projects/mpsafetty/contrib/libpcap/pcap.c#2 integrate .. //depot/projects/mpsafetty/etc/defaults/rc.conf#8 integrate .. //depot/projects/mpsafetty/etc/rc.d/jail#2 integrate .. //depot/projects/mpsafetty/gnu/usr.bin/gdb/libgdb/fbsd-threads.c#2 integrate .. //depot/projects/mpsafetty/include/uuid.h#2 integrate .. //depot/projects/mpsafetty/lib/libarchive/archive_write_disk.c#8 integrate .. //depot/projects/mpsafetty/lib/libarchive/config_freebsd.h#3 integrate .. //depot/projects/mpsafetty/lib/libc/rpc/clnt_dg.c#3 integrate .. //depot/projects/mpsafetty/lib/libc/uuid/Symbol.map#2 integrate .. //depot/projects/mpsafetty/lib/libpmc/Makefile#2 integrate .. //depot/projects/mpsafetty/lib/libpmc/libpmc.c#2 integrate .. //depot/projects/mpsafetty/lib/libpmc/pmc.3#2 integrate .. //depot/projects/mpsafetty/lib/libpmc/pmc.k7.3#1 branch .. //depot/projects/mpsafetty/lib/libpmc/pmc.k8.3#1 branch .. //depot/projects/mpsafetty/lib/libpmc/pmc.p4.3#1 branch .. //depot/projects/mpsafetty/lib/libpmc/pmc.p5.3#1 branch .. //depot/projects/mpsafetty/lib/libpmc/pmc.p6.3#1 branch .. //depot/projects/mpsafetty/lib/libpmc/pmc.tsc.3#1 branch .. //depot/projects/mpsafetty/lib/libthr/thread/thr_event.c#2 integrate .. //depot/projects/mpsafetty/lib/libthread_db/libpthread_db.c#5 integrate .. //depot/projects/mpsafetty/lib/libthread_db/libthr_db.c#4 integrate .. //depot/projects/mpsafetty/lib/libthread_db/thread_db.c#4 integrate .. //depot/projects/mpsafetty/lib/libthread_db/thread_db.h#4 integrate .. //depot/projects/mpsafetty/lib/libthread_db/thread_db_int.h#4 integrate .. //depot/projects/mpsafetty/libexec/rtld-elf/rtld_lock.c#2 integrate .. //depot/projects/mpsafetty/rescue/rescue/Makefile#3 integrate .. //depot/projects/mpsafetty/sbin/fsck_ffs/fsck_ffs.8#2 integrate .. //depot/projects/mpsafetty/sbin/mount_nfs/mount_nfs.8#2 integrate .. //depot/projects/mpsafetty/sbin/mount_nfs/mount_nfs.c#3 integrate .. //depot/projects/mpsafetty/share/man/man4/ddb.4#7 integrate .. //depot/projects/mpsafetty/share/man/man4/snd_hda.4#3 integrate .. //depot/projects/mpsafetty/share/man/man5/rc.conf.5#4 integrate .. //depot/projects/mpsafetty/share/man/man9/DB_COMMAND.9#1 branch .. //depot/projects/mpsafetty/share/man/man9/Makefile#6 integrate .. //depot/projects/mpsafetty/share/zoneinfo/africa#3 integrate .. //depot/projects/mpsafetty/share/zoneinfo/asia#3 integrate .. //depot/projects/mpsafetty/share/zoneinfo/europe#3 integrate .. //depot/projects/mpsafetty/share/zoneinfo/southamerica#3 integrate .. //depot/projects/mpsafetty/sys/amd64/include/pmc_mdep.h#2 integrate .. //depot/projects/mpsafetty/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c#4 integrate .. //depot/projects/mpsafetty/sys/compat/freebsd32/freebsd32_misc.c#3 integrate .. //depot/projects/mpsafetty/sys/compat/freebsd32/freebsd32_proto.h#5 integrate .. //depot/projects/mpsafetty/sys/compat/freebsd32/freebsd32_syscall.h#5 integrate .. //depot/projects/mpsafetty/sys/compat/freebsd32/freebsd32_syscalls.c#5 integrate .. //depot/projects/mpsafetty/sys/compat/freebsd32/freebsd32_sysent.c#5 integrate .. //depot/projects/mpsafetty/sys/compat/freebsd32/syscalls.master#6 integrate .. //depot/projects/mpsafetty/sys/compat/svr4/svr4_stream.c#2 integrate .. //depot/projects/mpsafetty/sys/compat/svr4/svr4_sysvec.c#2 integrate .. //depot/projects/mpsafetty/sys/ddb/db_command.c#2 integrate .. //depot/projects/mpsafetty/sys/ddb/ddb.h#2 integrate .. //depot/projects/mpsafetty/sys/dev/aic7xxx/aic79xx_osm.c#2 integrate .. //depot/projects/mpsafetty/sys/dev/cxgb/common/cxgb_t3_hw.c#4 integrate .. //depot/projects/mpsafetty/sys/dev/cxgb/cxgb_adapter.h#6 integrate .. //depot/projects/mpsafetty/sys/dev/cxgb/cxgb_config.h#2 integrate .. //depot/projects/mpsafetty/sys/dev/cxgb/cxgb_include.h#2 integrate .. //depot/projects/mpsafetty/sys/dev/cxgb/cxgb_main.c#8 integrate .. //depot/projects/mpsafetty/sys/dev/cxgb/cxgb_offload.h#2 integrate .. //depot/projects/mpsafetty/sys/dev/cxgb/cxgb_osdep.h#3 integrate .. //depot/projects/mpsafetty/sys/dev/cxgb/cxgb_sge.c#7 integrate .. //depot/projects/mpsafetty/sys/dev/cxgb/sys/cxgb_support.c#2 integrate .. //depot/projects/mpsafetty/sys/dev/cxgb/sys/mbufq.h#2 integrate .. //depot/projects/mpsafetty/sys/dev/cxgb/ulp/toecore/cxgb_toedev.h#2 integrate .. //depot/projects/mpsafetty/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#6 integrate .. //depot/projects/mpsafetty/sys/dev/cxgb/ulp/tom/cxgb_cpl_socket.c#3 integrate .. //depot/projects/mpsafetty/sys/dev/cxgb/ulp/tom/cxgb_ddp.c#3 integrate .. //depot/projects/mpsafetty/sys/dev/cxgb/ulp/tom/cxgb_tom.c#3 integrate .. //depot/projects/mpsafetty/sys/dev/hwpmc/hwpmc_x86.c#2 integrate .. //depot/projects/mpsafetty/sys/dev/pci/vga_pci.c#2 integrate .. //depot/projects/mpsafetty/sys/dev/ppbus/if_plip.c#3 integrate .. //depot/projects/mpsafetty/sys/dev/ppbus/lpt.c#2 integrate .. //depot/projects/mpsafetty/sys/dev/ppbus/ppbconf.c#3 integrate .. //depot/projects/mpsafetty/sys/dev/ppbus/ppbconf.h#2 integrate .. //depot/projects/mpsafetty/sys/dev/ppbus/ppi.c#2 integrate .. //depot/projects/mpsafetty/sys/dev/ppbus/pps.c#2 integrate .. //depot/projects/mpsafetty/sys/dev/ppc/ppc.c#3 integrate .. //depot/projects/mpsafetty/sys/dev/ppc/ppc_acpi.c#3 integrate .. //depot/projects/mpsafetty/sys/dev/ppc/ppc_isa.c#4 integrate .. //depot/projects/mpsafetty/sys/dev/ppc/ppc_pci.c#2 integrate .. //depot/projects/mpsafetty/sys/dev/ppc/ppc_puc.c#2 integrate .. //depot/projects/mpsafetty/sys/dev/ppc/ppcreg.h#3 integrate .. //depot/projects/mpsafetty/sys/dev/ppc/ppcvar.h#2 integrate .. //depot/projects/mpsafetty/sys/dev/sound/pci/hda/hdac.c#5 integrate .. //depot/projects/mpsafetty/sys/dev/usb/ubsa.c#3 integrate .. //depot/projects/mpsafetty/sys/dev/usb/ufoma.c#5 integrate .. //depot/projects/mpsafetty/sys/dev/usb/usbdevs#10 integrate .. //depot/projects/mpsafetty/sys/gnu/fs/ext2fs/ext2_inode.c#2 integrate .. //depot/projects/mpsafetty/sys/gnu/fs/xfs/FreeBSD/support/kdb.c#2 integrate .. //depot/projects/mpsafetty/sys/i386/conf/GENERIC#9 integrate .. //depot/projects/mpsafetty/sys/i386/include/pmc_mdep.h#3 integrate .. //depot/projects/mpsafetty/sys/kern/kern_intr.c#4 integrate .. //depot/projects/mpsafetty/sys/kern/kern_proc.c#7 integrate .. //depot/projects/mpsafetty/sys/kern/subr_pcpu.c#2 integrate .. //depot/projects/mpsafetty/sys/kern/subr_rman.c#3 integrate .. //depot/projects/mpsafetty/sys/kern/subr_sleepqueue.c#5 integrate .. //depot/projects/mpsafetty/sys/kern/subr_turnstile.c#3 integrate .. //depot/projects/mpsafetty/sys/kern/subr_witness.c#7 integrate .. //depot/projects/mpsafetty/sys/kern/tty.c#39 integrate .. //depot/projects/mpsafetty/sys/kern/vfs_bio.c#4 integrate .. //depot/projects/mpsafetty/sys/kern/vfs_vnops.c#4 integrate .. //depot/projects/mpsafetty/sys/modules/svr4/Makefile#3 integrate .. //depot/projects/mpsafetty/sys/modules/wlan/Makefile#3 integrate .. //depot/projects/mpsafetty/sys/net/if_atmsubr.c#2 integrate .. //depot/projects/mpsafetty/sys/net/if_fwsubr.c#2 integrate .. //depot/projects/mpsafetty/sys/net/if_iso88025subr.c#2 integrate .. //depot/projects/mpsafetty/sys/net/route.c#5 integrate .. //depot/projects/mpsafetty/sys/net/route.h#3 integrate .. //depot/projects/mpsafetty/sys/netinet/if_ether.c#6 integrate .. //depot/projects/mpsafetty/sys/netinet/in_rmx.c#3 integrate .. //depot/projects/mpsafetty/sys/netinet/in_var.h#3 integrate .. //depot/projects/mpsafetty/sys/netinet/ip_fw.h#3 integrate .. //depot/projects/mpsafetty/sys/netinet/ip_fw2.c#8 integrate .. //depot/projects/mpsafetty/sys/nfsserver/nfs.h#2 integrate .. //depot/projects/mpsafetty/sys/nfsserver/nfs_serv.c#3 integrate .. //depot/projects/mpsafetty/sys/nfsserver/nfs_srvsock.c#2 integrate .. //depot/projects/mpsafetty/sys/nfsserver/nfs_srvsubs.c#3 integrate .. //depot/projects/mpsafetty/sys/nfsserver/nfs_syscalls.c#2 integrate .. //depot/projects/mpsafetty/sys/powerpc/aim/clock.c#3 integrate .. //depot/projects/mpsafetty/sys/powerpc/aim/mmu_oea.c#3 integrate .. //depot/projects/mpsafetty/sys/powerpc/aim/mp_cpudep.c#2 integrate .. //depot/projects/mpsafetty/sys/powerpc/aim/swtch.S#2 integrate .. //depot/projects/mpsafetty/sys/powerpc/aim/trap_subr.S#2 integrate .. //depot/projects/mpsafetty/sys/powerpc/include/cpufunc.h#3 integrate .. //depot/projects/mpsafetty/sys/powerpc/include/smp.h#2 integrate .. //depot/projects/mpsafetty/sys/powerpc/include/spr.h#2 integrate .. //depot/projects/mpsafetty/sys/powerpc/powerpc/autoconf.c#2 integrate .. //depot/projects/mpsafetty/sys/powerpc/powerpc/cpu.c#2 integrate .. //depot/projects/mpsafetty/sys/powerpc/powerpc/mp_machdep.c#2 integrate .. //depot/projects/mpsafetty/sys/powerpc/powerpc/openpic.c#2 integrate .. //depot/projects/mpsafetty/sys/sys/interrupt.h#3 integrate .. //depot/projects/mpsafetty/sys/sys/mount.h#3 integrate .. //depot/projects/mpsafetty/sys/sys/param.h#10 integrate .. //depot/projects/mpsafetty/sys/sys/proc.h#7 integrate .. //depot/projects/mpsafetty/sys/sys/procfs.h#3 integrate .. //depot/projects/mpsafetty/sys/sys/ttydisc.h#7 integrate .. //depot/projects/mpsafetty/sys/sys/vnode.h#5 integrate .. //depot/projects/mpsafetty/sys/ufs/ffs/ffs_extern.h#3 integrate .. //depot/projects/mpsafetty/sys/ufs/ffs/ffs_inode.c#2 integrate .. //depot/projects/mpsafetty/sys/ufs/ffs/ffs_snapshot.c#3 integrate .. //depot/projects/mpsafetty/sys/ufs/ffs/ffs_softdep.c#4 integrate .. //depot/projects/mpsafetty/sys/ufs/ffs/ffs_vfsops.c#6 integrate .. //depot/projects/mpsafetty/sys/ufs/ufs/dirhash.h#2 integrate .. //depot/projects/mpsafetty/sys/ufs/ufs/inode.h#2 integrate .. //depot/projects/mpsafetty/sys/ufs/ufs/ufs_dirhash.c#2 integrate .. //depot/projects/mpsafetty/sys/ufs/ufs/ufs_inode.c#2 integrate .. //depot/projects/mpsafetty/sys/ufs/ufs/ufs_lookup.c#3 integrate .. //depot/projects/mpsafetty/sys/ufs/ufs/ufs_vnops.c#4 integrate .. //depot/projects/mpsafetty/sys/ufs/ufs/ufsmount.h#3 integrate .. //depot/projects/mpsafetty/usr.bin/tar/config_freebsd.h#2 integrate .. //depot/projects/mpsafetty/usr.bin/tar/test/Makefile#3 integrate .. //depot/projects/mpsafetty/usr.bin/tar/test/test_symlink_dir.c#1 branch .. //depot/projects/mpsafetty/usr.bin/tar/write.c#2 integrate .. //depot/projects/mpsafetty/usr.sbin/portsnap/portsnap/portsnap.8#2 integrate .. //depot/projects/mpsafetty/usr.sbin/quot/quot.c#2 integrate .. //depot/projects/mpsafetty/usr.sbin/ypbind/yp_ping.c#2 integrate Differences ... ==== //depot/projects/mpsafetty/ObsoleteFiles.inc#11 (text+ko) ==== @@ -1,5 +1,5 @@ # -# $FreeBSD: src/ObsoleteFiles.inc,v 1.159 2008/09/13 17:29:49 antoine Exp $ +# $FreeBSD: src/ObsoleteFiles.inc,v 1.160 2008/09/14 17:49:46 antoine 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. # +# 20080913: pax removed from rescue +OLD_FILES+=rescue/pax # 20080823: removal of unneeded pt_chown, to implement grantpt(3) OLD_FILES+=usr/libexec/pt_chown # 20080822: ntp 4.2.4p5 import ==== //depot/projects/mpsafetty/UPDATING#10 (text+ko) ==== @@ -30,10 +30,10 @@ drivers have not yet been ported to the new TTY layer: PCI/ISA: - cy, digi, rc, rp, si, sio + cy, digi, rc, rp, sio USB: - ubser, ucycom, ufoma + ubser, ucycom Line disciplines: ng_h4, ng_tty, ppp, sl, snp @@ -1126,4 +1126,4 @@ Contact Warner Losh if you have any questions about your use of this document. -$FreeBSD: src/UPDATING,v 1.541 2008/09/03 08:30:17 roberto Exp $ +$FreeBSD: src/UPDATING,v 1.542 2008/09/14 19:25:57 ed Exp $ ==== //depot/projects/mpsafetty/contrib/libpcap/pcap-bpf.c#2 (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/mpsafetty/contrib/libpcap/pcap-int.h#2 (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/mpsafetty/contrib/libpcap/pcap.c#2 (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/mpsafetty/etc/defaults/rc.conf#8 (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/mpsafetty/etc/rc.d/jail#2 (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/mpsafetty/gnu/usr.bin/gdb/libgdb/fbsd-threads.c#2 (text+ko) ==== @@ -1,4 +1,4 @@ -/* $FreeBSD: src/gnu/usr.bin/gdb/libgdb/fbsd-threads.c,v 1.17 2008/04/29 17:47:25 jhb Exp $ */ +/* $FreeBSD: src/gnu/usr.bin/gdb/libgdb/fbsd-threads.c,v 1.18 2008/09/14 16:52:42 marcel Exp $ */ /* FreeBSD libthread_db assisted debugging support. Copyright 1999, 2000, 2001 Free Software Foundation, Inc. @@ -710,7 +710,7 @@ error ("Cannot get thread event message: %s", thread_db_err_str (err)); } - err = td_thr_get_info_p (msg.th_p, &ti); + err = td_thr_get_info_p ((void *)(uintptr_t)msg.th_p, &ti); if (err != TD_OK) error ("Cannot get thread info: %s", thread_db_err_str (err)); ptid = BUILD_THREAD (ti.ti_tid, GET_PID (ptid)); @@ -720,7 +720,7 @@ /* We may already know about this thread, for instance when the user has issued the `info threads' command before the SIGTRAP for hitting the thread creation breakpoint was reported. */ - attach_thread (ptid, msg.th_p, &ti, 1); + attach_thread (ptid, (void *)(uintptr_t)msg.th_p, &ti, 1); break; case TD_DEATH: if (!in_thread_list (ptid)) @@ -1178,13 +1178,14 @@ if (ti.ti_lid != 0) { - snprintf (buf, sizeof (buf), "Thread %p (LWP %d)", - th.th_thread, ti.ti_lid); + snprintf (buf, sizeof (buf), "Thread %llx (LWP %d)", + (unsigned long long)th.th_thread, ti.ti_lid); } else { - snprintf (buf, sizeof (buf), "Thread %p (%s)", - th.th_thread, thread_db_state_str (ti.ti_state)); + snprintf (buf, sizeof (buf), "Thread %llx (%s)", + (unsigned long long)th.th_thread, + thread_db_state_str (ti.ti_state)); } return buf; ==== //depot/projects/mpsafetty/include/uuid.h#2 (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/mpsafetty/lib/libarchive/archive_write_disk.c#8 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.38 2008/09/12 04:08:11 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.39 2008/09/14 05:51:25 kientzle Exp $"); #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> @@ -1963,7 +1963,10 @@ } -#if ( defined(HAVE_LCHFLAGS) || defined(HAVE_CHFLAGS) || defined(HAVE_FCHFLAGS) ) && !defined(__linux) +#if ( defined(HAVE_LCHFLAGS) || defined(HAVE_CHFLAGS) || defined(HAVE_FCHFLAGS) ) && defined(HAVE_STRUCT_STAT_ST_FLAGS) +/* + * BSD reads flags using stat() and sets them with one of {f,l,}chflags() + */ static int set_fflags_platform(struct archive_write_disk *a, int fd, const char *name, mode_t mode, unsigned long set, unsigned long clear) @@ -2012,11 +2015,9 @@ return (ARCHIVE_WARN); } -#elif defined(__linux) && defined(EXT2_IOC_GETFLAGS) && defined(EXT2_IOC_SETFLAGS) - +#elif defined(EXT2_IOC_GETFLAGS) && defined(EXT2_IOC_SETFLAGS) /* - * Linux has flags too, but uses ioctl() to access them instead of - * having a separate chflags() system call. + * Linux uses ioctl() to read and write file flags. */ static int set_fflags_platform(struct archive_write_disk *a, int fd, const char *name, @@ -2084,7 +2085,7 @@ return (ret); } -#else /* Not HAVE_CHFLAGS && Not __linux */ +#else /* * Of course, some systems have neither BSD chflags() nor Linux' flags ==== //depot/projects/mpsafetty/lib/libarchive/config_freebsd.h#3 (text+ko) ==== @@ -22,7 +22,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/lib/libarchive/config_freebsd.h,v 1.13 2008/09/12 04:08:11 kientzle Exp $ + * $FreeBSD: src/lib/libarchive/config_freebsd.h,v 1.14 2008/09/14 05:51:25 kientzle Exp $ */ /* FreeBSD 5.0 and later have ACL support. */ @@ -89,6 +89,7 @@ #define HAVE_STRING_H 1 #define HAVE_STRRCHR 1 #define HAVE_STRUCT_STAT_ST_BLKSIZE 1 +#define HAVE_STRUCT_STAT_ST_FLAGS 1 #define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1 #define HAVE_SYS_ACL_H 1 #define HAVE_SYS_IOCTL_H 1 ==== //depot/projects/mpsafetty/lib/libc/rpc/clnt_dg.c#3 (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/mpsafetty/lib/libc/uuid/Symbol.map#2 (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/mpsafetty/lib/libpmc/Makefile#2 (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 $ >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200809171536.m8HFaD3D069914>