From owner-svn-src-head@FreeBSD.ORG Sun Jul 3 12:22:02 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8D11C1065677; Sun, 3 Jul 2011 12:22:02 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7B4E18FC0A; Sun, 3 Jul 2011 12:22:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p63CM2tp012916; Sun, 3 Jul 2011 12:22:02 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p63CM219012904; Sun, 3 Jul 2011 12:22:02 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201107031222.p63CM219012904@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 3 Jul 2011 12:22:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223735 - in head: sbin/ifconfig share/man/man9 sys/kern sys/net sys/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jul 2011 12:22:02 -0000 Author: bz Date: Sun Jul 3 12:22:02 2011 New Revision: 223735 URL: http://svn.freebsd.org/changeset/base/223735 Log: Add infrastructure to allow all frames/packets received on an interface to be assigned to a non-default FIB instance. You may need to recompile world or ports due to the change of struct ifnet. Submitted by: cjsp Submitted by: Alexander V. Chernikov (melifaro ipfw.ru) (original versions) Reviewed by: julian Reviewed by: Alexander V. Chernikov (melifaro ipfw.ru) MFC after: 2 weeks X-MFC: use spare in struct ifnet Added: head/sbin/ifconfig/iffib.c (contents, props changed) Modified: head/sbin/ifconfig/Makefile head/sbin/ifconfig/ifconfig.8 head/share/man/man9/ifnet.9 head/sys/kern/kern_jail.c head/sys/net/if.c head/sys/net/if.h head/sys/net/if_debug.c head/sys/net/if_var.h head/sys/sys/priv.h head/sys/sys/sockio.h Modified: head/sbin/ifconfig/Makefile ============================================================================== --- head/sbin/ifconfig/Makefile Sun Jul 3 07:16:59 2011 (r223734) +++ head/sbin/ifconfig/Makefile Sun Jul 3 12:22:02 2011 (r223735) @@ -29,6 +29,7 @@ SRCS+= af_nd6.c # ND6 support SRCS+= ifclone.c # clone device support SRCS+= ifmac.c # MAC support SRCS+= ifmedia.c # SIOC[GS]IFMEDIA support +SRCS+= iffib.c # non-default FIB support SRCS+= ifvlan.c # SIOC[GS]ETVLAN support SRCS+= ifgre.c # GRE keys etc SRCS+= ifgif.c # GIF reversed header workaround Modified: head/sbin/ifconfig/ifconfig.8 ============================================================================== --- head/sbin/ifconfig/ifconfig.8 Sun Jul 3 07:16:59 2011 (r223734) +++ head/sbin/ifconfig/ifconfig.8 Sun Jul 3 12:22:02 2011 (r223735) @@ -28,7 +28,7 @@ .\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94 .\" $FreeBSD$ .\" -.Dd May 31, 2011 +.Dd July 3, 2011 .Dt IFCONFIG 8 .Os .Sh NAME @@ -296,6 +296,19 @@ Remove the interface from the given Fill interface index (lowermost 64bit of an IPv6 address) automatically. +.It Cm fib Ar fib_number +Specify interface FIB. +A FIB +.Ar fib_number +is assigned to all frames or packets received on that interface. +The FIB is not inherited, e.g. vlans or other sub-interfaces will use +the default FIB (0) irrespective of the parent interface's FIB. +The kernel needs to be tuned to support more than the default FIB +using the +.Va ROUTETABLES +kernel configuration option, or the +.Va net.fibs +tunable. .It Cm ipdst This is used to specify an Internet host who is willing to receive IP packets encapsulating IPX packets bound for a remote network. Added: head/sbin/ifconfig/iffib.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sbin/ifconfig/iffib.c Sun Jul 3 12:22:02 2011 (r223735) @@ -0,0 +1,103 @@ +/*- + * Copyright (c) 2011 Alexander V. Chernikov + * Copyright (c) 2011 Christian S.J. Peron + * Copyright (c) 2011 Bjoern A. Zeeb + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (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$ + */ + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include "ifconfig.h" + +static void +fib_status(int s) +{ + struct ifreq ifr; + + memset(&ifr, 0, sizeof(ifr)); + strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); + + if (ioctl(s, SIOCGIFFIB, (caddr_t)&ifr) < 0) + return; + + /* Ignore if it is the default. */ + if (ifr.ifr_fib == 0) + return; + + printf("\tfib: %u\n", ifr.ifr_fib); +} + +static void +setiffib(const char *val, int dummy __unused, int s, + const struct afswtch *afp) +{ + unsigned long fib; + char *ep; + + fib = strtoul(val, &ep, 0); + if (*ep != '\0' || fib > UINT_MAX) { + warn("fib %s not valid", val); + return; + } + + strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); + ifr.ifr_fib = fib; + if (ioctl(s, SIOCSIFFIB, (caddr_t)&ifr) < 0) + warn("ioctl (SIOCSIFFIB)"); +} + +static struct cmd fib_cmds[] = { + DEF_CMD_ARG("fib", setiffib), +}; + +static struct afswtch af_fib = { + .af_name = "af_fib", + .af_af = AF_UNSPEC, + .af_other_status = fib_status, +}; + +static __constructor void +fib_ctor(void) +{ +#define N(a) (sizeof(a) / sizeof(a[0])) + size_t i; + + for (i = 0; i < N(fib_cmds); i++) + cmd_register(&fib_cmds[i]); + af_register(&af_fib); +#undef N +} Modified: head/share/man/man9/ifnet.9 ============================================================================== --- head/share/man/man9/ifnet.9 Sun Jul 3 07:16:59 2011 (r223734) +++ head/share/man/man9/ifnet.9 Sun Jul 3 12:22:02 2011 (r223735) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 1, 2009 +.Dd July 3, 2011 .Dt IFNET 9 .Os .Sh NAME @@ -1169,11 +1169,12 @@ list. Caller must have appropriate privilege. (No call-down to driver.) .It Dv SIOCGIFCAP +.It Dv SIOCGIFFIB .It Dv SIOCGIFFLAGS .It Dv SIOCGIFMETRIC .It Dv SIOCGIFMTU .It Dv SIOCGIFPHYS -Get interface capabilities, flags, metric, MTU, medium selection. +Get interface capabilities, FIB, flags, metric, MTU, medium selection. (No call-down to driver.) .Pp .It Dv SIOCSIFCAP @@ -1192,6 +1193,12 @@ and .Va if_data.ifi_hwassist appropriately. .Pp +.It Dv SIOCSIFFIB +Sets interface FIB. +Caller must have appropriate privilege. +FIB values start at 0 and values greater or equals than +.Va net.fibs +are considered invalid. .It Dv SIOCSIFFLAGS Change interface flags. Caller must have appropriate privilege. Modified: head/sys/kern/kern_jail.c ============================================================================== --- head/sys/kern/kern_jail.c Sun Jul 3 07:16:59 2011 (r223734) +++ head/sys/kern/kern_jail.c Sun Jul 3 12:22:02 2011 (r223735) @@ -3639,6 +3639,7 @@ prison_priv_check(struct ucred *cred, in case PRIV_NET_LAGG: case PRIV_NET_GIF: case PRIV_NET_SETIFVNET: + case PRIV_NET_SETIFFIB: /* * 802.11-related privileges. Modified: head/sys/net/if.c ============================================================================== --- head/sys/net/if.c Sun Jul 3 07:16:59 2011 (r223734) +++ head/sys/net/if.c Sun Jul 3 12:22:02 2011 (r223735) @@ -58,6 +58,8 @@ #include #include #include +#include + #include #include @@ -2135,6 +2137,20 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, free(odescrbuf, M_IFDESCR); break; + case SIOCGIFFIB: + ifr->ifr_fib = ifp->if_fib; + break; + + case SIOCSIFFIB: + error = priv_check(td, PRIV_NET_SETIFFIB); + if (error) + return (error); + if (ifr->ifr_fib >= rt_numfibs) + return (EINVAL); + + ifp->if_fib = ifr->ifr_fib; + break; + case SIOCSIFFLAGS: error = priv_check(td, PRIV_NET_SETIFFLAGS); if (error) Modified: head/sys/net/if.h ============================================================================== --- head/sys/net/if.h Sun Jul 3 07:16:59 2011 (r223734) +++ head/sys/net/if.h Sun Jul 3 12:22:02 2011 (r223735) @@ -325,6 +325,7 @@ struct ifreq { int ifru_media; caddr_t ifru_data; int ifru_cap[2]; + u_int ifru_fib; } ifr_ifru; #define ifr_addr ifr_ifru.ifru_addr /* address */ #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */ @@ -341,6 +342,7 @@ struct ifreq { #define ifr_reqcap ifr_ifru.ifru_cap[0] /* requested capabilities */ #define ifr_curcap ifr_ifru.ifru_cap[1] /* current capabilities */ #define ifr_index ifr_ifru.ifru_index /* interface index */ +#define ifr_fib ifr_ifru.ifru_fib /* interface fib */ }; #define _SIZEOF_ADDR_IFREQ(ifr) \ Modified: head/sys/net/if_debug.c ============================================================================== --- head/sys/net/if_debug.c Sun Jul 3 07:16:59 2011 (r223734) +++ head/sys/net/if_debug.c Sun Jul 3 12:22:02 2011 (r223735) @@ -86,6 +86,7 @@ if_show_ifnet(struct ifnet *ifp) IF_DB_PRINTF("%d", if_snd.ifq_drv_maxlen); IF_DB_PRINTF("%d", if_snd.altq_type); IF_DB_PRINTF("%x", if_snd.altq_flags); + IF_DB_PRINTF("%u", if_fib); #undef IF_DB_PRINTF } Modified: head/sys/net/if_var.h ============================================================================== --- head/sys/net/if_var.h Sun Jul 3 07:16:59 2011 (r223734) +++ head/sys/net/if_var.h Sun Jul 3 12:22:02 2011 (r223735) @@ -196,6 +196,7 @@ struct ifnet { void *if_pf_kif; void *if_lagg; /* lagg glue */ u_char if_alloctype; /* if_type at time of allocation */ + u_int if_fib; /* interface FIB */ /* * Spare fields are added so that we can modify sensitive data Modified: head/sys/sys/priv.h ============================================================================== --- head/sys/sys/priv.h Sun Jul 3 07:16:59 2011 (r223734) +++ head/sys/sys/priv.h Sun Jul 3 12:22:02 2011 (r223735) @@ -337,6 +337,7 @@ #define PRIV_NET_GIF 416 /* Administer gif interface. */ #define PRIV_NET_SETIFVNET 417 /* Move interface to vnet. */ #define PRIV_NET_SETIFDESCR 418 /* Set interface description. */ +#define PRIV_NET_SETIFFIB 419 /* Set interface fib. */ /* * 802.11-related privileges. Modified: head/sys/sys/sockio.h ============================================================================== --- head/sys/sys/sockio.h Sun Jul 3 07:16:59 2011 (r223734) +++ head/sys/sys/sockio.h Sun Jul 3 12:22:02 2011 (r223735) @@ -110,6 +110,9 @@ #define SIOCSIFVNET _IOWR('i', 90, struct ifreq) /* move IF jail/vnet */ #define SIOCSIFRVNET _IOWR('i', 91, struct ifreq) /* reclaim vnet IF */ +#define SIOCGIFFIB _IOWR('i', 92, struct ifreq) /* get IF fib */ +#define SIOCSIFFIB _IOW('i', 93, struct ifreq) /* set IF fib */ + #define SIOCSDRVSPEC _IOW('i', 123, struct ifdrv) /* set driver-specific parameters */ #define SIOCGDRVSPEC _IOWR('i', 123, struct ifdrv) /* get driver-specific From owner-svn-src-head@FreeBSD.ORG Sun Jul 3 12:37:36 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 32EB31065670; Sun, 3 Jul 2011 12:37:36 +0000 (UTC) (envelope-from ronald-freebsd8@klop.yi.org) Received: from smtp-out1.tiscali.nl (smtp-out1.tiscali.nl [195.241.79.176]) by mx1.freebsd.org (Postfix) with ESMTP id B0D168FC19; Sun, 3 Jul 2011 12:37:35 +0000 (UTC) Received: from [212.182.167.131] (helo=sjakie.klop.ws) by smtp-out1.tiscali.nl with esmtp (Exim) (envelope-from ) id 1QdLah-0000D8-3y; Sun, 03 Jul 2011 14:15:59 +0200 Received: from 212-182-167-131.ip.telfort.nl (localhost [127.0.0.1]) by sjakie.klop.ws (Postfix) with ESMTP id 1143BF49C; Sun, 3 Jul 2011 14:15:48 +0200 (CEST) Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes To: "Alexey Dokuchaev" , "Warner Losh" References: <201106242132.p5OLW3DL071062@svn.freebsd.org> <20110628084558.GA35392@FreeBSD.org> <9521FD1A-3D77-4F37-B37C-CC73B13BC6B5@bsdimp.com> Date: Sun, 03 Jul 2011 14:15:46 +0200 MIME-Version: 1.0 From: "Ronald Klop" Message-ID: In-Reply-To: <9521FD1A-3D77-4F37-B37C-CC73B13BC6B5@bsdimp.com> User-Agent: Opera Mail/11.50 (FreeBSD) Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Hans Petter Selasky Subject: Re: svn commit: r223519 - head/etc/devd X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jul 2011 12:37:36 -0000 On Tue, 28 Jun 2011 18:01:37 +0200, Warner Losh wrote: > > On Jun 28, 2011, at 2:45 AM, Alexey Dokuchaev wrote: > >> On Sun, Jun 26, 2011 at 10:14:13PM -0600, Warner Losh wrote: >>> Not in GENERIC. 9.0 is getting ready to feature freeze any minute, s= o >>> there's no time to do the testing that a radical change like that wou= ld >>> require. >> >> Fair enough. Right now, this work seems to cover only USB kernel =20 >> modules, >> is it so? Is expansion into generic PCI area also planned, provided =20 >> that >> you've already had some ideas and seem to be willing to pick up the wo= rk >> given enough support from the other developers (please excuse me if my >> understanding is wrong)? > > The reason we were able to relatively quickly generate this file from =20 > USB is because USB is very regular and uniform in its probe routines. = =20 > They all have (or could be converted to have) something approximating =20 > the same format. > > PCI isn't even remotely close to this, and the techniques that worked =20 > for USB (and some of the short cuts taken) can't work for PCI for us. = =20 > There's no uniformity in the PCI space, although many of the PCI driver= s =20 > use a similar design pattern. They would all have to be converted to =20 > using the same thing, which is kinda impractical at the moment (since =20 > many have additional, driver specific fields). While the tool is kinda= =20 > flexible enough to cope with this situation, more and more code winds u= p =20 > in the tool to cope than is appropriate for the tool. > > That's why this feature is experimental. For what it works for, it =20 > works great. For everything else, it is a lot of work to make it happy= =20 > on a wide-spread enough scale. It is very instructive for how to =20 > approach things, but embeds too much knowledge of the bus code into the= =20 > tool to generate these files than is appropriate (since it is duplicate= d =20 > information from the driver, not exported from the bus/driver). > > Warner Maybe something for a GSOC 2012 project? From owner-svn-src-head@FreeBSD.ORG Sun Jul 3 13:27:23 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A67C21065672; Sun, 3 Jul 2011 13:27:23 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9606B8FC13; Sun, 3 Jul 2011 13:27:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p63DRN4M019925; Sun, 3 Jul 2011 13:27:23 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p63DRNOZ019920; Sun, 3 Jul 2011 13:27:23 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201107031327.p63DRNOZ019920@svn.freebsd.org> From: Hans Petter Selasky Date: Sun, 3 Jul 2011 13:27:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223736 - in head/sys/dev: sound/usb usb usb/quirk X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jul 2011 13:27:23 -0000 Author: hselasky Date: Sun Jul 3 13:27:23 2011 New Revision: 223736 URL: http://svn.freebsd.org/changeset/base/223736 Log: Introduce a quirk for broken USB MIDI hardware instead of limiting performance in general. MFC after: 1 week Modified: head/sys/dev/sound/usb/uaudio.c head/sys/dev/usb/quirk/usb_quirk.c head/sys/dev/usb/quirk/usb_quirk.h head/sys/dev/usb/usbdevs Modified: head/sys/dev/sound/usb/uaudio.c ============================================================================== --- head/sys/dev/sound/usb/uaudio.c Sun Jul 3 12:22:02 2011 (r223735) +++ head/sys/dev/sound/usb/uaudio.c Sun Jul 3 13:27:23 2011 (r223736) @@ -192,7 +192,7 @@ struct uaudio_chan { }; #define UMIDI_CABLES_MAX 16 /* units */ -#define UMIDI_TX_FRAMES 64 /* units */ +#define UMIDI_TX_FRAMES 128 /* units */ #define UMIDI_TX_BUFFER (UMIDI_TX_FRAMES * 4) /* bytes */ enum { @@ -236,6 +236,7 @@ struct umidi_chan { uint8_t curr_cable; uint8_t max_cable; uint8_t valid; + uint8_t single_command; }; struct uaudio_softc { @@ -499,7 +500,6 @@ static const struct usb_config .endpoint = UE_ADDR_ANY, .direction = UE_DIR_OUT, .bufsize = UMIDI_TX_BUFFER, - .frames = UMIDI_TX_FRAMES, .callback = &umidi_bulk_write_callback, }, @@ -3565,6 +3565,7 @@ tr_setup: nframes = 0; /* reset */ start_cable = chan->curr_cable; tr_any = 0; + pc = usbd_xfer_get_frame(xfer, 0); while (1) { @@ -3592,15 +3593,11 @@ tr_setup: sub->temp_cmd[0], sub->temp_cmd[1], sub->temp_cmd[2], sub->temp_cmd[3]); - usbd_xfer_set_frame_offset(xfer, 4 * nframes, nframes); - usbd_xfer_set_frame_len(xfer, nframes, 4); - - pc = usbd_xfer_get_frame(xfer, nframes); - - usbd_copy_in(pc, 0, sub->temp_cmd, 4); + usbd_copy_in(pc, nframes * 4, sub->temp_cmd, 4); nframes++; - if (nframes >= UMIDI_TX_FRAMES) + + if ((nframes >= UMIDI_TX_FRAMES) || (chan->single_command != 0)) break; } else { continue; @@ -3618,9 +3615,9 @@ tr_setup: } } - if (nframes > 0) { + if (nframes != 0) { DPRINTF("Transferring %d frames\n", (int)nframes); - usbd_xfer_set_frames(xfer, nframes); + usbd_xfer_set_frame_len(xfer, 0, 4 * nframes); usbd_transfer_submit(xfer); } break; @@ -3792,6 +3789,9 @@ umidi_probe(device_t dev) int error; uint32_t n; + if (usb_test_quirk(uaa, UQ_SINGLE_CMD_MIDI)) + chan->single_command = 1; + if (usbd_set_alt_interface_index(sc->sc_udev, chan->iface_index, chan->iface_alt_index)) { DPRINTF("setting of alternate index failed!\n"); Modified: head/sys/dev/usb/quirk/usb_quirk.c ============================================================================== --- head/sys/dev/usb/quirk/usb_quirk.c Sun Jul 3 12:22:02 2011 (r223735) +++ head/sys/dev/usb/quirk/usb_quirk.c Sun Jul 3 13:27:23 2011 (r223736) @@ -472,6 +472,7 @@ static struct usb_quirk_entry usb_quirks USB_QUIRK(ROLAND, SD20, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), USB_QUIRK(ROLAND, SD80, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), USB_QUIRK(ROLAND, UA700, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), + USB_QUIRK(MEDELI, DD305, 0x0000, 0xffff, UQ_SINGLE_CMD_MIDI, UQ_MATCH_VENDOR_ONLY), }; #undef USB_QUIRK_VP #undef USB_QUIRK @@ -538,6 +539,7 @@ static const char *usb_quirk_str[USB_QUI [UQ_MSC_EJECT_TCT] = "UQ_MSC_EJECT_TCT", [UQ_BAD_MIDI] = "UQ_BAD_MIDI", [UQ_AU_VENDOR_CLASS] = "UQ_AU_VENDOR_CLASS", + [UQ_SINGLE_CMD_MIDI] = "UQ_SINGLE_CMD_MIDI", }; /*------------------------------------------------------------------------* Modified: head/sys/dev/usb/quirk/usb_quirk.h ============================================================================== --- head/sys/dev/usb/quirk/usb_quirk.h Sun Jul 3 12:22:02 2011 (r223735) +++ head/sys/dev/usb/quirk/usb_quirk.h Sun Jul 3 13:27:23 2011 (r223736) @@ -102,6 +102,7 @@ enum { UQ_BAD_MIDI, /* device claims MIDI class, but isn't */ UQ_AU_VENDOR_CLASS, /* audio device uses vendor and not audio class */ + UQ_SINGLE_CMD_MIDI, /* at most one command per USB packet */ USB_QUIRK_MAX }; Modified: head/sys/dev/usb/usbdevs ============================================================================== --- head/sys/dev/usb/usbdevs Sun Jul 3 12:22:02 2011 (r223735) +++ head/sys/dev/usb/usbdevs Sun Jul 3 13:27:23 2011 (r223736) @@ -484,6 +484,7 @@ vendor SHANTOU 0x0a46 ShanTou vendor MEDIAGEAR 0x0a48 MediaGear vendor BROADCOM 0x0a5c Broadcom vendor GREENHOUSE 0x0a6b GREENHOUSE +vendor MEDELI 0x0a67 Medeli vendor GEOCAST 0x0a79 Geocast Network Systems vendor IDQUANTIQUE 0x0aba id Quantique vendor ZYDAS 0x0ace Zydas Technology Corporation @@ -2130,6 +2131,9 @@ product MCT DU_H3SP_USB232 0x0200 D-Link product MCT USB232 0x0210 USB-232 Interface product MCT SITECOM_USB232 0x0230 Sitecom USB-232 Products +/* Medeli */ +product MEDELI DD305 0x5011 DD305 Digital Drum Set + /* MediaTek, Inc. */ product MEDIATEK MTK3329 0x3329 MTK II GPS Receiver From owner-svn-src-head@FreeBSD.ORG Sun Jul 3 15:34:09 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7ED9F106566C; Sun, 3 Jul 2011 15:34:09 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6F91B8FC08; Sun, 3 Jul 2011 15:34:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p63FY9sQ023824; Sun, 3 Jul 2011 15:34:09 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p63FY9SS023822; Sun, 3 Jul 2011 15:34:09 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201107031534.p63FY9SS023822@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 3 Jul 2011 15:34:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223739 - head/sys/net X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jul 2011 15:34:09 -0000 Author: bz Date: Sun Jul 3 15:34:09 2011 New Revision: 223739 URL: http://svn.freebsd.org/changeset/base/223739 Log: Remove extra white space to comply with style for the rest of the struct. MFC after: 2 weeks Modified: head/sys/net/if_var.h Modified: head/sys/net/if_var.h ============================================================================== --- head/sys/net/if_var.h Sun Jul 3 15:28:32 2011 (r223738) +++ head/sys/net/if_var.h Sun Jul 3 15:34:09 2011 (r223739) @@ -195,7 +195,7 @@ struct ifnet { /* protected by if_addr_mtx */ void *if_pf_kif; void *if_lagg; /* lagg glue */ - u_char if_alloctype; /* if_type at time of allocation */ + u_char if_alloctype; /* if_type at time of allocation */ u_int if_fib; /* interface FIB */ /* @@ -203,7 +203,7 @@ struct ifnet { * structures without changing the kernel binary interface, and must * be used with care where binary compatibility is required. */ - char if_cspare[3]; + char if_cspare[3]; char *if_description; /* interface description */ void *if_pspare[7]; int if_ispare[4]; From owner-svn-src-head@FreeBSD.ORG Sun Jul 3 16:08:38 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CCB271065670; Sun, 3 Jul 2011 16:08:38 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BB3D88FC08; Sun, 3 Jul 2011 16:08:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p63G8cLE024919; Sun, 3 Jul 2011 16:08:38 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p63G8cIG024902; Sun, 3 Jul 2011 16:08:38 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201107031608.p63G8cIG024902@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 3 Jul 2011 16:08:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223741 - in head/sys: dev/iicbus dev/lmc dev/ppbus dev/usb/net net netgraph X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jul 2011 16:08:38 -0000 Author: bz Date: Sun Jul 3 16:08:38 2011 New Revision: 223741 URL: http://svn.freebsd.org/changeset/base/223741 Log: Tag mbufs of all incoming frames or packets with the interface's FIB setting (either default or if supported as set by SIOCSIFFIB, e.g. from ifconfig). Submitted by: Alexander V. Chernikov (melifaro ipfw.ru) Reviewed by: julian MFC after: 2 weeks Modified: head/sys/dev/iicbus/if_ic.c head/sys/dev/lmc/if_lmc.c head/sys/dev/ppbus/if_plip.c head/sys/dev/usb/net/uhso.c head/sys/net/if_arcsubr.c head/sys/net/if_atmsubr.c head/sys/net/if_ethersubr.c head/sys/net/if_fddisubr.c head/sys/net/if_fwsubr.c head/sys/net/if_gif.c head/sys/net/if_iso88025subr.c head/sys/net/if_spppfr.c head/sys/net/if_spppsubr.c head/sys/net/if_stf.c head/sys/net/if_tun.c head/sys/netgraph/ng_iface.c Modified: head/sys/dev/iicbus/if_ic.c ============================================================================== --- head/sys/dev/iicbus/if_ic.c Sun Jul 3 15:40:47 2011 (r223740) +++ head/sys/dev/iicbus/if_ic.c Sun Jul 3 16:08:38 2011 (r223741) @@ -308,6 +308,7 @@ icintr(device_t dev, int event, char *pt top = m_devget(sc->ic_ifbuf + ICHDRLEN, len, 0, sc->ic_ifp, 0); if (top) { mtx_unlock(&sc->ic_lock); + M_SETFIB(top, sc->ic_ifp->if_fib); netisr_dispatch(NETISR_IP, top); mtx_lock(&sc->ic_lock); } Modified: head/sys/dev/lmc/if_lmc.c ============================================================================== --- head/sys/dev/lmc/if_lmc.c Sun Jul 3 15:40:47 2011 (r223740) +++ head/sys/dev/lmc/if_lmc.c Sun Jul 3 16:08:38 2011 (r223741) @@ -2527,6 +2527,7 @@ lmc_raw_input(struct ifnet *ifp, struct { softc_t *sc = IFP2SC(ifp); + M_SETFIB(mbuf, ifp->if_fib); # if INET if (mbuf->m_data[0]>>4 == 4) netisr_dispatch(NETISR_IP, mbuf); Modified: head/sys/dev/ppbus/if_plip.c ============================================================================== --- head/sys/dev/ppbus/if_plip.c Sun Jul 3 15:40:47 2011 (r223740) +++ head/sys/dev/ppbus/if_plip.c Sun Jul 3 16:08:38 2011 (r223741) @@ -585,6 +585,8 @@ lp_intr(void *arg) if (bpf_peers_present(sc->sc_ifp->if_bpf)) lptap(sc->sc_ifp, top); + M_SETFIB(top, sc->sc_ifp->if_fib); + /* mbuf is free'd on failure. */ netisr_queue(NETISR_IP, top); ppb_lock(ppbus); @@ -637,6 +639,8 @@ lp_intr(void *arg) if (bpf_peers_present(sc->sc_ifp->if_bpf)) lptap(sc->sc_ifp, top); + M_SETFIB(top, sc->sc_ifp->if_fib); + /* mbuf is free'd on failure. */ netisr_queue(NETISR_IP, top); ppb_lock(ppbus); Modified: head/sys/dev/usb/net/uhso.c ============================================================================== --- head/sys/dev/usb/net/uhso.c Sun Jul 3 15:40:47 2011 (r223740) +++ head/sys/dev/usb/net/uhso.c Sun Jul 3 16:08:38 2011 (r223741) @@ -1754,6 +1754,7 @@ uhso_if_rxflush(void *arg) /* Dispatch to IP layer */ BPF_MTAP(sc->sc_ifp, m); + M_SETFIB(m, ifp->if_fib); netisr_dispatch(isr, m); m = m0 != NULL ? m0 : NULL; mtx_lock(&sc->sc_mtx); Modified: head/sys/net/if_arcsubr.c ============================================================================== --- head/sys/net/if_arcsubr.c Sun Jul 3 15:40:47 2011 (r223740) +++ head/sys/net/if_arcsubr.c Sun Jul 3 16:08:38 2011 (r223741) @@ -608,6 +608,7 @@ arc_input(struct ifnet *ifp, struct mbuf m_freem(m); return; } + M_SETFIB(m, ifp->if_fib); netisr_dispatch(isr, m); } Modified: head/sys/net/if_atmsubr.c ============================================================================== --- head/sys/net/if_atmsubr.c Sun Jul 3 15:40:47 2011 (r223740) +++ head/sys/net/if_atmsubr.c Sun Jul 3 16:08:38 2011 (r223741) @@ -332,6 +332,7 @@ atm_input(struct ifnet *ifp, struct atm_ return; } } + M_SETFIB(m, ifp->if_fib); netisr_dispatch(isr, m); } Modified: head/sys/net/if_ethersubr.c ============================================================================== --- head/sys/net/if_ethersubr.c Sun Jul 3 15:40:47 2011 (r223740) +++ head/sys/net/if_ethersubr.c Sun Jul 3 16:08:38 2011 (r223741) @@ -692,6 +692,8 @@ ether_input_internal(struct ifnet *ifp, m_adj(m, ETHER_VLAN_ENCAP_LEN); } + M_SETFIB(m, ifp->if_fib); + /* Allow ng_ether(4) to claim this frame. */ if (IFP2AC(ifp)->ac_netgraph != NULL) { KASSERT(ng_ether_input_p != NULL, Modified: head/sys/net/if_fddisubr.c ============================================================================== --- head/sys/net/if_fddisubr.c Sun Jul 3 15:40:47 2011 (r223740) +++ head/sys/net/if_fddisubr.c Sun Jul 3 16:08:38 2011 (r223741) @@ -550,6 +550,7 @@ fddi_input(ifp, m) ifp->if_noproto++; goto dropanyway; } + M_SETFIB(m, ifp->if_fib); netisr_dispatch(isr, m); return; Modified: head/sys/net/if_fwsubr.c ============================================================================== --- head/sys/net/if_fwsubr.c Sun Jul 3 15:40:47 2011 (r223740) +++ head/sys/net/if_fwsubr.c Sun Jul 3 16:08:38 2011 (r223741) @@ -627,6 +627,7 @@ firewire_input(struct ifnet *ifp, struct return; } + M_SETFIB(m, ifp->if_fib); netisr_dispatch(isr, m); } Modified: head/sys/net/if_gif.c ============================================================================== --- head/sys/net/if_gif.c Sun Jul 3 15:40:47 2011 (r223740) +++ head/sys/net/if_gif.c Sun Jul 3 16:08:38 2011 (r223741) @@ -609,6 +609,7 @@ gif_input(m, af, ifp) ifp->if_ipackets++; ifp->if_ibytes += m->m_pkthdr.len; + M_SETFIB(m, ifp->if_fib); netisr_dispatch(isr, m); } Modified: head/sys/net/if_iso88025subr.c ============================================================================== --- head/sys/net/if_iso88025subr.c Sun Jul 3 15:40:47 2011 (r223740) +++ head/sys/net/if_iso88025subr.c Sun Jul 3 16:08:38 2011 (r223741) @@ -680,6 +680,7 @@ iso88025_input(ifp, m) break; } + M_SETFIB(m, ifp->if_fib); netisr_dispatch(isr, m); return; Modified: head/sys/net/if_spppfr.c ============================================================================== --- head/sys/net/if_spppfr.c Sun Jul 3 15:40:47 2011 (r223740) +++ head/sys/net/if_spppfr.c Sun Jul 3 16:08:38 2011 (r223741) @@ -280,6 +280,8 @@ drop: ++ifp->if_ierrors; if (! (ifp->if_flags & IFF_UP)) goto drop; + M_SETFIB(m, ifp->if_fib); + /* Check queue. */ if (netisr_queue(isr, m)) { /* (0) on success. */ if (debug) Modified: head/sys/net/if_spppsubr.c ============================================================================== --- head/sys/net/if_spppsubr.c Sun Jul 3 15:40:47 2011 (r223740) +++ head/sys/net/if_spppsubr.c Sun Jul 3 16:08:38 2011 (r223741) @@ -737,6 +737,7 @@ sppp_input(struct ifnet *ifp, struct mbu goto drop; SPPP_UNLOCK(sp); + M_SETFIB(m, ifp->if_fib); /* Check queue. */ if (netisr_queue(isr, m)) { /* (0) on success. */ if (debug) Modified: head/sys/net/if_stf.c ============================================================================== --- head/sys/net/if_stf.c Sun Jul 3 15:40:47 2011 (r223740) +++ head/sys/net/if_stf.c Sun Jul 3 16:08:38 2011 (r223741) @@ -781,6 +781,7 @@ in_stf_input(m, off) */ ifp->if_ipackets++; ifp->if_ibytes += m->m_pkthdr.len; + M_SETFIB(m, ifp->if_fib); netisr_dispatch(NETISR_IPV6, m); } Modified: head/sys/net/if_tun.c ============================================================================== --- head/sys/net/if_tun.c Sun Jul 3 15:40:47 2011 (r223740) +++ head/sys/net/if_tun.c Sun Jul 3 16:08:38 2011 (r223741) @@ -929,6 +929,7 @@ tunwrite(struct cdev *dev, struct uio *u ifp->if_ibytes += m->m_pkthdr.len; ifp->if_ipackets++; CURVNET_SET(ifp->if_vnet); + M_SETFIB(m, ifp->if_fib); netisr_dispatch(isr, m); CURVNET_RESTORE(); return (0); Modified: head/sys/netgraph/ng_iface.c ============================================================================== --- head/sys/netgraph/ng_iface.c Sun Jul 3 15:40:47 2011 (r223740) +++ head/sys/netgraph/ng_iface.c Sun Jul 3 16:08:38 2011 (r223741) @@ -777,6 +777,7 @@ ng_iface_rcvdata(hook_p hook, item_p ite /* First chunk of an mbuf contains good junk */ if (harvest.point_to_point) random_harvest(m, 16, 3, 0, RANDOM_NET); + M_SETFIB(m, ifp->if_fib); netisr_dispatch(isr, m); return (0); } From owner-svn-src-head@FreeBSD.ORG Sun Jul 3 20:59:57 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D2F7C106566C; Sun, 3 Jul 2011 20:59:57 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C351F8FC19; Sun, 3 Jul 2011 20:59:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p63KxvwT040046; Sun, 3 Jul 2011 20:59:57 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p63Kxvdl040044; Sun, 3 Jul 2011 20:59:57 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201107032059.p63Kxvdl040044@svn.freebsd.org> From: Ed Schouten Date: Sun, 3 Jul 2011 20:59:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223744 - head/usr.sbin/config X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jul 2011 20:59:57 -0000 Author: ed Date: Sun Jul 3 20:59:57 2011 New Revision: 223744 URL: http://svn.freebsd.org/changeset/base/223744 Log: Improve portability of config(8). - Use strlen(dp->d_name) instead of the unportable dp->d_namlen. Rename i to len to make it slightly more descriptive and prevent negative indexing of the array. - Replace index() by strchr(). This supposedly fixes compilation on GNU systems. Submitted by: Robert Millan (original patch) MFC after: 3 weeks Modified: head/usr.sbin/config/main.c Modified: head/usr.sbin/config/main.c ============================================================================== --- head/usr.sbin/config/main.c Sun Jul 3 16:54:27 2011 (r223743) +++ head/usr.sbin/config/main.c Sun Jul 3 20:59:57 2011 (r223744) @@ -577,7 +577,7 @@ cleanheaders(char *p) struct dirent *dp; struct file_list *fl; struct hdr_list *hl; - int i; + size_t len; remember("y.tab.h"); remember("setdefs.h"); @@ -591,12 +591,13 @@ cleanheaders(char *p) if ((dirp = opendir(p)) == NULL) err(EX_OSERR, "opendir %s", p); while ((dp = readdir(dirp)) != NULL) { - i = dp->d_namlen - 2; + len = strlen(dp->d_name); /* Skip non-headers */ - if (dp->d_name[i] != '.' || dp->d_name[i + 1] != 'h') + if (len < 2 || dp->d_name[len - 2] != '.' || + dp->d_name[len - 1] != 'h') continue; /* Skip special stuff, eg: bus_if.h, but check opt_*.h */ - if (index(dp->d_name, '_') && + if (strchr(dp->d_name, '_') && strncmp(dp->d_name, "opt_", 4) != 0) continue; /* Check if it is a target file */ From owner-svn-src-head@FreeBSD.ORG Sun Jul 3 21:44:26 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DBA5E1065675; Sun, 3 Jul 2011 21:44:26 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CA9F98FC0C; Sun, 3 Jul 2011 21:44:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p63LiQLD041530; Sun, 3 Jul 2011 21:44:26 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p63LiQsF041526; Sun, 3 Jul 2011 21:44:26 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201107032144.p63LiQsF041526@svn.freebsd.org> From: Rick Macklem Date: Sun, 3 Jul 2011 21:44:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223747 - in head/sys/fs: nfs nfsclient X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jul 2011 21:44:27 -0000 Author: rmacklem Date: Sun Jul 3 21:44:26 2011 New Revision: 223747 URL: http://svn.freebsd.org/changeset/base/223747 Log: Modify the new NFSv4 client so that it appends a file handle to the lock_owner4 string that goes on the wire. Also, add code to do a ReleaseLockOwner Op on the lock_owner4 string before a Close. Apparently not all NFSv4 servers handle multiple instances of the same lock_owner4 string, at least not in a compatible way. This patch avoids having multiple instances, except for one unusual case, which will be fixed by a future commit. Found at the recent NFSv4 interoperability Bakeathon. Tested by: tdh at excfb.com MFC after: 2 weeks Modified: head/sys/fs/nfs/nfs_var.h head/sys/fs/nfsclient/nfs_clrpcops.c head/sys/fs/nfsclient/nfs_clstate.c Modified: head/sys/fs/nfs/nfs_var.h ============================================================================== --- head/sys/fs/nfs/nfs_var.h Sun Jul 3 21:07:21 2011 (r223746) +++ head/sys/fs/nfs/nfs_var.h Sun Jul 3 21:44:26 2011 (r223747) @@ -438,6 +438,7 @@ int nfscl_getcl(vnode_t, struct ucred *, struct nfsclclient *nfscl_findcl(struct nfsmount *); void nfscl_clientrelease(struct nfsclclient *); void nfscl_freelock(struct nfscllock *, int); +void nfscl_freelockowner(struct nfscllockowner *, int); int nfscl_getbytelock(vnode_t, u_int64_t, u_int64_t, short, struct ucred *, NFSPROC_T *, struct nfsclclient *, int, void *, int, u_int8_t *, u_int8_t *, struct nfscllockowner **, int *, int *); Modified: head/sys/fs/nfsclient/nfs_clrpcops.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clrpcops.c Sun Jul 3 21:07:21 2011 (r223746) +++ head/sys/fs/nfsclient/nfs_clrpcops.c Sun Jul 3 21:44:26 2011 (r223747) @@ -585,7 +585,7 @@ APPLESTATIC void nfsrpc_doclose(struct nfsmount *nmp, struct nfsclopen *op, NFSPROC_T *p) { struct nfsrv_descript nfsd, *nd = &nfsd; - struct nfscllockowner *lp; + struct nfscllockowner *lp, *nlp; struct nfscllock *lop, *nlop; struct ucred *tcred; u_int64_t off = 0, len = 0; @@ -642,6 +642,14 @@ nfsrpc_doclose(struct nfsmount *nmp, str } nfscl_freelock(lop, 0); } + /* + * Do a ReleaseLockOwner. + * The lock owner name nfsl_owner may be used by other opens for + * other files but the lock_owner4 name that nfsrpc_rellockown() + * puts on the wire has the file handle for this file appended + * to it, so it can be done now. + */ + (void)nfsrpc_rellockown(nmp, lp, tcred, p); } /* @@ -659,20 +667,8 @@ nfsrpc_doclose(struct nfsmount *nmp, str NFSLOCKCLSTATE(); nfscl_lockunlock(&op->nfso_own->nfsow_rwlock); - /* - * Move the lockowner to nfsc_defunctlockowner, - * so the Renew thread will do the ReleaseLockOwner - * Op on it later. There might still be other - * opens using the same lockowner name. - */ - lp = LIST_FIRST(&op->nfso_lock); - if (lp != NULL) { - while (LIST_NEXT(lp, nfsl_list) != NULL) - lp = LIST_NEXT(lp, nfsl_list); - LIST_PREPEND(&nmp->nm_clp->nfsc_defunctlockowner, - &op->nfso_lock, lp, nfsl_list); - LIST_INIT(&op->nfso_lock); - } + LIST_FOREACH_SAFE(lp, &op->nfso_lock, nfsl_list, nlp) + nfscl_freelockowner(lp, 0); nfscl_freeopen(op, 0); NFSUNLOCKCLSTATE(); NFSFREECRED(tcred); @@ -3629,7 +3625,8 @@ nfsrpc_lockt(struct nfsrv_descript *nd, { u_int32_t *tl; int error, type, size; - u_int8_t own[NFSV4CL_LOCKNAMELEN]; + uint8_t own[NFSV4CL_LOCKNAMELEN + NFSX_V4FHMAX]; + struct nfsnode *np; NFSCL_REQSTART(nd, NFSPROC_LOCKT, vp); NFSM_BUILD(tl, u_int32_t *, 7 * NFSX_UNSIGNED); @@ -3644,7 +3641,10 @@ nfsrpc_lockt(struct nfsrv_descript *nd, *tl++ = clp->nfsc_clientid.lval[0]; *tl = clp->nfsc_clientid.lval[1]; nfscl_filllockowner(id, own, flags); - (void) nfsm_strtom(nd, own, NFSV4CL_LOCKNAMELEN); + np = VTONFS(vp); + NFSBCOPY(np->n_fhp->nfh_fh, &own[NFSV4CL_LOCKNAMELEN], + np->n_fhp->nfh_len); + (void)nfsm_strtom(nd, own, NFSV4CL_LOCKNAMELEN + np->n_fhp->nfh_len); error = nfscl_request(nd, vp, p, cred, NULL); if (error) return (error); @@ -3744,6 +3744,7 @@ nfsrpc_lock(struct nfsrv_descript *nd, s { u_int32_t *tl; int error, size; + uint8_t own[NFSV4CL_LOCKNAMELEN + NFSX_V4FHMAX]; nfscl_reqstart(nd, NFSPROC_LOCK, nmp, nfhp, fhlen, NULL); NFSM_BUILD(tl, u_int32_t *, 7 * NFSX_UNSIGNED); @@ -3768,7 +3769,9 @@ nfsrpc_lock(struct nfsrv_descript *nd, s *tl++ = txdr_unsigned(lp->nfsl_seqid); *tl++ = lp->nfsl_open->nfso_own->nfsow_clp->nfsc_clientid.lval[0]; *tl = lp->nfsl_open->nfso_own->nfsow_clp->nfsc_clientid.lval[1]; - (void) nfsm_strtom(nd, lp->nfsl_owner, NFSV4CL_LOCKNAMELEN); + NFSBCOPY(lp->nfsl_owner, own, NFSV4CL_LOCKNAMELEN); + NFSBCOPY(nfhp, &own[NFSV4CL_LOCKNAMELEN], fhlen); + (void)nfsm_strtom(nd, own, NFSV4CL_LOCKNAMELEN + fhlen); } else { *tl = newnfs_false; NFSM_BUILD(tl, u_int32_t *, NFSX_STATEID + NFSX_UNSIGNED); @@ -4029,12 +4032,17 @@ nfsrpc_rellockown(struct nfsmount *nmp, struct nfsrv_descript nfsd, *nd = &nfsd; u_int32_t *tl; int error; + uint8_t own[NFSV4CL_LOCKNAMELEN + NFSX_V4FHMAX]; nfscl_reqstart(nd, NFSPROC_RELEASELCKOWN, nmp, NULL, 0, NULL); NFSM_BUILD(tl, u_int32_t *, 2 * NFSX_UNSIGNED); *tl++ = nmp->nm_clp->nfsc_clientid.lval[0]; *tl = nmp->nm_clp->nfsc_clientid.lval[1]; - (void) nfsm_strtom(nd, lp->nfsl_owner, NFSV4CL_LOCKNAMELEN); + NFSBCOPY(lp->nfsl_owner, own, NFSV4CL_LOCKNAMELEN); + NFSBCOPY(lp->nfsl_open->nfso_fh, &own[NFSV4CL_LOCKNAMELEN], + lp->nfsl_open->nfso_fhlen); + (void)nfsm_strtom(nd, own, NFSV4CL_LOCKNAMELEN + + lp->nfsl_open->nfso_fhlen); nd->nd_flag |= ND_USEGSSNAME; error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred, NFS_PROG, NFS_VER4, NULL, 1, NULL); Modified: head/sys/fs/nfsclient/nfs_clstate.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clstate.c Sun Jul 3 21:07:21 2011 (r223746) +++ head/sys/fs/nfsclient/nfs_clstate.c Sun Jul 3 21:44:26 2011 (r223747) @@ -114,7 +114,6 @@ static struct nfscldeleg *nfscl_finddele int); static int nfscl_checkconflict(struct nfscllockownerhead *, struct nfscllock *, u_int8_t *, struct nfscllock **); -static void nfscl_freelockowner(struct nfscllockowner *, int); static void nfscl_freealllocks(struct nfscllockownerhead *, int); static int nfscl_localconflict(struct nfsclclient *, u_int8_t *, int, struct nfscllock *, u_int8_t *, struct nfscldeleg *, struct nfscllock **); @@ -1450,7 +1449,7 @@ nfscl_freeopenowner(struct nfsclowner *o /* * Free up a byte range lock owner structure. */ -static void +APPLESTATIC void nfscl_freelockowner(struct nfscllockowner *lp, int local) { struct nfscllock *lop, *nlop; From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 03:19:06 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C6220106564A; Mon, 4 Jul 2011 03:19:06 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B73438FC18; Mon, 4 Jul 2011 03:19:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p643J6Wj051796; Mon, 4 Jul 2011 03:19:06 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p643J62W051794; Mon, 4 Jul 2011 03:19:06 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201107040319.p643J62W051794@svn.freebsd.org> From: Hiroki Sato Date: Mon, 4 Jul 2011 03:19:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223752 - head/usr.sbin/rtadvd X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 03:19:06 -0000 Author: hrs Date: Mon Jul 4 03:19:06 2011 New Revision: 223752 URL: http://svn.freebsd.org/changeset/base/223752 Log: Add sanity check for ifm_version in struct if_msghdr. Modified: head/usr.sbin/rtadvd/if.c Modified: head/usr.sbin/rtadvd/if.c ============================================================================== --- head/usr.sbin/rtadvd/if.c Mon Jul 4 01:27:41 2011 (r223751) +++ head/usr.sbin/rtadvd/if.c Mon Jul 4 03:19:06 2011 (r223752) @@ -105,6 +105,12 @@ if_nametosdl(char *name) lim = buf + len; for (next = buf; next < lim; next += ifm->ifm_msglen) { ifm = (struct if_msghdr *)next; + if (ifm->ifm_version != RTM_VERSION) { + syslog(LOG_ERR, + "<%s> RTM_VERSION mismatch (%d != %d).", + __func__, ifm->ifm_version, RTM_VERSION); + continue; + } if (ifm->ifm_type == RTM_IFINFO) { sa = (struct sockaddr *)(ifm + 1); get_rtaddrs(ifm->ifm_addrs, sa, rti_info); From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 05:47:48 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A1C65106566C; Mon, 4 Jul 2011 05:47:48 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 922178FC13; Mon, 4 Jul 2011 05:47:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p645lmN4056108; Mon, 4 Jul 2011 05:47:48 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p645lmhU056106; Mon, 4 Jul 2011 05:47:48 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201107040547.p645lmhU056106@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Mon, 4 Jul 2011 05:47:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223753 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 05:47:48 -0000 Author: ae Date: Mon Jul 4 05:47:48 2011 New Revision: 223753 URL: http://svn.freebsd.org/changeset/base/223753 Log: ARP code reuses mbuf from ARP request to make a reply, but it does not reset rcvif to NULL. Since rcvif is not NULL, ipfw(4) supposes that ARP replies were received on specified interface. Reset rcvif to NULL for ARP replies to fix this issue. PR: kern/131817 Reviewed by: glebius MFC after: 1 month Modified: head/sys/netinet/if_ether.c Modified: head/sys/netinet/if_ether.c ============================================================================== --- head/sys/netinet/if_ether.c Mon Jul 4 03:19:06 2011 (r223752) +++ head/sys/netinet/if_ether.c Mon Jul 4 05:47:48 2011 (r223753) @@ -857,6 +857,7 @@ reply: ah->ar_pro = htons(ETHERTYPE_IP); /* let's be sure! */ m->m_len = sizeof(*ah) + (2 * ah->ar_pln) + (2 * ah->ar_hln); m->m_pkthdr.len = m->m_len; + m->m_pkthdr.rcvif = NULL; sa.sa_family = AF_ARP; sa.sa_len = 2; (*ifp->if_output)(ifp, m, &sa, NULL); From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 07:03:45 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 014CB106564A; Mon, 4 Jul 2011 07:03:45 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E545F8FC13; Mon, 4 Jul 2011 07:03:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6473iln058327; Mon, 4 Jul 2011 07:03:44 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6473inv058324; Mon, 4 Jul 2011 07:03:44 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201107040703.p6473inv058324@svn.freebsd.org> From: Gleb Smirnoff Date: Mon, 4 Jul 2011 07:03:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223754 - head/sys/netgraph X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 07:03:45 -0000 Author: glebius Date: Mon Jul 4 07:03:44 2011 New Revision: 223754 URL: http://svn.freebsd.org/changeset/base/223754 Log: - Use refcount(9) API to manage node and hook refcounting. - Make ng_unref_node() void, since caller shouldn't be interested in whether node is valid after call or not, since it can't be guaranteed to be valid. [1] Ok from: julian [1] Modified: head/sys/netgraph/netgraph.h head/sys/netgraph/ng_base.c Modified: head/sys/netgraph/netgraph.h ============================================================================== --- head/sys/netgraph/netgraph.h Mon Jul 4 05:47:48 2011 (r223753) +++ head/sys/netgraph/netgraph.h Mon Jul 4 07:03:44 2011 (r223754) @@ -53,6 +53,7 @@ #include #include #include +#include #ifdef HAVE_KERNEL_OPTION_HEADERS #include "opt_netgraph.h" @@ -137,7 +138,7 @@ struct ng_hook { * If you can't do it with these you probably shouldn;t be doing it. */ void ng_unref_hook(hook_p hook); /* don't move this */ -#define _NG_HOOK_REF(hook) atomic_add_int(&(hook)->hk_refs, 1) +#define _NG_HOOK_REF(hook) refcount_acquire(&(hook)->hk_refs) #define _NG_HOOK_NAME(hook) ((hook)->hk_name) #define _NG_HOOK_UNREF(hook) ng_unref_hook(hook) #define _NG_HOOK_SET_PRIVATE(hook, val) do {(hook)->hk_private = val;} while (0) @@ -396,11 +397,11 @@ struct ng_node { * Public methods for nodes. * If you can't do it with these you probably shouldn't be doing it. */ -int ng_unref_node(node_p node); /* don't move this */ +void ng_unref_node(node_p node); /* don't move this */ #define _NG_NODE_NAME(node) ((node)->nd_name + 0) #define _NG_NODE_HAS_NAME(node) ((node)->nd_name[0] + 0) #define _NG_NODE_ID(node) ((node)->nd_ID + 0) -#define _NG_NODE_REF(node) atomic_add_int(&(node)->nd_refs, 1) +#define _NG_NODE_REF(node) refcount_acquire(&(node)->nd_refs) #define _NG_NODE_UNREF(node) ng_unref_node(node) #define _NG_NODE_SET_PRIVATE(node, val) do {(node)->nd_private = val;} while (0) #define _NG_NODE_PRIVATE(node) ((node)->nd_private) Modified: head/sys/netgraph/ng_base.c ============================================================================== --- head/sys/netgraph/ng_base.c Mon Jul 4 05:47:48 2011 (r223753) +++ head/sys/netgraph/ng_base.c Mon Jul 4 07:03:44 2011 (r223754) @@ -772,18 +772,14 @@ ng_rmnode(node_p node, hook_p dummy1, vo * Remove a reference to the node, possibly the last. * deadnode always acts as it it were the last. */ -int +void ng_unref_node(node_p node) { - int v; - - if (node == &ng_deadnode) { - return (0); - } - v = atomic_fetchadd_int(&node->nd_refs, -1); + if (node == &ng_deadnode) + return; - if (v == 1) { /* we were the last */ + if (refcount_release(&node->nd_refs)) { /* we were the last */ mtx_lock(&ng_namehash_mtx); node->nd_type->refs--; /* XXX maybe should get types lock? */ @@ -797,7 +793,6 @@ ng_unref_node(node_p node) mtx_destroy(&node->nd_input_queue.q_mtx); NG_FREE_NODE(node); } - return (v - 1); } /************************************************************************ @@ -963,15 +958,11 @@ ng_unname(node_p node) void ng_unref_hook(hook_p hook) { - int v; - if (hook == &ng_deadhook) { + if (hook == &ng_deadhook) return; - } - - v = atomic_fetchadd_int(&hook->hk_refs, -1); - if (v == 1) { /* we were the last */ + if (refcount_release(&hook->hk_refs)) { /* we were the last */ if (_NG_HOOK_NODE(hook)) /* it'll probably be ng_deadnode */ _NG_NODE_UNREF((_NG_HOOK_NODE(hook))); NG_FREE_HOOK(hook); From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 07:37:28 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5828D106566C; Mon, 4 Jul 2011 07:37:28 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4687E8FC0A; Mon, 4 Jul 2011 07:37:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p647bSOh059326; Mon, 4 Jul 2011 07:37:28 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p647bSQC059322; Mon, 4 Jul 2011 07:37:28 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201107040737.p647bSQC059322@svn.freebsd.org> From: Hans Petter Selasky Date: Mon, 4 Jul 2011 07:37:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223755 - in head/sys/dev/usb: . input X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 07:37:29 -0000 Author: hselasky Date: Mon Jul 4 07:37:28 2011 New Revision: 223755 URL: http://svn.freebsd.org/changeset/base/223755 Log: Make the USB keyboard driver more HID compliant. Try to auto-detect keyboards which should use the BOOT protocol. MFC after: 2 weeks Modified: head/sys/dev/usb/input/ukbd.c head/sys/dev/usb/usb_hid.c head/sys/dev/usb/usbhid.h Modified: head/sys/dev/usb/input/ukbd.c ============================================================================== --- head/sys/dev/usb/input/ukbd.c Mon Jul 4 07:03:44 2011 (r223754) +++ head/sys/dev/usb/input/ukbd.c Mon Jul 4 07:37:28 2011 (r223755) @@ -108,9 +108,10 @@ TUNABLE_INT("hw.usb.ukbd.no_leds", &ukbd #define UKBD_IN_BUF_SIZE (2*(UKBD_NMOD + (2*UKBD_NKEYCODE))) /* bytes */ #define UKBD_IN_BUF_FULL (UKBD_IN_BUF_SIZE / 2) /* bytes */ #define UKBD_NFKEY (sizeof(fkey_tab)/sizeof(fkey_tab[0])) /* units */ +#define UKBD_BUFFER_SIZE 64 /* bytes */ struct ukbd_data { - uint8_t modifiers; + uint16_t modifiers; #define MOD_CONTROL_L 0x01 #define MOD_CONTROL_R 0x10 #define MOD_SHIFT_L 0x02 @@ -119,9 +120,10 @@ struct ukbd_data { #define MOD_ALT_R 0x40 #define MOD_WIN_L 0x08 #define MOD_WIN_R 0x80 - uint8_t reserved; +/* internal */ +#define MOD_EJECT 0x0100 +#define MOD_FN 0x0200 uint8_t keycode[UKBD_NKEYCODE]; - uint8_t exten[8]; }; enum { @@ -137,6 +139,18 @@ struct ukbd_softc { fkeytab_t sc_fkeymap[UKBD_NFKEY]; struct hid_location sc_loc_apple_eject; struct hid_location sc_loc_apple_fn; + struct hid_location sc_loc_ctrl_l; + struct hid_location sc_loc_ctrl_r; + struct hid_location sc_loc_shift_l; + struct hid_location sc_loc_shift_r; + struct hid_location sc_loc_alt_l; + struct hid_location sc_loc_alt_r; + struct hid_location sc_loc_win_l; + struct hid_location sc_loc_win_r; + struct hid_location sc_loc_events; + struct hid_location sc_loc_numlock; + struct hid_location sc_loc_capslock; + struct hid_location sc_loc_scrolllock; struct usb_callout sc_callout; struct ukbd_data sc_ndata; struct ukbd_data sc_odata; @@ -155,31 +169,64 @@ struct ukbd_softc { uint32_t sc_buffered_char[2]; #endif uint32_t sc_flags; /* flags */ -#define UKBD_FLAG_COMPOSE 0x0001 -#define UKBD_FLAG_POLLING 0x0002 -#define UKBD_FLAG_SET_LEDS 0x0004 -#define UKBD_FLAG_ATTACHED 0x0010 -#define UKBD_FLAG_GONE 0x0020 -#define UKBD_FLAG_APPLE_EJECT 0x0040 -#define UKBD_FLAG_APPLE_FN 0x0080 -#define UKBD_FLAG_APPLE_SWAP 0x0100 -#define UKBD_FLAG_TIMER_RUNNING 0x0200 +#define UKBD_FLAG_COMPOSE 0x00000001 +#define UKBD_FLAG_POLLING 0x00000002 +#define UKBD_FLAG_SET_LEDS 0x00000004 +#define UKBD_FLAG_ATTACHED 0x00000010 +#define UKBD_FLAG_GONE 0x00000020 + +#define UKBD_FLAG_HID_MASK 0x003fffc0 +#define UKBD_FLAG_APPLE_EJECT 0x00000040 +#define UKBD_FLAG_APPLE_FN 0x00000080 +#define UKBD_FLAG_APPLE_SWAP 0x00000100 +#define UKBD_FLAG_TIMER_RUNNING 0x00000200 +#define UKBD_FLAG_CTRL_L 0x00000400 +#define UKBD_FLAG_CTRL_R 0x00000800 +#define UKBD_FLAG_SHIFT_L 0x00001000 +#define UKBD_FLAG_SHIFT_R 0x00002000 +#define UKBD_FLAG_ALT_L 0x00004000 +#define UKBD_FLAG_ALT_R 0x00008000 +#define UKBD_FLAG_WIN_L 0x00010000 +#define UKBD_FLAG_WIN_R 0x00020000 +#define UKBD_FLAG_EVENTS 0x00040000 +#define UKBD_FLAG_NUMLOCK 0x00080000 +#define UKBD_FLAG_CAPSLOCK 0x00100000 +#define UKBD_FLAG_SCROLLLOCK 0x00200000 int sc_mode; /* input mode (K_XLATE,K_RAW,K_CODE) */ int sc_state; /* shift/lock key state */ int sc_accents; /* accent key index (> 0) */ int sc_poll_tick_last; + int sc_led_size; + int sc_kbd_size; uint16_t sc_inputs; uint16_t sc_inputhead; uint16_t sc_inputtail; + uint16_t sc_modifiers; uint8_t sc_leds; /* store for async led requests */ uint8_t sc_iface_index; uint8_t sc_iface_no; + uint8_t sc_id_apple_eject; + uint8_t sc_id_apple_fn; + uint8_t sc_id_ctrl_l; + uint8_t sc_id_ctrl_r; + uint8_t sc_id_shift_l; + uint8_t sc_id_shift_r; + uint8_t sc_id_alt_l; + uint8_t sc_id_alt_r; + uint8_t sc_id_win_l; + uint8_t sc_id_win_r; + uint8_t sc_id_event; + uint8_t sc_id_numlock; + uint8_t sc_id_capslock; + uint8_t sc_id_scrolllock; + uint8_t sc_id_events; uint8_t sc_kbd_id; - uint8_t sc_led_id; + uint8_t sc_poll_detected; + uint8_t sc_buffer[UKBD_BUFFER_SIZE]; }; #define KEY_ERROR 0x01 @@ -261,6 +308,22 @@ static const uint8_t ukbd_trtab[256] = { NN, NN, NN, NN, NN, NN, NN, NN, /* F8 - FF */ }; +static const uint8_t ukbd_boot_desc[] = { + 0x05, 0x01, 0x09, 0x06, 0xa1, + 0x01, 0x05, 0x07, 0x19, 0xe0, + 0x29, 0xe7, 0x15, 0x00, 0x25, + 0x01, 0x75, 0x01, 0x95, 0x08, + 0x81, 0x02, 0x95, 0x01, 0x75, + 0x08, 0x81, 0x01, 0x95, 0x03, + 0x75, 0x01, 0x05, 0x08, 0x19, + 0x01, 0x29, 0x03, 0x91, 0x02, + 0x95, 0x05, 0x75, 0x01, 0x91, + 0x01, 0x95, 0x06, 0x75, 0x08, + 0x15, 0x00, 0x26, 0xff, 0x00, + 0x05, 0x07, 0x19, 0x00, 0x2a, + 0xff, 0x00, 0x81, 0x00, 0xc0 +}; + /* prototypes */ static void ukbd_timeout(void *); static void ukbd_set_leds(struct ukbd_softc *, uint8_t); @@ -561,8 +624,6 @@ ukbd_intr_callback(struct usb_xfer *xfer uint8_t i; uint8_t offset; uint8_t id; - uint8_t apple_fn; - uint8_t apple_eject; int len; usbd_xfer_status(xfer, &len, NULL, NULL, NULL); @@ -580,73 +641,145 @@ ukbd_intr_callback(struct usb_xfer *xfer if (sc->sc_kbd_id != 0) { /* check and remove HID ID byte */ usbd_copy_out(pc, 0, &id, 1); - if (id != sc->sc_kbd_id) { - DPRINTF("wrong HID ID\n"); - goto tr_setup; - } offset = 1; len--; + if (len == 0) { + DPRINTF("zero length data\n"); + goto tr_setup; + } } else { offset = 0; + id = 0; } - if (len > sizeof(sc->sc_ndata)) { - len = sizeof(sc->sc_ndata); - } + if (len > UKBD_BUFFER_SIZE) + len = UKBD_BUFFER_SIZE; - if (len) { - memset(&sc->sc_ndata, 0, sizeof(sc->sc_ndata)); - usbd_copy_out(pc, offset, &sc->sc_ndata, len); - - if ((sc->sc_flags & UKBD_FLAG_APPLE_EJECT) && - hid_get_data((uint8_t *)&sc->sc_ndata, - len, &sc->sc_loc_apple_eject)) - apple_eject = 1; - else - apple_eject = 0; + /* get data */ + usbd_copy_out(pc, offset, sc->sc_buffer, len); + + /* clear temporary storage */ + memset(&sc->sc_ndata, 0, sizeof(sc->sc_ndata)); - if ((sc->sc_flags & UKBD_FLAG_APPLE_FN) && - hid_get_data((uint8_t *)&sc->sc_ndata, - len, &sc->sc_loc_apple_fn)) - apple_fn = 1; + /* scan through HID data */ + if ((sc->sc_flags & UKBD_FLAG_APPLE_EJECT) && + (id == sc->sc_id_apple_eject)) { + if (hid_get_data(sc->sc_buffer, len, &sc->sc_loc_apple_eject)) + sc->sc_modifiers |= MOD_EJECT; else - apple_fn = 0; -#ifdef USB_DEBUG - DPRINTF("apple_eject=%u apple_fn=%u\n", - apple_eject, apple_fn); + sc->sc_modifiers &= ~MOD_EJECT; + } + if ((sc->sc_flags & UKBD_FLAG_APPLE_FN) && + (id == sc->sc_id_apple_fn)) { + if (hid_get_data(sc->sc_buffer, len, &sc->sc_loc_apple_fn)) + sc->sc_modifiers |= MOD_FN; + else + sc->sc_modifiers &= ~MOD_FN; + } + if ((sc->sc_flags & UKBD_FLAG_CTRL_L) && + (id == sc->sc_id_ctrl_l)) { + if (hid_get_data(sc->sc_buffer, len, &sc->sc_loc_ctrl_l)) + sc-> sc_modifiers |= MOD_CONTROL_L; + else + sc-> sc_modifiers &= ~MOD_CONTROL_L; + } + if ((sc->sc_flags & UKBD_FLAG_CTRL_R) && + (id == sc->sc_id_ctrl_r)) { + if (hid_get_data(sc->sc_buffer, len, &sc->sc_loc_ctrl_r)) + sc->sc_modifiers |= MOD_CONTROL_R; + else + sc->sc_modifiers &= ~MOD_CONTROL_R; + } + if ((sc->sc_flags & UKBD_FLAG_SHIFT_L) && + (id == sc->sc_id_shift_l)) { + if (hid_get_data(sc->sc_buffer, len, &sc->sc_loc_shift_l)) + sc->sc_modifiers |= MOD_SHIFT_L; + else + sc->sc_modifiers &= ~MOD_SHIFT_L; + } + if ((sc->sc_flags & UKBD_FLAG_SHIFT_R) && + (id == sc->sc_id_shift_r)) { + if (hid_get_data(sc->sc_buffer, len, &sc->sc_loc_shift_r)) + sc->sc_modifiers |= MOD_SHIFT_R; + else + sc->sc_modifiers &= ~MOD_SHIFT_R; + } + if ((sc->sc_flags & UKBD_FLAG_ALT_L) && + (id == sc->sc_id_alt_l)) { + if (hid_get_data(sc->sc_buffer, len, &sc->sc_loc_alt_l)) + sc->sc_modifiers |= MOD_ALT_L; + else + sc->sc_modifiers &= ~MOD_ALT_L; + } + if ((sc->sc_flags & UKBD_FLAG_ALT_R) && + (id == sc->sc_id_alt_r)) { + if (hid_get_data(sc->sc_buffer, len, &sc->sc_loc_alt_r)) + sc->sc_modifiers |= MOD_ALT_R; + else + sc->sc_modifiers &= ~MOD_ALT_R; + } + if ((sc->sc_flags & UKBD_FLAG_WIN_L) && + (id == sc->sc_id_win_l)) { + if (hid_get_data(sc->sc_buffer, len, &sc->sc_loc_win_l)) + sc->sc_modifiers |= MOD_WIN_L; + else + sc->sc_modifiers &= ~MOD_WIN_L; + } + if ((sc->sc_flags & UKBD_FLAG_WIN_R) && + (id == sc->sc_id_win_r)) { + if (hid_get_data(sc->sc_buffer, len, &sc->sc_loc_win_r)) + sc->sc_modifiers |= MOD_WIN_R; + else + sc->sc_modifiers &= ~MOD_WIN_R; + } - if (sc->sc_ndata.modifiers) { - DPRINTF("mod: 0x%04x\n", sc->sc_ndata.modifiers); - } - for (i = 0; i < UKBD_NKEYCODE; i++) { - if (sc->sc_ndata.keycode[i]) { - DPRINTF("[%d] = %d\n", i, sc->sc_ndata.keycode[i]); - } + sc->sc_ndata.modifiers = sc->sc_modifiers; + + if ((sc->sc_flags & UKBD_FLAG_EVENTS) && + (id == sc->sc_id_events)) { + i = sc->sc_loc_events.count; + if (i > UKBD_NKEYCODE) + i = UKBD_NKEYCODE; + if (i > len) + i = len; + while (i--) { + sc->sc_ndata.keycode[i] = + hid_get_data(sc->sc_buffer + i, len - i, + &sc->sc_loc_events); } -#endif /* USB_DEBUG */ + } - if (apple_fn) { - for (i = 0; i < UKBD_NKEYCODE; i++) { - sc->sc_ndata.keycode[i] = - ukbd_apple_fn(sc->sc_ndata.keycode[i]); - } +#ifdef USB_DEBUG + DPRINTF("modifiers = 0x%04x\n", (int)sc->sc_modifiers); + for (i = 0; i < UKBD_NKEYCODE; i++) { + if (sc->sc_ndata.keycode[i]) { + DPRINTF("[%d] = 0x%02x\n", + (int)i, (int)sc->sc_ndata.keycode[i]); } + } +#endif + if (sc->sc_modifiers & MOD_FN) { + for (i = 0; i < UKBD_NKEYCODE; i++) { + sc->sc_ndata.keycode[i] = + ukbd_apple_fn(sc->sc_ndata.keycode[i]); + } + } - if (sc->sc_flags & UKBD_FLAG_APPLE_SWAP) { - for (i = 0; i < UKBD_NKEYCODE; i++) { - sc->sc_ndata.keycode[i] = - ukbd_apple_swap(sc->sc_ndata.keycode[i]); - } + if (sc->sc_flags & UKBD_FLAG_APPLE_SWAP) { + for (i = 0; i < UKBD_NKEYCODE; i++) { + sc->sc_ndata.keycode[i] = + ukbd_apple_swap(sc->sc_ndata.keycode[i]); } + } - ukbd_interrupt(sc); + ukbd_interrupt(sc); - if (!(sc->sc_flags & UKBD_FLAG_TIMER_RUNNING)) { - if (ukbd_any_key_pressed(sc)) { - ukbd_start_timer(sc); - } + if (!(sc->sc_flags & UKBD_FLAG_TIMER_RUNNING)) { + if (ukbd_any_key_pressed(sc)) { + ukbd_start_timer(sc); } } + case USB_ST_SETUP: tr_setup: if (sc->sc_inputs < UKBD_IN_BUF_FULL) { @@ -672,10 +805,12 @@ tr_setup: static void ukbd_set_leds_callback(struct usb_xfer *xfer, usb_error_t error) { + struct ukbd_softc *sc = usbd_xfer_softc(xfer); struct usb_device_request req; struct usb_page_cache *pc; - uint8_t buf[2]; - struct ukbd_softc *sc = usbd_xfer_softc(xfer); + uint8_t id; + uint8_t any; + int len; #ifdef USB_DEBUG if (ukbd_no_leds) @@ -685,37 +820,83 @@ ukbd_set_leds_callback(struct usb_xfer * switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: case USB_ST_SETUP: - if (sc->sc_flags & UKBD_FLAG_SET_LEDS) { - sc->sc_flags &= ~UKBD_FLAG_SET_LEDS; + if (!(sc->sc_flags & UKBD_FLAG_SET_LEDS)) + break; + sc->sc_flags &= ~UKBD_FLAG_SET_LEDS; - req.bmRequestType = UT_WRITE_CLASS_INTERFACE; - req.bRequest = UR_SET_REPORT; - USETW2(req.wValue, UHID_OUTPUT_REPORT, 0); - req.wIndex[0] = sc->sc_iface_no; - req.wIndex[1] = 0; - req.wLength[1] = 0; - - /* check if we need to prefix an ID byte */ - if (sc->sc_led_id != 0) { - req.wLength[0] = 2; - buf[0] = sc->sc_led_id; - buf[1] = sc->sc_leds; - } else { - req.wLength[0] = 1; - buf[0] = sc->sc_leds; - buf[1] = 0; + req.bmRequestType = UT_WRITE_CLASS_INTERFACE; + req.bRequest = UR_SET_REPORT; + USETW2(req.wValue, UHID_OUTPUT_REPORT, 0); + req.wIndex[0] = sc->sc_iface_no; + req.wIndex[1] = 0; + req.wLength[1] = 0; + + memset(sc->sc_buffer, 0, UKBD_BUFFER_SIZE); + + id = 0; + any = 0; + + /* Assumption: All led bits must be in the same ID. */ + + if (sc->sc_flags & UKBD_FLAG_NUMLOCK) { + if (sc->sc_leds & NLKED) { + hid_put_data_unsigned(sc->sc_buffer + 1, UKBD_BUFFER_SIZE - 1, + &sc->sc_loc_numlock, 1); } + id = sc->sc_id_numlock; + any = 1; + } - pc = usbd_xfer_get_frame(xfer, 0); - usbd_copy_in(pc, 0, &req, sizeof(req)); - pc = usbd_xfer_get_frame(xfer, 1); - usbd_copy_in(pc, 0, buf, sizeof(buf)); - - usbd_xfer_set_frame_len(xfer, 0, sizeof(req)); - usbd_xfer_set_frame_len(xfer, 1, req.wLength[0]); - usbd_xfer_set_frames(xfer, 2); - usbd_transfer_submit(xfer); + if (sc->sc_flags & UKBD_FLAG_SCROLLLOCK) { + if (sc->sc_leds & SLKED) { + hid_put_data_unsigned(sc->sc_buffer + 1, UKBD_BUFFER_SIZE - 1, + &sc->sc_loc_scrolllock, 1); + } + id = sc->sc_id_scrolllock; + any = 1; + } + + if (sc->sc_flags & UKBD_FLAG_CAPSLOCK) { + if (sc->sc_leds & CLKED) { + hid_put_data_unsigned(sc->sc_buffer + 1, UKBD_BUFFER_SIZE - 1, + &sc->sc_loc_capslock, 1); + } + id = sc->sc_id_capslock; + any = 1; + } + + /* if no leds, nothing to do */ + if (!any) + break; + + /* range check output report length */ + len = sc->sc_led_size; + if (len > (UKBD_BUFFER_SIZE - 1)) + len = (UKBD_BUFFER_SIZE - 1); + + /* check if we need to prefix an ID byte */ + sc->sc_buffer[0] = id; + + pc = usbd_xfer_get_frame(xfer, 1); + if (id != 0) { + len++; + usbd_copy_in(pc, 0, sc->sc_buffer, len); + } else { + usbd_copy_in(pc, 0, sc->sc_buffer + 1, len); } + req.wLength[0] = len; + usbd_xfer_set_frame_len(xfer, 1, len); + + DPRINTF("len=%d, id=%d\n", len, id); + + /* setup control request last */ + pc = usbd_xfer_get_frame(xfer, 0); + usbd_copy_in(pc, 0, &req, sizeof(req)); + usbd_xfer_set_frame_len(xfer, 0, sizeof(req)); + + /* start data transfer */ + usbd_xfer_set_frames(xfer, 2); + usbd_transfer_submit(xfer); break; default: /* Error */ @@ -739,7 +920,7 @@ static const struct usb_config ukbd_conf .type = UE_CONTROL, .endpoint = 0x00, /* Control pipe */ .direction = UE_DIR_ANY, - .bufsize = sizeof(struct usb_device_request) + 8, + .bufsize = sizeof(struct usb_device_request) + UKBD_BUFFER_SIZE, .callback = &ukbd_set_leds_callback, .timeout = 1000, /* 1 second */ }, @@ -808,6 +989,140 @@ ukbd_probe(device_t dev) return (error); } +static void +ukbd_parse_hid(struct ukbd_softc *sc, const uint8_t *ptr, uint32_t len) +{ + uint32_t flags; + + /* reset detected bits */ + sc->sc_flags &= ~UKBD_FLAG_HID_MASK; + + /* check if there is an ID byte */ + sc->sc_kbd_size = hid_report_size(ptr, len, + hid_input, &sc->sc_kbd_id); + + /* investigate if this is an Apple Keyboard */ + if (hid_locate(ptr, len, + HID_USAGE2(HUP_CONSUMER, HUG_APPLE_EJECT), + hid_input, 0, &sc->sc_loc_apple_eject, &flags, + &sc->sc_id_apple_eject)) { + if (flags & HIO_VARIABLE) + sc->sc_flags |= UKBD_FLAG_APPLE_EJECT | + UKBD_FLAG_APPLE_SWAP; + DPRINTFN(1, "Found Apple eject-key\n"); + } + if (hid_locate(ptr, len, + HID_USAGE2(0xFFFF, 0x0003), + hid_input, 0, &sc->sc_loc_apple_fn, &flags, + &sc->sc_id_apple_fn)) { + if (flags & HIO_VARIABLE) + sc->sc_flags |= UKBD_FLAG_APPLE_FN; + DPRINTFN(1, "Found Apple FN-key\n"); + } + /* figure out some keys */ + if (hid_locate(ptr, len, + HID_USAGE2(HUP_KEYBOARD, 0xE0), + hid_input, 0, &sc->sc_loc_ctrl_l, &flags, + &sc->sc_id_ctrl_l)) { + if (flags & HIO_VARIABLE) + sc->sc_flags |= UKBD_FLAG_CTRL_L; + DPRINTFN(1, "Found left control\n"); + } + if (hid_locate(ptr, len, + HID_USAGE2(HUP_KEYBOARD, 0xE4), + hid_input, 0, &sc->sc_loc_ctrl_r, &flags, + &sc->sc_id_ctrl_r)) { + if (flags & HIO_VARIABLE) + sc->sc_flags |= UKBD_FLAG_CTRL_R; + DPRINTFN(1, "Found right control\n"); + } + if (hid_locate(ptr, len, + HID_USAGE2(HUP_KEYBOARD, 0xE1), + hid_input, 0, &sc->sc_loc_shift_l, &flags, + &sc->sc_id_shift_l)) { + if (flags & HIO_VARIABLE) + sc->sc_flags |= UKBD_FLAG_SHIFT_L; + DPRINTFN(1, "Found left shift\n"); + } + if (hid_locate(ptr, len, + HID_USAGE2(HUP_KEYBOARD, 0xE5), + hid_input, 0, &sc->sc_loc_shift_r, &flags, + &sc->sc_id_shift_r)) { + if (flags & HIO_VARIABLE) + sc->sc_flags |= UKBD_FLAG_SHIFT_R; + DPRINTFN(1, "Found right shift\n"); + } + if (hid_locate(ptr, len, + HID_USAGE2(HUP_KEYBOARD, 0xE2), + hid_input, 0, &sc->sc_loc_alt_l, &flags, + &sc->sc_id_alt_l)) { + if (flags & HIO_VARIABLE) + sc->sc_flags |= UKBD_FLAG_ALT_L; + DPRINTFN(1, "Found left alt\n"); + } + if (hid_locate(ptr, len, + HID_USAGE2(HUP_KEYBOARD, 0xE6), + hid_input, 0, &sc->sc_loc_alt_r, &flags, + &sc->sc_id_alt_r)) { + if (flags & HIO_VARIABLE) + sc->sc_flags |= UKBD_FLAG_ALT_R; + DPRINTFN(1, "Found right alt\n"); + } + if (hid_locate(ptr, len, + HID_USAGE2(HUP_KEYBOARD, 0xE3), + hid_input, 0, &sc->sc_loc_win_l, &flags, + &sc->sc_id_win_l)) { + if (flags & HIO_VARIABLE) + sc->sc_flags |= UKBD_FLAG_WIN_L; + DPRINTFN(1, "Found left GUI\n"); + } + if (hid_locate(ptr, len, + HID_USAGE2(HUP_KEYBOARD, 0xE7), + hid_input, 0, &sc->sc_loc_win_r, &flags, + &sc->sc_id_win_r)) { + if (flags & HIO_VARIABLE) + sc->sc_flags |= UKBD_FLAG_WIN_R; + DPRINTFN(1, "Found right GUI\n"); + } + /* figure out event buffer */ + if (hid_locate(ptr, len, + HID_USAGE2(HUP_KEYBOARD, 0x00), + hid_input, 0, &sc->sc_loc_events, &flags, + &sc->sc_id_events)) { + sc->sc_flags |= UKBD_FLAG_EVENTS; + DPRINTFN(1, "Found keyboard events\n"); + } + + /* figure out leds on keyboard */ + sc->sc_led_size = hid_report_size(ptr, len, + hid_output, NULL); + + if (hid_locate(ptr, len, + HID_USAGE2(HUP_LEDS, 0x01), + hid_output, 0, &sc->sc_loc_numlock, &flags, + &sc->sc_id_numlock)) { + if (flags & HIO_VARIABLE) + sc->sc_flags |= UKBD_FLAG_NUMLOCK; + DPRINTFN(1, "Found keyboard numlock\n"); + } + if (hid_locate(ptr, len, + HID_USAGE2(HUP_LEDS, 0x02), + hid_output, 0, &sc->sc_loc_capslock, &flags, + &sc->sc_id_capslock)) { + if (flags & HIO_VARIABLE) + sc->sc_flags |= UKBD_FLAG_CAPSLOCK; + DPRINTFN(1, "Found keyboard capslock\n"); + } + if (hid_locate(ptr, len, + HID_USAGE2(HUP_LEDS, 0x03), + hid_output, 0, &sc->sc_loc_scrolllock, &flags, + &sc->sc_id_scrolllock)) { + if (flags & HIO_VARIABLE) + sc->sc_flags |= UKBD_FLAG_SCROLLLOCK; + DPRINTFN(1, "Found keyboard scrolllock\n"); + } +} + static int ukbd_attach(device_t dev) { @@ -817,7 +1132,6 @@ ukbd_attach(device_t dev) keyboard_t *kbd = &sc->sc_kbd; void *hid_ptr = NULL; usb_error_t err; - uint32_t flags; uint16_t n; uint16_t hid_len; @@ -864,64 +1178,38 @@ ukbd_attach(device_t dev) */ KBD_PROBE_DONE(kbd); - /* - * Set boot protocol if we need the quirk. - */ - if (usb_test_quirk(uaa, UQ_KBD_BOOTPROTO)) { - err = usbd_req_set_protocol(sc->sc_udev, NULL, - sc->sc_iface_index, 0); - if (err != USB_ERR_NORMAL_COMPLETION) { - DPRINTF("set protocol error=%s\n", usbd_errstr(err)); - goto detach; - } - } - - /* figure out if there is an ID byte in the data */ + /* get HID descriptor */ err = usbd_req_get_hid_desc(uaa->device, NULL, &hid_ptr, &hid_len, M_TEMP, uaa->info.bIfaceIndex); - if (err == 0) { - uint8_t apple_keys = 0; - uint8_t temp_id; - /* investigate if this is an Apple Keyboard */ - if (hid_locate(hid_ptr, hid_len, - HID_USAGE2(HUP_CONSUMER, HUG_APPLE_EJECT), - hid_input, 0, &sc->sc_loc_apple_eject, &flags, - &temp_id)) { - if (flags & HIO_VARIABLE) - sc->sc_flags |= UKBD_FLAG_APPLE_EJECT | - UKBD_FLAG_APPLE_SWAP; - DPRINTFN(1, "Found Apple eject-key\n"); - apple_keys = 1; - sc->sc_kbd_id = temp_id; - } - if (hid_locate(hid_ptr, hid_len, - HID_USAGE2(0xFFFF, 0x0003), - hid_input, 0, &sc->sc_loc_apple_fn, &flags, - &temp_id)) { - if (flags & HIO_VARIABLE) - sc->sc_flags |= UKBD_FLAG_APPLE_FN; - DPRINTFN(1, "Found Apple FN-key\n"); - apple_keys = 1; - sc->sc_kbd_id = temp_id; - } - if (apple_keys == 0) { - /* - * Assume the first HID ID contains the - * keyboard data - */ - hid_report_size(hid_ptr, hid_len, - hid_input, &sc->sc_kbd_id); - } + if (err == 0) { + DPRINTF("Parsing HID descriptor of %d bytes\n", + (int)hid_len); - /* investigate if we need an ID-byte for the leds */ - hid_report_size(hid_ptr, hid_len, hid_output, &sc->sc_led_id); + ukbd_parse_hid(sc, hid_ptr, hid_len); free(hid_ptr, M_TEMP); } + /* check if we should use the boot protocol */ + if (usb_test_quirk(uaa, UQ_KBD_BOOTPROTO) || + (err != 0) || (!(sc->sc_flags & UKBD_FLAG_EVENTS))) { + + DPRINTF("Forcing boot protocol\n"); + + err = usbd_req_set_protocol(sc->sc_udev, NULL, + sc->sc_iface_index, 0); + + if (err != 0) { + DPRINTF("Set protocol error=%s (ignored)\n", + usbd_errstr(err)); + } + + ukbd_parse_hid(sc, ukbd_boot_desc, sizeof(ukbd_boot_desc)); + } + /* ignore if SETIDLE fails, hence it is not crucial */ - err = usbd_req_set_idle(sc->sc_udev, NULL, sc->sc_iface_index, 0, 0); + usbd_req_set_idle(sc->sc_udev, NULL, sc->sc_iface_index, 0, 0); mtx_lock(&Giant); @@ -1468,10 +1756,6 @@ errkey: static int ukbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) { - /* translate LED_XXX bits into the device specific bits */ - static const uint8_t ledmap[8] = { - 0, 2, 1, 3, 4, 6, 5, 7, - }; struct ukbd_softc *sc = kbd->kb_data; int i; @@ -1547,10 +1831,11 @@ ukbd_ioctl(keyboard_t *kbd, u_long cmd, #endif case KDSETLED: /* set keyboard LED */ /* NOTE: lock key state in "sc_state" won't be changed */ - if (*(int *)arg & ~LOCK_MASK) { + if (*(int *)arg & ~LOCK_MASK) return (EINVAL); - } + i = *(int *)arg; + /* replace CAPS LED with ALTGR LED for ALTGR keyboards */ if (sc->sc_mode == K_XLATE && kbd->kb_keymap->n_keys > ALTGR_OFFSET) { @@ -1559,9 +1844,9 @@ ukbd_ioctl(keyboard_t *kbd, u_long cmd, else i &= ~CLKED; } - if (KBD_HAS_DEVICE(kbd)) { - ukbd_set_leds(sc, ledmap[i & LED_MASK]); - } + if (KBD_HAS_DEVICE(kbd)) + ukbd_set_leds(sc, i); + KBD_LED_VAL(kbd) = *(int *)arg; break; case KDGKBSTATE: /* get lock key state */ Modified: head/sys/dev/usb/usb_hid.c ============================================================================== --- head/sys/dev/usb/usb_hid.c Mon Jul 4 07:03:44 2011 (r223754) +++ head/sys/dev/usb/usb_hid.c Mon Jul 4 07:37:28 2011 (r223755) @@ -702,6 +702,43 @@ hid_get_data_unsigned(const uint8_t *buf } /*------------------------------------------------------------------------* + * hid_put_data + *------------------------------------------------------------------------*/ +void +hid_put_data_unsigned(uint8_t *buf, usb_size_t len, + struct hid_location *loc, unsigned int value) +{ + uint32_t hpos = loc->pos; + uint32_t hsize = loc->size; + uint64_t data; + uint64_t mask; + uint32_t rpos; + uint8_t n; + + DPRINTFN(11, "hid_put_data: loc %d/%d = %u\n", hpos, hsize, value); + + /* Range check and limit */ + if (hsize == 0) + return; + if (hsize > 32) + hsize = 32; + + /* Put data in a safe way */ + rpos = (hpos / 8); + n = (hsize + 7) / 8; + data = ((uint64_t)value) << (hpos % 8); + mask = ((1ULL << hsize) - 1ULL) << (hpos % 8); + rpos += n; + while (n--) { + rpos--; + if (rpos < len) { + buf[rpos] &= ~(mask >> (8 * n)); + buf[rpos] |= (data >> (8 * n)); + } + } +} + +/*------------------------------------------------------------------------* * hid_is_collection *------------------------------------------------------------------------*/ int Modified: head/sys/dev/usb/usbhid.h ============================================================================== --- head/sys/dev/usb/usbhid.h Mon Jul 4 07:03:44 2011 (r223754) +++ head/sys/dev/usb/usbhid.h Mon Jul 4 07:37:28 2011 (r223755) @@ -233,6 +233,8 @@ int32_t hid_get_data(const uint8_t *buf, struct hid_location *loc); uint32_t hid_get_data_unsigned(const uint8_t *buf, usb_size_t len, struct hid_location *loc); +void hid_put_data_unsigned(uint8_t *buf, usb_size_t len, + struct hid_location *loc, unsigned int value); int hid_is_collection(const void *desc, usb_size_t size, uint32_t usage); struct usb_hid_descriptor *hid_get_descriptor_from_usb( struct usb_config_descriptor *cd, From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 11:24:38 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D1324106564A; Mon, 4 Jul 2011 11:24:38 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from mx0.hoeg.nl (mx0.hoeg.nl [IPv6:2a01:4f8:101:5343::aa]) by mx1.freebsd.org (Postfix) with ESMTP id 6E8858FC15; Mon, 4 Jul 2011 11:24:38 +0000 (UTC) Received: by mx0.hoeg.nl (Postfix, from userid 1000) id A85132A2919F; Mon, 4 Jul 2011 13:24:37 +0200 (CEST) Date: Mon, 4 Jul 2011 13:24:37 +0200 From: Ed Schouten To: Ulrich Spoerlein Message-ID: <20110704112437.GT71453@hoeg.nl> References: <201107012045.p61Kju11005984@svn.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="PVZB3C997XEKXh6G" Content-Disposition: inline In-Reply-To: <201107012045.p61Kju11005984@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r223715 - head/contrib/gcc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 11:24:38 -0000 --PVZB3C997XEKXh6G Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Uli, * Ulrich Spoerlein , 20110701 22:45: > - Port -Wtrampolines support from gcc3. Some testing here seems to suggest it's quite hard to write code that triggers this warning, while still passing WARNS >=3D 3. But still, I think it would be good to add this flag to bsd.sys.mk. I've run a `make universe' and it can be added to WARNS >=3D 2 without breaking the build. Maybe we should add it after we have MFCd this commit back to 8? --=20 Ed Schouten WWW: http://80386.nl/ --PVZB3C997XEKXh6G Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (FreeBSD) iQIcBAEBAgAGBQJOEaL1AAoJEG5e2P40kaK7I/QP/jgkE/IN8DAIm+xQeTpQXOm+ 0qZImwwQ2KOkyoomACK+aUwUm0oFjBXvZTjuA9p9m7XrMPMH7ONJ+N6IwoGhi79/ SHlToa0MAPkAg8lqh4JIwn8z7mME9KP+RbPtlv6HTp1W3X1455+zASd26Hm3ufGW DzQs3nXd4ZZLcodsAvHroAQqywnJid+FNv8ORSoYx+QOTgxeU0ZHpJLjPoxV3uIb D6yYLW40YacQy9PKqnah3zyQOOYU9/O/a46EBZ0BPhD0P93a95dZSp0sZRx/A0E/ jAmd4SP/6QNSh1R/ZCyGilzNCCvy6WUlLKfuwuqLyXLbLhGnXbjyEJ96Bh19t7VM rntdKu6F8wDhe7SGMoI8BmdrHn4eWn5smKJK/8EXFuWFuJIiljuhCiBsCPNR5Xmx mcWHf/uzdLzXl+JsZaMCdVifxTqcj73+EuFC3OJ9ddU3E0GlpieZCkDn2ikXLguZ lIYA+DsH5PebFGBrhE5jv5EagDyCmkET5EWYOT6JvxhBNuPdvh8/DgvwizEat2+X luTwz1kBxm4pA2hovrUMvrd9WRKCyMYJ5ix1spZXQTMZTMdYSXJFfshLvdvf8UmH J7isv8I89IqHpbArvkSix4us8PddJQBsYrdkueeEQthbpGimpR7LsB2/X8+I4NTW lPsbCjIBH0Lu+MJopEz8 =LvmA -----END PGP SIGNATURE----- --PVZB3C997XEKXh6G-- From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 11:43:18 2011 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 60D6C106564A; Mon, 4 Jul 2011 11:43:18 +0000 (UTC) (envelope-from uqs@FreeBSD.org) Received: from acme.spoerlein.net (acme.spoerlein.net [IPv6:2a01:4f8:131:23c2::1]) by mx1.freebsd.org (Postfix) with ESMTP id ECDCB8FC0C; Mon, 4 Jul 2011 11:43:17 +0000 (UTC) Received: from localhost (acme.spoerlein.net [IPv6:2a01:4f8:131:23c2::1]) by acme.spoerlein.net (8.14.4/8.14.4) with ESMTP id p64BhDrW062758 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 4 Jul 2011 13:43:13 +0200 (CEST) (envelope-from uqs@FreeBSD.org) Date: Mon, 4 Jul 2011 13:43:12 +0200 From: Ulrich Spoerlein To: Ed Schouten Message-ID: <20110704114312.GC8485@acme.spoerlein.net> Mail-Followup-To: Ulrich Spoerlein , Ed Schouten , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org References: <201107012045.p61Kju11005984@svn.freebsd.org> <20110704112437.GT71453@hoeg.nl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="sdtB3X0nJg68CQEu" Content-Disposition: inline In-Reply-To: <20110704112437.GT71453@hoeg.nl> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r223715 - head/contrib/gcc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 11:43:18 -0000 --sdtB3X0nJg68CQEu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, 04.07.2011 at 13:24:37 +0200, Ed Schouten wrote: > Hi Uli, >=20 > * Ulrich Spoerlein , 20110701 22:45: > > - Port -Wtrampolines support from gcc3. >=20 > Some testing here seems to suggest it's quite hard to write code that > triggers this warning, while still passing WARNS >=3D 3. But still, I > think it would be good to add this flag to bsd.sys.mk. >=20 > I've run a `make universe' and it can be added to WARNS >=3D 2 without > breaking the build. Maybe we should add it after we have MFCd this > commit back to 8? There are a couple of ports that are using our make and some of them might even set WARNS, so I fear this would also need an exp-run to see if there's any fallout there. Otherwise, I think it's a good idea. Which WARNS<2 parts of our tree would trigger that warning, btw? Uli % find . -name Makefile\* -exec grep WARNS {} + =2E/benchmarks/raidtest/files/Makefile:WARNS?=3D 6 =2E/databases/sybtcl/files/Makefile.bsd:WARNS?=3D 2 =2E/graphics/gdtclft/files/Makefile.bsd:WARNS =3D 2 =2E/graphics/libfpx/files/Makefile.bsd:WARNS=3D 3 =2E/graphics/libfpx/Makefile:# (based on WARNS=3D in particular) instead of= being influenced by =2E/shells/v7sh/files/Makefile:WARNS?=3D 6 =2E/sysutils/ffs2recov/Makefile: WARNS=3D0 =2E/sysutils/k8temp/Makefile: @${REINPLACE_CMD} -e 's|WARNS=3D.*[6-9]|W= ARNS=3D5|g' ${WRKSRC}/Makefile =2E/sysutils/k8temp/Makefile:WARNS=3D 6 =2E/sysutils/lookupd/Makefile:MAKE_ENV=3D WARNS=3D0 =2E/textproc/tclExpat/files/Makefile:WARNS=3D 3 =2E/www/mod_dtcl/files/Makefile.bsd:WARNS=3D 2 PS: That does not include ports, using our make and setting WARNS in the Makefile that they ship with ... --sdtB3X0nJg68CQEu Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iQEcBAEBAgAGBQJOEadQAAoJEKOmmGRKr4LOTD8IAK26r/0qtGjYARnlO1fF8L5p iFjIOngvQ/srYMjIX1AjGTLrvEkZ5ERTDVFDGaELpSjfCljDRuuGdkdM0sVg7IU7 qVTGV4PN0fdbPUhOelk/CMVdjy0D0cSJAtEzq66SnKiQL0HJiOGMbpnrvPmo9Kuy WW97XOgYbMRVpKyVNd5yc3NBf6sjm0+MdRHPZZc0LMmstxihP4AgKmGBbe3lg4I9 S5MFBZVIZRpwPhLBnTShRkdFso6k0nveGZnbSqJv7vKYaBZC/Ro02yIez+IDS0Oh XDJYp3fefreKCpcQc0KCs9zP+Sy8VMgJC1L4XIx0xYMFpaHcdCX12TfTaw59JC8= =GFWY -----END PGP SIGNATURE----- --sdtB3X0nJg68CQEu-- From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 11:49:16 2011 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ABF9F106564A; Mon, 4 Jul 2011 11:49:16 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from mx0.hoeg.nl (mx0.hoeg.nl [IPv6:2a01:4f8:101:5343::aa]) by mx1.freebsd.org (Postfix) with ESMTP id 6FE508FC16; Mon, 4 Jul 2011 11:49:16 +0000 (UTC) Received: by mx0.hoeg.nl (Postfix, from userid 1000) id CCC552A2919F; Mon, 4 Jul 2011 13:49:15 +0200 (CEST) Date: Mon, 4 Jul 2011 13:49:15 +0200 From: Ed Schouten To: Ulrich Spoerlein , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org Message-ID: <20110704114915.GV71453@hoeg.nl> References: <201107012045.p61Kju11005984@svn.freebsd.org> <20110704112437.GT71453@hoeg.nl> <20110704114312.GC8485@acme.spoerlein.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="rHeCoQbvuHTnkkIZ" Content-Disposition: inline In-Reply-To: <20110704114312.GC8485@acme.spoerlein.net> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Subject: Re: svn commit: r223715 - head/contrib/gcc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 11:49:16 -0000 --rHeCoQbvuHTnkkIZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Ulrich, * Ulrich Spoerlein , 20110704 13:43: > Which WARNS<2 parts of our tree would trigger that warning, btw? I have no idea. I just picked WARNS>=3D2, because levels lower than 2 are often used for horrible code anyway. I could do another run at WARNS=3D1 if you like. --=20 Ed Schouten WWW: http://80386.nl/ --rHeCoQbvuHTnkkIZ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (FreeBSD) iQIcBAEBAgAGBQJOEai7AAoJEG5e2P40kaK7OsIP/21s1siJnAAvUxU9ZH4eKT0k cw68051GhtqRrUP7Mv/REXVyDqEoXxXfkuWBz49J/Ppu3KI3tYe5MqeJgUqVHlvR hA1WpMNYHPw7j2l3iW6+jKCNzVfaFxuv+jbhJAMMnU6IIvKUocK8u2a6vwRt5umL rKGvdNpeazuS7mjZD7iuAclDlppsrgKzS2hNckrUGbEyQZwX6pgUmHmyboAGWsmP HLbhn6l8/yBQun+8Lcbfl19v9tM9A9o7oqQejKX4zEuotLfsdEVU8iNZFQiYlMdZ WSyxbFIR5QSk0GWdYcE/aVxIbg5yOj4nLnjEz43IiwjV849DWQY3DJJ2zE3Ngkon baLn7AYM0quCRwI51wQgcZaLSCDP2EGdjAzgVZFFERFbedFitYTiMHmSeRmaoagP HWxGkR4wPhKJyZsxRncUuP1rrKgfXzhs5oseDkDJqR2GDv3NjQt5wEZ97SfeRDLb 0Jpeh8yYElsA5xWqrBsi5O4cSgSBjT48dLKfzx+VISZpQxhOG4KiKFPOIfpE4I+E fYYMO84gBe7ivzVGEsXrsDUUjnbm2CkXsUFLXoLHdeBITvLMmXdZgZYeuUa6MHx4 /bROiFBCG1mlAdCqqqW9qRc12KP1Mi63kRP0TJiAGJDXb8AW1MkdcJEVw5kaM0EY 6vhMwrWGKwuZVPsbl/g5 =7wDY -----END PGP SIGNATURE----- --rHeCoQbvuHTnkkIZ-- From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 12:04:52 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AD652106566B; Mon, 4 Jul 2011 12:04:52 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9911F8FC08; Mon, 4 Jul 2011 12:04:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p64C4qig018170; Mon, 4 Jul 2011 12:04:52 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p64C4q8p018157; Mon, 4 Jul 2011 12:04:52 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201107041204.p64C4q8p018157@svn.freebsd.org> From: Attilio Rao Date: Mon, 4 Jul 2011 12:04:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223758 - in head: contrib/top lib/libkvm share/mk sys/amd64/acpica sys/amd64/amd64 sys/cddl/dev/dtrace/amd64 sys/cddl/dev/dtrace/i386 sys/dev/xen/control sys/i386/i386 sys/i386/xen sys... X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 12:04:52 -0000 Author: attilio Date: Mon Jul 4 12:04:52 2011 New Revision: 223758 URL: http://svn.freebsd.org/changeset/base/223758 Log: With retirement of cpumask_t and usage of cpuset_t for representing a mask of CPUs, pc_other_cpus and pc_cpumask become highly inefficient. Remove them and replace their usage with custom pc_cpuid magic (as, atm, pc_cpumask can be easilly represented by (1 << pc_cpuid) and pc_other_cpus by (all_cpus & ~(1 << pc_cpuid))). This change is not targeted for MFC because of struct pcpu members removal and dependency by cpumask_t retirement. MD review by: marcel, marius, alc Tested by: pluknet MD testing by: marcel, marius, gonzo, andreast Modified: head/lib/libkvm/kvm_pcpu.c head/sys/amd64/acpica/acpi_wakeup.c head/sys/amd64/amd64/mp_machdep.c head/sys/amd64/amd64/pmap.c head/sys/amd64/amd64/vm_machdep.c head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c head/sys/cddl/dev/dtrace/i386/dtrace_subr.c head/sys/dev/xen/control/control.c head/sys/i386/i386/mp_machdep.c head/sys/i386/i386/pmap.c head/sys/i386/i386/vm_machdep.c head/sys/i386/xen/mp_machdep.c head/sys/i386/xen/pmap.c head/sys/ia64/ia64/mp_machdep.c head/sys/kern/kern_rmlock.c head/sys/kern/sched_4bsd.c head/sys/kern/subr_kdb.c head/sys/kern/subr_pcpu.c head/sys/kern/subr_smp.c head/sys/mips/mips/mp_machdep.c head/sys/mips/mips/pmap.c head/sys/powerpc/aim/mmu_oea.c head/sys/powerpc/aim/mmu_oea64.c head/sys/powerpc/booke/pmap.c head/sys/powerpc/powerpc/mp_machdep.c head/sys/sparc64/sparc64/mp_machdep.c head/sys/sys/pcpu.h Directory Properties: head/ (props changed) head/cddl/contrib/opensolaris/ (props changed) head/contrib/bind9/ (props changed) head/contrib/binutils/ (props changed) head/contrib/bzip2/ (props changed) head/contrib/compiler-rt/ (props changed) head/contrib/dialog/ (props changed) head/contrib/ee/ (props changed) head/contrib/expat/ (props changed) head/contrib/file/ (props changed) head/contrib/gcc/ (props changed) head/contrib/gdb/ (props changed) head/contrib/gdtoa/ (props changed) head/contrib/gnu-sort/ (props changed) head/contrib/groff/ (props changed) head/contrib/less/ (props changed) head/contrib/libpcap/ (props changed) head/contrib/libstdc++/ (props changed) head/contrib/llvm/ (props changed) head/contrib/llvm/tools/clang/ (props changed) head/contrib/ncurses/ (props changed) head/contrib/netcat/ (props changed) head/contrib/ntp/ (props changed) head/contrib/one-true-awk/ (props changed) head/contrib/openbsm/ (props changed) head/contrib/openpam/ (props changed) head/contrib/pf/ (props changed) head/contrib/sendmail/ (props changed) head/contrib/tcpdump/ (props changed) head/contrib/tcsh/ (props changed) head/contrib/tnftp/ (props changed) head/contrib/top/ (props changed) head/contrib/top/install-sh (props changed) head/contrib/tzcode/stdtime/ (props changed) head/contrib/tzcode/zic/ (props changed) head/contrib/tzdata/ (props changed) head/contrib/wpa/ (props changed) head/contrib/xz/ (props changed) head/crypto/openssh/ (props changed) head/crypto/openssl/ (props changed) head/gnu/lib/ (props changed) head/gnu/usr.bin/binutils/ (props changed) head/gnu/usr.bin/cc/cc_tools/ (props changed) head/gnu/usr.bin/gdb/ (props changed) head/lib/libc/ (props changed) head/lib/libc/stdtime/ (props changed) head/lib/libutil/ (props changed) head/lib/libz/ (props changed) head/sbin/ (props changed) head/sbin/ipfw/ (props changed) head/share/mk/bsd.arch.inc.mk (props changed) head/share/zoneinfo/ (props changed) head/sys/ (props changed) head/sys/amd64/include/xen/ (props changed) head/sys/boot/ (props changed) head/sys/boot/i386/efi/ (props changed) head/sys/boot/ia64/efi/ (props changed) head/sys/boot/ia64/ski/ (props changed) head/sys/boot/powerpc/boot1.chrp/ (props changed) head/sys/boot/powerpc/ofw/ (props changed) head/sys/cddl/contrib/opensolaris/ (props changed) head/sys/conf/ (props changed) head/sys/contrib/dev/acpica/ (props changed) head/sys/contrib/octeon-sdk/ (props changed) head/sys/contrib/pf/ (props changed) head/sys/contrib/x86emu/ (props changed) head/usr.bin/calendar/ (props changed) head/usr.bin/csup/ (props changed) head/usr.bin/procstat/ (props changed) head/usr.sbin/ndiscvt/ (props changed) head/usr.sbin/zic/ (props changed) Modified: head/lib/libkvm/kvm_pcpu.c ============================================================================== --- head/lib/libkvm/kvm_pcpu.c Mon Jul 4 11:13:00 2011 (r223757) +++ head/lib/libkvm/kvm_pcpu.c Mon Jul 4 12:04:52 2011 (r223758) @@ -39,13 +39,11 @@ __FBSDID("$FreeBSD$"); #include -#include #include #include #include #include #include -#include #include "kvm_private.h" @@ -120,9 +118,6 @@ _kvm_pcpu_clear(void) void * kvm_getpcpu(kvm_t *kd, int cpu) { - long kcpusetsize; - ssize_t nbytes; - uintptr_t readptr; char *buf; if (kd == NULL) { @@ -130,10 +125,6 @@ kvm_getpcpu(kvm_t *kd, int cpu) return (NULL); } - kcpusetsize = sysconf(_SC_CPUSET_SIZE); - if (kcpusetsize == -1 || (u_long)kcpusetsize > sizeof(cpuset_t)) - return ((void *)-1); - if (maxcpu == 0) if (_kvm_pcpu_init(kd) < 0) return ((void *)-1); @@ -146,26 +137,8 @@ kvm_getpcpu(kvm_t *kd, int cpu) _kvm_err(kd, kd->program, "out of memory"); return ((void *)-1); } - nbytes = sizeof(struct pcpu) - 2 * kcpusetsize; - readptr = (uintptr_t)pcpu_data[cpu]; - if (kvm_read(kd, readptr, buf, nbytes) != nbytes) { - _kvm_err(kd, kd->program, "unable to read per-CPU data"); - free(buf); - return ((void *)-1); - } - - /* Fetch the valid cpuset_t objects. */ - CPU_ZERO((cpuset_t *)(buf + nbytes)); - CPU_ZERO((cpuset_t *)(buf + nbytes + sizeof(cpuset_t))); - readptr += nbytes; - if (kvm_read(kd, readptr, buf + nbytes, kcpusetsize) != kcpusetsize) { - _kvm_err(kd, kd->program, "unable to read per-CPU data"); - free(buf); - return ((void *)-1); - } - readptr += kcpusetsize; - if (kvm_read(kd, readptr, buf + nbytes + sizeof(cpuset_t), - kcpusetsize) != kcpusetsize) { + if (kvm_read(kd, (uintptr_t)pcpu_data[cpu], buf, + sizeof(struct pcpu)) != sizeof(struct pcpu)) { _kvm_err(kd, kd->program, "unable to read per-CPU data"); free(buf); return ((void *)-1); Modified: head/sys/amd64/acpica/acpi_wakeup.c ============================================================================== --- head/sys/amd64/acpica/acpi_wakeup.c Mon Jul 4 11:13:00 2011 (r223757) +++ head/sys/amd64/acpica/acpi_wakeup.c Mon Jul 4 12:04:52 2011 (r223758) @@ -226,7 +226,8 @@ acpi_sleep_machdep(struct acpi_softc *sc return (ret); #ifdef SMP - wakeup_cpus = PCPU_GET(other_cpus); + wakeup_cpus = all_cpus; + CPU_CLR(PCPU_GET(cpuid), &wakeup_cpus); #endif AcpiSetFirmwareWakingVector(WAKECODE_PADDR(sc)); Modified: head/sys/amd64/amd64/mp_machdep.c ============================================================================== --- head/sys/amd64/amd64/mp_machdep.c Mon Jul 4 11:13:00 2011 (r223757) +++ head/sys/amd64/amd64/mp_machdep.c Mon Jul 4 12:04:52 2011 (r223758) @@ -604,10 +604,10 @@ cpu_mp_announce(void) void init_secondary(void) { - cpuset_t tcpuset, tallcpus; struct pcpu *pc; struct nmi_pcpu *np; u_int64_t msr, cr0; + u_int cpuid; int cpu, gsel_tss, x; struct region_descriptor ap_gdt; @@ -711,8 +711,9 @@ init_secondary(void) fpuinit(); /* A quick check from sanity claus */ + cpuid = PCPU_GET(cpuid); if (PCPU_GET(apic_id) != lapic_id()) { - printf("SMP: cpuid = %d\n", PCPU_GET(cpuid)); + printf("SMP: cpuid = %d\n", cpuid); printf("SMP: actual apic_id = %d\n", lapic_id()); printf("SMP: correct apic_id = %d\n", PCPU_GET(apic_id)); panic("cpuid mismatch! boom!!"); @@ -734,19 +735,13 @@ init_secondary(void) smp_cpus++; - CTR1(KTR_SMP, "SMP: AP CPU #%d Launched", PCPU_GET(cpuid)); - printf("SMP: AP CPU #%d Launched!\n", PCPU_GET(cpuid)); - tcpuset = PCPU_GET(cpumask); + CTR1(KTR_SMP, "SMP: AP CPU #%d Launched", cpuid); + printf("SMP: AP CPU #%d Launched!\n", cpuid); /* Determine if we are a logical CPU. */ /* XXX Calculation depends on cpu_logical being a power of 2, e.g. 2 */ if (cpu_logical > 1 && PCPU_GET(apic_id) % cpu_logical != 0) - CPU_OR(&logical_cpus_mask, &tcpuset); - - /* Build our map of 'other' CPUs. */ - tallcpus = all_cpus; - CPU_NAND(&tallcpus, &tcpuset); - PCPU_SET(other_cpus, tallcpus); + CPU_SET(cpuid, &logical_cpus_mask); if (bootverbose) lapic_dump("AP"); @@ -893,7 +888,6 @@ assign_cpu_ids(void) static int start_all_aps(void) { - cpuset_t tallcpus, tcpuset; vm_offset_t va = boot_address + KERNBASE; u_int64_t *pt4, *pt3, *pt2; u_int32_t mpbioswarmvec; @@ -961,12 +955,6 @@ start_all_aps(void) CPU_SET(cpu, &all_cpus); /* record AP in CPU map */ } - /* build our map of 'other' CPUs */ - tallcpus = all_cpus; - tcpuset = PCPU_GET(cpumask); - CPU_NAND(&tallcpus, &tcpuset); - PCPU_SET(other_cpus, tallcpus); - /* restore the warmstart vector */ *(u_int32_t *) WARMBOOT_OFF = mpbioswarmvec; @@ -1150,9 +1138,7 @@ smp_targeted_tlb_shootdown(cpuset_t mask if (othercpus < 1) return; } else { - sched_pin(); - CPU_NAND(&mask, PCPU_PTR(cpumask)); - sched_unpin(); + CPU_CLR(PCPU_GET(cpuid), &mask); if (CPU_EMPTY(&mask)) return; } @@ -1349,11 +1335,13 @@ ipi_cpu(int cpu, u_int ipi) void ipi_all_but_self(u_int ipi) { + cpuset_t other_cpus; + + other_cpus = all_cpus; + CPU_CLR(PCPU_GET(cpuid), &other_cpus); - sched_pin(); if (IPI_IS_BITMAPED(ipi)) { - ipi_selected(PCPU_GET(other_cpus), ipi); - sched_unpin(); + ipi_selected(other_cpus, ipi); return; } @@ -1363,8 +1351,7 @@ ipi_all_but_self(u_int ipi) * Set the mask of receiving CPUs for this purpose. */ if (ipi == IPI_STOP_HARD) - CPU_OR_ATOMIC(&ipi_nmi_pending, PCPU_PTR(other_cpus)); - sched_unpin(); + CPU_OR_ATOMIC(&ipi_nmi_pending, &other_cpus); CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi); lapic_ipi_vectored(ipi, APIC_IPI_DEST_OTHERS); @@ -1373,7 +1360,7 @@ ipi_all_but_self(u_int ipi) int ipi_nmi_handler() { - cpuset_t cpumask; + u_int cpuid; /* * As long as there is not a simple way to know about a NMI's @@ -1381,13 +1368,11 @@ ipi_nmi_handler() * the global pending bitword an IPI_STOP_HARD has been issued * and should be handled. */ - sched_pin(); - cpumask = PCPU_GET(cpumask); - sched_unpin(); - if (!CPU_OVERLAP(&ipi_nmi_pending, &cpumask)) + cpuid = PCPU_GET(cpuid); + if (!CPU_ISSET(cpuid, &ipi_nmi_pending)) return (1); - CPU_NAND_ATOMIC(&ipi_nmi_pending, &cpumask); + CPU_CLR_ATOMIC(cpuid, &ipi_nmi_pending); cpustop_handler(); return (0); } @@ -1399,25 +1384,21 @@ ipi_nmi_handler() void cpustop_handler(void) { - cpuset_t cpumask; u_int cpu; - sched_pin(); cpu = PCPU_GET(cpuid); - cpumask = PCPU_GET(cpumask); - sched_unpin(); savectx(&stoppcbs[cpu]); /* Indicate that we are stopped */ - CPU_OR_ATOMIC(&stopped_cpus, &cpumask); + CPU_SET_ATOMIC(cpu, &stopped_cpus); /* Wait for restart */ - while (!CPU_OVERLAP(&started_cpus, &cpumask)) + while (!CPU_ISSET(cpu, &started_cpus)) ia32_pause(); - CPU_NAND_ATOMIC(&started_cpus, &cpumask); - CPU_NAND_ATOMIC(&stopped_cpus, &cpumask); + CPU_CLR_ATOMIC(cpu, &started_cpus); + CPU_CLR_ATOMIC(cpu, &stopped_cpus); if (cpu == 0 && cpustop_restartfunc != NULL) { cpustop_restartfunc(); @@ -1432,19 +1413,17 @@ cpustop_handler(void) void cpususpend_handler(void) { - cpuset_t cpumask; register_t cr3, rf; u_int cpu; cpu = PCPU_GET(cpuid); - cpumask = PCPU_GET(cpumask); rf = intr_disable(); cr3 = rcr3(); if (savectx(susppcbs[cpu])) { wbinvd(); - CPU_OR_ATOMIC(&stopped_cpus, &cpumask); + CPU_SET_ATOMIC(cpu, &stopped_cpus); } else { pmap_init_pat(); PCPU_SET(switchtime, 0); @@ -1452,11 +1431,11 @@ cpususpend_handler(void) } /* Wait for resume */ - while (!CPU_OVERLAP(&started_cpus, &cpumask)) + while (!CPU_ISSET(cpu, &started_cpus)) ia32_pause(); - CPU_NAND_ATOMIC(&started_cpus, &cpumask); - CPU_NAND_ATOMIC(&stopped_cpus, &cpumask); + CPU_CLR_ATOMIC(cpu, &started_cpus); + CPU_CLR_ATOMIC(cpu, &stopped_cpus); /* Restore CR3 and enable interrupts */ load_cr3(cr3); Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Mon Jul 4 11:13:00 2011 (r223757) +++ head/sys/amd64/amd64/pmap.c Mon Jul 4 12:04:52 2011 (r223758) @@ -925,16 +925,18 @@ pmap_update_pde_invalidate(vm_offset_t v void pmap_invalidate_page(pmap_t pmap, vm_offset_t va) { - cpuset_t cpumask, other_cpus; + cpuset_t other_cpus; + u_int cpuid; sched_pin(); if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) { invlpg(va); smp_invlpg(va); } else { - cpumask = PCPU_GET(cpumask); - other_cpus = PCPU_GET(other_cpus); - if (CPU_OVERLAP(&pmap->pm_active, &cpumask)) + cpuid = PCPU_GET(cpuid); + other_cpus = all_cpus; + CPU_CLR(cpuid, &other_cpus); + if (CPU_ISSET(cpuid, &pmap->pm_active)) invlpg(va); CPU_AND(&other_cpus, &pmap->pm_active); if (!CPU_EMPTY(&other_cpus)) @@ -946,8 +948,9 @@ pmap_invalidate_page(pmap_t pmap, vm_off void pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) { - cpuset_t cpumask, other_cpus; + cpuset_t other_cpus; vm_offset_t addr; + u_int cpuid; sched_pin(); if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) { @@ -955,9 +958,10 @@ pmap_invalidate_range(pmap_t pmap, vm_of invlpg(addr); smp_invlpg_range(sva, eva); } else { - cpumask = PCPU_GET(cpumask); - other_cpus = PCPU_GET(other_cpus); - if (CPU_OVERLAP(&pmap->pm_active, &cpumask)) + cpuid = PCPU_GET(cpuid); + other_cpus = all_cpus; + CPU_CLR(cpuid, &other_cpus); + if (CPU_ISSET(cpuid, &pmap->pm_active)) for (addr = sva; addr < eva; addr += PAGE_SIZE) invlpg(addr); CPU_AND(&other_cpus, &pmap->pm_active); @@ -970,16 +974,18 @@ pmap_invalidate_range(pmap_t pmap, vm_of void pmap_invalidate_all(pmap_t pmap) { - cpuset_t cpumask, other_cpus; + cpuset_t other_cpus; + u_int cpuid; sched_pin(); if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) { invltlb(); smp_invltlb(); } else { - cpumask = PCPU_GET(cpumask); - other_cpus = PCPU_GET(other_cpus); - if (CPU_OVERLAP(&pmap->pm_active, &cpumask)) + cpuid = PCPU_GET(cpuid); + other_cpus = all_cpus; + CPU_CLR(cpuid, &other_cpus); + if (CPU_ISSET(cpuid, &pmap->pm_active)) invltlb(); CPU_AND(&other_cpus, &pmap->pm_active); if (!CPU_EMPTY(&other_cpus)) @@ -999,11 +1005,11 @@ pmap_invalidate_cache(void) } struct pde_action { - cpuset_t store; /* processor that updates the PDE */ cpuset_t invalidate; /* processors that invalidate their TLB */ vm_offset_t va; pd_entry_t *pde; pd_entry_t newpde; + u_int store; /* processor that updates the PDE */ }; static void @@ -1011,12 +1017,8 @@ pmap_update_pde_action(void *arg) { struct pde_action *act = arg; - sched_pin(); - if (!CPU_CMP(&act->store, PCPU_PTR(cpumask))) { - sched_unpin(); + if (act->store == PCPU_GET(cpuid)) pde_store(act->pde, act->newpde); - } else - sched_unpin(); } static void @@ -1024,12 +1026,8 @@ pmap_update_pde_teardown(void *arg) { struct pde_action *act = arg; - sched_pin(); - if (CPU_OVERLAP(&act->invalidate, PCPU_PTR(cpumask))) { - sched_unpin(); + if (CPU_ISSET(PCPU_GET(cpuid), &act->invalidate)) pmap_update_pde_invalidate(act->va, act->newpde); - } else - sched_unpin(); } /* @@ -1044,28 +1042,30 @@ static void pmap_update_pde(pmap_t pmap, vm_offset_t va, pd_entry_t *pde, pd_entry_t newpde) { struct pde_action act; - cpuset_t active, cpumask, other_cpus; + cpuset_t active, other_cpus; + u_int cpuid; sched_pin(); - cpumask = PCPU_GET(cpumask); - other_cpus = PCPU_GET(other_cpus); + cpuid = PCPU_GET(cpuid); + other_cpus = all_cpus; + CPU_CLR(cpuid, &other_cpus); if (pmap == kernel_pmap) active = all_cpus; else active = pmap->pm_active; if (CPU_OVERLAP(&active, &other_cpus)) { - act.store = cpumask; + act.store = cpuid; act.invalidate = active; act.va = va; act.pde = pde; act.newpde = newpde; - CPU_OR(&cpumask, &active); - smp_rendezvous_cpus(cpumask, + CPU_SET(cpuid, &active); + smp_rendezvous_cpus(active, smp_no_rendevous_barrier, pmap_update_pde_action, pmap_update_pde_teardown, &act); } else { pde_store(pde, newpde); - if (CPU_OVERLAP(&active, &cpumask)) + if (CPU_ISSET(cpuid, &active)) pmap_update_pde_invalidate(va, newpde); } sched_unpin(); @@ -5095,17 +5095,19 @@ void pmap_activate(struct thread *td) { pmap_t pmap, oldpmap; + u_int cpuid; u_int64_t cr3; critical_enter(); pmap = vmspace_pmap(td->td_proc->p_vmspace); oldpmap = PCPU_GET(curpmap); + cpuid = PCPU_GET(cpuid); #ifdef SMP - CPU_NAND_ATOMIC(&oldpmap->pm_active, PCPU_PTR(cpumask)); - CPU_OR_ATOMIC(&pmap->pm_active, PCPU_PTR(cpumask)); + CPU_CLR_ATOMIC(cpuid, &oldpmap->pm_active); + CPU_SET_ATOMIC(cpuid, &pmap->pm_active); #else - CPU_NAND(&oldpmap->pm_active, PCPU_PTR(cpumask)); - CPU_OR(&pmap->pm_active, PCPU_PTR(cpumask)); + CPU_CLR(cpuid, &oldpmap->pm_active); + CPU_SET(cpuid, &pmap->pm_active); #endif cr3 = DMAP_TO_PHYS((vm_offset_t)pmap->pm_pml4); td->td_pcb->pcb_cr3 = cr3; Modified: head/sys/amd64/amd64/vm_machdep.c ============================================================================== --- head/sys/amd64/amd64/vm_machdep.c Mon Jul 4 11:13:00 2011 (r223757) +++ head/sys/amd64/amd64/vm_machdep.c Mon Jul 4 12:04:52 2011 (r223758) @@ -59,7 +59,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -535,8 +534,8 @@ cpu_reset() u_int cnt; if (smp_active) { - sched_pin(); - map = PCPU_GET(other_cpus); + map = all_cpus; + CPU_CLR(PCPU_GET(cpuid), &map); CPU_NAND(&map, &stopped_cpus); if (!CPU_EMPTY(&map)) { printf("cpu_reset: Stopping other CPUs\n"); @@ -545,7 +544,6 @@ cpu_reset() if (PCPU_GET(cpuid) != 0) { cpu_reset_proxyid = PCPU_GET(cpuid); - sched_unpin(); cpustop_restartfunc = cpu_reset_proxy; cpu_reset_proxy_active = 0; printf("cpu_reset: Restarting BSP\n"); @@ -564,8 +562,7 @@ cpu_reset() while (1); /* NOTREACHED */ - } else - sched_unpin(); + } DELAY(1000000); } Modified: head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c ============================================================================== --- head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c Mon Jul 4 11:13:00 2011 (r223757) +++ head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c Mon Jul 4 12:04:52 2011 (r223758) @@ -412,8 +412,8 @@ dtrace_gethrtime_init(void *arg) continue; pc = pcpu_find(i); - map = PCPU_GET(cpumask); - CPU_OR(&map, &pc->pc_cpumask); + CPU_SETOF(PCPU_GET(cpuid), &map); + CPU_SET(pc->pc_cpuid, &map); smp_rendezvous_cpus(map, NULL, dtrace_gethrtime_init_cpu, Modified: head/sys/cddl/dev/dtrace/i386/dtrace_subr.c ============================================================================== --- head/sys/cddl/dev/dtrace/i386/dtrace_subr.c Mon Jul 4 11:13:00 2011 (r223757) +++ head/sys/cddl/dev/dtrace/i386/dtrace_subr.c Mon Jul 4 12:04:52 2011 (r223758) @@ -413,8 +413,8 @@ dtrace_gethrtime_init(void *arg) continue; pc = pcpu_find(i); - map = PCPU_GET(cpumask); - CPU_OR(&map, &pc->pc_cpumask); + CPU_SETOF(PCPU_GET(cpuid), &map); + CPU_SET(pc->pc_cpuid, &map); smp_rendezvous_cpus(map, NULL, dtrace_gethrtime_init_cpu, Modified: head/sys/dev/xen/control/control.c ============================================================================== --- head/sys/dev/xen/control/control.c Mon Jul 4 11:13:00 2011 (r223757) +++ head/sys/dev/xen/control/control.c Mon Jul 4 12:04:52 2011 (r223758) @@ -197,6 +197,7 @@ extern void xencons_resume(void); static void xctrl_suspend() { + u_int cpuid; int i, j, k, fpp; unsigned long max_pfn, start_info_mfn; @@ -210,11 +211,11 @@ xctrl_suspend() thread_lock(td); sched_bind(td, 0); thread_unlock(td); - KASSERT(PCPU_GET(cpuid) == 0, ("xen_suspend: not running on cpu 0")); + cpuid = PCPU_GET(cpuid); + KASSERT(cpuid == 0, ("xen_suspend: not running on cpu 0")); - sched_pin(); - map = PCPU_GET(other_cpus); - sched_unpin(); + map = all_cpus; + CPU_CLR(cpuid, &map); CPU_NAND(&map, &stopped_cpus); if (!CPU_EMPTY(&map)) stop_cpus(map); Modified: head/sys/i386/i386/mp_machdep.c ============================================================================== --- head/sys/i386/i386/mp_machdep.c Mon Jul 4 11:13:00 2011 (r223757) +++ head/sys/i386/i386/mp_machdep.c Mon Jul 4 12:04:52 2011 (r223758) @@ -658,12 +658,11 @@ cpu_mp_announce(void) void init_secondary(void) { - cpuset_t tcpuset, tallcpus; struct pcpu *pc; vm_offset_t addr; int gsel_tss; int x, myid; - u_int cr0; + u_int cpuid, cr0; /* bootAP is set in start_ap() to our ID. */ myid = bootAP; @@ -758,8 +757,9 @@ init_secondary(void) #endif /* A quick check from sanity claus */ + cpuid = PCPU_GET(cpuid); if (PCPU_GET(apic_id) != lapic_id()) { - printf("SMP: cpuid = %d\n", PCPU_GET(cpuid)); + printf("SMP: cpuid = %d\n", cpuid); printf("SMP: actual apic_id = %d\n", lapic_id()); printf("SMP: correct apic_id = %d\n", PCPU_GET(apic_id)); panic("cpuid mismatch! boom!!"); @@ -781,19 +781,13 @@ init_secondary(void) smp_cpus++; - CTR1(KTR_SMP, "SMP: AP CPU #%d Launched", PCPU_GET(cpuid)); - printf("SMP: AP CPU #%d Launched!\n", PCPU_GET(cpuid)); - tcpuset = PCPU_GET(cpumask); + CTR1(KTR_SMP, "SMP: AP CPU #%d Launched", cpuid); + printf("SMP: AP CPU #%d Launched!\n", cpuid); /* Determine if we are a logical CPU. */ /* XXX Calculation depends on cpu_logical being a power of 2, e.g. 2 */ if (cpu_logical > 1 && PCPU_GET(apic_id) % cpu_logical != 0) - CPU_OR(&logical_cpus_mask, &tcpuset); - - /* Build our map of 'other' CPUs. */ - tallcpus = all_cpus; - CPU_NAND(&tallcpus, &tcpuset); - PCPU_SET(other_cpus, tallcpus); + CPU_SET(cpuid, &logical_cpus_mask); if (bootverbose) lapic_dump("AP"); @@ -934,7 +928,6 @@ assign_cpu_ids(void) static int start_all_aps(void) { - cpuset_t tallcpus; #ifndef PC98 u_char mpbiosreason; #endif @@ -997,11 +990,6 @@ start_all_aps(void) CPU_SET(cpu, &all_cpus); /* record AP in CPU map */ } - /* build our map of 'other' CPUs */ - tallcpus = all_cpus; - CPU_NAND(&tallcpus, PCPU_PTR(cpumask)); - PCPU_SET(other_cpus, tallcpus); - /* restore the warmstart vector */ *(u_int32_t *) WARMBOOT_OFF = mpbioswarmvec; @@ -1253,9 +1241,7 @@ smp_targeted_tlb_shootdown(cpuset_t mask if (othercpus < 1) return; } else { - sched_pin(); - CPU_NAND(&mask, PCPU_PTR(cpumask)); - sched_unpin(); + CPU_CLR(PCPU_GET(cpuid), &mask); if (CPU_EMPTY(&mask)) return; } @@ -1452,11 +1438,12 @@ ipi_cpu(int cpu, u_int ipi) void ipi_all_but_self(u_int ipi) { + cpuset_t other_cpus; - sched_pin(); + other_cpus = all_cpus; + CPU_CLR(PCPU_GET(cpuid), &other_cpus); if (IPI_IS_BITMAPED(ipi)) { - ipi_selected(PCPU_GET(other_cpus), ipi); - sched_unpin(); + ipi_selected(other_cpus, ipi); return; } @@ -1466,8 +1453,7 @@ ipi_all_but_self(u_int ipi) * Set the mask of receiving CPUs for this purpose. */ if (ipi == IPI_STOP_HARD) - CPU_OR_ATOMIC(&ipi_nmi_pending, PCPU_PTR(other_cpus)); - sched_unpin(); + CPU_OR_ATOMIC(&ipi_nmi_pending, &other_cpus); CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi); lapic_ipi_vectored(ipi, APIC_IPI_DEST_OTHERS); @@ -1476,7 +1462,7 @@ ipi_all_but_self(u_int ipi) int ipi_nmi_handler() { - cpuset_t cpumask; + u_int cpuid; /* * As long as there is not a simple way to know about a NMI's @@ -1484,13 +1470,11 @@ ipi_nmi_handler() * the global pending bitword an IPI_STOP_HARD has been issued * and should be handled. */ - sched_pin(); - cpumask = PCPU_GET(cpumask); - sched_unpin(); - if (!CPU_OVERLAP(&ipi_nmi_pending, &cpumask)) + cpuid = PCPU_GET(cpuid); + if (!CPU_ISSET(cpuid, &ipi_nmi_pending)) return (1); - CPU_NAND_ATOMIC(&ipi_nmi_pending, &cpumask); + CPU_CLR_ATOMIC(cpuid, &ipi_nmi_pending); cpustop_handler(); return (0); } @@ -1502,25 +1486,21 @@ ipi_nmi_handler() void cpustop_handler(void) { - cpuset_t cpumask; u_int cpu; - sched_pin(); cpu = PCPU_GET(cpuid); - cpumask = PCPU_GET(cpumask); - sched_unpin(); savectx(&stoppcbs[cpu]); /* Indicate that we are stopped */ - CPU_OR_ATOMIC(&stopped_cpus, &cpumask); + CPU_SET_ATOMIC(cpu, &stopped_cpus); /* Wait for restart */ - while (!CPU_OVERLAP(&started_cpus, &cpumask)) + while (!CPU_ISSET(cpu, &started_cpus)) ia32_pause(); - CPU_NAND_ATOMIC(&started_cpus, &cpumask); - CPU_NAND_ATOMIC(&stopped_cpus, &cpumask); + CPU_CLR_ATOMIC(cpu, &started_cpus); + CPU_CLR_ATOMIC(cpu, &stopped_cpus); if (cpu == 0 && cpustop_restartfunc != NULL) { cpustop_restartfunc(); Modified: head/sys/i386/i386/pmap.c ============================================================================== --- head/sys/i386/i386/pmap.c Mon Jul 4 11:13:00 2011 (r223757) +++ head/sys/i386/i386/pmap.c Mon Jul 4 12:04:52 2011 (r223758) @@ -932,16 +932,18 @@ pmap_update_pde_invalidate(vm_offset_t v void pmap_invalidate_page(pmap_t pmap, vm_offset_t va) { - cpuset_t cpumask, other_cpus; + cpuset_t other_cpus; + u_int cpuid; sched_pin(); if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) { invlpg(va); smp_invlpg(va); } else { - cpumask = PCPU_GET(cpumask); - other_cpus = PCPU_GET(other_cpus); - if (CPU_OVERLAP(&pmap->pm_active, &cpumask)) + cpuid = PCPU_GET(cpuid); + other_cpus = all_cpus; + CPU_CLR(cpuid, &other_cpus); + if (CPU_ISSET(cpuid, &pmap->pm_active)) invlpg(va); CPU_AND(&other_cpus, &pmap->pm_active); if (!CPU_EMPTY(&other_cpus)) @@ -953,8 +955,9 @@ pmap_invalidate_page(pmap_t pmap, vm_off void pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) { - cpuset_t cpumask, other_cpus; + cpuset_t other_cpus; vm_offset_t addr; + u_int cpuid; sched_pin(); if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) { @@ -962,9 +965,10 @@ pmap_invalidate_range(pmap_t pmap, vm_of invlpg(addr); smp_invlpg_range(sva, eva); } else { - cpumask = PCPU_GET(cpumask); - other_cpus = PCPU_GET(other_cpus); - if (CPU_OVERLAP(&pmap->pm_active, &cpumask)) + cpuid = PCPU_GET(cpuid); + other_cpus = all_cpus; + CPU_CLR(cpuid, &other_cpus); + if (CPU_ISSET(cpuid, &pmap->pm_active)) for (addr = sva; addr < eva; addr += PAGE_SIZE) invlpg(addr); CPU_AND(&other_cpus, &pmap->pm_active); @@ -977,16 +981,18 @@ pmap_invalidate_range(pmap_t pmap, vm_of void pmap_invalidate_all(pmap_t pmap) { - cpuset_t cpumask, other_cpus; + cpuset_t other_cpus; + u_int cpuid; sched_pin(); if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) { invltlb(); smp_invltlb(); } else { - cpumask = PCPU_GET(cpumask); - other_cpus = PCPU_GET(other_cpus); - if (CPU_OVERLAP(&pmap->pm_active, &cpumask)) + cpuid = PCPU_GET(cpuid); + other_cpus = all_cpus; + CPU_CLR(cpuid, &other_cpus); + if (CPU_ISSET(cpuid, &pmap->pm_active)) invltlb(); CPU_AND(&other_cpus, &pmap->pm_active); if (!CPU_EMPTY(&other_cpus)) @@ -1006,11 +1012,11 @@ pmap_invalidate_cache(void) } struct pde_action { - cpuset_t store; /* processor that updates the PDE */ cpuset_t invalidate; /* processors that invalidate their TLB */ vm_offset_t va; pd_entry_t *pde; pd_entry_t newpde; + u_int store; /* processor that updates the PDE */ }; static void @@ -1020,9 +1026,7 @@ pmap_update_pde_kernel(void *arg) pd_entry_t *pde; pmap_t pmap; - sched_pin(); - if (!CPU_CMP(&act->store, PCPU_PTR(cpumask))) { - sched_unpin(); + if (act->store == PCPU_GET(cpuid)) { /* * Elsewhere, this operation requires allpmaps_lock for @@ -1033,8 +1037,7 @@ pmap_update_pde_kernel(void *arg) pde = pmap_pde(pmap, act->va); pde_store(pde, act->newpde); } - } else - sched_unpin(); + } } static void @@ -1042,12 +1045,8 @@ pmap_update_pde_user(void *arg) { struct pde_action *act = arg; - sched_pin(); - if (!CPU_CMP(&act->store, PCPU_PTR(cpumask))) { - sched_unpin(); + if (act->store == PCPU_GET(cpuid)) pde_store(act->pde, act->newpde); - } else - sched_unpin(); } static void @@ -1055,12 +1054,8 @@ pmap_update_pde_teardown(void *arg) { struct pde_action *act = arg; - sched_pin(); - if (CPU_OVERLAP(&act->invalidate, PCPU_PTR(cpumask))) { - sched_unpin(); + if (CPU_ISSET(PCPU_GET(cpuid), &act->invalidate)) pmap_update_pde_invalidate(act->va, act->newpde); - } else - sched_unpin(); } /* @@ -1075,23 +1070,25 @@ static void pmap_update_pde(pmap_t pmap, vm_offset_t va, pd_entry_t *pde, pd_entry_t newpde) { struct pde_action act; - cpuset_t active, cpumask, other_cpus; + cpuset_t active, other_cpus; + u_int cpuid; sched_pin(); - cpumask = PCPU_GET(cpumask); - other_cpus = PCPU_GET(other_cpus); + cpuid = PCPU_GET(cpuid); + other_cpus = all_cpus; + CPU_CLR(cpuid, &other_cpus); if (pmap == kernel_pmap) active = all_cpus; else active = pmap->pm_active; if (CPU_OVERLAP(&active, &other_cpus)) { - act.store = cpumask; + act.store = cpuid; act.invalidate = active; act.va = va; act.pde = pde; act.newpde = newpde; - CPU_OR(&cpumask, &active); - smp_rendezvous_cpus(cpumask, + CPU_SET(cpuid, &active); + smp_rendezvous_cpus(active, smp_no_rendevous_barrier, pmap == kernel_pmap ? pmap_update_pde_kernel : pmap_update_pde_user, pmap_update_pde_teardown, &act); @@ -1100,7 +1097,7 @@ pmap_update_pde(pmap_t pmap, vm_offset_t pmap_kenter_pde(va, newpde); else pde_store(pde, newpde); - if (CPU_OVERLAP(&active, &cpumask)) + if (CPU_ISSET(cpuid, &active)) pmap_update_pde_invalidate(va, newpde); } sched_unpin(); @@ -1925,12 +1922,12 @@ pmap_lazyfix_action(void) } static void -pmap_lazyfix_self(cpuset_t mymask) +pmap_lazyfix_self(u_int cpuid) { if (rcr3() == lazyptd) load_cr3(PCPU_GET(curpcb)->pcb_cr3); - CPU_NAND_ATOMIC(lazymask, &mymask); + CPU_CLR_ATOMIC(cpuid, lazymask); } @@ -1938,7 +1935,7 @@ static void pmap_lazyfix(pmap_t pmap) { cpuset_t mymask, mask; - u_int spins; + u_int cpuid, spins; int lsb; mask = pmap->pm_active; @@ -1956,10 +1953,13 @@ pmap_lazyfix(pmap_t pmap) #else lazyptd = vtophys(pmap->pm_pdir); #endif - mymask = PCPU_GET(cpumask); + cpuid = PCPU_GET(cpuid); + + /* Use a cpuset just for having an easy check. */ + CPU_SETOF(cpuid, &mymask); if (!CPU_CMP(&mask, &mymask)) { lazymask = &pmap->pm_active; - pmap_lazyfix_self(mymask); + pmap_lazyfix_self(cpuid); } else { atomic_store_rel_int((u_int *)&lazymask, (u_int)&pmap->pm_active); @@ -5098,17 +5098,19 @@ void pmap_activate(struct thread *td) { pmap_t pmap, oldpmap; + u_int cpuid; u_int32_t cr3; critical_enter(); pmap = vmspace_pmap(td->td_proc->p_vmspace); oldpmap = PCPU_GET(curpmap); + cpuid = PCPU_GET(cpuid); #if defined(SMP) - CPU_NAND_ATOMIC(&oldpmap->pm_active, PCPU_PTR(cpumask)); - CPU_OR_ATOMIC(&pmap->pm_active, PCPU_PTR(cpumask)); + CPU_CLR_ATOMIC(cpuid, &oldpmap->pm_active); + CPU_SET_ATOMIC(cpuid, &pmap->pm_active); #else - CPU_NAND(&oldpmap->pm_active, PCPU_PTR(cpumask)); - CPU_OR(&pmap->pm_active, PCPU_PTR(cpumask)); + CPU_CLR(cpuid, &oldpmap->pm_active); + CPU_SET(cpuid, &pmap->pm_active); #endif #ifdef PAE cr3 = vtophys(pmap->pm_pdpt); Modified: head/sys/i386/i386/vm_machdep.c ============================================================================== --- head/sys/i386/i386/vm_machdep.c Mon Jul 4 11:13:00 2011 (r223757) +++ head/sys/i386/i386/vm_machdep.c Mon Jul 4 12:04:52 2011 (r223758) @@ -602,8 +602,8 @@ cpu_reset() u_int cnt; if (smp_active) { - sched_pin(); - map = PCPU_GET(other_cpus); + map = all_cpus; + CPU_CLR(PCPU_GET(cpuid), &map); CPU_NAND(&map, &stopped_cpus); if (!CPU_EMPTY(&map)) { printf("cpu_reset: Stopping other CPUs\n"); @@ -612,7 +612,6 @@ cpu_reset() if (PCPU_GET(cpuid) != 0) { cpu_reset_proxyid = PCPU_GET(cpuid); - sched_unpin(); cpustop_restartfunc = cpu_reset_proxy; cpu_reset_proxy_active = 0; printf("cpu_reset: Restarting BSP\n"); @@ -632,8 +631,7 @@ cpu_reset() while (1); /* NOTREACHED */ - } else - sched_unpin(); + } DELAY(1000000); } @@ -802,7 +800,8 @@ sf_buf_alloc(struct vm_page *m, int flag struct sf_head *hash_list; struct sf_buf *sf; #ifdef SMP - cpuset_t cpumask, other_cpus; + cpuset_t other_cpus; + u_int cpuid; #endif int error; @@ -877,13 +876,14 @@ sf_buf_alloc(struct vm_page *m, int flag CPU_ZERO(&sf->cpumask); shootdown: sched_pin(); - cpumask = PCPU_GET(cpumask); - if (!CPU_OVERLAP(&cpumask, &sf->cpumask)) { - CPU_OR(&sf->cpumask, &cpumask); + cpuid = PCPU_GET(cpuid); + if (!CPU_ISSET(cpuid, &sf->cpumask)) { + CPU_SET(cpuid, &sf->cpumask); invlpg(sf->kva); } *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 12:18:13 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0E2D81065678; Mon, 4 Jul 2011 12:18:13 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F22958FC1B; Mon, 4 Jul 2011 12:18:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p64CIC6X018638; Mon, 4 Jul 2011 12:18:12 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p64CICF4018636; Mon, 4 Jul 2011 12:18:12 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201107041218.p64CICF4018636@svn.freebsd.org> From: Attilio Rao Date: Mon, 4 Jul 2011 12:18:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223759 - head/sys/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 12:18:13 -0000 Author: attilio Date: Mon Jul 4 12:18:12 2011 New Revision: 223759 URL: http://svn.freebsd.org/changeset/base/223759 Log: - Remove the now unused CPU_NAND_ATOMIC() - Add a comment explaining that CPU_OR_ATOMIC() and CPU_COPY_STORE_REL() are special wrappers used to cater particular cases. Modified: head/sys/sys/cpuset.h Modified: head/sys/sys/cpuset.h ============================================================================== --- head/sys/sys/cpuset.h Mon Jul 4 12:04:52 2011 (r223758) +++ head/sys/sys/cpuset.h Mon Jul 4 12:18:12 2011 (r223759) @@ -131,6 +131,7 @@ #define CPU_SET_ATOMIC(n, p) \ atomic_set_long(&(p)->__bits[(n)/_NCPUBITS], __cpuset_mask(n)) +/* Convenience functions catering special cases. */ #define CPU_OR_ATOMIC(d, s) do { \ __size_t __i; \ for (__i = 0; __i < _NCPUWORDS; __i++) \ @@ -138,13 +139,6 @@ (s)->__bits[__i]); \ } while (0) -#define CPU_NAND_ATOMIC(d, s) do { \ - __size_t __i; \ - for (__i = 0; __i < _NCPUWORDS; __i++) \ - atomic_clear_long(&(d)->__bits[__i], \ - (s)->__bits[__i]); \ -} while (0) - #define CPU_COPY_STORE_REL(f, t) do { \ __size_t __i; \ for (__i = 0; __i < _NCPUWORDS; __i++) \ From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 13:55:56 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 56CCB1065670; Mon, 4 Jul 2011 13:55:56 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 474968FC15; Mon, 4 Jul 2011 13:55:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p64Dtu4l021520; Mon, 4 Jul 2011 13:55:56 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p64Dtu5R021518; Mon, 4 Jul 2011 13:55:56 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201107041355.p64Dtu5R021518@svn.freebsd.org> From: Gleb Smirnoff Date: Mon, 4 Jul 2011 13:55:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223761 - head/sys/netgraph X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 13:55:56 -0000 Author: glebius Date: Mon Jul 4 13:55:55 2011 New Revision: 223761 URL: http://svn.freebsd.org/changeset/base/223761 Log: Fix build with NETGRAPH_DEBUG. Modified: head/sys/netgraph/netgraph.h Modified: head/sys/netgraph/netgraph.h ============================================================================== --- head/sys/netgraph/netgraph.h Mon Jul 4 12:19:09 2011 (r223760) +++ head/sys/netgraph/netgraph.h Mon Jul 4 13:55:55 2011 (r223761) @@ -493,11 +493,11 @@ _ng_node_ref(node_p node, char *file, in _NG_NODE_REF(node); } -static __inline int +static __inline void _ng_node_unref(node_p node, char *file, int line) { _chknode(node, file, line); - return (_NG_NODE_UNREF(node)); + _NG_NODE_UNREF(node); } static __inline void From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 14:40:33 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 001C7106564A; Mon, 4 Jul 2011 14:40:32 +0000 (UTC) (envelope-from jonathan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E39D98FC18; Mon, 4 Jul 2011 14:40:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p64EeWRl022887; Mon, 4 Jul 2011 14:40:32 GMT (envelope-from jonathan@svn.freebsd.org) Received: (from jonathan@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p64EeWx6022884; Mon, 4 Jul 2011 14:40:32 GMT (envelope-from jonathan@svn.freebsd.org) Message-Id: <201107041440.p64EeWx6022884@svn.freebsd.org> From: Jonathan Anderson Date: Mon, 4 Jul 2011 14:40:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223762 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 14:40:33 -0000 Author: jonathan Date: Mon Jul 4 14:40:32 2011 New Revision: 223762 URL: http://svn.freebsd.org/changeset/base/223762 Log: Add kernel functions to unwrap capabilities. cap_funwrap() and cap_funwrap_mmap() unwrap capabilities, exposing the underlying object. Attempting to unwrap a capability with an inadequate rights mask (e.g. calling cap_funwrap(fp, CAP_WRITE | CAP_MMAP, &result) on a capability whose rights mask is CAP_READ | CAP_MMAP) will result in ENOTCAPABLE. Unwrapping a non-capability is effectively a no-op. These functions will be used by Capsicum-aware versions of _fget(), etc. Approved by: mentor (rwatson), re (Capsicum blanket) Sponsored by: Google Inc Modified: head/sys/kern/sys_capability.c head/sys/sys/capability.h Modified: head/sys/kern/sys_capability.c ============================================================================== --- head/sys/kern/sys_capability.c Mon Jul 4 13:55:55 2011 (r223761) +++ head/sys/kern/sys_capability.c Mon Jul 4 14:40:32 2011 (r223762) @@ -116,3 +116,125 @@ cap_getmode(struct thread *td, struct ca } #endif /* CAPABILITY_MODE */ + +#ifdef CAPABILITIES + +/* + * struct capability describes a capability, and is hung off of its struct + * file f_data field. cap_file and cap_rightss are static once hooked up, as + * neither the object it references nor the rights it encapsulates are + * permitted to change. cap_filelist may change when other capabilites are + * added or removed from the same file, and is currently protected by the + * pool mutex for the object file descriptor. + */ +struct capability { + struct file *cap_object; /* Underlying object's file. */ + struct file *cap_file; /* Back-pointer to cap's file. */ + cap_rights_t cap_rights; /* Mask of rights on object. */ + LIST_ENTRY(capability) cap_filelist; /* Object's cap list. */ +}; + +/* + * Test whether a capability grants the requested rights. + */ +static int +cap_check(struct capability *c, cap_rights_t rights) +{ + + if ((c->cap_rights | rights) != c->cap_rights) + return (ENOTCAPABLE); + return (0); +} + +/* + * Given a file descriptor, test it against a capability rights mask and then + * return the file descriptor on which to actually perform the requested + * operation. As long as the reference to fp_cap remains valid, the returned + * pointer in *fp will remain valid, so no extra reference management is + * required, and the caller should fdrop() fp_cap as normal when done with + * both. + */ +int +cap_funwrap(struct file *fp_cap, cap_rights_t rights, struct file **fpp) +{ + struct capability *c; + int error; + + if (fp_cap->f_type != DTYPE_CAPABILITY) { + *fpp = fp_cap; + return (0); + } + c = fp_cap->f_data; + error = cap_check(c, rights); + if (error) + return (error); + *fpp = c->cap_object; + return (0); +} + +/* + * Slightly different routine for memory mapping file descriptors: unwrap the + * capability and check CAP_MMAP, but also return a bitmask representing the + * maximum mapping rights the capability allows on the object. + */ +int +cap_funwrap_mmap(struct file *fp_cap, cap_rights_t rights, u_char *maxprotp, + struct file **fpp) +{ + struct capability *c; + u_char maxprot; + int error; + + if (fp_cap->f_type != DTYPE_CAPABILITY) { + *fpp = fp_cap; + *maxprotp = VM_PROT_ALL; + return (0); + } + c = fp_cap->f_data; + error = cap_check(c, rights | CAP_MMAP); + if (error) + return (error); + *fpp = c->cap_object; + maxprot = 0; + if (c->cap_rights & CAP_READ) + maxprot |= VM_PROT_READ; + if (c->cap_rights & CAP_WRITE) + maxprot |= VM_PROT_WRITE; + if (c->cap_rights & CAP_MAPEXEC) + maxprot |= VM_PROT_EXECUTE; + *maxprotp = maxprot; + return (0); +} + +#else /* !CAPABILITIES */ + +/* + * Stub Capability functions for when options CAPABILITIES isn't compiled + * into the kernel. + */ +int +cap_funwrap(struct file *fp_cap, cap_rights_t rights, struct file **fpp) +{ + + KASSERT(fp_cap->f_type != DTYPE_CAPABILITY, + ("cap_funwrap: saw capability")); + + *fpp = fp_cap; + return (0); +} + +int +cap_funwrap_mmap(struct file *fp_cap, cap_rights_t rights, u_char *maxprotp, + struct file **fpp) +{ + + KASSERT(fp_cap->f_type != DTYPE_CAPABILITY, + ("cap_funwrap_mmap: saw capability")); + + *fpp = fp_cap; + *maxprotp = VM_PROT_ALL; + return (0); +} + +#endif /* CAPABILITIES */ + Modified: head/sys/sys/capability.h ============================================================================== --- head/sys/sys/capability.h Mon Jul 4 13:55:55 2011 (r223761) +++ head/sys/sys/capability.h Mon Jul 4 14:40:32 2011 (r223762) @@ -38,10 +38,50 @@ #include #include +#include + +/* + * Possible rights on capabilities. + * + * Notes: + * Some system calls don't require a capability in order to perform an + * operation on an fd. These include: close, dup, dup2. + * + * sendfile is authorized using CAP_READ on the file and CAP_WRITE on the + * socket. + * + * mmap() and aio*() system calls will need special attention as they may + * involve reads or writes depending a great deal on context. + */ +#define CAP_READ 0x0000000000000001ULL /* read/recv */ +#define CAP_WRITE 0x0000000000000002ULL /* write/send */ +#define CAP_MMAP 0x0000000000000004ULL /* mmap */ +#define CAP_MAPEXEC 0x0000000000000008ULL /* mmap(2) as exec */ +#define CAP_MASK_VALID 0x000000000000000fULL + #ifdef _KERNEL #define IN_CAPABILITY_MODE(td) (td->td_ucred->cr_flags & CRED_FLAG_CAPMODE) +/* + * Unwrap a capability if its rights mask is a superset of 'rights'. + * + * Unwrapping a non-capability is effectively a no-op; the value of fp_cap + * is simply copied into fpp. + */ +int cap_funwrap(struct file *fp_cap, cap_rights_t rights, + struct file **fpp); +int cap_funwrap_mmap(struct file *fp_cap, cap_rights_t rights, + u_char *maxprotp, struct file **fpp); + +/* + * For the purposes of procstat(1) and similar tools, allow kern_descrip.c to + * extract the rights from a capability. However, this should not be used by + * kernel code generally, instead cap_funwrap() should be used in order to + * keep all access control in one place. + */ +cap_rights_t cap_rights(struct file *fp_cap); + #else /* !_KERNEL */ __BEGIN_DECLS From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 16:59:27 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4EEA1106564A; Mon, 4 Jul 2011 16:59:27 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3F84E8FC16; Mon, 4 Jul 2011 16:59:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p64GxRXC026968; Mon, 4 Jul 2011 16:59:27 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p64GxReB026966; Mon, 4 Jul 2011 16:59:27 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201107041659.p64GxReB026966@svn.freebsd.org> From: Marcel Moolenaar Date: Mon, 4 Jul 2011 16:59:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223763 - head/sys/ia64/conf X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 16:59:27 -0000 Author: marcel Date: Mon Jul 4 16:59:26 2011 New Revision: 223763 URL: http://svn.freebsd.org/changeset/base/223763 Log: Disable PREEMPTION for now. See also PR ia64/147501. Modified: head/sys/ia64/conf/GENERIC Modified: head/sys/ia64/conf/GENERIC ============================================================================== --- head/sys/ia64/conf/GENERIC Mon Jul 4 14:40:32 2011 (r223762) +++ head/sys/ia64/conf/GENERIC Mon Jul 4 16:59:26 2011 (r223763) @@ -48,7 +48,7 @@ options NFSLOCKD # Network Lock Manager options NFSD # New Network Filesystem Server options NFS_ROOT # NFS usable as root device options P1003_1B_SEMAPHORES # POSIX-style semaphores -options PREEMPTION # Enable kernel thread preemption +#options PREEMPTION # Enable kernel thread preemption options PRINTF_BUFR_SIZE=128 # Printf buffering to limit interspersion options PROCFS # Process filesystem (/proc) options PSEUDOFS # Pseudo-filesystem framework From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 17:03:19 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E0739106564A; Mon, 4 Jul 2011 17:03:19 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D10FE8FC0C; Mon, 4 Jul 2011 17:03:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p64H3J99027131; Mon, 4 Jul 2011 17:03:19 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p64H3Jsr027130; Mon, 4 Jul 2011 17:03:19 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201107041703.p64H3Jsr027130@svn.freebsd.org> From: Marcel Moolenaar Date: Mon, 4 Jul 2011 17:03:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223764 - head/release/ia64 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 17:03:20 -0000 Author: marcel Date: Mon Jul 4 17:03:19 2011 New Revision: 223764 URL: http://svn.freebsd.org/changeset/base/223764 Log: Add a trivial script for creating memstick images. These are not bootable yet, but proven to be useful without it already. Added: head/release/ia64/make-memstick.sh (contents, props changed) Added: head/release/ia64/make-memstick.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/release/ia64/make-memstick.sh Mon Jul 4 17:03:19 2011 (r223764) @@ -0,0 +1,38 @@ +#!/bin/sh +# +# This script generates a "memstick image" (image that can be copied to a +# USB memory stick) from a directory tree. Note that the script does not +# clean up after itself very well for error conditions on purpose so the +# problem can be diagnosed (full filesystem most likely but ...). +# +# Usage: make-memstick.sh +# +# $FreeBSD$ +# + +PATH=/bin:/usr/bin:/sbin:/usr/sbin +export PATH + +BLOCKSIZE=10240 + +if [ $# -ne 2 ]; then + echo "make-memstick.sh /path/to/directory /path/to/image/file" + exit 1 +fi + +if [ ! -d ${1} ]; then + echo "${1} must be a directory" + exit 1 +fi + +if [ -e ${2} ]; then + echo "won't overwrite ${2}" + exit 1 +fi + +makefs -B little ${2} ${1} +if [ $? -ne 0 ]; then + echo "makefs failed" + exit 1 +fi + From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 17:43:04 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D28811065672; Mon, 4 Jul 2011 17:43:04 +0000 (UTC) (envelope-from eri@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C38D98FC16; Mon, 4 Jul 2011 17:43:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p64Hh4w3028302; Mon, 4 Jul 2011 17:43:04 GMT (envelope-from eri@svn.freebsd.org) Received: (from eri@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p64Hh4HJ028300; Mon, 4 Jul 2011 17:43:04 GMT (envelope-from eri@svn.freebsd.org) Message-Id: <201107041743.p64Hh4HJ028300@svn.freebsd.org> From: Ermal Luçi Date: Mon, 4 Jul 2011 17:43:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223765 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 17:43:04 -0000 Author: eri Date: Mon Jul 4 17:43:04 2011 New Revision: 223765 URL: http://svn.freebsd.org/changeset/base/223765 Log: pf(4) tags now store the state key but tcp_respond tries to reuse a mbuf as an optimization. This makes pf find the wrong state and cause errors reported with state mismatches. Clear the cached state link on the pf(4) tag to avoid the state mismatches. Approved by: bz Modified: head/sys/netinet/tcp_subr.c Modified: head/sys/netinet/tcp_subr.c ============================================================================== --- head/sys/netinet/tcp_subr.c Mon Jul 4 17:03:19 2011 (r223764) +++ head/sys/netinet/tcp_subr.c Mon Jul 4 17:43:04 2011 (r223765) @@ -541,6 +541,7 @@ tcp_respond(struct tcpcb *tp, void *ipge m_freem(m->m_next); m->m_next = NULL; m->m_data = (caddr_t)ipgen; + m_addr_changed(m); /* m_len is set later */ tlen = 0; #define xchg(a,b,type) { type t; t=a; a=b; b=t; } From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 20:50:10 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4D9481065670; Mon, 4 Jul 2011 20:50:10 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3CD458FC14; Mon, 4 Jul 2011 20:50:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p64KoArx033877; Mon, 4 Jul 2011 20:50:10 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p64KoA45033875; Mon, 4 Jul 2011 20:50:10 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201107042050.p64KoA45033875@svn.freebsd.org> From: Gleb Smirnoff Date: Mon, 4 Jul 2011 20:50:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223768 - head/sys/netgraph X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 20:50:10 -0000 Author: glebius Date: Mon Jul 4 20:50:09 2011 New Revision: 223768 URL: http://svn.freebsd.org/changeset/base/223768 Log: Fix build with NETGRAPH_DEBUG. Modified: head/sys/netgraph/netgraph.h Modified: head/sys/netgraph/netgraph.h ============================================================================== --- head/sys/netgraph/netgraph.h Mon Jul 4 19:51:26 2011 (r223767) +++ head/sys/netgraph/netgraph.h Mon Jul 4 20:50:09 2011 (r223768) @@ -442,7 +442,7 @@ static __inline char * _ng_node_name(nod static __inline int _ng_node_has_name(node_p node, char *file, int line); static __inline ng_ID_t _ng_node_id(node_p node, char *file, int line); static __inline void _ng_node_ref(node_p node, char *file, int line); -static __inline int _ng_node_unref(node_p node, char *file, int line); +static __inline void _ng_node_unref(node_p node, char *file, int line); static __inline void _ng_node_set_private(node_p node, void * val, char *file, int line); static __inline void * _ng_node_private(node_p node, char *file, int line); From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 20:52:24 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2A3661065677; Mon, 4 Jul 2011 20:52:24 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1874D8FC1C; Mon, 4 Jul 2011 20:52:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p64KqNFh033974; Mon, 4 Jul 2011 20:52:23 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p64KqNhl033972; Mon, 4 Jul 2011 20:52:23 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201107042052.p64KqNhl033972@svn.freebsd.org> From: Jeff Roberson Date: Mon, 4 Jul 2011 20:52:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223769 - head/sys/ufs/ufs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 20:52:24 -0000 Author: jeff Date: Mon Jul 4 20:52:23 2011 New Revision: 223769 URL: http://svn.freebsd.org/changeset/base/223769 Log: - Fix an inode quota leak. We need to decrement the quota once and only once. Tested by: pho Reviewed by: mckusick Modified: head/sys/ufs/ufs/ufs_inode.c Modified: head/sys/ufs/ufs/ufs_inode.c ============================================================================== --- head/sys/ufs/ufs/ufs_inode.c Mon Jul 4 20:50:09 2011 (r223768) +++ head/sys/ufs/ufs/ufs_inode.c Mon Jul 4 20:52:23 2011 (r223769) @@ -120,15 +120,14 @@ ufs_inactive(ap) isize = ip->i_size; if (ip->i_ump->um_fstype == UFS2) isize += ip->i_din2->di_extsize; - if (ip->i_effnlink <= 0 && isize && !UFS_RDONLY(ip)) { + if (ip->i_effnlink <= 0 && isize && !UFS_RDONLY(ip)) + error = UFS_TRUNCATE(vp, (off_t)0, IO_EXT | IO_NORMAL, + NOCRED, td); + if (ip->i_nlink <= 0 && ip->i_mode && !UFS_RDONLY(ip)) { #ifdef QUOTA if (!getinoquota(ip)) (void)chkiq(ip, -1, NOCRED, FORCE); #endif - error = UFS_TRUNCATE(vp, (off_t)0, IO_EXT | IO_NORMAL, - NOCRED, td); - } - if (ip->i_nlink <= 0 && ip->i_mode && !UFS_RDONLY(ip)) { #ifdef UFS_EXTATTR ufs_extattr_vnode_inactive(vp, td); #endif From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 20:53:55 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 86A89106566C; Mon, 4 Jul 2011 20:53:55 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 75CEC8FC1F; Mon, 4 Jul 2011 20:53:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p64KrtNO034052; Mon, 4 Jul 2011 20:53:55 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p64Krtf9034050; Mon, 4 Jul 2011 20:53:55 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201107042053.p64Krtf9034050@svn.freebsd.org> From: Jeff Roberson Date: Mon, 4 Jul 2011 20:53:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223770 - head/sys/ufs/ffs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 20:53:55 -0000 Author: jeff Date: Mon Jul 4 20:53:55 2011 New Revision: 223770 URL: http://svn.freebsd.org/changeset/base/223770 Log: - It is impossible to run request_cleanup() while doing a copyonwrite. This will most likely cause new block allocations which can recurse into request cleanup. - While here optimize the ufs locking slightly. We need only acquire and drop once. - process_removes() and process_truncates() also is only needed once. - Attempt to flush each item on the worklist once but do not loop forever if some can not be completed. Discussed with: mckusick Modified: head/sys/ufs/ffs/ffs_softdep.c Modified: head/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- head/sys/ufs/ffs/ffs_softdep.c Mon Jul 4 20:52:23 2011 (r223769) +++ head/sys/ufs/ffs/ffs_softdep.c Mon Jul 4 20:53:55 2011 (r223770) @@ -12510,33 +12510,36 @@ softdep_request_cleanup(fs, vp, cred, re int error; mp = vp->v_mount; - ump = VTOI(vp)->i_ump; + ump = VFSTOUFS(mp); mtx_assert(UFS_MTX(ump), MA_OWNED); if (resource == FLUSH_BLOCKS_WAIT) stat_cleanup_blkrequests += 1; else stat_cleanup_inorequests += 1; + /* * If we are being called because of a process doing a - * copy-on-write, then it is not safe to update the vnode - * as we may recurse into the copy-on-write routine. + * copy-on-write, then it is not safe to process any + * worklist items as we will recurse into the copyonwrite + * routine. This will result in an incoherent snapshot. */ - if (!(curthread->td_pflags & TDP_COWINPROGRESS)) { - UFS_UNLOCK(ump); - error = ffs_update(vp, 1); + if (curthread->td_pflags & TDP_COWINPROGRESS) + return (0); + UFS_UNLOCK(ump); + error = ffs_update(vp, 1); + if (error != 0) { UFS_LOCK(ump); - if (error != 0) - return (0); + return (0); } /* * If we are in need of resources, consider pausing for * tickdelay to give ourselves some breathing room. */ - UFS_UNLOCK(ump); ACQUIRE_LOCK(&lk); + process_removes(vp); + process_truncates(vp); request_cleanup(UFSTOVFS(ump), resource); FREE_LOCK(&lk); - UFS_LOCK(ump); /* * Now clean up at least as many resources as we will need. * @@ -12568,29 +12571,23 @@ softdep_request_cleanup(fs, vp, cred, re roundup((fs->fs_dsize * fs->fs_minfree / 100) - fs->fs_cstotal.cs_nffree, fs->fs_frag)); } else { + UFS_LOCK(ump); printf("softdep_request_cleanup: Unknown resource type %d\n", resource); return (0); } starttime = time_second; retry: - while ((resource == FLUSH_BLOCKS_WAIT && ump->softdep_on_worklist > 0 && - fs->fs_cstotal.cs_nbfree <= needed) || - (resource == FLUSH_INODES_WAIT && fs->fs_pendinginodes > 0 && - fs->fs_cstotal.cs_nifree <= needed)) { - UFS_UNLOCK(ump); + if ((resource == FLUSH_BLOCKS_WAIT && ump->softdep_on_worklist > 0 && + fs->fs_cstotal.cs_nbfree <= needed) || + (resource == FLUSH_INODES_WAIT && fs->fs_pendinginodes > 0 && + fs->fs_cstotal.cs_nifree <= needed)) { ACQUIRE_LOCK(&lk); - process_removes(vp); - process_truncates(vp); if (ump->softdep_on_worklist > 0 && - process_worklist_item(UFSTOVFS(ump), 1, LK_NOWAIT) != 0) { + process_worklist_item(UFSTOVFS(ump), + ump->softdep_on_worklist, LK_NOWAIT) != 0) stat_worklist_push += 1; - FREE_LOCK(&lk); - UFS_LOCK(ump); - continue; - } FREE_LOCK(&lk); - UFS_LOCK(ump); } /* * If we still need resources and there are no more worklist @@ -12604,7 +12601,6 @@ retry: fs->fs_cstotal.cs_nbfree <= needed) || (resource == FLUSH_INODES_WAIT && fs->fs_pendinginodes > 0 && fs->fs_cstotal.cs_nifree <= needed)) { - UFS_UNLOCK(ump); MNT_ILOCK(mp); MNT_VNODE_FOREACH(lvp, mp, mvp) { VI_LOCK(lvp); @@ -12633,7 +12629,6 @@ retry: VOP_FSYNC(lvp, MNT_NOWAIT, curthread); VOP_UNLOCK(lvp, 0); } - UFS_LOCK(ump); if (ump->softdep_on_worklist > 0) { stat_cleanup_retries += 1; goto retry; @@ -12642,6 +12637,7 @@ retry: } if (time_second - starttime > stat_cleanup_high_delay) stat_cleanup_high_delay = time_second - starttime; + UFS_LOCK(ump); return (1); } From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 21:04:26 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 23AC3106564A; Mon, 4 Jul 2011 21:04:26 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1347A8FC0A; Mon, 4 Jul 2011 21:04:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p64L4Pl0034427; Mon, 4 Jul 2011 21:04:25 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p64L4P6H034425; Mon, 4 Jul 2011 21:04:25 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201107042104.p64L4P6H034425@svn.freebsd.org> From: Jeff Roberson Date: Mon, 4 Jul 2011 21:04:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223771 - head/sys/ufs/ffs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 21:04:26 -0000 Author: jeff Date: Mon Jul 4 21:04:25 2011 New Revision: 223771 URL: http://svn.freebsd.org/changeset/base/223771 Log: - Handle D_JSEGDEP in the softdep_sync_buf() switch. These can now find themselves on snapshot vnodes. Reported by: pho Modified: head/sys/ufs/ffs/ffs_softdep.c Modified: head/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- head/sys/ufs/ffs/ffs_softdep.c Mon Jul 4 20:53:55 2011 (r223770) +++ head/sys/ufs/ffs/ffs_softdep.c Mon Jul 4 21:04:25 2011 (r223771) @@ -12082,6 +12082,7 @@ top: case D_FREEWORK: case D_FREEDEP: + case D_JSEGDEP: continue; default: From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 22:08:05 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 07B721065670; Mon, 4 Jul 2011 22:08:05 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EA9C88FC12; Mon, 4 Jul 2011 22:08:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p64M8404036305; Mon, 4 Jul 2011 22:08:04 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p64M84I8036302; Mon, 4 Jul 2011 22:08:04 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201107042208.p64M84I8036302@svn.freebsd.org> From: Jeff Roberson Date: Mon, 4 Jul 2011 22:08:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223772 - head/sys/ufs/ffs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 22:08:05 -0000 Author: jeff Date: Mon Jul 4 22:08:04 2011 New Revision: 223772 URL: http://svn.freebsd.org/changeset/base/223772 Log: - Speed up pendingblock processing again. Having too much delay between ffs_blkfree() and the pending adjustment causes all kinds of space related problems. Modified: head/sys/ufs/ffs/ffs_softdep.c head/sys/ufs/ffs/softdep.h Modified: head/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- head/sys/ufs/ffs/ffs_softdep.c Mon Jul 4 21:04:25 2011 (r223771) +++ head/sys/ufs/ffs/ffs_softdep.c Mon Jul 4 22:08:04 2011 (r223772) @@ -880,6 +880,7 @@ static inline void setup_freeext(struct static inline void setup_freeindir(struct freeblks *, struct inode *, int, ufs_lbn_t, int); static inline struct freeblks *newfreeblks(struct mount *, struct inode *); +static void freeblks_free(struct ufsmount *, struct freeblks *, int); static void indir_trunc(struct freework *, ufs2_daddr_t, ufs_lbn_t); ufs2_daddr_t blkcount(struct fs *, ufs2_daddr_t, off_t); static int trunc_check_buf(struct buf *, int *, ufs_lbn_t, int, int); @@ -5751,7 +5752,6 @@ newfreeblks(mp, ip) freeblks->fb_modrev = DIP(ip, i_modrev); freeblks->fb_devvp = ip->i_devvp; freeblks->fb_chkcnt = 0; - freeblks->fb_freecnt = 0; freeblks->fb_len = 0; return (freeblks); @@ -6199,7 +6199,7 @@ softdep_journal_freeblocks(ip, cred, len quotaref(vp, freeblks->fb_quota); (void) chkdq(ip, -datablocks, NOCRED, 0); #endif - freeblks->fb_chkcnt = datablocks; + freeblks->fb_chkcnt = -datablocks; UFS_LOCK(ip->i_ump); fs->fs_pendingblocks += datablocks; UFS_UNLOCK(ip->i_ump); @@ -6429,7 +6429,7 @@ softdep_setup_freeblocks(ip, length, fla quotaref(vp, freeblks->fb_quota); (void) chkdq(ip, -datablocks, NOCRED, 0); #endif - freeblks->fb_chkcnt = datablocks; + freeblks->fb_chkcnt = -datablocks; UFS_LOCK(ip->i_ump); fs->fs_pendingblocks += datablocks; UFS_UNLOCK(ip->i_ump); @@ -7284,8 +7284,8 @@ freework_freeblock(freework) freeblks->fb_cgwait++; WORKLIST_INSERT(&wkhd, &freework->fw_list); } - freeblks->fb_freecnt += btodb(bsize); FREE_LOCK(&lk); + freeblks_free(ump, freeblks, btodb(bsize)); ffs_blkfree(ump, fs, freeblks->fb_devvp, freework->fw_blkno, bsize, freeblks->fb_inum, freeblks->fb_vtype, &wkhd); ACQUIRE_LOCK(&lk); @@ -7459,6 +7459,33 @@ handle_workitem_freeblocks(freeblks, fla } /* + * Handle completion of block free via truncate. This allows fs_pending + * to track the actual free block count more closely than if we only updated + * it at the end. We must be careful to handle cases where the block count + * on free was incorrect. + */ +static void +freeblks_free(ump, freeblks, blocks) + struct ufsmount *ump; + struct freeblks *freeblks; + int blocks; +{ + struct fs *fs; + ufs2_daddr_t remain; + + UFS_LOCK(ump); + remain = -freeblks->fb_chkcnt; + freeblks->fb_chkcnt += blocks; + if (remain > 0) { + if (remain < blocks) + blocks = remain; + fs = ump->um_fs; + fs->fs_pendingblocks -= blocks; + } + UFS_UNLOCK(ump); +} + +/* * Once all of the freework workitems are complete we can retire the * freeblocks dependency and any journal work awaiting completion. This * can not be called until all other dependencies are stable on disk. @@ -7478,7 +7505,7 @@ handle_complete_freeblocks(freeblks, fla ump = VFSTOUFS(freeblks->fb_list.wk_mp); fs = ump->um_fs; flags = LK_EXCLUSIVE | flags; - spare = freeblks->fb_freecnt - freeblks->fb_chkcnt; + spare = freeblks->fb_chkcnt; /* * If we did not release the expected number of blocks we may have @@ -7501,9 +7528,9 @@ handle_complete_freeblocks(freeblks, fla } vput(vp); } - if (freeblks->fb_chkcnt) { + if (spare < 0) { UFS_LOCK(ump); - fs->fs_pendingblocks -= freeblks->fb_chkcnt; + fs->fs_pendingblocks += spare; UFS_UNLOCK(ump); } #ifdef QUOTA @@ -7559,7 +7586,7 @@ indir_trunc(freework, dbn, lbn) ufs2_daddr_t nb, nnb, *bap2 = 0; ufs_lbn_t lbnadd, nlbn; int i, nblocks, ufs1fmt; - int fs_pendingblocks; + int freedblocks; int goingaway; int freedeps; int needj; @@ -7701,16 +7728,18 @@ indir_trunc(freework, dbn, lbn) bp->b_flags |= B_INVAL | B_NOCACHE; brelse(bp); } - fs_pendingblocks = 0; + freedblocks = 0; if (level == 0) - fs_pendingblocks = (nblocks * cnt); + freedblocks = (nblocks * cnt); + if (needj == 0) + freedblocks += nblocks; + freeblks_free(ump, freeblks, freedblocks); /* * If we are journaling set up the ref counts and offset so this * indirect can be completed when its children are free. */ if (needj) { ACQUIRE_LOCK(&lk); - freeblks->fb_freecnt += fs_pendingblocks; freework->fw_off = i; freework->fw_ref += freedeps; freework->fw_ref -= NINDIR(fs) + 1; @@ -7724,12 +7753,10 @@ indir_trunc(freework, dbn, lbn) /* * If we're not journaling we can free the indirect now. */ - fs_pendingblocks += nblocks; dbn = dbtofsb(fs, dbn); ffs_blkfree(ump, fs, freeblks->fb_devvp, dbn, fs->fs_bsize, freeblks->fb_inum, freeblks->fb_vtype, NULL); /* Non SUJ softdep does single-threaded truncations. */ - freeblks->fb_freecnt += fs_pendingblocks; if (freework->fw_blkno == dbn) { freework->fw_state |= ALLCOMPLETE; ACQUIRE_LOCK(&lk); Modified: head/sys/ufs/ffs/softdep.h ============================================================================== --- head/sys/ufs/ffs/softdep.h Mon Jul 4 21:04:25 2011 (r223771) +++ head/sys/ufs/ffs/softdep.h Mon Jul 4 22:08:04 2011 (r223772) @@ -536,8 +536,7 @@ struct freeblks { #endif uint64_t fb_modrev; /* Inode revision at start of trunc. */ off_t fb_len; /* Length we're truncating to. */ - ufs2_daddr_t fb_chkcnt; /* Expected blks released. */ - ufs2_daddr_t fb_freecnt; /* Actual blocks released. */ + ufs2_daddr_t fb_chkcnt; /* Blocks released. */ ino_t fb_inum; /* inode owner of blocks */ enum vtype fb_vtype; /* inode owner's file type */ uid_t fb_uid; /* uid of previous owner of blocks */ From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 23:00:27 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 28B12106566B; Mon, 4 Jul 2011 23:00:27 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 16AE68FC08; Mon, 4 Jul 2011 23:00:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p64N0RNo037920; Mon, 4 Jul 2011 23:00:27 GMT (envelope-from gjb@svn.freebsd.org) Received: (from gjb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p64N0Rub037918; Mon, 4 Jul 2011 23:00:27 GMT (envelope-from gjb@svn.freebsd.org) Message-Id: <201107042300.p64N0Rub037918@svn.freebsd.org> From: Glen Barber Date: Mon, 4 Jul 2011 23:00:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223773 - head/sys/netinet/libalias X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 23:00:27 -0000 Author: gjb (doc committer) Date: Mon Jul 4 23:00:26 2011 New Revision: 223773 URL: http://svn.freebsd.org/changeset/base/223773 Log: - General grammar and mdoc(7) fixes. [1] [2] - While here, remove a paragraph about userspace operation that has been outdated for some time. [2] PR: 158623 Submitted by: Ben Kudak (kaduk % mit!edu) [1] Reviewed by: glebius [2] MFC after: 1 week Modified: head/sys/netinet/libalias/libalias.3 Modified: head/sys/netinet/libalias/libalias.3 ============================================================================== --- head/sys/netinet/libalias/libalias.3 Mon Jul 4 22:08:04 2011 (r223772) +++ head/sys/netinet/libalias/libalias.3 Mon Jul 4 23:00:26 2011 (r223773) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 22, 2011 +.Dd July 04, 2011 .Dt LIBALIAS 3 .Os .Sh NAME @@ -52,7 +52,7 @@ machine on the local network. .Pp A certain amount of flexibility is built into the packet aliasing engine. In the simplest mode of operation, a many-to-one address mapping takes -place between local network and the packet aliasing host. +place between the local network and the packet aliasing host. This is known as IP masquerading. In addition, one-to-one mappings between local and public addresses can also be implemented, which is known as static NAT. @@ -61,15 +61,11 @@ linked to different public addresses, co many-to-one mappings. Also, a given public address and port can be statically redirected to a private address/port. -.Pp -The packet aliasing engine was designed to operate in user space outside -of the kernel, without any access to private kernel data structure, but -the source code can also be ported to a kernel environment. .Sh INITIALIZATION AND CONTROL One special function, .Fn LibAliasInit , -must always be called before any packet handling may be performed and -the returned instance pointer passed to all the other functions. +must always be called before any packet handling may be performed, and +the returned instance pointer must be passed to all the other functions. Normally, the .Fn LibAliasSetAddress function is called afterwards, to set the default aliasing address. @@ -118,8 +114,8 @@ prior to any packet handling. This function has no return value and is used to clear any resources attached to internal data structures. .Pp -This functions should be called when a program stops using the aliasing -engine; it does, amongst other things, clear out any firewall holes. +This function should be called when a program stops using the aliasing +engine; amongst other things, it clears out any firewall holes. To provide backwards compatibility and extra security, it is added to the .Xr atexit 3 @@ -135,7 +131,7 @@ local area network are aliased. All outgoing packets are re-mapped to this address unless overridden by a static address mapping established by .Fn LibAliasRedirectAddr . -If this function is not called, and no static rules match, an outgoing +If this function has not been called, and no static rules match, an outgoing packet retains its source address. .Pp If the @@ -150,7 +146,7 @@ address may or may not change on success If the .Dv PKT_ALIAS_RESET_ON_ADDR_CHANGE mode bit is set to zero, this function can also be used to dynamically change -the aliasing address on a packet to packet basis (it is a low overhead call). +the aliasing address on a packet-to-packet basis (it is a low overhead call). .Pp It is mandatory that this function be called prior to any packet handling. .Ed @@ -170,7 +166,7 @@ The following mode bits are defined in .It Dv PKT_ALIAS_LOG Enables logging into .Pa /var/log/alias.log . -Each time an aliasing link is created or deleted, the log file is appended +Each time an aliasing link is created or deleted, the log file is appended to with the current number of ICMP, TCP and UDP links. Mainly useful for debugging when the log file is viewed continuously with .Xr tail 1 . @@ -186,7 +182,7 @@ Response packets to connections or trans aliasing host or local network will be unaffected. This mode bit is useful for implementing a one-way firewall. .It Dv PKT_ALIAS_SAME_PORTS -If this mode bit is set, the packet aliasing engine will attempt to leave +If this mode bit is set, the packet-aliasing engine will attempt to leave the alias port numbers unchanged from the actual local port numbers. This can be done as long as the quintuple (proto, alias addr, alias port, remote addr, remote port) is unique. @@ -211,7 +207,7 @@ Standard Class A, B and C unregistered a 192.168.0.0 -> 192.168.255.255 (Class C subnets) .Ed .Pp -This option is useful in the case that packet aliasing host has both +This option is useful in the case that the packet aliasing host has both registered and unregistered subnets on different interfaces. The registered subnet is fully accessible to the outside world, so traffic from it does not need to be passed through the packet aliasing engine. @@ -229,8 +225,9 @@ of an address change. .It Dv PKT_ALIAS_PUNCH_FW This option makes .Nm -`punch holes' in an -.Xr ipfirewall 4 +.Dq punch holes +in an +.Xr ipfirewall 4 - based firewall for FTP/IRC DCC connections. The holes punched are bound by from/to IP address and port; it will not be possible to use a hole for another connection. @@ -240,9 +237,9 @@ To cater to unexpected death of a progra (e.g.\& kill -9), changing the state of the flag will clear the entire firewall range allocated for holes. -This will also happen on the initial call to -.Fn LibAliasSetFWBase . -This call must happen prior to setting this flag. +This clearing will also happen on the initial call to +.Fn LibAliasSetFWBase , +which must happen prior to setting this flag. .It Dv PKT_ALIAS_REVERSE This option makes .Nm @@ -260,9 +257,11 @@ below for details. .It Dv PKT_ALIAS_SKIP_GLOBAL This option is used by .Pa ipfw_nat -only. Specifying it as a flag to +only. +Specifying it as a flag to .Fn LibAliasSetMode -has no effect. See section +has no effect. +See section .Sx NETWORK ADDRESS TRANSLATION in .Xr ipfw 8 @@ -273,10 +272,10 @@ for more details. .Ft void .Fn LibAliasSetFWBase "struct libalias *" "unsigned int base" "unsigned int num" .Bd -ragged -offset indent -Set firewall range allocated for punching firewall holes (with the +Set the firewall range allocated for punching firewall holes (with the .Dv PKT_ALIAS_PUNCH_FW flag). -The range will be cleared for all rules on initialization. +The range is cleared for all rules on initialization. .Ed .Pp .Ft void @@ -302,7 +301,7 @@ the two packet handling functions, .Fn LibAliasIn and .Fn LibAliasOut , -comprise minimal set of functions needed for a basic IP masquerading +comprise the minimal set of functions needed for a basic IP masquerading implementation. .Pp .Ft int @@ -323,11 +322,11 @@ Return codes: The packet aliasing process was successful. .It Dv PKT_ALIAS_IGNORED The packet was ignored and not de-aliased. -This can happen if the protocol is unrecognized, possibly an ICMP message -type is not handled or if incoming packets for new connections are being -ignored (if +This can happen if the protocol is unrecognized, as for an ICMP message +type that is not handled, or if incoming packets for new connections are being +ignored (if the .Dv PKT_ALIAS_DENY_INCOMING -mode bit was set by +mode bit was set using .Fn LibAliasSetMode ) . .It Dv PKT_ALIAS_UNRESOLVED_FRAGMENT This is returned when a fragment cannot be resolved because the header @@ -418,7 +417,7 @@ is called to change the address after .Fn LibAliasRedirectPort is called, a zero reference will track this change. .Pp -If the link is further set up to operate for a load sharing, then +If the link is further set up to operate with load sharing, then .Fa local_addr and .Fa local_port @@ -433,7 +432,7 @@ Likewise, if .Fa remote_port is zero, this indicates to redirect packets originating from any remote port number. -Almost always, the remote port specification will be zero, but non-zero +The remote port specification will almost always be zero, but non-zero remote addresses can sometimes be useful for firewalling. If two calls to .Fn LibAliasRedirectPort @@ -485,9 +484,10 @@ is called to change the address after .Fn LibAliasRedirectAddr is called, a zero reference will track this change. .Pp -If the link is further set up to operate for a load sharing, then +If the link is further set up to operate with load sharing, then the .Fa local_addr -is ignored, and is selected dynamically from the server pool, as described in +argument is ignored, and is selected dynamically from the server pool, +as described in .Fn LibAliasAddServer below. .Pp @@ -542,12 +542,12 @@ up for Load Sharing using IP Network Add LSNAT operates as follows. A client attempts to access a server by using the server virtual address. The LSNAT router transparently redirects the request to one of the hosts -in server pool, selected using a real-time load sharing algorithm. +in the server pool, using a real-time load sharing algorithm. Multiple sessions may be initiated from the same client, and each session -could be directed to a different host based on load balance across server -pool hosts at the time. -If load share is desired for just a few specific services, the configuration -on LSNAT could be defined to restrict load share for just the services +could be directed to a different host based on the load balance across server +pool hosts when the sessions are initiated. +If load sharing is desired for just a few specific services, the configuration +on LSNAT could be defined to restrict load sharing to just the services desired. .Pp Currently, only the simplest selection algorithm is implemented, where a @@ -606,8 +606,8 @@ The parameter is the pointer returned by either of the redirection functions. If an invalid pointer is passed to .Fn LibAliasRedirectDelete , -then a program crash or unpredictable operation could result, so it is -necessary to be careful using this function. +then a program crash or unpredictable operation could result, so +care is needed when using this function. .Ed .Pp .Ft int @@ -714,7 +714,7 @@ access, or to restrict access to certain .Bd -ragged -offset indent This function specifies that any IP packet with protocol number of .Fa proto -from a given remote address to an alias address be +from a given remote address to an alias address will be redirected to a specified local address. .Pp If @@ -829,10 +829,12 @@ is the pointer to the packet to be de-al "struct in_addr alias_addr" "u_short src_port" "u_short dst_port" \ "int alias_param" "int link_type" .Bd -ragged -offset indent -This function adds new state to instance hash table. -Zero can be specified instead of dst_address and/or dst port. -This makes link partially specified dynamic. -However due to hashing method such links can be resolved on inbound (ext -> int) only. +This function adds new state to the instance hash table. +The dst_address and/or dst_port may be given as zero, which +introduces some dynamic character into the link, since +LibAliasSetAddress can change the address that is used. +However, in the current implementation, such links can only be used +for inbound (ext -> int) traffic. .Ed .Pp .Ft void @@ -1119,9 +1121,9 @@ SLIST_HEAD(dll_chain, dll) dll_chain ... .Ed .Pp .Va handler_chain -keep tracks of all the protocol handlers loaded, while +keeps track of all the protocol handlers loaded, while .Va ddl_chain -takes care of userland modules loaded. +tracks which userland modules are loaded. .Pp .Va handler_chain is composed of @@ -1143,12 +1145,12 @@ struct proto_handler { where: .Bl -inset .It Va pri -is the priority assigned to a protocol handler, lower +is the priority assigned to a protocol handler; lower priority is better. .It Va dir is the direction of packets: ingoing or outgoing. .It Va proto -says at which protocol this packet belongs: IP, TCP or UDP. +indicates to which protocol this packet belongs: IP, TCP or UDP. .It Va fingerprint points to the fingerprint function while protohandler points to the protocol handler function. @@ -1156,8 +1158,8 @@ to the protocol handler function. .Pp The .Va fingerprint -function has the double of scope of checking if the -incoming packet is found and if it belongs to any categories that this +function has the dual role of checking if the +incoming packet is found, and if it belongs to any categories that this module can handle. .Pp The @@ -1172,8 +1174,8 @@ When a packet enters if it meets a module hook, .Va handler_chain is searched to see if there is an handler that matches -this type of a packet (it checks protocol and direction of packet), then if -more than one handler is found, it starts with the module with +this type of a packet (it checks protocol and direction of packet). +Then, if more than one handler is found, it starts with the module with the lowest priority number: it calls the .Va fingerprint function and interprets the result. @@ -1211,8 +1213,8 @@ structure, then is called. The .Fn find_handler -function is responsible for walking out the handler -chain, it receives as input parameters: +function is responsible for walking the handler +chain; it receives as input parameters: .Bl -tag -width indent .It Fa IN direction @@ -1236,9 +1238,9 @@ supporting INcoming UDP packets. .Pp As was mentioned earlier, .Nm -in userland is a bit different, cause -care has to be taken of module handling too (avoiding duplicate load of -module, avoiding module with same name, etc.) so +in userland is a bit different, as +care must be taken in module handling as well (avoiding duplicate load of +modules, avoiding modules with same name, etc.) so .Va dll_chain was introduced. .Pp @@ -1252,9 +1254,8 @@ When an application calls .Nm first unloads all the loaded modules, then reloads all the modules listed in .Pa /etc/libalias.conf : -for every module loaded, a new entry to -.Va dll_chain -is added. +for every module loaded, a new entry is added to +.Va dll_chain . .Pp .Va dll_chain is composed of @@ -1291,8 +1292,8 @@ There is a module (called .Pa alias_dummy.[ch] ) in .Nm -that can be used as a skeleton for future work, here we analyse some parts of that -module. +that can be used as a skeleton for future work. +Here we analyse some parts of that module. From .Pa alias_dummy.c : .Bd -literal @@ -1305,7 +1306,7 @@ The variable is the .Dq "most important thing" in a module -cause it describes the handlers present and lets the outside world use +since it describes the handlers present and lets the outside world use it in an opaque way. .Pp It must ALWAYS be present in every module, and it MUST retain @@ -1348,7 +1349,7 @@ mod_handler(module_t mod, int type, void .Ed When running as KLD, .Fn mod_handler -register/deregister the module using +registers/deregisters the module using .Fn attach_handlers and .Fn detach_handlers , From owner-svn-src-head@FreeBSD.ORG Mon Jul 4 23:32:10 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 407381065673; Mon, 4 Jul 2011 23:32:10 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2EF558FC0C; Mon, 4 Jul 2011 23:32:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p64NWAgO038942; Mon, 4 Jul 2011 23:32:10 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p64NWAYj038940; Mon, 4 Jul 2011 23:32:10 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201107042332.p64NWAYj038940@svn.freebsd.org> From: Rick Macklem Date: Mon, 4 Jul 2011 23:32:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223774 - head/sys/fs/nfsclient X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2011 23:32:10 -0000 Author: rmacklem Date: Mon Jul 4 23:32:09 2011 New Revision: 223774 URL: http://svn.freebsd.org/changeset/base/223774 Log: The algorithm used by nfscl_getopen() could have resulted in multiple instances of the same lock_owner when a process both inherited an open file descriptor plus opened the same file itself. Since some NFSv4 servers cannot handle multiple instances of the same lock_owner string, this patch changes the algorithm used by nfscl_getopen() in the new NFSv4 client to keep that from happening. The new algorithm is simpler, since there is no longer any need to ascend the process's parentage tree because all NFSv4 Closes for a file are done at VOP_INACTIVE()/VOP_RECLAIM(), making the Opens indistinct w.r.t. use with Lock Ops. This problem was discovered at the recent NFSv4 interoperability Bakeathon. MFC after: 2 weeks Modified: head/sys/fs/nfsclient/nfs_clstate.c Modified: head/sys/fs/nfsclient/nfs_clstate.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clstate.c Mon Jul 4 23:00:26 2011 (r223773) +++ head/sys/fs/nfsclient/nfs_clstate.c Mon Jul 4 23:32:09 2011 (r223774) @@ -95,7 +95,7 @@ int nfscl_deleghighwater = NFSCLDELEGHIG static int nfscl_delegcnt = 0; static int nfscl_getopen(struct nfsclownerhead *, u_int8_t *, int, u_int8_t *, - NFSPROC_T *, u_int32_t, struct nfsclowner **, struct nfsclopen **); + u_int8_t *, u_int32_t, struct nfscllockowner **, struct nfsclopen **); static void nfscl_clrelease(struct nfsclclient *); static void nfscl_cleanclient(struct nfsclclient *); static void nfscl_expireclient(struct nfsclclient *, struct nfsmount *, @@ -521,25 +521,20 @@ nfscl_getstateid(vnode_t vp, u_int8_t *n * for a matching OpenOwner and use that. */ nfscl_filllockowner(p->td_proc, own, F_POSIX); - error = nfscl_getopen(&clp->nfsc_owner, nfhp, fhlen, NULL, p, - mode, NULL, &op); - if (error == 0) { - /* now look for a lockowner */ - LIST_FOREACH(lp, &op->nfso_lock, nfsl_list) { - if (!NFSBCMP(lp->nfsl_owner, own, - NFSV4CL_LOCKNAMELEN)) { - stateidp->seqid = - lp->nfsl_stateid.seqid; - stateidp->other[0] = - lp->nfsl_stateid.other[0]; - stateidp->other[1] = - lp->nfsl_stateid.other[1]; - stateidp->other[2] = - lp->nfsl_stateid.other[2]; - NFSUNLOCKCLSTATE(); - return (0); - } - } + lp = NULL; + error = nfscl_getopen(&clp->nfsc_owner, nfhp, fhlen, own, own, + mode, &lp, &op); + if (error == 0 && lp != NULL) { + stateidp->seqid = + lp->nfsl_stateid.seqid; + stateidp->other[0] = + lp->nfsl_stateid.other[0]; + stateidp->other[1] = + lp->nfsl_stateid.other[1]; + stateidp->other[2] = + lp->nfsl_stateid.other[2]; + NFSUNLOCKCLSTATE(); + return (0); } } if (op == NULL) { @@ -578,55 +573,74 @@ nfscl_getstateid(vnode_t vp, u_int8_t *n } /* - * Get an existing open. Search up the parentage tree for a match and - * return with the first one found. + * Search for a matching file, mode and, optionally, lockowner. */ static int nfscl_getopen(struct nfsclownerhead *ohp, u_int8_t *nfhp, int fhlen, - u_int8_t *rown, NFSPROC_T *p, u_int32_t mode, struct nfsclowner **owpp, - struct nfsclopen **opp) + u_int8_t *openown, u_int8_t *lockown, u_int32_t mode, + struct nfscllockowner **lpp, struct nfsclopen **opp) { - struct nfsclowner *owp = NULL; - struct nfsclopen *op; - NFSPROC_T *nproc; - u_int8_t own[NFSV4CL_LOCKNAMELEN], *ownp; + struct nfsclowner *owp; + struct nfsclopen *op, *rop, *rop2; + struct nfscllockowner *lp; + int keep_looping; - nproc = p; - op = NULL; - while (op == NULL && (nproc != NULL || rown != NULL)) { - if (nproc != NULL) { - nfscl_filllockowner(nproc->td_proc, own, F_POSIX); - ownp = own; - } else { - ownp = rown; - } - /* Search the client list */ - LIST_FOREACH(owp, ohp, nfsow_list) { - if (!NFSBCMP(owp->nfsow_owner, ownp, - NFSV4CL_LOCKNAMELEN)) - break; - } - if (owp != NULL) { - /* and look for the correct open */ - LIST_FOREACH(op, &owp->nfsow_open, nfso_list) { - if (op->nfso_fhlen == fhlen && - !NFSBCMP(op->nfso_fh, nfhp, fhlen) - && (op->nfso_mode & mode) == mode) { - break; + if (lpp != NULL) + *lpp = NULL; + /* + * rop will be set to the open to be returned. There are three + * variants of this, all for an open of the correct file: + * 1 - A match of lockown. + * 2 - A match of the openown, when no lockown match exists. + * 3 - A match for any open, if no openown or lockown match exists. + * Looking for #2 over #3 probably isn't necessary, but since + * RFC3530 is vague w.r.t. the relationship between openowners and + * lockowners, I think this is the safer way to go. + */ + rop = NULL; + rop2 = NULL; + keep_looping = 1; + /* Search the client list */ + owp = LIST_FIRST(ohp); + while (owp != NULL && keep_looping != 0) { + /* and look for the correct open */ + op = LIST_FIRST(&owp->nfsow_open); + while (op != NULL && keep_looping != 0) { + if (op->nfso_fhlen == fhlen && + !NFSBCMP(op->nfso_fh, nfhp, fhlen) + && (op->nfso_mode & mode) == mode) { + if (lpp != NULL) { + /* Now look for a matching lockowner. */ + LIST_FOREACH(lp, &op->nfso_lock, + nfsl_list) { + if (!NFSBCMP(lp->nfsl_owner, + lockown, + NFSV4CL_LOCKNAMELEN)) { + *lpp = lp; + rop = op; + keep_looping = 0; + break; + } + } } + if (rop == NULL && !NFSBCMP(owp->nfsow_owner, + openown, NFSV4CL_LOCKNAMELEN)) { + rop = op; + if (lpp == NULL) + keep_looping = 0; + } + if (rop2 == NULL) + rop2 = op; } + op = LIST_NEXT(op, nfso_list); } - if (rown != NULL) - break; - if (op == NULL) - nproc = nfscl_getparent(nproc); + owp = LIST_NEXT(owp, nfsow_list); } - if (op == NULL) { + if (rop == NULL) + rop = rop2; + if (rop == NULL) return (EBADF); - } - if (owpp) - *owpp = owp; - *opp = op; + *opp = rop; return (0); } @@ -891,16 +905,16 @@ nfscl_getbytelock(vnode_t vp, u_int64_t struct nfscldeleg *dp = NULL, *ldp = NULL; struct nfscllockownerhead *lhp = NULL; struct nfsnode *np; - u_int8_t own[NFSV4CL_LOCKNAMELEN], *ownp; + u_int8_t own[NFSV4CL_LOCKNAMELEN], *ownp, openown[NFSV4CL_LOCKNAMELEN]; + u_int8_t *openownp; int error = 0, ret, donelocally = 0; u_int32_t mode; - if (type == F_WRLCK) - mode = NFSV4OPEN_ACCESSWRITE; - else - mode = NFSV4OPEN_ACCESSREAD; + /* For Lock Ops, the open mode doesn't matter, so use 0 to match any. */ + mode = 0; np = VTONFS(vp); *lpp = NULL; + lp = NULL; *newonep = 0; *donelocallyp = 0; @@ -940,9 +954,12 @@ nfscl_getbytelock(vnode_t vp, u_int64_t op = NULL; if (recovery) { ownp = rownp; + openownp = ropenownp; } else { nfscl_filllockowner(id, own, flags); ownp = own; + nfscl_filllockowner(p->td_proc, openown, F_POSIX); + openownp = openown; } if (!recovery) { NFSLOCKCLSTATE(); @@ -961,13 +978,13 @@ nfscl_getbytelock(vnode_t vp, u_int64_t dp = NULL; } if (dp != NULL) { - /* Now, find the associated open to get the correct openowner */ + /* Now, find an open and maybe a lockowner. */ ret = nfscl_getopen(&dp->nfsdl_owner, np->n_fhp->nfh_fh, - np->n_fhp->nfh_len, NULL, p, mode, NULL, &op); + np->n_fhp->nfh_len, openownp, ownp, mode, NULL, &op); if (ret) ret = nfscl_getopen(&clp->nfsc_owner, - np->n_fhp->nfh_fh, np->n_fhp->nfh_len, NULL, p, - mode, NULL, &op); + np->n_fhp->nfh_fh, np->n_fhp->nfh_len, openownp, + ownp, mode, NULL, &op); if (!ret) { lhp = &dp->nfsdl_lock; TAILQ_REMOVE(&clp->nfsc_deleg, dp, nfsdl_list); @@ -980,16 +997,11 @@ nfscl_getbytelock(vnode_t vp, u_int64_t } if (!donelocally) { /* - * Get the related Open. + * Get the related Open and maybe lockowner. */ - if (recovery) - error = nfscl_getopen(&clp->nfsc_owner, - np->n_fhp->nfh_fh, np->n_fhp->nfh_len, ropenownp, - NULL, mode, NULL, &op); - else - error = nfscl_getopen(&clp->nfsc_owner, - np->n_fhp->nfh_fh, np->n_fhp->nfh_len, NULL, p, - mode, NULL, &op); + error = nfscl_getopen(&clp->nfsc_owner, + np->n_fhp->nfh_fh, np->n_fhp->nfh_len, openownp, + ownp, mode, &lp, &op); if (!error) lhp = &op->nfso_lock; } @@ -1010,10 +1022,11 @@ nfscl_getbytelock(vnode_t vp, u_int64_t /* * Ok, see if a lockowner exists and create one, as required. */ - LIST_FOREACH(lp, lhp, nfsl_list) { - if (!NFSBCMP(lp->nfsl_owner, ownp, NFSV4CL_LOCKNAMELEN)) - break; - } + if (lp == NULL) + LIST_FOREACH(lp, lhp, nfsl_list) { + if (!NFSBCMP(lp->nfsl_owner, ownp, NFSV4CL_LOCKNAMELEN)) + break; + } if (lp == NULL) { NFSBCOPY(ownp, nlp->nfsl_owner, NFSV4CL_LOCKNAMELEN); if (recovery) From owner-svn-src-head@FreeBSD.ORG Tue Jul 5 06:12:28 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EB1A1106564A; Tue, 5 Jul 2011 06:12:28 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DB0728FC0C; Tue, 5 Jul 2011 06:12:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p656CSia051064; Tue, 5 Jul 2011 06:12:28 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p656CSZ6051062; Tue, 5 Jul 2011 06:12:28 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201107050612.p656CSZ6051062@svn.freebsd.org> From: Mikolaj Golub Date: Tue, 5 Jul 2011 06:12:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223780 - head/sbin/hastd X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2011 06:12:29 -0000 Author: trociny Date: Tue Jul 5 06:12:28 2011 New Revision: 223780 URL: http://svn.freebsd.org/changeset/base/223780 Log: Remove useless initialization. Approved by: pjd (mentor) MFC after: 3 days Modified: head/sbin/hastd/control.c Modified: head/sbin/hastd/control.c ============================================================================== --- head/sbin/hastd/control.c Tue Jul 5 02:51:27 2011 (r223779) +++ head/sbin/hastd/control.c Tue Jul 5 06:12:28 2011 (r223780) @@ -155,8 +155,7 @@ control_status_worker(struct hast_resour const char *str; int error; - cnvin = cnvout = NULL; - error = 0; + cnvin = NULL; /* * Prepare and send command to worker process. From owner-svn-src-head@FreeBSD.ORG Tue Jul 5 08:00:57 2011 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 564DE106566B; Tue, 5 Jul 2011 08:00:57 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from mx0.hoeg.nl (mx0.hoeg.nl [IPv6:2a01:4f8:101:5343::aa]) by mx1.freebsd.org (Postfix) with ESMTP id E7E508FC16; Tue, 5 Jul 2011 08:00:56 +0000 (UTC) Received: by mx0.hoeg.nl (Postfix, from userid 1000) id AC0362A2928E; Tue, 5 Jul 2011 10:00:55 +0200 (CEST) Date: Tue, 5 Jul 2011 10:00:55 +0200 From: Ed Schouten To: Ulrich Spoerlein , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org Message-ID: <20110705080055.GW71453@hoeg.nl> References: <201107012045.p61Kju11005984@svn.freebsd.org> <20110704112437.GT71453@hoeg.nl> <20110704114312.GC8485@acme.spoerlein.net> <20110704114915.GV71453@hoeg.nl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="bE2XbrxqIoa/xW9+" Content-Disposition: inline In-Reply-To: <20110704114915.GV71453@hoeg.nl> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Subject: Re: svn commit: r223715 - head/contrib/gcc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2011 08:00:57 -0000 --bE2XbrxqIoa/xW9+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Ed Schouten , 20110704 13:49: > I could do another run at WARNS=3D1 if you like. Done. Everything still builds. --=20 Ed Schouten WWW: http://80386.nl/ --bE2XbrxqIoa/xW9+ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (FreeBSD) iQIcBAEBAgAGBQJOEsS3AAoJEG5e2P40kaK7wxwP/092tBPbE7se0xniFIE2igFc FLeNPXf6sBKjCNiA2xJk910ZE5DIBKOUe/SKXtHLpXOSb7/dY2Nz1k7+CSpviU8t zBOtpHafgSsjcJ17XpDM6Sg0WrWB6+taTw0DhvN5PKPqZizzr600N7R01r8/Y8kB grseOYzgju5RxOanMIpNMAw7FHFi7MiwpcyJAqSH2kU/wWe+cfJvWraVpP4k4Zl6 Kx2CfjlZN38D8mUgxKM3OSzYFgi71OxpRkc7vcugVpkyRHUppUlFn1JxL5zIug1R dGyE/rBOt7Hv0cFg5vntn7KFOhw9SgLPwOldTup5RNTuNIStE8Iv9mSHGfT07Wyz IB4ZesvNu222OeMtbk1v5JHIp/aOQoK1D/9DUkGIDsu3coygaPxXMHgT2V86EaBk VNP4ZsDc/8EftFBTcqpxLfZvAR8S1vNDNBuqMiInETbRuYDFKjLrTyX0oGOjVLIJ 1AufcCW9+0iOg8S2rPPU2DcYNxGOW614LS0MorO0sn9ckpdaYrteGiD5Wmo95hdo zCifV5LBZ1Vlg5J7sgiHJurNTeyhQfs+iRIXAsNiidkBKc4Q2ckvgMm7/35keCOD 8hXUZ/YImfVFBy8GqH2jbMAzOAc6XCZFXPW3NRcQ7DZbYd24hE32XJlUWKOfiLdr lJNtv8GTmsRxrYWM2Kmu =YoW9 -----END PGP SIGNATURE----- --bE2XbrxqIoa/xW9+-- From owner-svn-src-head@FreeBSD.ORG Tue Jul 5 13:45:10 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 87691106566B; Tue, 5 Jul 2011 13:45:10 +0000 (UTC) (envelope-from jonathan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 76AF38FC0C; Tue, 5 Jul 2011 13:45:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p65DjAQF070859; Tue, 5 Jul 2011 13:45:10 GMT (envelope-from jonathan@svn.freebsd.org) Received: (from jonathan@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p65DjAkY070856; Tue, 5 Jul 2011 13:45:10 GMT (envelope-from jonathan@svn.freebsd.org) Message-Id: <201107051345.p65DjAkY070856@svn.freebsd.org> From: Jonathan Anderson Date: Tue, 5 Jul 2011 13:45:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223785 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2011 13:45:10 -0000 Author: jonathan Date: Tue Jul 5 13:45:10 2011 New Revision: 223785 URL: http://svn.freebsd.org/changeset/base/223785 Log: Rework _fget to accept capability parameters. This new version of _fget() requires new parameters: - cap_rights_t needrights the rights that we expect the capability's rights mask to include (e.g. CAP_READ if we are going to read from the file) - cap_rights_t *haverights used to return the capability's rights mask (ignored if NULL) - u_char *maxprotp the maximum mmap() rights (e.g. VM_PROT_READ) that can be permitted (only used if we are going to mmap the file; ignored if NULL) - int fget_flags FGET_GETCAP if we want to return the capability itself, rather than the underlying object which it wraps Approved by: mentor (rwatson), re (Capsicum blanket) Sponsored by: Google Inc Modified: head/sys/kern/kern_descrip.c head/sys/sys/file.h Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Tue Jul 5 10:37:17 2011 (r223784) +++ head/sys/kern/kern_descrip.c Tue Jul 5 13:45:10 2011 (r223785) @@ -37,6 +37,7 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_capsicum.h" #include "opt_compat.h" #include "opt_ddb.h" #include "opt_ktrace.h" @@ -44,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -91,6 +93,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include @@ -2259,15 +2262,27 @@ fget_unlocked(struct filedesc *fdp, int * If the descriptor doesn't exist or doesn't match 'flags', EBADF is * returned. * + * If the FGET_GETCAP flag is set, the capability itself will be returned. + * Calling _fget() with FGET_GETCAP on a non-capability will return EINVAL. + * Otherwise, if the file is a capability, its rights will be checked against + * the capability rights mask, and if successful, the object will be unwrapped. + * * If an error occured the non-zero error is returned and *fpp is set to * NULL. Otherwise *fpp is held and set and zero is returned. Caller is * responsible for fdrop(). */ +#define FGET_GETCAP 0x00000001 static __inline int -_fget(struct thread *td, int fd, struct file **fpp, int flags) +_fget(struct thread *td, int fd, struct file **fpp, int flags, + cap_rights_t needrights, cap_rights_t *haverights, u_char *maxprotp, + int fget_flags) { struct filedesc *fdp; struct file *fp; +#ifdef CAPABILITIES + struct file *fp_fromcap; + int error; +#endif *fpp = NULL; if (td == NULL || (fdp = td->td_proc->p_fd) == NULL) @@ -2278,6 +2293,47 @@ _fget(struct thread *td, int fd, struct fdrop(fp, td); return (EBADF); } + +#ifdef CAPABILITIES + /* + * If a capability has been requested, return the capability directly. + * Otherwise, check capability rights, extract the underlying object, + * and check its access flags. + */ + if (fget_flags & FGET_GETCAP) { + if (fp->f_type != DTYPE_CAPABILITY) { + fdrop(fp, td); + return (EINVAL); + } + } else { + if (maxprotp == NULL) + error = cap_funwrap(fp, needrights, &fp_fromcap); + else + error = cap_funwrap_mmap(fp, needrights, maxprotp, + &fp_fromcap); + if (error) { + fdrop(fp, td); + return (error); + } + + /* + * If we've unwrapped a file, drop the original capability + * and hold the new descriptor. fp after this point refers to + * the actual (unwrapped) object, not the capability. + */ + if (fp != fp_fromcap) { + fhold(fp_fromcap); + fdrop(fp, td); + fp = fp_fromcap; + } + } +#else /* !CAPABILITIES */ + KASSERT(fp->f_type != DTYPE_CAPABILITY, + ("%s: saw capability", __func__)); + if (maxprotp != NULL) + *maxprotp = VM_PROT_ALL; +#endif /* CAPABILITIES */ + /* * FREAD and FWRITE failure return EBADF as per POSIX. * @@ -2296,23 +2352,36 @@ int fget(struct thread *td, int fd, struct file **fpp) { - return(_fget(td, fd, fpp, 0)); + return(_fget(td, fd, fpp, 0, 0, NULL, NULL, 0)); } int fget_read(struct thread *td, int fd, struct file **fpp) { - return(_fget(td, fd, fpp, FREAD)); + return(_fget(td, fd, fpp, FREAD, 0, NULL, NULL, 0)); } int fget_write(struct thread *td, int fd, struct file **fpp) { - return(_fget(td, fd, fpp, FWRITE)); + return(_fget(td, fd, fpp, FWRITE, 0, NULL, NULL, 0)); +} + +/* + * Unlike the other fget() calls, which will accept and check capability rights + * but never return capabilities, fgetcap() returns the capability but doesn't + * check capability rights. + */ +int +fgetcap(struct thread *td, int fd, struct file **fpp) +{ + + return (_fget(td, fd, fpp, 0, 0, NULL, NULL, FGET_GETCAP)); } + /* * Like fget() but loads the underlying vnode, or returns an error if the * descriptor does not represent a vnode. Note that pipes use vnodes but @@ -2327,7 +2396,7 @@ _fgetvp(struct thread *td, int fd, struc int error; *vpp = NULL; - if ((error = _fget(td, fd, &fp, flags)) != 0) + if ((error = _fget(td, fd, &fp, flags, 0, NULL, NULL, 0)) != 0) return (error); if (fp->f_vnode == NULL) { error = EINVAL; @@ -2383,7 +2452,7 @@ fgetsock(struct thread *td, int fd, stru *spp = NULL; if (fflagp != NULL) *fflagp = 0; - if ((error = _fget(td, fd, &fp, 0)) != 0) + if ((error = _fget(td, fd, &fp, 0, 0, NULL, NULL, 0)) != 0) return (error); if (fp->f_type != DTYPE_SOCKET) { error = ENOTSOCK; Modified: head/sys/sys/file.h ============================================================================== --- head/sys/sys/file.h Tue Jul 5 10:37:17 2011 (r223784) +++ head/sys/sys/file.h Tue Jul 5 13:45:10 2011 (r223785) @@ -179,6 +179,7 @@ extern volatile int openfiles; /* actual int fget(struct thread *td, int fd, struct file **fpp); int fget_read(struct thread *td, int fd, struct file **fpp); int fget_write(struct thread *td, int fd, struct file **fpp); +int fgetcap(struct thread *td, int fd, struct file **fpp); int _fdrop(struct file *fp, struct thread *td); /* From owner-svn-src-head@FreeBSD.ORG Tue Jul 5 14:12:48 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6C103106566B; Tue, 5 Jul 2011 14:12:48 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5CE288FC16; Tue, 5 Jul 2011 14:12:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p65ECmWt072516; Tue, 5 Jul 2011 14:12:48 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p65ECmhE072514; Tue, 5 Jul 2011 14:12:48 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201107051412.p65ECmhE072514@svn.freebsd.org> From: Ed Schouten Date: Tue, 5 Jul 2011 14:12:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223786 - head/usr.bin/w X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2011 14:12:48 -0000 Author: ed Date: Tue Jul 5 14:12:48 2011 New Revision: 223786 URL: http://svn.freebsd.org/changeset/base/223786 Log: Only print entries for which ut_host points to a character device. Now that we use utmpx, we more often have entries for which the ut_line is left blank. To prevent us from returning struct stat for "/dev/", check that the resulting stat structure belongs to a character device. Modified: head/usr.bin/w/w.c Modified: head/usr.bin/w/w.c ============================================================================== --- head/usr.bin/w/w.c Tue Jul 5 13:45:10 2011 (r223785) +++ head/usr.bin/w/w.c Tue Jul 5 14:12:48 2011 (r223786) @@ -497,7 +497,7 @@ ttystat(char *line) char ttybuf[MAXPATHLEN]; (void)snprintf(ttybuf, sizeof(ttybuf), "%s%s", _PATH_DEV, line); - if (stat(ttybuf, &sb) == 0) { + if (stat(ttybuf, &sb) == 0 && S_ISCHR(sb.st_mode)) { return (&sb); } else return (NULL); From owner-svn-src-head@FreeBSD.ORG Tue Jul 5 14:48:40 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 14B32106564A; Tue, 5 Jul 2011 14:48:40 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 038148FC19; Tue, 5 Jul 2011 14:48:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p65EmdqQ073576; Tue, 5 Jul 2011 14:48:39 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p65EmdUv073572; Tue, 5 Jul 2011 14:48:39 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201107051448.p65EmdUv073572@svn.freebsd.org> From: Gleb Smirnoff Date: Tue, 5 Jul 2011 14:48:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223787 - head/sys/netgraph/netflow X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2011 14:48:40 -0000 Author: glebius Date: Tue Jul 5 14:48:39 2011 New Revision: 223787 URL: http://svn.freebsd.org/changeset/base/223787 Log: o Eliminate flow6_hash_entry in favor of flow_hash_entry. We don't need a separate struct to start a slist of semi-opaque structs. This makes some code more compact. o Rewrite ng_netflow_flow_show() and its API/ABI: - Support for IPv6 is added. - Request and response now use same struct. Structure specifies version (6 or 4), index of last retrieved hash, and also index of last retrieved entry in the hash entry. Modified: head/sys/netgraph/netflow/netflow.c head/sys/netgraph/netflow/ng_netflow.c head/sys/netgraph/netflow/ng_netflow.h Modified: head/sys/netgraph/netflow/netflow.c ============================================================================== --- head/sys/netgraph/netflow/netflow.c Tue Jul 5 14:12:48 2011 (r223786) +++ head/sys/netgraph/netflow/netflow.c Tue Jul 5 14:48:39 2011 (r223787) @@ -100,7 +100,7 @@ static int export_send(priv_p, fib_expor static int hash_insert(priv_p, struct flow_hash_entry *, struct flow_rec *, int, uint8_t); #ifdef INET6 -static int hash6_insert(priv_p, struct flow6_hash_entry *, struct flow6_rec *, int, uint8_t); +static int hash6_insert(priv_p, struct flow_hash_entry *, struct flow6_rec *, int, uint8_t); #endif static __inline void expire_flow(priv_p, fib_export_p, struct flow_entry *, int); @@ -412,7 +412,7 @@ hash_insert(priv_p priv, struct flow_has bitcount32((x).__u6_addr.__u6_addr32[3]) /* XXX: Do we need inline here ? */ static __inline int -hash6_insert(priv_p priv, struct flow6_hash_entry *hsh6, struct flow6_rec *r, +hash6_insert(priv_p priv, struct flow_hash_entry *hsh6, struct flow6_rec *r, int plen, uint8_t tcp_flags) { struct flow6_entry *fle6; @@ -491,7 +491,7 @@ hash6_insert(priv_p priv, struct flow6_h } /* Push new flow at the and of hash. */ - TAILQ_INSERT_TAIL(&hsh6->head, fle6, fle6_hash); + TAILQ_INSERT_TAIL(&hsh6->head, (struct flow_entry *)fle6, fle_hash); return (0); } @@ -507,9 +507,6 @@ void ng_netflow_cache_init(priv_p priv) { struct flow_hash_entry *hsh; -#ifdef INET6 - struct flow6_hash_entry *hsh6; -#endif int i; /* Initialize cache UMA zone. */ @@ -534,13 +531,13 @@ ng_netflow_cache_init(priv_p priv) #ifdef INET6 /* Allocate hash. */ - priv->hash6 = malloc(NBUCKETS * sizeof(struct flow6_hash_entry), + priv->hash6 = malloc(NBUCKETS * sizeof(struct flow_hash_entry), M_NETFLOW_HASH, M_WAITOK | M_ZERO); /* Initialize hash. */ - for (i = 0, hsh6 = priv->hash6; i < NBUCKETS; i++, hsh6++) { - mtx_init(&hsh6->mtx, "hash mutex", NULL, MTX_DEF); - TAILQ_INIT(&hsh6->head); + for (i = 0, hsh = priv->hash6; i < NBUCKETS; i++, hsh++) { + mtx_init(&hsh->mtx, "hash mutex", NULL, MTX_DEF); + TAILQ_INIT(&hsh->head); } #endif @@ -588,10 +585,6 @@ ng_netflow_cache_flush(priv_p priv) { struct flow_entry *fle, *fle1; struct flow_hash_entry *hsh; -#ifdef INET6 - struct flow6_entry *fle6, *fle61; - struct flow6_hash_entry *hsh6; -#endif struct netflow_export_item exp; fib_export_p fe; int i; @@ -610,11 +603,11 @@ ng_netflow_cache_flush(priv_p priv) expire_flow(priv, fe, fle, NG_QUEUE); } #ifdef INET6 - for (hsh6 = priv->hash6, i = 0; i < NBUCKETS; hsh6++, i++) - TAILQ_FOREACH_SAFE(fle6, &hsh6->head, fle6_hash, fle61) { - TAILQ_REMOVE(&hsh6->head, fle6, fle6_hash); - fe = priv_to_fib(priv, fle6->f.r.fib); - expire_flow(priv, fe, (struct flow_entry *)fle6, NG_QUEUE); + for (hsh = priv->hash6, i = 0; i < NBUCKETS; hsh++, i++) + TAILQ_FOREACH_SAFE(fle, &hsh->head, fle_hash, fle1) { + TAILQ_REMOVE(&hsh->head, fle, fle_hash); + fe = priv_to_fib(priv, fle->f.r.fib); + expire_flow(priv, fe, fle, NG_QUEUE); } #endif @@ -629,8 +622,8 @@ ng_netflow_cache_flush(priv_p priv) #ifdef INET6 uma_zdestroy(priv->zone6); /* Destroy hash mutexes. */ - for (i = 0, hsh6 = priv->hash6; i < NBUCKETS; i++, hsh6++) - mtx_destroy(&hsh6->mtx); + for (i = 0, hsh = priv->hash6; i < NBUCKETS; i++, hsh++) + mtx_destroy(&hsh->mtx); /* Free hash memory. */ if (priv->hash6 != NULL) @@ -790,8 +783,9 @@ int ng_netflow_flow6_add(priv_p priv, fib_export_p fe, struct ip6_hdr *ip6, caddr_t upper_ptr, uint8_t upper_proto, uint8_t is_frag, unsigned int src_if_index) { - register struct flow6_entry *fle6 = NULL, *fle61; - struct flow6_hash_entry *hsh6; + register struct flow_entry *fle = NULL, *fle1; + register struct flow6_entry *fle6; + struct flow_hash_entry *hsh; struct flow6_rec r; int plen; int error = 0; @@ -846,9 +840,9 @@ ng_netflow_flow6_add(priv_p priv, fib_ex priv->info.nfinfo_bytes6 += plen; /* Find hash slot. */ - hsh6 = &priv->hash6[ip6_hash(&r)]; + hsh = &priv->hash6[ip6_hash(&r)]; - mtx_lock(&hsh6->mtx); + mtx_lock(&hsh->mtx); /* * Go through hash and find our entry. If we encounter an @@ -856,19 +850,22 @@ ng_netflow_flow6_add(priv_p priv, fib_ex * search since most active entries are first, and most * searches are done on most active entries. */ - TAILQ_FOREACH_REVERSE_SAFE(fle6, &hsh6->head, f6head, fle6_hash, fle61) { - if (fle6->f.version != IP6VERSION) + TAILQ_FOREACH_REVERSE_SAFE(fle, &hsh->head, fhead, fle_hash, fle1) { + if (fle->f.version != IP6VERSION) continue; + fle6 = (struct flow6_entry *)fle; if (bcmp(&r, &fle6->f.r, sizeof(struct flow6_rec)) == 0) break; if ((INACTIVE(fle6) && SMALL(fle6)) || AGED(fle6)) { - TAILQ_REMOVE(&hsh6->head, fle6, fle6_hash); - expire_flow(priv, priv_to_fib(priv, fle6->f.r.fib), (struct flow_entry *)fle6, NG_QUEUE); + TAILQ_REMOVE(&hsh->head, fle, fle_hash); + expire_flow(priv, priv_to_fib(priv, fle->f.r.fib), fle, + NG_QUEUE); atomic_add_32(&priv->info.nfinfo_act_exp, 1); } } - if (fle6 != NULL) { /* An existent entry. */ + if (fle != NULL) { /* An existent entry. */ + fle6 = (struct flow6_entry *)fle; fle6->f.bytes += plen; fle6->f.packets ++; @@ -883,8 +880,9 @@ ng_netflow_flow6_add(priv_p priv, fib_ex */ if (tcp_flags & TH_FIN || tcp_flags & TH_RST || AGED(fle6) || (fle6->f.bytes >= (CNTR_MAX - IF_MAXMTU)) ) { - TAILQ_REMOVE(&hsh6->head, fle6, fle6_hash); - expire_flow(priv, priv_to_fib(priv, fle6->f.r.fib), (struct flow_entry *)fle6, NG_QUEUE); + TAILQ_REMOVE(&hsh->head, fle, fle_hash); + expire_flow(priv, priv_to_fib(priv, fle->f.r.fib), fle, + NG_QUEUE); atomic_add_32(&priv->info.nfinfo_act_exp, 1); } else { /* @@ -892,15 +890,15 @@ ng_netflow_flow6_add(priv_p priv, fib_ex * if it isn't there already. Next search will * locate it quicker. */ - if (fle6 != TAILQ_LAST(&hsh6->head, f6head)) { - TAILQ_REMOVE(&hsh6->head, fle6, fle6_hash); - TAILQ_INSERT_TAIL(&hsh6->head, fle6, fle6_hash); + if (fle != TAILQ_LAST(&hsh->head, fhead)) { + TAILQ_REMOVE(&hsh->head, fle, fle_hash); + TAILQ_INSERT_TAIL(&hsh->head, fle, fle_hash); } } } else /* A new flow entry. */ - error = hash6_insert(priv, hsh6, &r, plen, tcp_flags); + error = hash6_insert(priv, hsh, &r, plen, tcp_flags); - mtx_unlock(&hsh6->mtx); + mtx_unlock(&hsh->mtx); return (error); } @@ -910,64 +908,107 @@ ng_netflow_flow6_add(priv_p priv, fib_ex * Return records from cache to userland. * * TODO: matching particular IP should be done in kernel, here. - * XXX: IPv6 flows will return random data */ int -ng_netflow_flow_show(priv_p priv, uint32_t last, struct ng_mesg *resp) +ng_netflow_flow_show(priv_p priv, struct ngnf_show_header *req, +struct ngnf_show_header *resp) { struct flow_hash_entry *hsh; struct flow_entry *fle; - struct ngnf_flows *data; - int i; + struct flow_entry_data *data = (struct flow_entry_data *)(resp + 1); +#ifdef INET6 + struct flow6_entry_data *data6 = (struct flow6_entry_data *)(resp + 1); +#endif + int i, max; - data = (struct ngnf_flows *)resp->data; - data->last = 0; - data->nentries = 0; - - /* Check if this is a first run */ - if (last == 0) { - hsh = priv->hash; - i = 0; - } else { - if (last > NBUCKETS-1) - return (EINVAL); - hsh = priv->hash + last; - i = last; - } + i = req->hash_id; + if (i > NBUCKETS-1) + return (EINVAL); + +#ifdef INET6 + if (req->version == 6) { + resp->version = 6; + hsh = priv->hash6 + i; + max = NREC6_AT_ONCE; + } else +#endif + if (req->version == 4) { + resp->version = 4; + hsh = priv->hash + i; + max = NREC_AT_ONCE; + } else + return (EINVAL); /* * We will transfer not more than NREC_AT_ONCE. More data * will come in next message. - * We send current hash index to userland, and userland should - * return it back to us. Then, we will restart with new entry. + * We send current hash index and current record number in list + * to userland, and userland should return it back to us. + * Then, we will restart with new entry. * - * The resulting cache snapshot is inaccurate for the - * following reasons: - * - we skip locked hash entries - * - we bail out, if someone wants our entry - * - we skip rest of entry, when hit NREC_AT_ONCE + * The resulting cache snapshot can be inaccurate if flow expiration + * is taking place on hash item between userland data requests for + * this hash item id. */ + resp->nentries = 0; for (; i < NBUCKETS; hsh++, i++) { - if (mtx_trylock(&hsh->mtx) == 0) - continue; + int list_id; + + if (mtx_trylock(&hsh->mtx) == 0) { + /* + * Requested hash index is not available, + * relay decision to skip or re-request data + * to userland. + */ + resp->hash_id = i; + resp->list_id = 0; + return (0); + } + list_id = 0; TAILQ_FOREACH(fle, &hsh->head, fle_hash) { - if (hsh->mtx.mtx_lock & MTX_CONTESTED) - break; + if (hsh->mtx.mtx_lock & MTX_CONTESTED) { + resp->hash_id = i; + resp->list_id = list_id; + return (0); + } + + list_id++; + /* Search for particular record in list. */ + if (req->list_id > 0) { + if (list_id < req->list_id) + continue; - bcopy(&fle->f, &(data->entries[data->nentries]), - sizeof(fle->f)); - data->nentries++; - if (data->nentries == NREC_AT_ONCE) { - mtx_unlock(&hsh->mtx); - if (++i < NBUCKETS) - data->last = i; + /* Requested list position found. */ + req->list_id = 0; + } +#ifdef INET6 + if (req->version == 6) { + struct flow6_entry *fle6; + + fle6 = (struct flow6_entry *)fle; + bcopy(&fle6->f, data6 + resp->nentries, + sizeof(fle6->f)); + } else +#endif + bcopy(&fle->f, data + resp->nentries, + sizeof(fle->f)); + resp->nentries++; + if (resp->nentries == max) { + resp->hash_id = i; + /* + * If it was the last item in list + * we simply skip to next hash_id. + */ + resp->list_id = list_id + 1; return (0); } } mtx_unlock(&hsh->mtx); } + resp->hash_id = resp->list_id = 0; + return (0); } @@ -1057,10 +1098,6 @@ ng_netflow_expire(void *arg) { struct flow_entry *fle, *fle1; struct flow_hash_entry *hsh; -#ifdef INET6 - struct flow6_entry *fle6, *fle61; - struct flow6_hash_entry *hsh6; -#endif priv_p priv = (priv_p )arg; uint32_t used; int i; @@ -1103,20 +1140,23 @@ ng_netflow_expire(void *arg) } #ifdef INET6 - for (hsh6 = priv->hash6, i = 0; i < NBUCKETS; hsh6++, i++) { + for (hsh = priv->hash6, i = 0; i < NBUCKETS; hsh++, i++) { + struct flow6_entry *fle6; + /* * Skip entries, that are already being worked on. */ - if (mtx_trylock(&hsh6->mtx) == 0) + if (mtx_trylock(&hsh->mtx) == 0) continue; used = atomic_load_acq_32(&priv->info.nfinfo_used6); - TAILQ_FOREACH_SAFE(fle6, &hsh6->head, fle6_hash, fle61) { + TAILQ_FOREACH_SAFE(fle, &hsh->head, fle_hash, fle1) { + fle6 = (struct flow6_entry *)fle; /* * Interrupt thread wants this entry! * Quick! Quick! Bail out! */ - if (hsh6->mtx.mtx_lock & MTX_CONTESTED) + if (hsh->mtx.mtx_lock & MTX_CONTESTED) break; /* @@ -1128,13 +1168,14 @@ ng_netflow_expire(void *arg) if ((INACTIVE(fle6) && (SMALL(fle6) || (used > (NBUCKETS*2)))) || AGED(fle6)) { - TAILQ_REMOVE(&hsh6->head, fle6, fle6_hash); - expire_flow(priv, priv_to_fib(priv, fle6->f.r.fib), (struct flow_entry *)fle6, NG_NOFLAGS); + TAILQ_REMOVE(&hsh->head, fle, fle_hash); + expire_flow(priv, priv_to_fib(priv, + fle->f.r.fib), fle, NG_NOFLAGS); used--; atomic_add_32(&priv->info.nfinfo_inact_exp, 1); } } - mtx_unlock(&hsh6->mtx); + mtx_unlock(&hsh->mtx); } #endif Modified: head/sys/netgraph/netflow/ng_netflow.c ============================================================================== --- head/sys/netgraph/netflow/ng_netflow.c Tue Jul 5 14:12:48 2011 (r223786) +++ head/sys/netgraph/netflow/ng_netflow.c Tue Jul 5 14:48:39 2011 (r223787) @@ -504,19 +504,20 @@ ng_netflow_rcvmsg (node_p node, item_p i } case NGM_NETFLOW_SHOW: { - uint32_t *last; - - if (msg->header.arglen != sizeof(uint32_t)) + if (msg->header.arglen != sizeof(struct ngnf_show_header)) ERROUT(EINVAL); - last = (uint32_t *)msg->data; - NG_MKRESPONSE(resp, msg, NGRESP_SIZE, M_NOWAIT); if (!resp) ERROUT(ENOMEM); - error = ng_netflow_flow_show(priv, *last, resp); + error = ng_netflow_flow_show(priv, + (struct ngnf_show_header *)msg->data, + (struct ngnf_show_header *)resp->data); + + if (error) + NG_FREE_MSG(resp); break; } Modified: head/sys/netgraph/netflow/ng_netflow.h ============================================================================== --- head/sys/netgraph/netflow/ng_netflow.h Tue Jul 5 14:12:48 2011 (r223786) +++ head/sys/netgraph/netflow/ng_netflow.h Tue Jul 5 14:48:39 2011 (r223787) @@ -33,7 +33,7 @@ #define _NG_NETFLOW_H_ #define NG_NETFLOW_NODE_TYPE "netflow" -#define NGM_NETFLOW_COOKIE 1299079728 +#define NGM_NETFLOW_COOKIE 1309868867 #define NG_NETFLOW_MAXIFACES USHRT_MAX @@ -133,6 +133,19 @@ struct ng_netflow_setmtu { uint16_t mtu; /* MTU for packet */ }; +/* This structure is used in NGM_NETFLOW_SHOW request/responce */ +struct ngnf_show_header { + u_char version; /* IPv4 or IPv6 */ + uint32_t hash_id; /* current hash index */ + uint32_t list_id; /* current record number in given hash */ + uint32_t nentries; /* number of records in response */ +}; + +/* XXXGL + * Somewhere flow_rec6 is casted to flow_rec, and flow6_entry_data is + * casted to flow_entry_data. After casting, fle->r.fib is accessed. + * So beginning of these structs up to fib should be kept common. + */ /* This is unique data, which identifies flow */ struct flow_rec { @@ -233,29 +246,24 @@ struct flow6_entry_data { * without overflowing socket receive buffer */ #define NREC_AT_ONCE 1000 -#define NGRESP_SIZE (sizeof(struct ngnf_flows) + (NREC_AT_ONCE * \ +#define NREC6_AT_ONCE (NREC_AT_ONCE * sizeof(struct flow_entry_data) / \ + sizeof(struct flow6_entry_data)) +#define NGRESP_SIZE (sizeof(struct ngnf_show_header) + (NREC_AT_ONCE * \ sizeof(struct flow_entry_data))) #define SORCVBUF_SIZE (NGRESP_SIZE + 2 * sizeof(struct ng_mesg)) -/* This struct is returned to userland, when "show cache ip flow" */ -struct ngnf_flows { - uint32_t nentries; - uint32_t last; - struct flow_entry_data entries[0]; -}; - /* Everything below is for kernel */ #ifdef _KERNEL struct flow_entry { - struct flow_entry_data f; TAILQ_ENTRY(flow_entry) fle_hash; /* entries in hash slot */ + struct flow_entry_data f; }; struct flow6_entry { + TAILQ_ENTRY(flow_entry) fle_hash; /* entries in hash slot */ struct flow6_entry_data f; - TAILQ_ENTRY(flow6_entry) fle6_hash; /* entries in hash slot */ }; /* Parsing declarations */ @@ -402,7 +410,7 @@ struct netflow { /* IPv6 support */ #ifdef INET6 uma_zone_t zone6; - struct flow6_hash_entry *hash6; + struct flow_hash_entry *hash6; #endif /* Multiple FIB support */ fib_export_p fib_data[RT_NUMFIBS]; /* array of pointers to fib-specific data */ @@ -430,11 +438,6 @@ struct flow_hash_entry { TAILQ_HEAD(fhead, flow_entry) head; }; -struct flow6_hash_entry { - struct mtx mtx; - TAILQ_HEAD(f6head, flow6_entry) head; -}; - #define ERROUT(x) { error = (x); goto done; } #define MTAG_NETFLOW 1221656444 @@ -465,7 +468,7 @@ void ng_netflow_copyinfo(priv_p, struct timeout_t ng_netflow_expire; int ng_netflow_flow_add(priv_p, fib_export_p, struct ip *, caddr_t, uint8_t, uint8_t, unsigned int); int ng_netflow_flow6_add(priv_p, fib_export_p, struct ip6_hdr *, caddr_t , uint8_t, uint8_t, unsigned int); -int ng_netflow_flow_show(priv_p, uint32_t last, struct ng_mesg *); +int ng_netflow_flow_show(priv_p, struct ngnf_show_header *req, struct ngnf_show_header *resp); void ng_netflow_v9_cache_init(priv_p); void ng_netflow_v9_cache_flush(priv_p); From owner-svn-src-head@FreeBSD.ORG Tue Jul 5 14:50:07 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 49891106564A; Tue, 5 Jul 2011 14:50:07 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 29E858FC0C; Tue, 5 Jul 2011 14:50:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p65Eo73a073671; Tue, 5 Jul 2011 14:50:07 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p65Eo7ah073669; Tue, 5 Jul 2011 14:50:07 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201107051450.p65Eo7ah073669@svn.freebsd.org> From: Gleb Smirnoff Date: Tue, 5 Jul 2011 14:50:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223788 - head/usr.sbin/flowctl X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2011 14:50:07 -0000 Author: glebius Date: Tue Jul 5 14:50:06 2011 New Revision: 223788 URL: http://svn.freebsd.org/changeset/base/223788 Log: Rewrite the flowctl utility to add it support for displaying both IPv4 and IPv4 flows. Modified: head/usr.sbin/flowctl/Makefile head/usr.sbin/flowctl/flowctl.c Modified: head/usr.sbin/flowctl/Makefile ============================================================================== --- head/usr.sbin/flowctl/Makefile Tue Jul 5 14:48:39 2011 (r223787) +++ head/usr.sbin/flowctl/Makefile Tue Jul 5 14:50:06 2011 (r223788) @@ -2,6 +2,8 @@ # $FreeBSD$ # +.include + PROG= flowctl MAN= flowctl.8 @@ -9,4 +11,10 @@ WARNS?= 2 DPADD= ${LIBNETGRAPH} LDADD= -lnetgraph +.if ${MK_INET6_SUPPORT} != "no" +CFLAGS+= -DINET6 +.endif + +CFLAGS+= -I. + .include Modified: head/usr.sbin/flowctl/flowctl.c ============================================================================== --- head/usr.sbin/flowctl/flowctl.c Tue Jul 5 14:48:39 2011 (r223787) +++ head/usr.sbin/flowctl/flowctl.c Tue Jul 5 14:50:06 2011 (r223788) @@ -46,6 +46,7 @@ static const char rcs_id[] = #include #include #include +#include #include #include @@ -54,21 +55,32 @@ static const char rcs_id[] = #define CISCO_SH_FLOW_HEADER "SrcIf SrcIPaddress DstIf DstIPaddress Pr SrcP DstP Pkts\n" #define CISCO_SH_FLOW "%-13s %-15s %-13s %-15s %2u %4.4x %4.4x %6lu\n" +#define CISCO_SH_FLOW6_HEADER "SrcIf SrcIPaddress DstIf DstIPaddress Pr SrcP DstP Pkts\n" +#define CISCO_SH_FLOW6 "%-13s %-30s %-13s %-30s %2u %4.4x %4.4x %6lu\n" + #define CISCO_SH_VERB_FLOW_HEADER "SrcIf SrcIPaddress DstIf DstIPaddress Pr TOS Flgs Pkts\n" \ "Port Msk AS Port Msk AS NextHop B/Pk Active\n" #define CISCO_SH_VERB_FLOW "%-14s %-15s %-14s %-15s %2u %3x %4x %6lu\n" \ "%4.4x /%-2u %-5u %4.4x /%-2u %-5u %-15s %9u %8u\n\n" -static int flow_cache_print(struct ngnf_flows *recs); -static int flow_cache_print_verbose(struct ngnf_flows *recs); -static int ctl_show(int, char **); +#define CISCO_SH_VERB_FLOW6_HEADER "SrcIf SrcIPaddress DstIf DstIPaddress Pr TOS Flgs Pkts\n" \ +"Port Msk AS Port Msk AS NextHop B/Pk Active\n" + +#define CISCO_SH_VERB_FLOW6 "%-14s %-30s %-14s %-30s %2u %3x %4x %6lu\n" \ + "%4.4x /%-2u %-5u %4.4x /%-2u %-5u %-30s %9u %8u\n\n" +static void flow_cache_print(struct ngnf_show_header *resp); +static void flow_cache_print6(struct ngnf_show_header *resp); +static void flow_cache_print_verbose(struct ngnf_show_header *resp); +static void flow_cache_print6_verbose(struct ngnf_show_header *resp); +static void ctl_show(int, char **); +static void do_show(int, void (*func)(struct ngnf_show_header *)); static void help(void); static void execute_command(int, char **); struct ip_ctl_cmd { char *cmd_name; - int (*cmd_func)(int argc, char **argv); + void (*cmd_func)(int argc, char **argv); }; struct ip_ctl_cmd cmds[] = { @@ -77,7 +89,7 @@ struct ip_ctl_cmd cmds[] = { }; int cs; -char ng_nodename[NG_PATHSIZ]; +char *ng_path; int main(int argc, char **argv) @@ -85,7 +97,6 @@ main(int argc, char **argv) int c; char sname[NG_NODESIZ]; int rcvbuf = SORCVBUF_SIZE; - char *ng_name; /* parse options */ while ((c = getopt(argc, argv, "d:")) != -1) { @@ -98,14 +109,12 @@ main(int argc, char **argv) argc -= optind; argv += optind; - ng_name = argv[0]; - if (ng_name == NULL) + ng_path = argv[0]; + if (ng_path == NULL || (strlen(ng_path) > NG_PATHSIZ)) help(); argc--; argv++; - snprintf(ng_nodename, sizeof(ng_nodename), "%s:", ng_name); - /* create control socket. */ snprintf(sname, sizeof(sname), "flowctl%i", getpid()); @@ -145,74 +154,99 @@ execute_command(int argc, char **argv) (*cmds[cindex].cmd_func)(argc, argv); } -static int +static void ctl_show(int argc, char **argv) { - struct ng_mesg *ng_mesg; - struct ngnf_flows *data; - char path[NG_PATHSIZ]; - int token, nread, last = 0; - int verbose = 0; + int ipv4 = 1, ipv6 = 1, verbose = 0; + + if (argc > 0 && !strncmp(argv[0], "ipv4", 4)) { + ipv6 = 0; + argc--; + argv++; + } + if (argc > 0 && !strncmp(argv[0], "ipv6", 4)) { + ipv4 = 0; + argc--; + argv++; + } if (argc > 0 && !strncmp(argv[0], "verbose", strlen(argv[0]))) verbose = 1; + if (ipv4) { + if (verbose) + do_show(4, &flow_cache_print_verbose); + else + do_show(4, &flow_cache_print); + } + + if (ipv6) { + if (verbose) + do_show(6, &flow_cache_print6_verbose); + else + do_show(6, &flow_cache_print6); + } +} + +static void +do_show(int version, void (*func)(struct ngnf_show_header *)) +{ + struct ng_mesg *ng_mesg; + struct ngnf_show_header req, *resp; + int token, nread; + ng_mesg = alloca(SORCVBUF_SIZE); - if (verbose) - printf(CISCO_SH_VERB_FLOW_HEADER); - else - printf(CISCO_SH_FLOW_HEADER); + req.version = version; + req.hash_id = req.list_id = 0; for (;;) { /* request set of accounting records */ - token = NgSendMsg(cs, ng_nodename, NGM_NETFLOW_COOKIE, - NGM_NETFLOW_SHOW, (void *)&last, sizeof(last)); + token = NgSendMsg(cs, ng_path, NGM_NETFLOW_COOKIE, + NGM_NETFLOW_SHOW, (void *)&req, sizeof(req)); if (token == -1) err(1, "NgSendMsg(NGM_NETFLOW_SHOW)"); /* read reply */ - nread = NgRecvMsg(cs, ng_mesg, SORCVBUF_SIZE, path); + nread = NgRecvMsg(cs, ng_mesg, SORCVBUF_SIZE, NULL); if (nread == -1) err(1, "NgRecvMsg() failed"); if (ng_mesg->header.token != token) err(1, "NgRecvMsg(NGM_NETFLOW_SHOW): token mismatch"); - data = (struct ngnf_flows*)ng_mesg->data; - if ((ng_mesg->header.arglen < (sizeof(*data))) || - (ng_mesg->header.arglen < (sizeof(*data) + - (data->nentries * sizeof(struct flow_entry_data))))) + resp = (struct ngnf_show_header *)ng_mesg->data; + if ((ng_mesg->header.arglen < (sizeof(*resp))) || + (ng_mesg->header.arglen < (sizeof(*resp) + + (resp->nentries * sizeof(struct flow_entry_data))))) err(1, "NgRecvMsg(NGM_NETFLOW_SHOW): arglen too small"); - if (verbose) - (void )flow_cache_print_verbose(data); - else - (void )flow_cache_print(data); + (*func)(resp); - if (data->last != 0) - last = data->last; + if (resp->hash_id != 0) + req.hash_id = resp->hash_id; else break; + req.list_id = resp->list_id; } - - return (0); } -static int -flow_cache_print(struct ngnf_flows *recs) +static void +flow_cache_print(struct ngnf_show_header *resp) { struct flow_entry_data *fle; char src[INET_ADDRSTRLEN], dst[INET_ADDRSTRLEN]; char src_if[IFNAMSIZ], dst_if[IFNAMSIZ]; int i; - /* quick check */ - if (recs->nentries == 0) - return (0); + if (resp->version != 4) + errx(EX_SOFTWARE, "%s: version mismatch: %u", + __func__, resp->version); - fle = recs->entries; - for (i = 0; i < recs->nentries; i++, fle++) { + printf(CISCO_SH_FLOW_HEADER); + + fle = (struct flow_entry_data *)(resp + 1); + for (i = 0; i < resp->nentries; i++, fle++) { inet_ntop(AF_INET, &fle->r.r_src, src, sizeof(src)); inet_ntop(AF_INET, &fle->r.r_dst, dst, sizeof(dst)); printf(CISCO_SH_FLOW, @@ -226,24 +260,57 @@ flow_cache_print(struct ngnf_flows *recs fle->packets); } - - return (i); } -static int -flow_cache_print_verbose(struct ngnf_flows *recs) +#ifdef INET6 +static void +flow_cache_print6(struct ngnf_show_header *resp) +{ + struct flow6_entry_data *fle6; + char src6[INET6_ADDRSTRLEN], dst6[INET6_ADDRSTRLEN]; + char src_if[IFNAMSIZ], dst_if[IFNAMSIZ]; + int i; + + if (resp->version != 6) + errx(EX_SOFTWARE, "%s: version mismatch: %u", + __func__, resp->version); + + printf(CISCO_SH_FLOW6_HEADER); + + fle6 = (struct flow6_entry_data *)(resp + 1); + for (i = 0; i < resp->nentries; i++, fle6++) { + inet_ntop(AF_INET6, &fle6->r.src.r_src6, src6, sizeof(src6)); + inet_ntop(AF_INET6, &fle6->r.dst.r_dst6, dst6, sizeof(dst6)); + printf(CISCO_SH_FLOW6, + if_indextoname(fle6->fle_i_ifx, src_if), + src6, + if_indextoname(fle6->fle_o_ifx, dst_if), + dst6, + fle6->r.r_ip_p, + ntohs(fle6->r.r_sport), + ntohs(fle6->r.r_dport), + fle6->packets); + + } +} +#endif + +static void +flow_cache_print_verbose(struct ngnf_show_header *resp) { struct flow_entry_data *fle; char src[INET_ADDRSTRLEN], dst[INET_ADDRSTRLEN], next[INET_ADDRSTRLEN]; char src_if[IFNAMSIZ], dst_if[IFNAMSIZ]; int i; - /* quick check */ - if (recs->nentries == 0) - return (0); + if (resp->version != 4) + errx(EX_SOFTWARE, "%s: version mismatch: %u", + __func__, resp->version); + + printf(CISCO_SH_VERB_FLOW_HEADER); - fle = recs->entries; - for (i = 0; i < recs->nentries; i++, fle++) { + fle = (struct flow_entry_data *)(resp + 1); + for (i = 0; i < resp->nentries; i++, fle++) { inet_ntop(AF_INET, &fle->r.r_src, src, sizeof(src)); inet_ntop(AF_INET, &fle->r.r_dst, dst, sizeof(dst)); inet_ntop(AF_INET, &fle->next_hop, next, sizeof(next)); @@ -267,10 +334,50 @@ flow_cache_print_verbose(struct ngnf_flo 0); } - - return (i); } +#ifdef INET6 +static void +flow_cache_print6_verbose(struct ngnf_show_header *resp) +{ + struct flow6_entry_data *fle6; + char src6[INET6_ADDRSTRLEN], dst6[INET6_ADDRSTRLEN], next6[INET6_ADDRSTRLEN]; + char src_if[IFNAMSIZ], dst_if[IFNAMSIZ]; + int i; + + if (resp->version != 6) + errx(EX_SOFTWARE, "%s: version mismatch: %u", + __func__, resp->version); + + printf(CISCO_SH_VERB_FLOW6_HEADER); + + fle6 = (struct flow6_entry_data *)(resp + 1); + for (i = 0; i < resp->nentries; i++, fle6++) { + inet_ntop(AF_INET6, &fle6->r.src.r_src6, src6, sizeof(src6)); + inet_ntop(AF_INET6, &fle6->r.dst.r_dst6, dst6, sizeof(dst6)); + inet_ntop(AF_INET6, &fle6->n.next_hop6, next6, sizeof(next6)); + printf(CISCO_SH_VERB_FLOW6, + if_indextoname(fle6->fle_i_ifx, src_if), + src6, + if_indextoname(fle6->fle_o_ifx, dst_if), + dst6, + fle6->r.r_ip_p, + fle6->r.r_tos, + fle6->tcp_flags, + fle6->packets, + ntohs(fle6->r.r_sport), + fle6->src_mask, + 0, + ntohs(fle6->r.r_dport), + fle6->dst_mask, + 0, + next6, + (u_int)(fle6->bytes / fle6->packets), + 0); + } +} +#endif + static void help(void) { From owner-svn-src-head@FreeBSD.ORG Tue Jul 5 14:55:18 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4D82C106566B; Tue, 5 Jul 2011 14:55:18 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3DE398FC13; Tue, 5 Jul 2011 14:55:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p65EtIKE073912; Tue, 5 Jul 2011 14:55:18 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p65EtIJB073910; Tue, 5 Jul 2011 14:55:18 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201107051455.p65EtIJB073910@svn.freebsd.org> From: Gleb Smirnoff Date: Tue, 5 Jul 2011 14:55:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223790 - head/usr.sbin/flowctl X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2011 14:55:18 -0000 Author: glebius Date: Tue Jul 5 14:55:17 2011 New Revision: 223790 URL: http://svn.freebsd.org/changeset/base/223790 Log: Update manual page. Mention IPv6 support, and notice that main argument isn't actually a node, but a netgraph path. Modified: head/usr.sbin/flowctl/flowctl.8 Modified: head/usr.sbin/flowctl/flowctl.8 ============================================================================== --- head/usr.sbin/flowctl/flowctl.8 Tue Jul 5 14:54:33 2011 (r223789) +++ head/usr.sbin/flowctl/flowctl.8 Tue Jul 5 14:55:17 2011 (r223790) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 23, 2005 +.Dd July 5, 2011 .Dt FLOWCTL 8 .Os .Sh NAME @@ -35,7 +35,7 @@ control utility .Sh SYNOPSIS .Nm .Op Fl d Ar level -.Ar node command +.Ar path command .Sh DESCRIPTION The .Nm @@ -55,11 +55,16 @@ Currently, .Nm supports only one command. .Bl -tag -width ".Cm show" -.It Cm show +.It Cm show Op Cm ipv4|ipv6 This command is the analog of the .Dq "show ip cache flow" command of a Cisco router. It dumps the contents of the flow cache in Cisco-like format. +Specifing either +.Cm ipv4 +or +.Cm ipv6 +would extract only IPv4 or IPv6 flows respectively. It has optional parameter .Cm verbose , which is analog of the From owner-svn-src-head@FreeBSD.ORG Tue Jul 5 15:00:55 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8A6E11065672; Tue, 5 Jul 2011 15:00:55 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7A8628FC15; Tue, 5 Jul 2011 15:00:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p65F0tIZ074170; Tue, 5 Jul 2011 15:00:55 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p65F0tZ5074168; Tue, 5 Jul 2011 15:00:55 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201107051500.p65F0tZ5074168@svn.freebsd.org> From: Nathan Whitehorn Date: Tue, 5 Jul 2011 15:00:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223792 - head/sys/powerpc/ps3 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2011 15:00:55 -0000 Author: nwhitehorn Date: Tue Jul 5 15:00:55 2011 New Revision: 223792 URL: http://svn.freebsd.org/changeset/base/223792 Log: Follow Linux by unconditionally stripping the RX vlan tag from incoming packets. It turns out that all firmware versions insert it, whether or not they support VLAN tagging. Submitted by: glevand Modified: head/sys/powerpc/ps3/if_glc.c Modified: head/sys/powerpc/ps3/if_glc.c ============================================================================== --- head/sys/powerpc/ps3/if_glc.c Tue Jul 5 14:58:10 2011 (r223791) +++ head/sys/powerpc/ps3/if_glc.c Tue Jul 5 15:00:55 2011 (r223792) @@ -155,7 +155,7 @@ glc_attach(device_t dev) lv1_net_control(sc->sc_bus, sc->sc_dev, GELIC_GET_MAC_ADDRESS, 0, 0, 0, &mac64, &junk); memcpy(sc->sc_enaddr, &((uint8_t *)&mac64)[2], sizeof(sc->sc_enaddr)); - sc->sc_tx_vlan = sc->sc_rx_vlan = -1; + sc->sc_tx_vlan = sc->sc_rx_vlan = -1; err = lv1_net_control(sc->sc_bus, sc->sc_dev, GELIC_GET_VLAN_ID, GELIC_VLAN_TX_ETHERNET, 0, 0, &val, &junk); if (err == 0) @@ -178,7 +178,7 @@ glc_attach(device_t dev) } bus_setup_intr(dev, sc->sc_irq, - INTR_TYPE_MISC | INTR_MPSAFE | INTR_ENTROPY, + INTR_TYPE_NET | INTR_MPSAFE | INTR_ENTROPY, glc_intr_filter, glc_intr, sc, &sc->sc_irqctx); sc->sc_hwirq_status = (uint64_t *)contigmalloc(8, M_GLC, M_ZERO, 0, BUS_SPACE_MAXADDR_32BIT, 8, PAGE_SIZE); @@ -755,8 +755,11 @@ glc_rxintr(struct glc_softc *sc) m->m_len = sc->sc_rxdmadesc[i].valid_size; m->m_pkthdr.len = m->m_len; - if (sc->sc_rx_vlan >= 0) - m_adj(m, 2); + /* + * Remove VLAN tag. Even on early firmwares that do not allow + * multiple VLANs, the VLAN tag is still in place here. + */ + m_adj(m, 2); mtx_unlock(&sc->sc_mtx); (*ifp->if_input)(ifp, m); From owner-svn-src-head@FreeBSD.ORG Tue Jul 5 16:47:21 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 276361065675; Tue, 5 Jul 2011 16:47:21 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-yw0-f54.google.com (mail-yw0-f54.google.com [209.85.213.54]) by mx1.freebsd.org (Postfix) with ESMTP id A4E288FC0A; Tue, 5 Jul 2011 16:47:20 +0000 (UTC) Received: by ywf7 with SMTP id 7so2995143ywf.13 for ; Tue, 05 Jul 2011 09:47:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=WK9fip47z+v1KUmzSSoTyBkyLhspnBcn2pszq8JsLB8=; b=H+sUA9RSxArXnjQkzPate/qfaLffnjA6gjc2820VQn8WKhXtBhI0p9BvHKiME1YaxG LYbuAn/uRm5OGyUEQnG1r6t4aDmq/sQI1v+CwLfMzTFKCJHNKGtNYIgsZ45MNnKOPZ2c xMJzF3Nw6PFD+ixBzSIbF82m32zz4gYXdltjE= MIME-Version: 1.0 Received: by 10.151.8.21 with SMTP id l21mr2678520ybi.186.1309884439771; Tue, 05 Jul 2011 09:47:19 -0700 (PDT) Sender: pluknet@gmail.com Received: by 10.150.92.6 with HTTP; Tue, 5 Jul 2011 09:47:19 -0700 (PDT) In-Reply-To: <201107051450.p65Eo7ah073669@svn.freebsd.org> References: <201107051450.p65Eo7ah073669@svn.freebsd.org> Date: Tue, 5 Jul 2011 20:47:19 +0400 X-Google-Sender-Auth: QhA1fbRwYT4FAAUjRnoRrMX_wZM Message-ID: From: Sergey Kandaurov To: Gleb Smirnoff Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r223788 - head/usr.sbin/flowctl X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2011 16:47:21 -0000 On 5 July 2011 18:50, Gleb Smirnoff wrote: > Author: glebius > Date: Tue Jul =A05 14:50:06 2011 > New Revision: 223788 > URL: http://svn.freebsd.org/changeset/base/223788 > > Log: > =A0Rewrite the flowctl utility to add it support for displaying > =A0both IPv4 and IPv4 flows. > > Modified: > =A0head/usr.sbin/flowctl/Makefile > =A0head/usr.sbin/flowctl/flowctl.c > > Modified: head/usr.sbin/flowctl/Makefile > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/usr.sbin/flowctl/Makefile =A0 =A0 =A0Tue Jul =A05 14:48:39 2011 = =A0 =A0 =A0 =A0(r223787) > +++ head/usr.sbin/flowctl/Makefile =A0 =A0 =A0Tue Jul =A05 14:50:06 2011 = =A0 =A0 =A0 =A0(r223788) > @@ -2,6 +2,8 @@ > =A0# $FreeBSD$ > =A0# > > +.include > + > =A0PROG=3D =A0flowctl > =A0MAN=3D =A0 flowctl.8 > > @@ -9,4 +11,10 @@ WARNS?=3D 2 > =A0DPADD=3D =A0${LIBNETGRAPH} > =A0LDADD=3D =A0-lnetgraph > > +.if ${MK_INET6_SUPPORT} !=3D "no" > +CFLAGS+=3D -DINET6 > +.endif [...] It's broken for WITHOUT_INET6=3Dyes. Please consider taking a look at the change below on top of r223788. The patch adds handling for WITHOUT_INET, too. Index: usr.sbin/flowctl/flowctl.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- usr.sbin/flowctl/flowctl.c (revision 223792) +++ usr.sbin/flowctl/flowctl.c (working copy) @@ -69,12 +69,18 @@ #define CISCO_SH_VERB_FLOW6 "%-14s %-30s %-14s %-30s %2u %3x %4x %6lu\n" \ "%4.4x /%-2u %-5u %4.4x /%-2u %-5u %-30s %9u %8u\n\= n" +#ifdef INET static void flow_cache_print(struct ngnf_show_header *resp); +static void flow_cache_print_verbose(struct ngnf_show_header *resp); +#endif +#ifdef INET6 static void flow_cache_print6(struct ngnf_show_header *resp); -static void flow_cache_print_verbose(struct ngnf_show_header *resp); static void flow_cache_print6_verbose(struct ngnf_show_header *resp); +#endif static void ctl_show(int, char **); +#if defined(INET) || defined(INET6) static void do_show(int, void (*func)(struct ngnf_show_header *)); +#endif static void help(void); static void execute_command(int, char **); @@ -157,8 +163,11 @@ static void ctl_show(int argc, char **argv) { - int ipv4 =3D 1, ipv6 =3D 1, verbose =3D 0; + int ipv4, ipv6, verbose =3D 0; + ipv4 =3D feature_present("inet"); + ipv6 =3D feature_present("inet6"); + if (argc > 0 && !strncmp(argv[0], "ipv4", 4)) { ipv6 =3D 0; argc--; @@ -173,21 +182,26 @@ if (argc > 0 && !strncmp(argv[0], "verbose", strlen(argv[0]))) verbose =3D 1; +#ifdef INET if (ipv4) { if (verbose) do_show(4, &flow_cache_print_verbose); else do_show(4, &flow_cache_print); } +#endif +#ifdef INET6 if (ipv6) { if (verbose) do_show(6, &flow_cache_print6_verbose); else do_show(6, &flow_cache_print6); } +#endif } +#if defined(INET) || defined(INET6) static void do_show(int version, void (*func)(struct ngnf_show_header *)) { @@ -230,7 +244,9 @@ req.list_id =3D resp->list_id; } } +#endif +#ifdef INET static void flow_cache_print(struct ngnf_show_header *resp) { @@ -261,6 +277,7 @@ } } +#endif #ifdef INET6 static void @@ -295,6 +312,7 @@ } #endif +#ifdef INET static void flow_cache_print_verbose(struct ngnf_show_header *resp) { @@ -335,6 +353,7 @@ } } +#endif #ifdef INET6 static void Index: usr.sbin/flowctl/Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- usr.sbin/flowctl/Makefile (revision 223792) +++ usr.sbin/flowctl/Makefile (working copy) @@ -14,7 +14,8 @@ .if ${MK_INET6_SUPPORT} !=3D "no" CFLAGS+=3D -DINET6 .endif +.if ${MK_INET_SUPPORT} !=3D "no" +CFLAGS+=3D -DINET +.endif -CFLAGS+=3D -I. - .include --=20 wbr, pluknet From owner-svn-src-head@FreeBSD.ORG Tue Jul 5 18:40:19 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B1BEC106566B; Tue, 5 Jul 2011 18:40:19 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A2DBC8FC08; Tue, 5 Jul 2011 18:40:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p65IeJjQ080732; Tue, 5 Jul 2011 18:40:19 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p65IeJwp080730; Tue, 5 Jul 2011 18:40:19 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201107051840.p65IeJwp080730@svn.freebsd.org> From: Rick Macklem Date: Tue, 5 Jul 2011 18:40:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223794 - head X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2011 18:40:19 -0000 Author: rmacklem Date: Tue Jul 5 18:40:19 2011 New Revision: 223794 URL: http://svn.freebsd.org/changeset/base/223794 Log: Delete files made obsolete by the change in default NFS client and the move of nfs_kdtrace.h to sys/nfs. Modified: head/ObsoleteFiles.inc Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Tue Jul 5 18:29:32 2011 (r223793) +++ head/ObsoleteFiles.inc Tue Jul 5 18:40:19 2011 (r223794) @@ -38,6 +38,10 @@ # xargs -n1 | sort | uniq -d; # done +# 20110705: the switch of default NFS client to the new one +OLD_FILES+=sbin/mount_newnfs +OLD_FILES+=usr/share/man/man8/mount_newnfs.8.gz +OLD_FILES+=usr/include/nfsclient/nfs_kdtrace.h # 20110502: new clang import which bumps version from 2.9 to 3.0 OLD_FILES+=usr/include/clang/2.9/emmintrin.h OLD_FILES+=usr/include/clang/2.9/mm_malloc.h From owner-svn-src-head@FreeBSD.ORG Tue Jul 5 18:40:38 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 49E2B106567A; Tue, 5 Jul 2011 18:40:38 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 212BD8FC20; Tue, 5 Jul 2011 18:40:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p65Ieb82080776; Tue, 5 Jul 2011 18:40:37 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p65IebRj080773; Tue, 5 Jul 2011 18:40:37 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201107051840.p65IebRj080773@svn.freebsd.org> From: Marius Strobl Date: Tue, 5 Jul 2011 18:40:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223795 - in head/sys: kern sparc64/sparc64 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2011 18:40:38 -0000 Author: marius Date: Tue Jul 5 18:40:37 2011 New Revision: 223795 URL: http://svn.freebsd.org/changeset/base/223795 Log: Call pmap_qremove() before freeing or unwiring the pages, otherwise there's a window during which a page can be re-used before its previous mapping is removed. Reviewed by: alc MFC after: 1 week Modified: head/sys/kern/vfs_bio.c head/sys/sparc64/sparc64/pmap.c Modified: head/sys/kern/vfs_bio.c ============================================================================== --- head/sys/kern/vfs_bio.c Tue Jul 5 18:40:19 2011 (r223794) +++ head/sys/kern/vfs_bio.c Tue Jul 5 18:40:37 2011 (r223795) @@ -1625,6 +1625,7 @@ vfs_vmio_release(struct buf *bp) int i; vm_page_t m; + pmap_qremove(trunc_page((vm_offset_t)bp->b_data), bp->b_npages); VM_OBJECT_LOCK(bp->b_bufobj->bo_object); for (i = 0; i < bp->b_npages; i++) { m = bp->b_pages[i]; @@ -1658,7 +1659,6 @@ vfs_vmio_release(struct buf *bp) vm_page_unlock(m); } VM_OBJECT_UNLOCK(bp->b_bufobj->bo_object); - pmap_qremove(trunc_page((vm_offset_t) bp->b_data), bp->b_npages); if (bp->b_bufsize) { bufspacewakeup(); @@ -3012,6 +3012,10 @@ allocbuf(struct buf *bp, int size) if (desiredpages < bp->b_npages) { vm_page_t m; + pmap_qremove((vm_offset_t)trunc_page( + (vm_offset_t)bp->b_data) + + (desiredpages << PAGE_SHIFT), + (bp->b_npages - desiredpages)); VM_OBJECT_LOCK(bp->b_bufobj->bo_object); for (i = desiredpages; i < bp->b_npages; i++) { /* @@ -3032,8 +3036,6 @@ allocbuf(struct buf *bp, int size) vm_page_unlock(m); } VM_OBJECT_UNLOCK(bp->b_bufobj->bo_object); - pmap_qremove((vm_offset_t) trunc_page((vm_offset_t)bp->b_data) + - (desiredpages << PAGE_SHIFT), (bp->b_npages - desiredpages)); bp->b_npages = desiredpages; } } else if (size > bp->b_bcount) { Modified: head/sys/sparc64/sparc64/pmap.c ============================================================================== --- head/sys/sparc64/sparc64/pmap.c Tue Jul 5 18:40:19 2011 (r223794) +++ head/sys/sparc64/sparc64/pmap.c Tue Jul 5 18:40:37 2011 (r223795) @@ -1294,6 +1294,7 @@ pmap_release(pmap_t pm) pc->pc_pmap = NULL; mtx_unlock_spin(&sched_lock); + pmap_qremove((vm_offset_t)pm->pm_tsb, TSB_PAGES); obj = pm->pm_tsb_obj; VM_OBJECT_LOCK(obj); KASSERT(obj->ref_count == 1, ("pmap_release: tsbobj ref count != 1")); @@ -1305,7 +1306,6 @@ pmap_release(pmap_t pm) vm_page_free_zero(m); } VM_OBJECT_UNLOCK(obj); - pmap_qremove((vm_offset_t)pm->pm_tsb, TSB_PAGES); PMAP_LOCK_DESTROY(pm); } From owner-svn-src-head@FreeBSD.ORG Tue Jul 5 18:42:10 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 819E91065673; Tue, 5 Jul 2011 18:42:10 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 58E918FC0A; Tue, 5 Jul 2011 18:42:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p65IgAi1080861; Tue, 5 Jul 2011 18:42:10 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p65IgAEH080858; Tue, 5 Jul 2011 18:42:10 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201107051842.p65IgAEH080858@svn.freebsd.org> From: Jung-uk Kim Date: Tue, 5 Jul 2011 18:42:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223796 - in head/sys: amd64/include i386/include X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2011 18:42:10 -0000 Author: jkim Date: Tue Jul 5 18:42:10 2011 New Revision: 223796 URL: http://svn.freebsd.org/changeset/base/223796 Log: Correct cpu_monitor() and cpu_mwait() for amd64. These instructions take %rcx as "extensions" in long mode. If any unused bit is set in %rcx, these instructions cause general protection fault. Fix style nits and synchronize i386 with amd64. Modified: head/sys/amd64/include/cpufunc.h head/sys/i386/include/cpufunc.h Modified: head/sys/amd64/include/cpufunc.h ============================================================================== --- head/sys/amd64/include/cpufunc.h Tue Jul 5 18:40:37 2011 (r223795) +++ head/sys/amd64/include/cpufunc.h Tue Jul 5 18:42:10 2011 (r223796) @@ -467,16 +467,18 @@ load_es(u_short sel) } static __inline void -cpu_monitor(const void *addr, int extensions, int hints) +cpu_monitor(const void *addr, u_long extensions, u_int hints) { - __asm __volatile("monitor;" - : :"a" (addr), "c" (extensions), "d"(hints)); + + __asm __volatile("monitor" + : : "a" (addr), "c" (extensions), "d" (hints)); } static __inline void -cpu_mwait(int extensions, int hints) +cpu_mwait(u_long extensions, u_int hints) { - __asm __volatile("mwait;" : :"a" (hints), "c" (extensions)); + + __asm __volatile("mwait" : : "a" (hints), "c" (extensions)); } #ifdef _KERNEL Modified: head/sys/i386/include/cpufunc.h ============================================================================== --- head/sys/i386/include/cpufunc.h Tue Jul 5 18:40:37 2011 (r223795) +++ head/sys/i386/include/cpufunc.h Tue Jul 5 18:42:10 2011 (r223796) @@ -133,16 +133,18 @@ enable_intr(void) } static __inline void -cpu_monitor(const void *addr, int extensions, int hints) +cpu_monitor(const void *addr, u_long extensions, u_int hints) { - __asm __volatile("monitor;" - : :"a" (addr), "c" (extensions), "d"(hints)); + + __asm __volatile("monitor" + : : "a" (addr), "c" (extensions), "d" (hints)); } static __inline void -cpu_mwait(int extensions, int hints) +cpu_mwait(u_long extensions, u_int hints) { - __asm __volatile("mwait;" : :"a" (hints), "c" (extensions)); + + __asm __volatile("mwait" : : "a" (hints), "c" (extensions)); } static __inline void From owner-svn-src-head@FreeBSD.ORG Tue Jul 5 18:43:54 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F1A41106566C; Tue, 5 Jul 2011 18:43:54 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E2ACB8FC08; Tue, 5 Jul 2011 18:43:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p65Ihs19080971; Tue, 5 Jul 2011 18:43:54 GMT (envelope-from cperciva@svn.freebsd.org) Received: (from cperciva@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p65IhsKk080969; Tue, 5 Jul 2011 18:43:54 GMT (envelope-from cperciva@svn.freebsd.org) Message-Id: <201107051843.p65IhsKk080969@svn.freebsd.org> From: Colin Percival Date: Tue, 5 Jul 2011 18:43:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223797 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2011 18:43:55 -0000 Author: cperciva Date: Tue Jul 5 18:43:54 2011 New Revision: 223797 URL: http://svn.freebsd.org/changeset/base/223797 Log: Don't allow lro->len to exceed 65535, as this will result in overflow when len is inserted back into the synthetic IP packet and cause a multiple of 2^16 bytes of TCP "packet loss". This improves Linux->FreeBSD netperf bandwidth by a factor of 300 in testing on Amazon EC2. Reviewed by: jfv MFC after: 2 weeks Modified: head/sys/netinet/tcp_lro.c Modified: head/sys/netinet/tcp_lro.c ============================================================================== --- head/sys/netinet/tcp_lro.c Tue Jul 5 18:42:10 2011 (r223796) +++ head/sys/netinet/tcp_lro.c Tue Jul 5 18:43:54 2011 (r223797) @@ -277,6 +277,14 @@ tcp_lro_rx(struct lro_ctrl *cntl, struct lro->dest_port == tcp->th_dport && lro->source_ip == ip->ip_src.s_addr && lro->dest_ip == ip->ip_dst.s_addr) { + /* Flush now if appending will result in overflow. */ + if (lro->len > (65535 - tcp_data_len)) { + SLIST_REMOVE(&cntl->lro_active, lro, + lro_entry, next); + tcp_lro_flush(cntl, lro); + break; + } + /* Try to append it */ if (__predict_false(seq != lro->next_seq || From owner-svn-src-head@FreeBSD.ORG Tue Jul 5 18:46:19 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A04A9106564A; Tue, 5 Jul 2011 18:46:19 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 913368FC12; Tue, 5 Jul 2011 18:46:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p65IkJVR081086; Tue, 5 Jul 2011 18:46:19 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p65IkJhJ081084; Tue, 5 Jul 2011 18:46:19 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201107051846.p65IkJhJ081084@svn.freebsd.org> From: Marius Strobl Date: Tue, 5 Jul 2011 18:46:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223798 - head/sys/sparc64/sparc64 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2011 18:46:19 -0000 Author: marius Date: Tue Jul 5 18:46:19 2011 New Revision: 223798 URL: http://svn.freebsd.org/changeset/base/223798 Log: In pmap_remove_all() assert that the page is neither fictitious nor unmanaged as also done on other architectures. Reviewed by: alc Modified: head/sys/sparc64/sparc64/pmap.c Modified: head/sys/sparc64/sparc64/pmap.c ============================================================================== --- head/sys/sparc64/sparc64/pmap.c Tue Jul 5 18:43:54 2011 (r223797) +++ head/sys/sparc64/sparc64/pmap.c Tue Jul 5 18:46:19 2011 (r223798) @@ -1387,6 +1387,8 @@ pmap_remove_all(vm_page_t m) struct tte *tp; vm_offset_t va; + KASSERT((m->flags & (PG_FICTITIOUS | PG_UNMANAGED)) == 0, + ("pmap_remove_all: page %p is not managed", m)); vm_page_lock_queues(); for (tp = TAILQ_FIRST(&m->md.tte_list); tp != NULL; tp = tpn) { tpn = TAILQ_NEXT(tp, tte_link); From owner-svn-src-head@FreeBSD.ORG Tue Jul 5 18:49:55 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 88850106567A; Tue, 5 Jul 2011 18:49:55 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 799108FC1B; Tue, 5 Jul 2011 18:49:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p65IntGr081241; Tue, 5 Jul 2011 18:49:55 GMT (envelope-from cperciva@svn.freebsd.org) Received: (from cperciva@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p65IntWU081239; Tue, 5 Jul 2011 18:49:55 GMT (envelope-from cperciva@svn.freebsd.org) Message-Id: <201107051849.p65IntWU081239@svn.freebsd.org> From: Colin Percival Date: Tue, 5 Jul 2011 18:49:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223799 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2011 18:49:55 -0000 Author: cperciva Date: Tue Jul 5 18:49:55 2011 New Revision: 223799 URL: http://svn.freebsd.org/changeset/base/223799 Log: Remove #ifdef notyet code dating back to 4.3BSD Net/2 (and possibly earlier). I think the benefit of making the code cleaner and easier to understand outweighs the humour of leaving this intact (or possibly changing it to #ifdef not_yet_and_probably_never). MFC after: 2 weeks Modified: head/sys/netinet/tcp_output.c Modified: head/sys/netinet/tcp_output.c ============================================================================== --- head/sys/netinet/tcp_output.c Tue Jul 5 18:46:19 2011 (r223798) +++ head/sys/netinet/tcp_output.c Tue Jul 5 18:49:55 2011 (r223799) @@ -84,10 +84,6 @@ __FBSDID("$FreeBSD$"); #include -#ifdef notyet -extern struct mbuf *m_copypack(); -#endif - VNET_DEFINE(int, path_mtu_discovery) = 1; SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, path_mtu_discovery, CTLFLAG_RW, &VNET_NAME(path_mtu_discovery), 1, @@ -820,19 +816,6 @@ send: TCPSTAT_INC(tcps_sndpack); TCPSTAT_ADD(tcps_sndbyte, len); } -#ifdef notyet - if ((m = m_copypack(so->so_snd.sb_mb, off, - (int)len, max_linkhdr + hdrlen)) == 0) { - SOCKBUF_UNLOCK(&so->so_snd); - error = ENOBUFS; - goto out; - } - /* - * m_copypack left space for our hdr; use it. - */ - m->m_len += hdrlen; - m->m_data -= hdrlen; -#else MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) { SOCKBUF_UNLOCK(&so->so_snd); @@ -872,7 +855,7 @@ send: goto out; } } -#endif /* notyet */ + /* * If we're sending everything we've got, set PUSH. * (This will keep happy those implementations which only From owner-svn-src-head@FreeBSD.ORG Tue Jul 5 18:50:41 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4C4FB1065689; Tue, 5 Jul 2011 18:50:41 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 23B988FC25; Tue, 5 Jul 2011 18:50:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p65Iof1D081305; Tue, 5 Jul 2011 18:50:41 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p65Iofvo081302; Tue, 5 Jul 2011 18:50:41 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201107051850.p65Iofvo081302@svn.freebsd.org> From: Marius Strobl Date: Tue, 5 Jul 2011 18:50:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223800 - in head/sys/sparc64: include sparc64 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2011 18:50:41 -0000 Author: marius Date: Tue Jul 5 18:50:40 2011 New Revision: 223800 URL: http://svn.freebsd.org/changeset/base/223800 Log: - pmap_cache_remove() and pmap_protect_tte() are only used within pmap.c so static'ize them. - Correct a typo. Modified: head/sys/sparc64/include/pmap.h head/sys/sparc64/sparc64/pmap.c Modified: head/sys/sparc64/include/pmap.h ============================================================================== --- head/sys/sparc64/include/pmap.h Tue Jul 5 18:49:55 2011 (r223799) +++ head/sys/sparc64/include/pmap.h Tue Jul 5 18:50:40 2011 (r223800) @@ -90,12 +90,9 @@ void pmap_kremove_flags(vm_offset_t va); boolean_t pmap_page_is_mapped(vm_page_t m); int pmap_cache_enter(vm_page_t m, vm_offset_t va); -void pmap_cache_remove(vm_page_t m, vm_offset_t va); int pmap_remove_tte(struct pmap *pm1, struct pmap *pm2, struct tte *tp, vm_offset_t va); -int pmap_protect_tte(struct pmap *pm1, struct pmap *pm2, struct tte *tp, - vm_offset_t va); void pmap_map_tsb(void); void pmap_set_kctx(void); Modified: head/sys/sparc64/sparc64/pmap.c ============================================================================== --- head/sys/sparc64/sparc64/pmap.c Tue Jul 5 18:49:55 2011 (r223799) +++ head/sys/sparc64/sparc64/pmap.c Tue Jul 5 18:50:40 2011 (r223800) @@ -152,6 +152,9 @@ struct pmap kernel_pmap_store; static vm_paddr_t pmap_bootstrap_alloc(vm_size_t size, uint32_t colors); static void pmap_bootstrap_set_tte(struct tte *tp, u_long vpn, u_long data); +static void pmap_cache_remove(vm_page_t m, vm_offset_t va); +static int pmap_protect_tte(struct pmap *pm1, struct pmap *pm2, + struct tte *tp, vm_offset_t va); /* * Map the given physical page at the specified virtual address in the @@ -956,7 +959,7 @@ pmap_cache_enter(vm_page_t m, vm_offset_ return (0); } -void +static void pmap_cache_remove(vm_page_t m, vm_offset_t va) { struct tte *tp; @@ -1415,7 +1418,7 @@ pmap_remove_all(vm_page_t m) vm_page_unlock_queues(); } -int +static int pmap_protect_tte(struct pmap *pm, struct pmap *pm2, struct tte *tp, vm_offset_t va) { @@ -1984,7 +1987,7 @@ pmap_page_wired_mappings(vm_page_t m) /* * Remove all pages from specified address space, this aids process exit - * speeds. This is much faster than pmap_remove n the case of running down + * speeds. This is much faster than pmap_remove in the case of running down * an entire address space. Only works for the current pmap. */ void From owner-svn-src-head@FreeBSD.ORG Tue Jul 5 18:55:57 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 240F81065674; Tue, 5 Jul 2011 18:55:57 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 152078FC08; Tue, 5 Jul 2011 18:55:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p65ItutH081500; Tue, 5 Jul 2011 18:55:56 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p65ItuWa081498; Tue, 5 Jul 2011 18:55:56 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201107051855.p65ItuWa081498@svn.freebsd.org> From: Marius Strobl Date: Tue, 5 Jul 2011 18:55:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223801 - head/sys/sparc64/sparc64 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2011 18:55:57 -0000 Author: marius Date: Tue Jul 5 18:55:56 2011 New Revision: 223801 URL: http://svn.freebsd.org/changeset/base/223801 Log: It can be useful to know which page still has mappings. Modified: head/sys/sparc64/sparc64/vm_machdep.c Modified: head/sys/sparc64/sparc64/vm_machdep.c ============================================================================== --- head/sys/sparc64/sparc64/vm_machdep.c Tue Jul 5 18:50:40 2011 (r223800) +++ head/sys/sparc64/sparc64/vm_machdep.c Tue Jul 5 18:55:56 2011 (r223801) @@ -525,7 +525,7 @@ uma_small_alloc(uma_zone_t zone, int byt pa = VM_PAGE_TO_PHYS(m); if (dcache_color_ignore == 0 && m->md.color != DCACHE_COLOR(pa)) { KASSERT(m->md.colors[0] == 0 && m->md.colors[1] == 0, - ("uma_small_alloc: free page still has mappings!")); + ("uma_small_alloc: free page %p still has mappings!", m)); PMAP_STATS_INC(uma_nsmall_alloc_oc); m->md.color = DCACHE_COLOR(pa); dcache_page_inval(pa); From owner-svn-src-head@FreeBSD.ORG Tue Jul 5 19:26:59 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2C2CC106566C; Tue, 5 Jul 2011 19:26:59 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0D7F38FC1A; Tue, 5 Jul 2011 19:26:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p65JQwjA082463; Tue, 5 Jul 2011 19:26:58 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p65JQwGM082461; Tue, 5 Jul 2011 19:26:58 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201107051926.p65JQwGM082461@svn.freebsd.org> From: Rick Macklem Date: Tue, 5 Jul 2011 19:26:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223802 - head X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2011 19:26:59 -0000 Author: rmacklem Date: Tue Jul 5 19:26:58 2011 New Revision: 223802 URL: http://svn.freebsd.org/changeset/base/223802 Log: Delete files made obsolete because they were moved to sys/nfs in order to be shared by both NFS clients. Modified: head/ObsoleteFiles.inc Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Tue Jul 5 18:55:56 2011 (r223801) +++ head/ObsoleteFiles.inc Tue Jul 5 19:26:58 2011 (r223802) @@ -38,6 +38,9 @@ # xargs -n1 | sort | uniq -d; # done +# 20110705: files moved so both NFS clients can share them +OLD_FILES+=usr/include/nfsclient/krpc.h +OLD_FILES+=usr/include/nfsclient/nfsdiskless.h # 20110705: the switch of default NFS client to the new one OLD_FILES+=sbin/mount_newnfs OLD_FILES+=usr/share/man/man8/mount_newnfs.8.gz From owner-svn-src-head@FreeBSD.ORG Tue Jul 5 20:05:07 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 03D26106564A; Tue, 5 Jul 2011 20:05:07 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E93EA8FC14; Tue, 5 Jul 2011 20:05:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p65K567x083790; Tue, 5 Jul 2011 20:05:06 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p65K56PC083788; Tue, 5 Jul 2011 20:05:06 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201107052005.p65K56PC083788@svn.freebsd.org> From: Marius Strobl Date: Tue, 5 Jul 2011 20:05:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223806 - head/sys/sparc64/sparc64 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2011 20:05:07 -0000 Author: marius Date: Tue Jul 5 20:05:06 2011 New Revision: 223806 URL: http://svn.freebsd.org/changeset/base/223806 Log: Remove the IDR_CHEETAH_MAX_BN_PAIRS limit from cheetah_ipi_selected(). This is just a simple approach. For reasons unknown OpenSolaris uses a more sophisticated one involving IPIing the remaining CPUs in reverse order after the first batch of 32. Modified: head/sys/sparc64/sparc64/mp_machdep.c Modified: head/sys/sparc64/sparc64/mp_machdep.c ============================================================================== --- head/sys/sparc64/sparc64/mp_machdep.c Tue Jul 5 19:48:57 2011 (r223805) +++ head/sys/sparc64/sparc64/mp_machdep.c Tue Jul 5 20:05:06 2011 (r223806) @@ -139,8 +139,6 @@ static cpu_ipi_single_t spitfire_ipi_sin SYSINIT(cpu_mp_unleash, SI_SUB_SMP, SI_ORDER_FIRST, cpu_mp_unleash, NULL); -CTASSERT(MAXCPU <= IDR_CHEETAH_MAX_BN_PAIRS); - void mp_init(u_int cpu_impl) { @@ -696,6 +694,8 @@ cheetah_ipi_selected(cpuset_t cpus, u_lo ASI_SDB_INTR_W, 0); membar(Sync); bnp++; + if (bnp == IDR_CHEETAH_MAX_BN_PAIRS) + break; } } while (((ids = ldxa(0, ASI_INTR_DISPATCH_STATUS)) & From owner-svn-src-head@FreeBSD.ORG Wed Jul 6 00:47:27 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CBB66106566C; Wed, 6 Jul 2011 00:47:27 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BBBA88FC19; Wed, 6 Jul 2011 00:47:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p660lRLV092324; Wed, 6 Jul 2011 00:47:27 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p660lRYm092322; Wed, 6 Jul 2011 00:47:27 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201107060047.p660lRYm092322@svn.freebsd.org> From: Doug Barton Date: Wed, 6 Jul 2011 00:47:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223811 - head/contrib/bind9/lib/isc/sparc64/include/isc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jul 2011 00:47:27 -0000 Author: dougb Date: Wed Jul 6 00:47:27 2011 New Revision: 223811 URL: http://svn.freebsd.org/changeset/base/223811 Log: Apply bug fixes Submitted by: marius Modified: head/contrib/bind9/lib/isc/sparc64/include/isc/atomic.h Modified: head/contrib/bind9/lib/isc/sparc64/include/isc/atomic.h ============================================================================== --- head/contrib/bind9/lib/isc/sparc64/include/isc/atomic.h Tue Jul 5 23:31:40 2011 (r223810) +++ head/contrib/bind9/lib/isc/sparc64/include/isc/atomic.h Wed Jul 6 00:47:27 2011 (r223811) @@ -72,9 +72,9 @@ isc_atomic_xadd(isc_int32_t *p, isc_int3 for (prev = *(volatile isc_int32_t *)p; ; prev = swapped) { swapped = prev + val; __asm__ volatile( - "casa [%1] %2, %3, %0" - : "+r"(swapped) - : "r"(p), "n"(ASI_P), "r"(prev)); + "casa [%2] %3, %4, %0" + : "+r"(swapped), "=m"(*p) + : "r"(p), "n"(ASI_P), "r"(prev), "m"(*p)); if (swapped == prev) break; } @@ -92,10 +92,9 @@ isc_atomic_store(isc_int32_t *p, isc_int for (prev = *(volatile isc_int32_t *)p; ; prev = swapped) { swapped = val; __asm__ volatile( - "casa [%1] %2, %3, %0" - : "+r"(swapped) - : "r"(p), "n"(ASI_P), "r"(prev) - : "memory"); + "casa [%2] %3, %4, %0" + : "+r"(swapped), "=m"(*p) + : "r"(p), "n"(ASI_P), "r"(prev), "m"(*p)); if (swapped == prev) break; } @@ -111,9 +110,9 @@ isc_atomic_cmpxchg(isc_int32_t *p, isc_i isc_int32_t temp = val; __asm__ volatile( - "casa [%1] %2, %3, %0" - : "+r"(temp) - : "r"(p), "n"(ASI_P), "r"(cmpval)); + "casa [%2] %3, %4, %0" + : "+r"(temp), "=m"(*p) + : "r"(p), "n"(ASI_P), "r"(cmpval), "m"(*p)); return (temp); } From owner-svn-src-head@FreeBSD.ORG Wed Jul 6 00:48:31 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DEBDC1065677; Wed, 6 Jul 2011 00:48:31 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CD5D48FC20; Wed, 6 Jul 2011 00:48:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p660mVEp092416; Wed, 6 Jul 2011 00:48:31 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p660mVrX092402; Wed, 6 Jul 2011 00:48:31 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201107060048.p660mVrX092402@svn.freebsd.org> From: Doug Barton Date: Wed, 6 Jul 2011 00:48:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223812 - in head/contrib/bind9: . bin/named lib/dns lib/dns/include/dns X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jul 2011 00:48:32 -0000 Author: dougb Date: Wed Jul 6 00:48:31 2011 New Revision: 223812 URL: http://svn.freebsd.org/changeset/base/223812 Log: Update to version 9.6-ESV-R4-P3 ALL BIND USERS ARE ENCOURAGED TO UPGRADE IMMEDIATELY This update addresses the following vulnerability: CVE-2011-2464 ============= Severity: High Exploitable: Remotely Description: A defect in the affected BIND 9 versions allows an attacker to remotely cause the "named" process to exit using a specially crafted packet. This defect affects both recursive and authoritative servers. The code location of the defect makes it impossible to protect BIND using ACLs configured within named.conf or by disabling any features at compile-time or run-time. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-2464 https://www.isc.org/software/bind/advisories/cve-2011-2464 Modified: head/contrib/bind9/CHANGES head/contrib/bind9/bin/named/bind9.xsl.h head/contrib/bind9/lib/dns/api head/contrib/bind9/lib/dns/include/dns/masterdump.h head/contrib/bind9/lib/dns/include/dns/rdataset.h head/contrib/bind9/lib/dns/masterdump.c head/contrib/bind9/lib/dns/message.c head/contrib/bind9/lib/dns/ncache.c head/contrib/bind9/lib/dns/rbtdb.c head/contrib/bind9/lib/dns/rdataset.c head/contrib/bind9/lib/dns/resolver.c head/contrib/bind9/lib/dns/validator.c head/contrib/bind9/version Directory Properties: head/contrib/bind9/ (props changed) Modified: head/contrib/bind9/CHANGES ============================================================================== --- head/contrib/bind9/CHANGES Wed Jul 6 00:47:27 2011 (r223811) +++ head/contrib/bind9/CHANGES Wed Jul 6 00:48:31 2011 (r223812) @@ -1,3 +1,16 @@ + --- 9.6-ESV-R4-P3 released --- + +3124. [bug] Use an rdataset attribute flag to indicate + negative-cache records rather than using rrtype 0; + this will prevent problems when that rrtype is + used in actual DNS packets. [RT #24777] + + --- 9.6-ESV-R4-P2 released (withdrawn) --- + +3123. [security] Change #2912 exposed a latent flaw in + dns_rdataset_totext() that could cause named to + crash with an assertion failure. [RT #24777] + --- 9.6-ESV-R4-P1 released --- 3121. [security] An authoritative name server sending a negative Modified: head/contrib/bind9/bin/named/bind9.xsl.h ============================================================================== --- head/contrib/bind9/bin/named/bind9.xsl.h Wed Jul 6 00:47:27 2011 (r223811) +++ head/contrib/bind9/bin/named/bind9.xsl.h Wed Jul 6 00:48:31 2011 (r223812) @@ -1,6 +1,6 @@ /* - * Generated by convertxsl.pl 1.14 2008/07/17 23:43:26 jinmei Exp - * From bind9.xsl 1.19.82.2 2009/01/29 23:47:43 tbox Exp + * Generated by convertxsl.pl 1.14 2008-07-17 23:43:26 jinmei Exp + * From bind9.xsl 1.19.82.2 2009-01-29 23:47:43 tbox Exp */ static char xslmsg[] = "\n" @@ -20,7 +20,7 @@ static char xslmsg[] = " - PERFORMANCE OF THIS SOFTWARE.\n" "-->\n" "\n" - "\n" + "\n" "\n" "type == 0) { + if ((rdataset->attributes & DNS_RDATASETATTR_NEGATIVE) != 0) { type = rdataset->covers; } else { type = rdataset->type; } - { - unsigned int type_start; - INDENT_TO(type_column); - type_start = target->used; - if (rdataset->type == 0) - RETERR(str_totext("\\-", target)); - result = dns_rdatatype_totext(type, target); - if (result != ISC_R_SUCCESS) - return (result); - column += (target->used - type_start); - } + INDENT_TO(type_column); + type_start = target->used; + if ((rdataset->attributes & DNS_RDATASETATTR_NEGATIVE) != 0) + RETERR(str_totext("\\-", target)); + result = dns_rdatatype_totext(type, target); + if (result != ISC_R_SUCCESS) + return (result); + column += (target->used - type_start); /* * Rdata. */ INDENT_TO(rdata_column); - if (rdataset->type == 0) { + if ((rdataset->attributes & DNS_RDATASETATTR_NEGATIVE) != 0) { if (NXDOMAIN(rdataset)) RETERR(str_totext(";-$NXDOMAIN\n", target)); else @@ -814,7 +812,7 @@ dump_rdatasets_text(isc_mem_t *mctx, dns if (ctx->style.flags & DNS_STYLEFLAG_TRUST) { fprintf(f, "; %s\n", dns_trust_totext(rds->trust)); } - if (rds->type == 0 && + if (((rds->attributes & DNS_RDATASETATTR_NEGATIVE) != 0) && (ctx->style.flags & DNS_STYLEFLAG_NCACHE) == 0) { /* Omit negative cache entries */ } else { @@ -979,7 +977,7 @@ dump_rdatasets_raw(isc_mem_t *mctx, dns_ dns_rdataset_init(&rdataset); dns_rdatasetiter_current(rdsiter, &rdataset); - if (rdataset.type == 0 && + if (((rdataset.attributes & DNS_RDATASETATTR_NEGATIVE) != 0) && (ctx->style.flags & DNS_STYLEFLAG_NCACHE) == 0) { /* Omit negative cache entries */ } else { Modified: head/contrib/bind9/lib/dns/message.c ============================================================================== --- head/contrib/bind9/lib/dns/message.c Wed Jul 6 00:47:27 2011 (r223811) +++ head/contrib/bind9/lib/dns/message.c Wed Jul 6 00:48:31 2011 (r223812) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2010 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: message.c,v 1.245.50.7 2010-06-03 05:29:03 marka Exp $ */ +/* $Id: message.c,v 1.245.50.7.6.3 2011-06-21 20:13:22 each Exp $ */ /*! \file */ @@ -2469,7 +2469,7 @@ dns_message_peekheader(isc_buffer_t *sou isc_result_t dns_message_reply(dns_message_t *msg, isc_boolean_t want_question_section) { - unsigned int first_section; + unsigned int clear_after; isc_result_t result; REQUIRE(DNS_MESSAGE_VALID(msg)); @@ -2481,15 +2481,15 @@ dns_message_reply(dns_message_t *msg, is msg->opcode != dns_opcode_notify) want_question_section = ISC_FALSE; if (msg->opcode == dns_opcode_update) - first_section = DNS_SECTION_ADDITIONAL; + clear_after = DNS_SECTION_PREREQUISITE; else if (want_question_section) { if (!msg->question_ok) return (DNS_R_FORMERR); - first_section = DNS_SECTION_ANSWER; + clear_after = DNS_SECTION_ANSWER; } else - first_section = DNS_SECTION_QUESTION; + clear_after = DNS_SECTION_QUESTION; msg->from_to_wire = DNS_MESSAGE_INTENTRENDER; - msgresetnames(msg, first_section); + msgresetnames(msg, clear_after); msgresetopt(msg); msgresetsigs(msg, ISC_TRUE); msginitprivate(msg); Modified: head/contrib/bind9/lib/dns/ncache.c ============================================================================== --- head/contrib/bind9/lib/dns/ncache.c Wed Jul 6 00:47:27 2011 (r223811) +++ head/contrib/bind9/lib/dns/ncache.c Wed Jul 6 00:48:31 2011 (r223812) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2008, 2010 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2008, 2010, 2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ncache.c,v 1.43.48.7.6.1 2011-05-27 00:19:19 each Exp $ */ +/* $Id: ncache.c,v 1.43.48.7.6.3 2011-06-21 20:13:22 each Exp $ */ /*! \file */ @@ -294,6 +294,7 @@ dns_ncache_addoptout(dns_message_t *mess RUNTIME_CHECK(dns_rdatalist_tordataset(&ncrdatalist, &ncrdataset) == ISC_R_SUCCESS); ncrdataset.trust = trust; + ncrdataset.attributes |= DNS_RDATASETATTR_NEGATIVE; if (message->rcode == dns_rcode_nxdomain) ncrdataset.attributes |= DNS_RDATASETATTR_NXDOMAIN; if (optout) @@ -324,6 +325,7 @@ dns_ncache_towire(dns_rdataset_t *rdatas REQUIRE(rdataset != NULL); REQUIRE(rdataset->type == 0); + REQUIRE((rdataset->attributes & DNS_RDATASETATTR_NEGATIVE) != 0); savedbuffer = *target; count = 0; @@ -552,6 +554,7 @@ dns_ncache_getrdataset(dns_rdataset_t *n REQUIRE(ncacherdataset != NULL); REQUIRE(ncacherdataset->type == 0); + REQUIRE((ncacherdataset->attributes & DNS_RDATASETATTR_NEGATIVE) != 0); REQUIRE(name != NULL); REQUIRE(!dns_rdataset_isassociated(rdataset)); REQUIRE(type != dns_rdatatype_rrsig); @@ -628,6 +631,7 @@ dns_ncache_getsigrdataset(dns_rdataset_t REQUIRE(ncacherdataset != NULL); REQUIRE(ncacherdataset->type == 0); + REQUIRE((ncacherdataset->attributes & DNS_RDATASETATTR_NEGATIVE) != 0); REQUIRE(name != NULL); REQUIRE(!dns_rdataset_isassociated(rdataset)); @@ -727,6 +731,7 @@ dns_ncache_current(dns_rdataset_t *ncach REQUIRE(ncacherdataset != NULL); REQUIRE(ncacherdataset->type == 0); + REQUIRE((ncacherdataset->attributes & DNS_RDATASETATTR_NEGATIVE) != 0); REQUIRE(found != NULL); REQUIRE(!dns_rdataset_isassociated(rdataset)); Modified: head/contrib/bind9/lib/dns/rbtdb.c ============================================================================== --- head/contrib/bind9/lib/dns/rbtdb.c Wed Jul 6 00:47:27 2011 (r223811) +++ head/contrib/bind9/lib/dns/rbtdb.c Wed Jul 6 00:48:31 2011 (r223812) @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rbtdb.c,v 1.270.12.26 2010-12-02 05:09:58 marka Exp $ */ +/* $Id: rbtdb.c,v 1.270.12.26.4.1 2011-06-21 20:13:23 each Exp $ */ /*! \file */ @@ -278,6 +278,7 @@ typedef ISC_LIST(dns_rbtnode_t) #define RDATASET_ATTR_RESIGN 0x0020 #define RDATASET_ATTR_STATCOUNT 0x0040 #define RDATASET_ATTR_OPTOUT 0x0080 +#define RDATASET_ATTR_NEGATIVE 0x0100 typedef struct acache_cbarg { dns_rdatasetadditional_t type; @@ -316,6 +317,8 @@ struct acachectl { (((header)->attributes & RDATASET_ATTR_RESIGN) != 0) #define OPTOUT(header) \ (((header)->attributes & RDATASET_ATTR_OPTOUT) != 0) +#define NEGATIVE(header) \ + (((header)->attributes & RDATASET_ATTR_NEGATIVE) != 0) #define DEFAULT_NODE_LOCK_COUNT 7 /*%< Should be prime. */ @@ -391,12 +394,15 @@ typedef ISC_LIST(rbtdb_version_t) typedef struct { /* Unlocked. */ dns_db_t common; + /* Locks the data in this struct */ #if DNS_RBTDB_USERWLOCK isc_rwlock_t lock; #else isc_mutex_t lock; #endif + /* Locks the tree structure (prevents nodes appearing/disappearing) */ isc_rwlock_t tree_lock; + /* Locks for individual tree nodes */ unsigned int node_lock_count; rbtdb_nodelock_t * node_locks; dns_rbtnode_t * origin_node; @@ -689,11 +695,13 @@ update_rrsetstats(dns_rbtdb_t *rbtdb, rd /* At the moment we count statistics only for cache DB */ INSIST(IS_CACHE(rbtdb)); - if (NXDOMAIN(header)) - statattributes = DNS_RDATASTATSTYPE_ATTR_NXDOMAIN; - else if (RBTDB_RDATATYPE_BASE(header->type) == 0) { - statattributes = DNS_RDATASTATSTYPE_ATTR_NXRRSET; - base = RBTDB_RDATATYPE_EXT(header->type); + if (NEGATIVE(header)) { + if (NXDOMAIN(header)) + statattributes = DNS_RDATASTATSTYPE_ATTR_NXDOMAIN; + else { + statattributes = DNS_RDATASTATSTYPE_ATTR_NXRRSET; + base = RBTDB_RDATATYPE_EXT(header->type); + } } else base = RBTDB_RDATATYPE_BASE(header->type); @@ -2727,6 +2735,8 @@ bind_rdataset(dns_rbtdb_t *rbtdb, dns_rb rdataset->covers = RBTDB_RDATATYPE_EXT(header->type); rdataset->ttl = header->rdh_ttl - now; rdataset->trust = header->trust; + if (NEGATIVE(header)) + rdataset->attributes |= DNS_RDATASETATTR_NEGATIVE; if (NXDOMAIN(header)) rdataset->attributes |= DNS_RDATASETATTR_NXDOMAIN; if (OPTOUT(header)) @@ -4636,7 +4646,7 @@ cache_find(dns_db_t *db, dns_name_t *nam *nodep = node; } - if (RBTDB_RDATATYPE_BASE(found->type) == 0) { + if (NEGATIVE(found)) { /* * We found a negative cache entry. */ @@ -5305,7 +5315,7 @@ cache_findrdataset(dns_db_t *db, dns_dbn if (found == NULL) return (ISC_R_NOTFOUND); - if (RBTDB_RDATATYPE_BASE(found->type) == 0) { + if (NEGATIVE(found)) { /* * We found a negative cache entry. */ @@ -5516,7 +5526,7 @@ add(dns_rbtdb_t *rbtdb, dns_rbtnode_t *r negtype = 0; if (rbtversion == NULL && !newheader_nx) { rdtype = RBTDB_RDATATYPE_BASE(newheader->type); - if (rdtype == 0) { + if (NEGATIVE(newheader)) { /* * We're adding a negative cache entry. */ @@ -6056,6 +6066,8 @@ addrdataset(dns_db_t *db, dns_dbnode_t * } else { newheader->serial = 1; newheader->resign = 0; + if ((rdataset->attributes & DNS_RDATASETATTR_NEGATIVE) != 0) + newheader->attributes |= RDATASET_ATTR_NEGATIVE; if ((rdataset->attributes & DNS_RDATASETATTR_NXDOMAIN) != 0) newheader->attributes |= RDATASET_ATTR_NXDOMAIN; if ((rdataset->attributes & DNS_RDATASETATTR_OPTOUT) != 0) @@ -6780,7 +6792,7 @@ getsigningtime(dns_db_t *db, dns_rdatase REQUIRE(VALID_RBTDB(rbtdb)); - RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_read); + RWLOCK(&rbtdb->tree_lock, isc_rwlocktype_read); for (i = 0; i < rbtdb->node_lock_count; i++) { NODE_LOCK(&rbtdb->node_locks[i].lock, isc_rwlocktype_read); @@ -6816,7 +6828,7 @@ getsigningtime(dns_db_t *db, dns_rdatase result = ISC_R_SUCCESS; unlock: - RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_read); + RWUNLOCK(&rbtdb->tree_lock, isc_rwlocktype_read); return (result); } @@ -6838,7 +6850,7 @@ resigned(dns_db_t *db, dns_rdataset_t *r header = rdataset->private3; header--; - RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_write); + RWLOCK(&rbtdb->tree_lock, isc_rwlocktype_write); NODE_LOCK(&rbtdb->node_locks[node->locknum].lock, isc_rwlocktype_write); /* @@ -6852,7 +6864,7 @@ resigned(dns_db_t *db, dns_rdataset_t *r NODE_UNLOCK(&rbtdb->node_locks[node->locknum].lock, isc_rwlocktype_write); - RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_write); + RWUNLOCK(&rbtdb->tree_lock, isc_rwlocktype_write); } static dns_stats_t * @@ -7638,7 +7650,7 @@ rdatasetiter_next(dns_rdatasetiter_t *it type = header->type; rdtype = RBTDB_RDATATYPE_BASE(header->type); - if (rdtype == 0) { + if (NEGATIVE(header)) { covers = RBTDB_RDATATYPE_EXT(header->type); negtype = RBTDB_RDATATYPE_VALUE(covers, 0); } else Modified: head/contrib/bind9/lib/dns/rdataset.c ============================================================================== --- head/contrib/bind9/lib/dns/rdataset.c Wed Jul 6 00:47:27 2011 (r223811) +++ head/contrib/bind9/lib/dns/rdataset.c Wed Jul 6 00:48:31 2011 (r223812) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2010 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rdataset.c,v 1.82.50.4.6.1 2011-05-27 00:19:19 each Exp $ */ +/* $Id: rdataset.c,v 1.82.50.4.6.3 2011-06-21 20:13:23 each Exp $ */ /*! \file */ @@ -345,7 +345,7 @@ towiresorted(dns_rdataset_t *rdataset, c count = 1; result = dns_rdataset_first(rdataset); INSIST(result == ISC_R_NOMORE); - } else if (rdataset->type == 0) { + } else if ((rdataset->attributes & DNS_RDATASETATTR_NEGATIVE) != 0) { /* * This is a negative caching rdataset. */ Modified: head/contrib/bind9/lib/dns/resolver.c ============================================================================== --- head/contrib/bind9/lib/dns/resolver.c Wed Jul 6 00:47:27 2011 (r223811) +++ head/contrib/bind9/lib/dns/resolver.c Wed Jul 6 00:48:31 2011 (r223812) @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: resolver.c,v 1.384.14.30 2011-01-27 23:45:47 tbox Exp $ */ +/* $Id: resolver.c,v 1.384.14.30.4.1 2011-06-21 20:13:23 each Exp $ */ /*! \file */ @@ -424,6 +424,7 @@ struct dns_resolver { FCTX_ADDRINFO_TRIED) != 0) #define NXDOMAIN(r) (((r)->attributes & DNS_RDATASETATTR_NXDOMAIN) != 0) +#define NEGATIVE(r) (((r)->attributes & DNS_RDATASETATTR_NEGATIVE) != 0) static void destroy(dns_resolver_t *res); static void empty_bucket(dns_resolver_t *res); @@ -1047,7 +1048,7 @@ fctx_sendevents(fetchctx_t *fctx, isc_re * Negative results must be indicated in event->result. */ if (dns_rdataset_isassociated(event->rdataset) && - event->rdataset->type == dns_rdatatype_none) { + NEGATIVE(event->rdataset)) { INSIST(event->result == DNS_R_NCACHENXDOMAIN || event->result == DNS_R_NCACHENXRRSET); } @@ -4177,7 +4178,7 @@ validated(isc_task_t *task, isc_event_t if (result != ISC_R_SUCCESS && result != DNS_R_UNCHANGED) goto noanswer_response; - if (ardataset != NULL && ardataset->type == 0) { + if (ardataset != NULL && NEGATIVE(ardataset)) { if (NXDOMAIN(ardataset)) eresult = DNS_R_NCACHENXDOMAIN; else @@ -4498,7 +4499,7 @@ cache_name(fetchctx_t *fctx, dns_name_t result = ISC_R_SUCCESS; if (!need_validation && ardataset != NULL && - ardataset->type == 0) { + NEGATIVE(ardataset)) { /* * The answer in the cache is * better than the answer we @@ -4628,7 +4629,7 @@ cache_name(fetchctx_t *fctx, dns_name_t if (result == DNS_R_UNCHANGED) { if (ANSWER(rdataset) && ardataset != NULL && - ardataset->type == 0) { + NEGATIVE(ardataset)) { /* * The answer in the cache is better * than the answer we found, and is @@ -4658,7 +4659,7 @@ cache_name(fetchctx_t *fctx, dns_name_t * Negative results must be indicated in event->result. */ if (dns_rdataset_isassociated(event->rdataset) && - event->rdataset->type == dns_rdatatype_none) { + NEGATIVE(event->rdataset)) { INSIST(eresult == DNS_R_NCACHENXDOMAIN || eresult == DNS_R_NCACHENXRRSET); } @@ -4738,7 +4739,7 @@ ncache_adderesult(dns_message_t *message * care about whether it is DNS_R_NCACHENXDOMAIN or * DNS_R_NCACHENXRRSET then extract it. */ - if (ardataset->type == 0) { + if (NEGATIVE(ardataset)) { /* * The cache data is a negative cache entry. */ Modified: head/contrib/bind9/lib/dns/validator.c ============================================================================== --- head/contrib/bind9/lib/dns/validator.c Wed Jul 6 00:47:27 2011 (r223811) +++ head/contrib/bind9/lib/dns/validator.c Wed Jul 6 00:48:31 2011 (r223812) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2010 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: validator.c,v 1.164.12.23.4.1 2011-05-27 00:19:19 each Exp $ */ +/* $Id: validator.c,v 1.164.12.23.4.3 2011-06-21 20:13:23 each Exp $ */ #include @@ -129,6 +129,8 @@ #define SHUTDOWN(v) (((v)->attributes & VALATTR_SHUTDOWN) != 0) #define CANCELED(v) (((v)->attributes & VALATTR_CANCELED) != 0) +#define NEGATIVE(r) (((r)->attributes & DNS_RDATASETATTR_NEGATIVE) != 0) + static void destroy(dns_validator_t *val); @@ -733,7 +735,7 @@ dsvalidated(isc_task_t *task, isc_event_ name = dns_fixedname_name(&val->fname); if ((val->attributes & VALATTR_INSECURITY) != 0 && val->frdataset.covers == dns_rdatatype_ds && - val->frdataset.type == 0 && + NEGATIVE(&val->frdataset) && isdelegation(name, &val->frdataset, DNS_R_NCACHENXRRSET)) { if (val->mustbesecure) { validator_log(val, ISC_LOG_WARNING, @@ -3909,7 +3911,7 @@ validator_start(isc_task_t *task, isc_ev val->attributes |= VALATTR_NEEDNODATA; result = nsecvalidate(val, ISC_FALSE); } else if (val->event->rdataset != NULL && - val->event->rdataset->type == 0) + NEGATIVE(val->event->rdataset)) { /* * This is a nonexistence validation. Modified: head/contrib/bind9/version ============================================================================== --- head/contrib/bind9/version Wed Jul 6 00:47:27 2011 (r223811) +++ head/contrib/bind9/version Wed Jul 6 00:48:31 2011 (r223812) @@ -1,4 +1,4 @@ -# $Id: version,v 1.43.12.11.2.2.2.1 2011-05-27 00:19:16 each Exp $ +# $Id: version,v 1.43.12.11.2.2.2.3 2011-06-21 20:35:59 each Exp $ # # This file must follow /bin/sh rules. It is imported directly via # configure. @@ -7,4 +7,4 @@ MAJORVER=9 MINORVER=6 PATCHVER= RELEASETYPE=-ESV -RELEASEVER=-R4-P1 +RELEASEVER=-R4-P3 From owner-svn-src-head@FreeBSD.ORG Wed Jul 6 06:34:08 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9124D106564A; Wed, 6 Jul 2011 06:34:08 +0000 (UTC) (envelope-from gordon@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 807FB8FC12; Wed, 6 Jul 2011 06:34:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p666Y8q4003237; Wed, 6 Jul 2011 06:34:08 GMT (envelope-from gordon@svn.freebsd.org) Received: (from gordon@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p666Y8iu003235; Wed, 6 Jul 2011 06:34:08 GMT (envelope-from gordon@svn.freebsd.org) Message-Id: <201107060634.p666Y8iu003235@svn.freebsd.org> From: Gordon Tetlow Date: Wed, 6 Jul 2011 06:34:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223818 - head/usr.sbin/pwd_mkdb X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jul 2011 06:34:08 -0000 Author: gordon Date: Wed Jul 6 06:34:08 2011 New Revision: 223818 URL: http://svn.freebsd.org/changeset/base/223818 Log: Only increment the ypcnt once per data record. The old implementation was incrementing it twice making it impossible to iterate the table since the records were 1, 3, 5, 7 (or 2, 4, 6, 8 for the v3 records). MFC after: 10 days Modified: head/usr.sbin/pwd_mkdb/pwd_mkdb.c Modified: head/usr.sbin/pwd_mkdb/pwd_mkdb.c ============================================================================== --- head/usr.sbin/pwd_mkdb/pwd_mkdb.c Wed Jul 6 05:42:52 2011 (r223817) +++ head/usr.sbin/pwd_mkdb/pwd_mkdb.c Wed Jul 6 06:34:08 2011 (r223818) @@ -351,14 +351,16 @@ main(int argc, char *argv[]) if ((dp->put)(sdp, &key, &data, 0) == -1) error("put"); } - ypcnt = 1; + ypcnt = 0; data.data = (u_char *)buf; sdata.data = (u_char *)sbuf; key.data = (u_char *)tbuf; for (cnt = 1; scan(fp, &pwd); ++cnt) { if (!is_comment && - (pwd.pw_name[0] == '+' || pwd.pw_name[0] == '-')) + (pwd.pw_name[0] == '+' || pwd.pw_name[0] == '-')) { yp_enabled = 1; + ypcnt++; + } if (is_comment) --cnt; #define COMPACT(e) t = e; while ((*p++ = *t++)); @@ -456,7 +458,6 @@ main(int argc, char *argv[]) tbuf[0] = CURRENT_VERSION(_PW_KEYYPBYNUM); store = htonl(ypcnt); memmove(tbuf + 1, &store, sizeof(store)); - ypcnt++; key.size = sizeof(store) + 1; if ((dp->put)(dp, &key, &data, method) == -1) error("put"); @@ -547,7 +548,6 @@ main(int argc, char *argv[]) tbuf[0] = LEGACY_VERSION(_PW_KEYYPBYNUM); store = HTOL(ypcnt); memmove(tbuf + 1, &store, sizeof(store)); - ypcnt++; key.size = sizeof(store) + 1; if ((dp->put)(dp, &key, &data, method) == -1) error("put"); From owner-svn-src-head@FreeBSD.ORG Wed Jul 6 09:43:26 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4DCF6106566B; Wed, 6 Jul 2011 09:43:26 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3D3B38FC0A; Wed, 6 Jul 2011 09:43:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p669hQnI009191; Wed, 6 Jul 2011 09:43:26 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p669hQoI009189; Wed, 6 Jul 2011 09:43:26 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201107060943.p669hQoI009189@svn.freebsd.org> From: Gleb Smirnoff Date: Wed, 6 Jul 2011 09:43:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223822 - head/sys/netgraph/netflow X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jul 2011 09:43:26 -0000 Author: glebius Date: Wed Jul 6 09:43:25 2011 New Revision: 223822 URL: http://svn.freebsd.org/changeset/base/223822 Log: Add missing unlocks. Modified: head/sys/netgraph/netflow/netflow.c Modified: head/sys/netgraph/netflow/netflow.c ============================================================================== --- head/sys/netgraph/netflow/netflow.c Wed Jul 6 07:13:28 2011 (r223821) +++ head/sys/netgraph/netflow/netflow.c Wed Jul 6 09:43:25 2011 (r223822) @@ -970,6 +970,7 @@ struct ngnf_show_header *resp) if (hsh->mtx.mtx_lock & MTX_CONTESTED) { resp->hash_id = i; resp->list_id = list_id; + mtx_unlock(&hsh->mtx); return (0); } @@ -1001,6 +1002,7 @@ struct ngnf_show_header *resp) * we simply skip to next hash_id. */ resp->list_id = list_id + 1; + mtx_unlock(&hsh->mtx); return (0); } } From owner-svn-src-head@FreeBSD.ORG Wed Jul 6 15:09:52 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B6AC2106566C; Wed, 6 Jul 2011 15:09:52 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A76748FC0C; Wed, 6 Jul 2011 15:09:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p66F9qIg021372; Wed, 6 Jul 2011 15:09:52 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p66F9qVG021370; Wed, 6 Jul 2011 15:09:52 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201107061509.p66F9qVG021370@svn.freebsd.org> From: Attilio Rao Date: Wed, 6 Jul 2011 15:09:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223823 - head/sys/vm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jul 2011 15:09:52 -0000 Author: attilio Date: Wed Jul 6 15:09:52 2011 New Revision: 223823 URL: http://svn.freebsd.org/changeset/base/223823 Log: Handle a race between device_pager and devsw in a more graceful manner: return an error code rather than panic the kernel. Sponsored by: Sandvine Incorporated Reviewed by: kib Tested by: pho MFC after: 2 weeks Modified: head/sys/vm/device_pager.c Modified: head/sys/vm/device_pager.c ============================================================================== --- head/sys/vm/device_pager.c Wed Jul 6 09:43:25 2011 (r223822) +++ head/sys/vm/device_pager.c Wed Jul 6 15:09:52 2011 (r223823) @@ -217,8 +217,10 @@ dev_pager_getpages(object, m, count, req memattr = object->memattr; VM_OBJECT_UNLOCK(object); csw = dev_refthread(dev, &ref); - if (csw == NULL) - panic("dev_pager_getpage: no cdevsw"); + if (csw == NULL) { + VM_OBJECT_LOCK(object); + return (VM_PAGER_FAIL); + } td = curthread; fpop = td->td_fpop; td->td_fpop = NULL; From owner-svn-src-head@FreeBSD.ORG Wed Jul 6 15:18:33 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2829E1065670; Wed, 6 Jul 2011 15:18:33 +0000 (UTC) (envelope-from pluknet@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0E6558FC0A; Wed, 6 Jul 2011 15:18:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p66FIWXJ021669; Wed, 6 Jul 2011 15:18:32 GMT (envelope-from pluknet@svn.freebsd.org) Received: (from pluknet@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p66FIWRc021666; Wed, 6 Jul 2011 15:18:32 GMT (envelope-from pluknet@svn.freebsd.org) Message-Id: <201107061518.p66FIWRc021666@svn.freebsd.org> From: Sergey Kandaurov Date: Wed, 6 Jul 2011 15:18:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223824 - head/usr.sbin/flowctl X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jul 2011 15:18:33 -0000 Author: pluknet Date: Wed Jul 6 15:18:32 2011 New Revision: 223824 URL: http://svn.freebsd.org/changeset/base/223824 Log: Conditionally compile in the IPv4/IPv6 address family support. Test it with feature_present(3), so that we do not end up with passing an unsupported version to NgSendMsg(3). Approved by: glebius Modified: head/usr.sbin/flowctl/Makefile head/usr.sbin/flowctl/flowctl.c Modified: head/usr.sbin/flowctl/Makefile ============================================================================== --- head/usr.sbin/flowctl/Makefile Wed Jul 6 15:09:52 2011 (r223823) +++ head/usr.sbin/flowctl/Makefile Wed Jul 6 15:18:32 2011 (r223824) @@ -14,7 +14,8 @@ LDADD= -lnetgraph .if ${MK_INET6_SUPPORT} != "no" CFLAGS+= -DINET6 .endif - -CFLAGS+= -I. +.if ${MK_INET_SUPPORT} != "no" +CFLAGS+= -DINET +.endif .include Modified: head/usr.sbin/flowctl/flowctl.c ============================================================================== --- head/usr.sbin/flowctl/flowctl.c Wed Jul 6 15:09:52 2011 (r223823) +++ head/usr.sbin/flowctl/flowctl.c Wed Jul 6 15:18:32 2011 (r223824) @@ -69,12 +69,18 @@ static const char rcs_id[] = #define CISCO_SH_VERB_FLOW6 "%-14s %-30s %-14s %-30s %2u %3x %4x %6lu\n" \ "%4.4x /%-2u %-5u %4.4x /%-2u %-5u %-30s %9u %8u\n\n" +#ifdef INET static void flow_cache_print(struct ngnf_show_header *resp); -static void flow_cache_print6(struct ngnf_show_header *resp); static void flow_cache_print_verbose(struct ngnf_show_header *resp); +#endif +#ifdef INET6 +static void flow_cache_print6(struct ngnf_show_header *resp); static void flow_cache_print6_verbose(struct ngnf_show_header *resp); +#endif static void ctl_show(int, char **); +#if defined(INET) || defined(INET6) static void do_show(int, void (*func)(struct ngnf_show_header *)); +#endif static void help(void); static void execute_command(int, char **); @@ -157,7 +163,10 @@ execute_command(int argc, char **argv) static void ctl_show(int argc, char **argv) { - int ipv4 = 1, ipv6 = 1, verbose = 0; + int ipv4, ipv6, verbose = 0; + + ipv4 = feature_present("inet"); + ipv6 = feature_present("inet6"); if (argc > 0 && !strncmp(argv[0], "ipv4", 4)) { ipv6 = 0; @@ -173,21 +182,26 @@ ctl_show(int argc, char **argv) if (argc > 0 && !strncmp(argv[0], "verbose", strlen(argv[0]))) verbose = 1; +#ifdef INET if (ipv4) { if (verbose) do_show(4, &flow_cache_print_verbose); else do_show(4, &flow_cache_print); } +#endif +#ifdef INET6 if (ipv6) { if (verbose) do_show(6, &flow_cache_print6_verbose); else do_show(6, &flow_cache_print6); } +#endif } +#if defined(INET) || defined(INET6) static void do_show(int version, void (*func)(struct ngnf_show_header *)) { @@ -230,7 +244,9 @@ do_show(int version, void (*func)(struct req.list_id = resp->list_id; } } +#endif +#ifdef INET static void flow_cache_print(struct ngnf_show_header *resp) { @@ -261,6 +277,7 @@ flow_cache_print(struct ngnf_show_header } } +#endif #ifdef INET6 static void @@ -295,6 +312,7 @@ flow_cache_print6(struct ngnf_show_heade } #endif +#ifdef INET static void flow_cache_print_verbose(struct ngnf_show_header *resp) { @@ -335,6 +353,7 @@ flow_cache_print_verbose(struct ngnf_sho } } +#endif #ifdef INET6 static void From owner-svn-src-head@FreeBSD.ORG Wed Jul 6 20:06:45 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4F3F0106564A; Wed, 6 Jul 2011 20:06:45 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3D4748FC08; Wed, 6 Jul 2011 20:06:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p66K6jqm030307; Wed, 6 Jul 2011 20:06:45 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p66K6jwZ030292; Wed, 6 Jul 2011 20:06:45 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201107062006.p66K6jwZ030292@svn.freebsd.org> From: Edward Tomasz Napierala Date: Wed, 6 Jul 2011 20:06:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223825 - in head/sys: kern vm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jul 2011 20:06:45 -0000 Author: trasz Date: Wed Jul 6 20:06:44 2011 New Revision: 223825 URL: http://svn.freebsd.org/changeset/base/223825 Log: All the racct_*() calls need to happen with the proc locked. Fixing this won't happen before 9.0. This commit adds "#ifdef RACCT" around all the "PROC_LOCK(p); racct_whatever(p, ...); PROC_UNLOCK(p)" instances, in order to avoid useless locking/unlocking in kernels built without "options RACCT". Modified: head/sys/kern/imgact_elf.c head/sys/kern/kern_descrip.c head/sys/kern/kern_exit.c head/sys/kern/kern_fork.c head/sys/kern/kern_thr.c head/sys/kern/sysv_msg.c head/sys/kern/sysv_sem.c head/sys/kern/sysv_shm.c head/sys/vm/swap_pager.c head/sys/vm/vm_glue.c head/sys/vm/vm_map.c head/sys/vm/vm_mmap.c head/sys/vm/vm_pageout.c head/sys/vm/vm_unix.c Modified: head/sys/kern/imgact_elf.c ============================================================================== --- head/sys/kern/imgact_elf.c Wed Jul 6 15:18:32 2011 (r223824) +++ head/sys/kern/imgact_elf.c Wed Jul 6 20:06:44 2011 (r223825) @@ -1115,6 +1115,7 @@ __elfN(coredump)(struct thread *td, stru hdrsize = 0; __elfN(puthdr)(td, (void *)NULL, &hdrsize, seginfo.count); +#ifdef RACCT PROC_LOCK(td->td_proc); error = racct_add(td->td_proc, RACCT_CORE, hdrsize + seginfo.size); PROC_UNLOCK(td->td_proc); @@ -1122,6 +1123,7 @@ __elfN(coredump)(struct thread *td, stru error = EFAULT; goto done; } +#endif if (hdrsize + seginfo.size >= limit) { error = EFAULT; goto done; Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Wed Jul 6 15:18:32 2011 (r223824) +++ head/sys/kern/kern_descrip.c Wed Jul 6 20:06:44 2011 (r223825) @@ -821,6 +821,7 @@ do_dup(struct thread *td, int flags, int * descriptors, just put the limit on the size of the file * descriptor table. */ +#ifdef RACCT PROC_LOCK(p); error = racct_set(p, RACCT_NOFILE, new + 1); PROC_UNLOCK(p); @@ -829,6 +830,7 @@ do_dup(struct thread *td, int flags, int fdrop(fp, td); return (EMFILE); } +#endif fdgrowtable(fdp, new + 1); } if (fdp->fd_ofiles[new] == NULL) @@ -1476,7 +1478,10 @@ fdalloc(struct thread *td, int minfd, in { struct proc *p = td->td_proc; struct filedesc *fdp = p->p_fd; - int fd = -1, maxfd, error; + int fd = -1, maxfd; +#ifdef RACCT + int error; +#endif FILEDESC_XLOCK_ASSERT(fdp); @@ -1499,11 +1504,13 @@ fdalloc(struct thread *td, int minfd, in return (EMFILE); if (fd < fdp->fd_nfiles) break; +#ifdef RACCT PROC_LOCK(p); error = racct_set(p, RACCT_NOFILE, min(fdp->fd_nfiles * 2, maxfd)); PROC_UNLOCK(p); if (error != 0) return (EMFILE); +#endif fdgrowtable(fdp, min(fdp->fd_nfiles * 2, maxfd)); } @@ -1819,9 +1826,11 @@ fdfree(struct thread *td) if (fdp == NULL) return; +#ifdef RACCT PROC_LOCK(td->td_proc); racct_set(td->td_proc, RACCT_NOFILE, 0); PROC_UNLOCK(td->td_proc); +#endif /* Check for special need to clear POSIX style locks */ fdtol = td->td_proc->p_fdtol; Modified: head/sys/kern/kern_exit.c ============================================================================== --- head/sys/kern/kern_exit.c Wed Jul 6 15:18:32 2011 (r223824) +++ head/sys/kern/kern_exit.c Wed Jul 6 20:06:44 2011 (r223825) @@ -744,9 +744,11 @@ proc_reap(struct thread *td, struct proc * Destroy resource accounting information associated with the process. */ racct_proc_exit(p); +#ifdef RACCT PROC_LOCK(p->p_pptr); racct_sub(p->p_pptr, RACCT_NPROC, 1); PROC_UNLOCK(p->p_pptr); +#endif /* * Free credentials, arguments, and sigacts. @@ -905,19 +907,23 @@ loop: void proc_reparent(struct proc *child, struct proc *parent) { +#ifdef RACCT int locked; +#endif sx_assert(&proctree_lock, SX_XLOCKED); PROC_LOCK_ASSERT(child, MA_OWNED); if (child->p_pptr == parent) return; +#ifdef RACCT locked = PROC_LOCKED(parent); if (!locked) PROC_LOCK(parent); racct_add_force(parent, RACCT_NPROC, 1); if (!locked) PROC_UNLOCK(parent); +#endif PROC_LOCK(child->p_pptr); racct_sub(child->p_pptr, RACCT_NPROC, 1); sigqueue_take(child->p_ksi); Modified: head/sys/kern/kern_fork.c ============================================================================== --- head/sys/kern/kern_fork.c Wed Jul 6 15:18:32 2011 (r223824) +++ head/sys/kern/kern_fork.c Wed Jul 6 20:06:44 2011 (r223825) @@ -734,11 +734,13 @@ fork1(struct thread *td, int flags, int return (fork_norfproc(td, flags)); } +#ifdef RACCT PROC_LOCK(p1); error = racct_add(p1, RACCT_NPROC, 1); PROC_UNLOCK(p1); if (error != 0) return (EAGAIN); +#endif mem_charged = 0; vm2 = NULL; @@ -822,6 +824,7 @@ fork1(struct thread *td, int flags, int goto fail; } +#ifdef RACCT /* * After fork, there is exactly one thread running. */ @@ -832,6 +835,7 @@ fork1(struct thread *td, int flags, int error = EAGAIN; goto fail; } +#endif /* * Increment the count of procs running with this uid. Don't allow @@ -874,9 +878,11 @@ fail1: vmspace_free(vm2); uma_zfree(proc_zone, newproc); pause("fork", hz / 2); +#ifdef RACCT PROC_LOCK(p1); racct_sub(p1, RACCT_NPROC, 1); PROC_UNLOCK(p1); +#endif return (error); } Modified: head/sys/kern/kern_thr.c ============================================================================== --- head/sys/kern/kern_thr.c Wed Jul 6 15:18:32 2011 (r223824) +++ head/sys/kern/kern_thr.c Wed Jul 6 20:06:44 2011 (r223825) @@ -185,11 +185,13 @@ create_thread(struct thread *td, mcontex } } +#ifdef RACCT PROC_LOCK(td->td_proc); error = racct_add(p, RACCT_NTHR, 1); PROC_UNLOCK(td->td_proc); if (error != 0) return (EPROCLIM); +#endif /* Initialize our td */ newtd = thread_alloc(0); @@ -277,9 +279,11 @@ create_thread(struct thread *td, mcontex return (0); fail: +#ifdef RACCT PROC_LOCK(p); racct_sub(p, RACCT_NTHR, 1); PROC_UNLOCK(p); +#endif return (error); } Modified: head/sys/kern/sysv_msg.c ============================================================================== --- head/sys/kern/sysv_msg.c Wed Jul 6 15:18:32 2011 (r223824) +++ head/sys/kern/sysv_msg.c Wed Jul 6 20:06:44 2011 (r223825) @@ -620,6 +620,7 @@ msgget(td, uap) error = ENOSPC; goto done2; } +#ifdef RACCT PROC_LOCK(td->td_proc); error = racct_add(td->td_proc, RACCT_NMSGQ, 1); PROC_UNLOCK(td->td_proc); @@ -627,6 +628,7 @@ msgget(td, uap) error = ENOSPC; goto done2; } +#endif DPRINTF(("msqid %d is available\n", msqid)); msqkptr->u.msg_perm.key = key; msqkptr->u.msg_perm.cuid = cred->cr_uid; @@ -685,7 +687,9 @@ kern_msgsnd(td, msqid, msgp, msgsz, msgf register struct msqid_kernel *msqkptr; register struct msg *msghdr; short next; +#ifdef RACCT size_t saved_msgsz; +#endif if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC)) return (ENOSYS); @@ -723,6 +727,7 @@ kern_msgsnd(td, msqid, msgp, msgsz, msgf goto done2; #endif +#ifdef RACCT PROC_LOCK(td->td_proc); if (racct_add(td->td_proc, RACCT_MSGQQUEUED, 1)) { PROC_UNLOCK(td->td_proc); @@ -737,6 +742,7 @@ kern_msgsnd(td, msqid, msgp, msgsz, msgf goto done2; } PROC_UNLOCK(td->td_proc); +#endif segs_needed = (msgsz + msginfo.msgssz - 1) / msginfo.msgssz; DPRINTF(("msgsz=%zu, msgssz=%d, segs_needed=%d\n", msgsz, @@ -991,12 +997,14 @@ kern_msgsnd(td, msqid, msgp, msgsz, msgf wakeup(msqkptr); td->td_retval[0] = 0; done3: +#ifdef RACCT if (error != 0) { PROC_LOCK(td->td_proc); racct_sub(td->td_proc, RACCT_MSGQQUEUED, 1); racct_sub(td->td_proc, RACCT_MSGQSIZE, saved_msgsz); PROC_UNLOCK(td->td_proc); } +#endif done2: mtx_unlock(&msq_mtx); return (error); Modified: head/sys/kern/sysv_sem.c ============================================================================== --- head/sys/kern/sysv_sem.c Wed Jul 6 15:18:32 2011 (r223824) +++ head/sys/kern/sysv_sem.c Wed Jul 6 20:06:44 2011 (r223825) @@ -931,6 +931,7 @@ semget(struct thread *td, struct semget_ error = ENOSPC; goto done2; } +#ifdef RACCT PROC_LOCK(td->td_proc); error = racct_add(td->td_proc, RACCT_NSEM, nsems); PROC_UNLOCK(td->td_proc); @@ -938,6 +939,7 @@ semget(struct thread *td, struct semget_ error = ENOSPC; goto done2; } +#endif DPRINTF(("semid %d is available\n", semid)); mtx_lock(&sema_mtx[semid]); KASSERT((sema[semid].u.sem_perm.mode & SEM_ALLOC) == 0, @@ -1023,12 +1025,14 @@ semop(struct thread *td, struct semop_ar nsops)); return (E2BIG); } else { +#ifdef RACCT PROC_LOCK(td->td_proc); if (nsops > racct_get_available(td->td_proc, RACCT_NSEMOP)) { PROC_UNLOCK(td->td_proc); return (E2BIG); } PROC_UNLOCK(td->td_proc); +#endif sops = malloc(nsops * sizeof(*sops), M_TEMP, M_WAITOK); } Modified: head/sys/kern/sysv_shm.c ============================================================================== --- head/sys/kern/sysv_shm.c Wed Jul 6 15:18:32 2011 (r223824) +++ head/sys/kern/sysv_shm.c Wed Jul 6 20:06:44 2011 (r223825) @@ -672,6 +672,7 @@ shmget_allocate_segment(td, uap, mode) shm_last_free = -1; } shmseg = &shmsegs[segnum]; +#ifdef RACCT PROC_LOCK(td->td_proc); if (racct_add(td->td_proc, RACCT_NSHM, 1)) { PROC_UNLOCK(td->td_proc); @@ -683,6 +684,7 @@ shmget_allocate_segment(td, uap, mode) return (ENOMEM); } PROC_UNLOCK(td->td_proc); +#endif /* * In case we sleep in malloc(), mark the segment present but deleted * so that noone else tries to create the same key. @@ -699,10 +701,12 @@ shmget_allocate_segment(td, uap, mode) shm_object = vm_pager_allocate(shm_use_phys ? OBJT_PHYS : OBJT_SWAP, 0, size, VM_PROT_DEFAULT, 0, cred); if (shm_object == NULL) { +#ifdef RACCT PROC_LOCK(td->td_proc); racct_sub(td->td_proc, RACCT_NSHM, 1); racct_sub(td->td_proc, RACCT_SHMSIZE, size); PROC_UNLOCK(td->td_proc); +#endif return (ENOMEM); } VM_OBJECT_LOCK(shm_object); Modified: head/sys/vm/swap_pager.c ============================================================================== --- head/sys/vm/swap_pager.c Wed Jul 6 15:18:32 2011 (r223824) +++ head/sys/vm/swap_pager.c Wed Jul 6 20:06:44 2011 (r223825) @@ -193,11 +193,13 @@ swap_reserve_by_cred(vm_ooffset_t incr, if (incr & PAGE_MASK) panic("swap_reserve: & PAGE_MASK"); +#ifdef RACCT PROC_LOCK(curproc); error = racct_add(curproc, RACCT_SWAP, incr); PROC_UNLOCK(curproc); if (error != 0) return (0); +#endif res = 0; mtx_lock(&sw_dev_mtx); @@ -237,11 +239,13 @@ swap_reserve_by_cred(vm_ooffset_t incr, curproc->p_pid, uip->ui_uid, incr); } +#ifdef RACCT if (!res) { PROC_LOCK(curproc); racct_sub(curproc, RACCT_SWAP, incr); PROC_UNLOCK(curproc); } +#endif return (res); } @@ -255,9 +259,11 @@ swap_reserve_force(vm_ooffset_t incr) swap_reserved += incr; mtx_unlock(&sw_dev_mtx); +#ifdef RACCT PROC_LOCK(curproc); racct_add_force(curproc, RACCT_SWAP, incr); PROC_UNLOCK(curproc); +#endif uip = curthread->td_ucred->cr_ruidinfo; PROC_LOCK(curproc); Modified: head/sys/vm/vm_glue.c ============================================================================== --- head/sys/vm/vm_glue.c Wed Jul 6 15:18:32 2011 (r223824) +++ head/sys/vm/vm_glue.c Wed Jul 6 20:06:44 2011 (r223825) @@ -222,12 +222,14 @@ vslock(void *addr, size_t len) #endif error = vm_map_wire(&curproc->p_vmspace->vm_map, start, end, VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES); +#ifdef RACCT if (error != KERN_SUCCESS) { PROC_LOCK(curproc); racct_set(curproc, RACCT_MEMLOCK, ptoa(pmap_wired_count(vm_map_pmap(&curproc->p_vmspace->vm_map)))); PROC_UNLOCK(curproc); } +#endif /* * Return EFAULT on error to match copy{in,out}() behaviour * rather than returning ENOMEM like mlock() would. @@ -244,10 +246,12 @@ vsunlock(void *addr, size_t len) trunc_page((vm_offset_t)addr), round_page((vm_offset_t)addr + len), VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES); +#ifdef RACCT PROC_LOCK(curproc); racct_set(curproc, RACCT_MEMLOCK, ptoa(pmap_wired_count(vm_map_pmap(&curproc->p_vmspace->vm_map)))); PROC_UNLOCK(curproc); +#endif } /* Modified: head/sys/vm/vm_map.c ============================================================================== --- head/sys/vm/vm_map.c Wed Jul 6 15:18:32 2011 (r223824) +++ head/sys/vm/vm_map.c Wed Jul 6 20:06:44 2011 (r223825) @@ -318,6 +318,7 @@ static void vmspace_container_reset(struct proc *p) { +#ifdef RACCT PROC_LOCK(p); racct_set(p, RACCT_DATA, 0); racct_set(p, RACCT_STACK, 0); @@ -325,6 +326,7 @@ vmspace_container_reset(struct proc *p) racct_set(p, RACCT_MEMLOCK, 0); racct_set(p, RACCT_VMEM, 0); PROC_UNLOCK(p); +#endif } static inline void @@ -3305,7 +3307,9 @@ vm_map_growstack(struct proc *p, vm_offs #ifdef notyet uint64_t limit; #endif +#ifdef RACCT int error; +#endif Retry: PROC_LOCK(p); @@ -3404,6 +3408,7 @@ Retry: vm_map_unlock_read(map); return (KERN_NO_SPACE); } +#ifdef RACCT PROC_LOCK(p); if (is_procstack && racct_set(p, RACCT_STACK, ctob(vm->vm_ssize) + grow_amount)) { @@ -3412,6 +3417,7 @@ Retry: return (KERN_NO_SPACE); } PROC_UNLOCK(p); +#endif /* Round up the grow amount modulo SGROWSIZ */ grow_amount = roundup (grow_amount, sgrowsiz); @@ -3435,6 +3441,7 @@ Retry: rv = KERN_NO_SPACE; goto out; } +#ifdef RACCT PROC_LOCK(p); if (racct_set(p, RACCT_VMEM, map->size + grow_amount)) { PROC_UNLOCK(p); @@ -3443,6 +3450,7 @@ Retry: goto out; } PROC_UNLOCK(p); +#endif if (vm_map_lock_upgrade(map)) goto Retry; @@ -3542,6 +3550,7 @@ Retry: } out: +#ifdef RACCT if (rv != KERN_SUCCESS) { PROC_LOCK(p); error = racct_set(p, RACCT_VMEM, map->size); @@ -3550,6 +3559,7 @@ out: KASSERT(error == 0, ("decreasing RACCT_STACK failed")); PROC_UNLOCK(p); } +#endif return (rv); } Modified: head/sys/vm/vm_mmap.c ============================================================================== --- head/sys/vm/vm_mmap.c Wed Jul 6 15:18:32 2011 (r223824) +++ head/sys/vm/vm_mmap.c Wed Jul 6 20:06:44 2011 (r223825) @@ -1019,19 +1019,23 @@ mlock(td, uap) PROC_UNLOCK(proc); if (npages + cnt.v_wire_count > vm_page_max_wired) return (EAGAIN); +#ifdef RACCT PROC_LOCK(proc); error = racct_set(proc, RACCT_MEMLOCK, nsize); PROC_UNLOCK(proc); if (error != 0) return (ENOMEM); +#endif error = vm_map_wire(&proc->p_vmspace->vm_map, start, end, VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES); +#ifdef RACCT if (error != KERN_SUCCESS) { PROC_LOCK(proc); racct_set(proc, RACCT_MEMLOCK, ptoa(pmap_wired_count(vm_map_pmap(&proc->p_vmspace->vm_map)))); PROC_UNLOCK(proc); } +#endif return (error == KERN_SUCCESS ? 0 : ENOMEM); } @@ -1074,11 +1078,13 @@ mlockall(td, uap) if (error) return (error); #endif +#ifdef RACCT PROC_LOCK(td->td_proc); error = racct_set(td->td_proc, RACCT_MEMLOCK, map->size); PROC_UNLOCK(td->td_proc); if (error != 0) return (ENOMEM); +#endif if (uap->how & MCL_FUTURE) { vm_map_lock(map); @@ -1098,12 +1104,14 @@ mlockall(td, uap) VM_MAP_WIRE_USER|VM_MAP_WIRE_HOLESOK); error = (error == KERN_SUCCESS ? 0 : EAGAIN); } +#ifdef RACCT if (error != KERN_SUCCESS) { PROC_LOCK(td->td_proc); racct_set(td->td_proc, RACCT_MEMLOCK, ptoa(pmap_wired_count(vm_map_pmap(&td->td_proc->p_vmspace->vm_map)))); PROC_UNLOCK(td->td_proc); } +#endif return (error); } @@ -1138,11 +1146,13 @@ munlockall(td, uap) /* Forcibly unwire all pages. */ error = vm_map_unwire(map, vm_map_min(map), vm_map_max(map), VM_MAP_WIRE_USER|VM_MAP_WIRE_HOLESOK); +#ifdef RACCT if (error == KERN_SUCCESS) { PROC_LOCK(td->td_proc); racct_set(td->td_proc, RACCT_MEMLOCK, 0); PROC_UNLOCK(td->td_proc); } +#endif return (error); } @@ -1177,11 +1187,13 @@ munlock(td, uap) return (EINVAL); error = vm_map_unwire(&td->td_proc->p_vmspace->vm_map, start, end, VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES); +#ifdef RACCT if (error == KERN_SUCCESS) { PROC_LOCK(td->td_proc); racct_sub(td->td_proc, RACCT_MEMLOCK, ptoa(end - start)); PROC_UNLOCK(td->td_proc); } +#endif return (error == KERN_SUCCESS ? 0 : ENOMEM); } Modified: head/sys/vm/vm_pageout.c ============================================================================== --- head/sys/vm/vm_pageout.c Wed Jul 6 15:18:32 2011 (r223824) +++ head/sys/vm/vm_pageout.c Wed Jul 6 20:06:44 2011 (r223825) @@ -1640,7 +1640,9 @@ vm_daemon() struct thread *td; struct vmspace *vm; int breakout, swapout_flags, tryagain, attempts; +#ifdef RACCT uint64_t rsize, ravailable; +#endif while (TRUE) { mtx_lock(&vm_daemon_mtx); @@ -1722,6 +1724,7 @@ again: vm_pageout_map_deactivate_pages( &vm->vm_map, limit); } +#ifdef RACCT rsize = IDX_TO_OFF(size); PROC_LOCK(p); racct_set(p, RACCT_RSS, rsize); @@ -1750,6 +1753,7 @@ again: if (rsize > ravailable) tryagain = 1; } +#endif vmspace_free(vm); } sx_sunlock(&allproc_lock); Modified: head/sys/vm/vm_unix.c ============================================================================== --- head/sys/vm/vm_unix.c Wed Jul 6 15:18:32 2011 (r223824) +++ head/sys/vm/vm_unix.c Wed Jul 6 20:06:44 2011 (r223825) @@ -117,6 +117,7 @@ obreak(td, uap) error = ENOMEM; goto done; } +#ifdef RACCT PROC_LOCK(td->td_proc); error = racct_set(td->td_proc, RACCT_DATA, new - base); if (error != 0) { @@ -133,13 +134,16 @@ obreak(td, uap) goto done; } PROC_UNLOCK(td->td_proc); +#endif rv = vm_map_insert(&vm->vm_map, NULL, 0, old, new, VM_PROT_RW, VM_PROT_ALL, 0); if (rv != KERN_SUCCESS) { +#ifdef RACCT PROC_LOCK(td->td_proc); racct_set_force(td->td_proc, RACCT_DATA, old - base); racct_set_force(td->td_proc, RACCT_VMEM, vm->vm_map.size); PROC_UNLOCK(td->td_proc); +#endif error = ENOMEM; goto done; } @@ -165,10 +169,12 @@ obreak(td, uap) goto done; } vm->vm_dsize -= btoc(old - new); +#ifdef RACCT PROC_LOCK(td->td_proc); racct_set_force(td->td_proc, RACCT_DATA, new - base); racct_set_force(td->td_proc, RACCT_VMEM, vm->vm_map.size); PROC_UNLOCK(td->td_proc); +#endif } done: vm_map_unlock(&vm->vm_map); From owner-svn-src-head@FreeBSD.ORG Thu Jul 7 00:46:51 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3D27F1065670; Thu, 7 Jul 2011 00:46:51 +0000 (UTC) (envelope-from jfv@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2E6A68FC13; Thu, 7 Jul 2011 00:46:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p670kpmF038559; Thu, 7 Jul 2011 00:46:51 GMT (envelope-from jfv@svn.freebsd.org) Received: (from jfv@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p670kpjW038557; Thu, 7 Jul 2011 00:46:51 GMT (envelope-from jfv@svn.freebsd.org) Message-Id: <201107070046.p670kpjW038557@svn.freebsd.org> From: Jack F Vogel Date: Thu, 7 Jul 2011 00:46:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223831 - head/sys/dev/e1000 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2011 00:46:51 -0000 Author: jfv Date: Thu Jul 7 00:46:50 2011 New Revision: 223831 URL: http://svn.freebsd.org/changeset/base/223831 Log: A fix to make the LINT-NOINET build happy, if this works out the ixgbe driver should be changed as well. Modified: head/sys/dev/e1000/if_igb.c Modified: head/sys/dev/e1000/if_igb.c ============================================================================== --- head/sys/dev/e1000/if_igb.c Thu Jul 7 00:30:34 2011 (r223830) +++ head/sys/dev/e1000/if_igb.c Thu Jul 7 00:46:50 2011 (r223831) @@ -1041,8 +1041,8 @@ igb_ioctl(struct ifnet *ifp, u_long comm struct ifreq *ifr = (struct ifreq *)data; #if defined(INET) || defined(INET6) struct ifaddr *ifa = (struct ifaddr *)data; - bool avoid_reset = FALSE; #endif + bool avoid_reset = FALSE; int error = 0; if (adapter->in_detach) @@ -1058,7 +1058,6 @@ igb_ioctl(struct ifnet *ifp, u_long comm if (ifa->ifa_addr->sa_family == AF_INET6) avoid_reset = TRUE; #endif -#if defined(INET) || defined(INET6) /* ** Calling init results in link renegotiation, ** so we avoid doing it when possible. @@ -1067,10 +1066,11 @@ igb_ioctl(struct ifnet *ifp, u_long comm ifp->if_flags |= IFF_UP; if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) igb_init(adapter); +#ifdef INET if (!(ifp->if_flags & IFF_NOARP)) arp_ifinit(ifp, ifa); - } else #endif + } else error = ether_ioctl(ifp, command, data); break; case SIOCSIFMTU: From owner-svn-src-head@FreeBSD.ORG Thu Jul 7 01:22:50 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 71C0D1065675; Thu, 7 Jul 2011 01:22:50 +0000 (UTC) (envelope-from kevlo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 62D228FC14; Thu, 7 Jul 2011 01:22:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p671MoZj039631; Thu, 7 Jul 2011 01:22:50 GMT (envelope-from kevlo@svn.freebsd.org) Received: (from kevlo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p671MoPG039629; Thu, 7 Jul 2011 01:22:50 GMT (envelope-from kevlo@svn.freebsd.org) Message-Id: <201107070122.p671MoPG039629@svn.freebsd.org> From: Kevin Lo Date: Thu, 7 Jul 2011 01:22:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223832 - head/usr.sbin/bsdinstall/partedit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2011 01:22:50 -0000 Author: kevlo Date: Thu Jul 7 01:22:50 2011 New Revision: 223832 URL: http://svn.freebsd.org/changeset/base/223832 Log: Add an extra tab between fs_file and fs_vfstype Reviewed by: nwhitehorn Modified: head/usr.sbin/bsdinstall/partedit/partedit.c Modified: head/usr.sbin/bsdinstall/partedit/partedit.c ============================================================================== --- head/usr.sbin/bsdinstall/partedit/partedit.c Thu Jul 7 00:46:50 2011 (r223831) +++ head/usr.sbin/bsdinstall/partedit/partedit.c Thu Jul 7 01:22:50 2011 (r223832) @@ -305,7 +305,7 @@ apply_changes(struct gmesh *mesh) fprintf(fstab, "# Device\tMountpoint\tFStype\tOptions\tDump\tPass#\n"); TAILQ_FOREACH(md, &part_metadata, metadata) { if (md->fstab != NULL) - fprintf(fstab, "%s\t%s\t%s\t%s\t%d\t%d\n", + fprintf(fstab, "%s\t%s\t\t%s\t%s\t%d\t%d\n", md->fstab->fs_spec, md->fstab->fs_file, md->fstab->fs_vfstype, md->fstab->fs_mntops, md->fstab->fs_freq, md->fstab->fs_passno); From owner-svn-src-head@FreeBSD.ORG Thu Jul 7 03:29:23 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6FAE3106566B; Thu, 7 Jul 2011 03:29:23 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 225BC8FC17; Thu, 7 Jul 2011 03:29:23 +0000 (UTC) Received: from [10.15.136.170] (dhcp-0-18-a-1-a3-b4.cpe.eaglecable.net [66.232.214.39]) (authenticated bits=0) by harmony.bsdimp.com (8.14.4/8.14.3) with ESMTP id p673RrDF086728 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Wed, 6 Jul 2011 21:28:01 -0600 (MDT) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1084) From: Warner Losh In-Reply-To: Date: Sun, 3 Jul 2011 19:51:30 -0500 Message-Id: References: <201106242132.p5OLW3DL071062@svn.freebsd.org> <20110628084558.GA35392@FreeBSD.org> <9521FD1A-3D77-4F37-B37C-CC73B13BC6B5@bsdimp.com> To: "Ronald Klop" X-Mailer: Apple Mail (2.1084) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (harmony.bsdimp.com [10.0.0.6]); Wed, 06 Jul 2011 21:28:13 -0600 (MDT) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: svn-src-head@freebsd.org, Alexey Dokuchaev , src-committers@freebsd.org, svn-src-all@freebsd.org, Hans Petter Selasky Subject: Re: svn commit: r223519 - head/etc/devd X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2011 03:29:23 -0000 On Jul 3, 2011, at 7:15 AM, Ronald Klop wrote: > On Tue, 28 Jun 2011 18:01:37 +0200, Warner Losh = wrote: >=20 >>=20 >> On Jun 28, 2011, at 2:45 AM, Alexey Dokuchaev wrote: >>=20 >>> On Sun, Jun 26, 2011 at 10:14:13PM -0600, Warner Losh wrote: >>>> Not in GENERIC. 9.0 is getting ready to feature freeze any minute, = so >>>> there's no time to do the testing that a radical change like that = would >>>> require. >>>=20 >>> Fair enough. Right now, this work seems to cover only USB kernel = modules, >>> is it so? Is expansion into generic PCI area also planned, provided = that >>> you've already had some ideas and seem to be willing to pick up the = work >>> given enough support from the other developers (please excuse me if = my >>> understanding is wrong)? >>=20 >> The reason we were able to relatively quickly generate this file from = USB is because USB is very regular and uniform in its probe routines. = They all have (or could be converted to have) something approximating = the same format. >>=20 >> PCI isn't even remotely close to this, and the techniques that worked = for USB (and some of the short cuts taken) can't work for PCI for us. = There's no uniformity in the PCI space, although many of the PCI drivers = use a similar design pattern. They would all have to be converted to = using the same thing, which is kinda impractical at the moment (since = many have additional, driver specific fields). While the tool is kinda = flexible enough to cope with this situation, more and more code winds up = in the tool to cope than is appropriate for the tool. >>=20 >> That's why this feature is experimental. For what it works for, it = works great. For everything else, it is a lot of work to make it happy = on a wide-spread enough scale. It is very instructive for how to = approach things, but embeds too much knowledge of the bus code into the = tool to generate these files than is appropriate (since it is duplicated = information from the driver, not exported from the bus/driver). >>=20 >> Warner >=20 > Maybe something for a GSOC 2012 project? Yes. that would make a good GSOC for the right student... It would = also scale well depending on the students skills. Warner= From owner-svn-src-head@FreeBSD.ORG Thu Jul 7 10:37:14 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8CAD71065747; Thu, 7 Jul 2011 10:37:14 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 63A978FC1B; Thu, 7 Jul 2011 10:37:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p67AbEcs059638; Thu, 7 Jul 2011 10:37:14 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p67AbEQF059634; Thu, 7 Jul 2011 10:37:14 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201107071037.p67AbEQF059634@svn.freebsd.org> From: Andre Oppermann Date: Thu, 7 Jul 2011 10:37:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223839 - in head/sys: conf kern netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2011 10:37:14 -0000 Author: andre Date: Thu Jul 7 10:37:14 2011 New Revision: 223839 URL: http://svn.freebsd.org/changeset/base/223839 Log: Remove the TCP_SORECEIVE_STREAM compile time option. The use of soreceive_stream() for TCP still has to be enabled with the loader tuneable net.inet.tcp.soreceive_stream. Suggested by: trociny and others Modified: head/sys/conf/options head/sys/kern/uipc_socket.c head/sys/netinet/tcp_subr.c Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Thu Jul 7 09:51:31 2011 (r223838) +++ head/sys/conf/options Thu Jul 7 10:37:14 2011 (r223839) @@ -427,7 +427,6 @@ SLIP_IFF_OPTS opt_slip.h TCPDEBUG TCP_OFFLOAD_DISABLE opt_inet.h #Disable code to dispatch tcp offloading TCP_SIGNATURE opt_inet.h -TCP_SORECEIVE_STREAM opt_inet.h VLAN_ARRAY opt_vlan.h XBONEHACK FLOWTABLE opt_route.h Modified: head/sys/kern/uipc_socket.c ============================================================================== --- head/sys/kern/uipc_socket.c Thu Jul 7 09:51:31 2011 (r223838) +++ head/sys/kern/uipc_socket.c Thu Jul 7 10:37:14 2011 (r223839) @@ -1915,7 +1915,6 @@ release: /* * Optimized version of soreceive() for stream (TCP) sockets. */ -#ifdef TCP_SORECEIVE_STREAM int soreceive_stream(struct socket *so, struct sockaddr **psa, struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, int *flagsp) @@ -2109,7 +2108,6 @@ out: sbunlock(sb); return (error); } -#endif /* TCP_SORECEIVE_STREAM */ /* * Optimized version of soreceive() for simple datagram cases from userspace. Modified: head/sys/netinet/tcp_subr.c ============================================================================== --- head/sys/netinet/tcp_subr.c Thu Jul 7 09:51:31 2011 (r223838) +++ head/sys/netinet/tcp_subr.c Thu Jul 7 10:37:14 2011 (r223839) @@ -206,11 +206,9 @@ SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, &VNET_NAME(tcp_isn_reseed_interval), 0, "Seconds between reseeding of ISN secret"); -#ifdef TCP_SORECEIVE_STREAM static int tcp_soreceive_stream = 0; SYSCTL_INT(_net_inet_tcp, OID_AUTO, soreceive_stream, CTLFLAG_RDTUN, &tcp_soreceive_stream, 0, "Using soreceive_stream for TCP sockets"); -#endif #ifdef TCP_SIGNATURE static int tcp_sig_checksigs = 1; @@ -337,13 +335,13 @@ tcp_init(void) tcp_finwait2_timeout = TCPTV_FINWAIT2_TIMEOUT; tcp_tcbhashsize = hashsize; -#ifdef TCP_SORECEIVE_STREAM TUNABLE_INT_FETCH("net.inet.tcp.soreceive_stream", &tcp_soreceive_stream); if (tcp_soreceive_stream) { tcp_usrreqs.pru_soreceive = soreceive_stream; +#ifdef INET6 tcp6_usrreqs.pru_soreceive = soreceive_stream; +#endif /* INET6 */ } -#endif #ifdef INET6 #define TCP_MINPROTOHDR (sizeof(struct ip6_hdr) + sizeof(struct tcphdr)) From owner-svn-src-head@FreeBSD.ORG Thu Jul 7 11:59:52 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 313351065670; Thu, 7 Jul 2011 11:59:52 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2194C8FC1C; Thu, 7 Jul 2011 11:59:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p67Bxp88062368; Thu, 7 Jul 2011 11:59:51 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p67BxpVk062366; Thu, 7 Jul 2011 11:59:51 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201107071159.p67BxpVk062366@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Thu, 7 Jul 2011 11:59:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223840 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2011 11:59:52 -0000 Author: ae Date: Thu Jul 7 11:59:51 2011 New Revision: 223840 URL: http://svn.freebsd.org/changeset/base/223840 Log: Add again the checking for log_arp_permanent_modify that was by accident removed in the r186119. PR: kern/154831 MFC after: 1 week Modified: head/sys/netinet/if_ether.c Modified: head/sys/netinet/if_ether.c ============================================================================== --- head/sys/netinet/if_ether.c Thu Jul 7 10:37:14 2011 (r223839) +++ head/sys/netinet/if_ether.c Thu Jul 7 11:59:51 2011 (r223840) @@ -694,11 +694,13 @@ match: bcmp(ar_sha(ah), &la->ll_addr, ifp->if_addrlen)) { if (la->la_flags & LLE_STATIC) { LLE_WUNLOCK(la); - log(LOG_ERR, - "arp: %*D attempts to modify permanent " - "entry for %s on %s\n", - ifp->if_addrlen, (u_char *)ar_sha(ah), ":", - inet_ntoa(isaddr), ifp->if_xname); + if (log_arp_permanent_modify) + log(LOG_ERR, + "arp: %*D attempts to modify " + "permanent entry for %s on %s\n", + ifp->if_addrlen, + (u_char *)ar_sha(ah), ":", + inet_ntoa(isaddr), ifp->if_xname); goto reply; } if (log_arp_movements) { From owner-svn-src-head@FreeBSD.ORG Thu Jul 7 13:37:47 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 09DC210656DF; Thu, 7 Jul 2011 13:37:47 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EE3838FC0A; Thu, 7 Jul 2011 13:37:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p67DbkIF065291; Thu, 7 Jul 2011 13:37:46 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p67DbkTn065288; Thu, 7 Jul 2011 13:37:46 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201107071337.p67DbkTn065288@svn.freebsd.org> From: John Baldwin Date: Thu, 7 Jul 2011 13:37:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223841 - head/usr.bin/top X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2011 13:37:47 -0000 Author: jhb Date: Thu Jul 7 13:37:46 2011 New Revision: 223841 URL: http://svn.freebsd.org/changeset/base/223841 Log: Always skip the kernel idle process if requested, it is not specific to the 'CPU' mode. PR: bin/158677 Reported by: arundel MFC after: 3 days Modified: head/usr.bin/top/machine.c Modified: head/usr.bin/top/machine.c ============================================================================== --- head/usr.bin/top/machine.c Thu Jul 7 11:59:51 2011 (r223840) +++ head/usr.bin/top/machine.c Thu Jul 7 13:37:46 2011 (r223841) @@ -701,17 +701,16 @@ get_process_info(struct system_info *si, /* skip zombies */ continue; + if (!show_kidle && pp->ki_tdflags & TDF_IDLETD) + /* skip kernel idle process */ + continue; + if (displaymode == DISP_CPU && !show_idle && (pp->ki_pctcpu == 0 || pp->ki_stat == SSTOP || pp->ki_stat == SIDL)) /* skip idle or non-running processes */ continue; - if (displaymode == DISP_CPU && !show_kidle && - pp->ki_tdflags & TDF_IDLETD) - /* skip kernel idle process */ - continue; - if (displaymode == DISP_IO && !show_idle && p_io == 0) /* skip processes that aren't doing I/O */ continue; From owner-svn-src-head@FreeBSD.ORG Thu Jul 7 14:34:49 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8D6AF1065674; Thu, 7 Jul 2011 14:34:49 +0000 (UTC) (envelope-from nwhitehorn@freebsd.org) Received: from adsum.doit.wisc.edu (adsum.doit.wisc.edu [144.92.197.210]) by mx1.freebsd.org (Postfix) with ESMTP id 5DF138FC14; Thu, 7 Jul 2011 14:34:49 +0000 (UTC) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII; format=flowed Received: from avs-daemon.smtpauth1.wiscmail.wisc.edu by smtpauth1.wiscmail.wisc.edu (Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30 2009)) id <0LNY00204WI01600@smtpauth1.wiscmail.wisc.edu>; Thu, 07 Jul 2011 09:34:48 -0500 (CDT) Received: from comporellon.tachypleus.net (adsl-75-50-91-37.dsl.mdsnwi.sbcglobal.net [75.50.91.37]) by smtpauth1.wiscmail.wisc.edu (Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30 2009)) with ESMTPSA id <0LNY00L98WHRJ310@smtpauth1.wiscmail.wisc.edu>; Thu, 07 Jul 2011 09:34:41 -0500 (CDT) Date: Thu, 07 Jul 2011 09:34:39 -0500 From: Nathan Whitehorn In-reply-to: <201106281616.p5SGGhbx056614@svn.freebsd.org> To: Marius Strobl Message-id: <4E15C3FF.5030703@freebsd.org> X-Spam-Report: AuthenticatedSender=yes, SenderIP=75.50.91.37 X-Spam-PmxInfo: Server=avs-14, Version=5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2011.7.7.142716, SenderIP=75.50.91.37 References: <201106281616.p5SGGhbx056614@svn.freebsd.org> User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:5.0) Gecko/20110704 Thunderbird/5.0 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r223648 - head/sys/dev/gem X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2011 14:34:49 -0000 This breaks one of my gem devices (chip=0x0021106b) when the controller is initialized from FreeBSD (netbooting works fine, and the controller stays working after that), with "cannot disable RX MAC" or "cannot disable RX MAC or hash filter" messages. -Nathan On 06/28/11 11:16, Marius Strobl wrote: > Author: marius > Date: Tue Jun 28 16:16:43 2011 > New Revision: 223648 > URL: http://svn.freebsd.org/changeset/base/223648 > > Log: > - In gem_reset_rx() also reset the RX MAC which is necessary in order to > get it out of a stuck condition that can be caused by GEM_MAC_RX_OVERFLOW. > - In gem_reset_rxdma() call gem_setladrf() in order to reprogram the RX > filter and restore the previous content of GEM_MAC_RX_CONFIG. While at it > consistently use the newly introduced sc_mac_rxcfg throughout the driver > instead of reading the its old content. > - Increment if_iqdrops instead of if_ierrors in case of RX buffer allocation > failure. > - According to the GEM datasheet the RX MAC should also be disabled in > gem_setladrf() before changing its configuration. > - Add error messages to gem_disable_{r,t}x() and take advantage of these > throughout the driver instead of duplicating their functionality all over > the place. > > In joint forces with: yongari > > Modified: > head/sys/dev/gem/if_gem.c > head/sys/dev/gem/if_gemvar.h > > Modified: head/sys/dev/gem/if_gem.c > ============================================================================== > --- head/sys/dev/gem/if_gem.c Tue Jun 28 15:19:45 2011 (r223647) > +++ head/sys/dev/gem/if_gem.c Tue Jun 28 16:16:43 2011 (r223648) > @@ -121,7 +121,7 @@ static void gem_rint_timeout(void *arg); > #endif > static inline void gem_rxcksum(struct mbuf *m, uint64_t flags); > static void gem_rxdrain(struct gem_softc *sc); > -static void gem_setladrf(struct gem_softc *sc); > +static void gem_setladrf(struct gem_softc *sc, u_int enable); > static void gem_start(struct ifnet *ifp); > static void gem_start_locked(struct ifnet *ifp); > static void gem_stop(struct ifnet *ifp, int disable); > @@ -705,7 +705,7 @@ gem_reset_rx(struct gem_softc *sc) > * Resetting while DMA is in progress can cause a bus hang, so we > * disable DMA first. > */ > - gem_disable_rx(sc); > + (void)gem_disable_rx(sc); > GEM_BANK1_WRITE_4(sc, GEM_RX_CONFIG, 0); > GEM_BANK1_BARRIER(sc, GEM_RX_CONFIG, 4, > BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > @@ -715,7 +715,7 @@ gem_reset_rx(struct gem_softc *sc) > /* Wait 5ms extra. */ > DELAY(5000); > > - /* Finally, reset the ERX. */ > + /* Reset the ERX. */ > GEM_BANK2_WRITE_4(sc, GEM_RESET, GEM_RESET_RX); > GEM_BANK2_BARRIER(sc, GEM_RESET, 4, > BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > @@ -724,6 +724,16 @@ gem_reset_rx(struct gem_softc *sc) > device_printf(sc->sc_dev, "cannot reset receiver\n"); > return (1); > } > + > + /* Finally, reset RX MAC. */ > + GEM_BANK1_WRITE_4(sc, GEM_MAC_RXRESET, 1); > + GEM_BANK1_BARRIER(sc, GEM_MAC_RXRESET, 4, > + BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > + if (!GEM_BANK1_BITWAIT(sc, GEM_MAC_RXRESET, 1, 0)) { > + device_printf(sc->sc_dev, "cannot reset RX MAC\n"); > + return (1); > + } > + > return (0); > } > > @@ -766,12 +776,17 @@ gem_reset_rxdma(struct gem_softc *sc) > GEM_BANK1_WRITE_4(sc, GEM_RX_PAUSE_THRESH, > (3 * sc->sc_rxfifosize / 256) | > ((sc->sc_rxfifosize / 256)<< 12)); > + /* > + * Clear the RX filter and reprogram it. This will also set the > + * current RX MAC configuration. > + */ > + gem_setladrf(sc, 0); > GEM_BANK1_WRITE_4(sc, GEM_RX_CONFIG, > GEM_BANK1_READ_4(sc, GEM_RX_CONFIG) | GEM_RX_CONFIG_RXDMA_EN); > GEM_BANK1_WRITE_4(sc, GEM_MAC_RX_MASK, > GEM_MAC_RX_DONE | GEM_MAC_RX_FRAME_CNT); > GEM_BANK1_WRITE_4(sc, GEM_MAC_RX_CONFIG, > - GEM_BANK1_READ_4(sc, GEM_MAC_RX_CONFIG) | GEM_MAC_RX_ENABLE); > + sc->sc_mac_rxcfg | GEM_MAC_RX_ENABLE); > } > > static int > @@ -782,7 +797,7 @@ gem_reset_tx(struct gem_softc *sc) > * Resetting while DMA is in progress can cause a bus hang, so we > * disable DMA first. > */ > - gem_disable_tx(sc); > + (void)gem_disable_tx(sc); > GEM_BANK1_WRITE_4(sc, GEM_TX_CONFIG, 0); > GEM_BANK1_BARRIER(sc, GEM_TX_CONFIG, 4, > BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > @@ -812,8 +827,10 @@ gem_disable_rx(struct gem_softc *sc) > GEM_BANK1_READ_4(sc, GEM_MAC_RX_CONFIG)& ~GEM_MAC_RX_ENABLE); > GEM_BANK1_BARRIER(sc, GEM_MAC_RX_CONFIG, 4, > BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > - return (GEM_BANK1_BITWAIT(sc, GEM_MAC_RX_CONFIG, GEM_MAC_RX_ENABLE, > - 0)); > + if (GEM_BANK1_BITWAIT(sc, GEM_MAC_RX_CONFIG, GEM_MAC_RX_ENABLE, 0)) > + return (1); > + device_printf(sc->sc_dev, "cannot disable RX MAC\n"); > + return (0); > } > > static int > @@ -824,8 +841,10 @@ gem_disable_tx(struct gem_softc *sc) > GEM_BANK1_READ_4(sc, GEM_MAC_TX_CONFIG)& ~GEM_MAC_TX_ENABLE); > GEM_BANK1_BARRIER(sc, GEM_MAC_TX_CONFIG, 4, > BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > - return (GEM_BANK1_BITWAIT(sc, GEM_MAC_TX_CONFIG, GEM_MAC_TX_ENABLE, > - 0)); > + if (GEM_BANK1_BITWAIT(sc, GEM_MAC_TX_CONFIG, GEM_MAC_TX_ENABLE, 0)) > + return (1); > + device_printf(sc->sc_dev, "cannot disable TX MAC\n"); > + return (0); > } > > static int > @@ -960,7 +979,7 @@ gem_init_locked(struct gem_softc *sc) > gem_init_regs(sc); > > /* step 5. RX MAC registers& counters */ > - gem_setladrf(sc); > + gem_setladrf(sc, 0); > > /* step 6& 7. Program Descriptor Ring Base Addresses. */ > /* NOTE: we use only 32-bit DMA addresses here. */ > @@ -1050,21 +1069,14 @@ gem_init_locked(struct gem_softc *sc) > /* step 12. RX_MAC Configuration Register */ > v = GEM_BANK1_READ_4(sc, GEM_MAC_RX_CONFIG); > v |= GEM_MAC_RX_ENABLE | GEM_MAC_RX_STRIP_CRC; > - GEM_BANK1_WRITE_4(sc, GEM_MAC_RX_CONFIG, 0); > - GEM_BANK1_BARRIER(sc, GEM_MAC_RX_CONFIG, 4, > - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > - if (!GEM_BANK1_BITWAIT(sc, GEM_MAC_RX_CONFIG, GEM_MAC_RX_ENABLE, 0)) > - device_printf(sc->sc_dev, "cannot configure RX MAC\n"); > + (void)gem_disable_rx(sc); > + sc->sc_mac_rxcfg = v& ~GEM_MAC_RX_ENABLE; > GEM_BANK1_WRITE_4(sc, GEM_MAC_RX_CONFIG, v); > > /* step 13. TX_MAC Configuration Register */ > v = GEM_BANK1_READ_4(sc, GEM_MAC_TX_CONFIG); > v |= GEM_MAC_TX_ENABLE; > - GEM_BANK1_WRITE_4(sc, GEM_MAC_TX_CONFIG, 0); > - GEM_BANK1_BARRIER(sc, GEM_MAC_TX_CONFIG, 4, > - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > - if (!GEM_BANK1_BITWAIT(sc, GEM_MAC_TX_CONFIG, GEM_MAC_TX_ENABLE, 0)) > - device_printf(sc->sc_dev, "cannot configure TX MAC\n"); > + (void)gem_disable_tx(sc); > GEM_BANK1_WRITE_4(sc, GEM_MAC_TX_CONFIG, v); > > /* step 14. Issue Transmit Pending command. */ > @@ -1588,7 +1600,7 @@ gem_rint(struct gem_softc *sc) > * the buffer that's already attached to this descriptor. > */ > if (gem_add_rxbuf(sc, sc->sc_rxptr) != 0) { > - ifp->if_ierrors++; > + ifp->if_iqdrops++; > GEM_INIT_RXDESC(sc, sc->sc_rxptr); > m = NULL; > } > @@ -2028,8 +2040,8 @@ gem_mii_statchg(device_t dev) > * the GEM Gigabit Ethernet ASIC Specification. > */ > > - rxcfg = GEM_BANK1_READ_4(sc, GEM_MAC_RX_CONFIG); > - rxcfg&= ~(GEM_MAC_RX_CARR_EXTEND | GEM_MAC_RX_ENABLE); > + rxcfg = sc->sc_mac_rxcfg; > + rxcfg&= ~GEM_MAC_RX_CARR_EXTEND; > txcfg = GEM_MAC_TX_ENA_IPG0 | GEM_MAC_TX_NGU | GEM_MAC_TX_NGU_LIMIT; > if ((IFM_OPTIONS(sc->sc_mii->mii_media_active)& IFM_FDX) != 0) > txcfg |= GEM_MAC_TX_IGN_CARRIER | GEM_MAC_TX_IGN_COLLIS; > @@ -2037,17 +2049,9 @@ gem_mii_statchg(device_t dev) > rxcfg |= GEM_MAC_RX_CARR_EXTEND; > txcfg |= GEM_MAC_TX_CARR_EXTEND; > } > - GEM_BANK1_WRITE_4(sc, GEM_MAC_TX_CONFIG, 0); > - GEM_BANK1_BARRIER(sc, GEM_MAC_TX_CONFIG, 4, > - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > - if (!GEM_BANK1_BITWAIT(sc, GEM_MAC_TX_CONFIG, GEM_MAC_TX_ENABLE, 0)) > - device_printf(sc->sc_dev, "cannot disable TX MAC\n"); > + (void)gem_disable_tx(sc); > GEM_BANK1_WRITE_4(sc, GEM_MAC_TX_CONFIG, txcfg); > - GEM_BANK1_WRITE_4(sc, GEM_MAC_RX_CONFIG, 0); > - GEM_BANK1_BARRIER(sc, GEM_MAC_RX_CONFIG, 4, > - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > - if (!GEM_BANK1_BITWAIT(sc, GEM_MAC_RX_CONFIG, GEM_MAC_RX_ENABLE, 0)) > - device_printf(sc->sc_dev, "cannot disable RX MAC\n"); > + (void)gem_disable_rx(sc); > GEM_BANK1_WRITE_4(sc, GEM_MAC_RX_CONFIG, rxcfg); > > v = GEM_BANK1_READ_4(sc, GEM_MAC_CONTROL_CONFIG)& > @@ -2092,6 +2096,7 @@ gem_mii_statchg(device_t dev) > v |= GEM_MAC_XIF_FDPLX_LED; > GEM_BANK1_WRITE_4(sc, GEM_MAC_XIF_CONFIG, v); > > + sc->sc_mac_rxcfg = rxcfg; > if ((sc->sc_ifp->if_drv_flags& IFF_DRV_RUNNING) != 0&& > (sc->sc_flags& GEM_LINK) != 0) { > GEM_BANK1_WRITE_4(sc, GEM_MAC_TX_CONFIG, > @@ -2147,7 +2152,7 @@ gem_ioctl(struct ifnet *ifp, u_long cmd, > if ((ifp->if_drv_flags& IFF_DRV_RUNNING) != 0&& > ((ifp->if_flags ^ sc->sc_ifflags)& > (IFF_ALLMULTI | IFF_PROMISC)) != 0) > - gem_setladrf(sc); > + gem_setladrf(sc, 1); > else > gem_init_locked(sc); > } else if ((ifp->if_drv_flags& IFF_DRV_RUNNING) != 0) > @@ -2164,7 +2169,8 @@ gem_ioctl(struct ifnet *ifp, u_long cmd, > case SIOCADDMULTI: > case SIOCDELMULTI: > GEM_LOCK(sc); > - gem_setladrf(sc); > + if ((ifp->if_drv_flags& IFF_DRV_RUNNING) != 0) > + gem_setladrf(sc, 1); > GEM_UNLOCK(sc); > break; > case SIOCGIFMEDIA: > @@ -2189,7 +2195,7 @@ gem_ioctl(struct ifnet *ifp, u_long cmd, > } > > static void > -gem_setladrf(struct gem_softc *sc) > +gem_setladrf(struct gem_softc *sc, u_int enable) > { > struct ifnet *ifp = sc->sc_ifp; > struct ifmultiaddr *inm; > @@ -2199,24 +2205,20 @@ gem_setladrf(struct gem_softc *sc) > > GEM_LOCK_ASSERT(sc, MA_OWNED); > > - /* Get the current RX configuration. */ > - v = GEM_BANK1_READ_4(sc, GEM_MAC_RX_CONFIG); > - > /* > - * Turn off promiscuous mode, promiscuous group mode (all multicast), > - * and hash filter. Depending on the case, the right bit will be > - * enabled. > + * Turn off the RX MAC and the hash filter as required by the Sun GEM > + * programming restrictions. > */ > - v&= ~(GEM_MAC_RX_PROMISCUOUS | GEM_MAC_RX_HASH_FILTER | > - GEM_MAC_RX_PROMISC_GRP); > - > + v = sc->sc_mac_rxcfg& GEM_MAC_RX_HASH_FILTER; > GEM_BANK1_WRITE_4(sc, GEM_MAC_RX_CONFIG, v); > GEM_BANK1_BARRIER(sc, GEM_MAC_RX_CONFIG, 4, > BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > - if (!GEM_BANK1_BITWAIT(sc, GEM_MAC_RX_CONFIG, GEM_MAC_RX_HASH_FILTER, > - 0)) > - device_printf(sc->sc_dev, "cannot disable RX hash filter\n"); > + if (!GEM_BANK1_BITWAIT(sc, GEM_MAC_RX_CONFIG, GEM_MAC_RX_HASH_FILTER | > + GEM_MAC_RX_ENABLE, 0)) > + device_printf(sc->sc_dev, > + "cannot disable RX MAC or hash filter\n"); > > + v&= ~(GEM_MAC_RX_PROMISCUOUS | GEM_MAC_RX_PROMISC_GRP); > if ((ifp->if_flags& IFF_PROMISC) != 0) { > v |= GEM_MAC_RX_PROMISCUOUS; > goto chipit; > @@ -2262,5 +2264,8 @@ gem_setladrf(struct gem_softc *sc) > hash[i]); > > chipit: > + sc->sc_mac_rxcfg = v; > + if (enable) > + v |= GEM_MAC_RX_ENABLE; > GEM_BANK1_WRITE_4(sc, GEM_MAC_RX_CONFIG, v); > } > > Modified: head/sys/dev/gem/if_gemvar.h > ============================================================================== > --- head/sys/dev/gem/if_gemvar.h Tue Jun 28 15:19:45 2011 (r223647) > +++ head/sys/dev/gem/if_gemvar.h Tue Jun 28 16:16:43 2011 (r223648) > @@ -173,6 +173,8 @@ struct gem_softc { > u_int sc_rxptr; /* next ready RX descriptor/state */ > u_int sc_rxfifosize; /* RX FIFO size (bytes) */ > > + uint32_t sc_mac_rxcfg; /* RX MAC conf. % GEM_MAC_RX_ENABLE */ > + > int sc_ifflags; > u_long sc_csum_features; > }; From owner-svn-src-head@FreeBSD.ORG Thu Jul 7 15:41:40 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 87B48106566C; Thu, 7 Jul 2011 15:41:40 +0000 (UTC) (envelope-from kevlo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 77FE38FC12; Thu, 7 Jul 2011 15:41:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p67Ffe7O069056; Thu, 7 Jul 2011 15:41:40 GMT (envelope-from kevlo@svn.freebsd.org) Received: (from kevlo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p67Ffe2r069053; Thu, 7 Jul 2011 15:41:40 GMT (envelope-from kevlo@svn.freebsd.org) Message-Id: <201107071541.p67Ffe2r069053@svn.freebsd.org> From: Kevin Lo Date: Thu, 7 Jul 2011 15:41:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223842 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2011 15:41:40 -0000 Author: kevlo Date: Thu Jul 7 15:41:40 2011 New Revision: 223842 URL: http://svn.freebsd.org/changeset/base/223842 Log: Fix memset sizeofs Reviewed by: bschmidt Modified: head/sys/net80211/ieee80211_ageq.c head/sys/net80211/ieee80211_power.c Modified: head/sys/net80211/ieee80211_ageq.c ============================================================================== --- head/sys/net80211/ieee80211_ageq.c Thu Jul 7 13:37:46 2011 (r223841) +++ head/sys/net80211/ieee80211_ageq.c Thu Jul 7 15:41:40 2011 (r223842) @@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$"); void ieee80211_ageq_init(struct ieee80211_ageq *aq, int maxlen, const char *name) { - memset(aq, 0, sizeof(aq)); + memset(aq, 0, sizeof(*aq)); aq->aq_maxlen = maxlen; IEEE80211_AGEQ_INIT(aq, name); /* OS-dependent setup */ } Modified: head/sys/net80211/ieee80211_power.c ============================================================================== --- head/sys/net80211/ieee80211_power.c Thu Jul 7 13:37:46 2011 (r223841) +++ head/sys/net80211/ieee80211_power.c Thu Jul 7 15:41:40 2011 (r223842) @@ -102,7 +102,7 @@ ieee80211_power_vdetach(struct ieee80211 void ieee80211_psq_init(struct ieee80211_psq *psq, const char *name) { - memset(psq, 0, sizeof(psq)); + memset(psq, 0, sizeof(*psq)); psq->psq_maxlen = IEEE80211_PS_MAX_QUEUE; IEEE80211_PSQ_INIT(psq, name); /* OS-dependent setup */ } From owner-svn-src-head@FreeBSD.ORG Thu Jul 7 16:23:01 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BC9FF106564A; Thu, 7 Jul 2011 16:23:01 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id 819428FC12; Thu, 7 Jul 2011 16:23:00 +0000 (UTC) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.4/8.14.4/ALCHEMY.FRANKEN.DE) with ESMTP id p67G7a6g091040; Thu, 7 Jul 2011 18:07:36 +0200 (CEST) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.4/8.14.4/Submit) id p67G7aDD091039; Thu, 7 Jul 2011 18:07:36 +0200 (CEST) (envelope-from marius) Date: Thu, 7 Jul 2011 18:07:36 +0200 From: Marius Strobl To: Nathan Whitehorn Message-ID: <20110707160736.GE88226@alchemy.franken.de> References: <201106281616.p5SGGhbx056614@svn.freebsd.org> <4E15C3FF.5030703@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4E15C3FF.5030703@freebsd.org> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r223648 - head/sys/dev/gem X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2011 16:23:01 -0000 On Thu, Jul 07, 2011 at 09:34:39AM -0500, Nathan Whitehorn wrote: > This breaks one of my gem devices (chip=0x0021106b) when the controller > is initialized from FreeBSD (netbooting works fine, and the controller > stays working after that), with "cannot disable RX MAC" or "cannot > disable RX MAC or hash filter" messages. Are you positive that it's exactly this revision which breaks things? Actually there was a report from Justin Hibbits that r222135 causing a GMAC to no longer work with similar symptoms, which still is unsolved AFAICT. If it's really r223648 which is causing problems in your case please try to figure out which part is causing that as none of the changes exactly stands out as disruptive, probably best by reverting gem_reset_rx() and gem_setladrf() one by one. Marius > > On 06/28/11 11:16, Marius Strobl wrote: > >Author: marius > >Date: Tue Jun 28 16:16:43 2011 > >New Revision: 223648 > >URL: http://svn.freebsd.org/changeset/base/223648 > > > >Log: > > - In gem_reset_rx() also reset the RX MAC which is necessary in order to > > get it out of a stuck condition that can be caused by > > GEM_MAC_RX_OVERFLOW. > > - In gem_reset_rxdma() call gem_setladrf() in order to reprogram the RX > > filter and restore the previous content of GEM_MAC_RX_CONFIG. While > > at it > > consistently use the newly introduced sc_mac_rxcfg throughout the > > driver > > instead of reading the its old content. > > - Increment if_iqdrops instead of if_ierrors in case of RX buffer > > allocation > > failure. > > - According to the GEM datasheet the RX MAC should also be disabled in > > gem_setladrf() before changing its configuration. > > - Add error messages to gem_disable_{r,t}x() and take advantage of these > > throughout the driver instead of duplicating their functionality all > > over > > the place. > > > > In joint forces with: yongari > > > >Modified: > > head/sys/dev/gem/if_gem.c > > head/sys/dev/gem/if_gemvar.h > > > >Modified: head/sys/dev/gem/if_gem.c > >============================================================================== > >--- head/sys/dev/gem/if_gem.c Tue Jun 28 15:19:45 2011 (r223647) > >+++ head/sys/dev/gem/if_gem.c Tue Jun 28 16:16:43 2011 (r223648) > >@@ -121,7 +121,7 @@ static void gem_rint_timeout(void *arg); > > #endif > > static inline void gem_rxcksum(struct mbuf *m, uint64_t flags); > > static void gem_rxdrain(struct gem_softc *sc); > >-static void gem_setladrf(struct gem_softc *sc); > >+static void gem_setladrf(struct gem_softc *sc, u_int enable); > > static void gem_start(struct ifnet *ifp); > > static void gem_start_locked(struct ifnet *ifp); > > static void gem_stop(struct ifnet *ifp, int disable); > >@@ -705,7 +705,7 @@ gem_reset_rx(struct gem_softc *sc) > > * Resetting while DMA is in progress can cause a bus hang, so we > > * disable DMA first. > > */ > >- gem_disable_rx(sc); > >+ (void)gem_disable_rx(sc); > > GEM_BANK1_WRITE_4(sc, GEM_RX_CONFIG, 0); > > GEM_BANK1_BARRIER(sc, GEM_RX_CONFIG, 4, > > BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > >@@ -715,7 +715,7 @@ gem_reset_rx(struct gem_softc *sc) > > /* Wait 5ms extra. */ > > DELAY(5000); > > > >- /* Finally, reset the ERX. */ > >+ /* Reset the ERX. */ > > GEM_BANK2_WRITE_4(sc, GEM_RESET, GEM_RESET_RX); > > GEM_BANK2_BARRIER(sc, GEM_RESET, 4, > > BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > >@@ -724,6 +724,16 @@ gem_reset_rx(struct gem_softc *sc) > > device_printf(sc->sc_dev, "cannot reset receiver\n"); > > return (1); > > } > >+ > >+ /* Finally, reset RX MAC. */ > >+ GEM_BANK1_WRITE_4(sc, GEM_MAC_RXRESET, 1); > >+ GEM_BANK1_BARRIER(sc, GEM_MAC_RXRESET, 4, > >+ BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > >+ if (!GEM_BANK1_BITWAIT(sc, GEM_MAC_RXRESET, 1, 0)) { > >+ device_printf(sc->sc_dev, "cannot reset RX MAC\n"); > >+ return (1); > >+ } > >+ > > return (0); > > } > > > >@@ -766,12 +776,17 @@ gem_reset_rxdma(struct gem_softc *sc) > > GEM_BANK1_WRITE_4(sc, GEM_RX_PAUSE_THRESH, > > (3 * sc->sc_rxfifosize / 256) | > > ((sc->sc_rxfifosize / 256)<< 12)); > >+ /* > >+ * Clear the RX filter and reprogram it. This will also set the > >+ * current RX MAC configuration. > >+ */ > >+ gem_setladrf(sc, 0); > > GEM_BANK1_WRITE_4(sc, GEM_RX_CONFIG, > > GEM_BANK1_READ_4(sc, GEM_RX_CONFIG) | GEM_RX_CONFIG_RXDMA_EN); > > GEM_BANK1_WRITE_4(sc, GEM_MAC_RX_MASK, > > GEM_MAC_RX_DONE | GEM_MAC_RX_FRAME_CNT); > > GEM_BANK1_WRITE_4(sc, GEM_MAC_RX_CONFIG, > >- GEM_BANK1_READ_4(sc, GEM_MAC_RX_CONFIG) | GEM_MAC_RX_ENABLE); > >+ sc->sc_mac_rxcfg | GEM_MAC_RX_ENABLE); > > } > > > > static int > >@@ -782,7 +797,7 @@ gem_reset_tx(struct gem_softc *sc) > > * Resetting while DMA is in progress can cause a bus hang, so we > > * disable DMA first. > > */ > >- gem_disable_tx(sc); > >+ (void)gem_disable_tx(sc); > > GEM_BANK1_WRITE_4(sc, GEM_TX_CONFIG, 0); > > GEM_BANK1_BARRIER(sc, GEM_TX_CONFIG, 4, > > BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > >@@ -812,8 +827,10 @@ gem_disable_rx(struct gem_softc *sc) > > GEM_BANK1_READ_4(sc, GEM_MAC_RX_CONFIG)& ~GEM_MAC_RX_ENABLE); > > GEM_BANK1_BARRIER(sc, GEM_MAC_RX_CONFIG, 4, > > BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > >- return (GEM_BANK1_BITWAIT(sc, GEM_MAC_RX_CONFIG, GEM_MAC_RX_ENABLE, > >- 0)); > >+ if (GEM_BANK1_BITWAIT(sc, GEM_MAC_RX_CONFIG, GEM_MAC_RX_ENABLE, 0)) > >+ return (1); > >+ device_printf(sc->sc_dev, "cannot disable RX MAC\n"); > >+ return (0); > > } > > > > static int > >@@ -824,8 +841,10 @@ gem_disable_tx(struct gem_softc *sc) > > GEM_BANK1_READ_4(sc, GEM_MAC_TX_CONFIG)& ~GEM_MAC_TX_ENABLE); > > GEM_BANK1_BARRIER(sc, GEM_MAC_TX_CONFIG, 4, > > BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > >- return (GEM_BANK1_BITWAIT(sc, GEM_MAC_TX_CONFIG, GEM_MAC_TX_ENABLE, > >- 0)); > >+ if (GEM_BANK1_BITWAIT(sc, GEM_MAC_TX_CONFIG, GEM_MAC_TX_ENABLE, 0)) > >+ return (1); > >+ device_printf(sc->sc_dev, "cannot disable TX MAC\n"); > >+ return (0); > > } > > > > static int > >@@ -960,7 +979,7 @@ gem_init_locked(struct gem_softc *sc) > > gem_init_regs(sc); > > > > /* step 5. RX MAC registers& counters */ > >- gem_setladrf(sc); > >+ gem_setladrf(sc, 0); > > > > /* step 6& 7. Program Descriptor Ring Base Addresses. */ > > /* NOTE: we use only 32-bit DMA addresses here. */ > >@@ -1050,21 +1069,14 @@ gem_init_locked(struct gem_softc *sc) > > /* step 12. RX_MAC Configuration Register */ > > v = GEM_BANK1_READ_4(sc, GEM_MAC_RX_CONFIG); > > v |= GEM_MAC_RX_ENABLE | GEM_MAC_RX_STRIP_CRC; > >- GEM_BANK1_WRITE_4(sc, GEM_MAC_RX_CONFIG, 0); > >- GEM_BANK1_BARRIER(sc, GEM_MAC_RX_CONFIG, 4, > >- BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > >- if (!GEM_BANK1_BITWAIT(sc, GEM_MAC_RX_CONFIG, GEM_MAC_RX_ENABLE, 0)) > >- device_printf(sc->sc_dev, "cannot configure RX MAC\n"); > >+ (void)gem_disable_rx(sc); > >+ sc->sc_mac_rxcfg = v& ~GEM_MAC_RX_ENABLE; > > GEM_BANK1_WRITE_4(sc, GEM_MAC_RX_CONFIG, v); > > > > /* step 13. TX_MAC Configuration Register */ > > v = GEM_BANK1_READ_4(sc, GEM_MAC_TX_CONFIG); > > v |= GEM_MAC_TX_ENABLE; > >- GEM_BANK1_WRITE_4(sc, GEM_MAC_TX_CONFIG, 0); > >- GEM_BANK1_BARRIER(sc, GEM_MAC_TX_CONFIG, 4, > >- BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > >- if (!GEM_BANK1_BITWAIT(sc, GEM_MAC_TX_CONFIG, GEM_MAC_TX_ENABLE, 0)) > >- device_printf(sc->sc_dev, "cannot configure TX MAC\n"); > >+ (void)gem_disable_tx(sc); > > GEM_BANK1_WRITE_4(sc, GEM_MAC_TX_CONFIG, v); > > > > /* step 14. Issue Transmit Pending command. */ > >@@ -1588,7 +1600,7 @@ gem_rint(struct gem_softc *sc) > > * the buffer that's already attached to this descriptor. > > */ > > if (gem_add_rxbuf(sc, sc->sc_rxptr) != 0) { > >- ifp->if_ierrors++; > >+ ifp->if_iqdrops++; > > GEM_INIT_RXDESC(sc, sc->sc_rxptr); > > m = NULL; > > } > >@@ -2028,8 +2040,8 @@ gem_mii_statchg(device_t dev) > > * the GEM Gigabit Ethernet ASIC Specification. > > */ > > > >- rxcfg = GEM_BANK1_READ_4(sc, GEM_MAC_RX_CONFIG); > >- rxcfg&= ~(GEM_MAC_RX_CARR_EXTEND | GEM_MAC_RX_ENABLE); > >+ rxcfg = sc->sc_mac_rxcfg; > >+ rxcfg&= ~GEM_MAC_RX_CARR_EXTEND; > > txcfg = GEM_MAC_TX_ENA_IPG0 | GEM_MAC_TX_NGU | GEM_MAC_TX_NGU_LIMIT; > > if ((IFM_OPTIONS(sc->sc_mii->mii_media_active)& IFM_FDX) != 0) > > txcfg |= GEM_MAC_TX_IGN_CARRIER | GEM_MAC_TX_IGN_COLLIS; > >@@ -2037,17 +2049,9 @@ gem_mii_statchg(device_t dev) > > rxcfg |= GEM_MAC_RX_CARR_EXTEND; > > txcfg |= GEM_MAC_TX_CARR_EXTEND; > > } > >- GEM_BANK1_WRITE_4(sc, GEM_MAC_TX_CONFIG, 0); > >- GEM_BANK1_BARRIER(sc, GEM_MAC_TX_CONFIG, 4, > >- BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > >- if (!GEM_BANK1_BITWAIT(sc, GEM_MAC_TX_CONFIG, GEM_MAC_TX_ENABLE, 0)) > >- device_printf(sc->sc_dev, "cannot disable TX MAC\n"); > >+ (void)gem_disable_tx(sc); > > GEM_BANK1_WRITE_4(sc, GEM_MAC_TX_CONFIG, txcfg); > >- GEM_BANK1_WRITE_4(sc, GEM_MAC_RX_CONFIG, 0); > >- GEM_BANK1_BARRIER(sc, GEM_MAC_RX_CONFIG, 4, > >- BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > >- if (!GEM_BANK1_BITWAIT(sc, GEM_MAC_RX_CONFIG, GEM_MAC_RX_ENABLE, 0)) > >- device_printf(sc->sc_dev, "cannot disable RX MAC\n"); > >+ (void)gem_disable_rx(sc); > > GEM_BANK1_WRITE_4(sc, GEM_MAC_RX_CONFIG, rxcfg); > > > > v = GEM_BANK1_READ_4(sc, GEM_MAC_CONTROL_CONFIG)& > >@@ -2092,6 +2096,7 @@ gem_mii_statchg(device_t dev) > > v |= GEM_MAC_XIF_FDPLX_LED; > > GEM_BANK1_WRITE_4(sc, GEM_MAC_XIF_CONFIG, v); > > > >+ sc->sc_mac_rxcfg = rxcfg; > > if ((sc->sc_ifp->if_drv_flags& IFF_DRV_RUNNING) != 0&& > > (sc->sc_flags& GEM_LINK) != 0) { > > GEM_BANK1_WRITE_4(sc, GEM_MAC_TX_CONFIG, > >@@ -2147,7 +2152,7 @@ gem_ioctl(struct ifnet *ifp, u_long cmd, > > if ((ifp->if_drv_flags& IFF_DRV_RUNNING) != 0&& > > ((ifp->if_flags ^ sc->sc_ifflags)& > > (IFF_ALLMULTI | IFF_PROMISC)) != 0) > >- gem_setladrf(sc); > >+ gem_setladrf(sc, 1); > > else > > gem_init_locked(sc); > > } else if ((ifp->if_drv_flags& IFF_DRV_RUNNING) != 0) > >@@ -2164,7 +2169,8 @@ gem_ioctl(struct ifnet *ifp, u_long cmd, > > case SIOCADDMULTI: > > case SIOCDELMULTI: > > GEM_LOCK(sc); > >- gem_setladrf(sc); > >+ if ((ifp->if_drv_flags& IFF_DRV_RUNNING) != 0) > >+ gem_setladrf(sc, 1); > > GEM_UNLOCK(sc); > > break; > > case SIOCGIFMEDIA: > >@@ -2189,7 +2195,7 @@ gem_ioctl(struct ifnet *ifp, u_long cmd, > > } > > > > static void > >-gem_setladrf(struct gem_softc *sc) > >+gem_setladrf(struct gem_softc *sc, u_int enable) > > { > > struct ifnet *ifp = sc->sc_ifp; > > struct ifmultiaddr *inm; > >@@ -2199,24 +2205,20 @@ gem_setladrf(struct gem_softc *sc) > > > > GEM_LOCK_ASSERT(sc, MA_OWNED); > > > >- /* Get the current RX configuration. */ > >- v = GEM_BANK1_READ_4(sc, GEM_MAC_RX_CONFIG); > >- > > /* > >- * Turn off promiscuous mode, promiscuous group mode (all multicast), > >- * and hash filter. Depending on the case, the right bit will be > >- * enabled. > >+ * Turn off the RX MAC and the hash filter as required by the Sun GEM > >+ * programming restrictions. > > */ > >- v&= ~(GEM_MAC_RX_PROMISCUOUS | GEM_MAC_RX_HASH_FILTER | > >- GEM_MAC_RX_PROMISC_GRP); > >- > >+ v = sc->sc_mac_rxcfg& GEM_MAC_RX_HASH_FILTER; > > GEM_BANK1_WRITE_4(sc, GEM_MAC_RX_CONFIG, v); > > GEM_BANK1_BARRIER(sc, GEM_MAC_RX_CONFIG, 4, > > BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); > >- if (!GEM_BANK1_BITWAIT(sc, GEM_MAC_RX_CONFIG, GEM_MAC_RX_HASH_FILTER, > >- 0)) > >- device_printf(sc->sc_dev, "cannot disable RX hash filter\n"); > >+ if (!GEM_BANK1_BITWAIT(sc, GEM_MAC_RX_CONFIG, GEM_MAC_RX_HASH_FILTER > >| > >+ GEM_MAC_RX_ENABLE, 0)) > >+ device_printf(sc->sc_dev, > >+ "cannot disable RX MAC or hash filter\n"); > > > >+ v&= ~(GEM_MAC_RX_PROMISCUOUS | GEM_MAC_RX_PROMISC_GRP); > > if ((ifp->if_flags& IFF_PROMISC) != 0) { > > v |= GEM_MAC_RX_PROMISCUOUS; > > goto chipit; > >@@ -2262,5 +2264,8 @@ gem_setladrf(struct gem_softc *sc) > > hash[i]); > > > > chipit: > >+ sc->sc_mac_rxcfg = v; > >+ if (enable) > >+ v |= GEM_MAC_RX_ENABLE; > > GEM_BANK1_WRITE_4(sc, GEM_MAC_RX_CONFIG, v); > > } > > > >Modified: head/sys/dev/gem/if_gemvar.h > >============================================================================== > >--- head/sys/dev/gem/if_gemvar.h Tue Jun 28 15:19:45 2011 (r223647) > >+++ head/sys/dev/gem/if_gemvar.h Tue Jun 28 16:16:43 2011 (r223648) > >@@ -173,6 +173,8 @@ struct gem_softc { > > u_int sc_rxptr; /* next ready RX descriptor/state */ > > u_int sc_rxfifosize; /* RX FIFO size (bytes) */ > > > >+ uint32_t sc_mac_rxcfg; /* RX MAC conf. % GEM_MAC_RX_ENABLE > >*/ > >+ > > int sc_ifflags; > > u_long sc_csum_features; > > }; > > _______________________________________________ > svn-src-all@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/svn-src-all > To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" From owner-svn-src-head@FreeBSD.ORG Thu Jul 7 17:00:42 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D93F9106566C; Thu, 7 Jul 2011 17:00:42 +0000 (UTC) (envelope-from jonathan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C99978FC14; Thu, 7 Jul 2011 17:00:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p67H0glB071439; Thu, 7 Jul 2011 17:00:42 GMT (envelope-from jonathan@svn.freebsd.org) Received: (from jonathan@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p67H0gra071437; Thu, 7 Jul 2011 17:00:42 GMT (envelope-from jonathan@svn.freebsd.org) Message-Id: <201107071700.p67H0gra071437@svn.freebsd.org> From: Jonathan Anderson Date: Thu, 7 Jul 2011 17:00:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223843 - head/sys/fs/smbfs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2011 17:00:42 -0000 Author: jonathan Date: Thu Jul 7 17:00:42 2011 New Revision: 223843 URL: http://svn.freebsd.org/changeset/base/223843 Log: Make a comment more accurate. This comment refers to CAP_NT_SMBS, which does not exist; it should refer to SMB_CAP_NT_SMBS. Fixing this comment makes it easier for people interested in Capsicum to grep around for capability rights, whose identifiers are of the form 'CAP_[A-Z_]'. Approved by: mentor (rwatson), re (Capsicum blanket) Sponsored by: Google Inc Modified: head/sys/fs/smbfs/smbfs_smb.c Modified: head/sys/fs/smbfs/smbfs_smb.c ============================================================================== --- head/sys/fs/smbfs/smbfs_smb.c Thu Jul 7 15:41:40 2011 (r223842) +++ head/sys/fs/smbfs/smbfs_smb.c Thu Jul 7 17:00:42 2011 (r223843) @@ -556,7 +556,7 @@ smbfs_smb_setftime(struct smbnode *np, s /* * Set DOS file attributes. - * Looks like this call can be used only if CAP_NT_SMBS bit is on. + * Looks like this call can be used only if SMB_CAP_NT_SMBS bit is on. */ int smbfs_smb_setfattrNT(struct smbnode *np, u_int16_t attr, struct timespec *mtime, From owner-svn-src-head@FreeBSD.ORG Thu Jul 7 17:07:13 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E1DA0106564A; Thu, 7 Jul 2011 17:07:12 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id 7FE9D8FC0C; Thu, 7 Jul 2011 17:07:12 +0000 (UTC) Received: by iwr19 with SMTP id 19so1354789iwr.13 for ; Thu, 07 Jul 2011 10:07:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:date:to:cc:subject:message-id:reply-to:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=DykaOpABxKFWC4n42RQihUAM8d6t33fyZH3ZapQn1dI=; b=Ad9eDbj1n6P19bjUJ15Er6cl+VEX5hr/oCVGQCDBYO1v0PZzkCJ9RESPEL09vOhtGm DW8KVco3xrPKr1AI/q9SA4+7+uGIH38P7P89xbvBnp92OxOw/hMlsJMBPVtRkT/RXVbL euROiGBcM+EZ80W3TXIoZEojyfv+aVJ6ikCYg= Received: by 10.231.64.132 with SMTP id e4mr894355ibi.8.1310056708376; Thu, 07 Jul 2011 09:38:28 -0700 (PDT) Received: from pyunyh@gmail.com ([174.35.1.224]) by mx.google.com with ESMTPS id v16sm5544916ibe.51.2011.07.07.09.38.25 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 07 Jul 2011 09:38:27 -0700 (PDT) Received: by pyunyh@gmail.com (sSMTP sendmail emulation); Thu, 07 Jul 2011 09:36:55 -0700 From: YongHyeon PYUN Date: Thu, 7 Jul 2011 09:36:55 -0700 To: Nathan Whitehorn Message-ID: <20110707163655.GA8702@michelle.cdnetworks.com> References: <201106281616.p5SGGhbx056614@svn.freebsd.org> <4E15C3FF.5030703@freebsd.org> <20110707160736.GE88226@alchemy.franken.de> <4E15DE20.2040000@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="DocE+STaALJfprDB" Content-Disposition: inline In-Reply-To: <4E15DE20.2040000@freebsd.org> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Marius Strobl Subject: Re: svn commit: r223648 - head/sys/dev/gem X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: pyunyh@gmail.com List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2011 17:07:13 -0000 --DocE+STaALJfprDB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jul 07, 2011 at 11:26:08AM -0500, Nathan Whitehorn wrote: > On 07/07/11 11:07, Marius Strobl wrote: > >On Thu, Jul 07, 2011 at 09:34:39AM -0500, Nathan Whitehorn wrote: > >>This breaks one of my gem devices (chip=0x0021106b) when the controller > >>is initialized from FreeBSD (netbooting works fine, and the controller > >>stays working after that), with "cannot disable RX MAC" or "cannot > >>disable RX MAC or hash filter" messages. > >Are you positive that it's exactly this revision which breaks things? > >Actually there was a report from Justin Hibbits that r222135 causing > >a GMAC to no longer work with similar symptoms, which still is unsolved > >AFAICT. If it's really r223648 which is causing problems in your case > >please try to figure out which part is causing that as none of the > >changes exactly stands out as disruptive, probably best by reverting > >gem_reset_rx() and gem_setladrf() one by one. > > > > You're right. r223648 just added the printf(), r222135 is where it began > not working. Yes, I know that. I still have no clue and can't explain how r222135 can break gem(4). Also note, the "cannot disable RX MAC" was there before r222135. One vague guess I have at this moment is that firmware may have put controller into some deep power save state so the first time gem_init() is called it may not have fully initialized the controller. I sent a patch to Justin to check that and waiting for his reply. > -Nathan --DocE+STaALJfprDB Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="gem.apple.diff" Index: sys/dev/gem/if_gem.c =================================================================== --- sys/dev/gem/if_gem.c (revision 223682) +++ sys/dev/gem/if_gem.c (working copy) @@ -328,6 +328,9 @@ phy = MII_PHY_ANY; break; } + if (GEM_IS_APPLE(sc)) + GEM_BANK1_WRITE_4(sc, GEM_MAC_XIF_CONFIG, + GEM_MAC_XIF_TX_MII_ENA); error = mii_attach(sc->sc_dev, &sc->sc_miibus, ifp, gem_mediachange, gem_mediastatus, BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, MIIF_DOPAUSE); --DocE+STaALJfprDB-- From owner-svn-src-head@FreeBSD.ORG Thu Jul 7 17:44:42 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA1FD106567F; Thu, 7 Jul 2011 17:44:42 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B9DD78FC16; Thu, 7 Jul 2011 17:44:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p67Hig1m072759; Thu, 7 Jul 2011 17:44:42 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p67HigjS072755; Thu, 7 Jul 2011 17:44:42 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201107071744.p67HigjS072755@svn.freebsd.org> From: Edward Tomasz Napierala Date: Thu, 7 Jul 2011 17:44:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223844 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2011 17:44:42 -0000 Author: trasz Date: Thu Jul 7 17:44:42 2011 New Revision: 223844 URL: http://svn.freebsd.org/changeset/base/223844 Log: Style fix - macros are supposed to be uppercase. Modified: head/sys/kern/kern_racct.c head/sys/kern/kern_rctl.c head/sys/sys/racct.h Modified: head/sys/kern/kern_racct.c ============================================================================== --- head/sys/kern/kern_racct.c Thu Jul 7 17:00:42 2011 (r223843) +++ head/sys/kern/kern_racct.c Thu Jul 7 17:44:42 2011 (r223844) @@ -173,7 +173,7 @@ racct_sub_racct(struct racct *dest, cons * Update resource usage in dest. */ for (i = 0; i <= RACCT_MAX; i++) { - if (!racct_is_sloppy(i)) { + if (!RACCT_IS_SLOPPY(i)) { KASSERT(dest->r_resources[i] >= 0, ("racct propagation meltdown: dest < 0")); KASSERT(src->r_resources[i] >= 0, @@ -181,10 +181,10 @@ racct_sub_racct(struct racct *dest, cons KASSERT(src->r_resources[i] <= dest->r_resources[i], ("racct propagation meltdown: src > dest")); } - if (racct_is_reclaimable(i)) { + if (RACCT_IS_RECLAIMABLE(i)) { dest->r_resources[i] -= src->r_resources[i]; if (dest->r_resources[i] < 0) { - KASSERT(racct_is_sloppy(i), + KASSERT(RACCT_IS_SLOPPY(i), ("racct_sub_racct: usage < 0")); dest->r_resources[i] = 0; } @@ -218,9 +218,9 @@ racct_destroy_locked(struct racct **racc racct = *racctp; for (i = 0; i <= RACCT_MAX; i++) { - if (racct_is_sloppy(i)) + if (RACCT_IS_SLOPPY(i)) continue; - if (!racct_is_reclaimable(i)) + if (!RACCT_IS_RECLAIMABLE(i)) continue; KASSERT(racct->r_resources[i] == 0, ("destroying non-empty racct: " @@ -255,7 +255,7 @@ racct_alloc_resource(struct racct *racct racct->r_resources[resource] += amount; if (racct->r_resources[resource] < 0) { - KASSERT(racct_is_sloppy(resource), + KASSERT(RACCT_IS_SLOPPY(resource), ("racct_alloc_resource: usage < 0")); racct->r_resources[resource] = 0; } @@ -285,7 +285,7 @@ racct_add(struct proc *p, int resource, mtx_lock(&racct_lock); #ifdef RCTL error = rctl_enforce(p, resource, amount); - if (error && racct_is_deniable(resource)) { + if (error && RACCT_IS_DENIABLE(resource)) { SDT_PROBE(racct, kernel, rusage, add_failure, p, resource, amount, 0, 0); mtx_unlock(&racct_lock); @@ -373,14 +373,14 @@ racct_set_locked(struct proc *p, int res diff = amount - p->p_racct->r_resources[resource]; #ifdef notyet - KASSERT(diff >= 0 || racct_is_reclaimable(resource), + KASSERT(diff >= 0 || RACCT_IS_RECLAIMABLE(resource), ("racct_set: usage of non-reclaimable resource %d dropping", resource)); #endif #ifdef RCTL if (diff > 0) { error = rctl_enforce(p, resource, diff); - if (error && racct_is_deniable(resource)) { + if (error && RACCT_IS_DENIABLE(resource)) { SDT_PROBE(racct, kernel, rusage, set_failure, p, resource, amount, 0, 0); return (error); @@ -489,7 +489,7 @@ racct_sub(struct proc *p, int resource, * We need proc lock to dereference p->p_ucred. */ PROC_LOCK_ASSERT(p, MA_OWNED); - KASSERT(racct_is_reclaimable(resource), + KASSERT(RACCT_IS_RECLAIMABLE(resource), ("racct_sub: called for non-reclaimable resource %d", resource)); mtx_lock(&racct_lock); @@ -512,7 +512,7 @@ racct_sub_cred_locked(struct ucred *cred 0, 0); #ifdef notyet - KASSERT(racct_is_reclaimable(resource), + KASSERT(RACCT_IS_RECLAIMABLE(resource), ("racct_sub_cred: called for non-reclaimable resource %d", resource)); #endif @@ -564,7 +564,7 @@ racct_proc_fork(struct proc *parent, str */ for (i = 0; i <= RACCT_MAX; i++) { if (parent->p_racct->r_resources[i] == 0 || - !racct_is_inheritable(i)) + !RACCT_IS_INHERITABLE(i)) continue; error = racct_set_locked(child, i, Modified: head/sys/kern/kern_rctl.c ============================================================================== --- head/sys/kern/kern_rctl.c Thu Jul 7 17:00:42 2011 (r223843) +++ head/sys/kern/kern_rctl.c Thu Jul 7 17:44:42 2011 (r223844) @@ -907,7 +907,7 @@ rctl_string_to_rule(char *rulestr, struc error = str2int64(amountstr, &rule->rr_amount); if (error != 0) goto out; - if (racct_is_in_thousands(rule->rr_resource)) + if (RACCT_IS_IN_THOUSANDS(rule->rr_resource)) rule->rr_amount *= 1000; } @@ -947,7 +947,7 @@ rctl_rule_add(struct rctl_rule *rule) /* * Some rules just don't make sense. Note that the one below - * cannot be rewritten using racct_is_deniable(); the RACCT_PCTCPU, + * cannot be rewritten using RACCT_IS_DENIABLE(); the RACCT_PCTCPU, * for example, is not deniable in the racct sense, but the * limit is enforced in a different way, so "deny" rules for %CPU * do make sense. @@ -958,7 +958,7 @@ rctl_rule_add(struct rctl_rule *rule) return (EOPNOTSUPP); if (rule->rr_per == RCTL_SUBJECT_TYPE_PROCESS && - racct_is_sloppy(rule->rr_resource)) + RACCT_IS_SLOPPY(rule->rr_resource)) return (EOPNOTSUPP); /* @@ -1152,7 +1152,7 @@ rctl_rule_to_sbuf(struct sbuf *sb, const amount = rule->rr_amount; if (amount != RCTL_AMOUNT_UNDEFINED && - racct_is_in_thousands(rule->rr_resource)) + RACCT_IS_IN_THOUSANDS(rule->rr_resource)) amount /= 1000; sbuf_printf(sb, "%s:%s=%jd", @@ -1219,10 +1219,10 @@ rctl_racct_to_sbuf(struct racct *racct, sb = sbuf_new_auto(); for (i = 0; i <= RACCT_MAX; i++) { - if (sloppy == 0 && racct_is_sloppy(i)) + if (sloppy == 0 && RACCT_IS_SLOPPY(i)) continue; amount = racct->r_resources[i]; - if (racct_is_in_thousands(i)) + if (RACCT_IS_IN_THOUSANDS(i)) amount /= 1000; sbuf_printf(sb, "%s=%jd,", rctl_resource_name(i), amount); } Modified: head/sys/sys/racct.h ============================================================================== --- head/sys/sys/racct.h Thu Jul 7 17:00:42 2011 (r223843) +++ head/sys/sys/racct.h Thu Jul 7 17:44:42 2011 (r223844) @@ -86,31 +86,31 @@ extern int racct_types[]; * visible to the userland. It gets fixed up when retrieving resource * usage or adding rules. */ -#define racct_is_in_thousands(X) (racct_types[X] & RACCT_IN_THOUSANDS) +#define RACCT_IS_IN_THOUSANDS(X) (racct_types[X] & RACCT_IN_THOUSANDS) /* * Resource usage can drop, as opposed to only grow. */ -#define racct_is_reclaimable(X) (racct_types[X] & RACCT_RECLAIMABLE) +#define RACCT_IS_RECLAIMABLE(X) (racct_types[X] & RACCT_RECLAIMABLE) /* * Children inherit resource usage. */ -#define racct_is_inheritable(X) (racct_types[X] & RACCT_INHERITABLE) +#define RACCT_IS_INHERITABLE(X) (racct_types[X] & RACCT_INHERITABLE) /* * racct_{add,set}(9) can actually return an error and not update resource * usage counters. Note that even when resource is not deniable, allocating * resource might cause signals to be sent by RCTL code. */ -#define racct_is_deniable(X) (racct_types[X] & RACCT_DENIABLE) +#define RACCT_IS_DENIABLE(X) (racct_types[X] & RACCT_DENIABLE) /* * Per-process resource usage information makes no sense, but per-credential * one does. This kind of resources are usually allocated for process, but * freed using credentials. */ -#define racct_is_sloppy(X) (racct_types[X] & RACCT_SLOPPY) +#define RACCT_IS_SLOPPY(X) (racct_types[X] & RACCT_SLOPPY) /* * The 'racct' structure defines resource consumption for a particular From owner-svn-src-head@FreeBSD.ORG Thu Jul 7 18:07:04 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EAAA61065672; Thu, 7 Jul 2011 18:07:03 +0000 (UTC) (envelope-from jonathan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DA8FF8FC1B; Thu, 7 Jul 2011 18:07:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p67I73xT073458; Thu, 7 Jul 2011 18:07:03 GMT (envelope-from jonathan@svn.freebsd.org) Received: (from jonathan@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p67I73sc073454; Thu, 7 Jul 2011 18:07:03 GMT (envelope-from jonathan@svn.freebsd.org) Message-Id: <201107071807.p67I73sc073454@svn.freebsd.org> From: Jonathan Anderson Date: Thu, 7 Jul 2011 18:07:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223845 - head/tools/regression/kqueue X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2011 18:07:04 -0000 Author: jonathan Date: Thu Jul 7 18:07:03 2011 New Revision: 223845 URL: http://svn.freebsd.org/changeset/base/223845 Log: Ensure that kqueue is not inherited across fork(). Modify the existing unit test (from libkqueue) which already exercises process events via fork() and kill(). Now, the child process simply checks that the 'kqfd' descriptor is invalid. Some minor modifications were required to make err() work correctly. It seems that this test was imported using the output of a configure script, but config.h was not included in key places, nor was its syntax correct (need '#define HAVE_FOO 1' rather than '#define HAVE_FOO'). Finally, change main() to run the "proc" suite by default, but widened the '#if TODO' in proc.c to include the non-functioning test event_trigger(). Approved by: mentor (rwatson), re (Capsicum blanket) Sponsored by: Google Inc Modified: head/tools/regression/kqueue/config.h head/tools/regression/kqueue/main.c head/tools/regression/kqueue/proc.c Modified: head/tools/regression/kqueue/config.h ============================================================================== --- head/tools/regression/kqueue/config.h Thu Jul 7 17:44:42 2011 (r223844) +++ head/tools/regression/kqueue/config.h Thu Jul 7 18:07:03 2011 (r223845) @@ -1,7 +1,7 @@ -/* AUTOMATICALLY GENERATED -- DO NOT EDIT */ -/* $FreeBSD$ */ -#define HAVE_ERR_H -#define HAVE_SYS_EVENT_H +# $FreeBSD$ + +#define HAVE_ERR_H 1 +#define HAVE_SYS_EVENT_H 1 #define HAVE_EV_DISPATCH 1 #define HAVE_EV_RECEIPT 1 #undef HAVE_NOTE_TRUNCATE Modified: head/tools/regression/kqueue/main.c ============================================================================== --- head/tools/regression/kqueue/main.c Thu Jul 7 17:44:42 2011 (r223844) +++ head/tools/regression/kqueue/main.c Thu Jul 7 18:07:03 2011 (r223845) @@ -18,6 +18,7 @@ #include +#include "config.h" #include "common.h" int testnum = 1; @@ -230,7 +231,7 @@ test_kqueue_close(void) int main(int argc, char **argv) { - int test_proc = 0; /* XXX-FIXME */ + int test_proc = 1; int test_socket = 1; int test_signal = 1; int test_vnode = 1; Modified: head/tools/regression/kqueue/proc.c ============================================================================== --- head/tools/regression/kqueue/proc.c Thu Jul 7 17:44:42 2011 (r223844) +++ head/tools/regression/kqueue/proc.c Thu Jul 7 18:07:03 2011 (r223845) @@ -16,6 +16,11 @@ * $FreeBSD$ */ +#include + +#include + +#include "config.h" #include "common.h" static int sigusr1_caught = 0; @@ -37,6 +42,11 @@ add_and_delete(void) /* Create a child that waits to be killed and then exits */ pid = fork(); if (pid == 0) { + struct stat s; + if ((fstat(kqfd, &s) != -1) || (errno != EBADF)) + err(1, "%s:%d - %s: fstat(kqfd) in child did not return EBADF", + __FILE__, __LINE__, __func__); + pause(); exit(2); } @@ -52,6 +62,7 @@ add_and_delete(void) test_begin("kevent(EVFILT_PROC, EV_DELETE)"); + sleep(1); test_no_kevents(); kevent_add(kqfd, &kev, pid, EVFILT_PROC, EV_DELETE, 0, 0, NULL); if (kill(pid, SIGKILL) < 0) @@ -63,6 +74,7 @@ add_and_delete(void) } +#ifdef TODO static void event_trigger(void) { @@ -93,7 +105,6 @@ event_trigger(void) success(); } -#ifdef TODO void test_kevent_signal_disable(void) { @@ -225,7 +236,10 @@ test_evfilt_proc() signal(SIGUSR1, sig_handler); add_and_delete(); + +#if TODO event_trigger(); +#endif signal(SIGUSR1, SIG_DFL); From owner-svn-src-head@FreeBSD.ORG Thu Jul 7 20:02:09 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 950FA1065680; Thu, 7 Jul 2011 20:02:09 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 856ED8FC0C; Thu, 7 Jul 2011 20:02:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p67K29kS076848; Thu, 7 Jul 2011 20:02:09 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p67K29A2076846; Thu, 7 Jul 2011 20:02:09 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <201107072002.p67K29A2076846@svn.freebsd.org> From: Andrew Thompson Date: Thu, 7 Jul 2011 20:02:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223846 - head/sys/net X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2011 20:02:09 -0000 Author: thompsa Date: Thu Jul 7 20:02:09 2011 New Revision: 223846 URL: http://svn.freebsd.org/changeset/base/223846 Log: Grab the rlock before checking if our interface is enabled, it could be possible to hit a dead pointer when changing interfaces. PR: kern/156978 Submitted by: Andrew Boyer MFC after: 1 week Modified: head/sys/net/if_lagg.c Modified: head/sys/net/if_lagg.c ============================================================================== --- head/sys/net/if_lagg.c Thu Jul 7 18:07:03 2011 (r223845) +++ head/sys/net/if_lagg.c Thu Jul 7 20:02:09 2011 (r223846) @@ -1221,14 +1221,15 @@ lagg_input(struct ifnet *ifp, struct mbu struct lagg_softc *sc = lp->lp_softc; struct ifnet *scifp = sc->sc_ifp; + LAGG_RLOCK(sc); if ((scifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || (lp->lp_flags & LAGG_PORT_DISABLED) || sc->sc_proto == LAGG_PROTO_NONE) { + LAGG_RUNLOCK(sc); m_freem(m); return (NULL); } - LAGG_RLOCK(sc); ETHER_BPF_MTAP(scifp, m); m = (*sc->sc_input)(sc, lp, m); From owner-svn-src-head@FreeBSD.ORG Thu Jul 7 20:59:42 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 96F2B1065673; Thu, 7 Jul 2011 20:59:42 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 874F48FC17; Thu, 7 Jul 2011 20:59:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p67KxgM9078546; Thu, 7 Jul 2011 20:59:42 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p67KxgTI078544; Thu, 7 Jul 2011 20:59:42 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201107072059.p67KxgTI078544@svn.freebsd.org> From: Rick Macklem Date: Thu, 7 Jul 2011 20:59:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223847 - head/etc/rc.d X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2011 20:59:42 -0000 Author: rmacklem Date: Thu Jul 7 20:59:42 2011 New Revision: 223847 URL: http://svn.freebsd.org/changeset/base/223847 Log: Fix the /etc/rc.d/nfsd script so that it no longer uses the /etc/rc.d/nfsserver script to load the old nfs server module. Tested by: sgk at troutmask.apl.washington.edu Reviewed by: rc (hrs) Modified: head/etc/rc.d/nfsd Modified: head/etc/rc.d/nfsd ============================================================================== --- head/etc/rc.d/nfsd Thu Jul 7 20:02:09 2011 (r223846) +++ head/etc/rc.d/nfsd Thu Jul 7 20:59:42 2011 (r223847) @@ -22,9 +22,9 @@ nfsd_precmd() if checkyesno oldnfs_server_enable; then rc_flags="-o ${nfs_server_flags}" - if ! sysctl vfs.nfsrv >/dev/null 2>&1; then - force_depend nfsserver || return 1 - fi + # Load the module now, so that the vfs.nfsrv sysctl + # oids are available. + load_kld nfsserver if checkyesno nfs_reserved_port_only; then echo 'NFS on reserved port only=YES' From owner-svn-src-head@FreeBSD.ORG Thu Jul 7 23:17:57 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 049A2106566C; Thu, 7 Jul 2011 23:17:57 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E89DB8FC0C; Thu, 7 Jul 2011 23:17:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p67NHuZl082816; Thu, 7 Jul 2011 23:17:56 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p67NHuOS082814; Thu, 7 Jul 2011 23:17:56 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201107072317.p67NHuOS082814@svn.freebsd.org> From: "David E. O'Brien" Date: Thu, 7 Jul 2011 23:17:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223849 - head/contrib/pf/man X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2011 23:17:57 -0000 Author: obrien Date: Thu Jul 7 23:17:56 2011 New Revision: 223849 URL: http://svn.freebsd.org/changeset/base/223849 Log: Note the PF version. Discussed with: bz Modified: head/contrib/pf/man/pf.4 Modified: head/contrib/pf/man/pf.4 ============================================================================== --- head/contrib/pf/man/pf.4 Thu Jul 7 22:30:12 2011 (r223848) +++ head/contrib/pf/man/pf.4 Thu Jul 7 23:17:56 2011 (r223849) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 10 2008 +.Dd June 28 2011 .Dt PF 4 .Os .Sh NAME @@ -1146,4 +1146,9 @@ main(int argc, char *argv[]) The .Nm packet filtering mechanism first appeared in -.Ox 3.0 . +.Ox 3.0 +and then +.Fx 5.2 . +.Pp +This implementation matches +.Ox 4.5 . From owner-svn-src-head@FreeBSD.ORG Fri Jul 8 00:49:51 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 81569106566C; Fri, 8 Jul 2011 00:49:51 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 577C08FC12; Fri, 8 Jul 2011 00:49:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p680npsw085660; Fri, 8 Jul 2011 00:49:51 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p680npZX085654; Fri, 8 Jul 2011 00:49:51 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201107080049.p680npZX085654@svn.freebsd.org> From: Rick Macklem Date: Fri, 8 Jul 2011 00:49:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223852 - in head: . etc/rc.d X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2011 00:49:51 -0000 Author: rmacklem Date: Fri Jul 8 00:49:50 2011 New Revision: 223852 URL: http://svn.freebsd.org/changeset/base/223852 Log: Delete the /etc/rc.d/nfsserver script, since it is no longer used by /etc/rc.d/nfsd and it is no longer necessary to load the old nfs server by default, when nfs_server_enable="YES". Tested by: sgk at troutmask.apl.washington.edu Reviewed by: rc (Andrzej Tobola) Deleted: head/etc/rc.d/nfsserver Modified: head/ObsoleteFiles.inc head/etc/rc.d/Makefile head/etc/rc.d/lockd head/etc/rc.d/mountd head/etc/rc.d/statd Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Thu Jul 7 23:32:44 2011 (r223851) +++ head/ObsoleteFiles.inc Fri Jul 8 00:49:50 2011 (r223852) @@ -38,6 +38,8 @@ # xargs -n1 | sort | uniq -d; # done +# 20110707: script no longer needed by /etc/rc.d/nfsd +OLD_FILES+=etc/rc.d/nfsserver # 20110705: files moved so both NFS clients can share them OLD_FILES+=usr/include/nfsclient/krpc.h OLD_FILES+=usr/include/nfsclient/nfsdiskless.h Modified: head/etc/rc.d/Makefile ============================================================================== --- head/etc/rc.d/Makefile Thu Jul 7 23:32:44 2011 (r223851) +++ head/etc/rc.d/Makefile Fri Jul 8 00:49:50 2011 (r223852) @@ -24,7 +24,7 @@ FILES= DAEMON FILESYSTEMS LOGIN NETWORKI mdconfig mdconfig2 mountd moused mroute6d mrouted msgs \ named natd netif netoptions netwait \ newsyslog nfsclient nfscbd nfsd \ - nfsserver nfsuserd nisdomain nsswitch ntpd ntpdate \ + nfsuserd nisdomain nsswitch ntpd ntpdate \ othermta \ pf pflog pfsync \ powerd power_profile ppp pppoed pwcheck \ Modified: head/etc/rc.d/lockd ============================================================================== --- head/etc/rc.d/lockd Thu Jul 7 23:32:44 2011 (r223851) +++ head/etc/rc.d/lockd Fri Jul 8 00:49:50 2011 (r223852) @@ -5,7 +5,7 @@ # # PROVIDE: lockd -# REQUIRE: nfsserver nfsclient nfsd rpcbind statd +# REQUIRE: nfsclient nfsd rpcbind statd # BEFORE: DAEMON # KEYWORD: nojail shutdown Modified: head/etc/rc.d/mountd ============================================================================== --- head/etc/rc.d/mountd Thu Jul 7 23:32:44 2011 (r223851) +++ head/etc/rc.d/mountd Fri Jul 8 00:49:50 2011 (r223852) @@ -4,7 +4,7 @@ # # PROVIDE: mountd -# REQUIRE: NETWORKING nfsserver rpcbind quota +# REQUIRE: NETWORKING rpcbind quota # KEYWORD: nojail shutdown . /etc/rc.subr Modified: head/etc/rc.d/statd ============================================================================== --- head/etc/rc.d/statd Thu Jul 7 23:32:44 2011 (r223851) +++ head/etc/rc.d/statd Fri Jul 8 00:49:50 2011 (r223852) @@ -5,7 +5,7 @@ # # PROVIDE: statd -# REQUIRE: nfsserver nfsclient nfsd rpcbind +# REQUIRE: nfsclient nfsd rpcbind # BEFORE: DAEMON # KEYWORD: nojail shutdown From owner-svn-src-head@FreeBSD.ORG Fri Jul 8 01:35:34 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 36629106566B; Fri, 8 Jul 2011 01:35:34 +0000 (UTC) (envelope-from avatar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0CDF38FC16; Fri, 8 Jul 2011 01:35:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p681ZXaZ087115; Fri, 8 Jul 2011 01:35:33 GMT (envelope-from avatar@svn.freebsd.org) Received: (from avatar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p681ZXZu087112; Fri, 8 Jul 2011 01:35:33 GMT (envelope-from avatar@svn.freebsd.org) Message-Id: <201107080135.p681ZXZu087112@svn.freebsd.org> From: Tai-hwa Liang Date: Fri, 8 Jul 2011 01:35:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223854 - head/lib/libstand X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2011 01:35:34 -0000 Author: avatar Date: Fri Jul 8 01:35:33 2011 New Revision: 223854 URL: http://svn.freebsd.org/changeset/base/223854 Log: Fixing building bustage on 32 bits platforms when WARNS >= 2. Note that this fix only applies to zalloc.c, the other part of libstand such like qdivrem.c still gives compilation warnings on sparc64 tinderbox builds; therefore, WARNS level isn't changed for now. Submitted by: Garrett Cooper Reviewed by: bde Modified: head/lib/libstand/zalloc.c head/lib/libstand/zalloc_defs.h Modified: head/lib/libstand/zalloc.c ============================================================================== --- head/lib/libstand/zalloc.c Fri Jul 8 01:32:04 2011 (r223853) +++ head/lib/libstand/zalloc.c Fri Jul 8 01:35:33 2011 (r223854) @@ -154,7 +154,7 @@ zfree(MemPool *mp, void *ptr, iaddr_t by if ((char *)ptr < (char *)mp->mp_Base || (char *)ptr + bytes > (char *)mp->mp_End || ((iaddr_t)ptr & MEMNODE_SIZE_MASK) != 0) - panic("zfree(%p,%ju): wild pointer", ptr, bytes); + panic("zfree(%p,%ju): wild pointer", ptr, (uintmax_t)bytes); /* * free the segment @@ -177,8 +177,10 @@ zfree(MemPool *mp, void *ptr, iaddr_t by /* * range check */ - if ((char *)ptr + bytes > (char *)mn) - panic("zfree(%p,%ju): corrupt memlist1",ptr, bytes); + if ((char *)ptr + bytes > (char *)mn) { + panic("zfree(%p,%ju): corrupt memlist1", ptr, + (uintmax_t)bytes); + } /* * merge against next area or create independant area @@ -208,8 +210,10 @@ zfree(MemPool *mp, void *ptr, iaddr_t by return; /* NOT REACHED */ } - if ((char *)ptr < (char *)mn + mn->mr_Bytes) - panic("zfree(%p,%ju): corrupt memlist2", ptr, bytes); + if ((char *)ptr < (char *)mn + mn->mr_Bytes) { + panic("zfree(%p,%ju): corrupt memlist2", ptr, + (uintmax_t)bytes); + } } /* * We are beyond the last MemNode, append new MemNode. Merge against Modified: head/lib/libstand/zalloc_defs.h ============================================================================== --- head/lib/libstand/zalloc_defs.h Fri Jul 8 01:32:04 2011 (r223853) +++ head/lib/libstand/zalloc_defs.h Fri Jul 8 01:35:33 2011 (r223854) @@ -39,6 +39,7 @@ #define ZALLOCDEBUG #include +#include #include "stand.h" typedef uintptr_t iaddr_t; /* unsigned int same size as pointer */ From owner-svn-src-head@FreeBSD.ORG Thu Jul 7 16:26:11 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DABA81065672; Thu, 7 Jul 2011 16:26:11 +0000 (UTC) (envelope-from nwhitehorn@freebsd.org) Received: from argol.doit.wisc.edu (argol.doit.wisc.edu [144.92.197.212]) by mx1.freebsd.org (Postfix) with ESMTP id ABA808FC1D; Thu, 7 Jul 2011 16:26:11 +0000 (UTC) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII; format=flowed Received: from avs-daemon.smtpauth3.wiscmail.wisc.edu by smtpauth3.wiscmail.wisc.edu (Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30 2009)) id <0LNZ0041C1NMGA00@smtpauth3.wiscmail.wisc.edu>; Thu, 07 Jul 2011 11:26:10 -0500 (CDT) Received: from comporellon.tachypleus.net (adsl-75-50-91-37.dsl.mdsnwi.sbcglobal.net [75.50.91.37]) by smtpauth3.wiscmail.wisc.edu (Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30 2009)) with ESMTPSA id <0LNZ00G3U1NK9V30@smtpauth3.wiscmail.wisc.edu>; Thu, 07 Jul 2011 11:26:09 -0500 (CDT) Date: Thu, 07 Jul 2011 11:26:08 -0500 From: Nathan Whitehorn In-reply-to: <20110707160736.GE88226@alchemy.franken.de> To: Marius Strobl Message-id: <4E15DE20.2040000@freebsd.org> X-Spam-Report: AuthenticatedSender=yes, SenderIP=75.50.91.37 X-Spam-PmxInfo: Server=avs-14, Version=5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2011.7.7.161514, SenderIP=75.50.91.37 References: <201106281616.p5SGGhbx056614@svn.freebsd.org> <4E15C3FF.5030703@freebsd.org> <20110707160736.GE88226@alchemy.franken.de> User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:5.0) Gecko/20110704 Thunderbird/5.0 X-Mailman-Approved-At: Fri, 08 Jul 2011 05:43:56 +0000 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r223648 - head/sys/dev/gem X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jul 2011 16:26:12 -0000 On 07/07/11 11:07, Marius Strobl wrote: > On Thu, Jul 07, 2011 at 09:34:39AM -0500, Nathan Whitehorn wrote: >> This breaks one of my gem devices (chip=0x0021106b) when the controller >> is initialized from FreeBSD (netbooting works fine, and the controller >> stays working after that), with "cannot disable RX MAC" or "cannot >> disable RX MAC or hash filter" messages. > Are you positive that it's exactly this revision which breaks things? > Actually there was a report from Justin Hibbits that r222135 causing > a GMAC to no longer work with similar symptoms, which still is unsolved > AFAICT. If it's really r223648 which is causing problems in your case > please try to figure out which part is causing that as none of the > changes exactly stands out as disruptive, probably best by reverting > gem_reset_rx() and gem_setladrf() one by one. > You're right. r223648 just added the printf(), r222135 is where it began not working. -Nathan From owner-svn-src-head@FreeBSD.ORG Fri Jul 8 08:49:31 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D2947106564A; Fri, 8 Jul 2011 08:49:31 +0000 (UTC) (envelope-from crodr001@gmail.com) Received: from mail-yi0-f54.google.com (mail-yi0-f54.google.com [209.85.218.54]) by mx1.freebsd.org (Postfix) with ESMTP id 5A0E98FC13; Fri, 8 Jul 2011 08:49:31 +0000 (UTC) Received: by yic13 with SMTP id 13so883680yic.13 for ; Fri, 08 Jul 2011 01:49:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=ozgdtwGVC1whW4kOgqdq8PuXmWZyRN/kbw3gVkoiDDw=; b=gNfnpNszykOqsazc/siEgjTOUAfgOmx5znWGdtHGH8clo2MxOM7zue8APMQGxCUc8j vX1m5FgOW+u9h7fnzDD9yoZQaHueW0p3XuyO15wy1wl/Ofbyh39hvRWza0CcTjE/JEOd Pgam1DtiAfRjzrpndEfP6ptQp/o748ZKphEOE= MIME-Version: 1.0 Received: by 10.101.26.30 with SMTP id d30mr1422620anj.125.1310113531870; Fri, 08 Jul 2011 01:25:31 -0700 (PDT) Sender: crodr001@gmail.com Received: by 10.100.92.8 with HTTP; Fri, 8 Jul 2011 01:25:31 -0700 (PDT) In-Reply-To: <201107080135.p681ZXZu087112@svn.freebsd.org> References: <201107080135.p681ZXZu087112@svn.freebsd.org> Date: Fri, 8 Jul 2011 01:25:31 -0700 X-Google-Sender-Auth: ZPD5_YRSNVCw-uL8-AwK5UZSYac Message-ID: From: Craig Rodrigues To: Tai-hwa Liang Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r223854 - head/lib/libstand X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2011 08:49:31 -0000 Hi, While not ideal, would it be possible consider setting WARNS to set different levels depending on what the value of ${MACHINE_ARCH} is? Something like: .if ${MACHINE_ARCH} != "sparc64" (or whatever the correct value is) WARNS ?= 0 .else WARNS ?= 2 .endif This would at least be an attempt to prevent people from adding new code to libstand which introduce new warnings. -- Craig Rodrigues rodrigc@crodrigues.org On Thu, Jul 7, 2011 at 6:35 PM, Tai-hwa Liang wrote: > Author: avatar > Date: Fri Jul 8 01:35:33 2011 > New Revision: 223854 > URL: http://svn.freebsd.org/changeset/base/223854 > > Log: > Fixing building bustage on 32 bits platforms when WARNS >= 2. Note that > this fix only applies to zalloc.c, the other part of libstand such like > qdivrem.c still gives compilation warnings on sparc64 tinderbox builds; > therefore, WARNS level isn't changed for now. > > Submitted by: Garrett Cooper > Reviewed by: bde > > Modified: > head/lib/libstand/zalloc.c > head/lib/libstand/zalloc_defs.h > > Modified: head/lib/libstand/zalloc.c > > ============================================================================== > --- head/lib/libstand/zalloc.c Fri Jul 8 01:32:04 2011 (r223853) > +++ head/lib/libstand/zalloc.c Fri Jul 8 01:35:33 2011 (r223854) > @@ -154,7 +154,7 @@ zfree(MemPool *mp, void *ptr, iaddr_t by > if ((char *)ptr < (char *)mp->mp_Base || > (char *)ptr + bytes > (char *)mp->mp_End || > ((iaddr_t)ptr & MEMNODE_SIZE_MASK) != 0) > - panic("zfree(%p,%ju): wild pointer", ptr, bytes); > + panic("zfree(%p,%ju): wild pointer", ptr, (uintmax_t)bytes); > > /* > * free the segment > @@ -177,8 +177,10 @@ zfree(MemPool *mp, void *ptr, iaddr_t by > /* > * range check > */ > - if ((char *)ptr + bytes > (char *)mn) > - panic("zfree(%p,%ju): corrupt memlist1",ptr, bytes); > + if ((char *)ptr + bytes > (char *)mn) { > + panic("zfree(%p,%ju): corrupt memlist1", ptr, > + (uintmax_t)bytes); > + } > > /* > * merge against next area or create independant area > @@ -208,8 +210,10 @@ zfree(MemPool *mp, void *ptr, iaddr_t by > return; > /* NOT REACHED */ > } > - if ((char *)ptr < (char *)mn + mn->mr_Bytes) > - panic("zfree(%p,%ju): corrupt memlist2", ptr, bytes); > + if ((char *)ptr < (char *)mn + mn->mr_Bytes) { > + panic("zfree(%p,%ju): corrupt memlist2", ptr, > + (uintmax_t)bytes); > + } > } > /* > * We are beyond the last MemNode, append new MemNode. Merge > against > > Modified: head/lib/libstand/zalloc_defs.h > > ============================================================================== > --- head/lib/libstand/zalloc_defs.h Fri Jul 8 01:32:04 2011 > (r223853) > +++ head/lib/libstand/zalloc_defs.h Fri Jul 8 01:35:33 2011 > (r223854) > @@ -39,6 +39,7 @@ > #define ZALLOCDEBUG > > #include > +#include > #include "stand.h" > > typedef uintptr_t iaddr_t; /* unsigned int same size as pointer */ > -- Craig Rodrigues rodrigc@rodrigues.org From owner-svn-src-head@FreeBSD.ORG Fri Jul 8 09:38:34 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DFFAF106566C; Fri, 8 Jul 2011 09:38:33 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C5ADC8FC12; Fri, 8 Jul 2011 09:38:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p689cXqe002140; Fri, 8 Jul 2011 09:38:33 GMT (envelope-from zec@svn.freebsd.org) Received: (from zec@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p689cXTe002136; Fri, 8 Jul 2011 09:38:33 GMT (envelope-from zec@svn.freebsd.org) Message-Id: <201107080938.p689cXTe002136@svn.freebsd.org> From: Marko Zec Date: Fri, 8 Jul 2011 09:38:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223862 - in head/sys: net netinet netinet6 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2011 09:38:34 -0000 Author: zec Date: Fri Jul 8 09:38:33 2011 New Revision: 223862 URL: http://svn.freebsd.org/changeset/base/223862 Log: Permit ARP to proceed for IPv4 host routes for which the gateway is the same as the host address. This already works fine for INET6 and ND6. While here, remove two function pointers from struct lltable which are only initialized but never used. MFC after: 3 days Modified: head/sys/net/if_llatbl.h head/sys/netinet/in.c head/sys/netinet6/in6.c Modified: head/sys/net/if_llatbl.h ============================================================================== --- head/sys/net/if_llatbl.h Fri Jul 8 09:20:32 2011 (r223861) +++ head/sys/net/if_llatbl.h Fri Jul 8 09:38:33 2011 (r223862) @@ -151,7 +151,6 @@ struct lltable { int llt_af; struct ifnet *llt_ifp; - struct llentry * (*llt_new)(const struct sockaddr *, u_int); void (*llt_free)(struct lltable *, struct llentry *); void (*llt_prefix_free)(struct lltable *, const struct sockaddr *prefix, @@ -159,8 +158,6 @@ struct lltable { u_int flags); struct llentry * (*llt_lookup)(struct lltable *, u_int flags, const struct sockaddr *l3addr); - int (*llt_rtcheck)(struct ifnet *, u_int flags, - const struct sockaddr *); int (*llt_dump)(struct lltable *, struct sysctl_req *); }; Modified: head/sys/netinet/in.c ============================================================================== --- head/sys/netinet/in.c Fri Jul 8 09:20:32 2011 (r223861) +++ head/sys/netinet/in.c Fri Jul 8 09:38:33 2011 (r223862) @@ -1416,6 +1416,18 @@ in_lltable_rtcheck(struct ifnet *ifp, u_ /* XXX rtalloc1 should take a const param */ rt = rtalloc1(__DECONST(struct sockaddr *, l3addr), 0, 0); + + /* + * If the gateway for an existing host route matches the target L3 + * address, allow for ARP to proceed. + */ + if (rt != NULL && (rt->rt_flags & (RTF_HOST|RTF_GATEWAY)) && + rt->rt_gateway->sa_family == AF_INET && + memcmp(rt->rt_gateway->sa_data, l3addr->sa_data, 4) == 0) { + RTFREE_LOCKED(rt); + return (0); + } + if (rt == NULL || (!(flags & LLE_PUB) && ((rt->rt_flags & RTF_GATEWAY) || (rt->rt_ifp != ifp)))) { @@ -1599,10 +1611,8 @@ in_domifattach(struct ifnet *ifp) llt = lltable_init(ifp, AF_INET); if (llt != NULL) { - llt->llt_new = in_lltable_new; llt->llt_free = in_lltable_free; llt->llt_prefix_free = in_lltable_prefix_free; - llt->llt_rtcheck = in_lltable_rtcheck; llt->llt_lookup = in_lltable_lookup; llt->llt_dump = in_lltable_dump; } Modified: head/sys/netinet6/in6.c ============================================================================== --- head/sys/netinet6/in6.c Fri Jul 8 09:20:32 2011 (r223861) +++ head/sys/netinet6/in6.c Fri Jul 8 09:38:33 2011 (r223862) @@ -2636,10 +2636,8 @@ in6_domifattach(struct ifnet *ifp) ext->scope6_id = scope6_ifattach(ifp); ext->lltable = lltable_init(ifp, AF_INET6); if (ext->lltable != NULL) { - ext->lltable->llt_new = in6_lltable_new; ext->lltable->llt_free = in6_lltable_free; ext->lltable->llt_prefix_free = in6_lltable_prefix_free; - ext->lltable->llt_rtcheck = in6_lltable_rtcheck; ext->lltable->llt_lookup = in6_lltable_lookup; ext->lltable->llt_dump = in6_lltable_dump; } From owner-svn-src-head@FreeBSD.ORG Fri Jul 8 10:35:29 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5D6981065676 for ; Fri, 8 Jul 2011 10:35:29 +0000 (UTC) (envelope-from andre@freebsd.org) Received: from c00l3r.networx.ch (c00l3r.networx.ch [62.48.2.2]) by mx1.freebsd.org (Postfix) with ESMTP id B030B8FC20 for ; Fri, 8 Jul 2011 10:35:28 +0000 (UTC) Received: (qmail 62430 invoked from network); 8 Jul 2011 09:08:06 -0000 Received: from localhost (HELO [127.0.0.1]) ([127.0.0.1]) (envelope-sender ) by c00l3r.networx.ch (qmail-ldap-1.03) with SMTP for ; 8 Jul 2011 09:08:06 -0000 Message-ID: <4E16D731.9060008@freebsd.org> Date: Fri, 08 Jul 2011 12:08:49 +0200 From: Andre Oppermann User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 MIME-Version: 1.0 To: Marko Zec References: <201107080938.p689cXTe002136@svn.freebsd.org> In-Reply-To: <201107080938.p689cXTe002136@svn.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r223862 - in head/sys: net netinet netinet6 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2011 10:35:29 -0000 On 08.07.2011 11:38, Marko Zec wrote: > Author: zec > Date: Fri Jul 8 09:38:33 2011 > New Revision: 223862 > URL: http://svn.freebsd.org/changeset/base/223862 > > Log: > Permit ARP to proceed for IPv4 host routes for which the gateway is the > same as the host address. This already works fine for INET6 and ND6. Can you give an example what this does? Is it some sort of proxy ARP? > While here, remove two function pointers from struct lltable which are > only initialized but never used. Ideally this would have been a separate commit because it has nothing to do with primary functional change. -- Andre > MFC after: 3 days > > Modified: > head/sys/net/if_llatbl.h > head/sys/netinet/in.c > head/sys/netinet6/in6.c From owner-svn-src-head@FreeBSD.ORG Fri Jul 8 10:50:14 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 29C06106564A; Fri, 8 Jul 2011 10:50:14 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 19BCB8FC0C; Fri, 8 Jul 2011 10:50:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p68AoDtI004338; Fri, 8 Jul 2011 10:50:13 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p68AoD9D004336; Fri, 8 Jul 2011 10:50:13 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201107081050.p68AoD9D004336@svn.freebsd.org> From: Andre Oppermann Date: Fri, 8 Jul 2011 10:50:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223863 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2011 10:50:14 -0000 Author: andre Date: Fri Jul 8 10:50:13 2011 New Revision: 223863 URL: http://svn.freebsd.org/changeset/base/223863 Log: In the experimental soreceive_stream(): o Move the non-blocking socket test below the SBS_CANTRCVMORE so that EOF is correctly returned on a remote connection close. o In the non-blocking socket test compare SS_NBIO against the so->so_state field instead of the incorrect sb->sb_state field. o Simplify the ENOTCONN test by removing cases that can't occur. Submitted by: trociny (with some further tweaks by committer) Tested by: trociny Modified: head/sys/kern/uipc_socket.c Modified: head/sys/kern/uipc_socket.c ============================================================================== --- head/sys/kern/uipc_socket.c Fri Jul 8 09:38:33 2011 (r223862) +++ head/sys/kern/uipc_socket.c Fri Jul 8 10:50:13 2011 (r223863) @@ -1954,20 +1954,9 @@ soreceive_stream(struct socket *so, stru } oresid = uio->uio_resid; - /* We will never ever get anything unless we are connected. */ + /* We will never ever get anything unless we are or were connected. */ if (!(so->so_state & (SS_ISCONNECTED|SS_ISDISCONNECTED))) { - /* When disconnecting there may be still some data left. */ - if (sb->sb_cc > 0) - goto deliver; - if (!(so->so_state & SS_ISDISCONNECTED)) - error = ENOTCONN; - goto out; - } - - /* Socket buffer is empty and we shall not block. */ - if (sb->sb_cc == 0 && - ((sb->sb_flags & SS_NBIO) || (flags & (MSG_DONTWAIT|MSG_NBIO)))) { - error = EAGAIN; + error = ENOTCONN; goto out; } @@ -1994,6 +1983,13 @@ restart: goto out; } + /* Socket buffer is empty and we shall not block. */ + if (sb->sb_cc == 0 && + ((so->so_state & SS_NBIO) || (flags & (MSG_DONTWAIT|MSG_NBIO)))) { + error = EAGAIN; + goto out; + } + /* Socket buffer got some data that we shall deliver now. */ if (sb->sb_cc > 0 && !(flags & MSG_WAITALL) && ((sb->sb_flags & SS_NBIO) || From owner-svn-src-head@FreeBSD.ORG Fri Jul 8 10:58:57 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 36FED106564A; Fri, 8 Jul 2011 10:58:57 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 245728FC0C; Fri, 8 Jul 2011 10:58:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p68Awv3m004616; Fri, 8 Jul 2011 10:58:57 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p68AwvHV004612; Fri, 8 Jul 2011 10:58:57 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201107081058.p68AwvHV004612@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 8 Jul 2011 10:58:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223864 - in head/sys: conf dev/usb dev/usb/net modules/usb modules/usb/usie X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2011 10:58:57 -0000 Author: hselasky Date: Fri Jul 8 10:58:56 2011 New Revision: 223864 URL: http://svn.freebsd.org/changeset/base/223864 Log: Add new USB 3G driver. Submitted by: PseudoCylon MFC after: 14 days Added: head/sys/dev/usb/net/if_usie.c (contents, props changed) head/sys/dev/usb/net/if_usievar.h (contents, props changed) head/sys/modules/usb/usie/ head/sys/modules/usb/usie/Makefile (contents, props changed) Modified: head/sys/conf/files head/sys/dev/usb/usbdevs head/sys/modules/usb/Makefile Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Fri Jul 8 10:50:13 2011 (r223863) +++ head/sys/conf/files Fri Jul 8 10:58:56 2011 (r223864) @@ -1918,6 +1918,7 @@ dev/usb/net/if_kue.c optional kue dev/usb/net/if_mos.c optional mos dev/usb/net/if_rue.c optional rue dev/usb/net/if_udav.c optional udav +dev/usb/net/if_usie.c optional usie dev/usb/net/usb_ethernet.c optional aue | axe | cdce | cue | kue | mos | \ rue | udav dev/usb/net/uhso.c optional uhso @@ -1970,8 +1971,8 @@ dev/usb/serial/uvscom.c optional uvscom dev/usb/serial/usb_serial.c optional ucom | u3g | uark | ubsa | ubser | \ uchcom | ucycom | ufoma | uftdi | \ ugensa | uipaq | umcs | umct | \ - umodem | umoscom | uplcom | uslcom | \ - uvisor | uvscom + umodem | umoscom | uplcom | usie | \ + uslcom | uvisor | uvscom # # USB misc drivers # Added: head/sys/dev/usb/net/if_usie.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/usb/net/if_usie.c Fri Jul 8 10:58:56 2011 (r223864) @@ -0,0 +1,1587 @@ +/*- + * Copyright (c) 2011 Anybots Inc + * written by Akinori Furukoshi + * reviewed by Hans Petter Selasky + * - ucom part is based on u3g.c + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include "usbdevs.h" + +#define USB_DEBUG_VAR usie_debug +#include +#include +#include + +#include + +#include + +#ifdef USB_DEBUG +static int usie_debug = 0; + +SYSCTL_NODE(_hw_usb, OID_AUTO, usie, CTLFLAG_RW, 0, "sierra USB modem"); +SYSCTL_INT(_hw_usb_usie, OID_AUTO, debug, CTLFLAG_RW, &usie_debug, 0, + "usie debug level"); +#endif + +/* Sierra Wireless Direct IP modems */ +static const STRUCT_USB_HOST_ID usie_devs[] = { +#define USIE_DEV(v, d) { \ + USB_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##d) } + USIE_DEV(SIERRA, MC8700), + USIE_DEV(SIERRA, TRUINSTALL), + USIE_DEV(AIRPRIME, USB308), +#undef USIE_DEV +}; + +static device_probe_t usie_probe; +static device_attach_t usie_attach; +static device_detach_t usie_detach; + +static void usie_uc_update_line_state(struct ucom_softc *, uint8_t); +static void usie_uc_cfg_get_status(struct ucom_softc *, uint8_t *, uint8_t *); +static void usie_uc_cfg_set_dtr(struct ucom_softc *, uint8_t); +static void usie_uc_cfg_set_rts(struct ucom_softc *, uint8_t); +static void usie_uc_cfg_open(struct ucom_softc *); +static void usie_uc_cfg_close(struct ucom_softc *); +static void usie_uc_start_read(struct ucom_softc *); +static void usie_uc_stop_read(struct ucom_softc *); +static void usie_uc_start_write(struct ucom_softc *); +static void usie_uc_stop_write(struct ucom_softc *); + +static usb_callback_t usie_uc_tx_callback; +static usb_callback_t usie_uc_rx_callback; +static usb_callback_t usie_uc_status_callback; +static usb_callback_t usie_if_tx_callback; +static usb_callback_t usie_if_rx_callback; +static usb_callback_t usie_if_status_callback; + +static void usie_if_sync_to(void *); +static void usie_if_sync_cb(void *, int); +static void usie_if_status_cb(void *, int); + +static void usie_if_start(struct ifnet *); +static int usie_if_output(struct ifnet *, struct mbuf *, struct sockaddr *, struct route *); +static void usie_if_init(void *); +static void usie_if_stop(struct usie_softc *); +static int usie_if_ioctl(struct ifnet *, u_long, caddr_t); + +static int usie_do_request(struct usie_softc *, struct usb_device_request *, void *); +static int usie_if_cmd(struct usie_softc *, uint8_t); +static void usie_cns_req(struct usie_softc *, uint32_t, uint16_t); +static void usie_cns_rsp(struct usie_softc *, struct usie_cns *); +static void usie_hip_rsp(struct usie_softc *, uint8_t *, uint32_t); +static int usie_driver_loaded(struct module *, int, void *); + +static const struct usb_config usie_uc_config[USIE_UC_N_XFER] = { + [USIE_UC_STATUS] = { + .type = UE_INTERRUPT, + .endpoint = UE_ADDR_ANY, + .direction = UE_DIR_IN, + .bufsize = 0, /* use wMaxPacketSize */ + .flags = {.pipe_bof = 1,.short_xfer_ok = 1,}, + .callback = &usie_uc_status_callback, + }, + [USIE_UC_RX] = { + .type = UE_BULK, + .endpoint = UE_ADDR_ANY, + .direction = UE_DIR_IN, + .bufsize = USIE_BUFSIZE, + .flags = {.pipe_bof = 1,.short_xfer_ok = 1,.proxy_buffer = 1,}, + .callback = &usie_uc_rx_callback, + }, + [USIE_UC_TX] = { + .type = UE_BULK, + .endpoint = UE_ADDR_ANY, + .direction = UE_DIR_OUT, + .bufsize = USIE_BUFSIZE, + .flags = {.pipe_bof = 1,.force_short_xfer = 1,}, + .callback = &usie_uc_tx_callback, + } +}; + +static const struct usb_config usie_if_config[USIE_IF_N_XFER] = { + [USIE_IF_STATUS] = { + .type = UE_INTERRUPT, + .endpoint = UE_ADDR_ANY, + .direction = UE_DIR_IN, + .bufsize = 0, /* use wMaxPacketSize */ + .flags = {.pipe_bof = 1,.short_xfer_ok = 1,}, + .callback = &usie_if_status_callback, + }, + [USIE_IF_RX] = { + .type = UE_BULK, + .endpoint = UE_ADDR_ANY, + .direction = UE_DIR_IN, + .bufsize = USIE_BUFSIZE, + .flags = {.pipe_bof = 1,.short_xfer_ok = 1,}, + .callback = &usie_if_rx_callback, + }, + [USIE_IF_TX] = { + .type = UE_BULK, + .endpoint = UE_ADDR_ANY, + .direction = UE_DIR_OUT, + .bufsize = MAX(USIE_BUFSIZE, MCLBYTES), + .flags = {.pipe_bof = 1,.force_short_xfer = 1,}, + .callback = &usie_if_tx_callback, + } +}; + +static device_method_t usie_methods[] = { + DEVMETHOD(device_probe, usie_probe), + DEVMETHOD(device_attach, usie_attach), + DEVMETHOD(device_detach, usie_detach), + {0, 0} +}; + +static driver_t usie_driver = { + .name = "usie", + .methods = usie_methods, + .size = sizeof(struct usie_softc), +}; + +static devclass_t usie_devclass; +static eventhandler_tag usie_etag; + +DRIVER_MODULE(usie, uhub, usie_driver, usie_devclass, usie_driver_loaded, 0); +MODULE_DEPEND(usie, ucom, 1, 1, 1); +MODULE_DEPEND(usie, usb, 1, 1, 1); +MODULE_VERSION(usie, 1); + +static const struct ucom_callback usie_uc_callback = { + .ucom_cfg_get_status = &usie_uc_cfg_get_status, + .ucom_cfg_set_dtr = &usie_uc_cfg_set_dtr, + .ucom_cfg_set_rts = &usie_uc_cfg_set_rts, + .ucom_cfg_open = &usie_uc_cfg_open, + .ucom_cfg_close = &usie_uc_cfg_close, + .ucom_start_read = &usie_uc_start_read, + .ucom_stop_read = &usie_uc_stop_read, + .ucom_start_write = &usie_uc_start_write, + .ucom_stop_write = &usie_uc_stop_write, +}; + +static void +usie_autoinst(void *arg, struct usb_device *udev, + struct usb_attach_arg *uaa) +{ + struct usb_interface *iface; + struct usb_interface_descriptor *id; + struct usb_device_request req; + int err; + + if (uaa->dev_state != UAA_DEV_READY) + return; + + iface = usbd_get_iface(udev, 0); + if (iface == NULL) + return; + + id = iface->idesc; + if (id == NULL || id->bInterfaceClass != UICLASS_MASS) + return; + + if (usbd_lookup_id_by_uaa(usie_devs, sizeof(usie_devs), uaa) != 0) + return; /* no device match */ + + if (bootverbose) { + DPRINTF("Ejecting %s %s\n", + usb_get_manufacturer(udev), + usb_get_product(udev)); + } + req.bmRequestType = UT_VENDOR; + req.bRequest = UR_SET_INTERFACE; + USETW(req.wValue, UF_DEVICE_REMOTE_WAKEUP); + USETW(req.wIndex, UHF_PORT_CONNECTION); + USETW(req.wLength, 0); + + /* at this moment there is no mutex */ + err = usbd_do_request_flags(udev, NULL, &req, + NULL, 0, NULL, 250 /* ms */ ); + + /* success, mark the udev as disappearing */ + if (err == 0) + uaa->dev_state = UAA_DEV_EJECTING; +} + +static int +usie_probe(device_t self) +{ + struct usb_attach_arg *uaa = device_get_ivars(self); + + if (uaa->usb_mode != USB_MODE_HOST) + return (ENXIO); + if (uaa->info.bConfigIndex != USIE_CNFG_INDEX) + return (ENXIO); + if (uaa->info.bIfaceIndex != USIE_IFACE_INDEX) + return (ENXIO); + if (uaa->info.bInterfaceClass != UICLASS_VENDOR) + return (ENXIO); + + return (usbd_lookup_id_by_uaa(usie_devs, sizeof(usie_devs), uaa)); +} + +static int +usie_attach(device_t self) +{ + struct usie_softc *sc = device_get_softc(self); + struct usb_attach_arg *uaa = device_get_ivars(self); + struct ifnet *ifp; + struct usb_interface *iface; + struct usb_interface_descriptor *id; + struct usb_device_request req; + int err; + uint16_t fwattr; + uint8_t iface_index; + uint8_t ifidx; + uint8_t start; + + device_set_usb_desc(self); + sc->sc_udev = uaa->device; + sc->sc_dev = self; + + mtx_init(&sc->sc_mtx, "usie", MTX_NETWORK_LOCK, MTX_DEF); + + TASK_INIT(&sc->sc_if_status_task, 0, usie_if_status_cb, sc); + TASK_INIT(&sc->sc_if_sync_task, 0, usie_if_sync_cb, sc); + + usb_callout_init_mtx(&sc->sc_if_sync_ch, &sc->sc_mtx, 0); + + mtx_lock(&sc->sc_mtx); + + /* set power mode to D0 */ + req.bmRequestType = UT_WRITE_VENDOR_DEVICE; + req.bRequest = USIE_POWER; + USETW(req.wValue, 0); + USETW(req.wIndex, 0); + USETW(req.wLength, 0); + if (usie_do_request(sc, &req, NULL)) { + mtx_unlock(&sc->sc_mtx); + goto detach; + } + /* read fw attr */ + fwattr = 0; + req.bmRequestType = UT_READ_VENDOR_DEVICE; + req.bRequest = USIE_FW_ATTR; + USETW(req.wValue, 0); + USETW(req.wIndex, 0); + USETW(req.wLength, sizeof(fwattr)); + if (usie_do_request(sc, &req, &fwattr)) { + mtx_unlock(&sc->sc_mtx); + goto detach; + } + mtx_unlock(&sc->sc_mtx); + + /* check DHCP supports */ + DPRINTF("fwattr=%x\n", fwattr); + if (!(fwattr & USIE_FW_DHCP)) { + device_printf(self, "DHCP is not supported. A firmware upgrade might be needed.\n"); + } + + /* find available interfaces */ + sc->sc_nucom = 0; + for (ifidx = 0; ifidx < USIE_IFACE_MAX; ifidx++) { + iface = usbd_get_iface(uaa->device, ifidx); + if (iface == NULL) + break; + + id = usbd_get_interface_descriptor(iface); + if ((id == NULL) || (id->bInterfaceClass != UICLASS_VENDOR)) + continue; + + /* setup Direct IP transfer */ + if (id->bInterfaceNumber >= 7 && id->bNumEndpoints == 3) { + sc->sc_if_ifnum = id->bInterfaceNumber; + iface_index = ifidx; + + DPRINTF("ifnum=%d, ifidx=%d\n", + sc->sc_if_ifnum, ifidx); + + err = usbd_transfer_setup(uaa->device, + &iface_index, sc->sc_if_xfer, usie_if_config, + USIE_IF_N_XFER, sc, &sc->sc_mtx); + + if (err == 0) + continue; + + device_printf(self, + "could not allocate USB transfers on " + "iface_index=%d, err=%s\n", + iface_index, usbd_errstr(err)); + goto detach; + } + + /* setup ucom */ + if (sc->sc_nucom >= USIE_UCOM_MAX) + continue; + + usbd_set_parent_iface(uaa->device, ifidx, + uaa->info.bIfaceIndex); + + DPRINTF("NumEndpoints=%d bInterfaceNumber=%d\n", + id->bNumEndpoints, id->bInterfaceNumber); + + if (id->bNumEndpoints == 2) { + sc->sc_uc_xfer[sc->sc_nucom][0] = NULL; + start = 1; + } else + start = 0; + + err = usbd_transfer_setup(uaa->device, &ifidx, + sc->sc_uc_xfer[sc->sc_nucom] + start, + usie_uc_config + start, USIE_UC_N_XFER - start, + &sc->sc_ucom[sc->sc_nucom], &sc->sc_mtx); + + if (err != 0) { + DPRINTF("usbd_transfer_setup error=%s\n", usbd_errstr(err)); + continue; + } + + mtx_lock(&sc->sc_mtx); + for (; start < USIE_UC_N_XFER; start++) + usbd_xfer_set_stall(sc->sc_uc_xfer[sc->sc_nucom][start]); + mtx_unlock(&sc->sc_mtx); + + sc->sc_uc_ifnum[sc->sc_nucom] = id->bInterfaceNumber; + + sc->sc_nucom++; /* found a port */ + } + + if (sc->sc_nucom == 0) { + device_printf(self, "no comports found\n"); + goto detach; + } + + err = ucom_attach(&sc->sc_super_ucom, sc->sc_ucom, + sc->sc_nucom, sc, &usie_uc_callback, &sc->sc_mtx); + + if (err != 0) { + DPRINTF("ucom_attach failed\n"); + goto detach; + } + DPRINTF("Found %d interfaces.\n", sc->sc_nucom); + + /* setup ifnet (Direct IP) */ + sc->sc_ifp = ifp = if_alloc(IFT_OTHER); + + if (ifp == NULL) { + device_printf(self, "Could not allocate a network interface\n"); + goto detach; + } + if_initname(ifp, "usie", device_get_unit(self)); + + ifp->if_softc = sc; + ifp->if_mtu = USIE_MTU_MAX; + ifp->if_flags |= IFF_NOARP; + ifp->if_init = usie_if_init; + ifp->if_ioctl = usie_if_ioctl; + ifp->if_start = usie_if_start; + ifp->if_output = usie_if_output; + IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); + ifp->if_snd.ifq_drv_maxlen = ifqmaxlen; + IFQ_SET_READY(&ifp->if_snd); + + if_attach(ifp); + bpfattach(ifp, DLT_RAW, 0); + + if (fwattr & USIE_PM_AUTO) { + usbd_set_power_mode(uaa->device, USB_POWER_MODE_SAVE); + DPRINTF("enabling automatic suspend and resume\n"); + } else { + usbd_set_power_mode(uaa->device, USB_POWER_MODE_ON); + DPRINTF("USB power is always ON\n"); + } + + DPRINTF("device attached\n"); + return (0); + +detach: + usie_detach(self); + return (ENOMEM); +} + +static int +usie_detach(device_t self) +{ + struct usie_softc *sc = device_get_softc(self); + uint8_t x; + + /* detach ifnet */ + if (sc->sc_ifp != NULL) { + usie_if_stop(sc); + usbd_transfer_unsetup(sc->sc_if_xfer, USIE_IF_N_XFER); + bpfdetach(sc->sc_ifp); + if_detach(sc->sc_ifp); + if_free(sc->sc_ifp); + sc->sc_ifp = NULL; + } + /* detach ucom */ + if (sc->sc_nucom > 0) + ucom_detach(&sc->sc_super_ucom, sc->sc_ucom); + + /* stop all USB transfers */ + usbd_transfer_unsetup(sc->sc_if_xfer, USIE_IF_N_XFER); + + for (x = 0; x != USIE_UCOM_MAX; x++) + usbd_transfer_unsetup(sc->sc_uc_xfer[x], USIE_UC_N_XFER); + + mtx_destroy(&sc->sc_mtx); + + return (0); +} + +static void +usie_uc_update_line_state(struct ucom_softc *ucom, uint8_t ls) +{ + struct usie_softc *sc = ucom->sc_parent; + struct usb_device_request req; + + if (sc->sc_uc_xfer[ucom->sc_subunit][USIE_UC_STATUS] == NULL) + return; + + req.bmRequestType = UT_WRITE_CLASS_INTERFACE; + req.bRequest = USIE_LINK_STATE; + USETW(req.wValue, ls); + USETW(req.wIndex, sc->sc_uc_ifnum[ucom->sc_subunit]); + USETW(req.wLength, 0); + + DPRINTF("sc_uc_ifnum=%d\n", sc->sc_uc_ifnum[ucom->sc_subunit]); + + usie_do_request(sc, &req, NULL); +} + +static void +usie_uc_cfg_get_status(struct ucom_softc *ucom, uint8_t *lsr, uint8_t *msr) +{ + struct usie_softc *sc = ucom->sc_parent; + + *msr = sc->sc_msr; + *lsr = sc->sc_lsr; +} + +static void +usie_uc_cfg_set_dtr(struct ucom_softc *ucom, uint8_t flag) +{ + uint8_t dtr; + + dtr = flag ? USIE_LS_DTR : 0; + usie_uc_update_line_state(ucom, dtr); +} + +static void +usie_uc_cfg_set_rts(struct ucom_softc *ucom, uint8_t flag) +{ + uint8_t rts; + + rts = flag ? USIE_LS_RTS : 0; + usie_uc_update_line_state(ucom, rts); +} + +static void +usie_uc_cfg_open(struct ucom_softc *ucom) +{ + struct usie_softc *sc = ucom->sc_parent; + + /* usbd_transfer_start() is NULL safe */ + + usbd_transfer_start(sc->sc_uc_xfer[ucom->sc_subunit][USIE_UC_STATUS]); +} + +static void +usie_uc_cfg_close(struct ucom_softc *ucom) +{ + struct usie_softc *sc = ucom->sc_parent; + + usbd_transfer_stop(sc->sc_uc_xfer[ucom->sc_subunit][USIE_UC_STATUS]); +} + +static void +usie_uc_start_read(struct ucom_softc *ucom) +{ + struct usie_softc *sc = ucom->sc_parent; + + usbd_transfer_start(sc->sc_uc_xfer[ucom->sc_subunit][USIE_UC_RX]); +} + +static void +usie_uc_stop_read(struct ucom_softc *ucom) +{ + struct usie_softc *sc = ucom->sc_parent; + + usbd_transfer_stop(sc->sc_uc_xfer[ucom->sc_subunit][USIE_UC_RX]); +} + +static void +usie_uc_start_write(struct ucom_softc *ucom) +{ + struct usie_softc *sc = ucom->sc_parent; + + usbd_transfer_start(sc->sc_uc_xfer[ucom->sc_subunit][USIE_UC_TX]); +} + +static void +usie_uc_stop_write(struct ucom_softc *ucom) +{ + struct usie_softc *sc = ucom->sc_parent; + + usbd_transfer_stop(sc->sc_uc_xfer[ucom->sc_subunit][USIE_UC_TX]); +} + +static void +usie_uc_rx_callback(struct usb_xfer *xfer, usb_error_t error) +{ + struct ucom_softc *ucom = usbd_xfer_softc(xfer); + struct usie_softc *sc = ucom->sc_parent; + struct usb_page_cache *pc; + uint32_t actlen; + + usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL); + + switch (USB_GET_STATE(xfer)) { + case USB_ST_TRANSFERRED: + pc = usbd_xfer_get_frame(xfer, 0); + + /* handle CnS response */ + if (ucom == sc->sc_ucom && actlen >= USIE_HIPCNS_MIN) { + + DPRINTF("transferred=%u\n", actlen); + + /* check if it is really CnS reply */ + usbd_copy_out(pc, 0, sc->sc_resp_temp, 1); + + if (sc->sc_resp_temp[0] == USIE_HIP_FRM_CHR) { + + /* verify actlen */ + if (actlen > USIE_BUFSIZE) + actlen = USIE_BUFSIZE; + + /* get complete message */ + usbd_copy_out(pc, 0, sc->sc_resp_temp, actlen); + usie_hip_rsp(sc, sc->sc_resp_temp, actlen); + + /* need to fall though */ + goto tr_setup; + } + /* else call ucom_put_data() */ + } + /* standard ucom transfer */ + ucom_put_data(ucom, pc, 0, actlen); + + /* fall though */ + case USB_ST_SETUP: +tr_setup: + usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer)); + usbd_transfer_submit(xfer); + break; + + default: /* Error */ + if (error != USB_ERR_CANCELLED) { + usbd_xfer_set_stall(xfer); + goto tr_setup; + } + break; + } +} + +static void +usie_uc_tx_callback(struct usb_xfer *xfer, usb_error_t error) +{ + struct ucom_softc *ucom = usbd_xfer_softc(xfer); + struct usb_page_cache *pc; + uint32_t actlen; + + switch (USB_GET_STATE(xfer)) { + case USB_ST_TRANSFERRED: + case USB_ST_SETUP: +tr_setup: + pc = usbd_xfer_get_frame(xfer, 0); + + /* handle CnS request */ + struct mbuf *m = usbd_xfer_get_priv(xfer); + + if (m != NULL) { + usbd_m_copy_in(pc, 0, m, 0, m->m_pkthdr.len); + usbd_xfer_set_frame_len(xfer, 0, m->m_pkthdr.len); + usbd_xfer_set_priv(xfer, NULL); + usbd_transfer_submit(xfer); + m_freem(m); + break; + } + /* standard ucom transfer */ + if (ucom_get_data(ucom, pc, 0, USIE_BUFSIZE, &actlen)) { + usbd_xfer_set_frame_len(xfer, 0, actlen); + usbd_transfer_submit(xfer); + } + break; + + default: /* Error */ + if (error != USB_ERR_CANCELLED) { + usbd_xfer_set_stall(xfer); + goto tr_setup; + } + break; + } +} + +static void +usie_uc_status_callback(struct usb_xfer *xfer, usb_error_t error) +{ + struct usb_page_cache *pc; + struct { + struct usb_device_request req; + uint16_t param; + } st; + uint32_t actlen; + uint16_t param; + + usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL); + + switch (USB_GET_STATE(xfer)) { + case USB_ST_TRANSFERRED: + DPRINTFN(4, "info received, actlen=%u\n", actlen); + + if (actlen < sizeof(st)) { + DPRINTF("data too short actlen=%u\n", actlen); + goto tr_setup; + } + pc = usbd_xfer_get_frame(xfer, 0); + usbd_copy_out(pc, 0, &st, sizeof(st)); + + if (st.req.bmRequestType == 0xa1 && st.req.bRequest == 0x20) { + struct ucom_softc *ucom = usbd_xfer_softc(xfer); + struct usie_softc *sc = ucom->sc_parent; + + param = le16toh(st.param); + DPRINTF("param=%x\n", param); + sc->sc_msr = sc->sc_lsr = 0; + sc->sc_msr |= (param & USIE_DCD) ? SER_DCD : 0; + sc->sc_msr |= (param & USIE_DSR) ? SER_DSR : 0; + sc->sc_msr |= (param & USIE_RI) ? SER_RI : 0; + sc->sc_msr |= (param & USIE_CTS) ? 0 : SER_CTS; + sc->sc_msr |= (param & USIE_RTS) ? SER_RTS : 0; + sc->sc_msr |= (param & USIE_DTR) ? SER_DTR : 0; + } + /* fall though */ + case USB_ST_SETUP: +tr_setup: + usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer)); + usbd_transfer_submit(xfer); + break; + + default: /* Error */ + DPRINTF("USB transfer error, %s\n", + usbd_errstr(error)); + + if (error != USB_ERR_CANCELLED) { + usbd_xfer_set_stall(xfer); + goto tr_setup; + } + break; + } +} + +static void +usie_if_rx_callback(struct usb_xfer *xfer, usb_error_t error) +{ + struct usie_softc *sc = usbd_xfer_softc(xfer); + struct ifnet *ifp = sc->sc_ifp; + struct mbuf *m0; + struct mbuf *m = NULL; + struct usie_desc *rxd; + uint32_t actlen; + uint16_t err; + uint16_t pkt; + uint16_t ipl; + uint16_t len; + uint16_t diff; + uint8_t pad; + uint8_t ipv; + + usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL); + + switch (USB_GET_STATE(xfer)) { + case USB_ST_TRANSFERRED: + DPRINTFN(15, "rx done, actlen=%u\n", actlen); + + if (actlen < sizeof(struct usie_hip)) { + DPRINTF("data too short %u\n", actlen); + goto tr_setup; + } + m = sc->sc_rxm; + sc->sc_rxm = NULL; + + /* fall though */ + case USB_ST_SETUP: +tr_setup: + + if (sc->sc_rxm == NULL) { + sc->sc_rxm = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, + MJUMPAGESIZE /* could be bigger than MCLBYTES */ ); + } + if (sc->sc_rxm == NULL) { + DPRINTF("could not allocate Rx mbuf\n"); + ifp->if_ierrors++; + usbd_xfer_set_stall(xfer); + usbd_xfer_set_frames(xfer, 0); + } else { + /* + * Directly loading a mbuf cluster into DMA to + * save some data copying. This works because + * there is only one cluster. + */ + usbd_xfer_set_frame_data(xfer, 0, + mtod(sc->sc_rxm, caddr_t), MIN(MJUMPAGESIZE, USIE_RXSZ_MAX)); + usbd_xfer_set_frames(xfer, 1); + } + usbd_transfer_submit(xfer); + break; + + default: /* Error */ + DPRINTF("USB transfer error, %s\n", usbd_errstr(error)); + + if (error != USB_ERR_CANCELLED) { + /* try to clear stall first */ + usbd_xfer_set_stall(xfer); + ifp->if_ierrors++; + goto tr_setup; + } + if (sc->sc_rxm != NULL) { + m_freem(sc->sc_rxm); + sc->sc_rxm = NULL; + } + break; + } + + if (m == NULL) + return; + + mtx_unlock(&sc->sc_mtx); + + m->m_pkthdr.len = m->m_len = actlen; + + err = pkt = 0; + + /* HW can aggregate multiple frames in a single USB xfer */ + for (;;) { + rxd = mtod(m, struct usie_desc *); + + len = be16toh(rxd->hip.len) & USIE_HIP_IP_LEN_MASK; + pad = (rxd->hip.id & USIE_HIP_PAD) ? 1 : 0; + ipl = (len - pad - ETHER_HDR_LEN); + if (ipl >= len) { + DPRINTF("Corrupt frame\n"); + m_freem(m); + break; + } + diff = sizeof(struct usie_desc) + ipl + pad; + + if (((rxd->hip.id & USIE_HIP_MASK) != USIE_HIP_IP) || + (be16toh(rxd->desc_type) & USIE_TYPE_MASK) != USIE_IP_RX) { + DPRINTF("received wrong type of packet\n"); + m->m_data += diff; + m->m_pkthdr.len = (m->m_len -= diff); + err++; + if (m->m_pkthdr.len > 0) + continue; + m_freem(m); + break; + } + switch (be16toh(rxd->ethhdr.ether_type)) { + case ETHERTYPE_IP: + ipv = NETISR_IP; + break; +#ifdef INET6 + case ETHERTYPE_IPV6: + ipv = NETISR_IPV6; + break; +#endif + default: + DPRINTF("unsupported ether type\n"); + err++; + break; + } + + /* the last packet */ + if (m->m_pkthdr.len <= diff) { + m->m_data += (sizeof(struct usie_desc) + pad); + m->m_pkthdr.len = m->m_len = ipl; + m->m_pkthdr.rcvif = ifp; + BPF_MTAP(sc->sc_ifp, m); + netisr_dispatch(ipv, m); + break; + } + /* copy aggregated frames to another mbuf */ + m0 = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + if (__predict_false(m0 == NULL)) { + DPRINTF("could not allocate mbuf\n"); + err++; + m_freem(m); + break; + } + m_copydata(m, sizeof(struct usie_desc) + pad, ipl, mtod(m0, caddr_t)); + m0->m_pkthdr.rcvif = ifp; + m0->m_pkthdr.len = m0->m_len = ipl; + + BPF_MTAP(sc->sc_ifp, m0); + netisr_dispatch(ipv, m0); + + m->m_data += diff; + m->m_pkthdr.len = (m->m_len -= diff); + } + + mtx_lock(&sc->sc_mtx); + + ifp->if_ierrors += err; + ifp->if_ipackets += pkt; +} + +static void +usie_if_tx_callback(struct usb_xfer *xfer, usb_error_t error) +{ + struct usie_softc *sc = usbd_xfer_softc(xfer); + struct usb_page_cache *pc; + struct ifnet *ifp = sc->sc_ifp; + struct mbuf *m; + uint16_t size; + + switch (USB_GET_STATE(xfer)) { + case USB_ST_TRANSFERRED: + DPRINTFN(11, "transfer complete\n"); + ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + ifp->if_opackets++; + + /* fall though */ + case USB_ST_SETUP: +tr_setup: + + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + break; + + IFQ_DRV_DEQUEUE(&ifp->if_snd, m); + if (m == NULL) + break; + + if (m->m_pkthdr.len > (MCLBYTES - ETHER_HDR_LEN + + ETHER_CRC_LEN - sizeof(sc->sc_txd))) { + DPRINTF("packet len is too big: %d\n", + m->m_pkthdr.len); + break; + } + pc = usbd_xfer_get_frame(xfer, 0); + + sc->sc_txd.hip.len = htobe16(m->m_pkthdr.len + + ETHER_HDR_LEN + ETHER_CRC_LEN); + size = sizeof(sc->sc_txd); + + usbd_copy_in(pc, 0, &sc->sc_txd, size); + usbd_m_copy_in(pc, size, m, 0, m->m_pkthdr.len); + usbd_xfer_set_frame_len(xfer, 0, m->m_pkthdr.len + + size + ETHER_CRC_LEN); + + BPF_MTAP(ifp, m); + + m_freem(m); + + usbd_transfer_submit(xfer); + break; + + default: /* Error */ + DPRINTF("USB transfer error, %s\n", + usbd_errstr(error)); + ifp->if_oerrors++; + + if (error != USB_ERR_CANCELLED) { + usbd_xfer_set_stall(xfer); + ifp->if_ierrors++; + goto tr_setup; + } + break; + } +} + +static void +usie_if_status_callback(struct usb_xfer *xfer, usb_error_t error) +{ + struct usie_softc *sc = usbd_xfer_softc(xfer); + struct usb_page_cache *pc; + struct usb_cdc_notification cdc; + uint32_t actlen; + + usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL); + + switch (USB_GET_STATE(xfer)) { + case USB_ST_TRANSFERRED: + DPRINTFN(4, "info received, actlen=%d\n", actlen); + + /* usb_cdc_notification - .data[16] */ + if (actlen < (sizeof(cdc) - 16)) { + DPRINTF("data too short %d\n", actlen); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Fri Jul 8 11:51:04 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D0E141065673; Fri, 8 Jul 2011 11:51:04 +0000 (UTC) (envelope-from zec@freebsd.org) Received: from munja.zvne.fer.hr (munja.zvne.fer.hr [161.53.66.248]) by mx1.freebsd.org (Postfix) with ESMTP id 6459D8FC19; Fri, 8 Jul 2011 11:51:04 +0000 (UTC) Received: from sluga.fer.hr ([161.53.66.244]) by munja.zvne.fer.hr with Microsoft SMTPSVC(6.0.3790.4675); Fri, 8 Jul 2011 13:38:58 +0200 Received: from localhost ([161.53.19.8]) by sluga.fer.hr with Microsoft SMTPSVC(6.0.3790.4675); Fri, 8 Jul 2011 13:38:57 +0200 From: Marko Zec To: Andre Oppermann Date: Fri, 8 Jul 2011 13:38:52 +0200 User-Agent: KMail/1.9.10 References: <201107080938.p689cXTe002136@svn.freebsd.org> <4E16D731.9060008@freebsd.org> In-Reply-To: <4E16D731.9060008@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <201107081338.52323.zec@freebsd.org> X-OriginalArrivalTime: 08 Jul 2011 11:38:57.0804 (UTC) FILETIME=[9FBECCC0:01CC3D63] Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r223862 - in head/sys: net netinet netinet6 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2011 11:51:05 -0000 On Friday 08 July 2011 12:08:49 Andre Oppermann wrote: > On 08.07.2011 11:38, Marko Zec wrote: > > Author: zec > > Date: Fri Jul 8 09:38:33 2011 > > New Revision: 223862 > > URL: http://svn.freebsd.org/changeset/base/223862 > > > > Log: > > Permit ARP to proceed for IPv4 host routes for which the gateway is > > the same as the host address. This already works fine for INET6 and ND6. > > Can you give an example what this does? Is it some sort of proxy ARP? It is a bugfix. Consider this example on a pre-223862 kernel: cp12# ifconfig re0 10.0.0.2/24 cp12# ping -c 1 10.0.0.1 PING 10.0.0.1 (10.0.0.1): 56 data bytes 64 bytes from 10.0.0.1: icmp_seq=0 ttl=64 time=0.335 ms --- 10.0.0.1 ping statistics --- 1 packets transmitted, 1 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 0.285/0.285/0.285/0.000 ms So far, so good, but: cp12# arp -da 10.0.0.2 (10.0.0.2) deleted 10.0.0.1 (10.0.0.1) deleted cp12# route add 10.0.0.1 10.0.0.1 add host 10.0.0.1: gateway 10.0.0.1 cp12# netstat -rnf inet Destination Gateway Flags Refs Use Netif Expire 10.0.0.0/24 link#1 U 0 1 re0 10.0.0.1 10.0.0.1 UGHS 0 0 re0 10.0.0.2 link#1 UHS 0 0 lo0 127.0.0.1 link#11 UH 0 5 lo0 cp12# ping 10.0.0.1 PING 10.0.0.1 (10.0.0.1): 56 data bytes ping: sendto: Invalid argument ping: sendto: Invalid argument ^C --- 10.0.0.1 ping statistics --- 2 packets transmitted, 0 packets received, 100.0% packet loss cp12# dmesg | tail -2 arpresolve: can't allocate llinfo for 10.0.0.1 arpresolve: can't allocate llinfo for 10.0.0.1 With 223862 this scenario is no longer a problem: cp12# ifconfig re0 10.0.0.2/24 cp12# route add 10.0.0.1 10.0.0.1 add host 10.0.0.1: gateway 10.0.0.1 cp12# netstat -rnf inet Destination Gateway Flags Refs Use Netif Expire 10.0.0.0/24 link#1 U 0 0 re0 10.0.0.1 10.0.0.1 UGHS 0 0 re0 10.0.0.2 link#1 UHS 0 0 lo0 127.0.0.1 link#11 UH 0 4 lo0 cp12# ping 10.0.0.1 PING 10.0.0.1 (10.0.0.1): 56 data bytes 64 bytes from 10.0.0.1: icmp_seq=0 ttl=64 time=0.578 ms <-- ARP pingpong here 64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.134 ms ^C --- 10.0.0.1 ping statistics --- 2 packets transmitted, 2 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 0.134/0.356/0.578/0.222 ms > > While here, remove two function pointers from struct lltable which are > > only initialized but never used. > > Ideally this would have been a separate commit because it has nothing to > do with primary functional change. You're right, sorry for the noise... Marko From owner-svn-src-head@FreeBSD.ORG Fri Jul 8 12:16:31 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 598AF106564A; Fri, 8 Jul 2011 12:16:31 +0000 (UTC) (envelope-from jonathan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4970C8FC13; Fri, 8 Jul 2011 12:16:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p68CGVmY017245; Fri, 8 Jul 2011 12:16:31 GMT (envelope-from jonathan@svn.freebsd.org) Received: (from jonathan@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p68CGVtZ017242; Fri, 8 Jul 2011 12:16:31 GMT (envelope-from jonathan@svn.freebsd.org) Message-Id: <201107081216.p68CGVtZ017242@svn.freebsd.org> From: Jonathan Anderson Date: Fri, 8 Jul 2011 12:16:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223865 - head/tools/regression/kqueue X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2011 12:16:31 -0000 Author: jonathan Date: Fri Jul 8 12:16:30 2011 New Revision: 223865 URL: http://svn.freebsd.org/changeset/base/223865 Log: Clarify the meaning of a test. Rather than using err() if either of two failure conditions fires (which can produce spurious error messages), just use errx() if the one condition that really matters fires. In practice, this single test is enough to detect the failure mode we're looking for (kqueue being inherited across fork). Approved by: mentor (rwatson), re (Capsicum blanket) Sponsored by: Google Inc Modified: head/tools/regression/kqueue/config.h head/tools/regression/kqueue/proc.c Modified: head/tools/regression/kqueue/config.h ============================================================================== --- head/tools/regression/kqueue/config.h Fri Jul 8 10:58:56 2011 (r223864) +++ head/tools/regression/kqueue/config.h Fri Jul 8 12:16:30 2011 (r223865) @@ -1,4 +1,4 @@ -# $FreeBSD$ +/* $FreeBSD$ */ #define HAVE_ERR_H 1 #define HAVE_SYS_EVENT_H 1 Modified: head/tools/regression/kqueue/proc.c ============================================================================== --- head/tools/regression/kqueue/proc.c Fri Jul 8 10:58:56 2011 (r223864) +++ head/tools/regression/kqueue/proc.c Fri Jul 8 12:16:30 2011 (r223865) @@ -43,9 +43,9 @@ add_and_delete(void) pid = fork(); if (pid == 0) { struct stat s; - if ((fstat(kqfd, &s) != -1) || (errno != EBADF)) - err(1, "%s:%d - %s: fstat(kqfd) in child did not return EBADF", - __FILE__, __LINE__, __func__); + if (fstat(kqfd, &s) != -1) + errx(1, "kqueue inherited across fork! (%s() at %s:%d)", + __func__, __FILE__, __LINE__); pause(); exit(2); From owner-svn-src-head@FreeBSD.ORG Fri Jul 8 12:19:25 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B0E4A106566C; Fri, 8 Jul 2011 12:19:25 +0000 (UTC) (envelope-from jonathan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A11EB8FC1C; Fri, 8 Jul 2011 12:19:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p68CJPg7017420; Fri, 8 Jul 2011 12:19:25 GMT (envelope-from jonathan@svn.freebsd.org) Received: (from jonathan@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p68CJPDV017418; Fri, 8 Jul 2011 12:19:25 GMT (envelope-from jonathan@svn.freebsd.org) Message-Id: <201107081219.p68CJPDV017418@svn.freebsd.org> From: Jonathan Anderson Date: Fri, 8 Jul 2011 12:19:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223866 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2011 12:19:25 -0000 Author: jonathan Date: Fri Jul 8 12:19:25 2011 New Revision: 223866 URL: http://svn.freebsd.org/changeset/base/223866 Log: Fix the "passability" test in fdcopy(). Rather than checking to see if a descriptor is a kqueue, check to see if its fileops flags include DFLAG_PASSABLE. At the moment, these two tests are equivalent, but this will change with the addition of capabilities that wrap kqueues but are themselves of type DTYPE_CAPABILITY. We already have the DFLAG_PASSABLE abstraction, so let's use it. This change has been tested with [the newly improved] tools/regression/kqueue. Approved by: mentor (rwatson), re (Capsicum blanket) Sponsored by: Google Inc Modified: head/sys/kern/kern_descrip.c Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Fri Jul 8 12:16:30 2011 (r223865) +++ head/sys/kern/kern_descrip.c Fri Jul 8 12:19:25 2011 (r223866) @@ -1780,11 +1780,11 @@ fdcopy(struct filedesc *fdp) FILEDESC_XUNLOCK(newfdp); FILEDESC_SLOCK(fdp); } - /* copy everything except kqueue descriptors */ + /* copy all passable descriptors (i.e. not kqueue) */ newfdp->fd_freefile = -1; for (i = 0; i <= fdp->fd_lastfile; ++i) { if (fdisused(fdp, i) && - fdp->fd_ofiles[i]->f_type != DTYPE_KQUEUE && + (fdp->fd_ofiles[i]->f_ops->fo_flags & DFLAG_PASSABLE) && fdp->fd_ofiles[i]->f_ops != &badfileops) { newfdp->fd_ofiles[i] = fdp->fd_ofiles[i]; newfdp->fd_ofileflags[i] = fdp->fd_ofileflags[i]; From owner-svn-src-head@FreeBSD.ORG Fri Jul 8 13:45:53 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AA6ED1065670; Fri, 8 Jul 2011 13:45:53 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9AFB88FC0A; Fri, 8 Jul 2011 13:45:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p68Djr89021467; Fri, 8 Jul 2011 13:45:53 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p68Djrdt021465; Fri, 8 Jul 2011 13:45:53 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201107081345.p68Djrdt021465@svn.freebsd.org> From: John Baldwin Date: Fri, 8 Jul 2011 13:45:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223870 - head/contrib/top X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2011 13:45:53 -0000 Author: jhb Date: Fri Jul 8 13:45:53 2011 New Revision: 223870 URL: http://svn.freebsd.org/changeset/base/223870 Log: Note that -a, -C, -H, -j, and -z are also toggles. PR: bin/158682 Reported by: arundel MFC after: 3 days Modified: head/contrib/top/top.X Modified: head/contrib/top/top.X ============================================================================== --- head/contrib/top/top.X Fri Jul 8 13:04:47 2011 (r223869) +++ head/contrib/top/top.X Fri Jul 8 13:45:53 2011 (r223870) @@ -200,11 +200,16 @@ a user to set his or her own defaults. can also be specified in the environment variable .BR TOP . The options +.BR \-a , +.BR \-C , +.BR \-H , .BR \-I , +.BR \-j , .BR \-S , +.BR \-t , .BR \-u , and -.B \-t +.B \-z are actually toggles. A second specification of any of these options will negate the first. Thus a user who has the environment variable .B TOP From owner-svn-src-head@FreeBSD.ORG Fri Jul 8 13:58:16 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 979BE106566B; Fri, 8 Jul 2011 13:58:16 +0000 (UTC) (envelope-from nwhitehorn@freebsd.org) Received: from agogare.doit.wisc.edu (agogare.doit.wisc.edu [144.92.197.211]) by mx1.freebsd.org (Postfix) with ESMTP id 6773C8FC0C; Fri, 8 Jul 2011 13:58:16 +0000 (UTC) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII; format=flowed Received: from avs-daemon.smtpauth2.wiscmail.wisc.edu by smtpauth2.wiscmail.wisc.edu (Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30 2009)) id <0LO000G02PH3ST00@smtpauth2.wiscmail.wisc.edu>; Fri, 08 Jul 2011 08:58:15 -0500 (CDT) Received: from comporellon.tachypleus.net (adsl-75-50-91-60.dsl.mdsnwi.sbcglobal.net [75.50.91.60]) by smtpauth2.wiscmail.wisc.edu (Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30 2009)) with ESMTPSA id <0LO000B94PH1W210@smtpauth2.wiscmail.wisc.edu>; Fri, 08 Jul 2011 08:58:14 -0500 (CDT) Date: Fri, 08 Jul 2011 08:58:13 -0500 From: Nathan Whitehorn In-reply-to: <20110707163655.GA8702@michelle.cdnetworks.com> To: pyunyh@gmail.com Message-id: <4E170CF5.8010109@freebsd.org> X-Spam-Report: AuthenticatedSender=yes, SenderIP=75.50.91.60 X-Spam-PmxInfo: Server=avs-9, Version=5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2011.7.8.134515, SenderIP=75.50.91.60 References: <201106281616.p5SGGhbx056614@svn.freebsd.org> <4E15C3FF.5030703@freebsd.org> <20110707160736.GE88226@alchemy.franken.de> <4E15DE20.2040000@freebsd.org> <20110707163655.GA8702@michelle.cdnetworks.com> User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:5.0) Gecko/20110704 Thunderbird/5.0 X-Mailman-Approved-At: Fri, 08 Jul 2011 14:32:28 +0000 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Marius Strobl Subject: Re: svn commit: r223648 - head/sys/dev/gem X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2011 13:58:16 -0000 On 07/07/11 11:36, YongHyeon PYUN wrote: > On Thu, Jul 07, 2011 at 11:26:08AM -0500, Nathan Whitehorn wrote: >> On 07/07/11 11:07, Marius Strobl wrote: >>> On Thu, Jul 07, 2011 at 09:34:39AM -0500, Nathan Whitehorn wrote: >>>> This breaks one of my gem devices (chip=0x0021106b) when the controller >>>> is initialized from FreeBSD (netbooting works fine, and the controller >>>> stays working after that), with "cannot disable RX MAC" or "cannot >>>> disable RX MAC or hash filter" messages. >>> Are you positive that it's exactly this revision which breaks things? >>> Actually there was a report from Justin Hibbits that r222135 causing >>> a GMAC to no longer work with similar symptoms, which still is unsolved >>> AFAICT. If it's really r223648 which is causing problems in your case >>> please try to figure out which part is causing that as none of the >>> changes exactly stands out as disruptive, probably best by reverting >>> gem_reset_rx() and gem_setladrf() one by one. >>> >> You're right. r223648 just added the printf(), r222135 is where it began >> not working. > Yes, I know that. I still have no clue and can't explain how > r222135 can break gem(4). Also note, the "cannot disable RX MAC" > was there before r222135. > One vague guess I have at this moment is that firmware may have put > controller into some deep power save state so the first time > gem_init() is called it may not have fully initialized the > controller. I sent a patch to Justin to check that and waiting for > his reply. > That patch doesn't help my case. -Nathan From owner-svn-src-head@FreeBSD.ORG Fri Jul 8 16:30:55 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 672301065673; Fri, 8 Jul 2011 16:30:55 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 553198FC12; Fri, 8 Jul 2011 16:30:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p68GUtrU029120; Fri, 8 Jul 2011 16:30:55 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p68GUtci029116; Fri, 8 Jul 2011 16:30:55 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201107081630.p68GUtci029116@svn.freebsd.org> From: Marcel Moolenaar Date: Fri, 8 Jul 2011 16:30:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223873 - in head/sys/ia64: ia64 include X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2011 16:30:55 -0000 Author: marcel Date: Fri Jul 8 16:30:54 2011 New Revision: 223873 URL: http://svn.freebsd.org/changeset/base/223873 Log: Implement basic support for memory attributes. At this time we only distinguish between UC and WB memory so that we can map the page to either a region 6 address (for UC) or a region 7 address (for WB). This change is only now possible, because previously we would map regions 6 and 7 with 256MB translations and on top of that had the kernel mapped in region 7 using a wired translation. The introduction of the PBVM moved the kernel into its own region and freed up region 7 and allowed us to revert to standard page-sized translations. This commit inroduces pmap_page_to_va() that respects the attribute. Modified: head/sys/ia64/ia64/pmap.c head/sys/ia64/include/pmap.h head/sys/ia64/include/sf_buf.h Modified: head/sys/ia64/ia64/pmap.c ============================================================================== --- head/sys/ia64/ia64/pmap.c Fri Jul 8 14:30:06 2011 (r223872) +++ head/sys/ia64/ia64/pmap.c Fri Jul 8 16:30:54 2011 (r223873) @@ -483,6 +483,18 @@ pmap_vhpt_population(SYSCTL_HANDLER_ARGS return (error); } +vm_offset_t +pmap_page_to_va(vm_page_t m) +{ + vm_paddr_t pa; + vm_offset_t va; + + pa = VM_PAGE_TO_PHYS(m); + va = (m->md.memattr == VM_MEMATTR_UNCACHEABLE) ? IA64_PHYS_TO_RR6(pa) : + IA64_PHYS_TO_RR7(pa); + return (va); +} + /* * Initialize a vm_page's machine-dependent fields. */ @@ -492,6 +504,7 @@ pmap_page_init(vm_page_t m) TAILQ_INIT(&m->md.pv_list); m->md.pv_list_count = 0; + m->md.memattr = VM_MEMATTR_DEFAULT; } /* @@ -702,8 +715,7 @@ pmap_growkernel(vm_offset_t addr) if (!nkpg) panic("%s: cannot add dir. page", __func__); - dir1 = (struct ia64_lpte **) - IA64_PHYS_TO_RR7(VM_PAGE_TO_PHYS(nkpg)); + dir1 = (struct ia64_lpte **)pmap_page_to_va(nkpg); bzero(dir1, PAGE_SIZE); ia64_kptdir[KPTE_DIR0_INDEX(kernel_vm_end)] = dir1; } @@ -713,8 +725,7 @@ pmap_growkernel(vm_offset_t addr) if (!nkpg) panic("%s: cannot add PTE page", __func__); - leaf = (struct ia64_lpte *) - IA64_PHYS_TO_RR7(VM_PAGE_TO_PHYS(nkpg)); + leaf = (struct ia64_lpte *)pmap_page_to_va(nkpg); bzero(leaf, PAGE_SIZE); dir1[KPTE_DIR1_INDEX(kernel_vm_end)] = leaf; @@ -1125,6 +1136,14 @@ pmap_pte_prot(pmap_t pm, struct ia64_lpt pte->pte |= prot2ar[(prot & VM_PROT_ALL) >> 1]; } +static PMAP_INLINE void +pmap_pte_attr(struct ia64_lpte *pte, vm_memattr_t ma) +{ + + pte->pte &= ~PTE_MA_MASK; + pte->pte |= (ma & PTE_MA_MASK); +} + /* * Set a pte to contain a valid mapping and enter it in the VHPT. If * the pte was orginally valid, then its assumed to already be in the @@ -1137,8 +1156,9 @@ pmap_set_pte(struct ia64_lpte *pte, vm_o boolean_t wired, boolean_t managed) { - pte->pte &= PTE_PROT_MASK | PTE_PL_MASK | PTE_AR_MASK | PTE_ED; - pte->pte |= PTE_PRESENT | PTE_MA_WB; + pte->pte &= PTE_PROT_MASK | PTE_MA_MASK | PTE_PL_MASK | + PTE_AR_MASK | PTE_ED; + pte->pte |= PTE_PRESENT; pte->pte |= (managed) ? PTE_MANAGED : (PTE_DIRTY | PTE_ACCESSED); pte->pte |= (wired) ? PTE_WIRED : 0; pte->pte |= pa & PTE_PPN_MASK; @@ -1255,6 +1275,7 @@ pmap_qenter(vm_offset_t va, vm_page_t *m else pmap_enter_vhpt(pte, va); pmap_pte_prot(kernel_pmap, pte, VM_PROT_ALL); + pmap_pte_attr(pte, m[i]->md.memattr); pmap_set_pte(pte, va, VM_PAGE_TO_PHYS(m[i]), FALSE, FALSE); va += PAGE_SIZE; } @@ -1296,6 +1317,7 @@ pmap_kenter(vm_offset_t va, vm_offset_t else pmap_enter_vhpt(pte, va); pmap_pte_prot(kernel_pmap, pte, VM_PROT_ALL); + pmap_pte_attr(pte, VM_MEMATTR_DEFAULT); pmap_set_pte(pte, va, pa, FALSE, FALSE); } @@ -1606,6 +1628,7 @@ validate: * adds the pte to the VHPT if necessary. */ pmap_pte_prot(pmap, pte, prot); + pmap_pte_attr(pte, m->md.memattr); pmap_set_pte(pte, va, pa, wired, managed); /* Invalidate the I-cache when needed. */ @@ -1711,6 +1734,7 @@ pmap_enter_quick_locked(pmap_t pmap, vm_ pmap_enter_vhpt(pte, va); pmap_pte_prot(pmap, pte, prot & (VM_PROT_READ | VM_PROT_EXECUTE)); + pmap_pte_attr(pte, m->md.memattr); pmap_set_pte(pte, va, VM_PAGE_TO_PHYS(m), FALSE, managed); if (prot & VM_PROT_EXECUTE) @@ -1793,8 +1817,10 @@ pmap_copy(pmap_t dst_pmap, pmap_t src_pm void pmap_zero_page(vm_page_t m) { - vm_offset_t va = IA64_PHYS_TO_RR7(VM_PAGE_TO_PHYS(m)); - bzero((caddr_t) va, PAGE_SIZE); + void *p; + + p = (void *)pmap_page_to_va(m); + bzero(p, PAGE_SIZE); } @@ -1809,8 +1835,10 @@ pmap_zero_page(vm_page_t m) void pmap_zero_page_area(vm_page_t m, int off, int size) { - vm_offset_t va = IA64_PHYS_TO_RR7(VM_PAGE_TO_PHYS(m)); - bzero((char *)(caddr_t)va + off, size); + char *p; + + p = (void *)pmap_page_to_va(m); + bzero(p + off, size); } @@ -1823,8 +1851,10 @@ pmap_zero_page_area(vm_page_t m, int off void pmap_zero_page_idle(vm_page_t m) { - vm_offset_t va = IA64_PHYS_TO_RR7(VM_PAGE_TO_PHYS(m)); - bzero((caddr_t) va, PAGE_SIZE); + void *p; + + p = (void *)pmap_page_to_va(m); + bzero(p, PAGE_SIZE); } @@ -1837,9 +1867,11 @@ pmap_zero_page_idle(vm_page_t m) void pmap_copy_page(vm_page_t msrc, vm_page_t mdst) { - vm_offset_t src = IA64_PHYS_TO_RR7(VM_PAGE_TO_PHYS(msrc)); - vm_offset_t dst = IA64_PHYS_TO_RR7(VM_PAGE_TO_PHYS(mdst)); - bcopy((caddr_t) src, (caddr_t) dst, PAGE_SIZE); + void *dst, *src; + + src = (void *)pmap_page_to_va(msrc); + dst = (void *)pmap_page_to_va(mdst); + bcopy(src, dst, PAGE_SIZE); } /* @@ -2186,6 +2218,7 @@ pmap_remove_write(vm_page_t m) } prot &= ~VM_PROT_WRITE; pmap_pte_prot(pmap, pte, prot); + pmap_pte_attr(pte, m->md.memattr); pmap_invalidate_page(pv->pv_va); } pmap_switch(oldpmap); @@ -2219,6 +2252,63 @@ pmap_unmapdev(vm_offset_t va, vm_size_t } /* + * Sets the memory attribute for the specified page. + */ +static void +pmap_page_set_memattr_1(void *arg) +{ + struct ia64_pal_result res; + register_t is; + uintptr_t pp = (uintptr_t)arg; + + is = intr_disable(); + res = ia64_call_pal_static(pp, 0, 0, 0); + intr_restore(is); +} + +void +pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma) +{ + struct ia64_lpte *pte; + pmap_t oldpmap; + pv_entry_t pv; + void *va; + + vm_page_lock_queues(); + m->md.memattr = ma; + TAILQ_FOREACH(pv, &m->md.pv_list, pv_list) { + PMAP_LOCK(pv->pv_pmap); + oldpmap = pmap_switch(pv->pv_pmap); + pte = pmap_find_vhpt(pv->pv_va); + KASSERT(pte != NULL, ("pte")); + pmap_pte_attr(pte, ma); + pmap_invalidate_page(pv->pv_va); + pmap_switch(oldpmap); + PMAP_UNLOCK(pv->pv_pmap); + } + vm_page_unlock_queues(); + + if (ma == VM_MEMATTR_UNCACHEABLE) { +#ifdef SMP + smp_rendezvous(NULL, pmap_page_set_memattr_1, NULL, + (void *)PAL_PREFETCH_VISIBILITY); +#else + pmap_page_set_memattr_1((void *)PAL_PREFETCH_VISIBILITY); +#endif + va = (void *)pmap_page_to_va(m); + critical_enter(); + cpu_flush_dcache(va, PAGE_SIZE); + critical_exit(); +#ifdef SMP + smp_rendezvous(NULL, pmap_page_set_memattr_1, NULL, + (void *)PAL_MC_DRAIN); +#else + pmap_page_set_memattr_1((void *)PAL_MC_DRAIN); +#endif + } +} + +/* * perform the pmap work for mincore */ int @@ -2228,7 +2318,7 @@ pmap_mincore(pmap_t pmap, vm_offset_t ad struct ia64_lpte *pte, tpte; vm_paddr_t pa; int val; - + PMAP_LOCK(pmap); retry: oldpmap = pmap_switch(pmap); Modified: head/sys/ia64/include/pmap.h ============================================================================== --- head/sys/ia64/include/pmap.h Fri Jul 8 14:30:06 2011 (r223872) +++ head/sys/ia64/include/pmap.h Fri Jul 8 16:30:54 2011 (r223873) @@ -68,6 +68,7 @@ struct pv_entry; struct md_page { int pv_list_count; TAILQ_HEAD(,pv_entry) pv_list; + vm_memattr_t memattr; }; struct pmap { @@ -115,21 +116,22 @@ extern vm_offset_t virtual_end; extern uint64_t pmap_vhpt_base[]; extern int pmap_vhpt_log2size; -#define pmap_page_get_memattr(m) VM_MEMATTR_DEFAULT +#define pmap_page_get_memattr(m) ((m)->md.memattr) #define pmap_page_is_mapped(m) (!TAILQ_EMPTY(&(m)->md.pv_list)) -#define pmap_page_set_memattr(m, ma) (void)0 #define pmap_mapbios(pa, sz) pmap_mapdev(pa, sz) #define pmap_unmapbios(va, sz) pmap_unmapdev(va, sz) -vm_offset_t pmap_steal_memory(vm_size_t); vm_offset_t pmap_alloc_vhpt(void); void pmap_bootstrap(void); void pmap_kenter(vm_offset_t va, vm_offset_t pa); vm_paddr_t pmap_kextract(vm_offset_t va); void pmap_kremove(vm_offset_t); void *pmap_mapdev(vm_paddr_t, vm_size_t); -void pmap_unmapdev(vm_offset_t, vm_size_t); +void pmap_page_set_memattr(vm_page_t, vm_memattr_t); +vm_offset_t pmap_page_to_va(vm_page_t); +vm_offset_t pmap_steal_memory(vm_size_t); struct pmap *pmap_switch(struct pmap *pmap); +void pmap_unmapdev(vm_offset_t, vm_size_t); #endif /* _KERNEL */ Modified: head/sys/ia64/include/sf_buf.h ============================================================================== --- head/sys/ia64/include/sf_buf.h Fri Jul 8 14:30:06 2011 (r223872) +++ head/sys/ia64/include/sf_buf.h Fri Jul 8 16:30:54 2011 (r223873) @@ -41,18 +41,20 @@ */ struct sf_buf; -static __inline vm_offset_t -sf_buf_kva(struct sf_buf *sf) +static __inline vm_page_t +sf_buf_page(struct sf_buf *sf) { - - return (IA64_PHYS_TO_RR7(VM_PAGE_TO_PHYS((vm_page_t)sf))); + + return ((vm_page_t)sf); } -static __inline vm_page_t -sf_buf_page(struct sf_buf *sf) +static __inline vm_offset_t +sf_buf_kva(struct sf_buf *sf) { + vm_page_t m; - return ((vm_page_t)sf); + m = sf_buf_page(sf); + return (pmap_page_to_va(m)); } #endif /* !_MACHINE_SF_BUF_H_ */ From owner-svn-src-head@FreeBSD.ORG Fri Jul 8 17:45:38 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6FA33106564A; Fri, 8 Jul 2011 17:45:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5E5F38FC16; Fri, 8 Jul 2011 17:45:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p68Hjc26032429; Fri, 8 Jul 2011 17:45:38 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p68HjcGl032427; Fri, 8 Jul 2011 17:45:38 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201107081745.p68HjcGl032427@svn.freebsd.org> From: John Baldwin Date: Fri, 8 Jul 2011 17:45:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223874 - head/sys/dev/uart X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2011 17:45:38 -0000 Author: jhb Date: Fri Jul 8 17:45:38 2011 New Revision: 223874 URL: http://svn.freebsd.org/changeset/base/223874 Log: Add device ID for the Davicom 56PDV PCI Modem. PR: kern/75132 Submitted by: Mike Tancsa @ Sentex (older patch against puc(4)) MFC after: 1 week Modified: head/sys/dev/uart/uart_bus_pci.c Modified: head/sys/dev/uart/uart_bus_pci.c ============================================================================== --- head/sys/dev/uart/uart_bus_pci.c Fri Jul 8 16:30:54 2011 (r223873) +++ head/sys/dev/uart/uart_bus_pci.c Fri Jul 8 17:45:38 2011 (r223874) @@ -83,6 +83,7 @@ static struct pci_id pci_ns8250_ids[] = { 0x103c, 0x1290, 0xffff, 0, "HP Auxiliary Diva Serial Port", 0x18 }, { 0x11c1, 0x0480, 0xffff, 0, "Agere Systems Venus Modem (V90, 56KFlex)", 0x14 }, { 0x115d, 0x0103, 0xffff, 0, "Xircom Cardbus Ethernet + 56k Modem", 0x10 }, +{ 0x1282, 0x6585, 0xffff, 0, "Davicom 56PDV PCI Modem", 0x10 }, { 0x12b9, 0x1008, 0xffff, 0, "3Com 56K FaxModem Model 5610", 0x10 }, { 0x131f, 0x1000, 0xffff, 0, "Siig CyberSerial (1-port) 16550", 0x18 }, { 0x131f, 0x1001, 0xffff, 0, "Siig CyberSerial (1-port) 16650", 0x18 }, From owner-svn-src-head@FreeBSD.ORG Fri Jul 8 20:41:07 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8292D1065670; Fri, 8 Jul 2011 20:41:07 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 723588FC0A; Fri, 8 Jul 2011 20:41:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p68Kf7OK040399; Fri, 8 Jul 2011 20:41:07 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p68Kf7hv040397; Fri, 8 Jul 2011 20:41:07 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201107082041.p68Kf7hv040397@svn.freebsd.org> From: Matthew D Fleming Date: Fri, 8 Jul 2011 20:41:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223875 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2011 20:41:07 -0000 Author: mdf Date: Fri Jul 8 20:41:07 2011 New Revision: 223875 URL: http://svn.freebsd.org/changeset/base/223875 Log: style(9) and cleanup fixes. MFC after: 1 week Modified: head/sys/kern/kern_fail.c Modified: head/sys/kern/kern_fail.c ============================================================================== --- head/sys/kern/kern_fail.c Fri Jul 8 17:45:38 2011 (r223874) +++ head/sys/kern/kern_fail.c Fri Jul 8 20:41:07 2011 (r223875) @@ -52,6 +52,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include @@ -88,16 +89,20 @@ enum fail_point_t { FAIL_POINT_BREAK, /**< break into the debugger */ FAIL_POINT_PRINT, /**< print a message */ FAIL_POINT_SLEEP, /**< sleep for some msecs */ - FAIL_POINT_INVALID, /**< placeholder */ + FAIL_POINT_NUMTYPES }; -static const char *fail_type_strings[] = { - "off", - "panic", - "return", - "break", - "print", - "sleep", +static struct { + const char *name; + int nmlen; +} fail_type_strings[] = { +#define FP_TYPE_NM_LEN(s) { s, sizeof(s) - 1 } + [FAIL_POINT_OFF] = FP_TYPE_NM_LEN("off"), + [FAIL_POINT_PANIC] = FP_TYPE_NM_LEN("panic"), + [FAIL_POINT_RETURN] = FP_TYPE_NM_LEN("return"), + [FAIL_POINT_BREAK] = FP_TYPE_NM_LEN("break"), + [FAIL_POINT_PRINT] = FP_TYPE_NM_LEN("print"), + [FAIL_POINT_SLEEP] = FP_TYPE_NM_LEN("sleep"), }; /** @@ -120,7 +125,7 @@ fail_point_sleep(struct fail_point *fp, /* convert from millisecs to ticks, rounding up */ int timo = ((msecs * hz) + 999) / 1000; - if (timo) { + if (timo > 0) { if (fp->fp_sleep_fn == NULL) { msleep(fp, &g_fp_mtx, PWAIT, "failpt", timo); } else { @@ -191,19 +196,13 @@ fail_point_init(struct fail_point *fp, c void fail_point_destroy(struct fail_point *fp) { - struct fail_point_entry *ent; - if (fp->fp_flags & FAIL_POINT_DYNAMIC_NAME && fp->fp_name != NULL) { - fp_free((void *)(intptr_t)fp->fp_name); + if ((fp->fp_flags & FAIL_POINT_DYNAMIC_NAME) != 0) { + fp_free(__DECONST(void *, fp->fp_name)); fp->fp_name = NULL; } fp->fp_flags = 0; - - while (!TAILQ_EMPTY(&fp->fp_entries)) { - ent = TAILQ_FIRST(&fp->fp_entries); - TAILQ_REMOVE(&fp->fp_entries, ent, fe_entries); - fp_free(ent); - } + clear_entries(&fp->fp_entries); } /** @@ -222,16 +221,12 @@ fail_point_eval_nontrivial(struct fail_p FP_LOCK(); - ent = TAILQ_FIRST(&fp->fp_entries); - while (ent) { + TAILQ_FOREACH_SAFE(ent, &fp->fp_entries, fe_entries, next) { int cont = 0; /* don't continue by default */ - next = TAILQ_NEXT(ent, fe_entries); if (ent->fe_prob < PROB_MAX && - ent->fe_prob < random() % PROB_MAX) { - cont = 1; - goto loop_end; - } + ent->fe_prob < random() % PROB_MAX) + continue; switch (ent->fe_type) { case FAIL_POINT_PANIC: @@ -239,13 +234,14 @@ fail_point_eval_nontrivial(struct fail_p /* NOTREACHED */ case FAIL_POINT_RETURN: - if (return_value) + if (return_value != NULL) *return_value = ent->fe_arg; ret = FAIL_POINT_RC_RETURN; break; case FAIL_POINT_BREAK: - printf("fail point %s breaking to debugger\n", fp->fp_name); + printf("fail point %s breaking to debugger\n", + fp->fp_name); breakpoint(); break; @@ -273,13 +269,9 @@ fail_point_eval_nontrivial(struct fail_p break; } - if (ent && ent->fe_count > 0 && --ent->fe_count == 0) + if (ent != NULL && ent->fe_count > 0 && --ent->fe_count == 0) free_entry(&fp->fp_entries, ent); - -loop_end: - if (cont) - ent = next; - else + if (cont == 0) break; } @@ -290,7 +282,7 @@ loop_end: FP_UNLOCK(); - return ret; + return (ret); } /** @@ -320,7 +312,7 @@ fail_point_get(struct fail_point *fp, st } if (ent->fe_count > 0) sbuf_printf(sb, "%d*", ent->fe_count); - sbuf_printf(sb, "%s", fail_type_strings[ent->fe_type]); + sbuf_printf(sb, "%s", fail_type_strings[ent->fe_type].name); if (ent->fe_arg) sbuf_printf(sb, "(%d)", ent->fe_arg); if (TAILQ_NEXT(ent, fe_entries)) @@ -380,7 +372,7 @@ fail_point_set(struct fail_point *fp, ch fp->fp_name, fp->fp_location, buf); #endif /* IWARNING */ - return error; + return (error); } #define MAX_FAIL_POINT_BUF 1023 @@ -422,9 +414,8 @@ fail_point_sysctl(SYSCTL_HANDLER_ARGS) } out: - if (buf) - fp_free(buf); - return error; + fp_free(buf); + return (error); } /** @@ -437,12 +428,17 @@ parse_fail_point(struct fail_point_entri /* :: * ( "->" )* */ - if (!(p = parse_term(ents, p))) - return 0; - while (*p) - if (p[0] != '-' || p[1] != '>' || !(p = parse_term(ents, p+2))) - return 0; - return p; + p = parse_term(ents, p); + if (p == NULL) + return (NULL); + while (*p != '\0') { + if (p[0] != '-' || p[1] != '>') + return (NULL); + p = parse_term(ents, p + 2); + if (p == NULL) + return (NULL); + } + return (p); } /** @@ -465,11 +461,12 @@ parse_term(struct fail_point_entries *en */ /* ( ( "%") | ( "*" ) )* */ - while (('0' <= *p && *p <= '9') || *p == '.') { + while (isdigit(*p) || *p == '.') { int units, decimal; - if (!(p = parse_number(&units, &decimal, p))) - return 0; + p = parse_number(&units, &decimal, p); + if (p == NULL) + return (NULL); if (*p == '%') { if (units > 100) /* prevent overflow early */ @@ -477,37 +474,33 @@ parse_term(struct fail_point_entries *en ent->fe_prob = units * (PROB_MAX / 100) + decimal; if (ent->fe_prob > PROB_MAX) ent->fe_prob = PROB_MAX; - } else if (*p == '*') { if (!units || decimal) - return 0; + return (NULL); ent->fe_count = units; - - } else { - return 0; - } - + } else + return (NULL); p++; } /* */ - if (!(p = parse_type(ent, p))) - return 0; + p = parse_type(ent, p); + if (p == NULL) + return (NULL); if (*p == '\0') - return p; + return (p); /* [ "(" ")" ] */ if (*p != '(') return p; p++; - if (('0' <= *p && *p <= '9') || *p == '-') - ent->fe_arg = strtol(p, &p, 0); - else - return 0; + if (!isdigit(*p) && *p != '-') + return (NULL); + ent->fe_arg = strtol(p, &p, 0); if (*p++ != ')') - return 0; + return (NULL); - return p; + return (p); } /** @@ -528,14 +521,14 @@ parse_number(int *out_units, int *out_de old_p = p; *out_units = strtol(p, &p, 10); if (p == old_p && *p != '.') - return 0; + return (NULL); /* fractional part */ *out_decimal = 0; if (*p == '.') { int digits = 0; p++; - while ('0' <= *p && *p <= '9') { + while (isdigit(*p)) { int digit = *p - '0'; if (digits < PROB_DIGITS - 2) *out_decimal = *out_decimal * 10 + digit; @@ -545,12 +538,12 @@ parse_number(int *out_units, int *out_de p++; } if (!digits) /* need at least one digit after '.' */ - return 0; + return (NULL); while (digits++ < PROB_DIGITS - 2) /* add implicit zeros */ *out_decimal *= 10; } - return p; /* success */ + return (p); /* success */ } /** @@ -560,21 +553,16 @@ static char * parse_type(struct fail_point_entry *ent, char *beg) { enum fail_point_t type; - char *end = beg; - while ('a' <= *end && *end <= 'z') - end++; - if (beg == end) - return 0; - for (type = FAIL_POINT_OFF; type != FAIL_POINT_INVALID; type++) { - const char *p = fail_type_strings[type]; - const char *q = beg; - while (q < end && *p++ == *q++); - if (q == end && *p == '\0') { + int len; + + for (type = FAIL_POINT_OFF; type < FAIL_POINT_NUMTYPES; type++) { + len = fail_type_strings[type].nmlen; + if (strncmp(fail_type_strings[type].name, beg, len) == 0) { ent->fe_type = type; - return end; + return (beg + len); } } - return 0; + return (NULL); } /** @@ -595,6 +583,7 @@ static void clear_entries(struct fail_point_entries *ents) { struct fail_point_entry *ent, *ent_next; + TAILQ_FOREACH_SAFE(ent, ents, fe_entries, ent_next) fp_free(ent); TAILQ_INIT(ents); From owner-svn-src-head@FreeBSD.ORG Fri Jul 8 20:41:16 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DD27910656B6; Fri, 8 Jul 2011 20:41:13 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2C77F8FC14; Fri, 8 Jul 2011 20:41:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p68KfDnV040444; Fri, 8 Jul 2011 20:41:13 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p68KfDps040441; Fri, 8 Jul 2011 20:41:13 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201107082041.p68KfDps040441@svn.freebsd.org> From: Matthew D Fleming Date: Fri, 8 Jul 2011 20:41:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223876 - in head: share/man/man9 sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2011 20:41:16 -0000 Author: mdf Date: Fri Jul 8 20:41:12 2011 New Revision: 223876 URL: http://svn.freebsd.org/changeset/base/223876 Log: Add an option to have a fail point term only execute when run by a specified pid. This is helpful for automated testing involving a global knob that would otherwise be executed by many other threads. MFC after: 1 week Modified: head/share/man/man9/fail.9 head/sys/kern/kern_fail.c Modified: head/share/man/man9/fail.9 ============================================================================== --- head/share/man/man9/fail.9 Fri Jul 8 20:41:07 2011 (r223875) +++ head/share/man/man9/fail.9 Fri Jul 8 20:41:12 2011 (r223876) @@ -116,6 +116,7 @@ The sysctl variable may be set using the ( ( "%") | ( "*" ) )* [ "(" ")" ] + [ "[pid " "]" ] :: [ "." ] | @@ -161,6 +162,10 @@ For the purpose of this operator, the re are the only types that cascade. A return() term only cascades if the code executes, and a print() term only cascades when passed a non-zero argument. +A pid can optionally be specified. +The fail point term is only executed when invoked by a process with a +matching p_pid. +.Pp .Sh EXAMPLES .Bl -tag .It Sy sysctl debug.fail_point.foobar="2.1%return(5)" @@ -181,6 +186,8 @@ After that, 1/1000th of the time, return Return 5 for 1 in 1000 executions, but only 5 times total. .It Sy sysctl debug.fail_point.foobar="1%*sleep(50)" 1/100th of the time, sleep 50ms. +.It Sy sysctl debug.fail_point.foobar="1*return(5)[pid 1234]" +Return 5 once, when pid 1234 executes the fail point. .El .Sh AUTHORS .An -nosplit Modified: head/sys/kern/kern_fail.c ============================================================================== --- head/sys/kern/kern_fail.c Fri Jul 8 20:41:07 2011 (r223875) +++ head/sys/kern/kern_fail.c Fri Jul 8 20:41:12 2011 (r223876) @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -114,7 +115,7 @@ struct fail_point_entry { int fe_arg; /**< argument to type (e.g. return value) */ int fe_prob; /**< likelihood of firing in millionths */ int fe_count; /**< number of times to fire, 0 means always */ - + pid_t fe_pid; /**< only fail for this process */ TAILQ_ENTRY(fail_point_entry) fe_entries; /**< next entry in fail point */ }; @@ -227,6 +228,8 @@ fail_point_eval_nontrivial(struct fail_p if (ent->fe_prob < PROB_MAX && ent->fe_prob < random() % PROB_MAX) continue; + if (ent->fe_pid != NO_PID && ent->fe_pid != curproc->p_pid) + continue; switch (ent->fe_type) { case FAIL_POINT_PANIC: @@ -315,6 +318,8 @@ fail_point_get(struct fail_point *fp, st sbuf_printf(sb, "%s", fail_type_strings[ent->fe_type].name); if (ent->fe_arg) sbuf_printf(sb, "(%d)", ent->fe_arg); + if (ent->fe_pid != NO_PID) + sbuf_printf(sb, "[pid %d]", ent->fe_pid); if (TAILQ_NEXT(ent, fe_entries)) sbuf_printf(sb, "->"); } @@ -451,6 +456,7 @@ parse_term(struct fail_point_entries *en ent = fp_malloc(sizeof *ent, M_WAITOK | M_ZERO); ent->fe_prob = PROB_MAX; + ent->fe_pid = NO_PID; TAILQ_INSERT_TAIL(ents, ent, fe_entries); /* @@ -458,6 +464,7 @@ parse_term(struct fail_point_entries *en * ( ( "%") | ( "*" ) )* * * [ "(" ")" ] + * [ "[pid " "]" ] */ /* ( ( "%") | ( "*" ) )* */ @@ -500,6 +507,17 @@ parse_term(struct fail_point_entries *en if (*p++ != ')') return (NULL); + /* [ "[pid " "]" ] */ +#define PID_STRING "[pid " + if (strncmp(p, PID_STRING, sizeof(PID_STRING) - 1) != 0) + return (p); + p += sizeof(PID_STRING) - 1; + if (!isdigit(*p)) + return (NULL); + ent->fe_pid = strtol(p, &p, 0); + if (*p++ != ']') + return (NULL); + return (p); } From owner-svn-src-head@FreeBSD.ORG Fri Jul 8 22:33:56 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4916A1065674; Fri, 8 Jul 2011 22:33:56 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id DE02E8FC18; Fri, 8 Jul 2011 22:33:55 +0000 (UTC) Received: from 63.imp.bsdimp.com (63.imp.bsdimp.com [10.0.0.63]) (authenticated bits=0) by harmony.bsdimp.com (8.14.4/8.14.3) with ESMTP id p68MUc6M013873 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Fri, 8 Jul 2011 16:30:38 -0600 (MDT) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1084) From: Warner Losh In-Reply-To: Date: Fri, 8 Jul 2011 16:29:37 -0600 Message-Id: References: <201107080135.p681ZXZu087112@svn.freebsd.org> To: Craig Rodrigues X-Mailer: Apple Mail (2.1084) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (harmony.bsdimp.com [10.0.0.6]); Fri, 08 Jul 2011 16:30:38 -0600 (MDT) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Tai-hwa Liang , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r223854 - head/lib/libstand X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2011 22:33:56 -0000 On Jul 8, 2011, at 2:25 AM, Craig Rodrigues wrote: > Hi, >=20 > While not ideal, would it be possible consider setting WARNS to set = different levels > depending on what the value of ${MACHINE_ARCH} is? >=20 > Something like: >=20 > .if ${MACHINE_ARCH} !=3D "sparc64" (or whatever the correct value is) > WARNS ?=3D 0 > .else > WARNS ?=3D 2 > .endif >=20 > This would at least be an attempt to prevent people from adding new > code to libstand which introduce new warnings. We've avoided this in the tree, and I'd urge against it. It gives a = false sense of security and tends to make problems linger. I'd like to = strongly argue against it. Warner > -- > Craig Rodrigues > rodrigc@crodrigues.org >=20 > On Thu, Jul 7, 2011 at 6:35 PM, Tai-hwa Liang = wrote: > Author: avatar > Date: Fri Jul 8 01:35:33 2011 > New Revision: 223854 > URL: http://svn.freebsd.org/changeset/base/223854 >=20 > Log: > Fixing building bustage on 32 bits platforms when WARNS >=3D 2. Note = that > this fix only applies to zalloc.c, the other part of libstand such = like > qdivrem.c still gives compilation warnings on sparc64 tinderbox = builds; > therefore, WARNS level isn't changed for now. >=20 > Submitted by: Garrett Cooper > Reviewed by: bde >=20 > Modified: > head/lib/libstand/zalloc.c > head/lib/libstand/zalloc_defs.h >=20 > Modified: head/lib/libstand/zalloc.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/lib/libstand/zalloc.c Fri Jul 8 01:32:04 2011 = (r223853) > +++ head/lib/libstand/zalloc.c Fri Jul 8 01:35:33 2011 = (r223854) > @@ -154,7 +154,7 @@ zfree(MemPool *mp, void *ptr, iaddr_t by > if ((char *)ptr < (char *)mp->mp_Base || > (char *)ptr + bytes > (char *)mp->mp_End || > ((iaddr_t)ptr & MEMNODE_SIZE_MASK) !=3D 0) > - panic("zfree(%p,%ju): wild pointer", ptr, bytes); > + panic("zfree(%p,%ju): wild pointer", ptr, (uintmax_t)bytes); >=20 > /* > * free the segment > @@ -177,8 +177,10 @@ zfree(MemPool *mp, void *ptr, iaddr_t by > /* > * range check > */ > - if ((char *)ptr + bytes > (char *)mn) > - panic("zfree(%p,%ju): corrupt memlist1",ptr, = bytes); > + if ((char *)ptr + bytes > (char *)mn) { > + panic("zfree(%p,%ju): corrupt memlist1", ptr, > + (uintmax_t)bytes); > + } >=20 > /* > * merge against next area or create independant area > @@ -208,8 +210,10 @@ zfree(MemPool *mp, void *ptr, iaddr_t by > return; > /* NOT REACHED */ > } > - if ((char *)ptr < (char *)mn + mn->mr_Bytes) > - panic("zfree(%p,%ju): corrupt memlist2", ptr, bytes); > + if ((char *)ptr < (char *)mn + mn->mr_Bytes) { > + panic("zfree(%p,%ju): corrupt memlist2", ptr, > + (uintmax_t)bytes); > + } > } > /* > * We are beyond the last MemNode, append new MemNode. Merge = against >=20 > Modified: head/lib/libstand/zalloc_defs.h > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/lib/libstand/zalloc_defs.h Fri Jul 8 01:32:04 2011 = (r223853) > +++ head/lib/libstand/zalloc_defs.h Fri Jul 8 01:35:33 2011 = (r223854) > @@ -39,6 +39,7 @@ > #define ZALLOCDEBUG >=20 > #include > +#include > #include "stand.h" >=20 > typedef uintptr_t iaddr_t; /* unsigned int same size as pointer = */ >=20 >=20 >=20 > --=20 > Craig Rodrigues > rodrigc@rodrigues.org >=20 From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 07:43:56 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9DD4C106564A; Sat, 9 Jul 2011 07:43:56 +0000 (UTC) (envelope-from kevlo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8C8838FC12; Sat, 9 Jul 2011 07:43:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p697huIi086385; Sat, 9 Jul 2011 07:43:56 GMT (envelope-from kevlo@svn.freebsd.org) Received: (from kevlo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p697huB2086379; Sat, 9 Jul 2011 07:43:56 GMT (envelope-from kevlo@svn.freebsd.org) Message-Id: <201107090743.p697huB2086379@svn.freebsd.org> From: Kevin Lo Date: Sat, 9 Jul 2011 07:43:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223877 - in head: include/rpc lib/libc/xdr X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 07:43:56 -0000 Author: kevlo Date: Sat Jul 9 07:43:56 2011 New Revision: 223877 URL: http://svn.freebsd.org/changeset/base/223877 Log: - Add xdr_sizeof(3) to libc - Document xdr_sizeof(3); from NetBSD Discussed with: kib Modified: head/include/rpc/xdr.h head/lib/libc/xdr/Makefile.inc head/lib/libc/xdr/Symbol.map head/lib/libc/xdr/xdr.3 head/lib/libc/xdr/xdr_sizeof.c Modified: head/include/rpc/xdr.h ============================================================================== --- head/include/rpc/xdr.h Fri Jul 8 20:41:12 2011 (r223876) +++ head/include/rpc/xdr.h Sat Jul 9 07:43:56 2011 (r223877) @@ -285,43 +285,46 @@ struct xdr_discrim { * These are the "generic" xdr routines. */ __BEGIN_DECLS -extern bool_t xdr_void(void); -extern bool_t xdr_int(XDR *, int *); -extern bool_t xdr_u_int(XDR *, u_int *); -extern bool_t xdr_long(XDR *, long *); -extern bool_t xdr_u_long(XDR *, u_long *); -extern bool_t xdr_short(XDR *, short *); -extern bool_t xdr_u_short(XDR *, u_short *); -extern bool_t xdr_int16_t(XDR *, int16_t *); -extern bool_t xdr_u_int16_t(XDR *, u_int16_t *); -extern bool_t xdr_uint16_t(XDR *, u_int16_t *); -extern bool_t xdr_int32_t(XDR *, int32_t *); -extern bool_t xdr_u_int32_t(XDR *, u_int32_t *); -extern bool_t xdr_uint32_t(XDR *, u_int32_t *); -extern bool_t xdr_int64_t(XDR *, int64_t *); -extern bool_t xdr_u_int64_t(XDR *, u_int64_t *); -extern bool_t xdr_uint64_t(XDR *, u_int64_t *); -extern bool_t xdr_bool(XDR *, bool_t *); -extern bool_t xdr_enum(XDR *, enum_t *); -extern bool_t xdr_array(XDR *, char **, u_int *, u_int, u_int, xdrproc_t); -extern bool_t xdr_bytes(XDR *, char **, u_int *, u_int); -extern bool_t xdr_opaque(XDR *, char *, u_int); -extern bool_t xdr_string(XDR *, char **, u_int); -extern bool_t xdr_union(XDR *, enum_t *, char *, const struct xdr_discrim *, xdrproc_t); -extern bool_t xdr_char(XDR *, char *); -extern bool_t xdr_u_char(XDR *, u_char *); -extern bool_t xdr_vector(XDR *, char *, u_int, u_int, xdrproc_t); -extern bool_t xdr_float(XDR *, float *); -extern bool_t xdr_double(XDR *, double *); -extern bool_t xdr_quadruple(XDR *, long double *); -extern bool_t xdr_reference(XDR *, char **, u_int, xdrproc_t); -extern bool_t xdr_pointer(XDR *, char **, u_int, xdrproc_t); -extern bool_t xdr_wrapstring(XDR *, char **); -extern void xdr_free(xdrproc_t, void *); -extern bool_t xdr_hyper(XDR *, quad_t *); -extern bool_t xdr_u_hyper(XDR *, u_quad_t *); -extern bool_t xdr_longlong_t(XDR *, quad_t *); -extern bool_t xdr_u_longlong_t(XDR *, u_quad_t *); +extern bool_t xdr_void(void); +extern bool_t xdr_int(XDR *, int *); +extern bool_t xdr_u_int(XDR *, u_int *); +extern bool_t xdr_long(XDR *, long *); +extern bool_t xdr_u_long(XDR *, u_long *); +extern bool_t xdr_short(XDR *, short *); +extern bool_t xdr_u_short(XDR *, u_short *); +extern bool_t xdr_int16_t(XDR *, int16_t *); +extern bool_t xdr_u_int16_t(XDR *, u_int16_t *); +extern bool_t xdr_uint16_t(XDR *, u_int16_t *); +extern bool_t xdr_int32_t(XDR *, int32_t *); +extern bool_t xdr_u_int32_t(XDR *, u_int32_t *); +extern bool_t xdr_uint32_t(XDR *, u_int32_t *); +extern bool_t xdr_int64_t(XDR *, int64_t *); +extern bool_t xdr_u_int64_t(XDR *, u_int64_t *); +extern bool_t xdr_uint64_t(XDR *, u_int64_t *); +extern bool_t xdr_bool(XDR *, bool_t *); +extern bool_t xdr_enum(XDR *, enum_t *); +extern bool_t xdr_array(XDR *, char **, u_int *, u_int, u_int, + xdrproc_t); +extern bool_t xdr_bytes(XDR *, char **, u_int *, u_int); +extern bool_t xdr_opaque(XDR *, char *, u_int); +extern bool_t xdr_string(XDR *, char **, u_int); +extern bool_t xdr_union(XDR *, enum_t *, char *, + const struct xdr_discrim *, xdrproc_t); +extern bool_t xdr_char(XDR *, char *); +extern bool_t xdr_u_char(XDR *, u_char *); +extern bool_t xdr_vector(XDR *, char *, u_int, u_int, xdrproc_t); +extern bool_t xdr_float(XDR *, float *); +extern bool_t xdr_double(XDR *, double *); +extern bool_t xdr_quadruple(XDR *, long double *); +extern bool_t xdr_reference(XDR *, char **, u_int, xdrproc_t); +extern bool_t xdr_pointer(XDR *, char **, u_int, xdrproc_t); +extern bool_t xdr_wrapstring(XDR *, char **); +extern void xdr_free(xdrproc_t, void *); +extern bool_t xdr_hyper(XDR *, quad_t *); +extern bool_t xdr_u_hyper(XDR *, u_quad_t *); +extern bool_t xdr_longlong_t(XDR *, quad_t *); +extern bool_t xdr_u_longlong_t(XDR *, u_quad_t *); +extern unsigned long xdr_sizeof(xdrproc_t, void *); __END_DECLS /* Modified: head/lib/libc/xdr/Makefile.inc ============================================================================== --- head/lib/libc/xdr/Makefile.inc Fri Jul 8 20:41:12 2011 (r223876) +++ head/lib/libc/xdr/Makefile.inc Sat Jul 9 07:43:56 2011 (r223877) @@ -3,7 +3,8 @@ .PATH: ${.CURDIR}/xdr ${.CURDIR}/. SRCS+= xdr.c xdr_array.c xdr_float.c xdr_mem.c \ - xdr_rec.c xdr_reference.c xdr_stdio.c + xdr_rec.c xdr_reference.c xdr_sizeof.c \ + xdr_stdio.c SYM_MAPS+= ${.CURDIR}/xdr/Symbol.map @@ -39,6 +40,7 @@ MLINKS+= rpc_xdr.3 xdr_accepted_reply.3 xdr.3 xdr_reference.3 \ xdr.3 xdr_setpos.3 \ xdr.3 xdr_short.3 \ + xdr.3 xdr_sizeof.3 \ xdr.3 xdrstdio_create.3 \ xdr.3 xdr_string.3 \ xdr.3 xdr_u_char.3 \ Modified: head/lib/libc/xdr/Symbol.map ============================================================================== --- head/lib/libc/xdr/Symbol.map Fri Jul 8 20:41:12 2011 (r223876) +++ head/lib/libc/xdr/Symbol.map Sat Jul 9 07:43:56 2011 (r223877) @@ -42,7 +42,6 @@ FBSD_1.0 { xdrrec_endofrecord; xdr_reference; xdr_pointer; - /* xdr_sizeof; */ /* Why is xdr_sizeof.c not included in Makefileinc? */ xdrstdio_create; }; @@ -51,3 +50,7 @@ FBSD_1.1 { xdr_uint32_t; xdr_uint64_t; }; + +FBSD_1.2 { + xdr_sizeof; +}; Modified: head/lib/libc/xdr/xdr.3 ============================================================================== --- head/lib/libc/xdr/xdr.3 Fri Jul 8 20:41:12 2011 (r223876) +++ head/lib/libc/xdr/xdr.3 Sat Jul 9 07:43:56 2011 (r223877) @@ -31,6 +31,7 @@ .Nm xdr_reference , .Nm xdr_setpos , .Nm xdr_short , +.Nm xdr_sizeof, .Nm xdrstdio_create , .Nm xdr_string , .Nm xdr_u_char , @@ -561,6 +562,18 @@ A filter primitive that translates betwe integers and their external representations. This routine returns one if it succeeds, zero otherwise. .Pp +.It Xo +.Ft unsigned long +.Xc +.It Xo +.Fn xdr_sizeof "xdrproc_t func" "void *data" +.Xc +.Pp +This routine returns the amount of memory required to encode +.Fa data +using filter +.Fa func . +.Pp .It Li "#ifdef _STDIO_H_" .It Li "/* XDR using stdio library */" .It Xo Modified: head/lib/libc/xdr/xdr_sizeof.c ============================================================================== --- head/lib/libc/xdr/xdr_sizeof.c Fri Jul 8 20:41:12 2011 (r223876) +++ head/lib/libc/xdr/xdr_sizeof.c Sat Jul 9 07:43:56 2011 (r223877) @@ -94,7 +94,7 @@ x_inline(xdrs, len) if (xdrs->x_op != XDR_ENCODE) { return (NULL); } - if (len < (u_int)xdrs->x_base) { + if (len < (u_int)(uintptr_t)xdrs->x_base) { /* x_private was already allocated */ xdrs->x_handy += len; return ((int32_t *) xdrs->x_private); @@ -106,7 +106,7 @@ x_inline(xdrs, len) xdrs->x_base = 0; return (NULL); } - xdrs->x_base = (caddr_t) len; + xdrs->x_base = (caddr_t)(uintptr_t)len; xdrs->x_handy += len; return ((int32_t *) xdrs->x_private); } From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 08:14:13 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 1233) id 76E011065670; Sat, 9 Jul 2011 08:14:13 +0000 (UTC) Date: Sat, 9 Jul 2011 08:14:13 +0000 From: Alexander Best To: Kevin Lo Message-ID: <20110709081413.GA84325@freebsd.org> References: <201107090743.p697huB2086379@svn.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201107090743.p697huB2086379@svn.freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r223877 - in head: include/rpc lib/libc/xdr X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 08:14:13 -0000 On Sat Jul 9 11, Kevin Lo wrote: > Author: kevlo > Date: Sat Jul 9 07:43:56 2011 > New Revision: 223877 > URL: http://svn.freebsd.org/changeset/base/223877 > > Log: > - Add xdr_sizeof(3) to libc > - Document xdr_sizeof(3); from NetBSD > > Discussed with: kib > > Modified: > head/include/rpc/xdr.h > head/lib/libc/xdr/Makefile.inc > head/lib/libc/xdr/Symbol.map > head/lib/libc/xdr/xdr.3 > head/lib/libc/xdr/xdr_sizeof.c > > Modified: head/include/rpc/xdr.h > ============================================================================== > --- head/include/rpc/xdr.h Fri Jul 8 20:41:12 2011 (r223876) > +++ head/include/rpc/xdr.h Sat Jul 9 07:43:56 2011 (r223877) > @@ -285,43 +285,46 @@ struct xdr_discrim { > * These are the "generic" xdr routines. > */ > __BEGIN_DECLS > -extern bool_t xdr_void(void); > -extern bool_t xdr_int(XDR *, int *); > -extern bool_t xdr_u_int(XDR *, u_int *); > -extern bool_t xdr_long(XDR *, long *); > -extern bool_t xdr_u_long(XDR *, u_long *); > -extern bool_t xdr_short(XDR *, short *); > -extern bool_t xdr_u_short(XDR *, u_short *); > -extern bool_t xdr_int16_t(XDR *, int16_t *); > -extern bool_t xdr_u_int16_t(XDR *, u_int16_t *); > -extern bool_t xdr_uint16_t(XDR *, u_int16_t *); > -extern bool_t xdr_int32_t(XDR *, int32_t *); > -extern bool_t xdr_u_int32_t(XDR *, u_int32_t *); > -extern bool_t xdr_uint32_t(XDR *, u_int32_t *); > -extern bool_t xdr_int64_t(XDR *, int64_t *); > -extern bool_t xdr_u_int64_t(XDR *, u_int64_t *); > -extern bool_t xdr_uint64_t(XDR *, u_int64_t *); > -extern bool_t xdr_bool(XDR *, bool_t *); > -extern bool_t xdr_enum(XDR *, enum_t *); > -extern bool_t xdr_array(XDR *, char **, u_int *, u_int, u_int, xdrproc_t); > -extern bool_t xdr_bytes(XDR *, char **, u_int *, u_int); > -extern bool_t xdr_opaque(XDR *, char *, u_int); > -extern bool_t xdr_string(XDR *, char **, u_int); > -extern bool_t xdr_union(XDR *, enum_t *, char *, const struct xdr_discrim *, xdrproc_t); > -extern bool_t xdr_char(XDR *, char *); > -extern bool_t xdr_u_char(XDR *, u_char *); > -extern bool_t xdr_vector(XDR *, char *, u_int, u_int, xdrproc_t); > -extern bool_t xdr_float(XDR *, float *); > -extern bool_t xdr_double(XDR *, double *); > -extern bool_t xdr_quadruple(XDR *, long double *); > -extern bool_t xdr_reference(XDR *, char **, u_int, xdrproc_t); > -extern bool_t xdr_pointer(XDR *, char **, u_int, xdrproc_t); > -extern bool_t xdr_wrapstring(XDR *, char **); > -extern void xdr_free(xdrproc_t, void *); > -extern bool_t xdr_hyper(XDR *, quad_t *); > -extern bool_t xdr_u_hyper(XDR *, u_quad_t *); > -extern bool_t xdr_longlong_t(XDR *, quad_t *); > -extern bool_t xdr_u_longlong_t(XDR *, u_quad_t *); > +extern bool_t xdr_void(void); > +extern bool_t xdr_int(XDR *, int *); > +extern bool_t xdr_u_int(XDR *, u_int *); > +extern bool_t xdr_long(XDR *, long *); > +extern bool_t xdr_u_long(XDR *, u_long *); > +extern bool_t xdr_short(XDR *, short *); > +extern bool_t xdr_u_short(XDR *, u_short *); > +extern bool_t xdr_int16_t(XDR *, int16_t *); > +extern bool_t xdr_u_int16_t(XDR *, u_int16_t *); > +extern bool_t xdr_uint16_t(XDR *, u_int16_t *); > +extern bool_t xdr_int32_t(XDR *, int32_t *); > +extern bool_t xdr_u_int32_t(XDR *, u_int32_t *); > +extern bool_t xdr_uint32_t(XDR *, u_int32_t *); > +extern bool_t xdr_int64_t(XDR *, int64_t *); > +extern bool_t xdr_u_int64_t(XDR *, u_int64_t *); > +extern bool_t xdr_uint64_t(XDR *, u_int64_t *); > +extern bool_t xdr_bool(XDR *, bool_t *); > +extern bool_t xdr_enum(XDR *, enum_t *); > +extern bool_t xdr_array(XDR *, char **, u_int *, u_int, u_int, > + xdrproc_t); > +extern bool_t xdr_bytes(XDR *, char **, u_int *, u_int); > +extern bool_t xdr_opaque(XDR *, char *, u_int); > +extern bool_t xdr_string(XDR *, char **, u_int); > +extern bool_t xdr_union(XDR *, enum_t *, char *, > + const struct xdr_discrim *, xdrproc_t); > +extern bool_t xdr_char(XDR *, char *); > +extern bool_t xdr_u_char(XDR *, u_char *); > +extern bool_t xdr_vector(XDR *, char *, u_int, u_int, xdrproc_t); > +extern bool_t xdr_float(XDR *, float *); > +extern bool_t xdr_double(XDR *, double *); > +extern bool_t xdr_quadruple(XDR *, long double *); > +extern bool_t xdr_reference(XDR *, char **, u_int, xdrproc_t); > +extern bool_t xdr_pointer(XDR *, char **, u_int, xdrproc_t); > +extern bool_t xdr_wrapstring(XDR *, char **); > +extern void xdr_free(xdrproc_t, void *); > +extern bool_t xdr_hyper(XDR *, quad_t *); > +extern bool_t xdr_u_hyper(XDR *, u_quad_t *); > +extern bool_t xdr_longlong_t(XDR *, quad_t *); > +extern bool_t xdr_u_longlong_t(XDR *, u_quad_t *); > +extern unsigned long xdr_sizeof(xdrproc_t, void *); > __END_DECLS > > /* > > Modified: head/lib/libc/xdr/Makefile.inc > ============================================================================== > --- head/lib/libc/xdr/Makefile.inc Fri Jul 8 20:41:12 2011 (r223876) > +++ head/lib/libc/xdr/Makefile.inc Sat Jul 9 07:43:56 2011 (r223877) > @@ -3,7 +3,8 @@ > > .PATH: ${.CURDIR}/xdr ${.CURDIR}/. > SRCS+= xdr.c xdr_array.c xdr_float.c xdr_mem.c \ > - xdr_rec.c xdr_reference.c xdr_stdio.c > + xdr_rec.c xdr_reference.c xdr_sizeof.c \ > + xdr_stdio.c > > SYM_MAPS+= ${.CURDIR}/xdr/Symbol.map > > @@ -39,6 +40,7 @@ MLINKS+= rpc_xdr.3 xdr_accepted_reply.3 > xdr.3 xdr_reference.3 \ > xdr.3 xdr_setpos.3 \ > xdr.3 xdr_short.3 \ > + xdr.3 xdr_sizeof.3 \ > xdr.3 xdrstdio_create.3 \ > xdr.3 xdr_string.3 \ > xdr.3 xdr_u_char.3 \ > > Modified: head/lib/libc/xdr/Symbol.map > ============================================================================== > --- head/lib/libc/xdr/Symbol.map Fri Jul 8 20:41:12 2011 (r223876) > +++ head/lib/libc/xdr/Symbol.map Sat Jul 9 07:43:56 2011 (r223877) > @@ -42,7 +42,6 @@ FBSD_1.0 { > xdrrec_endofrecord; > xdr_reference; > xdr_pointer; > - /* xdr_sizeof; */ /* Why is xdr_sizeof.c not included in Makefileinc? */ > xdrstdio_create; > }; > > @@ -51,3 +50,7 @@ FBSD_1.1 { > xdr_uint32_t; > xdr_uint64_t; > }; > + > +FBSD_1.2 { > + xdr_sizeof; > +}; > > Modified: head/lib/libc/xdr/xdr.3 > ============================================================================== > --- head/lib/libc/xdr/xdr.3 Fri Jul 8 20:41:12 2011 (r223876) > +++ head/lib/libc/xdr/xdr.3 Sat Jul 9 07:43:56 2011 (r223877) how about adding a HISTORY section to the xdr(3) man page, with a note that xdr_sizeof() was added in freebsd 9.0 and was optained from netbsd? > @@ -31,6 +31,7 @@ > .Nm xdr_reference , > .Nm xdr_setpos , > .Nm xdr_short , > +.Nm xdr_sizeof, > .Nm xdrstdio_create , > .Nm xdr_string , > .Nm xdr_u_char , > @@ -561,6 +562,18 @@ A filter primitive that translates betwe > integers and their external representations. > This routine returns one if it succeeds, zero otherwise. > .Pp > +.It Xo > +.Ft unsigned long > +.Xc > +.It Xo > +.Fn xdr_sizeof "xdrproc_t func" "void *data" > +.Xc > +.Pp > +This routine returns the amount of memory required to encode > +.Fa data > +using filter > +.Fa func . > +.Pp > .It Li "#ifdef _STDIO_H_" > .It Li "/* XDR using stdio library */" > .It Xo > > Modified: head/lib/libc/xdr/xdr_sizeof.c > ============================================================================== > --- head/lib/libc/xdr/xdr_sizeof.c Fri Jul 8 20:41:12 2011 (r223876) > +++ head/lib/libc/xdr/xdr_sizeof.c Sat Jul 9 07:43:56 2011 (r223877) > @@ -94,7 +94,7 @@ x_inline(xdrs, len) > if (xdrs->x_op != XDR_ENCODE) { > return (NULL); > } > - if (len < (u_int)xdrs->x_base) { > + if (len < (u_int)(uintptr_t)xdrs->x_base) { > /* x_private was already allocated */ > xdrs->x_handy += len; > return ((int32_t *) xdrs->x_private); > @@ -106,7 +106,7 @@ x_inline(xdrs, len) > xdrs->x_base = 0; > return (NULL); > } > - xdrs->x_base = (caddr_t) len; > + xdrs->x_base = (caddr_t)(uintptr_t)len; > xdrs->x_handy += len; > return ((int32_t *) xdrs->x_private); > } From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 08:42:23 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B3D761065670; Sat, 9 Jul 2011 08:42:23 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A39B28FC14; Sat, 9 Jul 2011 08:42:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p698gNUd089810; Sat, 9 Jul 2011 08:42:23 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p698gNBq089808; Sat, 9 Jul 2011 08:42:23 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201107090842.p698gNBq089808@svn.freebsd.org> From: Edward Tomasz Napierala Date: Sat, 9 Jul 2011 08:42:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223878 - head/lib/libutil X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 08:42:23 -0000 Author: trasz Date: Sat Jul 9 08:42:23 2011 New Revision: 223878 URL: http://svn.freebsd.org/changeset/base/223878 Log: Add missing "swapuse" resource limit. Modified: head/lib/libutil/login.conf.5 Modified: head/lib/libutil/login.conf.5 ============================================================================== --- head/lib/libutil/login.conf.5 Sat Jul 9 07:43:56 2011 (r223877) +++ head/lib/libutil/login.conf.5 Sat Jul 9 08:42:23 2011 (r223878) @@ -19,7 +19,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 20, 2008 +.Dd July 8, 2011 .Dt LOGIN.CONF 5 .Os .Sh NAME @@ -190,6 +190,7 @@ notation may be used. .It "vmemoryuse size Maximum permitted total VM usage per process. .It "stacksize size Maximum stack size limit. .It "pseudoterminals number Maximum number of pseudo-terminals. +.It "swapuse size Maximum swap space size limit. .El .Pp These resource limit entries actually specify both the maximum From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 12:05:53 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A67871065674; Sat, 9 Jul 2011 12:05:53 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 95B898FC13; Sat, 9 Jul 2011 12:05:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p69C5rKR099567; Sat, 9 Jul 2011 12:05:53 GMT (envelope-from se@svn.freebsd.org) Received: (from se@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p69C5rRi099564; Sat, 9 Jul 2011 12:05:53 GMT (envelope-from se@svn.freebsd.org) Message-Id: <201107091205.p69C5rRi099564@svn.freebsd.org> From: Stefan Esser Date: Sat, 9 Jul 2011 12:05:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223881 - head/bin/expr X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 12:05:53 -0000 Author: se Date: Sat Jul 9 12:05:53 2011 New Revision: 223881 URL: http://svn.freebsd.org/changeset/base/223881 Log: Make /bin/expr support 64bit numeric range and range checks by default, again. This brings back the behaviour of expr in FreeBSD-4, which had been reverted due to an assumed incompatbility with POSIX.1 for FreeBSD-5. This issue has been discussed in the freebsd-standards list, and the consensus was, that POSIX.1 is in fact not violated by this extension, since it affects only cases of POSIX undefined behaviour (overflow of signed long). Other operating systems did upgrade their versions of expr to support 64bit range, after it had been initially brought to FreeBSD. They have used it for a decade without problems, meanwhile. The -e option is retained, but it will only select less strict checking of numeric parameters (leading white-space, leading "+" are allowed and skipped, an empty string is considered to represent 0 in numeric context.) The call of check_utility_compat() as a means of establishing backwards compatibility with FreeBSD-4 is considered obsolete, but preserved in this commit. It is expected to be removed in a later revision of this file. Reviewed by: bde, das, jilles MFC after: 2 month (those parts that do not violate POLA) Modified: head/bin/expr/expr.1 head/bin/expr/expr.y Modified: head/bin/expr/expr.1 ============================================================================== --- head/bin/expr/expr.1 Sat Jul 9 12:02:40 2011 (r223880) +++ head/bin/expr/expr.1 Sat Jul 9 12:05:53 2011 (r223881) @@ -50,25 +50,25 @@ and writes the result on standard output All operators and operands must be passed as separate arguments. Several of the operators have special meaning to command interpreters and must therefore be quoted appropriately. -All integer operands are interpreted in base 10. +All integer operands are interpreted in base 10 and must consist of only +an optional leading minus sign followed by one or more digits (unless +less strict parsing has been enabled for backwards compatibilty with +prior versions of +.Nm +in +.Fx ) . .Pp -Arithmetic operations are performed using signed integer math. -If the -.Fl e -flag is specified, arithmetic uses the C +Arithmetic operations are performed using signed integer math with a +range according to the C .Vt intmax_t -data type (the largest integral type available), and -.Nm -will detect arithmetic overflow and return an error indication. -If a numeric operand is specified which is so large as to overflow -conversion to an integer, it is parsed as a string instead. -If +data type (the largest signed integral type available). +All conversions and operations are checked for overflow. +Overflow results in program termination with an error message on stdout +and with an error status. +.Pp +The .Fl e -is not specified, arithmetic operations and parsing of integer -arguments will overflow silently according to the rules of the C -standard, using the -.Vt long -data type. +option enables backwards compatible behaviour as detailed below. .Pp Operators are listed below in order of increasing precedence; all are left-associative. @@ -82,7 +82,9 @@ Return the evaluation of .Ar expr1 if it is neither an empty string nor zero; otherwise, returns the evaluation of -.Ar expr2 . +.Ar expr2 +if it is not an empty string; +otherwise, returns zero. .It Ar expr1 Li & Ar expr2 Return the evaluation of .Ar expr1 @@ -163,25 +165,26 @@ function (with a .Fa utility argument of .Dq Li expr ) -is used to determine whether compatibility mode should be enabled. +is used to determine whether backwards compatibility mode should be enabled. This feature is intended for use as a transition and debugging aid, when .Nm is used in complex scripts which cannot easily be recast to avoid the non-portable usage. -Enabling compatibility mode -also implicitly enables the +Enabling backwards compatibility mode also implicitly enables the .Fl e option, since this matches the historic behavior of .Nm in -.Fx . +.Fx . This option makes number parsing less strict and permits leading +white space and an optional leading plus sign. In addition, empty operands +have an implied value of zero in numeric context. For historical reasons, defining the environment variable .Ev EXPR_COMPAT -also enables compatibility mode. +also enables backwards compatibility mode. .Sh ENVIRONMENT .Bl -tag -width ".Ev EXPR_COMPAT" .It Ev EXPR_COMPAT -If set, enables compatibility mode. +If set, enables backwards compatibility mode. .El .Sh EXIT STATUS The @@ -270,8 +273,37 @@ expands to the required number. The .Nm utility conforms to -.St -p1003.1-2001 , -provided that compatibility mode is not enabled. +.St -p1003.1-2008 , +provided that backwards compatibility mode is not enabled. +.Pp +Backwards compatibility mode performs less strict checks of numeric arguments: +.Bl -bullet +.It +An empty operand string is interpreted as 0. +.El +.Bl -bullet +.It +Leading white space and/or a plus sign before an otherwise valid positive +numberic operand are allowed and will be ignored. +.El +.Pp +The extended arithmetic range and overflow checks do not conflict with +POSIX's requirement that arithmetic be done using signed longs, since +they only make a difference to the result in cases where using signed +longs would give undefined behavior. +.Pp +According to the +.Tn POSIX +standard, the use of string arguments +.Va length , +.Va substr , +.Va index , +or +.Va match +produces undefined results. In this version of +.Nm , +these arguments are treated just as their respective string values. +.Pp The .Fl e flag is an extension. Modified: head/bin/expr/expr.y ============================================================================== --- head/bin/expr/expr.y Sat Jul 9 12:02:40 2011 (r223880) +++ head/bin/expr/expr.y Sat Jul 9 12:05:53 2011 (r223881) @@ -42,13 +42,15 @@ struct val { struct val *result; +void assert_to_integer(struct val *); int chk_div(intmax_t, intmax_t); int chk_minus(intmax_t, intmax_t, intmax_t); int chk_plus(intmax_t, intmax_t, intmax_t); int chk_times(intmax_t, intmax_t, intmax_t); void free_value(struct val *); -int is_zero_or_null(struct val *); +int is_integer(const char *); int isstring(struct val *); +int is_zero_or_null(struct val *); struct val *make_integer(intmax_t); struct val *make_str(const char *); struct val *op_and(struct val *, struct val *); @@ -65,13 +67,13 @@ struct val *op_or(struct val *, struct v struct val *op_plus(struct val *, struct val *); struct val *op_rem(struct val *, struct val *); struct val *op_times(struct val *, struct val *); -intmax_t to_integer(struct val *); +int to_integer(struct val *); void to_string(struct val *); int yyerror(const char *); int yylex(void); int yyparse(void); -static int eflag; +static int nonposix; char **av; %} @@ -134,37 +136,16 @@ struct val * make_str(const char *s) { struct val *vp; - char *ep; vp = (struct val *) malloc (sizeof (*vp)); if (vp == NULL || ((vp->u.s = strdup (s)) == NULL)) { errx(ERR_EXIT, "malloc() failed"); } - /* - * Previously we tried to scan the string to see if it ``looked like'' - * an integer (erroneously, as it happened). Let strtoimax() do the - * dirty work. We could cache the value, except that we are using - * a union and need to preserve the original string form until we - * are certain that it is not needed. - * - * IEEE Std.1003.1-2001 says: - * /integer/ An argument consisting only of an (optional) unary minus - * followed by digits. - * - * This means that arguments which consist of digits followed by - * non-digits MUST NOT be considered integers. strtoimax() will - * figure this out for us. - */ - if (eflag) - (void)strtoimax(s, &ep, 10); + if (is_integer(s)) + vp->type = numeric_string; else - (void)strtol(s, &ep, 10); - - if (*ep != '\0') vp->type = string; - else - vp->type = numeric_string; return vp; } @@ -178,31 +159,33 @@ free_value(struct val *vp) } -intmax_t +int to_integer(struct val *vp) { intmax_t i; - if (vp->type == integer) - return 1; - - if (vp->type == string) - return 0; - - /* vp->type == numeric_string, make it numeric */ - errno = 0; - if (eflag) { + /* we can only convert numeric_string to integer, here */ + if (vp->type == numeric_string) { + errno = 0; i = strtoimax(vp->u.s, (char **)NULL, 10); - if (errno == ERANGE) - err(ERR_EXIT, NULL); - } else { - i = strtol(vp->u.s, (char **)NULL, 10); + /* just keep as numeric_string, if the conversion fails */ + if (errno != ERANGE) { + free (vp->u.s); + vp->u.i = i; + vp->type = integer; + } } + return (vp->type == integer); +} - free (vp->u.s); - vp->u.i = i; - vp->type = integer; - return 1; + +void +assert_to_integer(struct val *vp) +{ + if (vp->type == string) + errx(ERR_EXIT, "not a decimal number: '%s'", vp->u.s); + if (!to_integer(vp)) + errx(ERR_EXIT, "operand too large: '%s'", vp->u.s); } void @@ -230,6 +213,25 @@ to_string(struct val *vp) int +is_integer(const char *s) +{ + if (nonposix) { + if (*s == '\0') + return (1); + while (isspace((unsigned char)*s)) + s++; + } + if (*s == '-' || (nonposix && *s == '+')) + s++; + if (*s == '\0') + return (0); + while (isdigit((unsigned char)*s)) + s++; + return (*s == '\0'); +} + + +int isstring(struct val *vp) { /* only TRUE if this string is not a valid integer */ @@ -282,12 +284,12 @@ main(int argc, char *argv[]) if (getenv("EXPR_COMPAT") != NULL || check_utility_compat("expr")) { av = argv + 1; - eflag = 1; + nonposix = 1; } else { while ((c = getopt(argc, argv, "e")) != -1) switch (c) { case 'e': - eflag = 1; + nonposix = 1; break; default: @@ -318,15 +320,17 @@ yyerror(const char *s __unused) struct val * op_or(struct val *a, struct val *b) { - if (is_zero_or_null (a)) { - free_value (a); - return (b); - } else { - free_value (b); + if (!is_zero_or_null(a)) { + free_value(b); return (a); } + free_value(a); + if (!is_zero_or_null(b)) + return (b); + free_value(b); + return (make_integer((intmax_t)0)); } - + struct val * op_and(struct val *a, struct val *b) { @@ -350,8 +354,8 @@ op_eq(struct val *a, struct val *b) to_string (b); r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) == 0)); } else { - (void)to_integer(a); - (void)to_integer(b); + assert_to_integer(a); + assert_to_integer(b); r = make_integer ((intmax_t)(a->u.i == b->u.i)); } @@ -370,8 +374,8 @@ op_gt(struct val *a, struct val *b) to_string (b); r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) > 0)); } else { - (void)to_integer(a); - (void)to_integer(b); + assert_to_integer(a); + assert_to_integer(b); r = make_integer ((intmax_t)(a->u.i > b->u.i)); } @@ -390,8 +394,8 @@ op_lt(struct val *a, struct val *b) to_string (b); r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) < 0)); } else { - (void)to_integer(a); - (void)to_integer(b); + assert_to_integer(a); + assert_to_integer(b); r = make_integer ((intmax_t)(a->u.i < b->u.i)); } @@ -410,8 +414,8 @@ op_ge(struct val *a, struct val *b) to_string (b); r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) >= 0)); } else { - (void)to_integer(a); - (void)to_integer(b); + assert_to_integer(a); + assert_to_integer(b); r = make_integer ((intmax_t)(a->u.i >= b->u.i)); } @@ -430,8 +434,8 @@ op_le(struct val *a, struct val *b) to_string (b); r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) <= 0)); } else { - (void)to_integer(a); - (void)to_integer(b); + assert_to_integer(a); + assert_to_integer(b); r = make_integer ((intmax_t)(a->u.i <= b->u.i)); } @@ -450,8 +454,8 @@ op_ne(struct val *a, struct val *b) to_string (b); r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) != 0)); } else { - (void)to_integer(a); - (void)to_integer(b); + assert_to_integer(a); + assert_to_integer(b); r = make_integer ((intmax_t)(a->u.i != b->u.i)); } @@ -479,17 +483,13 @@ op_plus(struct val *a, struct val *b) { struct val *r; - if (!to_integer(a) || !to_integer(b)) { - errx(ERR_EXIT, "non-numeric argument"); - } + assert_to_integer(a); + assert_to_integer(b); - if (eflag) { - r = make_integer(a->u.i + b->u.i); - if (chk_plus(a->u.i, b->u.i, r->u.i)) { - errx(ERR_EXIT, "overflow"); - } - } else - r = make_integer((long)a->u.i + (long)b->u.i); + r = make_integer(a->u.i + b->u.i); + if (chk_plus(a->u.i, b->u.i, r->u.i)) { + errx(ERR_EXIT, "overflow"); + } free_value (a); free_value (b); @@ -516,17 +516,13 @@ op_minus(struct val *a, struct val *b) { struct val *r; - if (!to_integer(a) || !to_integer(b)) { - errx(ERR_EXIT, "non-numeric argument"); - } + assert_to_integer(a); + assert_to_integer(b); - if (eflag) { - r = make_integer(a->u.i - b->u.i); - if (chk_minus(a->u.i, b->u.i, r->u.i)) { - errx(ERR_EXIT, "overflow"); - } - } else - r = make_integer((long)a->u.i - (long)b->u.i); + r = make_integer(a->u.i - b->u.i); + if (chk_minus(a->u.i, b->u.i, r->u.i)) { + errx(ERR_EXIT, "overflow"); + } free_value (a); free_value (b); @@ -550,17 +546,13 @@ op_times(struct val *a, struct val *b) { struct val *r; - if (!to_integer(a) || !to_integer(b)) { - errx(ERR_EXIT, "non-numeric argument"); - } + assert_to_integer(a); + assert_to_integer(b); - if (eflag) { - r = make_integer(a->u.i * b->u.i); - if (chk_times(a->u.i, b->u.i, r->u.i)) { - errx(ERR_EXIT, "overflow"); - } - } else - r = make_integer((long)a->u.i * (long)b->u.i); + r = make_integer(a->u.i * b->u.i); + if (chk_times(a->u.i, b->u.i, r->u.i)) { + errx(ERR_EXIT, "overflow"); + } free_value (a); free_value (b); @@ -583,21 +575,16 @@ op_div(struct val *a, struct val *b) { struct val *r; - if (!to_integer(a) || !to_integer(b)) { - errx(ERR_EXIT, "non-numeric argument"); - } + assert_to_integer(a); + assert_to_integer(b); if (b->u.i == 0) { errx(ERR_EXIT, "division by zero"); } - - if (eflag) { - r = make_integer(a->u.i / b->u.i); - if (chk_div(a->u.i, b->u.i)) { - errx(ERR_EXIT, "overflow"); - } - } else - r = make_integer((long)a->u.i / (long)b->u.i); + if (chk_div(a->u.i, b->u.i)) { + errx(ERR_EXIT, "overflow"); + } + r = make_integer(a->u.i / b->u.i); free_value (a); free_value (b); @@ -609,19 +596,12 @@ op_rem(struct val *a, struct val *b) { struct val *r; - if (!to_integer(a) || !to_integer(b)) { - errx(ERR_EXIT, "non-numeric argument"); - } - + assert_to_integer(a); + assert_to_integer(b); if (b->u.i == 0) { errx(ERR_EXIT, "division by zero"); } - - if (eflag) - r = make_integer(a->u.i % b->u.i); - /* chk_rem necessary ??? */ - else - r = make_integer((long)a->u.i % (long)b->u.i); + r = make_integer(a->u.i % b->u.i); free_value (a); free_value (b); From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 12:14:57 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7C5CD1065672; Sat, 9 Jul 2011 12:14:57 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6C0318FC0A; Sat, 9 Jul 2011 12:14:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p69CEvDo099920; Sat, 9 Jul 2011 12:14:57 GMT (envelope-from se@svn.freebsd.org) Received: (from se@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p69CEvfw099918; Sat, 9 Jul 2011 12:14:57 GMT (envelope-from se@svn.freebsd.org) Message-Id: <201107091214.p69CEvfw099918@svn.freebsd.org> From: Stefan Esser Date: Sat, 9 Jul 2011 12:14:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223882 - head/bin/expr X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 12:14:57 -0000 Author: se Date: Sat Jul 9 12:14:57 2011 New Revision: 223882 URL: http://svn.freebsd.org/changeset/base/223882 Log: Some refactoring for easier maintenance of the code. This is a follow-up to re-establishment of 64bit arithmetic, but is committed separately, to not obscure that conversion. This commit does not change the observed behaviour of expr in any way. Style will be fixed in a follow-up commit. Modified: head/bin/expr/expr.y Modified: head/bin/expr/expr.y ============================================================================== --- head/bin/expr/expr.y Sat Jul 9 12:05:53 2011 (r223881) +++ head/bin/expr/expr.y Sat Jul 9 12:14:57 2011 (r223882) @@ -40,13 +40,16 @@ struct val { } u; } ; +char **av; +int nonposix; struct val *result; void assert_to_integer(struct val *); -int chk_div(intmax_t, intmax_t); -int chk_minus(intmax_t, intmax_t, intmax_t); -int chk_plus(intmax_t, intmax_t, intmax_t); -int chk_times(intmax_t, intmax_t, intmax_t); +void assert_div(intmax_t, intmax_t); +void assert_minus(intmax_t, intmax_t, intmax_t); +void assert_plus(intmax_t, intmax_t, intmax_t); +void assert_times(intmax_t, intmax_t, intmax_t); +int compare_vals(struct val *, struct val *); void free_value(struct val *); int is_integer(const char *); int isstring(struct val *); @@ -73,8 +76,6 @@ int yyerror(const char *); int yylex(void); int yyparse(void); -static int nonposix; -char **av; %} %union @@ -344,138 +345,77 @@ op_and(struct val *a, struct val *b) } } -struct val * -op_eq(struct val *a, struct val *b) +int +compare_vals(struct val *a, struct val *b) { - struct val *r; + int r; - if (isstring (a) || isstring (b)) { - to_string (a); - to_string (b); - r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) == 0)); + if (isstring(a) || isstring(b)) { + to_string(a); + to_string(b); + r = strcoll(a->u.s, b->u.s); } else { assert_to_integer(a); assert_to_integer(b); - r = make_integer ((intmax_t)(a->u.i == b->u.i)); + if (a->u.i > b->u.i) + r = 1; + else if (a->u.i < b->u.i) + r = -1; + else + r = 0; } - free_value (a); - free_value (b); - return r; + free_value(a); + free_value(b); + return (r); } struct val * -op_gt(struct val *a, struct val *b) +op_eq(struct val *a, struct val *b) { - struct val *r; - - if (isstring (a) || isstring (b)) { - to_string (a); - to_string (b); - r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) > 0)); - } else { - assert_to_integer(a); - assert_to_integer(b); - r = make_integer ((intmax_t)(a->u.i > b->u.i)); - } + return (make_integer((intmax_t)(compare_vals(a, b) == 0))); +} - free_value (a); - free_value (b); - return r; +struct val * +op_gt(struct val *a, struct val *b) +{ + return (make_integer((intmax_t)(compare_vals(a, b) > 0))); } struct val * op_lt(struct val *a, struct val *b) { - struct val *r; - - if (isstring (a) || isstring (b)) { - to_string (a); - to_string (b); - r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) < 0)); - } else { - assert_to_integer(a); - assert_to_integer(b); - r = make_integer ((intmax_t)(a->u.i < b->u.i)); - } - - free_value (a); - free_value (b); - return r; + return (make_integer((intmax_t)(compare_vals(a, b) < 0))); } struct val * op_ge(struct val *a, struct val *b) { - struct val *r; - - if (isstring (a) || isstring (b)) { - to_string (a); - to_string (b); - r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) >= 0)); - } else { - assert_to_integer(a); - assert_to_integer(b); - r = make_integer ((intmax_t)(a->u.i >= b->u.i)); - } - - free_value (a); - free_value (b); - return r; + return (make_integer((intmax_t)(compare_vals(a, b) >= 0))); } struct val * op_le(struct val *a, struct val *b) { - struct val *r; - - if (isstring (a) || isstring (b)) { - to_string (a); - to_string (b); - r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) <= 0)); - } else { - assert_to_integer(a); - assert_to_integer(b); - r = make_integer ((intmax_t)(a->u.i <= b->u.i)); - } - - free_value (a); - free_value (b); - return r; + return (make_integer((intmax_t)(compare_vals(a, b) <= 0))); } struct val * op_ne(struct val *a, struct val *b) { - struct val *r; - - if (isstring (a) || isstring (b)) { - to_string (a); - to_string (b); - r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) != 0)); - } else { - assert_to_integer(a); - assert_to_integer(b); - r = make_integer ((intmax_t)(a->u.i != b->u.i)); - } - - free_value (a); - free_value (b); - return r; + return (make_integer((intmax_t)(compare_vals(a, b) != 0))); } -int -chk_plus(intmax_t a, intmax_t b, intmax_t r) +void +assert_plus(intmax_t a, intmax_t b, intmax_t r) { - - /* sum of two positive numbers must be positive */ - if (a > 0 && b > 0 && r <= 0) - return 1; - /* sum of two negative numbers must be negative */ - if (a < 0 && b < 0 && r >= 0) - return 1; - /* all other cases are OK */ - return 0; + /* + * sum of two positive numbers must be positive, + * sum of two negative numbers must be negative + */ + if ((a > 0 && b > 0 && r <= 0) || + (a < 0 && b < 0 && r >= 0)) + errx(ERR_EXIT, "overflow"); } struct val * @@ -487,28 +427,22 @@ op_plus(struct val *a, struct val *b) assert_to_integer(b); r = make_integer(a->u.i + b->u.i); - if (chk_plus(a->u.i, b->u.i, r->u.i)) { - errx(ERR_EXIT, "overflow"); - } + assert_plus(a->u.i, b->u.i, r->u.i); free_value (a); free_value (b); return r; } -int -chk_minus(intmax_t a, intmax_t b, intmax_t r) +void +assert_minus(intmax_t a, intmax_t b, intmax_t r) { /* special case subtraction of INTMAX_MIN */ - if (b == INTMAX_MIN) { - if (a >= 0) - return 1; - else - return 0; - } - /* this is allowed for b != INTMAX_MIN */ - return chk_plus (a, -b, r); + if (b == INTMAX_MIN && a < 0) + errx(ERR_EXIT, "overflow"); + /* check addition of negative subtrahend */ + assert_plus(a, -b, r); } struct val * @@ -520,25 +454,22 @@ op_minus(struct val *a, struct val *b) assert_to_integer(b); r = make_integer(a->u.i - b->u.i); - if (chk_minus(a->u.i, b->u.i, r->u.i)) { - errx(ERR_EXIT, "overflow"); - } + assert_minus(a->u.i, b->u.i, r->u.i); free_value (a); free_value (b); return r; } -int -chk_times(intmax_t a, intmax_t b, intmax_t r) +void +assert_times(intmax_t a, intmax_t b, intmax_t r) { - /* special case: first operand is 0, no overflow possible */ - if (a == 0) - return 0; - /* verify that result of division matches second operand */ - if (r / a != b) - return 1; - return 0; + /* + * if first operand is 0, no overflow is possible, + * else result of division test must match second operand + */ + if (a != 0 && r / a != b) + errx(ERR_EXIT, "overflow"); } struct val * @@ -550,24 +481,21 @@ op_times(struct val *a, struct val *b) assert_to_integer(b); r = make_integer(a->u.i * b->u.i); - if (chk_times(a->u.i, b->u.i, r->u.i)) { - errx(ERR_EXIT, "overflow"); - } + assert_times(a->u.i, b->u.i, r->u.i); free_value (a); free_value (b); return (r); } -int -chk_div(intmax_t a, intmax_t b) +void +assert_div(intmax_t a, intmax_t b) { - /* div by zero has been taken care of before */ + if (b == 0) + errx(ERR_EXIT, "division by zero"); /* only INTMAX_MIN / -1 causes overflow */ if (a == INTMAX_MIN && b == -1) - return 1; - /* everything else is OK */ - return 0; + errx(ERR_EXIT, "overflow"); } struct val * @@ -578,12 +506,8 @@ op_div(struct val *a, struct val *b) assert_to_integer(a); assert_to_integer(b); - if (b->u.i == 0) { - errx(ERR_EXIT, "division by zero"); - } - if (chk_div(a->u.i, b->u.i)) { - errx(ERR_EXIT, "overflow"); - } + /* assert based on operands only, not on result */ + assert_div(a->u.i, b->u.i); r = make_integer(a->u.i / b->u.i); free_value (a); @@ -598,9 +522,8 @@ op_rem(struct val *a, struct val *b) assert_to_integer(a); assert_to_integer(b); - if (b->u.i == 0) { - errx(ERR_EXIT, "division by zero"); - } + /* pass a=1 to only check for div by zero */ + assert_div(1, b->u.i); r = make_integer(a->u.i % b->u.i); free_value (a); From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 12:20:15 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CDFE5106564A; Sat, 9 Jul 2011 12:20:15 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BD9C18FC08; Sat, 9 Jul 2011 12:20:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p69CKFbm000206; Sat, 9 Jul 2011 12:20:15 GMT (envelope-from se@svn.freebsd.org) Received: (from se@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p69CKF1o000204; Sat, 9 Jul 2011 12:20:15 GMT (envelope-from se@svn.freebsd.org) Message-Id: <201107091220.p69CKF1o000204@svn.freebsd.org> From: Stefan Esser Date: Sat, 9 Jul 2011 12:20:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223883 - head/bin/expr X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 12:20:15 -0000 Author: se Date: Sat Jul 9 12:20:15 2011 New Revision: 223883 URL: http://svn.freebsd.org/changeset/base/223883 Log: Fix style, since this file has just been touched in a major way. No actual code changes. Modified: head/bin/expr/expr.y Modified: head/bin/expr/expr.y ============================================================================== --- head/bin/expr/expr.y Sat Jul 9 12:14:57 2011 (r223882) +++ head/bin/expr/expr.y Sat Jul 9 12:20:15 2011 (r223883) @@ -1,6 +1,6 @@ %{ /*- - * Written by Pace Willisson (pace@blitz.com) + * Written by Pace Willisson (pace@blitz.com) * and placed in the public domain. * * Largely rewritten by J.T. Conklin (jtc@wimsey.com) @@ -21,7 +21,7 @@ #include #include #include - + /* * POSIX specifies a specific error code for syntax errors. We exit * with this code for all errors. @@ -42,7 +42,7 @@ struct val { char **av; int nonposix; -struct val *result; +struct val *result; void assert_to_integer(struct val *); void assert_div(intmax_t, intmax_t); @@ -52,7 +52,7 @@ void assert_times(intmax_t, intmax_t, i int compare_vals(struct val *, struct val *); void free_value(struct val *); int is_integer(const char *); -int isstring(struct val *); +int is_string(struct val *); int is_zero_or_null(struct val *); struct val *make_integer(intmax_t); struct val *make_str(const char *); @@ -99,23 +99,22 @@ start: expr { result = $$; } expr: TOKEN | '(' expr ')' { $$ = $2; } - | expr '|' expr { $$ = op_or ($1, $3); } - | expr '&' expr { $$ = op_and ($1, $3); } - | expr '=' expr { $$ = op_eq ($1, $3); } - | expr '>' expr { $$ = op_gt ($1, $3); } - | expr '<' expr { $$ = op_lt ($1, $3); } - | expr GE expr { $$ = op_ge ($1, $3); } - | expr LE expr { $$ = op_le ($1, $3); } - | expr NE expr { $$ = op_ne ($1, $3); } - | expr '+' expr { $$ = op_plus ($1, $3); } - | expr '-' expr { $$ = op_minus ($1, $3); } - | expr '*' expr { $$ = op_times ($1, $3); } - | expr '/' expr { $$ = op_div ($1, $3); } - | expr '%' expr { $$ = op_rem ($1, $3); } - | expr ':' expr { $$ = op_colon ($1, $3); } + | expr '|' expr { $$ = op_or($1, $3); } + | expr '&' expr { $$ = op_and($1, $3); } + | expr '=' expr { $$ = op_eq($1, $3); } + | expr '>' expr { $$ = op_gt($1, $3); } + | expr '<' expr { $$ = op_lt($1, $3); } + | expr GE expr { $$ = op_ge($1, $3); } + | expr LE expr { $$ = op_le($1, $3); } + | expr NE expr { $$ = op_ne($1, $3); } + | expr '+' expr { $$ = op_plus($1, $3); } + | expr '-' expr { $$ = op_minus($1, $3); } + | expr '*' expr { $$ = op_times($1, $3); } + | expr '/' expr { $$ = op_div($1, $3); } + | expr '%' expr { $$ = op_rem($1, $3); } + | expr ':' expr { $$ = op_colon($1, $3); } ; - %% struct val * @@ -123,14 +122,13 @@ make_integer(intmax_t i) { struct val *vp; - vp = (struct val *) malloc (sizeof (*vp)); - if (vp == NULL) { + vp = (struct val *)malloc(sizeof(*vp)); + if (vp == NULL) errx(ERR_EXIT, "malloc() failed"); - } vp->type = integer; vp->u.i = i; - return vp; + return (vp); } struct val * @@ -138,28 +136,25 @@ make_str(const char *s) { struct val *vp; - vp = (struct val *) malloc (sizeof (*vp)); - if (vp == NULL || ((vp->u.s = strdup (s)) == NULL)) { + vp = (struct val *)malloc(sizeof(*vp)); + if (vp == NULL || ((vp->u.s = strdup(s)) == NULL)) errx(ERR_EXIT, "malloc() failed"); - } if (is_integer(s)) vp->type = numeric_string; else vp->type = string; - return vp; + return (vp); } - void free_value(struct val *vp) { if (vp->type == string || vp->type == numeric_string) - free (vp->u.s); + free(vp->u.s); } - int to_integer(struct val *vp) { @@ -171,7 +166,7 @@ to_integer(struct val *vp) i = strtoimax(vp->u.s, (char **)NULL, 10); /* just keep as numeric_string, if the conversion fails */ if (errno != ERANGE) { - free (vp->u.s); + free(vp->u.s); vp->u.i = i; vp->type = integer; } @@ -179,7 +174,6 @@ to_integer(struct val *vp) return (vp->type == integer); } - void assert_to_integer(struct val *vp) { @@ -212,7 +206,6 @@ to_string(struct val *vp) vp->u.s = tmp; } - int is_integer(const char *s) { @@ -231,15 +224,13 @@ is_integer(const char *s) return (*s == '\0'); } - int -isstring(struct val *vp) +is_string(struct val *vp) { /* only TRUE if this string is not a valid integer */ return (vp->type == string); } - int yylex(void) { @@ -250,10 +241,10 @@ yylex(void) p = *av++; - if (strlen (p) == 1) { - if (strchr ("|&=<>+-*/%:()", *p)) + if (strlen(p) == 1) { + if (strchr("|&=<>+-*/%:()", *p)) return (*p); - } else if (strlen (p) == 2 && p[1] == '=') { + } else if (strlen(p) == 2 && p[1] == '=') { switch (*p) { case '>': return (GE); case '<': return (LE); @@ -261,19 +252,17 @@ yylex(void) } } - yylval.val = make_str (p); + yylval.val = make_str(p); return (TOKEN); } int is_zero_or_null(struct val *vp) { - if (vp->type == integer) { + if (vp->type == integer) return (vp->u.i == 0); - } else { - return (*vp->u.s == 0 || (to_integer (vp) && vp->u.i == 0)); - } - /* NOTREACHED */ + + return (*vp->u.s == 0 || (to_integer(vp) && vp->u.i == 0)); } int @@ -281,23 +270,22 @@ main(int argc, char *argv[]) { int c; - setlocale (LC_ALL, ""); + setlocale(LC_ALL, ""); if (getenv("EXPR_COMPAT") != NULL || check_utility_compat("expr")) { av = argv + 1; nonposix = 1; } else { - while ((c = getopt(argc, argv, "e")) != -1) + while ((c = getopt(argc, argv, "e")) != -1) { switch (c) { case 'e': nonposix = 1; break; - default: - fprintf(stderr, + errx(ERR_EXIT, "usage: expr [-e] expression\n"); - exit(ERR_EXIT); } + } av = argv + optind; } @@ -317,7 +305,6 @@ yyerror(const char *s __unused) errx(ERR_EXIT, "syntax error"); } - struct val * op_or(struct val *a, struct val *b) { @@ -335,12 +322,12 @@ op_or(struct val *a, struct val *b) struct val * op_and(struct val *a, struct val *b) { - if (is_zero_or_null (a) || is_zero_or_null (b)) { - free_value (a); - free_value (b); - return (make_integer ((intmax_t)0)); + if (is_zero_or_null(a) || is_zero_or_null(b)) { + free_value(a); + free_value(b); + return (make_integer((intmax_t)0)); } else { - free_value (b); + free_value(b); return (a); } } @@ -350,7 +337,7 @@ compare_vals(struct val *a, struct val * { int r; - if (isstring(a) || isstring(b)) { + if (is_string(a) || is_string(b)) { to_string(a); to_string(b); r = strcoll(a->u.s, b->u.s); @@ -425,19 +412,17 @@ op_plus(struct val *a, struct val *b) assert_to_integer(a); assert_to_integer(b); - r = make_integer(a->u.i + b->u.i); assert_plus(a->u.i, b->u.i, r->u.i); - free_value (a); - free_value (b); - return r; + free_value(a); + free_value(b); + return (r); } void assert_minus(intmax_t a, intmax_t b, intmax_t r) { - /* special case subtraction of INTMAX_MIN */ if (b == INTMAX_MIN && a < 0) errx(ERR_EXIT, "overflow"); @@ -452,13 +437,12 @@ op_minus(struct val *a, struct val *b) assert_to_integer(a); assert_to_integer(b); - r = make_integer(a->u.i - b->u.i); assert_minus(a->u.i, b->u.i, r->u.i); - free_value (a); - free_value (b); - return r; + free_value(a); + free_value(b); + return (r); } void @@ -479,12 +463,11 @@ op_times(struct val *a, struct val *b) assert_to_integer(a); assert_to_integer(b); - r = make_integer(a->u.i * b->u.i); assert_times(a->u.i, b->u.i, r->u.i); - free_value (a); - free_value (b); + free_value(a); + free_value(b); return (r); } @@ -505,16 +488,15 @@ op_div(struct val *a, struct val *b) assert_to_integer(a); assert_to_integer(b); - /* assert based on operands only, not on result */ assert_div(a->u.i, b->u.i); r = make_integer(a->u.i / b->u.i); - free_value (a); - free_value (b); - return r; + free_value(a); + free_value(b); + return (r); } - + struct val * op_rem(struct val *a, struct val *b) { @@ -526,11 +508,11 @@ op_rem(struct val *a, struct val *b) assert_div(1, b->u.i); r = make_integer(a->u.i % b->u.i); - free_value (a); - free_value (b); - return r; + free_value(a); + free_value(b); + return (r); } - + struct val * op_colon(struct val *a, struct val *b) { @@ -545,33 +527,30 @@ op_colon(struct val *a, struct val *b) to_string(b); /* compile regular expression */ - if ((eval = regcomp (&rp, b->u.s, 0)) != 0) { - regerror (eval, &rp, errbuf, sizeof(errbuf)); + if ((eval = regcomp(&rp, b->u.s, 0)) != 0) { + regerror(eval, &rp, errbuf, sizeof(errbuf)); errx(ERR_EXIT, "%s", errbuf); } /* compare string against pattern */ /* remember that patterns are anchored to the beginning of the line */ - if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 && rm[0].rm_so == 0) { + if (regexec(&rp, a->u.s, (size_t)2, rm, 0) == 0 && rm[0].rm_so == 0) if (rm[1].rm_so >= 0) { *(a->u.s + rm[1].rm_eo) = '\0'; - v = make_str (a->u.s + rm[1].rm_so); + v = make_str(a->u.s + rm[1].rm_so); - } else { - v = make_integer ((intmax_t)(rm[0].rm_eo - rm[0].rm_so)); - } - } else { - if (rp.re_nsub == 0) { - v = make_integer ((intmax_t)0); - } else { - v = make_str (""); - } - } + } else + v = make_integer((intmax_t)(rm[0].rm_eo - rm[0].rm_so)); + else + if (rp.re_nsub == 0) + v = make_integer((intmax_t)0); + else + v = make_str(""); /* free arguments and pattern buffer */ - free_value (a); - free_value (b); - regfree (&rp); + free_value(a); + free_value(b); + regfree(&rp); - return v; + return (v); } From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 13:33:21 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A12B11065672; Sat, 9 Jul 2011 13:33:21 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay04.stack.nl [IPv6:2001:610:1108:5010::107]) by mx1.freebsd.org (Postfix) with ESMTP id 38D0E8FC15; Sat, 9 Jul 2011 13:33:21 +0000 (UTC) Received: from turtle.stack.nl (turtle.stack.nl [IPv6:2001:610:1108:5010::132]) by mx1.stack.nl (Postfix) with ESMTP id 202731DD758; Sat, 9 Jul 2011 15:33:20 +0200 (CEST) Received: by turtle.stack.nl (Postfix, from userid 1677) id 0488F17467; Sat, 9 Jul 2011 15:33:20 +0200 (CEST) Date: Sat, 9 Jul 2011 15:33:19 +0200 From: Jilles Tjoelker To: Kostik Belousov Message-ID: <20110709133319.GD14262@stack.nl> References: <200705131412.l4DECf2N068712@repoman.freebsd.org> <20110612213330.D10590@maildrop.int.zabbadoz.net> <20110616212738.GA73657@stack.nl> <20110616220313.GT48734@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110616220313.GT48734@deviant.kiev.zoral.com.ua> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Daniel Eischen , "Bjoern A. Zeeb" , svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-head@freebsd.org Subject: Re: cvs commit: src Makefile.inc1 src/lib/libc Makefile src/lib/libc_r Makefile src/lib/libpthread Makefile pthread.map src/lib/libpthread/thread thr_private.h src/lib/librt Makefile src/lib/libthr Makefile pthread.map src/lib/libthread_db Makefile ... X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 13:33:21 -0000 On Fri, Jun 17, 2011 at 01:03:13AM +0300, Kostik Belousov wrote: > On Thu, Jun 16, 2011 at 11:27:38PM +0200, Jilles Tjoelker wrote: > > I think disabling symver completely is too much: it implies a new > > mutually incompatible set of binaries. What should be done instead is > > allowing to compile out the compatibility functions. This means all > > __sym_compat() directives and all functions referred to by them. A > > simple approach would use a yes/no #ifdef, while a more sophisticated > > approach would allow choosing the oldest version to retain compatibility > > with, for example freebsd7_semctl() in lib/libc/gen/semctl.c would be > > compiled in iff compatibility with FreeBSD 7.x was requested. > > With just symver, a binary for FreeBSD version for which compatibility > > was not compiled in will abort if and when it attempts to use a function > > that was changed in a later version. > Preventing which behaviour was explicitely the goal of designing the > symver mechanism at the first place. That was certainly Sun's intention in designing symver, but it does not work for us. For the case of trying to run a 9-current binary on 8-stable, as soon as a new function is MFCed from 9-current to 8-stable and/or 7-stable, the libc in the stable branch will gain the FBSD_1.2 version definition, and therefore as far as symver is concerned running a 9-current binary is OK. For the case of running a binary for which compatibility was not compiled in, it is very likely that other symbols with that version (e.g. FBSD_1.0) remain and symver's initial check will pass. The only thing which symver does for us (but it is very useful) is ensuring that old binaries get the correct versions of functions which changed their ABI, allowing them to run with the current libraries. -- Jilles Tjoelker From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 14:29:24 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 081A3106566B; Sat, 9 Jul 2011 14:29:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id ECE338FC08; Sat, 9 Jul 2011 14:29:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p69ETNZo003912; Sat, 9 Jul 2011 14:29:23 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p69ETNNu003910; Sat, 9 Jul 2011 14:29:23 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201107091429.p69ETNNu003910@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 9 Jul 2011 14:29:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223884 - head/sys/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 14:29:24 -0000 Author: kib Date: Sat Jul 9 14:29:23 2011 New Revision: 223884 URL: http://svn.freebsd.org/changeset/base/223884 Log: Implement bitcount16. Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/sys/systm.h Modified: head/sys/sys/systm.h ============================================================================== --- head/sys/sys/systm.h Sat Jul 9 12:20:15 2011 (r223883) +++ head/sys/sys/systm.h Sat Jul 9 14:29:23 2011 (r223884) @@ -392,4 +392,15 @@ bitcount32(uint32_t x) return (x); } +static __inline uint16_t +bitcount16(uint32_t x) +{ + + x = (x & 0x5555) + ((x & 0xaaaa) >> 1); + x = (x & 0x3333) + ((x & 0xcccc) >> 2); + x = (x + (x >> 4)) & 0x0f0f; + x = (x + (x >> 8)) & 0x00ff; + return (x); +} + #endif /* !_SYS_SYSTM_H_ */ From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 14:30:13 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 818C7106564A; Sat, 9 Jul 2011 14:30:13 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 720FC8FC1F; Sat, 9 Jul 2011 14:30:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p69EUDih003978; Sat, 9 Jul 2011 14:30:13 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p69EUDf8003975; Sat, 9 Jul 2011 14:30:13 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201107091430.p69EUDf8003975@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 9 Jul 2011 14:30:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223885 - head/sys/dev/pci X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 14:30:13 -0000 Author: kib Date: Sat Jul 9 14:30:13 2011 New Revision: 223885 URL: http://svn.freebsd.org/changeset/base/223885 Log: Implement pci_find_class(9), the function to find a pci device by its class. Sponsored by: The FreeBSD Foundation Reviewed by: jhb MFC after: 1 week Modified: head/sys/dev/pci/pci.c head/sys/dev/pci/pcivar.h Modified: head/sys/dev/pci/pci.c ============================================================================== --- head/sys/dev/pci/pci.c Sat Jul 9 14:29:23 2011 (r223884) +++ head/sys/dev/pci/pci.c Sat Jul 9 14:30:13 2011 (r223885) @@ -347,6 +347,21 @@ pci_find_device(uint16_t vendor, uint16_ return (NULL); } +device_t +pci_find_class(uint8_t class, uint8_t subclass) +{ + struct pci_devinfo *dinfo; + + STAILQ_FOREACH(dinfo, &pci_devq, pci_links) { + if (dinfo->cfg.baseclass == class && + dinfo->cfg.subclass == subclass) { + return (dinfo->cfg.dev); + } + } + + return (NULL); +} + static int pci_printf(pcicfgregs *cfg, const char *fmt, ...) { Modified: head/sys/dev/pci/pcivar.h ============================================================================== --- head/sys/dev/pci/pcivar.h Sat Jul 9 14:29:23 2011 (r223884) +++ head/sys/dev/pci/pcivar.h Sat Jul 9 14:30:13 2011 (r223885) @@ -457,6 +457,7 @@ pci_msix_count(device_t dev) device_t pci_find_bsf(uint8_t, uint8_t, uint8_t); device_t pci_find_dbsf(uint32_t, uint8_t, uint8_t, uint8_t); device_t pci_find_device(uint16_t, uint16_t); +device_t pci_find_class(uint8_t class, uint8_t subclass); /* Can be used by drivers to manage the MSI-X table. */ int pci_pending_msix(device_t dev, u_int index); From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 14:41:29 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 05819106564A; Sat, 9 Jul 2011 14:41:29 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EA5558FC17; Sat, 9 Jul 2011 14:41:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p69EfSeX004404; Sat, 9 Jul 2011 14:41:28 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p69EfSSI004402; Sat, 9 Jul 2011 14:41:28 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201107091441.p69EfSSI004402@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 9 Jul 2011 14:41:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223886 - head/sys/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 14:41:29 -0000 Author: kib Date: Sat Jul 9 14:41:28 2011 New Revision: 223886 URL: http://svn.freebsd.org/changeset/base/223886 Log: Implement a helper functions to locally set thread-private flag, and restore it to the previous state. Note that only setting a flag locally is supported. Sponsored by: The FreeBSD Foundation Reviewed by: alc (previous version) MFC after: 1 week Modified: head/sys/sys/proc.h Modified: head/sys/sys/proc.h ============================================================================== --- head/sys/sys/proc.h Sat Jul 9 14:30:13 2011 (r223885) +++ head/sys/sys/proc.h Sat Jul 9 14:41:28 2011 (r223886) @@ -913,6 +913,25 @@ void thread_unthread(struct thread *td); void thread_wait(struct proc *p); struct thread *thread_find(struct proc *p, lwpid_t tid); +static __inline int +thread_pflags_set(int flags) +{ + struct thread *td; + int save; + + td = curthread; + save = ~flags | (td->td_pflags & flags); + td->td_pflags |= flags; + return (save); +} + +static __inline void +thread_pflags_restore(int save) +{ + + curthread->td_pflags &= save; +} + #endif /* _KERNEL */ #endif /* !_SYS_PROC_H_ */ From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 14:42:46 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 00A13106564A; Sat, 9 Jul 2011 14:42:46 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E503E8FC08; Sat, 9 Jul 2011 14:42:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p69EgjT7004478; Sat, 9 Jul 2011 14:42:45 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p69Egj3X004476; Sat, 9 Jul 2011 14:42:45 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201107091442.p69Egj3X004476@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 9 Jul 2011 14:42:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223887 - head/sys/ufs/ffs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 14:42:46 -0000 Author: kib Date: Sat Jul 9 14:42:45 2011 New Revision: 223887 URL: http://svn.freebsd.org/changeset/base/223887 Log: Use helper functions instead of manually managing TDP_INBDFLUSH. Sponsored by: The FreeBSD Foundation Reviewed by: alc (previous version) MFC after: 1 week Modified: head/sys/ufs/ffs/ffs_balloc.c Modified: head/sys/ufs/ffs/ffs_balloc.c ============================================================================== --- head/sys/ufs/ffs/ffs_balloc.c Sat Jul 9 14:41:28 2011 (r223886) +++ head/sys/ufs/ffs/ffs_balloc.c Sat Jul 9 14:42:45 2011 (r223887) @@ -234,9 +234,7 @@ ffs_balloc_ufs1(struct vnode *vp, off_t if (num < 1) panic ("ffs_balloc_ufs1: ufs_getlbns returned indirect block"); #endif - saved_inbdflush = ~TDP_INBDFLUSH | (curthread->td_pflags & - TDP_INBDFLUSH); - curthread->td_pflags |= TDP_INBDFLUSH; + saved_inbdflush = thread_pflags_set(TDP_INBDFLUSH); /* * Fetch the first indirect block allocating if necessary. */ @@ -250,7 +248,7 @@ ffs_balloc_ufs1(struct vnode *vp, off_t pref = ffs_blkpref_ufs1(ip, lbn, 0, (ufs1_daddr_t *)0); if ((error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize, flags, cred, &newb)) != 0) { - curthread->td_pflags &= saved_inbdflush; + thread_pflags_restore(saved_inbdflush); return (error); } nb = newb; @@ -356,7 +354,7 @@ retry: * If asked only for the indirect block, then return it. */ if (flags & BA_METAONLY) { - curthread->td_pflags &= saved_inbdflush; + thread_pflags_restore(saved_inbdflush); *bpp = bp; return (0); } @@ -406,7 +404,7 @@ retry: bp->b_flags |= B_CLUSTEROK; bdwrite(bp); } - curthread->td_pflags &= saved_inbdflush; + thread_pflags_restore(saved_inbdflush); *bpp = nbp; return (0); } @@ -428,11 +426,11 @@ retry: nbp = getblk(vp, lbn, fs->fs_bsize, 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); } - curthread->td_pflags &= saved_inbdflush; + thread_pflags_restore(saved_inbdflush); *bpp = nbp; return (0); fail: - curthread->td_pflags &= saved_inbdflush; + thread_pflags_restore(saved_inbdflush); /* * If we have failed to allocate any blocks, simply return the error. * This is the usual case and avoids the need to fsync the file. @@ -774,9 +772,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t if (num < 1) panic ("ffs_balloc_ufs2: ufs_getlbns returned indirect block"); #endif - saved_inbdflush = ~TDP_INBDFLUSH | (curthread->td_pflags & - TDP_INBDFLUSH); - curthread->td_pflags |= TDP_INBDFLUSH; + saved_inbdflush = thread_pflags_set(TDP_INBDFLUSH); /* * Fetch the first indirect block allocating if necessary. */ @@ -790,7 +786,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t pref = ffs_blkpref_ufs2(ip, lbn, 0, (ufs2_daddr_t *)0); if ((error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize, flags, cred, &newb)) != 0) { - curthread->td_pflags &= saved_inbdflush; + thread_pflags_restore(saved_inbdflush); return (error); } nb = newb; @@ -896,7 +892,7 @@ retry: * If asked only for the indirect block, then return it. */ if (flags & BA_METAONLY) { - curthread->td_pflags &= saved_inbdflush; + thread_pflags_restore(saved_inbdflush); *bpp = bp; return (0); } @@ -946,7 +942,7 @@ retry: bp->b_flags |= B_CLUSTEROK; bdwrite(bp); } - curthread->td_pflags &= saved_inbdflush; + thread_pflags_restore(saved_inbdflush); *bpp = nbp; return (0); } @@ -974,11 +970,11 @@ retry: nbp = getblk(vp, lbn, fs->fs_bsize, 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); } - curthread->td_pflags &= saved_inbdflush; + thread_pflags_restore(saved_inbdflush); *bpp = nbp; return (0); fail: - curthread->td_pflags &= saved_inbdflush; + thread_pflags_restore(saved_inbdflush); /* * If we have failed to allocate any blocks, simply return the error. * This is the usual case and avoids the need to fsync the file. From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 15:16:08 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 67810106564A; Sat, 9 Jul 2011 15:16:08 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4DF0D8FC08; Sat, 9 Jul 2011 15:16:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p69FG8NF005496; Sat, 9 Jul 2011 15:16:08 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p69FG8xr005493; Sat, 9 Jul 2011 15:16:08 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201107091516.p69FG8xr005493@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 9 Jul 2011 15:16:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223888 - in head/sys: sys ufs/ffs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 15:16:08 -0000 Author: kib Date: Sat Jul 9 15:16:07 2011 New Revision: 223888 URL: http://svn.freebsd.org/changeset/base/223888 Log: Use 'curthread_pflags' instead of 'thread_pflags' to signify that only curthread can be operated upon. Requested by: attilio MFC after: 1 week Modified: head/sys/sys/proc.h head/sys/ufs/ffs/ffs_balloc.c Modified: head/sys/sys/proc.h ============================================================================== --- head/sys/sys/proc.h Sat Jul 9 14:42:45 2011 (r223887) +++ head/sys/sys/proc.h Sat Jul 9 15:16:07 2011 (r223888) @@ -914,7 +914,7 @@ void thread_wait(struct proc *p); struct thread *thread_find(struct proc *p, lwpid_t tid); static __inline int -thread_pflags_set(int flags) +curthread_pflags_set(int flags) { struct thread *td; int save; @@ -926,7 +926,7 @@ thread_pflags_set(int flags) } static __inline void -thread_pflags_restore(int save) +curthread_pflags_restore(int save) { curthread->td_pflags &= save; Modified: head/sys/ufs/ffs/ffs_balloc.c ============================================================================== --- head/sys/ufs/ffs/ffs_balloc.c Sat Jul 9 14:42:45 2011 (r223887) +++ head/sys/ufs/ffs/ffs_balloc.c Sat Jul 9 15:16:07 2011 (r223888) @@ -234,7 +234,7 @@ ffs_balloc_ufs1(struct vnode *vp, off_t if (num < 1) panic ("ffs_balloc_ufs1: ufs_getlbns returned indirect block"); #endif - saved_inbdflush = thread_pflags_set(TDP_INBDFLUSH); + saved_inbdflush = curthread_pflags_set(TDP_INBDFLUSH); /* * Fetch the first indirect block allocating if necessary. */ @@ -248,7 +248,7 @@ ffs_balloc_ufs1(struct vnode *vp, off_t pref = ffs_blkpref_ufs1(ip, lbn, 0, (ufs1_daddr_t *)0); if ((error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize, flags, cred, &newb)) != 0) { - thread_pflags_restore(saved_inbdflush); + curthread_pflags_restore(saved_inbdflush); return (error); } nb = newb; @@ -354,7 +354,7 @@ retry: * If asked only for the indirect block, then return it. */ if (flags & BA_METAONLY) { - thread_pflags_restore(saved_inbdflush); + curthread_pflags_restore(saved_inbdflush); *bpp = bp; return (0); } @@ -404,7 +404,7 @@ retry: bp->b_flags |= B_CLUSTEROK; bdwrite(bp); } - thread_pflags_restore(saved_inbdflush); + curthread_pflags_restore(saved_inbdflush); *bpp = nbp; return (0); } @@ -426,11 +426,11 @@ retry: nbp = getblk(vp, lbn, fs->fs_bsize, 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); } - thread_pflags_restore(saved_inbdflush); + curthread_pflags_restore(saved_inbdflush); *bpp = nbp; return (0); fail: - thread_pflags_restore(saved_inbdflush); + curthread_pflags_restore(saved_inbdflush); /* * If we have failed to allocate any blocks, simply return the error. * This is the usual case and avoids the need to fsync the file. @@ -772,7 +772,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t if (num < 1) panic ("ffs_balloc_ufs2: ufs_getlbns returned indirect block"); #endif - saved_inbdflush = thread_pflags_set(TDP_INBDFLUSH); + saved_inbdflush = curthread_pflags_set(TDP_INBDFLUSH); /* * Fetch the first indirect block allocating if necessary. */ @@ -786,7 +786,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t pref = ffs_blkpref_ufs2(ip, lbn, 0, (ufs2_daddr_t *)0); if ((error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize, flags, cred, &newb)) != 0) { - thread_pflags_restore(saved_inbdflush); + curthread_pflags_restore(saved_inbdflush); return (error); } nb = newb; @@ -892,7 +892,7 @@ retry: * If asked only for the indirect block, then return it. */ if (flags & BA_METAONLY) { - thread_pflags_restore(saved_inbdflush); + curthread_pflags_restore(saved_inbdflush); *bpp = bp; return (0); } @@ -942,7 +942,7 @@ retry: bp->b_flags |= B_CLUSTEROK; bdwrite(bp); } - thread_pflags_restore(saved_inbdflush); + curthread_pflags_restore(saved_inbdflush); *bpp = nbp; return (0); } @@ -970,11 +970,11 @@ retry: nbp = getblk(vp, lbn, fs->fs_bsize, 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); } - thread_pflags_restore(saved_inbdflush); + curthread_pflags_restore(saved_inbdflush); *bpp = nbp; return (0); fail: - thread_pflags_restore(saved_inbdflush); + curthread_pflags_restore(saved_inbdflush); /* * If we have failed to allocate any blocks, simply return the error. * This is the usual case and avoids the need to fsync the file. From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 15:21:10 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DE93D1065672; Sat, 9 Jul 2011 15:21:10 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CE3B28FC13; Sat, 9 Jul 2011 15:21:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p69FLALh005684; Sat, 9 Jul 2011 15:21:10 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p69FLAat005677; Sat, 9 Jul 2011 15:21:10 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201107091521.p69FLAat005677@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 9 Jul 2011 15:21:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223889 - in head/sys: kern sys vm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 15:21:11 -0000 Author: kib Date: Sat Jul 9 15:21:10 2011 New Revision: 223889 URL: http://svn.freebsd.org/changeset/base/223889 Log: Add a facility to disable processing page faults. When activated, uiomove generates EFAULT if any accessed address is not mapped, as opposed to handling the fault. Sponsored by: The FreeBSD Foundation Reviewed by: alc (previous version) Modified: head/sys/kern/subr_uio.c head/sys/sys/proc.h head/sys/sys/systm.h head/sys/sys/uio.h head/sys/vm/vm_extern.h head/sys/vm/vm_fault.c Modified: head/sys/kern/subr_uio.c ============================================================================== --- head/sys/kern/subr_uio.c Sat Jul 9 15:16:07 2011 (r223888) +++ head/sys/kern/subr_uio.c Sat Jul 9 15:21:10 2011 (r223889) @@ -64,6 +64,8 @@ __FBSDID("$FreeBSD$"); SYSCTL_INT(_kern, KERN_IOV_MAX, iov_max, CTLFLAG_RD, NULL, UIO_MAXIOV, "Maximum number of elements in an I/O vector; sysconf(_SC_IOV_MAX)"); +static int uiomove_faultflag(void *cp, int n, struct uio *uio, int nofault); + #ifdef ZERO_COPY_SOCKETS /* Declared in uipc_socket.c */ extern int so_zero_copy_receive; @@ -129,23 +131,65 @@ retry: #endif /* ZERO_COPY_SOCKETS */ int +copyin_nofault(const void *udaddr, void *kaddr, size_t len) +{ + int error, save; + + save = vm_fault_disable_pagefaults(); + error = copyin(udaddr, kaddr, len); + vm_fault_enable_pagefaults(save); + return (error); +} + +int +copyout_nofault(const void *kaddr, void *udaddr, size_t len) +{ + int error, save; + + save = vm_fault_disable_pagefaults(); + error = copyout(kaddr, udaddr, len); + vm_fault_enable_pagefaults(save); + return (error); +} + +int uiomove(void *cp, int n, struct uio *uio) { - struct thread *td = curthread; + + return (uiomove_faultflag(cp, n, uio, 0)); +} + +int +uiomove_nofault(void *cp, int n, struct uio *uio) +{ + + return (uiomove_faultflag(cp, n, uio, 1)); +} + +static int +uiomove_faultflag(void *cp, int n, struct uio *uio, int nofault) +{ + struct thread *td; struct iovec *iov; u_int cnt; - int error = 0; - int save = 0; + int error, newflags, save; + + td = curthread; + error = 0; KASSERT(uio->uio_rw == UIO_READ || uio->uio_rw == UIO_WRITE, ("uiomove: mode")); - KASSERT(uio->uio_segflg != UIO_USERSPACE || uio->uio_td == curthread, + KASSERT(uio->uio_segflg != UIO_USERSPACE || uio->uio_td == td, ("uiomove proc")); - WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, - "Calling uiomove()"); - - save = td->td_pflags & TDP_DEADLKTREAT; - td->td_pflags |= TDP_DEADLKTREAT; + if (!nofault) + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, + "Calling uiomove()"); + + /* XXX does it make a sense to set TDP_DEADLKTREAT for UIO_SYSSPACE ? */ + newflags = TDP_DEADLKTREAT; + if (uio->uio_segflg == UIO_USERSPACE && nofault) + newflags |= TDP_NOFAULTING; + save = curthread_pflags_set(newflags); while (n > 0 && uio->uio_resid) { iov = uio->uio_iov; @@ -187,8 +231,7 @@ uiomove(void *cp, int n, struct uio *uio n -= cnt; } out: - if (save == 0) - td->td_pflags &= ~TDP_DEADLKTREAT; + curthread_pflags_restore(save); return (error); } Modified: head/sys/sys/proc.h ============================================================================== --- head/sys/sys/proc.h Sat Jul 9 15:16:07 2011 (r223888) +++ head/sys/sys/proc.h Sat Jul 9 15:21:10 2011 (r223889) @@ -393,7 +393,7 @@ do { \ #define TDP_COWINPROGRESS 0x00000010 /* Snapshot copy-on-write in progress. */ #define TDP_ALTSTACK 0x00000020 /* Have alternate signal stack. */ #define TDP_DEADLKTREAT 0x00000040 /* Lock aquisition - deadlock treatment. */ -#define TDP_UNUSED80 0x00000080 /* available. */ +#define TDP_NOFAULTING 0x00000080 /* Do not handle page faults. */ #define TDP_NOSLEEPING 0x00000100 /* Thread is not allowed to sleep on a sq. */ #define TDP_OWEUPC 0x00000200 /* Call addupc() at next AST. */ #define TDP_ITHREAD 0x00000400 /* Thread is an interrupt thread. */ Modified: head/sys/sys/systm.h ============================================================================== --- head/sys/sys/systm.h Sat Jul 9 15:16:07 2011 (r223888) +++ head/sys/sys/systm.h Sat Jul 9 15:21:10 2011 (r223889) @@ -217,8 +217,12 @@ int copyinstr(const void * __restrict ud __nonnull(1) __nonnull(2); int copyin(const void * __restrict udaddr, void * __restrict kaddr, size_t len) __nonnull(1) __nonnull(2); +int copyin_nofault(const void * __restrict udaddr, void * __restrict kaddr, + size_t len) __nonnull(1) __nonnull(2); int copyout(const void * __restrict kaddr, void * __restrict udaddr, size_t len) __nonnull(1) __nonnull(2); +int copyout_nofault(const void * __restrict kaddr, void * __restrict udaddr, + size_t len) __nonnull(1) __nonnull(2); int fubyte(const void *base); long fuword(const void *base); Modified: head/sys/sys/uio.h ============================================================================== --- head/sys/sys/uio.h Sat Jul 9 15:16:07 2011 (r223888) +++ head/sys/sys/uio.h Sat Jul 9 15:21:10 2011 (r223889) @@ -100,6 +100,7 @@ int uiomove(void *cp, int n, struct uio int uiomove_frombuf(void *buf, int buflen, struct uio *uio); int uiomove_fromphys(struct vm_page *ma[], vm_offset_t offset, int n, struct uio *uio); +int uiomove_nofault(void *cp, int n, struct uio *uio); int uiomoveco(void *cp, int n, struct uio *uio, int disposable); #else /* !_KERNEL */ Modified: head/sys/vm/vm_extern.h ============================================================================== --- head/sys/vm/vm_extern.h Sat Jul 9 15:16:07 2011 (r223888) +++ head/sys/vm/vm_extern.h Sat Jul 9 15:21:10 2011 (r223889) @@ -61,6 +61,8 @@ int useracc(void *, int, int); int vm_fault(vm_map_t, vm_offset_t, vm_prot_t, int); void vm_fault_copy_entry(vm_map_t, vm_map_t, vm_map_entry_t, vm_map_entry_t, vm_ooffset_t *); +int vm_fault_disable_pagefaults(void); +void vm_fault_enable_pagefaults(int save); int vm_fault_hold(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type, int fault_flags, vm_page_t *m_hold); int vm_fault_quick_hold_pages(vm_map_t map, vm_offset_t addr, vm_size_t len, Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Sat Jul 9 15:16:07 2011 (r223888) +++ head/sys/vm/vm_fault.c Sat Jul 9 15:21:10 2011 (r223889) @@ -209,6 +209,8 @@ vm_fault(vm_map_t map, vm_offset_t vaddr int fault_flags) { + if ((curthread->td_pflags & TDP_NOFAULTING) != 0) + return (KERN_PROTECTION_FAILURE); return (vm_fault_hold(map, vaddr, fault_type, fault_flags, NULL)); } @@ -1475,3 +1477,17 @@ vm_fault_additional_pages(m, rbehind, ra /* return number of pages */ return i; } + +int +vm_fault_disable_pagefaults(void) +{ + + return (curthread_pflags_set(TDP_NOFAULTING)); +} + +void +vm_fault_enable_pagefaults(int save) +{ + + curthread_pflags_restore(save); +} From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 15:24:12 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D87D81065673; Sat, 9 Jul 2011 15:24:12 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C82708FC16; Sat, 9 Jul 2011 15:24:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p69FOCWt005830; Sat, 9 Jul 2011 15:24:12 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p69FOCq6005825; Sat, 9 Jul 2011 15:24:12 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201107091524.p69FOCq6005825@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 9 Jul 2011 15:24:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223890 - head/share/man/man9 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 15:24:12 -0000 Author: kib Date: Sat Jul 9 15:24:12 2011 New Revision: 223890 URL: http://svn.freebsd.org/changeset/base/223890 Log: Document copyin_nofault, copyout_nofault, uiomove_nofault. Submitted by: alc Modified: head/share/man/man9/Makefile head/share/man/man9/copy.9 head/share/man/man9/uio.9 Modified: head/share/man/man9/Makefile ============================================================================== --- head/share/man/man9/Makefile Sat Jul 9 15:21:10 2011 (r223889) +++ head/share/man/man9/Makefile Sat Jul 9 15:24:12 2011 (r223890) @@ -551,8 +551,10 @@ MLINKS+=config_intrhook.9 config_intrhoo config_intrhook.9 config_intrhook_establish.9 MLINKS+=contigmalloc.9 contigfree.9 MLINKS+=copy.9 copyin.9 \ + copy.9 copyin_nofault.9 \ copy.9 copyinstr.9 \ copy.9 copyout.9 \ + copy.9 copyout_nofault.9 \ copy.9 copystr.9 MLINKS+=critical_enter.9 critical.9 \ critical_enter.9 critical_exit.9 @@ -1284,7 +1286,8 @@ MLINKS+=uidinfo.9 uifind.9 \ uidinfo.9 uifree.9 \ uidinfo.9 uihashinit.9 \ uidinfo.9 uihold.9 -MLINKS+=uio.9 uiomove.9 +MLINKS+=uio.9 uiomove.9 \ + uio.9 uiomove_nofault.9 MLINKS+=usbdi.9 usbd_do_request.9 \ usbdi.9 usbd_do_request_flags.9 \ usbdi.9 usbd_errstr.9 \ Modified: head/share/man/man9/copy.9 ============================================================================== --- head/share/man/man9/copy.9 Sat Jul 9 15:21:10 2011 (r223889) +++ head/share/man/man9/copy.9 Sat Jul 9 15:24:12 2011 (r223890) @@ -34,13 +34,15 @@ .\" .\" $FreeBSD$ .\" -.Dd January 7, 1996 +.Dd July 9, 2011 .Dt COPY 9 .Os .Sh NAME .Nm copy , .Nm copyin , +.Nm copyin_nofault , .Nm copyout , +.Nm copyout_nofault , .Nm copystr , .Nm copyinstr .Nd kernel copy functions @@ -50,8 +52,12 @@ .Ft int .Fn copyin "const void *uaddr" "void *kaddr" "size_t len" .Ft int +.Fn copyin_nofault "const void *uaddr" "void *kaddr" "size_t len" +.Ft int .Fn copyout "const void *kaddr" "void *uaddr" "size_t len" .Ft int +.Fn copyout_nofault "const void *kaddr" "void *uaddr" "size_t len" +.Ft int .Fn copystr "const void *kfaddr" "void *kdaddr" "size_t len" "size_t *done" .Ft int .Fn copyinstr "const void *uaddr" "void *kaddr" "size_t len" "size_t *done" @@ -67,25 +73,40 @@ All but copy data from user-space to kernel-space or vice-versa. .Pp The -.Nm -routines provide the following functionality: -.Bl -tag -width "copyoutstr()" -.It Fn copyin -Copies +.Fn copyin +and +.Fn copyin_nofault +functions copy .Fa len bytes of data from the user-space address .Fa uaddr to the kernel-space address .Fa kaddr . -.It Fn copyout -Copies +.Pp +The +.Fn copyout +and +.Fn copyout_nofault +functions copy .Fa len bytes of data from the kernel-space address .Fa kaddr to the user-space address .Fa uaddr . -.It Fn copystr -Copies a NUL-terminated string, at most +.Pp +The +.Fn copyin_nofault +and +.Fn copyout_nofault +functions require that the kernel-space and user-space data be +accessible without incurring a page fault. +The source and destination addresses must be physically mapped for +read and write access, respectively, and neither the source nor +destination addresses may be pageable. +.Pp +The +.Fn copystr +function copies a NUL-terminated string, at most .Fa len bytes long, from kernel-space address .Fa kfaddr @@ -98,8 +119,10 @@ NUL, is returned in .Fa done is .No non- Ns Dv NULL ) . -.It Fn copyinstr -Copies a NUL-terminated string, at most +.Pp +The +.Fn copyinstr +function copies a NUL-terminated string, at most .Fa len bytes long, from user-space address .Fa uaddr @@ -121,7 +144,6 @@ is .\" The number of bytes actually copied, including the terminating .\" NUL, is returned in .\" .Fa *done . -.El .Sh RETURN VALUES The .Nm @@ -129,7 +151,13 @@ functions return 0 on success or .Er EFAULT if a bad address is encountered. In addition, the -.Fn copystr , +.Fn copyin_nofault +and +.Fn copyout_nofault +functions return +.Er EFAULT +if a page fault occurs, and the +.Fn copystr and .Fn copyinstr .\" .Fn copyinstr , Modified: head/share/man/man9/uio.9 ============================================================================== --- head/share/man/man9/uio.9 Sat Jul 9 15:21:10 2011 (r223889) +++ head/share/man/man9/uio.9 Sat Jul 9 15:24:12 2011 (r223890) @@ -25,12 +25,13 @@ .\" .\" $FreeBSD$ .\" -.Dd March 21, 2010 +.Dd July 9, 2011 .Dt UIO 9 .Os .Sh NAME .Nm uio , -.Nm uiomove +.Nm uiomove , +.Nm uiomove_nofault .Nd device driver I/O routines .Sh SYNOPSIS .In sys/types.h @@ -48,11 +49,15 @@ struct uio { .Ed .Ft int .Fn uiomove "void *buf" "int howmuch" "struct uio *uiop" +.Ft int +.Fn uiomove_nofault "void *buf" "int howmuch" "struct uio *uiop" .Sh DESCRIPTION -The function +The functions .Fn uiomove -is used to handle transfer of data between buffers and I/O vectors -that might possibly also cross the user/kernel space boundary. +and +.Fn uiomove_nofault +are used to transfer data between buffers and I/O vectors that might +possibly cross the user/kernel space boundary. .Pp As a result of any .Xr read 2 , @@ -71,6 +76,8 @@ being passed. The transfer request is encoded in this structure. The driver itself should use .Fn uiomove +or +.Fn uiomove_nofault to get at the data in this structure. .Pp The fields in the @@ -99,7 +106,7 @@ Do not copy, already in object. .El .It Va uio_rw The direction of the desired transfer, either -.Dv UIO_READ , +.Dv UIO_READ or .Dv UIO_WRITE . .It Va uio_td @@ -110,10 +117,24 @@ for the associated thread; used if indicates that the transfer is to be made from/to a process's address space. .El +.Pp +The function +.Fn uiomove_nofault +requires that the buffer and I/O vectors be accessible without +incurring a page fault. +The source and destination addresses must be physically mapped for +read and write access, respectively, and neither the source nor +destination addresses may be pageable. +Thus, the function +.Fn uiomove_nofault +can be called from contexts where acquiring virtual memory system +locks or sleeping are prohibited. .Sh RETURN VALUES On success .Fn uiomove -will return 0, on error it will return an appropriate errno. +and +.Fn uiomove_nofault +will return 0; on error they will return an appropriate error code. .Sh EXAMPLES The idea is that the driver maintains a private buffer for its data, and processes the request in chunks of maximal the size of this @@ -156,6 +177,8 @@ fooread(dev_t dev, struct uio *uio, int .Ed .Sh ERRORS .Fn uiomove +and +.Fn uiomove_nofault will fail and return the following error code if: .Bl -tag -width Er .It Bq Er EFAULT @@ -166,6 +189,14 @@ or returned .Er EFAULT .El +.Pp +In addition, +.Fn uiomove_nofault +will fail and return the following error code if: +.Bl -tag -width Er +.It Bq Er EFAULT +A page fault occurs. +.El .Sh SEE ALSO .Xr read 2 , .Xr readv 2 , From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 15:36:30 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3B769106566C; Sat, 9 Jul 2011 15:36:30 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from mx0.hoeg.nl (mx0.hoeg.nl [IPv6:2a01:4f8:101:5343::aa]) by mx1.freebsd.org (Postfix) with ESMTP id CEB2D8FC0A; Sat, 9 Jul 2011 15:36:29 +0000 (UTC) Received: by mx0.hoeg.nl (Postfix, from userid 1000) id C2D5D2A28CC5; Sat, 9 Jul 2011 17:36:28 +0200 (CEST) Date: Sat, 9 Jul 2011 17:36:28 +0200 From: Ed Schouten To: Konstantin Belousov Message-ID: <20110709153628.GJ16219@hoeg.nl> References: <201107091429.p69ETNNu003910@svn.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="P6YfpwaDcfcOCJkJ" Content-Disposition: inline In-Reply-To: <201107091429.p69ETNNu003910@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r223884 - head/sys/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 15:36:30 -0000 --P6YfpwaDcfcOCJkJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Kostik, * Konstantin Belousov , 20110709 16:29: > +static __inline uint16_t > +bitcount16(uint32_t x) Shouldn't we use uint16_t for the argument here? When I saw the code, I thought by myself, this could be done more efficiently: | static __inline uint16_t | bitcount16(uint16_t x) | { | | x =3D (x & 0x5555) + ((x >> 1) & 0x5555); | x =3D (x & 0x3333) + ((x >> 2) & 0x3333); | x *=3D 0x1111; | return (x >> 12); | } But some testing revealed it works for all inputs, except 65536. d'oh! --=20 Ed Schouten WWW: http://80386.nl/ --P6YfpwaDcfcOCJkJ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (FreeBSD) iQIcBAEBAgAGBQJOGHV8AAoJEG5e2P40kaK7mcYP/2mExhD7lcmTJRQB/tsrpSB6 XHaqX/0RlYDKErMRDDOnI1oCibkNvDFPFg5QtKg8MqeY9ammqrByFn53k5uTyVrO 2kvx0lZbMeGAUHcRjdOXDEk++EwNmppfnNbSDYkV9N84f6Zf/dB23BxmCr0vrE9B MOWpuZFkoIWQQr8FxjV+Q2AcKC0aOgfVGdj6IBkAiQdX8+MzPvOv3Or8rCgzBScX Vp0WmEuLg6/NCDQHftoFH6DBncNbiFY8DQSbp+4qBoIpESupQHgmqxHxXWLobyIM 59zHXN1z9/MzDmlrgHuM+MiQM9ysxPRsSDTWM3sRV7KCHml1aOvoQSvlSuWuiOz7 Tyavxkn6NNW35RqhIT3muYH9ABUP+cG1qz06IBjecnbcKGHojfBjW6dUY0e4F23A eOAQFdB+HghqpJ83qUnTkdVaSg7QheXvM/KLTI+SGPR/GqUkggtppYLTWWPDvDLl LTrfTeDdDbg3P18iOEHDOugFmgfnqUeB1v/dR2EUkeoIWOEqLbkoaRIh8Fax3Shc Wrl/rOw2QLYtZNSrzPQCj9GWWaNk4vaMbF3trwnTdBcxX39tP28iM8Y3o9sCeSom 9ZJXTnIaV5i8DaIXtzWgaYjTM2YlXlYp/olmyv1ztkd2AIppK5tYKCIJ9RI+jzv4 CServnZ60Z9YhzKi4O6E =03JA -----END PGP SIGNATURE----- --P6YfpwaDcfcOCJkJ-- From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 17:04:42 2011 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5C87B1065670; Sat, 9 Jul 2011 17:04:42 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id C99D68FC17; Sat, 9 Jul 2011 17:04:41 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p69H4WlV010389 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 9 Jul 2011 20:04:33 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id p69H4WwH020502; Sat, 9 Jul 2011 20:04:32 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p69H4WtI020500; Sat, 9 Jul 2011 20:04:32 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 9 Jul 2011 20:04:32 +0300 From: Kostik Belousov To: Ed Schouten Message-ID: <20110709170432.GL48734@deviant.kiev.zoral.com.ua> References: <201107091429.p69ETNNu003910@svn.freebsd.org> <20110709153628.GJ16219@hoeg.nl> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="eULE+JHRRz2mSqwH" Content-Disposition: inline In-Reply-To: <20110709153628.GJ16219@hoeg.nl> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r223884 - head/sys/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 17:04:42 -0000 --eULE+JHRRz2mSqwH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jul 09, 2011 at 05:36:28PM +0200, Ed Schouten wrote: > Hi Kostik, >=20 > * Konstantin Belousov , 20110709 16:29: > > +static __inline uint16_t > > +bitcount16(uint32_t x) >=20 > Shouldn't we use uint16_t for the argument here? Not sure. uint32_t type of argument avoids repromotion, allowing to do the full-register calculation on both 32 and 64 bit architectures. The function correctly handles non-zero upper half-word on its own. >=20 > When I saw the code, I thought by myself, this could be done more > efficiently: >=20 > | static __inline uint16_t > | bitcount16(uint16_t x) > | { > | > | x =3D (x & 0x5555) + ((x >> 1) & 0x5555); > | x =3D (x & 0x3333) + ((x >> 2) & 0x3333); > | x *=3D 0x1111; > | return (x >> 12); > | } >=20 > But some testing revealed it works for all inputs, except 65536. d'oh! >=20 > --=20 > Ed Schouten > WWW: http://80386.nl/ --eULE+JHRRz2mSqwH Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk4YiiAACgkQC3+MBN1Mb4hBxQCgtf1CQybdUzbopmNuPw8ysusr tEgAoK3a/E/FBBoO/16ZZyV2p6ew7w6v =uHxi -----END PGP SIGNATURE----- --eULE+JHRRz2mSqwH-- From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 17:45:52 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A635E106564A; Sat, 9 Jul 2011 17:45:52 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail06.syd.optusnet.com.au (mail06.syd.optusnet.com.au [211.29.132.187]) by mx1.freebsd.org (Postfix) with ESMTP id 22E4D8FC08; Sat, 9 Jul 2011 17:45:51 +0000 (UTC) Received: from c122-106-165-191.carlnfd1.nsw.optusnet.com.au (c122-106-165-191.carlnfd1.nsw.optusnet.com.au [122.106.165.191]) by mail06.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id p69HjlX9019510 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 10 Jul 2011 03:45:48 +1000 Date: Sun, 10 Jul 2011 03:45:47 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Kevin Lo In-Reply-To: <201107090743.p697huB2086379@svn.freebsd.org> Message-ID: <20110710020439.U2667@besplex.bde.org> References: <201107090743.p697huB2086379@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r223877 - in head: include/rpc lib/libc/xdr X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 17:45:52 -0000 On Sat, 9 Jul 2011, Kevin Lo wrote: > Log: > - Add xdr_sizeof(3) to libc > - Document xdr_sizeof(3); from NetBSD > > Discussed with: kib Any reason to further break the style of every changed line of the header? > Modified: head/include/rpc/xdr.h > ============================================================================== > --- head/include/rpc/xdr.h Fri Jul 8 20:41:12 2011 (r223876) > +++ head/include/rpc/xdr.h Sat Jul 9 07:43:56 2011 (r223877) > @@ -285,43 +285,46 @@ struct xdr_discrim { > * These are the "generic" xdr routines. > */ > __BEGIN_DECLS > -extern bool_t xdr_void(void); > -extern bool_t xdr_int(XDR *, int *); > -extern bool_t xdr_u_int(XDR *, u_int *); > -extern bool_t xdr_long(XDR *, long *); > -extern bool_t xdr_u_long(XDR *, u_long *); > -extern bool_t xdr_short(XDR *, short *); > -extern bool_t xdr_u_short(XDR *, u_short *); > -extern bool_t xdr_int16_t(XDR *, int16_t *); > -extern bool_t xdr_u_int16_t(XDR *, u_int16_t *); > -extern bool_t xdr_uint16_t(XDR *, u_int16_t *); > -extern bool_t xdr_int32_t(XDR *, int32_t *); > -extern bool_t xdr_u_int32_t(XDR *, u_int32_t *); > -extern bool_t xdr_uint32_t(XDR *, u_int32_t *); > -extern bool_t xdr_int64_t(XDR *, int64_t *); > -extern bool_t xdr_u_int64_t(XDR *, u_int64_t *); > -extern bool_t xdr_uint64_t(XDR *, u_int64_t *); > -extern bool_t xdr_bool(XDR *, bool_t *); > -extern bool_t xdr_enum(XDR *, enum_t *); > -extern bool_t xdr_array(XDR *, char **, u_int *, u_int, u_int, xdrproc_t); > -extern bool_t xdr_bytes(XDR *, char **, u_int *, u_int); > -extern bool_t xdr_opaque(XDR *, char *, u_int); > -extern bool_t xdr_string(XDR *, char **, u_int); > -extern bool_t xdr_union(XDR *, enum_t *, char *, const struct xdr_discrim *, xdrproc_t); > -extern bool_t xdr_char(XDR *, char *); > -extern bool_t xdr_u_char(XDR *, u_char *); > -extern bool_t xdr_vector(XDR *, char *, u_int, u_int, xdrproc_t); > -extern bool_t xdr_float(XDR *, float *); > -extern bool_t xdr_double(XDR *, double *); > -extern bool_t xdr_quadruple(XDR *, long double *); > -extern bool_t xdr_reference(XDR *, char **, u_int, xdrproc_t); > -extern bool_t xdr_pointer(XDR *, char **, u_int, xdrproc_t); > -extern bool_t xdr_wrapstring(XDR *, char **); > -extern void xdr_free(xdrproc_t, void *); > -extern bool_t xdr_hyper(XDR *, quad_t *); > -extern bool_t xdr_u_hyper(XDR *, u_quad_t *); > -extern bool_t xdr_longlong_t(XDR *, quad_t *); > -extern bool_t xdr_u_longlong_t(XDR *, u_quad_t *); Old brokenness: bogus externs (they have no effect, except for some pre-K&R compilers, but even support for K&R was dropped long ago). > +extern bool_t xdr_void(void); > +extern bool_t xdr_int(XDR *, int *); > +extern bool_t xdr_u_int(XDR *, u_int *); > +extern bool_t xdr_long(XDR *, long *); > +extern bool_t xdr_u_long(XDR *, u_long *); > +extern bool_t xdr_short(XDR *, short *); > +extern bool_t xdr_u_short(XDR *, u_short *); > +extern bool_t xdr_int16_t(XDR *, int16_t *); > +extern bool_t xdr_u_int16_t(XDR *, u_int16_t *); > +extern bool_t xdr_uint16_t(XDR *, u_int16_t *); > +extern bool_t xdr_int32_t(XDR *, int32_t *); > +extern bool_t xdr_u_int32_t(XDR *, u_int32_t *); > +extern bool_t xdr_uint32_t(XDR *, u_int32_t *); > +extern bool_t xdr_int64_t(XDR *, int64_t *); > +extern bool_t xdr_u_int64_t(XDR *, u_int64_t *); > +extern bool_t xdr_uint64_t(XDR *, u_int64_t *); > +extern bool_t xdr_bool(XDR *, bool_t *); > +extern bool_t xdr_enum(XDR *, enum_t *); > +extern bool_t xdr_array(XDR *, char **, u_int *, u_int, u_int, > + xdrproc_t); > +extern bool_t xdr_bytes(XDR *, char **, u_int *, u_int); > +extern bool_t xdr_opaque(XDR *, char *, u_int); > +extern bool_t xdr_string(XDR *, char **, u_int); > +extern bool_t xdr_union(XDR *, enum_t *, char *, > + const struct xdr_discrim *, xdrproc_t); > +extern bool_t xdr_char(XDR *, char *); > +extern bool_t xdr_u_char(XDR *, u_char *); > +extern bool_t xdr_vector(XDR *, char *, u_int, u_int, xdrproc_t); > +extern bool_t xdr_float(XDR *, float *); > +extern bool_t xdr_double(XDR *, double *); > +extern bool_t xdr_quadruple(XDR *, long double *); > +extern bool_t xdr_reference(XDR *, char **, u_int, xdrproc_t); > +extern bool_t xdr_pointer(XDR *, char **, u_int, xdrproc_t); > +extern bool_t xdr_wrapstring(XDR *, char **); > +extern void xdr_free(xdrproc_t, void *); > +extern bool_t xdr_hyper(XDR *, quad_t *); > +extern bool_t xdr_u_hyper(XDR *, u_quad_t *); > +extern bool_t xdr_longlong_t(XDR *, quad_t *); > +extern bool_t xdr_u_longlong_t(XDR *, u_quad_t *); New style bugs in old code: excessive indentation (to match the excessive indentation in 1 line of new code). > +extern unsigned long xdr_sizeof(xdrproc_t, void *); New style bugs in new code: verboseness and associated style inconsistencies. 'unsigned foo' is spelled u_foo in KNF to avoid verboseness, and that style is used everywhere else in this file, even more so than usual since even the function names are spelled with u_foo. If u_foo were spelled normally, the indentation would not be excessive. This is the main reason for using u_foo. I think it also has an non-style bug -- a type mismatch. It returns u_long instead of the usual bool_t since it returns sizes of ojects. But size_t doesn't always have type unsigned long. It has type size_t, which is u_int on all 32-bit arches. This bug is old. xdr_size_t() is full of type errors -- see below. > ... > Modified: head/lib/libc/xdr/xdr.3 > ============================================================================== > --- head/lib/libc/xdr/xdr.3 Fri Jul 8 20:41:12 2011 (r223876) > +++ head/lib/libc/xdr/xdr.3 Sat Jul 9 07:43:56 2011 (r223877) > @@ -31,6 +31,7 @@ > .Nm xdr_reference , > .Nm xdr_setpos , > .Nm xdr_short , > +.Nm xdr_sizeof, > .Nm xdrstdio_create , > .Nm xdr_string , > .Nm xdr_u_char , > @@ -561,6 +562,18 @@ A filter primitive that translates betwe > integers and their external representations. > This routine returns one if it succeeds, zero otherwise. > .Pp > +.It Xo > +.Ft unsigned long Another `unsigned long'. The man page was already less consistent than the header in using u_foo. It uses `unsigned foo' for xdr_u_char(), xdr_u_short() and xdr_u_long, plain unsigned for xdr_u_int(), and uquad_t (sic) for xdr_ulonglong_t() (sic), so that the arg type doesn't match the function name literally for these functions. OTOH, it uses u_foo consistently for more specialized args (like counts and sizes) whose type isn't determined by the type of the data being translated. > +.Xc > +.It Xo > +.Fn xdr_sizeof "xdrproc_t func" "void *data" > +.Xc Using .Xo/.Xc is probably another style bug, but this man page does it consistently. > +.Pp > +This routine returns the amount of memory required to encode > +.Fa data > +using filter > +.Fa func . > +.Pp > .It Li "#ifdef _STDIO_H_" > .It Li "/* XDR using stdio library */" > .It Xo > > Modified: head/lib/libc/xdr/xdr_sizeof.c > ============================================================================== > --- head/lib/libc/xdr/xdr_sizeof.c Fri Jul 8 20:41:12 2011 (r223876) > +++ head/lib/libc/xdr/xdr_sizeof.c Sat Jul 9 07:43:56 2011 (r223877) > @@ -94,7 +94,7 @@ x_inline(xdrs, len) > if (xdrs->x_op != XDR_ENCODE) { > return (NULL); > } > - if (len < (u_int)xdrs->x_base) { > + if (len < (u_int)(uintptr_t)xdrs->x_base) { > /* x_private was already allocated */ > xdrs->x_handy += len; > return ((int32_t *) xdrs->x_private); Shouldn't the u_int be size_t? u_int doesn't match size_t any better than u_long does. I now see that the return type of unsigned long is an old mistake too. Dusty decks like rpc have zillions of type errors. The next one (visible in the above) is int32_t instead of any of size_t, the return type or u_int. Then xdr_sizeof() uses the caddr_t mistake. Then at the end, xdr_sizeof() bogusly casts the value to be returned to unsigned (spelled as plain unsigned) instead of to any of size_t, the return type, u_int or int32_t. > @@ -106,7 +106,7 @@ x_inline(xdrs, len) > xdrs->x_base = 0; > return (NULL); > } > - xdrs->x_base = (caddr_t) len; > + xdrs->x_base = (caddr_t)(uintptr_t)len; > xdrs->x_handy += len; > return ((int32_t *) xdrs->x_private); > } > xdr_inline() has similar type errors, but its return type is int32_t and it casts to that fairly consistently. I noticed the following other old bugs in the man page: - all the functions that are declared as returning bool_t are documented as returning int. bool_t is only documented to be used once (for the xdr_bool() pointer type. I prefer to use plain int. - size_t isn't used for any API. u_int and not u_long is used for all the size args that should really have type size_t. - the phrase "translates between [unsigned] ANSI C long long integers and their external representations" is used ad nauseum, but ANSI C doesn't exist. Informally, "ANSI C" means the pre-ISO-C90, and neither it not C90 have the long long mistake, so long long integers are further from being "ANSI C" than all other integers. For the actuall-ANSI-C integers, the duplicated phrase says "C [unsigned]" instead of "[unsigned] ANSI C" (note that this is also missing the bug of misplacing "[unsigned]"). The phrase for xdr_bool() says that booleans (bool_t's) are C integers, so bool_t must be int even in the one place that it is documented, except it is not clear that the "integer" here must be int. - xdr_longlong_t() and xdr_ulonglong_t() look like they support the [unsigned] long long mistake, and are documented to translate between [unsigned] ANSI C long long integers and their external representations, but their arg type is [u_]quad_t, so they actually only support BSD [unsigned] quad integers. Support for other C99 types is similarly absent (but present in practice in the same way as for long long while quad_t remains the same as long long, int64_t and intmax_t, and similarly for other intN_t). - xdr_longlong_t() and xdr_ulonglong_t() have a bogus _t in their name. Another man page, rpc.3, says that the xdr's x_inline function pointer is for a function that returns `long *'. This is inconsistent with the int32_t returns for the xdr x_inline function remarked on above. It is also inconsistent with the actual declaration of the x_inline function pointer in xdr.h. That uses int32_t too. It was changed to use int32_t instead of long in 1996. Bruce From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 18:05:28 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 79D55106564A; Sat, 9 Jul 2011 18:05:28 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5097D8FC0A; Sat, 9 Jul 2011 18:05:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p69I5Sj6010734; Sat, 9 Jul 2011 18:05:28 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p69I5S9m010731; Sat, 9 Jul 2011 18:05:28 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201107091805.p69I5S9m010731@svn.freebsd.org> From: Alan Cox Date: Sat, 9 Jul 2011 18:05:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223891 - head/share/man/man9 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 18:05:28 -0000 Author: alc Date: Sat Jul 9 18:05:27 2011 New Revision: 223891 URL: http://svn.freebsd.org/changeset/base/223891 Log: Remove manual pages for functions that no longer exist. MFC after: 1 week Deleted: head/share/man/man9/vm_page_copy.9 head/share/man/man9/vm_page_zero_fill.9 Modified: head/share/man/man9/Makefile head/share/man/man9/vm_map.9 Modified: head/share/man/man9/Makefile ============================================================================== --- head/share/man/man9/Makefile Sat Jul 9 15:24:12 2011 (r223890) +++ head/share/man/man9/Makefile Sat Jul 9 18:05:27 2011 (r223891) @@ -318,7 +318,6 @@ MAN= accept_filter.9 \ vm_page_alloc.9 \ vm_page_bits.9 \ vm_page_cache.9 \ - vm_page_copy.9 \ vm_page_deactivate.9 \ vm_page_dontneed.9 \ vm_page_flag.9 \ @@ -328,12 +327,10 @@ MAN= accept_filter.9 \ vm_page_insert.9 \ vm_page_io.9 \ vm_page_lookup.9 \ - vm_page_protect.9 \ vm_page_rename.9 \ vm_page_sleep_if_busy.9 \ vm_page_wakeup.9 \ vm_page_wire.9 \ - vm_page_zero_fill.9 \ vm_set_page_size.9 \ vn_fullpath.9 \ vn_isdisk.9 \ Modified: head/share/man/man9/vm_map.9 ============================================================================== --- head/share/man/man9/vm_map.9 Sat Jul 9 15:24:12 2011 (r223890) +++ head/share/man/man9/vm_map.9 Sat Jul 9 18:05:27 2011 (r223891) @@ -223,13 +223,9 @@ a user process's address space: .Bl -tag -width ".Va max_protection" .It Va protection Memory protection bits applied to this region. -These are identical to those defined for -.Xr vm_page_protect 9 . .It Va max_protection Mask for the memory protection bits which may be actually be applied to this region. -These are identical to those defined for -.Xr vm_page_protect 9 . .It Va inheritance Contains flags which specify how this entry should be treated during fork processing. @@ -348,8 +344,7 @@ is backed by a .Xr vm_map_simplify_entry 9 , .Xr vm_map_stack 9 , .Xr vm_map_submap 9 , -.Xr vm_map_wire 9 , -.Xr vm_page_protect 9 +.Xr vm_map_wire 9 .Sh AUTHORS This manual page was written by .An Bruce M Simpson Aq bms@spc.org . From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 18:09:58 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38B701065670; Sat, 9 Jul 2011 18:09:58 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 28F5E8FC18; Sat, 9 Jul 2011 18:09:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p69I9wAH010929; Sat, 9 Jul 2011 18:09:58 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p69I9wBR010927; Sat, 9 Jul 2011 18:09:58 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201107091809.p69I9wBR010927@svn.freebsd.org> From: Alan Cox Date: Sat, 9 Jul 2011 18:09:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223892 - in head: . share/man/man9 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 18:09:58 -0000 Author: alc Date: Sat Jul 9 18:09:57 2011 New Revision: 223892 URL: http://svn.freebsd.org/changeset/base/223892 Log: Oops. These changes should have been included in r223891. MFC after: 1 week Deleted: head/share/man/man9/vm_page_protect.9 Modified: head/ObsoleteFiles.inc Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Sat Jul 9 18:05:27 2011 (r223891) +++ head/ObsoleteFiles.inc Sat Jul 9 18:09:57 2011 (r223892) @@ -38,6 +38,10 @@ # xargs -n1 | sort | uniq -d; # done +# 20110709: Catch up with removal of these functions. +OLD_FILES+=usr/share/man/man9/vm_page_copy.9.gz +OLD_FILES+=usr/share/man/man9/vm_page_protect.9.gz +OLD_FILES+=usr/share/man/man9/vm_page_zero_fill.9.gz # 20110707: script no longer needed by /etc/rc.d/nfsd OLD_FILES+=etc/rc.d/nfsserver # 20110705: files moved so both NFS clients can share them From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 18:47:52 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B93A1065746; Sat, 9 Jul 2011 18:47:52 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4B7B08FC1E; Sat, 9 Jul 2011 18:47:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p69IlqF2012112; Sat, 9 Jul 2011 18:47:52 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p69Ilq5Z012110; Sat, 9 Jul 2011 18:47:52 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201107091847.p69Ilq5Z012110@svn.freebsd.org> From: Marius Strobl Date: Sat, 9 Jul 2011 18:47:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223893 - head/sys/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 18:47:52 -0000 Author: marius Date: Sat Jul 9 18:47:51 2011 New Revision: 223893 URL: http://svn.freebsd.org/changeset/base/223893 Log: Fix the definition for PCPU_NAME_LEN, which is intended to fit ("CPU %d", cpuid) where cpuid <= MAXCPU. 1. sizeof(__XSTRING(MAXCPU) + 1) is a typo: typeof(__XSTRING(...) + 1) is 'char *', so sizeof() will return the size of the pointer, not the size of the string contents. The proper expression should be 'sizeof(__XSTRING(MAXCPU)) + 1'. 2. One should not add one, but substract it: sizeof() accounts for the trailing '\0' and we have two sizeof's, so the size of one '\0' should be substracted -- this will give the maximal string buffer length for CPU with its number, no less, no more. Submitted by: rea Modified: head/sys/sys/pcpu.h Modified: head/sys/sys/pcpu.h ============================================================================== --- head/sys/sys/pcpu.h Sat Jul 9 18:09:57 2011 (r223892) +++ head/sys/sys/pcpu.h Sat Jul 9 18:47:51 2011 (r223893) @@ -146,7 +146,7 @@ struct rm_queue { struct rm_queue* volatile rmq_prev; }; -#define PCPU_NAME_LEN (sizeof("CPU ") + sizeof(__XSTRING(MAXCPU) + 1)) +#define PCPU_NAME_LEN (sizeof("CPU ") + sizeof(__XSTRING(MAXCPU)) - 1) /* * This structure maps out the global data that needs to be kept on a From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 19:01:50 2011 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AFCB4106566B; Sat, 9 Jul 2011 19:01:50 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 4AEFA8FC1E; Sat, 9 Jul 2011 19:01:50 +0000 (UTC) Received: from 63.imp.bsdimp.com (63.imp.bsdimp.com [10.0.0.63]) (authenticated bits=0) by harmony.bsdimp.com (8.14.4/8.14.3) with ESMTP id p69Iu63n008957 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Sat, 9 Jul 2011 12:56:07 -0600 (MDT) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <201107091430.p69EUDf8003975@svn.freebsd.org> Date: Sat, 9 Jul 2011 12:56:10 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <307FA901-53F0-4622-98AE-329FAE9762A1@bsdimp.com> References: <201107091430.p69EUDf8003975@svn.freebsd.org> To: Konstantin Belousov X-Mailer: Apple Mail (2.1084) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (harmony.bsdimp.com [10.0.0.6]); Sat, 09 Jul 2011 12:56:07 -0600 (MDT) Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r223885 - head/sys/dev/pci X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 19:01:50 -0000 Should't this be called 'pci_find_first_class()"? Also, can you add a = man page for it, or at least document what it is supposed to be used for = in the code? Warenr On Jul 9, 2011, at 8:30 AM, Konstantin Belousov wrote: > Author: kib > Date: Sat Jul 9 14:30:13 2011 > New Revision: 223885 > URL: http://svn.freebsd.org/changeset/base/223885 >=20 > Log: > Implement pci_find_class(9), the function to find a pci device by its = class. >=20 > Sponsored by: The FreeBSD Foundation > Reviewed by: jhb > MFC after: 1 week >=20 > Modified: > head/sys/dev/pci/pci.c > head/sys/dev/pci/pcivar.h >=20 > Modified: head/sys/dev/pci/pci.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/sys/dev/pci/pci.c Sat Jul 9 14:29:23 2011 = (r223884) > +++ head/sys/dev/pci/pci.c Sat Jul 9 14:30:13 2011 = (r223885) > @@ -347,6 +347,21 @@ pci_find_device(uint16_t vendor, uint16_ > return (NULL); > } >=20 > +device_t > +pci_find_class(uint8_t class, uint8_t subclass) > +{ > + struct pci_devinfo *dinfo; > + > + STAILQ_FOREACH(dinfo, &pci_devq, pci_links) { > + if (dinfo->cfg.baseclass =3D=3D class && > + dinfo->cfg.subclass =3D=3D subclass) { > + return (dinfo->cfg.dev); > + } > + } > + > + return (NULL); > +} > + > static int > pci_printf(pcicfgregs *cfg, const char *fmt, ...) > { >=20 > Modified: head/sys/dev/pci/pcivar.h > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/sys/dev/pci/pcivar.h Sat Jul 9 14:29:23 2011 = (r223884) > +++ head/sys/dev/pci/pcivar.h Sat Jul 9 14:30:13 2011 = (r223885) > @@ -457,6 +457,7 @@ pci_msix_count(device_t dev) > device_t pci_find_bsf(uint8_t, uint8_t, uint8_t); > device_t pci_find_dbsf(uint32_t, uint8_t, uint8_t, uint8_t); > device_t pci_find_device(uint16_t, uint16_t); > +device_t pci_find_class(uint8_t class, uint8_t subclass); >=20 > /* Can be used by drivers to manage the MSI-X table. */ > int pci_pending_msix(device_t dev, u_int index); >=20 >=20 From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 19:05:29 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 778D1106564A; Sat, 9 Jul 2011 19:05:29 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5CA308FC20; Sat, 9 Jul 2011 19:05:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p69J5Tjp012656; Sat, 9 Jul 2011 19:05:29 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p69J5TJP012651; Sat, 9 Jul 2011 19:05:29 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201107091905.p69J5TJP012651@svn.freebsd.org> From: Alan Cox Date: Sat, 9 Jul 2011 19:05:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223894 - in head: . share/man/man9 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 19:05:29 -0000 Author: alc Date: Sat Jul 9 19:05:28 2011 New Revision: 223894 URL: http://svn.freebsd.org/changeset/base/223894 Log: vm_map_clean() was long ago renamed to vm_map_sync(). Also, it no longer acquires Giant. MFC after: 1 week Added: head/share/man/man9/vm_map_sync.9 - copied, changed from r223890, head/share/man/man9/vm_map_clean.9 Modified: head/ObsoleteFiles.inc head/share/man/man9/Makefile head/share/man/man9/vm_map.9 Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Sat Jul 9 18:47:51 2011 (r223893) +++ head/ObsoleteFiles.inc Sat Jul 9 19:05:28 2011 (r223894) @@ -38,6 +38,8 @@ # xargs -n1 | sort | uniq -d; # done +# 20110709: vm_map_clean.9 -> vm_map_sync.9 +OLD_FILES+=usr/share/man/man9/vm_map_clean.9.gz # 20110709: Catch up with removal of these functions. OLD_FILES+=usr/share/man/man9/vm_page_copy.9.gz OLD_FILES+=usr/share/man/man9/vm_page_protect.9.gz Modified: head/share/man/man9/Makefile ============================================================================== --- head/share/man/man9/Makefile Sat Jul 9 18:47:51 2011 (r223893) +++ head/share/man/man9/Makefile Sat Jul 9 19:05:28 2011 (r223894) @@ -296,7 +296,6 @@ MAN= accept_filter.9 \ vm_fault_prefault.9 \ vm_map.9 \ vm_map_check_protection.9 \ - vm_map_clean.9 \ vm_map_create.9 \ vm_map_delete.9 \ vm_map_entry_resize_free.9 \ @@ -314,6 +313,7 @@ MAN= accept_filter.9 \ vm_map_simplify_entry.9 \ vm_map_stack.9 \ vm_map_submap.9 \ + vm_map_sync.9 \ vm_map_wire.9 \ vm_page_alloc.9 \ vm_page_bits.9 \ Modified: head/share/man/man9/vm_map.9 ============================================================================== --- head/share/man/man9/vm_map.9 Sat Jul 9 18:47:51 2011 (r223893) +++ head/share/man/man9/vm_map.9 Sat Jul 9 19:05:28 2011 (r223894) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 26, 2004 +.Dd July 9, 2011 .Dt VM_MAP 9 .Os .Sh NAME @@ -324,7 +324,6 @@ is backed by a .Sh SEE ALSO .Xr pmap 9 , .Xr vm_map_check_protection 9 , -.Xr vm_map_clean 9 , .Xr vm_map_create 9 , .Xr vm_map_delete 9 , .Xr vm_map_entry_resize_free 9 , @@ -344,6 +343,7 @@ is backed by a .Xr vm_map_simplify_entry 9 , .Xr vm_map_stack 9 , .Xr vm_map_submap 9 , +.Xr vm_map_sync 9 , .Xr vm_map_wire 9 .Sh AUTHORS This manual page was written by Copied and modified: head/share/man/man9/vm_map_sync.9 (from r223890, head/share/man/man9/vm_map_clean.9) ============================================================================== --- head/share/man/man9/vm_map_clean.9 Sat Jul 9 15:24:12 2011 (r223890, copy source) +++ head/share/man/man9/vm_map_sync.9 Sat Jul 9 19:05:28 2011 (r223894) @@ -25,24 +25,24 @@ .\" .\" $FreeBSD$ .\" -.Dd July 19, 2003 -.Dt VM_MAP_CLEAN 9 +.Dd July 9, 2011 +.Dt VM_MAP_SYNC 9 .Os .Sh NAME -.Nm vm_map_clean +.Nm vm_map_sync .Nd push dirty pages to their pager .Sh SYNOPSIS .In sys/param.h .In vm/vm.h .In vm/vm_map.h .Ft int -.Fo vm_map_clean +.Fo vm_map_sync .Fa "vm_map_t map" "vm_offset_t start" "vm_offset_t end" "boolean_t syncio" .Fa "boolean_t invalidate" .Fc .Sh DESCRIPTION The -.Fn vm_map_clean +.Fn vm_map_sync function forces any dirty cached pages in the range .Fa start to @@ -61,13 +61,9 @@ is TRUE, any cached pages are also freed .Pp The range provided must be contiguous, it MUST NOT contain holes. The range provided MUST NOT contain any sub-map entries. -.Sh IMPLEMENTATION NOTES -This routine holds the -.Va Giant -lock to prevent multiple entry. .Sh RETURN VALUES The -.Fn vm_map_clean +.Fn vm_map_sync function returns .Dv KERN_SUCCESS if successful. From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 19:09:20 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 949D5106566C; Sat, 9 Jul 2011 19:09:20 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6B6788FC21; Sat, 9 Jul 2011 19:09:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p69J9Kqq012805; Sat, 9 Jul 2011 19:09:20 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p69J9Kvl012804; Sat, 9 Jul 2011 19:09:20 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201107091909.p69J9Kvl012804@svn.freebsd.org> From: Alan Cox Date: Sat, 9 Jul 2011 19:09:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223895 - head/share/man/man9 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 19:09:20 -0000 Author: alc Date: Sat Jul 9 19:09:20 2011 New Revision: 223895 URL: http://svn.freebsd.org/changeset/base/223895 Log: Remove the old vm_map_clean man page. Deleted: head/share/man/man9/vm_map_clean.9 From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 19:17:02 2011 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1E876106564A; Sat, 9 Jul 2011 19:17:02 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id AF2128FC27; Sat, 9 Jul 2011 19:17:01 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p69JGrew020173 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 9 Jul 2011 22:16:53 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id p69JGqhc025128; Sat, 9 Jul 2011 22:16:52 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p69JGqo0025127; Sat, 9 Jul 2011 22:16:52 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 9 Jul 2011 22:16:52 +0300 From: Kostik Belousov To: Warner Losh Message-ID: <20110709191652.GA22221@deviant.kiev.zoral.com.ua> References: <201107091430.p69EUDf8003975@svn.freebsd.org> <307FA901-53F0-4622-98AE-329FAE9762A1@bsdimp.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="liOOAslEiF7prFVr" Content-Disposition: inline In-Reply-To: <307FA901-53F0-4622-98AE-329FAE9762A1@bsdimp.com> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r223885 - head/sys/dev/pci X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 19:17:02 -0000 --liOOAslEiF7prFVr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jul 09, 2011 at 12:56:10PM -0600, Warner Losh wrote: > Should't this be called 'pci_find_first_class()"? Also, can you add a > man page for it, or at least document what it is supposed to be used > for in the code? > > Warenr Sure, I will add a man page. Regarding the name, the intended use is to look up some unique devices on the hierarchy, like HOST-PCI bridge, or (used in the driver which requires this function) PCI-ISA bridge. It is known that device belonging to the supplied class is unique in the whole PCI buses hierarchy on the machine where the driver is attaching. 'First' there probably cannot be given any strong sense, since it would be a first device in some unspecified order. >=20 > On Jul 9, 2011, at 8:30 AM, Konstantin Belousov wrote: >=20 > > Author: kib > > Date: Sat Jul 9 14:30:13 2011 > > New Revision: 223885 > > URL: http://svn.freebsd.org/changeset/base/223885 > >=20 > > Log: > > Implement pci_find_class(9), the function to find a pci device by its = class. > >=20 > > Sponsored by: The FreeBSD Foundation > > Reviewed by: jhb > > MFC after: 1 week > >=20 > > Modified: > > head/sys/dev/pci/pci.c > > head/sys/dev/pci/pcivar.h > >=20 > > Modified: head/sys/dev/pci/pci.c > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- head/sys/dev/pci/pci.c Sat Jul 9 14:29:23 2011 (r223884) > > +++ head/sys/dev/pci/pci.c Sat Jul 9 14:30:13 2011 (r223885) > > @@ -347,6 +347,21 @@ pci_find_device(uint16_t vendor, uint16_ > > return (NULL); > > } > >=20 > > +device_t > > +pci_find_class(uint8_t class, uint8_t subclass) > > +{ > > + struct pci_devinfo *dinfo; > > + > > + STAILQ_FOREACH(dinfo, &pci_devq, pci_links) { > > + if (dinfo->cfg.baseclass =3D=3D class && > > + dinfo->cfg.subclass =3D=3D subclass) { > > + return (dinfo->cfg.dev); > > + } > > + } > > + > > + return (NULL); > > +} > > + > > static int > > pci_printf(pcicfgregs *cfg, const char *fmt, ...) > > { > >=20 > > Modified: head/sys/dev/pci/pcivar.h > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- head/sys/dev/pci/pcivar.h Sat Jul 9 14:29:23 2011 (r223884) > > +++ head/sys/dev/pci/pcivar.h Sat Jul 9 14:30:13 2011 (r223885) > > @@ -457,6 +457,7 @@ pci_msix_count(device_t dev) > > device_t pci_find_bsf(uint8_t, uint8_t, uint8_t); > > device_t pci_find_dbsf(uint32_t, uint8_t, uint8_t, uint8_t); > > device_t pci_find_device(uint16_t, uint16_t); > > +device_t pci_find_class(uint8_t class, uint8_t subclass); > >=20 > > /* Can be used by drivers to manage the MSI-X table. */ > > int pci_pending_msix(device_t dev, u_int index); > >=20 > >=20 >=20 --liOOAslEiF7prFVr Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk4YqSQACgkQC3+MBN1Mb4jX1QCg1LnpuPrWU54dkV0G6oMXp4Qr 1WcAoL1BFCNS4L8lEoO5w/N9atolc0rG =8v3Y -----END PGP SIGNATURE----- --liOOAslEiF7prFVr-- From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 20:16:53 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 324E5106564A; Sat, 9 Jul 2011 20:16:53 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2189B8FC14; Sat, 9 Jul 2011 20:16:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p69KGr1H014790; Sat, 9 Jul 2011 20:16:53 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p69KGriw014788; Sat, 9 Jul 2011 20:16:53 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201107092016.p69KGriw014788@svn.freebsd.org> From: Hans Petter Selasky Date: Sat, 9 Jul 2011 20:16:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223896 - head/sys/dev/usb/net X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 20:16:53 -0000 Author: hselasky Date: Sat Jul 9 20:16:52 2011 New Revision: 223896 URL: http://svn.freebsd.org/changeset/base/223896 Log: Remove reviewed line from copyright header. Suggested by: joel @ Modified: head/sys/dev/usb/net/if_usie.c Modified: head/sys/dev/usb/net/if_usie.c ============================================================================== --- head/sys/dev/usb/net/if_usie.c Sat Jul 9 19:09:20 2011 (r223895) +++ head/sys/dev/usb/net/if_usie.c Sat Jul 9 20:16:52 2011 (r223896) @@ -1,7 +1,6 @@ /*- * Copyright (c) 2011 Anybots Inc * written by Akinori Furukoshi - * reviewed by Hans Petter Selasky * - ucom part is based on u3g.c * * Redistribution and use in source and binary forms, with or without From owner-svn-src-head@FreeBSD.ORG Sat Jul 9 23:01:54 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 73C0F1065673; Sat, 9 Jul 2011 23:01:54 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 624998FC0C; Sat, 9 Jul 2011 23:01:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p69N1sdr019632; Sat, 9 Jul 2011 23:01:54 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p69N1sUp019626; Sat, 9 Jul 2011 23:01:54 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201107092301.p69N1sUp019626@svn.freebsd.org> From: Nathan Whitehorn Date: Sat, 9 Jul 2011 23:01:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223897 - in head: release usr.sbin/bsdinstall/scripts X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 23:01:54 -0000 Author: nwhitehorn Date: Sat Jul 9 23:01:54 2011 New Revision: 223897 URL: http://svn.freebsd.org/changeset/base/223897 Log: Per request of the docs team, install docs as packages, instead of via the normal distfile mechanism. Thanks to Marc Fonvieille for the patch and for putting up with me taking entirely too long to commit this! Submitted by: blackend Added: head/usr.sbin/bsdinstall/scripts/docsinstall (contents, props changed) Modified: head/release/Makefile head/release/generate-release.sh head/usr.sbin/bsdinstall/scripts/Makefile head/usr.sbin/bsdinstall/scripts/auto Modified: head/release/Makefile ============================================================================== --- head/release/Makefile Sat Jul 9 20:16:52 2011 (r223896) +++ head/release/Makefile Sat Jul 9 23:01:54 2011 (r223897) @@ -68,12 +68,7 @@ base.txz: # Set up mergemaster root database sh ${.CURDIR}/scripts/mm-mtree.sh -F \ "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" -D "${DISTDIR}/base" -# Merge handbook, etc. from doc tree into src tree doc distribution -.if !defined(NODOC) - cd ${DOCDIR} && ${IMAKE} all install \ - DOCDIR=${DISTDIR}/doc/usr/share/doc 'FORMATS=html html-split txt' \ - INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES -.endif +# Package all components cd ${WORLDDIR} && ${IMAKE} packageworld DISTDIR=${DISTDIR} mv ${DISTDIR}/*.txz ${.OBJDIR} Modified: head/release/generate-release.sh ============================================================================== --- head/release/generate-release.sh Sat Jul 9 20:16:52 2011 (r223896) +++ head/release/generate-release.sh Sat Jul 9 23:01:54 2011 (r223897) @@ -57,9 +57,8 @@ fi if [ -d $2/usr/doc ]; then cp /etc/resolv.conf $2/etc/resolv.conf - # Build ports to build the docs, then build the docs + # Build ports to build release documentation chroot $2 /bin/sh -c 'pkg_add -r docproj || (cd /usr/ports/textproc/docproj && make install clean BATCH=yes WITHOUT_X11=yes JADETEX=no WITHOUT_PYTHON=yes)' - chroot $2 make -C /usr/doc $MAKE_FLAGS 'FORMATS=html html-split txt' URLS_ABSOLUTE=YES fi chroot $2 make -C /usr/src $MAKE_FLAGS buildworld buildkernel Modified: head/usr.sbin/bsdinstall/scripts/Makefile ============================================================================== --- head/usr.sbin/bsdinstall/scripts/Makefile Sat Jul 9 20:16:52 2011 (r223896) +++ head/usr.sbin/bsdinstall/scripts/Makefile Sat Jul 9 23:01:54 2011 (r223897) @@ -1,8 +1,8 @@ # $FreeBSD$ -SCRIPTS= auto adduser checksum config hostname jail keymap mirrorselect \ - mount netconfig netconfig_ipv4 netconfig_ipv6 rootpass services \ - time umount wlanconfig +SCRIPTS= auto adduser checksum config docsinstall hostname jail keymap \ + mirrorselect mount netconfig netconfig_ipv4 netconfig_ipv6 rootpass \ + services time umount wlanconfig BINDIR= /usr/libexec/bsdinstall NO_MAN= true Modified: head/usr.sbin/bsdinstall/scripts/auto ============================================================================== --- head/usr.sbin/bsdinstall/scripts/auto Sat Jul 9 20:16:52 2011 (r223896) +++ head/usr.sbin/bsdinstall/scripts/auto Sat Jul 9 23:01:54 2011 (r223897) @@ -127,7 +127,7 @@ if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then # Try to use any existing distfiles if [ -d $BSDINSTALL_DISTDIR ]; then DISTDIR_IS_UNIONFS=1 - mount_unionfs "$BSDINSTALL_FETCHDEST" "$BSDINSTALL_DISTDIR" + mount_nullfs -o union "$BSDINSTALL_FETCHDEST" "$BSDINSTALL_DISTDIR" fi # Otherwise, fetch everything @@ -166,6 +166,7 @@ finalconfig() { "Network" "Networking configuration" \ "Services" "Set daemons to run on startup" \ "Time Zone" "Set system timezone" \ + "Handbook" "Install FreeBSD Handbook (requires network)" \ "Shell" "Open a shell in the new system" \ "Exit" "Apply configuration and exit installer" 2>&1 1>&3) exec 3>&- @@ -195,6 +196,10 @@ finalconfig() { bsdinstall time finalconfig ;; + "Handbook") + bsdinstall docsinstall + finalconfig + ;; "Shell") clear echo This shell is operating in a chroot in the new system. \ Added: head/usr.sbin/bsdinstall/scripts/docsinstall ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/bsdinstall/scripts/docsinstall Sat Jul 9 23:01:54 2011 (r223897) @@ -0,0 +1,69 @@ +#!/bin/sh +#- +# Copyright (c) 2011 Marc Fonvieille +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (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$ + + +exec 3>&1 +DOCS=$(dialog --backtitle "FreeBSD Installer" \ + --title "FreeBSD Documentation Installation" --separate-output \ + --checklist "This menu will allow you to install the whole documentation set +from the FreeBSD Documentation Project: Handbook, FAQ and articles.\n\n +Please select the language versions you wish to install. At minimum, +you should install the English version, this is the original version +of the documentation.\n\n +NB: This requires a working, configured network connection." 0 0 0 \ + bn "Bengali Documentation" ${DIST_DOC_BN:-off} \ + da "Danish Documentation" ${DIST_DOC_DA:-off} \ + de "German Documentation" ${DIST_DOC_DE:-off} \ + el "Greek Documentation" ${DIST_DOC_EL:-off} \ + en "English Documentation (recommended)" ${DIST_DOC_EN:-on} \ + es "Spanish Documentation" ${DIST_DOC_ES:-off} \ + fr "French Documentation" ${DIST_DOC_FR:-off} \ + hu "Hungarian Documentation" ${DIST_DOC_HU:-off} \ + it "Italian Documentation" ${DIST_DOC_IT:-off} \ + ja "Japanese Documentation" ${DIST_DOC_JA:-off} \ + mn "Mongolian Documentation" ${DIST_DOC_MN:-off} \ + nl "Dutch Documentation" ${DIST_DOC_NL:-off} \ + pl "Polish Documentation" ${DIST_DOC_PL:-off} \ + pt "Portuguese Documentation" ${DIST_DOC_PT:-off} \ + ru "Russian Documentation" ${DIST_DOC_RU:-off} \ + sr "Serbian Documentation" ${DIST_DOC_SR:-off} \ + tr "Turkish Documentation" ${DIST_DOC_TR:-off} \ + zh_cn "Simplified Chinese Documentation" ${DIST_DOC_ZH_CN:-off} \ + zh_tw "Traditional Chinese Documentation" ${DIST_DOC_ZH_TW:-off} \ +2>&1 1>&3) +test $? -eq 0 || exit 0 +exec 3>&- + +clear +echo "FreeBSD Installer" +echo "========================" +echo + +for i in $DOCS; do + pkg_add -C ${BSDINSTALL_CHROOT} -r ${i}-freebsd-doc +done