svn commit: r184464 - head/sys/dev/usb

2008-10-30 Thread Nick Hibma
Author: n_hibma
Date: Thu Oct 30 08:13:49 2008
New Revision: 184464
URL: http://svn.freebsd.org/changeset/base/184464

Log:
  Return USBD_NORMAL_COMPLETION instead of a hard coded 0.

Modified:
  head/sys/dev/usb/usbdi.c

Modified: head/sys/dev/usb/usbdi.c
==
--- head/sys/dev/usb/usbdi.cThu Oct 30 04:55:12 2008(r184463)
+++ head/sys/dev/usb/usbdi.cThu Oct 30 08:13:49 2008(r184464)
@@ -325,7 +325,7 @@ usbd_transfer(usbd_xfer_handle xfer)
}
 
if (!(xfer-flags  USBD_SYNCHRONOUS))
-   return (xfer-done ? 0 : USBD_IN_PROGRESS);
+   return (xfer-done ? USBD_NORMAL_COMPLETION : USBD_IN_PROGRESS);
 
/* Sync transfer, wait for completion. */
s = splusb();
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to [EMAIL PROTECTED]


svn commit: r184465 - head/sys/dev/usb

2008-10-30 Thread Nick Hibma
Author: n_hibma
Date: Thu Oct 30 08:17:27 2008
New Revision: 184465
URL: http://svn.freebsd.org/changeset/base/184465

Log:
  Bugfix: Check the error code for in progress as well, after starting the
  transfer.
  
  Some changes to improve the debugging experience.

Modified:
  head/sys/dev/usb/u3g.c

Modified: head/sys/dev/usb/u3g.c
==
--- head/sys/dev/usb/u3g.c  Thu Oct 30 08:13:49 2008(r184464)
+++ head/sys/dev/usb/u3g.c  Thu Oct 30 08:17:27 2008(r184465)
@@ -51,7 +51,7 @@
 #endif
 #include usbdevs.h
 
-/* #define U3G_DEBUG */
+//#define U3G_DEBUG
 #ifdef U3G_DEBUG
 #define DPRINTF(x...)  do { if (u3gdebug) device_printf(sc-sc_dev, 
##x); } while (0)
 intu3gdebug = 1;
@@ -483,8 +483,10 @@ u3gstub_scsi_eject(struct u3gstub_softc 
break;
}
 
-   if (i == id-bNumEndpoints)
+   if (i == id-bNumEndpoints) {
+   DPRINTF(failed to find bulk-out pipe\n);
return 0;
+   }
 
if (usbd_open_pipe(uaa-iface, ed-bEndpointAddress,
   USBD_EXCLUSIVE_USE, sc-sc_pipe) != 
USBD_NORMAL_COMPLETION) {
@@ -501,7 +503,8 @@ u3gstub_scsi_eject(struct u3gstub_softc 
 
usbd_setup_xfer(sc-sc_xfer, sc-sc_pipe, NULL, cmd, sizeof(cmd),
0, USBD_DEFAULT_TIMEOUT, NULL);
-   if (usbd_transfer(sc-sc_xfer) != USBD_NORMAL_COMPLETION) {
+   int err = usbd_transfer(sc-sc_xfer) != USBD_NORMAL_COMPLETION;
+   if (err != USBD_NORMAL_COMPLETION  err != USBD_IN_PROGRESS) {
DPRINTF(failed to start transfer\n);
return 0;
}
@@ -545,8 +548,8 @@ u3gstub_match(device_t self)
return UMATCH_NONE;
 
if (u3g_dev_type-flagsU3GFL_HUAWEI_INIT
-   || u3g_dev_type-flagsU3GFL_SIERRA_INIT
|| u3g_dev_type-flagsU3GFL_SCSI_EJECT
+   || u3g_dev_type-flagsU3GFL_SIERRA_INIT
|| u3g_dev_type-flagsU3GFL_STUB_WAIT) {
/* We assume that if the first interface is still a mass
 * storage device the device has not yet changed appearance.
@@ -574,9 +577,8 @@ u3gstub_attach(device_t self)
sc-sc_dev = self;
sc-sc_udev = uaa-device;
 
-   if (uaa-iface)
-   for (i = 0; i  uaa-nifaces; i++)
-   uaa-ifaces[i] = NULL;  // claim all interfaces
+   for (i = 0; i  uaa-nifaces; i++)
+   uaa-ifaces[i] = NULL;  // claim all interfaces
 
u3g_dev_type = u3g_lookup(uaa-vendor, uaa-product);
if (u3g_dev_type-flagsU3GFL_HUAWEI_INIT) {
@@ -584,7 +586,7 @@ u3gstub_attach(device_t self)
if (!u3gstub_huawei_init(sc, uaa))
return ENXIO;
} else if (u3g_dev_type-flagsU3GFL_SCSI_EJECT) {
-   DPRINTF(sending CD eject command to change to modem mode \n);
+   DPRINTF(sending CD eject command to change to modem mode\n);
if (!u3gstub_scsi_eject(sc, uaa))
return ENXIO;
} else if (u3g_dev_type-flagsU3GFL_SIERRA_INIT) {
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to [EMAIL PROTECTED]


svn commit: r184466 - head/sys/dev/usb

2008-10-30 Thread Nick Hibma
Author: n_hibma
Date: Thu Oct 30 08:32:18 2008
New Revision: 184466
URL: http://svn.freebsd.org/changeset/base/184466

Log:
  We need to print out the device info ourselves on FBSD 6.
  
  Submitted by: Thomas Nystrom

Modified:
  head/sys/dev/usb/u3g.c

Modified: head/sys/dev/usb/u3g.c
==
--- head/sys/dev/usb/u3g.c  Thu Oct 30 08:17:27 2008(r184465)
+++ head/sys/dev/usb/u3g.c  Thu Oct 30 08:32:18 2008(r184466)
@@ -227,6 +227,13 @@ u3g_attach(device_t self)
usb_config_descriptor_t *cd;
char devnamefmt[32];
 
+#if __FreeBSD_version  70
+   char *devinfo = malloc(1024, M_USBDEV, M_WAITOK);
+   usbd_devinfo(dev, 0, devinfo);
+   device_printf(self, %s\n, devinfo);
+   free(devinfo, M_USBDEV);
+#endif
+
/* get the config descriptor */
cd = usbd_get_config_descriptor(dev);
if (cd == NULL) {
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: svn commit: r184466 - head/sys/dev/usb

2008-10-30 Thread Nick Hibma
Folks,

Just to preempt people suggesting that I committed into the wrong tree: I 
didn't. FBSD 6 is still locked down. To keep things simple I keep one 
version of the driver in CURRENT which works on FBSD CURRENT, 7, and 6.

See 

http://people.freebsd.org/~n_hibma/u3g.html

for more info  on how to use the driver in various versions of the OS.

And the cross post is intentional as well as I've had many positive 
responses from people that became aware of the driver.

Nick

 Author: n_hibma
 Date: Thu Oct 30 08:32:18 2008
 New Revision: 184466
 URL: http://svn.freebsd.org/changeset/base/184466

 Log:
   We need to print out the device info ourselves on FBSD 6.

   Submitted by:   Thomas Nystrom

 Modified:
   head/sys/dev/usb/u3g.c

 Modified: head/sys/dev/usb/u3g.c
 =
= --- head/sys/dev/usb/u3g.c   Thu Oct 30 08:17:27 2008
(r184465)
 +++ head/sys/dev/usb/u3g.cThu Oct 30 08:32:18 2008(r184466)
 @@ -227,6 +227,13 @@ u3g_attach(device_t self)
   usb_config_descriptor_t *cd;
   char devnamefmt[32];

 +#if __FreeBSD_version  70
 + char *devinfo = malloc(1024, M_USBDEV, M_WAITOK);
 + usbd_devinfo(dev, 0, devinfo);
 + device_printf(self, %s\n, devinfo);
 + free(devinfo, M_USBDEV);
 +#endif
 +
   /* get the config descriptor */
   cd = usbd_get_config_descriptor(dev);
   if (cd == NULL) {
 ___
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to [EMAIL PROTECTED]


___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: svn commit: r184444 - head/share/man/man4

2008-10-30 Thread Nick Hibma
Thanks!

Nick

 Author: brueffer
 Date: Wed Oct 29 18:49:37 2008
 New Revision: 18
 URL: http://svn.freebsd.org/changeset/base/18

 Log:
   Misc cleanup.

 Modified:
   head/share/man/man4/u3g.4

 Modified: head/share/man/man4/u3g.4
 =
= --- head/share/man/man4/u3g.4Wed Oct 29 18:46:47 2008
(r184443) +++
 head/share/man/man4/u3g.4 Wed Oct 29 18:49:37 2008(r18) @@ 
 -43,7
 +43,7 @@ u3g_load=YES
  The
  .Nm
  driver provides support for the multiple USB-to-serial interfaces
 exposed by -many 3G usb/pccard modems.
 +many 3G USB/PCCard modems.
  .Pp
  The device is accessed through the
  .Xr ucom 4
 @@ -77,23 +77,27 @@ Novatal MC950D
  Sierra cards
  .El
  .Pp
 -See /sys/dev/u3g.c for the complete list of supported cards for each
 vendor +See
 +.Pa /sys/dev/u3g.c
 +for the complete list of supported cards for each vendor
  mentioned above.
  .Pp
  The supported 3G cards provide the necessary modem port for ppp,
  pppd, or mpd connections as well as extra ports (depending on the
 specific -device) to provide other functions (diagnostic port, SIM
 toolkit port) +device) to provide other functions (diagnostic port, SIM
 toolkit port). .Pp
  In some of these devices a mass storage device supported by the
  .Xr umass 4
 -driver is present which contains Windows and Mac OSX drivers. This
 device is -hidden, unless the machine was booted in verbose (see
 -.Xr boot 8 ).
 +driver is present which contains Windows and Mac OS X drivers.
 +This device is
 +hidden, unless the machine was booted in verbose mode (see
 +.Xr boot 8 ) .
  To temporarily unhide the device, set
  .Va debug.bootverbose
  to 1 using
  .Xr sysctl 8
 -and replug the device. The
 +and replug the device.
 +The
  .Xr u3gstub 4
  device will attach temporarily and detach within seconds.
  .Sh SEE ALSO
 @@ -103,10 +107,11 @@ device will attach temporarily and detac
  .Sh HISTORY
  The
  .Nm
 -driver
 -appeared in
 +driver appeared in
  .Fx 8.0 ,
 -is based on the uark driver, and written by
 +is based on the
 +.Xr uark 4
 +driver, and written by
  .An Andrea Guzzo Aq [EMAIL PROTECTED]
  in September 2008.
  .Sh AUTHORS
 @@ -116,4 +121,4 @@ driver was written by
  .An Andrea Guzzo Aq [EMAIL PROTECTED]
  and
  .An Nick Hibma Aq [EMAIL PROTECTED] .
 -Hardware for testing provided by AnyWi Technologies, Leiden, NL.
 +Hardware for testing was provided by AnyWi Technologies, Leiden, NL.
 ___
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to [EMAIL PROTECTED]


___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to [EMAIL PROTECTED]


svn commit: r184467 - head/sys/security/mac_bsdextended

2008-10-30 Thread Robert Watson
Author: rwatson
Date: Thu Oct 30 10:13:53 2008
New Revision: 184467
URL: http://svn.freebsd.org/changeset/base/184467

Log:
  The V* flags passed using an accmode_t to the access() and open()
  access control checks in mac_bsdextended are not in the same
  namespace as the MBI_ flags used in ugidfw policies, so add an
  explicit conversion routine to get from one to the other.
  
  Obtained from:TrustedBSD Project

Modified:
  head/sys/security/mac_bsdextended/mac_bsdextended.c
  head/sys/security/mac_bsdextended/ugidfw_internal.h
  head/sys/security/mac_bsdextended/ugidfw_vnode.c

Modified: head/sys/security/mac_bsdextended/mac_bsdextended.c
==
--- head/sys/security/mac_bsdextended/mac_bsdextended.c Thu Oct 30 08:32:18 
2008(r184466)
+++ head/sys/security/mac_bsdextended/mac_bsdextended.c Thu Oct 30 10:13:53 
2008(r184467)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 1999-2002, 2007 Robert N. M. Watson
+ * Copyright (c) 1999-2002, 2007-2008 Robert N. M. Watson
  * Copyright (c) 2001-2005 Networks Associates Technology, Inc.
  * Copyright (c) 2005 Tom Rhodes
  * Copyright (c) 2006 SPARTA, Inc.
@@ -465,6 +465,27 @@ ugidfw_check_vp(struct ucred *cred, stru
return (ugidfw_check(cred, vp, vap, acc_mode));
 }
 
+int
+ugidfw_accmode2mbi(accmode_t accmode)
+{
+   int mbi;
+
+   mbi = 0;
+   if (accmode  VEXEC)
+   mbi |= MBI_EXEC;
+   if (accmode  VWRITE)
+   mbi |= MBI_WRITE;
+   if (accmode  VREAD)
+   mbi |= MBI_READ;
+   if (accmode  VADMIN)
+   mbi |= MBI_ADMIN;
+   if (accmode  VSTAT)
+   mbi |= MBI_STAT;
+   if (accmode  VAPPEND)
+   mbi |= MBI_APPEND;
+   return (mbi);
+}
+
 static struct mac_policy_ops ugidfw_ops =
 {
.mpo_destroy = ugidfw_destroy,

Modified: head/sys/security/mac_bsdextended/ugidfw_internal.h
==
--- head/sys/security/mac_bsdextended/ugidfw_internal.h Thu Oct 30 08:32:18 
2008(r184466)
+++ head/sys/security/mac_bsdextended/ugidfw_internal.h Thu Oct 30 10:13:53 
2008(r184467)
@@ -34,6 +34,7 @@
 /*
  * Central access control routines used by object-specific checks.
  */
+intugidfw_accmode2mbi(accmode_t accmode);
 intugidfw_check(struct ucred *cred, struct vnode *vp, struct vattr *vap,
int acc_mode);
 intugidfw_check_vp(struct ucred *cred, struct vnode *vp, int acc_mode);

Modified: head/sys/security/mac_bsdextended/ugidfw_vnode.c
==
--- head/sys/security/mac_bsdextended/ugidfw_vnode.cThu Oct 30 08:32:18 
2008(r184466)
+++ head/sys/security/mac_bsdextended/ugidfw_vnode.cThu Oct 30 10:13:53 
2008(r184467)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 1999-2002, 2007 Robert N. M. Watson
+ * Copyright (c) 1999-2002, 2007-2008 Robert N. M. Watson
  * Copyright (c) 2001-2005 Networks Associates Technology, Inc.
  * Copyright (c) 2005 Tom Rhodes
  * Copyright (c) 2006 SPARTA, Inc.
@@ -65,11 +65,7 @@ ugidfw_vnode_check_access(struct ucred *
 struct label *vplabel, accmode_t accmode)
 {
 
-   /*
-* XXX: We pass accmode_t variable containing V* constants
-*  as an int containing MBI_* constants.
-*/
-   return (ugidfw_check_vp(cred, vp, (int)accmode));
+   return (ugidfw_check_vp(cred, vp, ugidfw_accmode2mbi(accmode)));
 }
 
 int
@@ -175,11 +171,7 @@ ugidfw_vnode_check_open(struct ucred *cr
 struct label *vplabel, accmode_t accmode)
 {
 
-   /*
-* XXX: We pass accmode_t variable containing V* constants
-*  as an int containing MBI_* constants.
-*/
-   return (ugidfw_check_vp(cred, vp, (int)accmode));
+   return (ugidfw_check_vp(cred, vp, ugidfw_accmode2mbi(accmode)));
 }
 
 int
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: svn commit: r184323 - head/sys/kern

2008-10-30 Thread Dag-Erling Smørgrav
Maxim Sobolev [EMAIL PROTECTED] writes:
 Log:
   Default HZ value (1,000) on i386/amd64 is not very virtual machine friendly.
   Due to the nature of the beast it causes lot of unproductive overhead. This
   is especially bad when running SMP kernel on VMWare with several virtual
   processors - idle FreeBSD guest with SMP kernel takes 150% host CPU time on 
 my
   dual-core MacBook Pro when I am enabling two virtual CPUs, making even host
   not very usable. Detect when we are running in the sandbox and reduce HZ
   to 10 (can be adjusted via VM_HZ in the kernel config) in such cases. This
   brings host CPU usage of idle FreeBSD/SMP on two virtual processors down
   to 10%.

What, too chicken to go whole hog and make the kernel tickless?  :)

DES
-- 
Dag-Erling Smørgrav - [EMAIL PROTECTED]
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to [EMAIL PROTECTED]


svn commit: r184468 - in stable/6/sys: . dev/ata

2008-10-30 Thread Konstantin Belousov
Author: kib
Date: Thu Oct 30 13:10:33 2008
New Revision: 184468
URL: http://svn.freebsd.org/changeset/base/184468

Log:
  MFC of the r179312 by sos:
  Do not call ata_start() when ata_reinit fails in the ioctl path.
  
  Approved by:  re (kensmith), sos
  Prodded by:   Andrey V. Elsukov [EMAIL PROTECTED]

Modified:
  stable/6/sys/   (props changed)
  stable/6/sys/dev/ata/ata-all.c

Modified: stable/6/sys/dev/ata/ata-all.c
==
--- stable/6/sys/dev/ata/ata-all.c  Thu Oct 30 10:13:53 2008
(r184467)
+++ stable/6/sys/dev/ata/ata-all.c  Thu Oct 30 13:10:33 2008
(r184468)
@@ -375,7 +375,6 @@ ata_ioctl(struct cdev *dev, u_long cmd, 
!(device = devclass_get_device(ata_devclass, *value)))
return ENXIO;
error = ata_reinit(device);
-   ata_start(device);
break;
 
 case IOCATAATTACH:
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to [EMAIL PROTECTED]


svn commit: r184469 - in stable/7/sys: . compat/freebsd32 kern sys

2008-10-30 Thread John Baldwin
Author: jhb
Date: Thu Oct 30 13:14:45 2008
New Revision: 184469
URL: http://svn.freebsd.org/changeset/base/184469

Log:
  MFC: Split most of getdirentries() out into a kern_getdirentries() and add
  a freebsd32 frontend to fix a data corruption bug with 32-bit binaries.
  
  Approved by:  re (kib)

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/compat/freebsd32/freebsd32_misc.c
  stable/7/sys/compat/freebsd32/syscalls.master
  stable/7/sys/kern/vfs_syscalls.c
  stable/7/sys/sys/syscallsubr.h

Modified: stable/7/sys/compat/freebsd32/freebsd32_misc.c
==
--- stable/7/sys/compat/freebsd32/freebsd32_misc.c  Thu Oct 30 13:10:33 
2008(r184468)
+++ stable/7/sys/compat/freebsd32/freebsd32_misc.c  Thu Oct 30 13:14:45 
2008(r184469)
@@ -1724,6 +1724,24 @@ freebsd32_ftruncate(struct thread *td, s
return (ftruncate(td, ap));
 }
 
+int
+freebsd32_getdirentries(struct thread *td,
+struct freebsd32_getdirentries_args *uap)
+{
+   long base;
+   int32_t base32;
+   int error;
+
+   error = kern_getdirentries(td, uap-fd, uap-buf, uap-count, base);
+   if (error)
+   return (error);
+   if (uap-basep != NULL) {
+   base32 = base;
+   error = copyout(base32, uap-basep, sizeof(int32_t));
+   }
+   return (error);
+}
+
 #ifdef COMPAT_FREEBSD6
 /* versions with the 'int pad' argument */
 int

Modified: stable/7/sys/compat/freebsd32/syscalls.master
==
--- stable/7/sys/compat/freebsd32/syscalls.master   Thu Oct 30 13:10:33 
2008(r184468)
+++ stable/7/sys/compat/freebsd32/syscalls.master   Thu Oct 30 13:14:45 
2008(r184469)
@@ -350,8 +350,8 @@
 195AUE_SETRLIMIT   NOPROTO { int setrlimit(u_int which, \
struct rlimit *rlp); } setrlimit \
__setrlimit_args int
-196AUE_GETDIRENTRIES   NOPROTO { int getdirentries(int fd, char *buf, \
-   u_int count, long *basep); }
+196AUE_GETDIRENTRIES   STD { int freebsd32_getdirentries(int fd, \
+   char *buf, u_int count, int32_t *basep); }
 197AUE_MMAPCOMPAT6 { caddr_t freebsd32_mmap(caddr_t addr, \
size_t len, int prot, int flags, int fd, \
int pad, u_int32_t poslo, \

Modified: stable/7/sys/kern/vfs_syscalls.c
==
--- stable/7/sys/kern/vfs_syscalls.cThu Oct 30 13:10:33 2008
(r184468)
+++ stable/7/sys/kern/vfs_syscalls.cThu Oct 30 13:14:45 2008
(r184469)
@@ -3761,6 +3761,21 @@ getdirentries(td, uap)
long *basep;
} */ *uap;
 {
+   long base;
+   int error;
+
+   error = kern_getdirentries(td, uap-fd, uap-buf, uap-count, base);
+   if (error)
+   return (error);
+   if (uap-basep != NULL)
+   error = copyout(base, uap-basep, sizeof(long));
+   return (error);
+}
+
+int
+kern_getdirentries(struct thread *td, int fd, char *buf, u_int count,
+long *basep)
+{
struct vnode *vp;
struct file *fp;
struct uio auio;
@@ -3769,8 +3784,8 @@ getdirentries(td, uap)
long loff;
int error, eofflag;
 
-   AUDIT_ARG(fd, uap-fd);
-   if ((error = getvnode(td-td_proc-p_fd, uap-fd, fp)) != 0)
+   AUDIT_ARG(fd, fd);
+   if ((error = getvnode(td-td_proc-p_fd, fd, fp)) != 0)
return (error);
if ((fp-f_flag  FREAD) == 0) {
fdrop(fp, td);
@@ -3784,14 +3799,14 @@ unionread:
error = EINVAL;
goto fail;
}
-   aiov.iov_base = uap-buf;
-   aiov.iov_len = uap-count;
+   aiov.iov_base = buf;
+   aiov.iov_len = count;
auio.uio_iov = aiov;
auio.uio_iovcnt = 1;
auio.uio_rw = UIO_READ;
auio.uio_segflg = UIO_USERSPACE;
auio.uio_td = td;
-   auio.uio_resid = uap-count;
+   auio.uio_resid = count;
/* vn_lock(vp, LK_SHARED | LK_RETRY, td); */
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
AUDIT_ARG(vnode, vp, ARG_VNODE1);
@@ -3808,7 +3823,7 @@ unionread:
VFS_UNLOCK_GIANT(vfslocked);
goto fail;
}
-   if (uap-count == auio.uio_resid 
+   if (count == auio.uio_resid 
(vp-v_vflag  VV_ROOT) 
(vp-v_mount-mnt_flag  MNT_UNION)) {
struct vnode *tvp = vp;
@@ -3823,10 +3838,8 @@ unionread:
}
VOP_UNLOCK(vp, 0, td);
VFS_UNLOCK_GIANT(vfslocked);
-   if (uap-basep != NULL) {
-   error = copyout(loff, uap-basep, sizeof(long));
-   }
-   td-td_retval[0] = uap-count - auio.uio_resid;
+   *basep = loff;
+   

svn commit: r184472 - stable/7/sys/compat/freebsd32

2008-10-30 Thread John Baldwin
Author: jhb
Date: Thu Oct 30 14:30:49 2008
New Revision: 184472
URL: http://svn.freebsd.org/changeset/base/184472

Log:
  Regen for freebsd32_getdirentries().
  
  Approved by:  re (kib)

Modified:
  stable/7/sys/compat/freebsd32/freebsd32_proto.h
  stable/7/sys/compat/freebsd32/freebsd32_syscall.h
  stable/7/sys/compat/freebsd32/freebsd32_syscalls.c
  stable/7/sys/compat/freebsd32/freebsd32_sysent.c

Modified: stable/7/sys/compat/freebsd32/freebsd32_proto.h
==
--- stable/7/sys/compat/freebsd32/freebsd32_proto.h Thu Oct 30 14:05:57 
2008(r184471)
+++ stable/7/sys/compat/freebsd32/freebsd32_proto.h Thu Oct 30 14:30:49 
2008(r184472)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: stable/7/sys/compat/freebsd32/syscalls.master 183644 
2008-10-06 16:11:08Z obrien 
+ * created from FreeBSD: stable/7/sys/compat/freebsd32/syscalls.master 184469 
2008-10-30 13:14:45Z jhb 
  */
 
 #ifndef _FREEBSD32_SYSPROTO_H_
@@ -152,6 +152,12 @@ struct freebsd32_lstat_args {
char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
char ub_l_[PADL_(struct stat32 *)]; struct stat32 * ub; char 
ub_r_[PADR_(struct stat32 *)];
 };
+struct freebsd32_getdirentries_args {
+   char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
+   char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)];
+   char count_l_[PADL_(u_int)]; u_int count; char count_r_[PADR_(u_int)];
+   char basep_l_[PADL_(int32_t *)]; int32_t * basep; char 
basep_r_[PADR_(int32_t *)];
+};
 struct freebsd32_sysctl_args {
char name_l_[PADL_(int *)]; int * name; char name_r_[PADR_(int *)];
char namelen_l_[PADL_(u_int)]; u_int namelen; char 
namelen_r_[PADR_(u_int)];
@@ -390,6 +396,7 @@ int freebsd32_shmsys(struct thread *, st
 intfreebsd32_stat(struct thread *, struct freebsd32_stat_args *);
 intfreebsd32_fstat(struct thread *, struct freebsd32_fstat_args *);
 intfreebsd32_lstat(struct thread *, struct freebsd32_lstat_args *);
+intfreebsd32_getdirentries(struct thread *, struct 
freebsd32_getdirentries_args *);
 intfreebsd32_sysctl(struct thread *, struct freebsd32_sysctl_args *);
 intfreebsd32_futimes(struct thread *, struct freebsd32_futimes_args *);
 intfreebsd32_semctl(struct thread *, struct freebsd32_semctl_args *);
@@ -599,6 +606,7 @@ int freebsd6_freebsd32_ftruncate(struct 
 #defineFREEBSD32_SYS_AUE_freebsd32_statAUE_STAT
 #defineFREEBSD32_SYS_AUE_freebsd32_fstat   AUE_FSTAT
 #defineFREEBSD32_SYS_AUE_freebsd32_lstat   AUE_LSTAT
+#defineFREEBSD32_SYS_AUE_freebsd32_getdirentries   
AUE_GETDIRENTRIES
 #defineFREEBSD32_SYS_AUE_freebsd32_sysctl  AUE_SYSCTL
 #defineFREEBSD32_SYS_AUE_freebsd32_futimes AUE_FUTIMES
 #defineFREEBSD32_SYS_AUE_freebsd32_semctl  AUE_SEMCTL

Modified: stable/7/sys/compat/freebsd32/freebsd32_syscall.h
==
--- stable/7/sys/compat/freebsd32/freebsd32_syscall.h   Thu Oct 30 14:05:57 
2008(r184471)
+++ stable/7/sys/compat/freebsd32/freebsd32_syscall.h   Thu Oct 30 14:30:49 
2008(r184472)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: stable/7/sys/compat/freebsd32/syscalls.master 183644 
2008-10-06 16:11:08Z obrien 
+ * created from FreeBSD: stable/7/sys/compat/freebsd32/syscalls.master 184469 
2008-10-30 13:14:45Z jhb 
  */
 
 #defineFREEBSD32_SYS_syscall   0
@@ -177,7 +177,7 @@
 #defineFREEBSD32_SYS_fpathconf 192
 #defineFREEBSD32_SYS_getrlimit 194
 #defineFREEBSD32_SYS_setrlimit 195
-#defineFREEBSD32_SYS_getdirentries 196
+#defineFREEBSD32_SYS_freebsd32_getdirentries   196
 #defineFREEBSD32_SYS_freebsd6_freebsd32_mmap   197
 #defineFREEBSD32_SYS___syscall 198
 #defineFREEBSD32_SYS_freebsd6_freebsd32_lseek  199

Modified: stable/7/sys/compat/freebsd32/freebsd32_syscalls.c
==
--- stable/7/sys/compat/freebsd32/freebsd32_syscalls.c  Thu Oct 30 14:05:57 
2008(r184471)
+++ stable/7/sys/compat/freebsd32/freebsd32_syscalls.c  Thu Oct 30 14:30:49 
2008(r184472)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: stable/7/sys/compat/freebsd32/syscalls.master 183644 
2008-10-06 16:11:08Z obrien 
+ * created from FreeBSD: stable/7/sys/compat/freebsd32/syscalls.master 184469 
2008-10-30 13:14:45Z jhb 
  */
 
 const char *freebsd32_syscallnames[] = {
@@ -203,7 +203,7 @@ const char *freebsd32_syscallnames[] = {
#193, /* 193 = nosys */
getrlimit,/* 194 = getrlimit */

svn commit: r184474 - in stable/7/sys: . netinet

2008-10-30 Thread Bjoern A. Zeeb
Author: bz
Date: Thu Oct 30 15:48:55 2008
New Revision: 184474
URL: http://svn.freebsd.org/changeset/base/184474

Log:
  MFC: r182855
  
There is no real consumer of ip6_plen (IPv6 payload length)
as set in tcpip_fillheaders().
ip6_output() will calculate it based of the length from the
mbuf packet header itself.
Initialize the value in tcpip_fillheaders() in correct
(network) byte order.
  
With the above change, all places calling tcp_trace() pass in
the ip6 header serialized in the mbuf as ipgen and with
ip6_plen in network byte order.  Thus convert the IPv6 payload
length to host byte order before printing.
  
  Approved by:  re (gnn)

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/netinet/tcp_debug.c
  stable/7/sys/netinet/tcp_subr.c

Modified: stable/7/sys/netinet/tcp_debug.c
==
--- stable/7/sys/netinet/tcp_debug.cThu Oct 30 15:27:13 2008
(r184473)
+++ stable/7/sys/netinet/tcp_debug.cThu Oct 30 15:48:55 2008
(r184474)
@@ -171,7 +171,7 @@ tcp_trace(short act, short ostate, struc
ack = th-th_ack;
len =
 #ifdef INET6
-   isipv6 ? ((struct ip6_hdr *)ipgen)-ip6_plen :
+   isipv6 ? ntohs(((struct ip6_hdr *)ipgen)-ip6_plen) :
 #endif
((struct ip *)ipgen)-ip_len;
if (act == TA_OUTPUT) {

Modified: stable/7/sys/netinet/tcp_subr.c
==
--- stable/7/sys/netinet/tcp_subr.c Thu Oct 30 15:27:13 2008
(r184473)
+++ stable/7/sys/netinet/tcp_subr.c Thu Oct 30 15:48:55 2008
(r184474)
@@ -344,7 +344,7 @@ tcpip_fillheaders(struct inpcb *inp, voi
ip6-ip6_vfc = (ip6-ip6_vfc  ~IPV6_VERSION_MASK) |
(IPV6_VERSION  IPV6_VERSION_MASK);
ip6-ip6_nxt = IPPROTO_TCP;
-   ip6-ip6_plen = sizeof(struct tcphdr);
+   ip6-ip6_plen = htons(sizeof(struct tcphdr));
ip6-ip6_src = inp-in6p_laddr;
ip6-ip6_dst = inp-in6p_faddr;
} else
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to [EMAIL PROTECTED]


svn commit: r184478 - in stable/7/sys: . netinet6

2008-10-30 Thread Bjoern A. Zeeb
Author: bz
Date: Thu Oct 30 16:15:12 2008
New Revision: 184478
URL: http://svn.freebsd.org/changeset/base/184478

Log:
  MFC: r183611
  
Style changes: compare pointer to NULL and move a }.
  
  Approved by:  re (gnn)

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/netinet6/in6_pcb.c

Modified: stable/7/sys/netinet6/in6_pcb.c
==
--- stable/7/sys/netinet6/in6_pcb.c Thu Oct 30 16:11:07 2008
(r184477)
+++ stable/7/sys/netinet6/in6_pcb.c Thu Oct 30 16:15:12 2008
(r184478)
@@ -255,8 +255,7 @@ in6_pcbbind(register struct inpcb *inp, 
int e;
if ((e = in6_pcbsetport(inp-in6p_laddr, inp, cred)) != 0)
return (e);
-   }
-   else {
+   } else {
inp-inp_lport = lport;
if (in_pcbinshash(inp) != 0) {
inp-in6p_laddr = in6addr_any;
@@ -325,7 +324,7 @@ in6_pcbladdr(register struct inpcb *inp,
return(error);
}
 
-   if (*plocal_addr6 == 0) {
+   if (*plocal_addr6 == NULL) {
if (error == 0)
error = EADDRNOTAVAIL;
return (error);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to [EMAIL PROTECTED]


svn commit: r184479 - in stable/7/sys: . dev/lmc

2008-10-30 Thread Bjoern A. Zeeb
Author: bz
Date: Thu Oct 30 16:20:42 2008
New Revision: 184479
URL: http://svn.freebsd.org/changeset/base/184479

Log:
  MFC: r182112
  
Make lmc(4) compile without INET6 defined. While here make it
compile if there is no INET defined.
  
  Approved by:  re (gnn)

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/dev/lmc/if_lmc.c

Modified: stable/7/sys/dev/lmc/if_lmc.c
==
--- stable/7/sys/dev/lmc/if_lmc.c   Thu Oct 30 16:15:12 2008
(r184478)
+++ stable/7/sys/dev/lmc/if_lmc.c   Thu Oct 30 16:20:42 2008
(r184479)
@@ -80,6 +80,12 @@
 # ifdef HAVE_KERNEL_OPTION_HEADERS
 # include opt_device_polling.h /* DEVICE_POLLING */
 # endif
+# ifndef INET
+#  define INET 0
+# endif
+# ifndef INET6
+#  define INET6 0
+# endif
 # ifndef NETGRAPH
 #  define NETGRAPH 0
 # endif
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to [EMAIL PROTECTED]


svn commit: r184481 - in stable/7/sys: . contrib/pf/net netinet netinet6

2008-10-30 Thread Bjoern A. Zeeb
Author: bz
Date: Thu Oct 30 16:29:04 2008
New Revision: 184481
URL: http://svn.freebsd.org/changeset/base/184481

Log:
  MFC: r183606, r183610
  
Cache so_cred as inp_cred in the inpcb.
This means that inp_cred is always there, even after the socket
has gone away. It also means that it is constant for the lifetime
of the inp.
Both facts lead to simpler code and possibly less locking.
  
  Approved by:  re (gnn)

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/net/pf.c
  stable/7/sys/netinet/in_pcb.c
  stable/7/sys/netinet/in_pcb.h
  stable/7/sys/netinet/ip_fw2.c
  stable/7/sys/netinet/raw_ip.c
  stable/7/sys/netinet/tcp_subr.c
  stable/7/sys/netinet/udp_usrreq.c
  stable/7/sys/netinet6/in6_pcb.c
  stable/7/sys/netinet6/udp6_usrreq.c

Modified: stable/7/sys/contrib/pf/net/pf.c
==
--- stable/7/sys/contrib/pf/net/pf.cThu Oct 30 16:22:04 2008
(r184480)
+++ stable/7/sys/contrib/pf/net/pf.cThu Oct 30 16:29:04 2008
(r184481)
@@ -2938,13 +2938,9 @@ pf_socket_lookup(int direction, struct p
 #ifdef __FreeBSD__
if (inp_arg != NULL) {
INP_LOCK_ASSERT(inp_arg);
-   if (inp_arg-inp_socket) {
-   pd-lookup.uid = inp_arg-inp_socket-so_cred-cr_uid;
-   pd-lookup.gid =
-   inp_arg-inp_socket-so_cred-cr_groups[0];
-   return (1);
-   } else
-   return (-1);
+   pd-lookup.uid = inp_arg-inp_cred-cr_uid;
+   pd-lookup.gid = inp_arg-inp_cred-cr_groups[0];
+   return (1);
}
 #endif
switch (pd-proto) {
@@ -3040,15 +3036,9 @@ pf_socket_lookup(int direction, struct p
return (-1);
}
 #ifdef __FreeBSD__
-   INP_RLOCK(inp);
+   pd-lookup.uid = inp-inp_cred-cr_uid;
+   pd-lookup.gid = inp-inp_cred-cr_groups[0];
INP_INFO_RUNLOCK(pi);
-   if ((inp-inp_socket == NULL) || (inp-inp_socket-so_cred == NULL)) {
-   INP_RUNLOCK(inp);
-   return (-1);
-   }
-   pd-lookup.uid = inp-inp_socket-so_cred-cr_uid;
-   pd-lookup.gid = inp-inp_socket-so_cred-cr_groups[0];
-   INP_RUNLOCK(inp);
 #else
pd-lookup.uid = inp-inp_socket-so_euid;
pd-lookup.gid = inp-inp_socket-so_egid;

Modified: stable/7/sys/netinet/in_pcb.c
==
--- stable/7/sys/netinet/in_pcb.c   Thu Oct 30 16:22:04 2008
(r184480)
+++ stable/7/sys/netinet/in_pcb.c   Thu Oct 30 16:29:04 2008
(r184481)
@@ -186,6 +186,7 @@ in_pcballoc(struct socket *so, struct in
bzero(inp, inp_zero_size);
inp-inp_pcbinfo = pcbinfo;
inp-inp_socket = so;
+   inp-inp_cred = crhold(so-so_cred);
inp-inp_inc.inc_fibnum = so-so_fibnum;
 #ifdef MAC
error = mac_init_inpcb(inp, M_NOWAIT);
@@ -224,8 +225,10 @@ in_pcballoc(struct socket *so, struct in
 
 #if defined(IPSEC) || defined(MAC)
 out:
-   if (error != 0)
+   if (error != 0) {
+   crfree(inp-inp_cred);
uma_zfree(pcbinfo-ipi_zone, inp);
+   }
 #endif
return (error);
 }
@@ -345,7 +348,7 @@ in_pcbbind_setup(struct inpcb *inp, stru
if (jailed(cred))
prison = 1;
if (!IN_MULTICAST(ntohl(sin-sin_addr.s_addr)) 
-   priv_check_cred(so-so_cred,
+   priv_check_cred(inp-inp_cred,
PRIV_NETINET_REUSEPORT, 0) != 0) {
t = in_pcblookup_local(pcbinfo, sin-sin_addr,
lport, prison ? 0 : INPLOOKUP_WILDCARD,
@@ -362,8 +365,8 @@ in_pcbbind_setup(struct inpcb *inp, stru
 ntohl(t-inp_laddr.s_addr) != INADDR_ANY ||
 (t-inp_socket-so_options 
 SO_REUSEPORT) == 0) 
-   (so-so_cred-cr_uid !=
-t-inp_socket-so_cred-cr_uid))
+   (inp-inp_cred-cr_uid !=
+t-inp_cred-cr_uid))
return (EADDRINUSE);
}
if (prison  prison_ip(cred, 0, sin-sin_addr.s_addr))
@@ -745,6 +748,7 @@ in_pcbfree(struct inpcb *inp)
if (inp-inp_moptions != NULL)
inp_freemoptions(inp-inp_moptions);
inp-inp_vflag = 0;
+   crfree(inp-inp_cred);
 
 #ifdef MAC
mac_destroy_inpcb(inp);

Modified: stable/7/sys/netinet/in_pcb.h
==
--- stable/7/sys/netinet/in_pcb.h   Thu Oct 30 16:22:04 2008
(r184480)
+++ stable/7/sys/netinet/in_pcb.h 

svn commit: r184484 - head/bin/chio

2008-10-30 Thread Joerg Wunsch
Author: joerg
Date: Thu Oct 30 19:51:02 2008
New Revision: 184484
URL: http://svn.freebsd.org/changeset/base/184484

Log:
  When running a chio return operation using a physical source unit
  rather than a voltag name, do not set the CESR_VOLTAGS flags in the
  CHIOGSTATUS command requesting the current status.  As voltags are an
  optional feature that must be handled as reserved by media changers
  not implementing the feature, always setting CESR_VOLTAGS resulted in
  the command being aborted with an `Invalid field in CDB', and
  consequently the chio return failed, for media changers that do not
  support voltags.
  
  MFC after:1 week

Modified:
  head/bin/chio/chio.c

Modified: head/bin/chio/chio.c
==
--- head/bin/chio/chio.cThu Oct 30 17:54:20 2008(r184483)
+++ head/bin/chio/chio.cThu Oct 30 19:51:02 2008(r184484)
@@ -69,7 +69,7 @@ staticconst char *bits_to_string(ces_st
 
 static void find_element(char *, uint16_t *, uint16_t *);
 static struct changer_element_status *get_element_status
-  (unsigned int, unsigned int);
+  (unsigned int, unsigned int, int);
 
 static int do_move(const char *, int, char **);
 static int do_exchange(const char *, int, char **);
@@ -969,7 +969,8 @@ do_return(const char *cname, int argc, c
++argv; --argc;
 
/* Get the status */
-   ces = get_element_status((unsigned int)type, (unsigned int)element);
+   ces = get_element_status((unsigned int)type, (unsigned int)element,
+   CHET_VT == type);
 
if (NULL == ces)
errx(1, %s: null element status pointer, cname);
@@ -1004,7 +1005,7 @@ usage:
  * should free() it when done.
  */
 static struct changer_element_status *
-get_element_status(unsigned int type, unsigned int element)
+get_element_status(unsigned int type, unsigned int element, int use_voltags)
 {
struct changer_element_status_request cesr;
struct changer_element_status *ces;
@@ -1020,7 +1021,8 @@ get_element_status(unsigned int type, un
cesr.cesr_element_type = (uint16_t)type;
cesr.cesr_element_base = (uint16_t)element;
cesr.cesr_element_count = 1;/* Only this one element */
-   cesr.cesr_flags |= CESR_VOLTAGS;/* Grab voltags as well */
+   if (use_voltags)
+   cesr.cesr_flags |= CESR_VOLTAGS; /* Grab voltags as well */
cesr.cesr_element_status = ces;
 
if (ioctl(changer_fd, CHIOGSTATUS, (char *)cesr) == -1) {
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to [EMAIL PROTECTED]


svn commit: r184486 - head/sys/powerpc/include

2008-10-30 Thread Maxim Sobolev
Author: sobomax
Date: Thu Oct 30 21:02:00 2008
New Revision: 184486
URL: http://svn.freebsd.org/changeset/base/184486

Log:
  Fix compilation in the case when kernel doesn't have KDB ebabled.
  subr_kdb.c still references breakpoint() in this case.

Modified:
  head/sys/powerpc/include/cpufunc.h

Modified: head/sys/powerpc/include/cpufunc.h
==
--- head/sys/powerpc/include/cpufunc.h  Thu Oct 30 20:24:25 2008
(r184485)
+++ head/sys/powerpc/include/cpufunc.h  Thu Oct 30 21:02:00 2008
(r184486)
@@ -50,6 +50,13 @@ struct thread;
 
 #ifdef KDB
 void breakpoint(void);
+#else
+static __inline void
+breakpoint(void)
+{
+
+   return;
+}
 #endif
 
 /* CPU register mangling inlines */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to [EMAIL PROTECTED]


svn commit: r184487 - in head/sys: conf kern

2008-10-30 Thread Maxim Sobolev
Author: sobomax
Date: Thu Oct 30 21:48:28 2008
New Revision: 184487
URL: http://svn.freebsd.org/changeset/base/184487

Log:
  Make it possible to compile kernel with KTR but without DDB.

Modified:
  head/sys/conf/files
  head/sys/kern/subr_stack.c

Modified: head/sys/conf/files
==
--- head/sys/conf/files Thu Oct 30 21:02:00 2008(r184486)
+++ head/sys/conf/files Thu Oct 30 21:48:28 2008(r184487)
@@ -1691,7 +1691,7 @@ kern/subr_sbuf.c  standard
 kern/subr_scanf.c  standard
 kern/subr_sleepqueue.c standard
 kern/subr_smp.cstandard
-kern/subr_stack.c  optional ddb | stack
+kern/subr_stack.c  optional ddb | stack | ktr
 kern/subr_taskqueue.c  standard
 kern/subr_trap.c   standard
 kern/subr_turnstile.c  standard

Modified: head/sys/kern/subr_stack.c
==
--- head/sys/kern/subr_stack.c  Thu Oct 30 21:02:00 2008(r184486)
+++ head/sys/kern/subr_stack.c  Thu Oct 30 21:48:28 2008(r184487)
@@ -155,15 +155,18 @@ stack_sbuf_print_ddb(struct sbuf *sb, st
name, offset);
}
 }
+#endif
 
 #ifdef KTR
 void
 stack_ktr(u_int mask, const char *file, int line, struct stack *st, u_int 
depth,
 int cheap)
 {
+#ifdef DDB
const char *name;
long offset;
int i;
+#endif
 
KASSERT(st-depth = STACK_MAX, (bogus stack));
if (cheap) {
@@ -180,6 +183,7 @@ stack_ktr(u_int mask, const char *file, 
ktr_tracepoint(mask, file, line, #2 %p %p %p %p %p %p,
st-pcs[12], st-pcs[13], st-pcs[14], st-pcs[15],
st-pcs[16], st-pcs[17]);
+#ifdef DDB
} else {
if (depth == 0 || st-depth  depth)
depth = st-depth;
@@ -188,10 +192,10 @@ stack_ktr(u_int mask, const char *file, 
ktr_tracepoint(mask, file, line, #%d %p at %s+%#lx,
i, st-pcs[i], (u_long)name, offset, 0, 0);
}
+#endif
}
 }
 #endif
-#endif
 
 /*
  * Two variants of stack symbol lookup -- one that uses the DDB interfaces
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to [EMAIL PROTECTED]


svn commit: r184488 - head/sys/security/audit

2008-10-30 Thread Robert Watson
Author: rwatson
Date: Thu Oct 30 21:58:39 2008
New Revision: 184488
URL: http://svn.freebsd.org/changeset/base/184488

Log:
  Break out single audit_pipe_mtx into two types of locks: a global rwlock
  protecting the list of audit pipes, and a per-pipe mutex protecting the
  queue.
  
  Likewise, replace the single global condition variable used to signal
  delivery of a record to one or more pipes, and add a per-pipe condition
  variable to avoid spurious wakeups when event subscriptions differ
  across multiple pipes.
  
  This slightly increases the cost of delivering to audit pipes, but should
  reduce lock contention in the presence of multiple readers as only the
  per-pipe lock is required to read from a pipe, as well as avoid
  overheading when different pipes are used in different ways.
  
  MFC after:2 months
  Sponsored by: Apple, Inc.

Modified:
  head/sys/security/audit/audit_pipe.c

Modified: head/sys/security/audit/audit_pipe.c
==
--- head/sys/security/audit/audit_pipe.cThu Oct 30 21:48:28 2008
(r184487)
+++ head/sys/security/audit/audit_pipe.cThu Oct 30 21:58:39 2008
(r184488)
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2006 Robert N. M. Watson
+ * Copyright (c) 2008 Apple, Inc.
  * All rights reserved.
  *
  * This software was developed by Robert Watson for the TrustedBSD Project.
@@ -41,6 +42,7 @@ __FBSDID($FreeBSD$);
 #include sys/poll.h
 #include sys/proc.h
 #include sys/queue.h
+#include sys/rwlock.h
 #include sys/selinfo.h
 #include sys/sigio.h
 #include sys/signal.h
@@ -115,6 +117,17 @@ struct audit_pipe {
struct selinfo   ap_selinfo;
struct sigio*ap_sigio;
 
+   /*
+* Per-pipe mutex protecting most fields in this data structure.
+*/
+   struct mtx   ap_lock;
+
+   /*
+* Condition variable to signal when data has been delivered to a
+* pipe.
+*/
+   struct cvap_cv;
+
u_intap_qlen;
u_intap_qlimit;
 
@@ -144,19 +157,31 @@ struct audit_pipe {
TAILQ_ENTRY(audit_pipe)  ap_list;
 };
 
+#defineAUDIT_PIPE_LOCK(ap) mtx_lock((ap)-ap_lock)
+#defineAUDIT_PIPE_LOCK_ASSERT(ap)  mtx_assert((ap)-ap_lock, 
MA_OWNED)
+#defineAUDIT_PIPE_LOCK_DESTROY(ap) mtx_destroy((ap)-ap_lock)
+#defineAUDIT_PIPE_LOCK_INIT(ap)mtx_init((ap)-ap_lock, \
+   audit_pipe_lock, NULL, MTX_DEF)
+#defineAUDIT_PIPE_UNLOCK(ap)   mtx_unlock((ap)-ap_lock)
+#defineAUDIT_PIPE_MTX(ap)  ((ap)-ap_lock)
+
 /*
- * Global list of audit pipes, mutex to protect it and the pipes.  Finer
- * grained locking may be desirable at some point.
+ * Global list of audit pipes, rwlock to protect it.  Individual record
+ * queues on pipes are protected by per-pipe locks; these locks synchronize
+ * between threads walking the list to deliver to individual pipes and add/
+ * remove of pipes, and are mostly acquired for read.
  */
 static TAILQ_HEAD(, audit_pipe) audit_pipe_list;
-static struct mtx   audit_pipe_mtx;
+static struct rwlockaudit_pipe_lock;
 
-/*
- * This CV is used to wakeup on an audit record write.  Eventually, it might
- * be per-pipe to avoid unnecessary wakeups when several pipes with different
- * preselection masks are present.
- */
-static struct cvaudit_pipe_cv;
+#defineAUDIT_PIPE_LIST_LOCK_INIT() rw_init(audit_pipe_lock, \
+   audit_pipe_list_lock)
+#defineAUDIT_PIPE_LIST_RLOCK() rw_rlock(audit_pipe_lock)
+#defineAUDIT_PIPE_LIST_RUNLOCK()   rw_runlock(audit_pipe_lock)
+#defineAUDIT_PIPE_LIST_WLOCK() rw_wlock(audit_pipe_lock)
+#defineAUDIT_PIPE_LIST_WLOCK_ASSERT()  rw_assert(audit_pipe_lock, \
+   RA_WLOCKED)
+#defineAUDIT_PIPE_LIST_WUNLOCK()   rw_wunlock(audit_pipe_lock)
 
 /*
  * Cloning related variables and constants.
@@ -224,7 +249,7 @@ audit_pipe_preselect_find(struct audit_p
 {
struct audit_pipe_preselect *app;
 
-   mtx_assert(audit_pipe_mtx, MA_OWNED);
+   AUDIT_PIPE_LOCK_ASSERT(ap);
 
TAILQ_FOREACH(app, ap-ap_preselect_list, app_list) {
if (app-app_auid == auid)
@@ -243,14 +268,14 @@ audit_pipe_preselect_get(struct audit_pi
struct audit_pipe_preselect *app;
int error;
 
-   mtx_lock(audit_pipe_mtx);
+   AUDIT_PIPE_LOCK(ap);
app = audit_pipe_preselect_find(ap, auid);
if (app != NULL) {
*maskp = app-app_mask;
error = 0;
} else
error = ENOENT;
-   mtx_unlock(audit_pipe_mtx);
+   AUDIT_PIPE_UNLOCK(ap);
return (error);
 }
 
@@