From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 01:17: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 CF64E106566C; Sun, 27 Mar 2011 01:17:25 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16]) by mx1.freebsd.org (Postfix) with ESMTP id 9FD0F8FC17; Sun, 27 Mar 2011 01:17:25 +0000 (UTC) Received: from julian-mac.elischer.org (home-nat.elischer.org [67.100.89.137]) (authenticated bits=0) by vps1.elischer.org (8.14.4/8.14.4) with ESMTP id p2R1HNES006364 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sat, 26 Mar 2011 18:17:24 -0700 (PDT) (envelope-from julian@freebsd.org) Message-ID: <4D8E9037.6090408@freebsd.org> Date: Sat, 26 Mar 2011 18:17:43 -0700 From: Julian Elischer User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 To: Andriy Gapon References: <201103261125.p2QBPa19020439@svn.freebsd.org> <4D8DCE0B.5040808@freebsd.org> In-Reply-To: <4D8DCE0B.5040808@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: r220032 - in head/sys: amd64/linux32 compat/linux i386/linux 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, 27 Mar 2011 01:17:25 -0000 On 3/26/11 4:29 AM, Andriy Gapon wrote: > on 26/03/2011 13:25 Andriy Gapon said the following: >> Author: avg >> Date: Sat Mar 26 11:25:36 2011 >> New Revision: 220032 >> URL: http://svn.freebsd.org/changeset/base/220032 >> >> Log: >> linux compat: add SO_PASSCRED option with basic handling >> >> This seems to have been a part of a bigger patch by dchagin that either >> haven't been committed or committed partially. >> >> Submitted by: dchagin, nox >> MFC after: 2 weeks > Dear linuxulator guys, > > apologies for wading into your territory and possibly making some mess while > there. But I really couldn't wait any longer for these patches to get finally > committed. you have a commit bit. you have shown an interest. All you need to do now is make contact with others in this area and: You are one of the linuxulator guys! congratulations on your new team membership! From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 03:03: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 A6047106564A; Sun, 27 Mar 2011 03:03:29 +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 7B4378FC1E; Sun, 27 Mar 2011 03:03:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2R33T6j044522; Sun, 27 Mar 2011 03:03:29 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2R33Tss044521; Sun, 27 Mar 2011 03:03:29 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201103270303.p2R33Tss044521@svn.freebsd.org> From: Doug Barton Date: Sun, 27 Mar 2011 03:03: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: r220048 - in head/etc/periodic: security weekly 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, 27 Mar 2011 03:03:29 -0000 Author: dougb Date: Sun Mar 27 03:03:29 2011 New Revision: 220048 URL: http://svn.freebsd.org/changeset/base/220048 Log: Add svn:executable property on remaining period scripts without it Modified: Directory Properties: head/etc/periodic/security/410.logincheck (props changed) head/etc/periodic/security/460.chkportsum (props changed) head/etc/periodic/security/510.ipfdenied (props changed) head/etc/periodic/security/520.pfdenied (props changed) head/etc/periodic/security/610.ipf6denied (props changed) head/etc/periodic/weekly/340.noid (props changed) From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 03:06: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 C27C1106564A; Sun, 27 Mar 2011 03:06:58 +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 B18BB8FC14; Sun, 27 Mar 2011 03:06:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2R36w8f044628; Sun, 27 Mar 2011 03:06:58 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2R36wD0044625; Sun, 27 Mar 2011 03:06:58 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201103270306.p2R36wD0044625@svn.freebsd.org> From: Doug Barton Date: Sun, 27 Mar 2011 03:06: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: r220049 - in head/etc/periodic: daily security 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, 27 Mar 2011 03:06:58 -0000 Author: dougb Date: Sun Mar 27 03:06:58 2011 New Revision: 220049 URL: http://svn.freebsd.org/changeset/base/220049 Log: Hook the 220.backup-pkgdb script I added to the build unconditionally Hook up 610.ipf6denied based on MK_IPFILTER as 510.ipfdenied is now Poked by: Andrzej Tobola Modified: head/etc/periodic/daily/Makefile head/etc/periodic/security/Makefile Modified: head/etc/periodic/daily/Makefile ============================================================================== --- head/etc/periodic/daily/Makefile Sun Mar 27 03:03:29 2011 (r220048) +++ head/etc/periodic/daily/Makefile Sun Mar 27 03:06:58 2011 (r220049) @@ -6,6 +6,7 @@ FILES= 100.clean-disks \ 110.clean-tmps \ 120.clean-preserve \ 200.backup-passwd \ + 220.backup-pkgdb \ 330.news \ 400.status-disks \ 405.status-ata-raid \ Modified: head/etc/periodic/security/Makefile ============================================================================== --- head/etc/periodic/security/Makefile Sun Mar 27 03:03:29 2011 (r220048) +++ head/etc/periodic/security/Makefile Sun Mar 27 03:06:58 2011 (r220049) @@ -17,6 +17,7 @@ FILES= 100.chksetuid \ .if ${MK_IPFILTER} != "no" FILES+= 510.ipfdenied +FILES+= 610.ipf6denied .endif .if ${MK_IPFW} != "no" From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 03:57:21 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2001:4f8:fff6::35]) by hub.freebsd.org (Postfix) with ESMTP id 07C6F106566B; Sun, 27 Mar 2011 03:57:21 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from 65-241-43-5.globalsuite.net (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx2.freebsd.org (Postfix) with ESMTP id 8FC5A14E19C; Sun, 27 Mar 2011 03:57:19 +0000 (UTC) Message-ID: <4D8EB596.3060706@FreeBSD.org> Date: Sat, 26 Mar 2011 20:57:10 -0700 From: Doug Barton Organization: http://SupersetSolutions.com/ User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.9.2.15) Gecko/20110326 Thunderbird/3.1.9 MIME-Version: 1.0 To: Alexander Best References: <201103260034.p2Q0YaC0098236@svn.freebsd.org> <20110326015721.GA25582@freebsd.org> In-Reply-To: <20110326015721.GA25582@freebsd.org> X-Enigmail-Version: 1.1.2 OpenPGP: id=1A1ABC84 Content-Type: text/plain; charset=ISO-8859-1; 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: r220015 - head/usr.sbin/newsyslog 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, 27 Mar 2011 03:57:21 -0000 On 03/25/2011 18:57, Alexander Best wrote: > On Sat Mar 26 11, Doug Barton wrote: >> Author: dougb >> Date: Sat Mar 26 00:34:35 2011 >> New Revision: 220015 >> URL: http://svn.freebsd.org/changeset/base/220015 >> >> Log: >> Add an example for the use of the entry to help others >> who are as slow as I am. > > shouldn't that be march 25th? ;) Technically, yes. :) But more importantly it is later than the previous date. Doug >> Discussed with: gordon >> >> Modified: >> head/usr.sbin/newsyslog/newsyslog.conf.5 >> >> Modified: head/usr.sbin/newsyslog/newsyslog.conf.5 >> ============================================================================== >> --- head/usr.sbin/newsyslog/newsyslog.conf.5 Fri Mar 25 22:31:28 2011 (r220014) >> +++ head/usr.sbin/newsyslog/newsyslog.conf.5 Sat Mar 26 00:34:35 2011 (r220015) >> @@ -21,7 +21,7 @@ >> .\" the suitability of this software for any purpose. It is >> .\" provided "as is" without express or implied warranty. >> .\" >> -.Dd January 31, 2011 >> +.Dd February 25, 2011 >> .Dt NEWSYSLOG.CONF 5 >> .Os >> .Sh NAME >> @@ -349,6 +349,11 @@ If this field is not present, then a >> .Dv SIGHUP >> signal will be sent. >> .El >> +.Sh EXAMPLES >> +The following is an example of the >> +.Dq Aq Li include >> +entry: >> +.Dl " /etc/newsyslog-local.conf" >> .Sh SEE ALSO >> .Xr bzip2 1 , >> .Xr gzip 1 , > -- Nothin' ever doesn't change, but nothin' changes much. -- OK Go Breadth of IT experience, and depth of knowledge in the DNS. Yours for the right price. :) http://SupersetSolutions.com/ From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 08:32: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 0131F106566B; Sun, 27 Mar 2011 08:32:48 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E65ED8FC08; Sun, 27 Mar 2011 08:32:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2R8Wlin051255; Sun, 27 Mar 2011 08:32:47 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2R8Wlq7051253; Sun, 27 Mar 2011 08:32:47 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103270832.p2R8Wlq7051253@svn.freebsd.org> From: Adrian Chadd Date: Sun, 27 Mar 2011 08:32:47 +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: r220051 - head/sys/mips/atheros 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, 27 Mar 2011 08:32:48 -0000 Author: adrian Date: Sun Mar 27 08:32:47 2011 New Revision: 220051 URL: http://svn.freebsd.org/changeset/base/220051 Log: Add some missing flags needed for AR913x/AR724x USB to correctly operate. The AR913x/AR724x USB lives at a different offset to the AR71xx USB, so this needs to be either adjusted for in a subsequent commit, or updated in hints for kernels compiled for those platforms. Submitted by: Luiz Otavio O Souzau Modified: head/sys/mips/atheros/ar71xx_ehci.c Modified: head/sys/mips/atheros/ar71xx_ehci.c ============================================================================== --- head/sys/mips/atheros/ar71xx_ehci.c Sun Mar 27 05:09:21 2011 (r220050) +++ head/sys/mips/atheros/ar71xx_ehci.c Sun Mar 27 08:32:47 2011 (r220051) @@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #define EHCI_HC_DEVSTR "AR71XX Integrated USB 2.0 controller" @@ -192,6 +193,19 @@ ar71xx_ehci_attach(device_t self) * register following a port enable. */ sc->sc_flags = EHCI_SCFLG_SETMODE; + + switch (ar71xx_soc) { + case AR71XX_SOC_AR7241: + case AR71XX_SOC_AR7242: + case AR71XX_SOC_AR9130: + case AR71XX_SOC_AR9132: + sc->sc_flags |= EHCI_SCFLG_TT | EHCI_SCFLG_NORESTERM; + break; + default: + /* fallthrough */ + break; + } + (void) ehci_reset(sc); err = ehci_init(sc); From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 08:44: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 264FA1065673; Sun, 27 Mar 2011 08:44:28 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F122E8FC12; Sun, 27 Mar 2011 08:44:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2R8iRxF051533; Sun, 27 Mar 2011 08:44:27 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2R8iROR051530; Sun, 27 Mar 2011 08:44:27 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103270844.p2R8iROR051530@svn.freebsd.org> From: Adrian Chadd Date: Sun, 27 Mar 2011 08:44: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: r220052 - in head/sys: conf mips/atheros 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, 27 Mar 2011 08:44:28 -0000 Author: adrian Date: Sun Mar 27 08:44:27 2011 New Revision: 220052 URL: http://svn.freebsd.org/changeset/base/220052 Log: Add an option - AR71XX_REALMEM - which overrides the amount of memory detected from Redboot, or overrides the "otherwise" case if no Redboot information was found. Some AR71XX platforms don't use Redboot (eg TP-LINK devices using UBoot; some later Ubiquiti devices which apparently also use UBoot) and at least one plain out lies - the Ubiquiti LS-SR71A Redboot says there's 16mb of RAM when in fact there's 32mb. A more "clean" solution will be needed at a later date. Modified: head/sys/conf/options head/sys/mips/atheros/ar71xx_machdep.c Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Sun Mar 27 08:32:47 2011 (r220051) +++ head/sys/conf/options Sun Mar 27 08:44:27 2011 (r220052) @@ -872,3 +872,9 @@ SDP opt_ofed.h SDP_DEBUG opt_ofed.h IPOIB_DEBUG opt_ofed.h IPOIB_CM opt_ofed.h + +# At least one of the AR71XX ubiquiti boards has a Redboot configuration +# that "lies" about the amount of RAM it has. Until a cleaner method is +# defined, this option will suffice in overriding what Redboot says. +AR71XX_REALMEM opt_global.h + Modified: head/sys/mips/atheros/ar71xx_machdep.c ============================================================================== --- head/sys/mips/atheros/ar71xx_machdep.c Sun Mar 27 08:32:47 2011 (r220051) +++ head/sys/mips/atheros/ar71xx_machdep.c Sun Mar 27 08:44:27 2011 (r220052) @@ -180,6 +180,20 @@ platform_start(__register_t a0 __unused, if (realmem == 0) realmem = btoc(32*1024*1024); + /* + * Allow build-time override in case Redboot lies + * or in other situations (eg where there's u-boot) + * where there isn't (yet) a convienent method of + * being told how much RAM is available. + * + * This happens on at least the Ubiquiti LS-SR71A + * board, where redboot says there's 16mb of RAM + * but in fact there's 32mb. + */ +#if defined(AR71XX_REALMEM) + realmem = btoc(MIPS_REALMEM); +#endif + /* phys_avail regions are in bytes */ phys_avail[0] = MIPS_KSEG0_TO_PHYS(kernel_kseg0_end); phys_avail[1] = ctob(realmem); From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 08:47: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 B07CC1065670; Sun, 27 Mar 2011 08:47:55 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A16068FC14; Sun, 27 Mar 2011 08:47:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2R8ltcs051637; Sun, 27 Mar 2011 08:47:55 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2R8ltJJ051633; Sun, 27 Mar 2011 08:47:55 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103270847.p2R8ltJJ051633@svn.freebsd.org> From: Adrian Chadd Date: Sun, 27 Mar 2011 08:47: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: r220053 - in head/sys: conf dev/ath 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, 27 Mar 2011 08:47:55 -0000 Author: adrian Date: Sun Mar 27 08:47:55 2011 New Revision: 220053 URL: http://svn.freebsd.org/changeset/base/220053 Log: Rename AH_ENABLE_11N to ATH_ENABLE_11 - the HAL supports 11n by default but the ath driver doesn't. This is a much more consistent name. Modified: head/sys/conf/options head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_athvar.h Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Sun Mar 27 08:44:27 2011 (r220052) +++ head/sys/conf/options Sun Mar 27 08:47:55 2011 (r220053) @@ -768,6 +768,7 @@ ATH_TXBUF opt_ath.h ATH_RXBUF opt_ath.h ATH_DIAGAPI opt_ath.h ATH_TX99_DIAG opt_ath.h +ATH_ENABLE_11N opt_ah.h # options for the Atheros hal AH_SUPPORT_AR5416 opt_ah.h @@ -784,7 +785,6 @@ AH_NEED_DESC_SWAP opt_ah.h AH_USE_INIPDGAIN opt_ah.h AH_MAXCHAN opt_ah.h AH_RXCFG_SDMAMW_4BYTES opt_ah.h -AH_ENABLE_11N opt_ah.h # options for the Broadcom BCM43xx driver (bwi) BWI_DEBUG opt_bwi.h Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Sun Mar 27 08:44:27 2011 (r220052) +++ head/sys/dev/ath/if_ath.c Sun Mar 27 08:47:55 2011 (r220053) @@ -612,7 +612,7 @@ ath_attach(u_int16_t devid, struct ath_s * Don't think of doing that unless you know what you're doing. */ -#ifdef AH_ENABLE_11N +#ifdef ATH_ENABLE_11N /* * Query HT capabilities */ Modified: head/sys/dev/ath/if_athvar.h ============================================================================== --- head/sys/dev/ath/if_athvar.h Sun Mar 27 08:44:27 2011 (r220052) +++ head/sys/dev/ath/if_athvar.h Sun Mar 27 08:47:55 2011 (r220053) @@ -46,7 +46,7 @@ /* * 802.11n requires more TX and RX buffers to do AMPDU. */ -#ifdef AH_ENABLE_11N +#ifdef ATH_ENABLE_11N #define ATH_TXBUF 512 #define ATH_RXBUF 512 #endif From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 10:35:39 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 A55D3106566B; Sun, 27 Mar 2011 10:35:39 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 95DB58FC20; Sun, 27 Mar 2011 10:35:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RAZdqI053834; Sun, 27 Mar 2011 10:35:39 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RAZd2l053832; Sun, 27 Mar 2011 10:35:39 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103271035.p2RAZd2l053832@svn.freebsd.org> From: Adrian Chadd Date: Sun, 27 Mar 2011 10:35: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: r220054 - head/sys/dev/ath 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, 27 Mar 2011 10:35:39 -0000 Author: adrian Date: Sun Mar 27 10:35:39 2011 New Revision: 220054 URL: http://svn.freebsd.org/changeset/base/220054 Log: Fix typo. Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Sun Mar 27 08:47:55 2011 (r220053) +++ head/sys/dev/ath/if_ath.c Sun Mar 27 10:35:39 2011 (r220054) @@ -1930,9 +1930,9 @@ ath_calcrxfilter(struct ath_softc *sc) #if 0 /* - * Enable hardware PS-POLL only for hostap mode; + * Enable hardware PS-POLL RX only for hostap mode; * STA mode sends PS-POLL frames but never - * sends them. + * receives them. */ if (ath_hal_getcapability(ah, HAL_CAP_HAS_PSPOLL, 0, NULL) == HAL_OK && From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 12:53: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 608AF106566B; Sun, 27 Mar 2011 12:53:20 +0000 (UTC) (envelope-from ume@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 501DB8FC0A; Sun, 27 Mar 2011 12:53:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RCrKhH058678; Sun, 27 Mar 2011 12:53:20 GMT (envelope-from ume@svn.freebsd.org) Received: (from ume@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RCrK6h058676; Sun, 27 Mar 2011 12:53:20 GMT (envelope-from ume@svn.freebsd.org) Message-Id: <201103271253.p2RCrK6h058676@svn.freebsd.org> From: Hajimu UMEMOTO Date: Sun, 27 Mar 2011 12:53: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: r220055 - head/usr.bin/su 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, 27 Mar 2011 12:53:20 -0000 Author: ume Date: Sun Mar 27 12:53:20 2011 New Revision: 220055 URL: http://svn.freebsd.org/changeset/base/220055 Log: getpwnam(3) may return NULL. Requested by: nork Reviewed by: Takeharu KATO , nork MFC after: 1 week Modified: head/usr.bin/su/su.c Modified: head/usr.bin/su/su.c ============================================================================== --- head/usr.bin/su/su.c Sun Mar 27 10:35:39 2011 (r220054) +++ head/usr.bin/su/su.c Sun Mar 27 12:53:20 2011 (r220055) @@ -149,7 +149,7 @@ int main(int argc, char *argv[]) { static char *cleanenv; - struct passwd *pwd; + struct passwd *pwd = NULL; struct pam_conv conv = { openpam_ttyconv, NULL }; enum tristate iscsh; login_cap_t *lc; @@ -255,8 +255,9 @@ main(int argc, char *argv[]) /* get current login name, real uid and shell */ ruid = getuid(); username = getlogin(); - pwd = getpwnam(username); - if (username == NULL || pwd == NULL || pwd->pw_uid != ruid) + if (username != NULL) + pwd = getpwnam(username); + if (pwd == NULL || pwd->pw_uid != ruid) pwd = getpwuid(ruid); if (pwd == NULL) { #ifdef USE_BSM_AUDIT From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 13:55: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 5C7121065670; Sun, 27 Mar 2011 13:55:36 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 312CE8FC08; Sun, 27 Mar 2011 13:55:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RDta0U059960; Sun, 27 Mar 2011 13:55:36 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RDta4Z059958; Sun, 27 Mar 2011 13:55:36 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103271355.p2RDta4Z059958@svn.freebsd.org> From: Adrian Chadd Date: Sun, 27 Mar 2011 13:55:36 +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: r220056 - head/sys/mips/atheros 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, 27 Mar 2011 13:55:36 -0000 Author: adrian Date: Sun Mar 27 13:55:35 2011 New Revision: 220056 URL: http://svn.freebsd.org/changeset/base/220056 Log: Refactor out the ar71xx mac address code into something that's just for Redboot. At some point we're going to need to build options for different boot environments - for example, the UBoot setups I've seen simply have the MAC address hard-coded at a fixed location in flash. The OpenWRT support simply yanks the if_arge MAC directly from that in code, rather than trying to find a uboot environment to pull it from. Modified: head/sys/mips/atheros/ar71xx_machdep.c Modified: head/sys/mips/atheros/ar71xx_machdep.c ============================================================================== --- head/sys/mips/atheros/ar71xx_machdep.c Sun Mar 27 12:53:20 2011 (r220055) +++ head/sys/mips/atheros/ar71xx_machdep.c Sun Mar 27 13:55:35 2011 (r220056) @@ -139,13 +139,39 @@ platform_trap_exit(void) } +/* + * Obtain the MAC address via the Redboot environment. + */ +static void +ar71xx_redboot_get_macaddr(void) +{ + char *var; + int count = 0; + + /* + * "ethaddr" is passed via envp on RedBoot platforms + * "kmac" is passed via argv on RouterBOOT platforms + */ + if ((var = getenv("ethaddr")) != NULL || + (var = getenv("kmac")) != NULL) { + count = sscanf(var, "%x%*c%x%*c%x%*c%x%*c%x%*c%x", + &ar711_base_mac[0], &ar711_base_mac[1], + &ar711_base_mac[2], &ar711_base_mac[3], + &ar711_base_mac[4], &ar711_base_mac[5]); + if (count < 6) + memset(ar711_base_mac, 0, + sizeof(ar711_base_mac)); + freeenv(var); + } +} + void platform_start(__register_t a0 __unused, __register_t a1 __unused, __register_t a2 __unused, __register_t a3 __unused) { uint64_t platform_counter_freq; - int argc, i, count = 0; - char **argv, **envp, *var; + int argc, i; + char **argv, **envp; vm_offset_t kernend; /* @@ -252,21 +278,8 @@ platform_start(__register_t a0 __unused, else printf ("envp is invalid\n"); - /* - * "ethaddr" is passed via envp on RedBoot platforms - * "kmac" is passed via argv on RouterBOOT platforms - */ - if ((var = getenv("ethaddr")) != NULL || - (var = getenv("kmac")) != NULL) { - count = sscanf(var, "%x%*c%x%*c%x%*c%x%*c%x%*c%x", - &ar711_base_mac[0], &ar711_base_mac[1], - &ar711_base_mac[2], &ar711_base_mac[3], - &ar711_base_mac[4], &ar711_base_mac[5]); - if (count < 6) - memset(ar711_base_mac, 0, - sizeof(ar711_base_mac)); - freeenv(var); - } + /* Redboot if_arge MAC address is in the environment */ + ar71xx_redboot_get_macaddr(); init_param2(physmem); mips_cpu_init(); From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 14:20: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 F3EEE106564A; Sun, 27 Mar 2011 14:20:47 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E2DA48FC14; Sun, 27 Mar 2011 14:20:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2REKlNv060577; Sun, 27 Mar 2011 14:20:47 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2REKlV3060575; Sun, 27 Mar 2011 14:20:47 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201103271420.p2REKlV3060575@svn.freebsd.org> From: Josh Paetzel Date: Sun, 27 Mar 2011 14:20:47 +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: r220057 - head/usr.sbin/pc-sysinstall/backend 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, 27 Mar 2011 14:20:48 -0000 Author: jpaetzel Date: Sun Mar 27 14:20:47 2011 New Revision: 220057 URL: http://svn.freebsd.org/changeset/base/220057 Log: Increase size of boot partition to give breathing room in the future. Approved by: kib (mentor) Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Sun Mar 27 13:55:35 2011 (r220056) +++ head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Sun Mar 27 14:20:47 2011 (r220057) @@ -596,7 +596,7 @@ init_gpt_full_disk() echo_log "Running gpart on ${_intDISK}" rc_halt "gpart create -s GPT ${_intDISK}" - rc_halt "gpart add -b 34 -s 64 -t freebsd-boot ${_intDISK}" + rc_halt "gpart add -b 34 -s 128 -t freebsd-boot ${_intDISK}" echo_log "Stamping boot sector on ${_intDISK}" rc_halt "gpart bootcode -b /boot/pmbr ${_intDISK}" From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 16:18: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 7412C1065670; Sun, 27 Mar 2011 16:18:51 +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 61EF28FC18; Sun, 27 Mar 2011 16:18:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RGIpx0062859; Sun, 27 Mar 2011 16:18:51 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RGIpmn062856; Sun, 27 Mar 2011 16:18:51 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201103271618.p2RGIpmn062856@svn.freebsd.org> From: Alan Cox Date: Sun, 27 Mar 2011 16:18: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: r220058 - in head/sys/amd64: amd64 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: Sun, 27 Mar 2011 16:18:51 -0000 Author: alc Date: Sun Mar 27 16:18:51 2011 New Revision: 220058 URL: http://svn.freebsd.org/changeset/base/220058 Log: Amd64 doesn't have a lazypmap ipi. Modified: head/sys/amd64/amd64/mp_machdep.c head/sys/amd64/include/smp.h Modified: head/sys/amd64/amd64/mp_machdep.c ============================================================================== --- head/sys/amd64/amd64/mp_machdep.c Sun Mar 27 14:20:47 2011 (r220057) +++ head/sys/amd64/amd64/mp_machdep.c Sun Mar 27 16:18:51 2011 (r220058) @@ -116,7 +116,6 @@ u_long *ipi_invlrng_counts[MAXCPU]; u_long *ipi_invlpg_counts[MAXCPU]; u_long *ipi_invlcache_counts[MAXCPU]; u_long *ipi_rendezvous_counts[MAXCPU]; -u_long *ipi_lazypmap_counts[MAXCPU]; static u_long *ipi_hardclock_counts[MAXCPU]; #endif @@ -1620,8 +1619,6 @@ mp_ipi_intrcnt(void *dummy) intrcnt_add(buf, &ipi_ast_counts[i]); snprintf(buf, sizeof(buf), "cpu%d:rendezvous", i); intrcnt_add(buf, &ipi_rendezvous_counts[i]); - snprintf(buf, sizeof(buf), "cpu%d:lazypmap", i); - intrcnt_add(buf, &ipi_lazypmap_counts[i]); snprintf(buf, sizeof(buf), "cpu%d:hardclock", i); intrcnt_add(buf, &ipi_hardclock_counts[i]); } Modified: head/sys/amd64/include/smp.h ============================================================================== --- head/sys/amd64/include/smp.h Sun Mar 27 14:20:47 2011 (r220057) +++ head/sys/amd64/include/smp.h Sun Mar 27 16:18:51 2011 (r220058) @@ -41,7 +41,6 @@ extern u_long *ipi_invlrng_counts[MAXCPU extern u_long *ipi_invlpg_counts[MAXCPU]; extern u_long *ipi_invlcache_counts[MAXCPU]; extern u_long *ipi_rendezvous_counts[MAXCPU]; -extern u_long *ipi_lazypmap_counts[MAXCPU]; #endif /* IPI handlers */ From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 16:57: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 B9067106566C; Sun, 27 Mar 2011 16:57:54 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A57CE8FC14; Sun, 27 Mar 2011 16:57:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RGvsbb063698; Sun, 27 Mar 2011 16:57:54 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RGvs2m063692; Sun, 27 Mar 2011 16:57:54 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201103271657.p2RGvs2m063692@svn.freebsd.org> From: Josh Paetzel Date: Sun, 27 Mar 2011 16:57: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: r220059 - head/usr.sbin/pc-sysinstall/backend 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, 27 Mar 2011 16:57:54 -0000 Author: jpaetzel Date: Sun Mar 27 16:57:54 2011 New Revision: 220059 URL: http://svn.freebsd.org/changeset/base/220059 Log: Fix a syntax error in a little-used function. Replace expr with $(()) Replace grep > /dev/null with grep -q Replace "$?" = "0" with $? -eq 0 in tests Consolidate export statements with variable assignment Replace tests for ! -z with -n Approved by: kib (mentor) Modified: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh head/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh head/usr.sbin/pc-sysinstall/backend/functions-disk.sh head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh head/usr.sbin/pc-sysinstall/backend/functions-ftp.sh head/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh head/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh head/usr.sbin/pc-sysinstall/backend/functions-localize.sh head/usr.sbin/pc-sysinstall/backend/functions-mountoptical.sh head/usr.sbin/pc-sysinstall/backend/functions-networking.sh head/usr.sbin/pc-sysinstall/backend/functions-packages.sh head/usr.sbin/pc-sysinstall/backend/functions-parse.sh head/usr.sbin/pc-sysinstall/backend/functions-runcommands.sh head/usr.sbin/pc-sysinstall/backend/functions-unmount.sh head/usr.sbin/pc-sysinstall/backend/functions-upgrade.sh head/usr.sbin/pc-sysinstall/backend/functions-users.sh head/usr.sbin/pc-sysinstall/backend/functions.sh head/usr.sbin/pc-sysinstall/backend/parseconfig.sh head/usr.sbin/pc-sysinstall/backend/startautoinstall.sh Modified: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh Sun Mar 27 16:18:51 2011 (r220058) +++ head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh Sun Mar 27 16:57:54 2011 (r220059) @@ -33,14 +33,14 @@ check_for_enc_pass() CURLINE="${1}" get_next_cfg_line "${CFGF}" "${CURLINE}" - echo ${VAL} | grep "^encpass=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo ${VAL} | grep -q "^encpass=" 2>/dev/null + if [ $? -eq 0 ] ; then # Found a password, return it get_value_from_string "${VAL}" return fi - VAL="" ; export VAL + export VAL="" return }; @@ -51,17 +51,17 @@ get_fs_line_xvars() ACTIVEDEV="${1}" LINE="${2}" - echo $LINE | grep ' (' >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo $LINE | grep -q ' (' 2>/dev/null + if [ $? -eq 0 ] ; then # See if we are looking for ZFS specific options - echo $LINE | grep '^ZFS' >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo $LINE | grep -q '^ZFS' 2>/dev/null + if [ $? -eq 0 ] ; then ZTYPE="NONE" ZFSVARS="`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`" - echo $ZFSVARS | grep -E "^(disk|file|mirror|raidz(1|2)?|spare|log|cache):" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo $ZFSVARS | grep -qE "^(disk|file|mirror|raidz(1|2)?|spare|log|cache):" 2>/dev/null + if [ $? -eq 0 ] ; then ZTYPE=`echo $ZFSVARS | cut -f1 -d:` ZFSVARS=`echo $ZFSVARS | sed "s|$ZTYPE: ||g" | sed "s|$ZTYPE:||g"` fi @@ -79,8 +79,7 @@ get_fs_line_xvars() fi # End of xtra-options block # If we got here, set VAR to empty and export - VAR="" - export VAR + export VAR="" return }; @@ -94,12 +93,12 @@ setup_zfs_mirror_parts() for _zvars in $_mirrline do echo "Looping through _zvars: $_zvars" >>${LOGOUT} - echo "$_zvars" | grep "${2}" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then continue ; fi + echo "$_zvars" | grep -q "${2}" 2>/dev/null + if [ $? -eq 0 ] ; then continue ; fi if [ -z "$_zvars" ] ; then continue ; fi is_disk "$_zvars" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + if [ $? -eq 0 ] ; then echo "Setting up ZFS mirror disk $_zvars" >>${LOGOUT} init_gpt_full_disk "$_zvars" >/dev/null 2>/dev/null rc_halt "gpart bootcode -p /boot/gptzfsboot -i 1 ${_zvars}" >/dev/null 2>/dev/null @@ -138,12 +137,12 @@ gen_glabel_name() while Z=1 do - glabel status | grep "${NAME}${NUM}" >/dev/null 2>/dev/null - if [ "$?" != "0" ] + glabel status | grep -q "${NAME}${NUM}" 2>/dev/null + if [ $? -ne 0 ] then break else - NUM="`expr ${NUM} + 1`" + NUM=$((NUM+1)) fi if [ $NUM -gt $MAXNUM ] @@ -154,8 +153,7 @@ gen_glabel_name() done - VAL="${NAME}${NUM}" - export VAL + export VAL="${NAME}${NUM}" }; # Function to setup partitions using gpart @@ -180,8 +178,8 @@ setup_gpart_partitions() while read line do # Check for data on this slice - echo $line | grep "^${_dTag}-part=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo $line | grep -q "^${_dTag}-part=" 2>/dev/null + if [ $? -eq 0 ] then FOUNDPARTS="0" # Found a slice- entry, lets get the slice info @@ -194,8 +192,8 @@ setup_gpart_partitions() MNT=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 3` # Check if we have a .eli extension on this FS - echo ${FS} | grep ".eli" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo ${FS} | grep -q ".eli" 2>/dev/null + if [ $? -eq 0 ] then FS="`echo ${FS} | cut -d '.' -f 1`" ENC="ON" @@ -210,9 +208,9 @@ setup_gpart_partitions() # Check if the user tried to setup / as an encrypted partition check_for_mount "${MNT}" "/" - if [ "${?}" = "0" -a "${ENC}" = "ON" ] + if [ $? -eq 0 -a "${ENC}" = "ON" ] then - USINGENCROOT="0" ; export USINGENCROOT + export USINGENCROOT="0" fi # Now check that these values are sane @@ -223,13 +221,13 @@ setup_gpart_partitions() # Check that we have a valid size number expr $SIZE + 1 >/dev/null 2>/dev/null - if [ "$?" != "0" ]; then + if [ $? -ne 0 ]; then exit_err "ERROR: The size specified on $line is invalid" fi # Check that the mount-point starts with / - echo "$MNT" | grep -e "^/" -e "^none" >/dev/null 2>/dev/null - if [ "$?" != "0" ]; then + echo "$MNT" | grep -qe "^/" -e "^none" 2>/dev/null + if [ $? -ne 0 ]; then exit_err "ERROR: The mount-point specified on $line is invalid" fi @@ -242,19 +240,19 @@ setup_gpart_partitions() # Check if we found a valid root partition check_for_mount "${MNT}" "/" - if [ "${?}" = "0" ] ; then - FOUNDROOT="1" ; export FOUNDROOT + if [ $? -eq 0 ] ; then + export FOUNDROOT="1" if [ "${CURPART}" = "2" -a "$_pType" = "gpt" ] ; then - FOUNDROOT="0" ; export FOUNDROOT + export FOUNDROOT="0" fi if [ "${CURPART}" = "1" -a "$_pType" = "mbr" ] ; then - FOUNDROOT="0" ; export FOUNDROOT + export FOUNDROOT="0" fi fi check_for_mount "${MNT}" "/boot" - if [ "${?}" = "0" ] ; then - USINGBOOTPART="0" ; export USINGBOOTPART + if [ $? -eq 0 ] ; then + export USINGBOOTPART="0" if [ "${CURPART}" != "2" -a "${_pType}" = "gpt" ] ; then exit_err "/boot partition must be first partition" fi @@ -280,8 +278,8 @@ setup_gpart_partitions() XTRAOPTS="${VAR}" # Check if using zfs mirror - echo ${XTRAOPTS} | grep "mirror" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo ${XTRAOPTS} | grep -q "mirror" 2>/dev/null + if [ $? -eq 0 ] ; then if [ "${_pType}" = "gpt" ] ; then XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_pDisk}p${CURPART}") else @@ -325,10 +323,10 @@ setup_gpart_partitions() # Clear out any headers sleep 2 - dd if=/dev/zero of=${_pDisk}p${CURPART} count=2048 >/dev/null 2>/dev/null + dd if=/dev/zero of=${_pDisk}p${CURPART} count=2048 2>/dev/null # If we have a enc password, save it as well - if [ ! -z "${ENCPASS}" ] ; then + if [ -n "${ENCPASS}" ] ; then echo "${ENCPASS}" >${PARTDIR}-enc/${_pDisk}p${CURPART}-encpass fi else @@ -336,10 +334,10 @@ setup_gpart_partitions() echo "${FS}:${MNT}:${ENC}:${PLABEL}:MBR:${XTRAOPTS}:${IMAGE}" >${PARTDIR}/${_wSlice}${PARTLETTER} # Clear out any headers sleep 2 - dd if=/dev/zero of=${_wSlice}${PARTLETTER} count=2048 >/dev/null 2>/dev/null + dd if=/dev/zero of=${_wSlice}${PARTLETTER} count=2048 2>/dev/null # If we have a enc password, save it as well - if [ ! -z "${ENCPASS}" ] ; then + if [ -n "${ENCPASS}" ] ; then echo "${ENCPASS}" >${PARTDIR}-enc/${_wSlice}${PARTLETTER}-encpass fi fi @@ -347,11 +345,11 @@ setup_gpart_partitions() # Increment our parts counter if [ "$_pType" = "gpt" ] ; then - CURPART="`expr ${CURPART} + 1`" + CURPART=$((CURPART+1)) # If this is a gpt partition, we can continue and skip the MBR part letter stuff continue else - CURPART="`expr ${CURPART} + 1`" + CURPART=$((CURPART+1)) if [ "$CURPART" = "3" ] ; then CURPART="4" ; fi fi @@ -370,8 +368,8 @@ setup_gpart_partitions() fi # End of subsection locating a slice in config - echo $line | grep "^commitDiskLabel" >/dev/null 2>/dev/null - if [ "$?" = "0" -a "${FOUNDPARTS}" = "0" ] + echo $line | grep -q "^commitDiskLabel" 2>/dev/null + if [ $? -eq 0 -a "${FOUNDPARTS}" = "0" ] then # If this is the boot disk, stamp the right gptboot @@ -455,20 +453,17 @@ setup_disk_label() done # Setup some files which we'll be referring to - LABELLIST="${TMPDIR}/workingLabels" - export LABELLIST + export LABELLIST="${TMPDIR}/workingLabels" rm $LABELLIST >/dev/null 2>/dev/null # Set our flag to determine if we've got a valid root partition in this setup - FOUNDROOT="-1" - export FOUNDROOT + export FOUNDROOT="-1" # Check if we are using a /boot partition - USINGBOOTPART="1" - export USINGBOOTPART + export USINGBOOTPART="1" # Set encryption on root check - USINGENCROOT="1" ; export USINGENCROOT + export USINGENCROOT="1" # Make the tmp directory where we'll store FS info & mount-points rm -rf ${PARTDIR} >/dev/null 2>/dev/null @@ -516,8 +511,8 @@ check_fstab_mbr() then PARTLETTER=`echo "$SLICE" | sed -E 's|^.+([a-h])$|\1|'` - cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/$' >/dev/null 2>&1 - if [ "$?" = "0" ] + cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/$' 2>&1 + if [ $? -eq 0 ] then if [ "${PARTLETTER}" = "a" ] then @@ -532,8 +527,8 @@ check_fstab_mbr() export ROOTIMAGE fi - cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/boot$' >/dev/null 2>&1 - if [ "$?" = "0" ] + cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/boot$' 2>&1 + if [ $? -eq 0 ] then if [ "${PARTLETTER}" = "a" ] then @@ -567,8 +562,8 @@ check_fstab_gpt() then PARTNUMBER=`echo "${SLICE}" | sed -E 's|^.+p([0-9]*)$|\1|'` - cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/$' >/dev/null 2>&1 - if [ "$?" = "0" ] + cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/$' 2>&1 + if [ $? -eq 0 ] then if [ "${PARTNUMBER}" = "2" ] then @@ -583,8 +578,8 @@ check_fstab_gpt() export ROOTIMAGE fi - cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/boot$' >/dev/null 2>&1 - if [ "$?" = "0" ] + cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/boot$' 2>&1 + if [ $? -eq 0 ] then if [ "${PARTNUMBER}" = "2" ] then @@ -645,7 +640,7 @@ check_disk_layout() do F=1 mount ${slice} /mnt 2>/dev/null - if [ "$?" != "0" ] + if [ $? -ne 0 ] then continue fi @@ -661,7 +656,7 @@ check_disk_layout() F="$?" fi - if [ "${F}" = "0" ] + if [ ${F} -eq 0 ] then umount /mnt break Modified: head/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh Sun Mar 27 16:18:51 2011 (r220058) +++ head/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh Sun Mar 27 16:57:54 2011 (r220059) @@ -46,27 +46,27 @@ zfs_cleanup_unmount() then # Make sure we haven't already added the zfs boot line when # Creating a dedicated "/boot" partition - cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep "vfs.root.mountfrom=" >/dev/null 2>/dev/null - if [ "$?" != "0" ] ; then + cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q "vfs.root.mountfrom=" 2>/dev/null + if [ $? -ne 0 ] ; then echo "vfs.root.mountfrom=\"zfs:${ZPOOLNAME}\"" >> ${FSMNT}/boot/loader.conf fi - FOUNDZFSROOT="${ZPOOLNAME}" ; export FOUNDZFSROOT + export FOUNDZFSROOT="${ZPOOLNAME}" fi done FOUNDZFS="1" fi done - if [ ! -z "${FOUNDZFS}" ] + if [ -n "${FOUNDZFS}" ] then # Check if we need to add our ZFS flags to rc.conf, src.conf and loader.conf - cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep 'zfs_load="YES"' >/dev/null 2>/dev/null - if [ "$?" != "0" ] + cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q 'zfs_load="YES"' 2>/dev/null + if [ $? -ne 0 ] then echo 'zfs_load="YES"' >>${FSMNT}/boot/loader.conf fi - cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep 'zfs_enable="YES"' >/dev/null 2>/dev/null - if [ "$?" != "0" ] + cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep -q 'zfs_enable="YES"' 2>/dev/null + if [ $? -ne 0 ] then echo 'zfs_enable="YES"' >>${FSMNT}/etc/rc.conf fi @@ -172,7 +172,7 @@ setup_fstab() # Figure out if we are using a glabel, or the raw name for this entry - if [ ! -z "${PARTLABEL}" ] + if [ -n "${PARTLABEL}" ] then DEVICE="label/${PARTLABEL}" else @@ -190,7 +190,7 @@ setup_fstab() # Set our ROOTFSTYPE for loader.conf if necessary check_for_mount "${PARTMNT}" "/" - if [ "$?" = "0" ] ; then + if [ $? -eq 0 ] ; then if [ "${PARTFS}" = "ZFS" ] ; then ROOTFSTYPE="zfs" XPOOLNAME=$(get_zpool_name "${PART}") @@ -263,12 +263,12 @@ setup_gmirror() sleep 3 - NUM="`expr ${NUM} + 1`" + NUM=$((NUM+1)) done - cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep 'geom_mirror_load="YES"' >/dev/null 2>/dev/null - if [ "$?" != "0" ] + cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q 'geom_mirror_load="YES"' 2>/dev/null + if [ $? -ne 0 ] then echo 'geom_mirror_load="YES"' >>${FSMNT}/boot/loader.conf fi @@ -304,8 +304,8 @@ setup_geli_loading() done # Make sure we have geom_eli set to load at boot - cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep 'geom_eli_load="YES"' >/dev/null 2>/dev/null - if [ "$?" != "0" ] + cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q 'geom_eli_load="YES"' 2>/dev/null + if [ $? -ne 0 ] then echo 'geom_eli_load="YES"' >>${FSMNT}/boot/loader.conf fi @@ -360,8 +360,8 @@ setup_gjournal() { # Make sure we have geom_journal set to load at boot - cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep 'geom_journal_load="YES"' >/dev/null 2>/dev/null - if [ "$?" != "0" ] + cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q 'geom_journal_load="YES"' 2>/dev/null + if [ $? -ne 0 ] then echo 'geom_journal_load="YES"' >>${FSMNT}/boot/loader.conf fi @@ -385,14 +385,14 @@ set_root_pw() echo_log "Setting root password" # Check if setting plaintext password - if [ ! -z "${PW}" ] ; then + if [ -n "${PW}" ] ; then echo "${PW}" > ${FSMNT}/.rootpw run_chroot_cmd "cat /.rootpw | pw usermod root -h 0" rc_halt "rm ${FSMNT}/.rootpw" fi # Check if setting encrypted password - if [ ! -z "${ENCPW}" ] ; then + if [ -n "${ENCPW}" ] ; then echo "${ENCPW}" > ${FSMNT}/.rootpw run_chroot_cmd "cat /.rootpw | pw usermod root -H 0" rc_halt "rm ${FSMNT}/.rootpw" @@ -405,7 +405,7 @@ run_final_cleanup() { # Check if we need to run any gmirror setup ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null - if [ "$?" = "0" ] + if [ $? -eq 0 ] then # Lets setup gmirror now setup_gmirror @@ -413,7 +413,7 @@ run_final_cleanup() # Check if we need to save any geli keys ls ${GELIKEYDIR}/* >/dev/null 2>/dev/null - if [ "$?" = "0" ] + if [ $? -eq 0 ] then # Lets setup geli loading setup_geli_loading Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Sun Mar 27 16:18:51 2011 (r220058) +++ head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Sun Mar 27 16:57:54 2011 (r220059) @@ -32,7 +32,7 @@ is_disk() { for _dsk in `sysctl -n kern.disks` do - if [ "$_dsk" = "${1}" ] ; then return 0 ; fi + [ "$_dsk" = "${1}" ] && return 0 done return 1 @@ -47,8 +47,8 @@ get_partition_sysid_mbr() fdisk ${DISK} >${TMPDIR}/disk-${DISK} 2>/dev/null while read i do - echo "$i" | grep "The data for partition" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo "$i" | grep -q "The data for partition" 2>/dev/null + if [ $? -eq 0 ] ; then INPART="0" PART="`echo ${i} | cut -d ' ' -f 5`" if [ "$PART" = "$PARTNUM" ] ; then @@ -58,8 +58,8 @@ get_partition_sysid_mbr() # In the partition section if [ "$INPART" = "1" ] ; then - echo "$i" | grep "^sysid" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo "$i" | grep -q "^sysid" 2>/dev/null + if [ $? -eq 0 ] ; then SYSID="`echo ${i} | tr -s '\t' ' ' | cut -d ' ' -f 2`" break fi @@ -69,8 +69,7 @@ get_partition_sysid_mbr() done < ${TMPDIR}/disk-${DISK} rm ${TMPDIR}/disk-${DISK} - VAL="${SYSID}" - export VAL + export VAL="${SYSID}" }; # Get the partitions MBR label @@ -82,8 +81,8 @@ get_partition_label_mbr() fdisk ${DISK} >${TMPDIR}/disk-${DISK} 2>/dev/null while read i do - echo "$i" | grep "The data for partition" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo "$i" | grep -q "The data for partition" 2>/dev/null + if [ $? -eq 0 ] ; then INPART="0" PART="`echo ${i} | cut -d ' ' -f 5`" if [ "$PART" = "$PARTNUM" ] ; then @@ -93,8 +92,8 @@ get_partition_label_mbr() # In the partition section if [ "$INPART" = "1" ] ; then - echo "$i" | grep "^sysid" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo "$i" | grep -q "^sysid" 2>/dev/null + if [ $? -eq 0 ] ; then LABEL="`echo ${i} | tr -s '\t' ' ' | cut -d ',' -f 2-10`" break fi @@ -104,8 +103,7 @@ get_partition_label_mbr() done < ${TMPDIR}/disk-${DISK} rm ${TMPDIR}/disk-${DISK} - VAL="${LABEL}" - export VAL + export VAL="${LABEL}" }; # Get a GPT partitions label @@ -125,8 +123,7 @@ get_partition_label_gpt() done <${TMPDIR}/disk-${DISK} rm ${TMPDIR}/disk-${DISK} - VAL="${LABEL}" - export VAL + export VAL="${LABEL}" }; # Get a partitions startblock @@ -146,8 +143,7 @@ get_partition_startblock() done <${TMPDIR}/disk-${DISK} rm ${TMPDIR}/disk-${DISK} - VAL="${SB}" - export VAL + export VAL="${SB}" }; # Get a partitions blocksize @@ -167,16 +163,15 @@ get_partition_blocksize() done <${TMPDIR}/disk-${DISK} rm ${TMPDIR}/disk-${DISK} - VAL="${BS}" - export VAL + export VAL="${BS}" }; # Function which returns the partitions on a target disk get_disk_partitions() { gpart show ${1} >/dev/null 2>/dev/null - if [ "$?" != "0" ] ; then - VAL="" ; export VAL + if [ $? -ne 0 ] ; then + export VAL="" return fi @@ -198,35 +193,35 @@ get_disk_partitions() fi done - VAL="${RSLICES}" ; export VAL + export VAL="${RSLICES}" }; # Function which returns a target disks cylinders get_disk_cyl() { cyl=`diskinfo -v ${1} | grep "# Cylinders" | tr -s ' ' | cut -f 2` - VAL="${cyl}" ; export VAL + export VAL="${cyl}" }; # Function which returns a target disks sectors get_disk_sectors() { sec=`diskinfo -v ${1} | grep "# Sectors" | tr -s ' ' | cut -f 2` - VAL="${sec}" ; export VAL + export VAL="${sec}" }; # Function which returns a target disks heads get_disk_heads() { head=`diskinfo -v ${1} | grep "# Heads" | tr -s ' ' | cut -f 2` - VAL="${head}" ; export VAL + export VAL="${head}" }; # Function which returns a target disks mediasize in sectors get_disk_mediasize() { mediasize=`diskinfo -v ${1} | grep "# mediasize in sectors" | tr -s ' ' | cut -f 2` - VAL="${mediasize}" ; export VAL + export VAL="${mediasize}" }; # Function which exports all zpools, making them safe to overwrite potentially @@ -288,8 +283,8 @@ stop_all_gmirror() GPROV="`gmirror list | grep ". Name: mirror/" | cut -d '/' -f 2`" for gprov in $GPROV do - gmirror list | grep "Name: ${DISK}" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + gmirror list | grep -q "Name: ${DISK}" 2>/dev/null + if [ $? -eq 0 ] then echo_log "Stopping mirror $gprov $DISK" rc_nohalt "gmirror remove $gprov $DISK" @@ -306,8 +301,8 @@ stop_all_geli() for i in `ls ${_geld}*` do - echo $i | grep '.eli' >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo $i | grep -q '.eli' 2>/dev/null + if [ $? -eq 0 ] then echo_log "Detaching GELI on ${i}" rc_halt "geli detach ${i}" @@ -335,8 +330,8 @@ setup_disk_slice() # We are ready to start setting up the disks, lets read the config and do the actions while read line do - echo $line | grep "^disk${disknum}=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo $line | grep -q "^disk${disknum}=" 2>/dev/null + if [ $? -eq 0 ] then # Found a disk= entry, lets get the disk we are working on @@ -362,8 +357,8 @@ setup_disk_slice() fi # Lets look if this device will be mirrored on another disk - echo $line | grep "^mirror=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo $line | grep -q "^mirror=" 2>/dev/null + if [ $? -eq 0 ] then # Found a disk= entry, lets get the disk we are working on @@ -379,8 +374,8 @@ setup_disk_slice() fi # Lets see if we have been given a mirror balance choice - echo $line | grep "^mirrorbal=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo $line | grep -q "^mirrorbal=" 2>/dev/null + if [ $? -eq 0 ] then # Found a disk= entry, lets get the disk we are working on @@ -389,8 +384,8 @@ setup_disk_slice() MIRRORBAL="$VAL" fi - echo $line | grep "^partition=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo $line | grep -q "^partition=" 2>/dev/null + if [ $? -eq 0 ] then # Found a partition= entry, lets read / set it get_value_from_string "${line}" @@ -413,7 +408,7 @@ setup_disk_slice() then LASTSLICE="1" else - LASTSLICE="`expr $LASTSLICE + 1`" + LASTSLICE=$((LASTSLICE+1)) fi if [ $LASTSLICE -gt 4 ] @@ -425,8 +420,8 @@ setup_disk_slice() fi # Check if we have an image file defined - echo $line | grep "^image=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo $line | grep -q "^image=" 2>/dev/null + if [ $? eq 0 ] ; then # Found an image= entry, lets read / set it get_value_from_string "${line}" strip_white_space "$VAL" @@ -437,8 +432,8 @@ setup_disk_slice() fi # Check if we have a partscheme specified - echo $line | grep "^partscheme=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo $line | grep -q "^partscheme=" 2>/dev/null + if [ $? -eq 0 ] ; then # Found a partscheme= entry, lets read / set it get_value_from_string "${line}" strip_white_space "$VAL" @@ -448,8 +443,8 @@ setup_disk_slice() fi fi - echo $line | grep "^bootManager=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo $line | grep -q "^bootManager=" 2>/dev/null + if [ $? -eq 0 ] then # Found a bootManager= entry, lets read /set it get_value_from_string "${line}" @@ -457,8 +452,8 @@ setup_disk_slice() BMANAGER="$VAL" fi - echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo $line | grep -q "^commitDiskPart" 2>/dev/null + if [ $? -eq 0 ] then # Found our flag to commit this disk setup / lets do sanity check and do it if [ ! -z "${DISK}" -a ! -z "${PTYPE}" ] @@ -520,7 +515,7 @@ setup_disk_slice() fi # Save any mirror config - if [ ! -z "$MIRRORDISK" ] + if [ -n "$MIRRORDISK" ] then # Default to round-robin if the user didn't specify if [ -z "$MIRRORBAL" ] @@ -532,7 +527,7 @@ setup_disk_slice() # Increment our disk counter to look for next disk and unset unset BMANAGER PTYPE DISK MIRRORDISK MIRRORBAL PSCHEME IMAGE - disknum="`expr $disknum + 1`" + disknum=$((disknum+1)) else exit_err "ERROR: commitDiskPart was called without procceding disk= and partition= entries!!!" fi @@ -548,7 +543,7 @@ stop_gjournal() _gdsk="$1" # Check if we need to shutdown any journals on this drive ls /dev/${_gdsk}*.journal >/dev/null 2>/dev/null - if [ "$?" = "0" ] + if [ $? -eq 0 ] then cd /dev for i in `ls ${_gdsk}*.journal` @@ -569,7 +564,7 @@ clear_backup_gpt_table() # Make sure this is a valid number is_num "${dSize}" >/dev/null 2>/dev/null - if [ "$?" != "0" ] ; then return ; fi + [ $? -ne 0 ] && return # Die backup label, DIE echo_log "Clearing gpt backup table location on disk" @@ -697,7 +692,7 @@ run_gpart_full() run_gpart_slice() { DISK=$1 - if [ ! -z "$2" ] + if [ -n "$2" ] then BMANAGER="$2" fi @@ -757,7 +752,7 @@ run_gpart_free() { DISK=$1 SLICENUM=$2 - if [ ! -z "$3" ] + if [ -n "$3" ] then BMANAGER="$3" fi @@ -770,7 +765,7 @@ run_gpart_free() # Working on the first slice, make sure we have MBR setup gpart show ${DISK} >/dev/null 2>/dev/null - if [ "$?" != "0" -a "$SLICENUM" = "1" ] ; then + if [ $? -ne 0 -a "$SLICENUM" = "1" ] ; then echo_log "Initializing disk, no existing MBR setup" rc_halt "gpart create -s mbr ${DISK}" fi @@ -781,12 +776,12 @@ run_gpart_free() startblock="63" else # Lets figure out where the prior slice ends - checkslice="`expr ${slicenum} - 1`" + checkslice=$((slicenum-1)) # Get starting block of this slice sblk=`gpart show ${DISK} | grep -v ${DISK} | tr -s '\t' ' ' | sed '/^$/d' | grep " ${checkslice} " | cut -d ' ' -f 2` blksize=`gpart show ${DISK} | grep -v ${DISK} | tr -s '\t' ' ' | sed '/^$/d' | grep " ${checkslice} " | cut -d ' ' -f 3` - startblock="`expr ${sblk} + ${blksize}`" + startblock=$((sblk+blksiz)) fi # No slice after the new slice, lets figure out the free space remaining and use it @@ -803,12 +798,12 @@ run_gpart_free() sec="${VAL}" # Multiply them all together to get our total blocks - totalblocks="`expr ${cyl} \* ${head}`" - totalblocks="`expr ${totalblocks} \* ${sec}`" + totalblocks=$((cyl*head)) + totalblocks=$((totalblocks*sec)) # Now set the ending block to the total disk block size - sizeblock="`expr ${totalblocks} - ${startblock}`" + sizeblock=$((totalblocks-startblock)) # Install new partition setup echo_log "Running gpart on ${DISK}" Modified: head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh Sun Mar 27 16:18:51 2011 (r220058) +++ head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh Sun Mar 27 16:57:54 2011 (r220059) @@ -59,7 +59,7 @@ start_extract_uzip_tar() MDDEVICE=`mdconfig -a -t vnode -o readonly -f ${INSFILE}` mkdir -p ${FSMNT}.uzip mount -r /dev/${MDDEVICE}.uzip ${FSMNT}.uzip - if [ "$?" != "0" ] + if [ $? -ne 0 ] then exit_err "ERROR: Failed mounting the ${INSFILE}" fi @@ -67,7 +67,7 @@ start_extract_uzip_tar() # Copy over all the files now! tar cvf - . 2>/dev/null | tar -xpv -C ${FSMNT} ${TAROPTS} -f - 2>&1 | tee -a ${FSMNT}/.tar-extract.log - if [ "$?" != "0" ] + if [ $? -ne 0 ] then cd / echo "TAR failure occurred:" >>${LOGOUT} @@ -84,7 +84,7 @@ start_extract_uzip_tar() ;; tar) tar -xpv -C ${FSMNT} -f ${INSFILE} ${TAROPTS} >&1 2>&1 - if [ "$?" != "0" ] + if [ $? -ne 0 ] then exit_err "ERROR: Failed extracting the tar image" fi @@ -127,7 +127,7 @@ start_extract_split() then echo_log "Extracting" `basename ${dir}` echo "y" | sh install.sh >/dev/null - if [ "$?" != "0" ] + if [ $? -ne 0 ] then exit_err "ERROR: Failed extracting ${dir}" fi @@ -143,7 +143,7 @@ start_extract_split() then echo_log "Extracting" `basename ${KERNELS}` echo "y" | sh install.sh generic >/dev/null - if [ "$?" != "0" ] + if [ $? -ne 0 ] then exit_err "ERROR: Failed extracting ${KERNELS}" fi @@ -160,7 +160,7 @@ start_extract_split() then echo_log "Extracting" `basename ${SOURCE}` echo "y" | sh install.sh all >/dev/null - if [ "$?" != "0" ] + if [ $? -ne 0 ] then exit_err "ERROR: Failed extracting ${SOURCE}" fi @@ -202,7 +202,7 @@ fetch_install_file() fetch_file "${FTPPATH}/${INSFILE}.md5" "${OUTFILE}.md5" "0" # Done fetching, now reset the INSFILE to our downloaded archived - INSFILE="${OUTFILE}" ; export INSFILE + export INSFILE="${OUTFILE}" }; @@ -244,7 +244,7 @@ fetch_split_files() NETRC="${OUTFILE}/.netrc" - cat<"${NETRC}" + cat <"${NETRC}" machine ${FTPHOST} login anonymous password anonymous @@ -255,14 +255,14 @@ EOF for d in ${DIRS} do - cat<>"${NETRC}" + cat <>"${NETRC}" cd ${FTPDIR}/${d} lcd ${OUTFILE}/${d} mreget * EOF done - cat<>"${NETRC}" + cat <>"${NETRC}" bye @@ -272,7 +272,7 @@ EOF echo "$ INSTALL" | ftp -N "${NETRC}" "${FTPHOST}" # Done fetching, now reset the INSFILE to our downloaded archived - INSFILE="${OUTFILE}" ; export INSFILE + export INSFILE="${OUTFILE}" } # Function which does the rsync download from the server specified in cfg @@ -283,27 +283,27 @@ start_rsync_copy() if [ -z "${VAL}" ]; then exit_err "ERROR: rsyncPath is unset! Please check your config and try again." fi - RSYNCPATH="${VAL}" ; export RSYNCPATH + export RSYNCPATH="${VAL}" get_value_from_cfg rsyncHost if [ -z "${VAL}" ]; then exit_err "ERROR: rsyncHost is unset! Please check your config and try again." fi - RSYNCHOST="${VAL}" ; export RSYNCHOST + export RSYNCHOST="${VAL}" get_value_from_cfg rsyncUser if [ -z "${VAL}" ]; then exit_err "ERROR: rsyncUser is unset! Please check your config and try again." fi - RSYNCUSER="${VAL}" ; export RSYNCUSER + export RSYNCUSER="${VAL}" get_value_from_cfg rsyncPort if [ -z "${VAL}" ]; then exit_err "ERROR: rsyncPort is unset! Please check your config and try again." fi - RSYNCPORT="${VAL}" ; export RSYNCPORT + export RSYNCPORT="${VAL}" - COUNT="1" + COUNT=1 while z=1 do @@ -317,14 +317,14 @@ start_rsync_copy() --rsync-path="rsync --fake-super" \ -e "ssh -p ${RSYNCPORT}" \ ${RSYNCUSER}@${RSYNCHOST}:${RSYNCPATH}/./ ${FSMNT} - if [ "$?" != "0" ] + if [ $? -ne 0 ] then echo "Rsync failed! Tries: ${COUNT}" else break fi - COUNT="`expr ${COUNT} + 1`" + COUNT=$((COUNT+1)) done }; @@ -339,8 +339,8 @@ start_image_install() # We are ready to start mounting, lets read the config and do it while read line do - echo $line | grep "^disk0=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo $line | grep -q "^disk0=" 2>/dev/null + if [ $? -eq 0 ] then # Found a disk= entry, lets get the disk we are working on get_value_from_string "${line}" @@ -348,11 +348,11 @@ start_image_install() DISK="$VAL" fi - echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null - if [ "$?" = "0" ] + echo $line | grep -q "^commitDiskPart" 2>/dev/null + if [ $? -eq 0 ] then # Found our flag to commit this disk setup / lets do sanity check and do it - if [ ! -z "${DISK}" ] + if [ -n "${DISK}" ] then # Write the image @@ -376,9 +376,9 @@ init_extraction() # Figure out what file we are using to install from via the config get_value_from_cfg installFile *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 17:22:31 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2001:4f8:fff6::35]) by hub.freebsd.org (Postfix) with ESMTP id DB08D106564A; Sun, 27 Mar 2011 17:22:31 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from 65-241-43-5.globalsuite.net (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx2.freebsd.org (Postfix) with ESMTP id 8A44D15542F; Sun, 27 Mar 2011 17:22:31 +0000 (UTC) Message-ID: <4D8F7257.50207@FreeBSD.org> Date: Sun, 27 Mar 2011 10:22:31 -0700 From: Doug Barton Organization: http://SupersetSolutions.com/ User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.9.2.15) Gecko/20110326 Thunderbird/3.1.9 MIME-Version: 1.0 To: Josh Paetzel References: <201103271657.p2RGvs2m063692@svn.freebsd.org> In-Reply-To: <201103271657.p2RGvs2m063692@svn.freebsd.org> X-Enigmail-Version: 1.1.2 OpenPGP: id=1A1ABC84 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, kib@FreeBSD.org Subject: Re: svn commit: r220059 - head/usr.sbin/pc-sysinstall/backend 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, 27 Mar 2011 17:22:32 -0000 On 03/27/2011 09:57, Josh Paetzel wrote: > Log: > Fix a syntax error in a little-used function. Since this is unique vs. all the other changes, IMO it should have been a separate commit. It doesn't hurt anything to split things up into multiple commits, and often helps make things more understandable down the road. > Replace expr with $(()) > Replace tests for ! -z with -n Good. :) > Replace grep> /dev/null with grep -q > Consolidate export statements with variable assignment These 2 make the code slightly less portable, but in this case I don't think that's a problem at all. > Replace "$?" = "0" with $? -eq 0 in tests Excellent! hth, Doug -- Nothin' ever doesn't change, but nothin' changes much. -- OK Go Breadth of IT experience, and depth of knowledge in the DNS. Yours for the right price. :) http://SupersetSolutions.com/ From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 19:56: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 9B481106566B; Sun, 27 Mar 2011 19:56:55 +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 6FD758FC18; Sun, 27 Mar 2011 19:56:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RJutoR067493; Sun, 27 Mar 2011 19:56:55 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RJutha067490; Sun, 27 Mar 2011 19:56:55 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201103271956.p2RJutha067490@svn.freebsd.org> From: Mikolaj Golub Date: Sun, 27 Mar 2011 19:56: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: r220062 - head/sys/geom/gate 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, 27 Mar 2011 19:56:55 -0000 Author: trociny Date: Sun Mar 27 19:56:55 2011 New Revision: 220062 URL: http://svn.freebsd.org/changeset/base/220062 Log: In g_gate_create() there is a window between when g_gate_softc is registered in g_gate_units array and when its sc_provider field is filled. If during this period g_gate_units is accessed by another thread that is checking for provider name collision the crash is possible. Fix this by adding sc_name field to struct g_gate_softc. In g_gate_create() when g_gate_softc is created but sc_provider is still not sc_name points to provider name stored in the local array. Approved by: pjd (mentor) Reported by: Freddie Cash MFC after: 1 week Modified: head/sys/geom/gate/g_gate.c head/sys/geom/gate/g_gate.h Modified: head/sys/geom/gate/g_gate.c ============================================================================== --- head/sys/geom/gate/g_gate.c Sun Mar 27 19:29:18 2011 (r220061) +++ head/sys/geom/gate/g_gate.c Sun Mar 27 19:56:55 2011 (r220062) @@ -409,13 +409,14 @@ g_gate_create(struct g_gate_ctl_create * for (unit = 0; unit < g_gate_maxunits; unit++) { if (g_gate_units[unit] == NULL) continue; - if (strcmp(name, g_gate_units[unit]->sc_provider->name) != 0) + if (strcmp(name, g_gate_units[unit]->sc_name) != 0) continue; mtx_unlock(&g_gate_units_lock); mtx_destroy(&sc->sc_queue_mtx); free(sc, M_GATE); return (EEXIST); } + sc->sc_name = name; g_gate_units[sc->sc_unit] = sc; g_gate_nunits++; mtx_unlock(&g_gate_units_lock); @@ -434,6 +435,9 @@ g_gate_create(struct g_gate_ctl_create * sc->sc_provider = pp; g_error_provider(pp, 0); g_topology_unlock(); + mtx_lock(&g_gate_units_lock); + sc->sc_name = sc->sc_provider->name; + mtx_unlock(&g_gate_units_lock); if (sc->sc_timeout > 0) { callout_reset(&sc->sc_callout, sc->sc_timeout * hz, Modified: head/sys/geom/gate/g_gate.h ============================================================================== --- head/sys/geom/gate/g_gate.h Sun Mar 27 19:29:18 2011 (r220061) +++ head/sys/geom/gate/g_gate.h Sun Mar 27 19:56:55 2011 (r220062) @@ -76,6 +76,7 @@ * 'P:' means 'Protected by'. */ struct g_gate_softc { + char *sc_name; /* P: (read-only) */ int sc_unit; /* P: (read-only) */ int sc_ref; /* P: g_gate_list_mtx */ struct g_provider *sc_provider; /* P: (read-only) */ @@ -96,7 +97,6 @@ struct g_gate_softc { LIST_ENTRY(g_gate_softc) sc_next; /* P: g_gate_list_mtx */ char sc_info[G_GATE_INFOSIZE]; /* P: (read-only) */ }; -#define sc_name sc_provider->geom->name #define G_GATE_DEBUG(lvl, ...) do { \ if (g_gate_debug >= (lvl)) { \ From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 20:08: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 0CA86106564A; Sun, 27 Mar 2011 20:08:09 +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 93CB28FC16; Sun, 27 Mar 2011 20:08:08 +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 p2RK848E027769 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 27 Mar 2011 23:08:04 +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 p2RK84Yp068527; Sun, 27 Mar 2011 23:08:04 +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 p2RK84cO068526; Sun, 27 Mar 2011 23:08:04 +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: Sun, 27 Mar 2011 23:08:04 +0300 From: Kostik Belousov To: Mikolaj Golub Message-ID: <20110327200804.GM78089@deviant.kiev.zoral.com.ua> References: <201103271956.p2RJutha067490@svn.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Jps4F43PgwelbvkV" Content-Disposition: inline In-Reply-To: <201103271956.p2RJutha067490@svn.freebsd.org> 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.4 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: r220062 - head/sys/geom/gate 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, 27 Mar 2011 20:08:09 -0000 --Jps4F43PgwelbvkV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Mar 27, 2011 at 07:56:55PM +0000, Mikolaj Golub wrote: > Author: trociny > Date: Sun Mar 27 19:56:55 2011 > New Revision: 220062 > URL: http://svn.freebsd.org/changeset/base/220062 >=20 > Log: > In g_gate_create() there is a window between when g_gate_softc is > registered in g_gate_units array and when its sc_provider field is > filled. If during this period g_gate_units is accessed by another > thread that is checking for provider name collision the crash is > possible. > =20 > Fix this by adding sc_name field to struct g_gate_softc. In > g_gate_create() when g_gate_softc is created but sc_provider is still > not sc_name points to provider name stored in the local array. > =20 > Approved by: pjd (mentor) > Reported by: Freddie Cash > MFC after: 1 week >=20 > Modified: > head/sys/geom/gate/g_gate.c > head/sys/geom/gate/g_gate.h >=20 > Modified: head/sys/geom/gate/g_gate.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/geom/gate/g_gate.c Sun Mar 27 19:29:18 2011 (r220061) > +++ head/sys/geom/gate/g_gate.c Sun Mar 27 19:56:55 2011 (r220062) > @@ -409,13 +409,14 @@ g_gate_create(struct g_gate_ctl_create * > for (unit =3D 0; unit < g_gate_maxunits; unit++) { > if (g_gate_units[unit] =3D=3D NULL) > continue; > - if (strcmp(name, g_gate_units[unit]->sc_provider->name) !=3D 0) > + if (strcmp(name, g_gate_units[unit]->sc_name) !=3D 0) > continue; > mtx_unlock(&g_gate_units_lock); > mtx_destroy(&sc->sc_queue_mtx); > free(sc, M_GATE); > return (EEXIST); > } > + sc->sc_name =3D name; > g_gate_units[sc->sc_unit] =3D sc; > g_gate_nunits++; > mtx_unlock(&g_gate_units_lock); > @@ -434,6 +435,9 @@ g_gate_create(struct g_gate_ctl_create * > sc->sc_provider =3D pp; > g_error_provider(pp, 0); > g_topology_unlock(); > + mtx_lock(&g_gate_units_lock); > + sc->sc_name =3D sc->sc_provider->name; > + mtx_unlock(&g_gate_units_lock); I think you do not need a mutex locked around the single assignment. As I understand, sc_provider->name is constant ? --Jps4F43PgwelbvkV Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk2PmSMACgkQC3+MBN1Mb4h/QgCgj0A2+WWl8o01tgozAZqHh7Rn wnIAn0FB2V8Netfa/TelAUxmZ7UhjBHl =K3f0 -----END PGP SIGNATURE----- --Jps4F43PgwelbvkV-- From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 20:49: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 5EE22106564A; Sun, 27 Mar 2011 20:49:19 +0000 (UTC) (envelope-from to.my.trociny@gmail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id 9469F8FC14; Sun, 27 Mar 2011 20:49:18 +0000 (UTC) Received: by fxm11 with SMTP id 11so2838697fxm.13 for ; Sun, 27 Mar 2011 13:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:x-comment-to :sender:date:in-reply-to:message-id:user-agent:mime-version :content-type; bh=pHscf/kDwVDlYGckvhSnWOv1Isiy/Z4OCfODqVt4ioA=; b=BH8kZXhKDU8WFGGPYOpVU7vRcfYZLAA0sagicNwJOcEiymsZwFrYBdxTzYofUBbdvK fijyxNUnWngYSW0Xp3iRL92fRJ5Zpnvl2VlIphtF5enlveKqnEfxmJRx8M2ooTvb0JEL xBc2E3O0LEYkxsClWN55x1LL21A6UxEXQbEHw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:x-comment-to:sender:date:in-reply-to :message-id:user-agent:mime-version:content-type; b=UtMpXoWHhTuU3iHPeo99lrORDA6/CpmYDGuAsl+airV+kM8PO7NH960v/96UnQK/Wh FRLVNvlM5qB8eZwlRNQtwOqtEVwMOcC+lebcI2cAjpzB0X3wIsrvAbRY4LJCRlOxfvQ9 NBGEQsN1BvVXSsMI/nkLSQocDSSKYAOnTT6mQ= Received: by 10.223.29.4 with SMTP id o4mr3602524fac.27.1301258957502; Sun, 27 Mar 2011 13:49:17 -0700 (PDT) Received: from localhost ([95.69.172.154]) by mx.google.com with ESMTPS id e23sm1208644faa.18.2011.03.27.13.49.16 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 27 Mar 2011 13:49:16 -0700 (PDT) From: Mikolaj Golub To: Kostik Belousov References: <201103271956.p2RJutha067490@svn.freebsd.org> <20110327200804.GM78089@deviant.kiev.zoral.com.ua> X-Comment-To: Kostik Belousov Sender: Mikolaj Golub Date: Sun, 27 Mar 2011 23:49:15 +0300 In-Reply-To: <20110327200804.GM78089@deviant.kiev.zoral.com.ua> (Kostik Belousov's message of "Sun, 27 Mar 2011 23:08:04 +0300") Message-ID: <86fwq8e1bo.fsf@kopusha.home.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r220062 - head/sys/geom/gate 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, 27 Mar 2011 20:49:19 -0000 On Sun, 27 Mar 2011 23:08:04 +0300 Kostik Belousov wrote: KB> On Sun, Mar 27, 2011 at 07:56:55PM +0000, Mikolaj Golub wrote: >> Author: trociny >> Date: Sun Mar 27 19:56:55 2011 >> New Revision: 220062 >> URL: http://svn.freebsd.org/changeset/base/220062 >> >> Log: >> In g_gate_create() there is a window between when g_gate_softc is >> registered in g_gate_units array and when its sc_provider field is >> filled. If during this period g_gate_units is accessed by another >> thread that is checking for provider name collision the crash is >> possible. >> >> Fix this by adding sc_name field to struct g_gate_softc. In >> g_gate_create() when g_gate_softc is created but sc_provider is still >> not sc_name points to provider name stored in the local array. >> >> Approved by: pjd (mentor) >> Reported by: Freddie Cash >> MFC after: 1 week >> >> Modified: >> head/sys/geom/gate/g_gate.c >> head/sys/geom/gate/g_gate.h >> >> Modified: head/sys/geom/gate/g_gate.c >> ============================================================================== >> --- head/sys/geom/gate/g_gate.c Sun Mar 27 19:29:18 2011 (r220061) >> +++ head/sys/geom/gate/g_gate.c Sun Mar 27 19:56:55 2011 (r220062) >> @@ -409,13 +409,14 @@ g_gate_create(struct g_gate_ctl_create * >> for (unit = 0; unit < g_gate_maxunits; unit++) { >> if (g_gate_units[unit] == NULL) >> continue; >> - if (strcmp(name, g_gate_units[unit]->sc_provider->name) != 0) >> + if (strcmp(name, g_gate_units[unit]->sc_name) != 0) >> continue; >> mtx_unlock(&g_gate_units_lock); >> mtx_destroy(&sc->sc_queue_mtx); >> free(sc, M_GATE); >> return (EEXIST); >> } >> + sc->sc_name = name; >> g_gate_units[sc->sc_unit] = sc; >> g_gate_nunits++; >> mtx_unlock(&g_gate_units_lock); >> @@ -434,6 +435,9 @@ g_gate_create(struct g_gate_ctl_create * >> sc->sc_provider = pp; >> g_error_provider(pp, 0); >> g_topology_unlock(); >> + mtx_lock(&g_gate_units_lock); >> + sc->sc_name = sc->sc_provider->name; >> + mtx_unlock(&g_gate_units_lock); KB> I think you do not need a mutex locked around the single assignment. KB> As I understand, sc_provider->name is constant ? Is the following scenario impossible? Thread A is looking for name collision and is accessing g_gate_units[unit]->sc_name of the unit that is being created by a thread B, so sc_name is pointing to thread B local buffer. At this time the thread B creates provider, does sc->sc_name = sc->sc_provider->name and returns from g_gate_create(). Thread A, if it is still working with g_gate_units[unit]->sc_name, is accessing invalid memory. -- Mikolaj Golub From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 21:06: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 924D7106566B; Sun, 27 Mar 2011 21:06: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 2ECDB8FC13; Sun, 27 Mar 2011 21:06: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 p2RL6c53031406 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Mar 2011 00:06:38 +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 p2RL6ccY068865; Mon, 28 Mar 2011 00:06:38 +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 p2RL6c9H068864; Mon, 28 Mar 2011 00:06:38 +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: Mon, 28 Mar 2011 00:06:38 +0300 From: Kostik Belousov To: Mikolaj Golub Message-ID: <20110327210638.GO78089@deviant.kiev.zoral.com.ua> References: <201103271956.p2RJutha067490@svn.freebsd.org> <20110327200804.GM78089@deviant.kiev.zoral.com.ua> <86fwq8e1bo.fsf@kopusha.home.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="bF/koNWjw4RKgJoH" Content-Disposition: inline In-Reply-To: <86fwq8e1bo.fsf@kopusha.home.net> 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.4 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: r220062 - head/sys/geom/gate 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, 27 Mar 2011 21:06:42 -0000 --bF/koNWjw4RKgJoH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Mar 27, 2011 at 11:49:15PM +0300, Mikolaj Golub wrote: >=20 > On Sun, 27 Mar 2011 23:08:04 +0300 Kostik Belousov wrote: >=20 > KB> On Sun, Mar 27, 2011 at 07:56:55PM +0000, Mikolaj Golub wrote: > >> Author: trociny > >> Date: Sun Mar 27 19:56:55 2011 > >> New Revision: 220062 > >> URL: http://svn.freebsd.org/changeset/base/220062 > >>=20 > >> Log: > >> In g_gate_create() there is a window between when g_gate_softc is > >> registered in g_gate_units array and when its sc_provider field is > >> filled. If during this period g_gate_units is accessed by another > >> thread that is checking for provider name collision the crash is > >> possible. > >> =20 > >> Fix this by adding sc_name field to struct g_gate_softc. In > >> g_gate_create() when g_gate_softc is created but sc_provider is sti= ll > >> not sc_name points to provider name stored in the local array. > >> =20 > >> Approved by: pjd (mentor) > >> Reported by: Freddie Cash > >> MFC after: 1 week > >>=20 > >> Modified: > >> head/sys/geom/gate/g_gate.c > >> head/sys/geom/gate/g_gate.h > >>=20 > >> Modified: head/sys/geom/gate/g_gate.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/geom/gate/g_gate.c Sun Mar 27 19:29:18 2011 = (r220061) > >> +++ head/sys/geom/gate/g_gate.c Sun Mar 27 19:56:55 2011 = (r220062) > >> @@ -409,13 +409,14 @@ g_gate_create(struct g_gate_ctl_create * > >> for (unit =3D 0; unit < g_gate_maxunits; unit++) { > >> if (g_gate_units[unit] =3D=3D NULL) > >> continue; > >> - if (strcmp(name, g_gate_units[unit]->sc_provider->na= me) !=3D 0) > >> + if (strcmp(name, g_gate_units[unit]->sc_name) !=3D 0) > >> continue; > >> mtx_unlock(&g_gate_units_lock); > >> mtx_destroy(&sc->sc_queue_mtx); > >> free(sc, M_GATE); > >> return (EEXIST); > >> } > >> + sc->sc_name =3D name; > >> g_gate_units[sc->sc_unit] =3D sc; > >> g_gate_nunits++; > >> mtx_unlock(&g_gate_units_lock); > >> @@ -434,6 +435,9 @@ g_gate_create(struct g_gate_ctl_create * > >> sc->sc_provider =3D pp; > >> g_error_provider(pp, 0); > >> g_topology_unlock(); > >> + mtx_lock(&g_gate_units_lock); > >> + sc->sc_name =3D sc->sc_provider->name; > >> + mtx_unlock(&g_gate_units_lock); > KB> I think you do not need a mutex locked around the single assignment. > KB> As I understand, sc_provider->name is constant ? >=20 > Is the following scenario impossible? >=20 > Thread A is looking for name collision and is accessing > g_gate_units[unit]->sc_name of the unit that is being created by a thread= B, > so sc_name is pointing to thread B local buffer. At this time the thread B > creates provider, does sc->sc_name =3D sc->sc_provider->name and returns = from > g_gate_create(). Thread A, if it is still working with > g_gate_units[unit]->sc_name, is accessing invalid memory. Ok, name is local variable. Apparently, what you need is a barrier. It would be enough to do sc->sc_name =3D sc->sc_provider->name; mtx_lock(&g_gate_units_lock); mtx_unlock(&g_gate_units_lock); The change is fine as is. --bF/koNWjw4RKgJoH Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk2Ppt0ACgkQC3+MBN1Mb4gKPgCfVcIJo1XtYN4nG1gd/akhD2o9 KUYAnRIFG+ZjE+9FLCexAdSG7D+PCFo0 =797P -----END PGP SIGNATURE----- --bF/koNWjw4RKgJoH-- From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 22:32: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 1D34E106566B; Sun, 27 Mar 2011 22:32:45 +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 B31518FC16; Sun, 27 Mar 2011 22:32:44 +0000 (UTC) Received: from 63.imp.bsdimp.com (63.imp.bsdimp.com [10.0.0.63] (may be forged)) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id p2RMTS0A076694; Sun, 27 Mar 2011 16:29:28 -0600 (MDT) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <4D8F7257.50207@FreeBSD.org> Date: Sun, 27 Mar 2011 16:29:28 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: References: <201103271657.p2RGvs2m063692@svn.freebsd.org> <4D8F7257.50207@FreeBSD.org> To: Doug Barton X-Mailer: Apple Mail (2.1082) Cc: Josh Paetzel , svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, kib@FreeBSD.org Subject: Re: svn commit: r220059 - head/usr.sbin/pc-sysinstall/backend 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, 27 Mar 2011 22:32:45 -0000 On Mar 27, 2011, at 11:22 AM, Doug Barton wrote: > On 03/27/2011 09:57, Josh Paetzel wrote: >> Replace "$?" =3D "0" with $? -eq 0 in tests >=20 > Excellent! Most of the time I've found that moving the command up to the if makes = the code clearer too. At jobs I've had in the past when I've written = code similar to what we have here, it almost always got flagged... Warner From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 23:43:32 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 B5367106564A; Sun, 27 Mar 2011 23:43:32 +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 668D68FC08; Sun, 27 Mar 2011 23:43:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RNhWV3073214; Sun, 27 Mar 2011 23:43:32 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RNhWAS073210; Sun, 27 Mar 2011 23:43:32 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201103272343.p2RNhWAS073210@svn.freebsd.org> From: Nathan Whitehorn Date: Sun, 27 Mar 2011 23:43: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: r220080 - head/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: Sun, 27 Mar 2011 23:43:32 -0000 Author: nwhitehorn Date: Sun Mar 27 23:43:32 2011 New Revision: 220080 URL: http://svn.freebsd.org/changeset/base/220080 Log: Add mirror selection for FTP installs. To support TBEMD installs (e.g. powerpc64), this looks in a slightly different default path than now, specifying both $MACHINE and $MACHINE_ARCH: MIRROR/pub/FreeBSD/releases/`uname -p`/`uname -m`/`uname -r` How to handle TBEMD properly probably merits some more discussion, but, since no such 9.0-CURRENT distfiles exist at the moment, all existing mirrors presently fail anyway. Added: head/usr.sbin/bsdinstall/scripts/mirrorselect (contents, props changed) Modified: head/usr.sbin/bsdinstall/scripts/Makefile head/usr.sbin/bsdinstall/scripts/auto Modified: head/usr.sbin/bsdinstall/scripts/Makefile ============================================================================== --- head/usr.sbin/bsdinstall/scripts/Makefile Sun Mar 27 23:14:02 2011 (r220079) +++ head/usr.sbin/bsdinstall/scripts/Makefile Sun Mar 27 23:43:32 2011 (r220080) @@ -1,7 +1,7 @@ # $FreeBSD$ -SCRIPTS= auto adduser checksum config hostname jail keymap mount netconfig \ - rootpass services time umount wlanconfig +SCRIPTS= auto adduser checksum config hostname jail keymap mirrorselect \ + mount netconfig 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 Sun Mar 27 23:14:02 2011 (r220079) +++ head/usr.sbin/bsdinstall/scripts/auto Sun Mar 27 23:43:32 2011 (r220080) @@ -35,6 +35,7 @@ error() { if [ $? -ne 0 ]; then exit else + test -n $DISTDIR_IS_UNIONFS && umount -f $BSDINSTALL_DISTDIR test -f $PATH_FSTAB && bsdinstall umount exec $0 fi @@ -72,13 +73,23 @@ for dist in $DISTRIBUTIONS; do FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist" fi done +FETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS` # Trim white space -if [ ! -z "$FETCH_DISTRIBUTIONS" -a ! -z $BSDINSTALL_CONFIGCURRENT ]; then +if [ -n "$FETCH_DISTRIBUTIONS" -a -n "$BSDINSTALL_CONFIGCURRENT" ]; then dialog --backtitle "FreeBSD Installer" --title "Network Installation" --msgbox "No installation files were found on the boot volume. The next few screens will allow you to configure networking so that they can be downloaded from the Internet." 0 0 bsdinstall netconfig || error NETCONFIG_DONE=yes fi +if [ -n "$FETCH_DISTRIBUTIONS" -a -z "$BSDINSTALL_DISTSITE" ]; then + exec 3>&1 + BSDINSTALL_DISTSITE=`bsdinstall mirrorselect 2>&1 1>&3` + MIRROR_BUTTON=$? + exec 3>&- + test $MIRROR_BUTTON -eq 0 || error + export BSDINSTALL_DISTSITE +fi + rm $PATH_FSTAB touch $PATH_FSTAB @@ -114,7 +125,11 @@ if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then export DISTRIBUTIONS="$FETCH_DISTRIBUTIONS" # Try to use any existing distfiles - [ -d $BSDINSTALL_DISTDIR -a "$FETCH_DISTRIBUTIONS" != "$ALL_DISTRIBUTIONS" ] && mount_unionfs "$BSDINSTALL_FETCHDEST" "$BSDINSTALL_DISTDIR" + if [ -d $BSDINSTALL_DISTDIR -a "$FETCH_DISTRIBUTIONS" != \ + "$ALL_DISTRIBUTIONS" ]; then + DISTDIR_IS_UNIONFS=1 + mount_unionfs "$BSDINSTALL_FETCHDEST" "$BSDINSTALL_DISTDIR" + fi # Otherwise, fetch everything if [ $? -ne 0 ]; then @@ -126,6 +141,8 @@ if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then export DISTRIBUTIONS="$ALL_DISTRIBUTIONS" fi +error + bsdinstall checksum || error bsdinstall distextract || error bsdinstall rootpass || error Added: head/usr.sbin/bsdinstall/scripts/mirrorselect ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/bsdinstall/scripts/mirrorselect Sun Mar 27 23:43:32 2011 (r220080) @@ -0,0 +1,214 @@ +#!/bin/sh +#- +# Copyright (c) 2011 Nathan Whitehorn +# 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$ + +: ${DIALOG_OK=0} +: ${DIALOG_CANCEL=1} +: ${DIALOG_HELP=2} +: ${DIALOG_EXTRA=3} +: ${DIALOG_ITEM_HELP=4} +: ${DIALOG_ESC=255} + +exec 3>&1 +MIRROR=`dialog --backtitle "FreeBSD Installer" \ + --title "Mirror Selection" --extra-button --extra-label "Other" \ + --menu "Please select the site closest to you or \"other\" if you'd like to specify a different choice. Also note that not every site listed here carries more than the base distribution kits. Only Primary sites are guaranteed to carry the full range of possible distributions. Select a site that's close!" \ + 0 0 0 \ + ftp://ftp.freebsd.org "Main Site"\ + ftp://snapshots.jp.freebsd.org "Snapshots Server Japan"\ + ftp://snapshots.se.freebsd.org "Snapshots Server Sweden"\ + ftp://ftp.freebsd.org "IPv6 Main Site"\ + ftp://ftp3.ie.freebsd.org "IPv6 Ireland"\ + ftp://ftp.il.freebsd.org "IPv6 Israel"\ + ftp://ftp2.jp.freebsd.org "IPv6 Japan"\ + ftp://ftp4.us.freebsd.org "IPv6 USA"\ + ftp://ftp2.tr.freebsd.org "IPv6 Turkey"\ + ftp://ftp1.freebsd.org "Primary"\ + ftp://ftp2.freebsd.org "Primary #2"\ + ftp://ftp3.freebsd.org "Primary #3"\ + ftp://ftp4.freebsd.org "Primary #4"\ + ftp://ftp5.freebsd.org "Primary #5"\ + ftp://ftp6.freebsd.org "Primary #6"\ + ftp://ftp7.freebsd.org "Primary #7"\ + ftp://ftp8.freebsd.org "Primary #8"\ + ftp://ftp9.freebsd.org "Primary #9"\ + ftp://ftp10.freebsd.org "Primary #10"\ + ftp://ftp11.freebsd.org "Primary #11"\ + ftp://ftp12.freebsd.org "Primary #12"\ + ftp://ftp13.freebsd.org "Primary #13"\ + ftp://ftp14.freebsd.org "Primary #14"\ + ftp://ftp.ar.freebsd.org "Argentina"\ + ftp://ftp.au.freebsd.org "Australia"\ + ftp://ftp2.au.freebsd.org "Australia #2"\ + ftp://ftp3.au.freebsd.org "Australia #3"\ + ftp://ftp.at.freebsd.org "Austria"\ + ftp://ftp2.at.freebsd.org "Austria #2"\ + ftp://ftp.br.freebsd.org "Brazil"\ + ftp://ftp2.br.freebsd.org "Brazil #2"\ + ftp://ftp3.br.freebsd.org "Brazil #3"\ + ftp://ftp4.br.freebsd.org "Brazil #4"\ + ftp://ftp5.br.freebsd.org "Brazil #5"\ + ftp://ftp6.br.freebsd.org "Brazil #6"\ + ftp://ftp7.br.freebsd.org "Brazil #7"\ + ftp://ftp.ca.freebsd.org "Canada"\ + ftp://ftp.cn.freebsd.org "China"\ + ftp://ftp2.cn.freebsd.org "China #2"\ + ftp://ftp.hr.freebsd.org "Croatia"\ + ftp://ftp.cz.freebsd.org "Czech Republic"\ + ftp://ftp.dk.freebsd.org "Denmark"\ + ftp://ftp2.dk.freebsd.org "Denmark #2"\ + ftp://ftp.ee.freebsd.org "Estonia"\ + ftp://ftp.fi.freebsd.org "Finland"\ + ftp://ftp.fr.freebsd.org "France"\ + ftp://ftp2.fr.freebsd.org "France #2"\ + ftp://ftp3.fr.freebsd.org "France #3"\ + ftp://ftp5.fr.freebsd.org "France #5"\ + ftp://ftp6.fr.freebsd.org "France #6"\ + ftp://ftp8.fr.freebsd.org "France #8"\ + ftp://ftp.de.freebsd.org "Germany"\ + ftp://ftp2.de.freebsd.org "Germany #2"\ + ftp://ftp3.de.freebsd.org "Germany #3"\ + ftp://ftp4.de.freebsd.org "Germany #4"\ + ftp://ftp5.de.freebsd.org "Germany #5"\ + ftp://ftp6.de.freebsd.org "Germany #6"\ + ftp://ftp7.de.freebsd.org "Germany #7"\ + ftp://ftp8.de.freebsd.org "Germany #8"\ + ftp://ftp.gr.freebsd.org "Greece"\ + ftp://ftp2.gr.freebsd.org "Greece #2"\ + ftp://ftp.hu.freebsd.org "Hungary"\ + ftp://ftp.is.freebsd.org "Iceland"\ + ftp://ftp.ie.freebsd.org "Ireland"\ + ftp://ftp2.ie.freebsd.org "Ireland #2"\ + ftp://ftp3.ie.freebsd.org "Ireland #3"\ + ftp://ftp.il.freebsd.org "Israel"\ + ftp://ftp.it.freebsd.org "Italy"\ + ftp://ftp.jp.freebsd.org "Japan"\ + ftp://ftp2.jp.freebsd.org "Japan #2"\ + ftp://ftp3.jp.freebsd.org "Japan #3"\ + ftp://ftp4.jp.freebsd.org "Japan #4"\ + ftp://ftp5.jp.freebsd.org "Japan #5"\ + ftp://ftp6.jp.freebsd.org "Japan #6"\ + ftp://ftp7.jp.freebsd.org "Japan #7"\ + ftp://ftp8.jp.freebsd.org "Japan #8"\ + ftp://ftp9.jp.freebsd.org "Japan #9"\ + ftp://ftp.kr.freebsd.org "Korea"\ + ftp://ftp2.kr.freebsd.org "Korea #2"\ + ftp://ftp.lt.freebsd.org "Lithuania"\ + ftp://ftp.nl.freebsd.org "Netherlands"\ + ftp://ftp2.nl.freebsd.org "Netherlands #2"\ + ftp://ftp.no.freebsd.org "Norway"\ + ftp://ftp3.no.freebsd.org "Norway #3"\ + ftp://ftp.pl.freebsd.org "Poland"\ + ftp://ftp2.pl.freebsd.org "Poland #2"\ + ftp://ftp5.pl.freebsd.org "Poland #5"\ + ftp://ftp.pt.freebsd.org "Portugal"\ + ftp://ftp2.pt.freebsd.org "Portugal #2"\ + ftp://ftp4.pt.freebsd.org "Portugal #4"\ + ftp://ftp.ro.freebsd.org "Romania"\ + ftp://ftp.ru.freebsd.org "Russia"\ + ftp://ftp2.ru.freebsd.org "Russia #2"\ + ftp://ftp3.ru.freebsd.org "Russia #3"\ + ftp://ftp4.ru.freebsd.org "Russia #4"\ + ftp://ftp.sg.freebsd.org "Singapore"\ + ftp://ftp.sk.freebsd.org "Slovak Republic"\ + ftp://ftp.si.freebsd.org "Slovenia"\ + ftp://ftp2.si.freebsd.org "Slovenia #2"\ + ftp://ftp.za.freebsd.org "South Africa"\ + ftp://ftp2.za.freebsd.org "South Africa #2"\ + ftp://ftp3.za.freebsd.org "South Africa #3"\ + ftp://ftp4.za.freebsd.org "South Africa #4"\ + ftp://ftp.es.freebsd.org "Spain"\ + ftp://ftp2.es.freebsd.org "Spain #2"\ + ftp://ftp3.es.freebsd.org "Spain #3"\ + ftp://ftp.se.freebsd.org "Sweden"\ + ftp://ftp2.se.freebsd.org "Sweden #2"\ + ftp://ftp3.se.freebsd.org "Sweden #3"\ + ftp://ftp4.se.freebsd.org "Sweden #4"\ + ftp://ftp5.se.freebsd.org "Sweden #5"\ + ftp://ftp.ch.freebsd.org "Switzerland"\ + ftp://ftp2.ch.freebsd.org "Switzerland #2"\ + ftp://ftp.tw.freebsd.org "Taiwan"\ + ftp://ftp2.tw.freebsd.org "Taiwan #2"\ + ftp://ftp3.tw.freebsd.org "Taiwan #3"\ + ftp://ftp4.tw.freebsd.org "Taiwan #4"\ + ftp://ftp6.tw.freebsd.org "Taiwan #6"\ + ftp://ftp11.tw.freebsd.org "Taiwan #11"\ + ftp://ftp.tr.freebsd.org "Turkey"\ + ftp://ftp2.tr.freebsd.org "Turkey #2"\ + ftp://ftp.uk.freebsd.org "UK"\ + ftp://ftp2.uk.freebsd.org "UK #2"\ + ftp://ftp3.uk.freebsd.org "UK #3"\ + ftp://ftp4.uk.freebsd.org "UK #4"\ + ftp://ftp5.uk.freebsd.org "UK #5"\ + ftp://ftp6.uk.freebsd.org "UK #6"\ + ftp://ftp.ua.freebsd.org "Ukraine"\ + ftp://ftp2.ua.freebsd.org "Ukraine #2"\ + ftp://ftp5.ua.freebsd.org "Ukraine #5"\ + ftp://ftp6.ua.freebsd.org "Ukraine #6"\ + ftp://ftp7.ua.freebsd.org "Ukraine #7"\ + ftp://ftp8.ua.freebsd.org "Ukraine #8"\ + ftp://ftp1.us.freebsd.org "USA #1"\ + ftp://ftp2.us.freebsd.org "USA #2"\ + ftp://ftp3.us.freebsd.org "USA #3"\ + ftp://ftp4.us.freebsd.org "USA #4"\ + ftp://ftp5.us.freebsd.org "USA #5"\ + ftp://ftp6.us.freebsd.org "USA #6"\ + ftp://ftp7.us.freebsd.org "USA #7"\ + ftp://ftp8.us.freebsd.org "USA #8"\ + ftp://ftp9.us.freebsd.org "USA #9"\ + ftp://ftp10.us.freebsd.org "USA #10"\ + ftp://ftp11.us.freebsd.org "USA #11"\ + ftp://ftp12.us.freebsd.org "USA #12"\ + ftp://ftp13.us.freebsd.org "USA #13"\ + ftp://ftp14.us.freebsd.org "USA #14"\ + ftp://ftp15.us.freebsd.org "USA #15"\ + 2>&1 1>&3` +MIRROR_BUTTON=$? +exec 3>&- + +BSDINSTALL_DISTSITE="$MIRROR/pub/FreeBSD/releases/`uname -p`/`uname -m`/`uname -r`" + +case $MIRROR_BUTTON in +$DIALOG_CANCEL) + exit 1 + ;; +$DIALOG_OK) + ;; +$DIALOG_EXTRA) + exec 3>&1 + BSDINSTALL_DISTSITE=`dialog --backtitle "FreeBSD Installer" \ + --title "Mirror Selection" \ + --inputbox "Please enter the URL to an alternate FreeBSD mirror:" \ + 0 0 "$BSDINSTALL_DISTSITE" 2>&1 1>&3` + MIRROR_BUTTON=$? + exec 3>&- + test $MIRROR_BUTTON -eq 0 || exec $0 $@ + ;; +esac + +export BSDINSTALL_DISTSITE +echo $BSDINSTALL_DISTSITE >&2 From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 23:46: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 D3488106564A; Sun, 27 Mar 2011 23:46:12 +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 A613F8FC13; Sun, 27 Mar 2011 23:46:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RNkCAc073324; Sun, 27 Mar 2011 23:46:12 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RNkCIQ073322; Sun, 27 Mar 2011 23:46:12 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201103272346.p2RNkCIQ073322@svn.freebsd.org> From: Nathan Whitehorn Date: Sun, 27 Mar 2011 23:46: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: r220081 - head/release 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, 27 Mar 2011 23:46:12 -0000 Author: nwhitehorn Date: Sun Mar 27 23:46:12 2011 New Revision: 220081 URL: http://svn.freebsd.org/changeset/base/220081 Log: Add infrastructure for generation of boot-only ISO images. These have a reduced world, though still reasonably complete for fixit purposes. Modified: head/release/Makefile Modified: head/release/Makefile ============================================================================== --- head/release/Makefile Sun Mar 27 23:43:32 2011 (r220080) +++ head/release/Makefile Sun Mar 27 23:46:12 2011 (r220081) @@ -122,13 +122,38 @@ system: packagesystem ln -s /tmp/bsdinstall_etc/resolv.conf ${.OBJDIR}/release/etc/resolv.conf echo sendmail_enable=\"NONE\" > ${.OBJDIR}/release/etc/rc.conf echo hostid_enable=\"NO\" >> ${.OBJDIR}/release/etc/rc.conf - touch ${.OBJDIR}/release/etc/fstab cp ${.CURDIR}/rc.local ${.OBJDIR}/release/etc touch ${.OBJDIR}/${.TARGET} +bootonly: packagesystem +# Install system + mkdir ${.OBJDIR}/bootonly + cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \ + DESTDIR=${.OBJDIR}/bootonly WITHOUT_AMD=1 WITHOUT_AT=1 \ + WITHOUT_BIND_DNSSEC=1 WITHOUT_BIND_ETC=1 WITHOUT_BIND_MTREE=1 \ + WITHOUT_BIND_NAMED=1 WITHOUT_GAMES=1 WITHOUT_GROFF=1 \ + WITHOUT_INSTALLLIB=1 WITHOUT_LIB32=1 WITHOUT_MAIL=1 \ + WITHOUT_NCP=1 WITHOUT_TOOLCHAIN=1 WITHOUT_RESCUE=1 WITHOUT_DICT=1 + -rm ${.OBJDIR}/bootonly/boot/kernel/*.symbols +# Copy manifest only (no distfiles) to get checksums + mkdir ${.OBJDIR}/bootonly/usr/freebsd-dist + cp ${.OBJDIR}/MANIFEST ${.OBJDIR}/bootonly/usr/freebsd-dist +# Copy documentation, if generated +.if !defined(NODOC) + cp ${.OBJDIR}/reldoc/* ${.OBJDIR}/bootonly +.endif +# Set up installation environment + ln -s /tmp/bsdinstall_etc/resolv.conf ${.OBJDIR}/bootonly/etc/resolv.conf + echo sendmail_enable=\"NONE\" > ${.OBJDIR}/bootonly/etc/rc.conf + echo hostid_enable=\"NO\" >> ${.OBJDIR}/bootonly/etc/rc.conf + cp ${.CURDIR}/rc.local ${.OBJDIR}/bootonly/etc + release.iso: system sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.OBJDIR}/release.iso ${.OBJDIR}/release +bootonly.iso: bootonly + sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.OBJDIR}/bootonly.iso ${.OBJDIR}/bootonly + memstick: system sh ${.CURDIR}/${TARGET}/make-memstick.sh ${.OBJDIR}/release ${.OBJDIR}/memstick @@ -136,7 +161,7 @@ packagesystem: base.txz kernel.txz ${EXT sh ${.CURDIR}/scripts/make-manifest.sh ${.OBJDIR}/*.txz > ${.OBJDIR}/MANIFEST touch ${.OBJDIR}/${.TARGET} -cdrom: release.iso +cdrom: release.iso bootonly.iso ftp: packagesystem rm -rf ${.OBJDIR}/ftp mkdir ${.OBJDIR}/ftp From owner-svn-src-head@FreeBSD.ORG Sun Mar 27 23:46: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 52616106566B; Sun, 27 Mar 2011 23:46:53 +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 3FD6F8FC13; Sun, 27 Mar 2011 23:46:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RNkrWV073371; Sun, 27 Mar 2011 23:46:53 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RNkrmF073369; Sun, 27 Mar 2011 23:46:53 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201103272346.p2RNkrmF073369@svn.freebsd.org> From: Nathan Whitehorn Date: Sun, 27 Mar 2011 23:46: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: r220082 - head/release 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, 27 Mar 2011 23:46:53 -0000 Author: nwhitehorn Date: Sun Mar 27 23:46:52 2011 New Revision: 220082 URL: http://svn.freebsd.org/changeset/base/220082 Log: Copy all generated ISO images into the release area. Modified: head/release/generate-release.sh Modified: head/release/generate-release.sh ============================================================================== --- head/release/generate-release.sh Sun Mar 27 23:46:12 2011 (r220081) +++ head/release/generate-release.sh Sun Mar 27 23:46:52 2011 (r220082) @@ -62,5 +62,5 @@ fi chroot $2 /bin/sh -c "cd /usr/src && make $MAKE_FLAGS buildworld buildkernel" || exit 1 chroot $2 /bin/sh -c "cd /usr/src/release && make release" || exit 1 mkdir $2/R -cp -pRP $2/usr/obj/usr/src/release/release.iso $2/usr/obj/usr/src/release/memstick $2/usr/obj/usr/src/release/ftp $2/R +cp -pRP $2/usr/obj/usr/src/release/*.iso $2/usr/obj/usr/src/release/memstick $2/usr/obj/usr/src/release/ftp $2/R From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 00:14:46 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 1233) id E21D2106566B; Mon, 28 Mar 2011 00:14:46 +0000 (UTC) Date: Mon, 28 Mar 2011 00:14:46 +0000 From: Alexander Best To: Nathan Whitehorn Message-ID: <20110328001446.GA74922@freebsd.org> References: <201103272346.p2RNkrmF073369@svn.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201103272346.p2RNkrmF073369@svn.freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r220082 - head/release 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, 28 Mar 2011 00:14:47 -0000 On Sun Mar 27 11, Nathan Whitehorn wrote: > Author: nwhitehorn > Date: Sun Mar 27 23:46:52 2011 > New Revision: 220082 > URL: http://svn.freebsd.org/changeset/base/220082 > > Log: > Copy all generated ISO images into the release area. s/cp -pRP/cp -a/ ? > > Modified: > head/release/generate-release.sh > > Modified: head/release/generate-release.sh > ============================================================================== > --- head/release/generate-release.sh Sun Mar 27 23:46:12 2011 (r220081) > +++ head/release/generate-release.sh Sun Mar 27 23:46:52 2011 (r220082) > @@ -62,5 +62,5 @@ fi > chroot $2 /bin/sh -c "cd /usr/src && make $MAKE_FLAGS buildworld buildkernel" || exit 1 > chroot $2 /bin/sh -c "cd /usr/src/release && make release" || exit 1 > mkdir $2/R > -cp -pRP $2/usr/obj/usr/src/release/release.iso $2/usr/obj/usr/src/release/memstick $2/usr/obj/usr/src/release/ftp $2/R > +cp -pRP $2/usr/obj/usr/src/release/*.iso $2/usr/obj/usr/src/release/memstick $2/usr/obj/usr/src/release/ftp $2/R > -- a13x From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 02:37: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 16008106564A; Mon, 28 Mar 2011 02:37:06 +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 019D98FC08; Mon, 28 Mar 2011 02:37:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S2b5mk077040; Mon, 28 Mar 2011 02:37:05 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S2b5Vt077038; Mon, 28 Mar 2011 02:37:05 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201103280237.p2S2b5Vt077038@svn.freebsd.org> From: Nathan Whitehorn Date: Mon, 28 Mar 2011 02:37:05 +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: r220088 - head/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: Mon, 28 Mar 2011 02:37:06 -0000 Author: nwhitehorn Date: Mon Mar 28 02:37:05 2011 New Revision: 220088 URL: http://svn.freebsd.org/changeset/base/220088 Log: Improve error handling. Modified: head/usr.sbin/bsdinstall/scripts/auto Modified: head/usr.sbin/bsdinstall/scripts/auto ============================================================================== --- head/usr.sbin/bsdinstall/scripts/auto Mon Mar 28 01:24:20 2011 (r220087) +++ head/usr.sbin/bsdinstall/scripts/auto Mon Mar 28 02:37:05 2011 (r220088) @@ -29,14 +29,14 @@ echo "Begun Installation at $(date)" > $BSDINSTALL_LOG error() { + test -n "$DISTDIR_IS_UNIONFS" && umount -f $BSDINSTALL_DISTDIR + test -f $PATH_FSTAB && bsdinstall umount dialog --backtitle "FreeBSD Installer" --title "Abort" \ --no-label "Exit" --yes-label "Restart" --yesno \ "An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0 if [ $? -ne 0 ]; then exit else - test -n $DISTDIR_IS_UNIONFS && umount -f $BSDINSTALL_DISTDIR - test -f $PATH_FSTAB && bsdinstall umount exec $0 fi } @@ -81,7 +81,7 @@ if [ -n "$FETCH_DISTRIBUTIONS" -a -n "$B NETCONFIG_DONE=yes fi -if [ -n "$FETCH_DISTRIBUTIONS" -a -z "$BSDINSTALL_DISTSITE" ]; then +if [ -n "$FETCH_DISTRIBUTIONS" ]; then exec 3>&1 BSDINSTALL_DISTSITE=`bsdinstall mirrorselect 2>&1 1>&3` MIRROR_BUTTON=$? @@ -125,8 +125,7 @@ if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then export DISTRIBUTIONS="$FETCH_DISTRIBUTIONS" # Try to use any existing distfiles - if [ -d $BSDINSTALL_DISTDIR -a "$FETCH_DISTRIBUTIONS" != \ - "$ALL_DISTRIBUTIONS" ]; then + if [ -d $BSDINSTALL_DISTDIR ]; then DISTDIR_IS_UNIONFS=1 mount_unionfs "$BSDINSTALL_FETCHDEST" "$BSDINSTALL_DISTDIR" fi From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 04:29: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 1293810656AC; Mon, 28 Mar 2011 04:29:51 +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 F2FFE8FC08; Mon, 28 Mar 2011 04:29:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S4Toqc080812; Mon, 28 Mar 2011 04:29:50 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S4To9v080810; Mon, 28 Mar 2011 04:29:50 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201103280429.p2S4To9v080810@svn.freebsd.org> From: Nathan Whitehorn Date: Mon, 28 Mar 2011 04:29: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: r220089 - head/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: Mon, 28 Mar 2011 04:29:51 -0000 Author: nwhitehorn Date: Mon Mar 28 04:29:50 2011 New Revision: 220089 URL: http://svn.freebsd.org/changeset/base/220089 Log: Committing while tired is never a good idea. Remove an unconditional error exit left over from debugging. Modified: head/usr.sbin/bsdinstall/scripts/auto Modified: head/usr.sbin/bsdinstall/scripts/auto ============================================================================== --- head/usr.sbin/bsdinstall/scripts/auto Mon Mar 28 02:37:05 2011 (r220088) +++ head/usr.sbin/bsdinstall/scripts/auto Mon Mar 28 04:29:50 2011 (r220089) @@ -140,8 +140,6 @@ if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then export DISTRIBUTIONS="$ALL_DISTRIBUTIONS" fi -error - bsdinstall checksum || error bsdinstall distextract || error bsdinstall rootpass || error From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 06:35: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 58F5D106564A; Mon, 28 Mar 2011 06:35:18 +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 2E9868FC14; Mon, 28 Mar 2011 06:35:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S6ZIQC083632; Mon, 28 Mar 2011 06:35:18 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S6ZIev083629; Mon, 28 Mar 2011 06:35:18 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201103280635.p2S6ZIev083629@svn.freebsd.org> From: Alan Cox Date: Mon, 28 Mar 2011 06:35: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: r220090 - in head/sys: amd64/amd64 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, 28 Mar 2011 06:35:18 -0000 Author: alc Date: Mon Mar 28 06:35:17 2011 New Revision: 220090 URL: http://svn.freebsd.org/changeset/base/220090 Log: The new binutils has correctly redefined MAXPAGESIZE on amd64 as 0x200000 instead of 0x100000. As a side effect, an amd64 kernel now loads at physical address 0x200000 instead of 0x100000. This is probably for the best because it avoids the use of a 2MB page mapping for the first 1MB of the kernel that also spans the fixed MTRRs. However, getmemsize() still thinks that the kernel loads at 0x100000, and so the physical memory between 0x100000 and 0x200000 is lost. Fix this problem by replacing the hard-wired constant in getmemsize() by a symbol "kernphys" that is defined by the linker script. In collaboration with: kib Modified: head/sys/amd64/amd64/machdep.c head/sys/conf/ldscript.amd64 Modified: head/sys/amd64/amd64/machdep.c ============================================================================== --- head/sys/amd64/amd64/machdep.c Mon Mar 28 04:29:50 2011 (r220089) +++ head/sys/amd64/amd64/machdep.c Mon Mar 28 06:35:17 2011 (r220090) @@ -156,6 +156,11 @@ static void get_fpcontext(struct thread static int set_fpcontext(struct thread *td, const mcontext_t *mcp); SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL); +/* + * The file "conf/ldscript.amd64" defines the symbol "kernphys". Its value is + * the physical address at which the kernel is loaded. + */ +extern char kernphys[]; #ifdef DDB extern vm_offset_t ksym_start, ksym_end; #endif @@ -1417,7 +1422,7 @@ getmemsize(caddr_t kmdp, u_int64_t first /* * block out kernel memory as not available. */ - if (pa >= 0x100000 && pa < first) + if (pa >= (vm_paddr_t)kernphys && pa < first) goto do_dump_avail; /* Modified: head/sys/conf/ldscript.amd64 ============================================================================== --- head/sys/conf/ldscript.amd64 Mon Mar 28 04:29:50 2011 (r220089) +++ head/sys/conf/ldscript.amd64 Mon Mar 28 06:35:17 2011 (r220090) @@ -6,7 +6,8 @@ SEARCH_DIR("/usr/lib"); SECTIONS { /* Read-only sections, merged into text segment: */ - . = kernbase + CONSTANT (MAXPAGESIZE) + SIZEOF_HEADERS; + kernphys = CONSTANT (MAXPAGESIZE); + . = kernbase + kernphys + SIZEOF_HEADERS; .interp : { *(.interp) } .hash : { *(.hash) } .gnu.hash : { *(.gnu.hash) } From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 07:00: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 805B7106564A; Mon, 28 Mar 2011 07:00:41 +0000 (UTC) (envelope-from mr@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 70F2E8FC1E; Mon, 28 Mar 2011 07:00:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S70f3F084252; Mon, 28 Mar 2011 07:00:41 GMT (envelope-from mr@svn.freebsd.org) Received: (from mr@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S70fsr084250; Mon, 28 Mar 2011 07:00:41 GMT (envelope-from mr@svn.freebsd.org) Message-Id: <201103280700.p2S70fsr084250@svn.freebsd.org> From: Michael Reifenberger Date: Mon, 28 Mar 2011 07:00:41 +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: r220091 - head/tools/tools/nanobsd 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, 28 Mar 2011 07:00:41 -0000 Author: mr Date: Mon Mar 28 07:00:41 2011 New Revision: 220091 URL: http://svn.freebsd.org/changeset/base/220091 Log: Use ${NANO_WORLDDIR}/var/empty as copy source since it has no schg flag set. Copying over /var/empty's schg flag had unpleasant side effects (schg flag on /etc and /cfg) during nanobsd boot before. Modified: head/tools/tools/nanobsd/nanobsd.sh Modified: head/tools/tools/nanobsd/nanobsd.sh ============================================================================== --- head/tools/tools/nanobsd/nanobsd.sh Mon Mar 28 06:35:17 2011 (r220090) +++ head/tools/tools/nanobsd/nanobsd.sh Mon Mar 28 07:00:41 2011 (r220091) @@ -413,8 +413,8 @@ populate_slice ( ) ( dir=$2 mnt=$3 lbl=$4 - test -z $2 && dir=/var/empty - test -d $dir || dir=/var/empty + test -z $2 && dir=${NANO_WORLDDIR}/var/empty + test -d $dir || dir=${NANO_WORLDDIR}/var/empty echo "Creating ${dev} with ${dir} (mounting on ${mnt})" newfs_part $dev $mnt $lbl cd ${dir} From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 08:37: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 899DD106566C; Mon, 28 Mar 2011 08:37:48 +0000 (UTC) (envelope-from martymac@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 792018FC16; Mon, 28 Mar 2011 08:37:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S8bmoA086890; Mon, 28 Mar 2011 08:37:48 GMT (envelope-from martymac@svn.freebsd.org) Received: (from martymac@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S8bm1V086888; Mon, 28 Mar 2011 08:37:48 GMT (envelope-from martymac@svn.freebsd.org) Message-Id: <201103280837.p2S8bm1V086888@svn.freebsd.org> From: Ganael LAPLANCHE Date: Mon, 28 Mar 2011 08:37: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: r220094 - head/usr.bin/calendar/calendars 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, 28 Mar 2011 08:37:48 -0000 Author: martymac (ports committer) Date: Mon Mar 28 08:37:48 2011 New Revision: 220094 URL: http://svn.freebsd.org/changeset/base/220094 Log: Add myself Modified: head/usr.bin/calendar/calendars/calendar.freebsd Modified: head/usr.bin/calendar/calendars/calendar.freebsd ============================================================================== --- head/usr.bin/calendar/calendars/calendar.freebsd Mon Mar 28 08:23:45 2011 (r220093) +++ head/usr.bin/calendar/calendars/calendar.freebsd Mon Mar 28 08:37:48 2011 (r220094) @@ -320,6 +320,7 @@ 12/03 Diane Bruce born in Ottawa, Ontario, Canada, 1952 12/05 Ivan Voras born in Slavonski Brod, Croatia, 1981 12/06 Stefan Farfeleder born in Wien, Austria, 1980 +12/11 Ganael Laplanche born in Reims, France, 1980 12/15 James FitzGibbon born in Amersham, Buckinghamshire, United Kingdom, 1974 12/15 Timur I. Bakeyev born in Kazan, Republic of Tatarstan, USSR, 1974 12/18 Chris Timmons born in Ellensburg, Washington, United States, 1964 From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 09:05:43 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 8DD821065670; Mon, 28 Mar 2011 09:05:43 +0000 (UTC) (envelope-from martymac@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7CE958FC1D; Mon, 28 Mar 2011 09:05:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S95h6g087572; Mon, 28 Mar 2011 09:05:43 GMT (envelope-from martymac@svn.freebsd.org) Received: (from martymac@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S95hgw087570; Mon, 28 Mar 2011 09:05:43 GMT (envelope-from martymac@svn.freebsd.org) Message-Id: <201103280905.p2S95hgw087570@svn.freebsd.org> From: Ganael LAPLANCHE Date: Mon, 28 Mar 2011 09:05:43 +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: r220095 - head/share/misc 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, 28 Mar 2011 09:05:43 -0000 Author: martymac (ports committer) Date: Mon Mar 28 09:05:43 2011 New Revision: 220095 URL: http://svn.freebsd.org/changeset/base/220095 Log: Add myself to committers-ports.dot Modified: head/share/misc/committers-ports.dot Modified: head/share/misc/committers-ports.dot ============================================================================== --- head/share/misc/committers-ports.dot Mon Mar 28 08:37:48 2011 (r220094) +++ head/share/misc/committers-ports.dot Mon Mar 28 09:05:43 2011 (r220095) @@ -127,6 +127,7 @@ makc [label="Max Brazhnikov\nmakc@FreeBS mandree [label="Matthias Andree\nmandree@FreeBSD.org\n2009/11/18"] marcus [label="Joe Marcus Clarke\nmarcus@FreeBSD.org\n2002/04/05"] markus [label="Markus Brueffer\nmarkus@FreeBSD.org\n2004/02/21"] +martymac [label="Ganael Laplanche\nmartymac@FreeBSD.org\n2010/09/24"] mat [label="Mathieu Arnold\nmat@FreeBSD.org\n2003/08/15"] mezz [label="Jeremy Messenger\nmezz@FreeBSD.org\n2004/04/30"] miwi [label="Martin Wilke\nmiwi@FreeBSD.org\n2006/06/04"] From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 09:11:00 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 1BF04106564A; Mon, 28 Mar 2011 09:11:00 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0ABB98FC15; Mon, 28 Mar 2011 09:11:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S9AxSp087728; Mon, 28 Mar 2011 09:10:59 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S9Ax4u087726; Mon, 28 Mar 2011 09:10:59 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103280910.p2S9Ax4u087726@svn.freebsd.org> From: Adrian Chadd Date: Mon, 28 Mar 2011 09:10:59 +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: r220096 - head/sys/mips/atheros 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, 28 Mar 2011 09:11:00 -0000 Author: adrian Date: Mon Mar 28 09:10:59 2011 New Revision: 220096 URL: http://svn.freebsd.org/changeset/base/220096 Log: The previous commit didn't completely rename this to what it should be. Modified: head/sys/mips/atheros/ar71xx_machdep.c Modified: head/sys/mips/atheros/ar71xx_machdep.c ============================================================================== --- head/sys/mips/atheros/ar71xx_machdep.c Mon Mar 28 09:05:43 2011 (r220095) +++ head/sys/mips/atheros/ar71xx_machdep.c Mon Mar 28 09:10:59 2011 (r220096) @@ -217,7 +217,7 @@ platform_start(__register_t a0 __unused, * but in fact there's 32mb. */ #if defined(AR71XX_REALMEM) - realmem = btoc(MIPS_REALMEM); + realmem = btoc(AR71XX_REALMEM); #endif /* phys_avail regions are in bytes */ From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 11:08: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 2C84C1065676; Mon, 28 Mar 2011 11:08:59 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 195188FC2A; Mon, 28 Mar 2011 11:08:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SB8w47092607; Mon, 28 Mar 2011 11:08:58 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SB8w9w092605; Mon, 28 Mar 2011 11:08:58 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201103281108.p2SB8w9w092605@svn.freebsd.org> From: Alexander Motin Date: Mon, 28 Mar 2011 11:08: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: r220097 - head/sys/dev/mvs 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, 28 Mar 2011 11:08:59 -0000 Author: mav Date: Mon Mar 28 11:08:58 2011 New Revision: 220097 URL: http://svn.freebsd.org/changeset/base/220097 Log: Update mvs(4) driver to work over FDT's simplebus(4) bus. Modified: head/sys/dev/mvs/mvs_soc.c Modified: head/sys/dev/mvs/mvs_soc.c ============================================================================== --- head/sys/dev/mvs/mvs_soc.c Mon Mar 28 09:10:59 2011 (r220096) +++ head/sys/dev/mvs/mvs_soc.c Mon Mar 28 11:08:58 2011 (r220097) @@ -43,6 +43,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include "mvs.h" /* local prototypes */ @@ -73,6 +75,9 @@ mvs_probe(device_t dev) int i; uint32_t devid, revid; + if (!ofw_bus_is_compatible(dev, "mrvl,sata")) + return (ENXIO); + soc_id(&devid, &revid); for (i = 0; mvs_ids[i].id != 0; i++) { if (mvs_ids[i].id == devid && @@ -440,10 +445,10 @@ static device_method_t mvs_methods[] = { { 0, 0 } }; static driver_t mvs_driver = { - "sata", + "mvs", mvs_methods, sizeof(struct mvs_controller) }; -DRIVER_MODULE(sata, mbus, mvs_driver, mvs_devclass, 0, 0); -MODULE_VERSION(sata, 1); - +DRIVER_MODULE(mvs, simplebus, mvs_driver, mvs_devclass, 0, 0); +MODULE_VERSION(mvs, 1); +MODULE_DEPEND(mvs, cam, 1, 1, 1); From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 11:48: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 6E1E71065680; Mon, 28 Mar 2011 11:48:49 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5C4AE8FC0A; Mon, 28 Mar 2011 11:48:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SBmni4093479; Mon, 28 Mar 2011 11:48:49 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SBmnNq093477; Mon, 28 Mar 2011 11:48:49 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103281148.p2SBmnNq093477@svn.freebsd.org> From: Adrian Chadd Date: Mon, 28 Mar 2011 11:48:49 +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: r220098 - head/sys/dev/ath 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, 28 Mar 2011 11:48:49 -0000 Author: adrian Date: Mon Mar 28 11:48:49 2011 New Revision: 220098 URL: http://svn.freebsd.org/changeset/base/220098 Log: Add in HT protection but disable it by default. I'll clear how it's supposed to work with Bernhard and then look at enabling this in the correct situations. But this -does- enable HT RTS protection (using the appropriate legacy rates) if this bit of code is enabled. Modified: head/sys/dev/ath/if_ath_tx.c Modified: head/sys/dev/ath/if_ath_tx.c ============================================================================== --- head/sys/dev/ath/if_ath_tx.c Mon Mar 28 11:08:58 2011 (r220097) +++ head/sys/dev/ath/if_ath_tx.c Mon Mar 28 11:48:49 2011 (r220098) @@ -702,6 +702,24 @@ ath_tx_start(struct ath_softc *sc, struc sc->sc_stats.ast_tx_protect++; } +#if 0 + /* + * If 11n protection is enabled and it's a HT frame, + * enable RTS. + * + * XXX ic_htprotmode or ic_curhtprotmode? + * XXX should it_htprotmode only matter if ic_curhtprotmode + * XXX indicates it's not a HT pure environment? + */ + if ((ic->ic_htprotmode == IEEE80211_PROT_RTSCTS) && + rt->info[rix].phy == IEEE80211_T_HT && + (flags & HAL_TXDESC_NOACK) == 0) { + cix = rt->info[sc->sc_protrix].controlRate; + flags |= HAL_TXDESC_RTSENA; + sc->sc_stats.ast_tx_htprotect++; + } +#endif + /* * Calculate duration. This logically belongs in the 802.11 * layer but it lacks sufficient information to calculate it. From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 12:39: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 A1ABA1065672; Mon, 28 Mar 2011 12:39:48 +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 8EE398FC1F; Mon, 28 Mar 2011 12:39:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SCdmd6094651; Mon, 28 Mar 2011 12:39:48 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SCdm46094649; Mon, 28 Mar 2011 12:39:48 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201103281239.p2SCdm46094649@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 28 Mar 2011 12:39: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: r220099 - 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, 28 Mar 2011 12:39:48 -0000 Author: kib Date: Mon Mar 28 12:39:48 2011 New Revision: 220099 URL: http://svn.freebsd.org/changeset/base/220099 Log: Fix the softdep_request_cleanup() function definition for !SOFTUPDATES case. Submitted by: Aleksandr Rybalko Modified: head/sys/ufs/ffs/ffs_softdep.c Modified: head/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- head/sys/ufs/ffs/ffs_softdep.c Mon Mar 28 11:48:49 2011 (r220098) +++ head/sys/ufs/ffs/ffs_softdep.c Mon Mar 28 12:39:48 2011 (r220099) @@ -514,9 +514,10 @@ softdep_releasefile(ip) } int -softdep_request_cleanup(fs, vp) +softdep_request_cleanup(fs, vp, resource) struct fs *fs; struct vnode *vp; + int resource; { return (0); From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 12:48: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 A5559106566B; Mon, 28 Mar 2011 12:48:33 +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 918798FC0A; Mon, 28 Mar 2011 12:48:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SCmXf8094858; Mon, 28 Mar 2011 12:48:33 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SCmX2m094854; Mon, 28 Mar 2011 12:48:33 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201103281248.p2SCmX2m094854@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 28 Mar 2011 12:48: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: r220100 - in head/sys: dev/ksyms 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, 28 Mar 2011 12:48:33 -0000 Author: kib Date: Mon Mar 28 12:48:33 2011 New Revision: 220100 URL: http://svn.freebsd.org/changeset/base/220100 Log: Promote ksyms_map() and ksyms_unmap() to general facility copyout_map() and copyout_unmap() interfaces. Submitted by: John Wehle , nox MFC after: 2 weeks Modified: head/sys/dev/ksyms/ksyms.c head/sys/kern/subr_uio.c head/sys/sys/uio.h Modified: head/sys/dev/ksyms/ksyms.c ============================================================================== --- head/sys/dev/ksyms/ksyms.c Mon Mar 28 12:39:48 2011 (r220099) +++ head/sys/dev/ksyms/ksyms.c Mon Mar 28 12:48:33 2011 (r220100) @@ -360,53 +360,6 @@ ksyms_snapshot(struct tsizes *ts, vm_off return (error); } -/* - * Map some anonymous memory in user space of size sz, rounded up to the page - * boundary. - */ -static int -ksyms_map(struct thread *td, vm_offset_t *addr, size_t sz) -{ - struct vmspace *vms = td->td_proc->p_vmspace; - int error; - vm_size_t size; - - - /* - * Map somewhere after heap in process memory. - */ - PROC_LOCK(td->td_proc); - *addr = round_page((vm_offset_t)vms->vm_daddr + - lim_max(td->td_proc, RLIMIT_DATA)); - PROC_UNLOCK(td->td_proc); - - /* round size up to page boundry */ - size = (vm_size_t) round_page(sz); - - error = vm_mmap(&vms->vm_map, addr, size, PROT_READ | PROT_WRITE, - VM_PROT_ALL, MAP_PRIVATE | MAP_ANON, OBJT_DEFAULT, NULL, 0); - - return (error); -} - -/* - * Unmap memory in user space. - */ -static int -ksyms_unmap(struct thread *td, vm_offset_t addr, size_t sz) -{ - vm_map_t map; - vm_size_t size; - - map = &td->td_proc->p_vmspace->vm_map; - size = (vm_size_t) round_page(sz); - - if (!vm_map_remove(map, addr, addr + size)) - return (EINVAL); - - return (0); -} - static void ksyms_cdevpriv_dtr(void *data) { @@ -475,7 +428,7 @@ ksyms_open(struct cdev *dev, int flags, total_elf_sz = sizeof(struct ksyms_hdr) + ts.ts_symsz + ts.ts_strsz; - error = ksyms_map(td, &(sc->sc_uaddr), + error = copyout_map(td, &(sc->sc_uaddr), (vm_size_t) total_elf_sz); if (error) break; @@ -488,7 +441,7 @@ ksyms_open(struct cdev *dev, int flags, } /* Snapshot failed, unmap the memory and try again */ - (void) ksyms_unmap(td, sc->sc_uaddr, sc->sc_usize); + (void) copyout_unmap(td, sc->sc_uaddr, sc->sc_usize); } failed: @@ -624,7 +577,7 @@ ksyms_close(struct cdev *dev, int flags return (error); /* Unmap the buffer from the process address space. */ - error = ksyms_unmap(td, sc->sc_uaddr, sc->sc_usize); + error = copyout_unmap(td, sc->sc_uaddr, sc->sc_usize); devfs_clear_cdevpriv(); Modified: head/sys/kern/subr_uio.c ============================================================================== --- head/sys/kern/subr_uio.c Mon Mar 28 12:39:48 2011 (r220099) +++ head/sys/kern/subr_uio.c Mon Mar 28 12:48:33 2011 (r220100) @@ -44,13 +44,16 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#include #include #include #include #include +#include #include #include #ifdef ZERO_COPY_SOCKETS @@ -457,3 +460,49 @@ cloneuio(struct uio *uiop) bcopy(uiop->uio_iov, uio->uio_iov, iovlen); return (uio); } + +/* + * Map some anonymous memory in user space of size sz, rounded up to the page + * boundary. + */ +int +copyout_map(struct thread *td, vm_offset_t *addr, size_t sz) +{ + struct vmspace *vms = td->td_proc->p_vmspace; + int error; + vm_size_t size; + + /* + * Map somewhere after heap in process memory. + */ + PROC_LOCK(td->td_proc); + *addr = round_page((vm_offset_t)vms->vm_daddr + + lim_max(td->td_proc, RLIMIT_DATA)); + PROC_UNLOCK(td->td_proc); + + /* round size up to page boundry */ + size = (vm_size_t) round_page(sz); + + error = vm_mmap(&vms->vm_map, addr, size, PROT_READ | PROT_WRITE, + VM_PROT_ALL, MAP_PRIVATE | MAP_ANON, OBJT_DEFAULT, NULL, 0); + + return (error); +} + +/* + * Unmap memory in user space. + */ +int +copyout_unmap(struct thread *td, vm_offset_t addr, size_t sz) +{ + vm_map_t map; + vm_size_t size; + + map = &td->td_proc->p_vmspace->vm_map; + size = (vm_size_t) round_page(sz); + + if (!vm_map_remove(map, addr, addr + size)) + return (EINVAL); + + return (0); +} Modified: head/sys/sys/uio.h ============================================================================== --- head/sys/sys/uio.h Mon Mar 28 12:39:48 2011 (r220099) +++ head/sys/sys/uio.h Mon Mar 28 12:48:33 2011 (r220100) @@ -94,6 +94,8 @@ int copyiniov(struct iovec *iovp, u_int int copyinstrfrom(const void * __restrict src, void * __restrict dst, size_t len, size_t * __restrict copied, int seg); int copyinuio(struct iovec *iovp, u_int iovcnt, struct uio **uiop); +int copyout_map(struct thread *td, vm_offset_t *addr, size_t sz); +int copyout_unmap(struct thread *td, vm_offset_t addr, size_t sz); int uiomove(void *cp, int n, struct uio *uio); int uiomove_frombuf(void *buf, int buflen, struct uio *uio); int uiomove_fromphys(struct vm_page *ma[], vm_offset_t offset, int n, From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 13:21: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 C7C37106564A; Mon, 28 Mar 2011 13:21:26 +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 B34128FC16; Mon, 28 Mar 2011 13:21:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SDLQwN095548; Mon, 28 Mar 2011 13:21:26 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SDLQSt095546; Mon, 28 Mar 2011 13:21:26 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201103281321.p2SDLQSt095546@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 28 Mar 2011 13:21: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: r220101 - 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: Mon, 28 Mar 2011 13:21:26 -0000 Author: kib Date: Mon Mar 28 13:21:26 2011 New Revision: 220101 URL: http://svn.freebsd.org/changeset/base/220101 Log: Handle zero length in copyout_unmap(). Submitted by: John Wehle MFC after: 2 weeks Modified: head/sys/kern/subr_uio.c Modified: head/sys/kern/subr_uio.c ============================================================================== --- head/sys/kern/subr_uio.c Mon Mar 28 12:48:33 2011 (r220100) +++ head/sys/kern/subr_uio.c Mon Mar 28 13:21:26 2011 (r220101) @@ -498,6 +498,9 @@ copyout_unmap(struct thread *td, vm_offs vm_map_t map; vm_size_t size; + if (sz == 0) + return (0); + map = &td->td_proc->p_vmspace->vm_map; size = (vm_size_t) round_page(sz); From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 13:28: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 60462106566C; Mon, 28 Mar 2011 13:28:23 +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 4B3BA8FC0A; Mon, 28 Mar 2011 13:28:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SDSNLe095738; Mon, 28 Mar 2011 13:28:23 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SDSNdC095736; Mon, 28 Mar 2011 13:28:23 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201103281328.p2SDSNdC095736@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 28 Mar 2011 13:28: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: r220102 - 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: Mon, 28 Mar 2011 13:28:23 -0000 Author: kib Date: Mon Mar 28 13:28:23 2011 New Revision: 220102 URL: http://svn.freebsd.org/changeset/base/220102 Log: Trim white spaces, adjust style. MFC after: 2 weeks Modified: head/sys/kern/subr_uio.c Modified: head/sys/kern/subr_uio.c ============================================================================== --- head/sys/kern/subr_uio.c Mon Mar 28 13:21:26 2011 (r220101) +++ head/sys/kern/subr_uio.c Mon Mar 28 13:28:23 2011 (r220102) @@ -468,24 +468,26 @@ cloneuio(struct uio *uiop) int copyout_map(struct thread *td, vm_offset_t *addr, size_t sz) { - struct vmspace *vms = td->td_proc->p_vmspace; + struct vmspace *vms; int error; vm_size_t size; - - /* + + vms = td->td_proc->p_vmspace; + + /* * Map somewhere after heap in process memory. */ PROC_LOCK(td->td_proc); - *addr = round_page((vm_offset_t)vms->vm_daddr + + *addr = round_page((vm_offset_t)vms->vm_daddr + lim_max(td->td_proc, RLIMIT_DATA)); PROC_UNLOCK(td->td_proc); /* round size up to page boundry */ - size = (vm_size_t) round_page(sz); - - error = vm_mmap(&vms->vm_map, addr, size, PROT_READ | PROT_WRITE, + size = (vm_size_t)round_page(sz); + + error = vm_mmap(&vms->vm_map, addr, size, PROT_READ | PROT_WRITE, VM_PROT_ALL, MAP_PRIVATE | MAP_ANON, OBJT_DEFAULT, NULL, 0); - + return (error); } @@ -497,12 +499,12 @@ copyout_unmap(struct thread *td, vm_offs { vm_map_t map; vm_size_t size; - + if (sz == 0) return (0); map = &td->td_proc->p_vmspace->vm_map; - size = (vm_size_t) round_page(sz); + size = (vm_size_t)round_page(sz); if (!vm_map_remove(map, addr, addr + size)) return (EINVAL); From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 16:58: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 B5A251065676; Mon, 28 Mar 2011 16:58:48 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A68858FC13; Mon, 28 Mar 2011 16:58:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SGwmJR000487; Mon, 28 Mar 2011 16:58:48 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SGwmOv000485; Mon, 28 Mar 2011 16:58:48 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103281658.p2SGwmOv000485@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 28 Mar 2011 16:58: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: r220103 - head/sys/dev/fxp 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, 28 Mar 2011 16:58:48 -0000 Author: yongari Date: Mon Mar 28 16:58:48 2011 New Revision: 220103 URL: http://svn.freebsd.org/changeset/base/220103 Log: Normally fxp(4) does not receive bad frames but promiscuous mode makes controller to receive bad frames and i82557 will also receive bad frames since fxp(4) have to receive VLAN oversized frames. If fxp(4) encounter DMA overrun error, the received frame size would be 0 so the actual frame size after checksum field extraction the length would be negative(-2). Due to signed/unsigned comparison used in driver, frame length check did not work for DMA overrun frames. Correct this by casting it to int. While I'm here explicitly check DMA overrun error and discard the frame regardless of result of received frame length check. Reported by: n_hibma Tested by: n_hibma MFC after: 1 week Modified: head/sys/dev/fxp/if_fxp.c Modified: head/sys/dev/fxp/if_fxp.c ============================================================================== --- head/sys/dev/fxp/if_fxp.c Mon Mar 28 13:28:23 2011 (r220102) +++ head/sys/dev/fxp/if_fxp.c Mon Mar 28 16:58:48 2011 (r220103) @@ -1941,11 +1941,11 @@ fxp_intr_body(struct fxp_softc *sc, stru /* Adjust for appended checksum bytes. */ total_len -= 2; } - if (total_len < sizeof(struct ether_header) || + if (total_len < (int)sizeof(struct ether_header) || total_len > (MCLBYTES - RFA_ALIGNMENT_FUDGE - sc->rfa_size) || status & (FXP_RFA_STATUS_CRC | - FXP_RFA_STATUS_ALIGN)) { + FXP_RFA_STATUS_ALIGN | FXP_RFA_STATUS_OVERRUN)) { m_freem(m); fxp_add_rfabuf(sc, rxp); continue; From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 19:03: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 08A05106564A; Mon, 28 Mar 2011 19:03:57 +0000 (UTC) (envelope-from weongyo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id ED0AA8FC0C; Mon, 28 Mar 2011 19:03:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SJ3ucY003531; Mon, 28 Mar 2011 19:03:56 GMT (envelope-from weongyo@svn.freebsd.org) Received: (from weongyo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SJ3uht003529; Mon, 28 Mar 2011 19:03:56 GMT (envelope-from weongyo@svn.freebsd.org) Message-Id: <201103281903.p2SJ3uht003529@svn.freebsd.org> From: Weongyo Jeong Date: Mon, 28 Mar 2011 19:03: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: r220105 - 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, 28 Mar 2011 19:03:57 -0000 Author: weongyo Date: Mon Mar 28 19:03:56 2011 New Revision: 220105 URL: http://svn.freebsd.org/changeset/base/220105 Log: Covers values if (BYTES_THIS_ACK(tp, th) / tp->t_maxseg) value is from 2.0 to 3.0. Reviewed by: lstewart Modified: head/sys/netinet/tcp_sack.c Modified: head/sys/netinet/tcp_sack.c ============================================================================== --- head/sys/netinet/tcp_sack.c Mon Mar 28 17:41:10 2011 (r220104) +++ head/sys/netinet/tcp_sack.c Mon Mar 28 19:03:56 2011 (r220105) @@ -577,7 +577,7 @@ tcp_sack_partialack(struct tcpcb *tp, st tcp_timer_activate(tp, TT_REXMT, 0); tp->t_rtttime = 0; /* Send one or 2 segments based on how much new data was acked. */ - if ((BYTES_THIS_ACK(tp, th) / tp->t_maxseg) > 2) + if ((BYTES_THIS_ACK(tp, th) / tp->t_maxseg) >= 2) num_segs = 2; tp->snd_cwnd = (tp->sackhint.sack_bytes_rexmit + (tp->snd_nxt - tp->sack_newdata) + num_segs * tp->t_maxseg); From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 19:08: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 9719F106564A; Mon, 28 Mar 2011 19:08:53 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 873028FC17; Mon, 28 Mar 2011 19:08:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SJ8rhw003683; Mon, 28 Mar 2011 19:08:53 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SJ8rdR003681; Mon, 28 Mar 2011 19:08:53 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103281908.p2SJ8rdR003681@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 28 Mar 2011 19:08: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: r220106 - head/sys/dev/dc 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, 28 Mar 2011 19:08:53 -0000 Author: yongari Date: Mon Mar 28 19:08:53 2011 New Revision: 220106 URL: http://svn.freebsd.org/changeset/base/220106 Log: Revise r220046 by introducing dc_netcfg_wait() which waits the end of active DMA cycle. dc_setcfg() also has to wait until the DMA engine is stopped so using a common function to handle the job is better than duplicating the code. No objection from: marius Modified: head/sys/dev/dc/if_dc.c Modified: head/sys/dev/dc/if_dc.c ============================================================================== --- head/sys/dev/dc/if_dc.c Mon Mar 28 19:03:56 2011 (r220105) +++ head/sys/dev/dc/if_dc.c Mon Mar 28 19:08:53 2011 (r220106) @@ -279,6 +279,7 @@ static void dc_miibus_statchg(device_t); static void dc_miibus_mediainit(device_t); static void dc_setcfg(struct dc_softc *, int); +static void dc_netcfg_wait(struct dc_softc *); static uint32_t dc_mchash_le(struct dc_softc *, const uint8_t *); static uint32_t dc_mchash_be(const uint8_t *); static void dc_setfilt_21143(struct dc_softc *); @@ -1370,6 +1371,32 @@ dc_setfilt(struct dc_softc *sc) dc_setfilt_xircom(sc); } +static void +dc_netcfg_wait(struct dc_softc *sc) +{ + uint32_t isr; + int i; + + for (i = 0; i < DC_TIMEOUT; i++) { + isr = CSR_READ_4(sc, DC_ISR); + if (isr & DC_ISR_TX_IDLE && + ((isr & DC_ISR_RX_STATE) == DC_RXSTATE_STOPPED || + (isr & DC_ISR_RX_STATE) == DC_RXSTATE_WAIT)) + break; + DELAY(10); + } + if (i == DC_TIMEOUT) { + if (!(isr & DC_ISR_TX_IDLE) && !DC_IS_ASIX(sc)) + device_printf(sc->dc_dev, + "%s: failed to force tx to idle state\n", __func__); + if (!((isr & DC_ISR_RX_STATE) == DC_RXSTATE_STOPPED || + (isr & DC_ISR_RX_STATE) == DC_RXSTATE_WAIT) && + !DC_HAS_BROKEN_RXSTATE(sc)) + device_printf(sc->dc_dev, + "%s: failed to force rx to idle state\n", __func__); + } +} + /* * In order to fiddle with the 'full-duplex' and '100Mbps' bits in * the netconfig register, we first have to put the transmit and/or @@ -1378,8 +1405,7 @@ dc_setfilt(struct dc_softc *sc) static void dc_setcfg(struct dc_softc *sc, int media) { - int i, restart = 0, watchdogreg; - uint32_t isr; + int restart = 0, watchdogreg; if (IFM_SUBTYPE(media) == IFM_NONE) return; @@ -1387,28 +1413,7 @@ dc_setcfg(struct dc_softc *sc, int media if (CSR_READ_4(sc, DC_NETCFG) & (DC_NETCFG_TX_ON | DC_NETCFG_RX_ON)) { restart = 1; DC_CLRBIT(sc, DC_NETCFG, (DC_NETCFG_TX_ON | DC_NETCFG_RX_ON)); - - for (i = 0; i < DC_TIMEOUT; i++) { - isr = CSR_READ_4(sc, DC_ISR); - if (isr & DC_ISR_TX_IDLE && - ((isr & DC_ISR_RX_STATE) == DC_RXSTATE_STOPPED || - (isr & DC_ISR_RX_STATE) == DC_RXSTATE_WAIT)) - break; - DELAY(10); - } - - if (i == DC_TIMEOUT) { - if (!(isr & DC_ISR_TX_IDLE) && !DC_IS_ASIX(sc)) - device_printf(sc->dc_dev, - "%s: failed to force tx to idle state\n", - __func__); - if (!((isr & DC_ISR_RX_STATE) == DC_RXSTATE_STOPPED || - (isr & DC_ISR_RX_STATE) == DC_RXSTATE_WAIT) && - !DC_HAS_BROKEN_RXSTATE(sc)) - device_printf(sc->dc_dev, - "%s: failed to force rx to idle state\n", - __func__); - } + dc_netcfg_wait(sc); } if (IFM_SUBTYPE(media) == IFM_100_TX) { @@ -3917,7 +3922,7 @@ dc_stop(struct dc_softc *sc) struct dc_list_data *ld; struct dc_chain_data *cd; int i; - uint32_t ctl, isr; + uint32_t ctl, netcfg; DC_LOCK_ASSERT(sc); @@ -3928,38 +3933,21 @@ dc_stop(struct dc_softc *sc) callout_stop(&sc->dc_stat_ch); callout_stop(&sc->dc_wdog_ch); sc->dc_wdog_timer = 0; + sc->dc_link = 0; ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); - DC_CLRBIT(sc, DC_NETCFG, (DC_NETCFG_RX_ON | DC_NETCFG_TX_ON)); - - for (i = 0; i < DC_TIMEOUT; i++) { - isr = CSR_READ_4(sc, DC_ISR); - if ((isr & DC_ISR_TX_IDLE || - (isr & DC_ISR_TX_STATE) == DC_TXSTATE_RESET) && - (isr & DC_ISR_RX_STATE) == DC_RXSTATE_STOPPED) - break; - DELAY(10); - } - - if (i == DC_TIMEOUT) { - if (!((isr & DC_ISR_TX_IDLE) || - (isr & DC_ISR_TX_STATE) == DC_TXSTATE_RESET) && - !DC_IS_ASIX(sc) && !DC_IS_DAVICOM(sc)) - device_printf(sc->dc_dev, - "%s: failed to force tx to idle state\n", - __func__); - if (!((isr & DC_ISR_RX_STATE) == DC_RXSTATE_STOPPED) && - !DC_HAS_BROKEN_RXSTATE(sc)) - device_printf(sc->dc_dev, - "%s: failed to force rx to idle state\n", - __func__); - } - + netcfg = CSR_READ_4(sc, DC_NETCFG); + if (netcfg & (DC_NETCFG_RX_ON | DC_NETCFG_TX_ON)) + CSR_WRITE_4(sc, DC_NETCFG, + netcfg & ~(DC_NETCFG_RX_ON | DC_NETCFG_TX_ON)); CSR_WRITE_4(sc, DC_IMR, 0x00000000); + /* Wait the completion of TX/RX SM. */ + if (netcfg & (DC_NETCFG_RX_ON | DC_NETCFG_TX_ON)) + dc_netcfg_wait(sc); + CSR_WRITE_4(sc, DC_TXADDR, 0x00000000); CSR_WRITE_4(sc, DC_RXADDR, 0x00000000); - sc->dc_link = 0; /* * Free data in the RX lists. From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 19:44: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 34D6D106566B; Mon, 28 Mar 2011 19:44:55 +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 252D88FC1A; Mon, 28 Mar 2011 19:44:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SJitOe005094; Mon, 28 Mar 2011 19:44:55 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SJitvv005092; Mon, 28 Mar 2011 19:44:55 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201103281944.p2SJitvv005092@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 28 Mar 2011 19:44: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: r220114 - 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: Mon, 28 Mar 2011 19:44:55 -0000 Author: kib Date: Mon Mar 28 19:44:54 2011 New Revision: 220114 URL: http://svn.freebsd.org/changeset/base/220114 Log: Fix the check for vm_map_remove() error. Pointed out by: alc MFC after: 2 weeks Modified: head/sys/kern/subr_uio.c Modified: head/sys/kern/subr_uio.c ============================================================================== --- head/sys/kern/subr_uio.c Mon Mar 28 19:42:21 2011 (r220113) +++ head/sys/kern/subr_uio.c Mon Mar 28 19:44:54 2011 (r220114) @@ -506,7 +506,7 @@ copyout_unmap(struct thread *td, vm_offs map = &td->td_proc->p_vmspace->vm_map; size = (vm_size_t)round_page(sz); - if (!vm_map_remove(map, addr, addr + size)) + if (vm_map_remove(map, addr, addr + size) != KERN_SUCCESS) return (EINVAL); return (0); From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 23:08: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 484941065670; Mon, 28 Mar 2011 23:08:19 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 356558FC16; Mon, 28 Mar 2011 23:08:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SN8Jwn009535; Mon, 28 Mar 2011 23:08:19 GMT (envelope-from emax@svn.freebsd.org) Received: (from emax@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SN8JWX009532; Mon, 28 Mar 2011 23:08:19 GMT (envelope-from emax@svn.freebsd.org) Message-Id: <201103282308.p2SN8JWX009532@svn.freebsd.org> From: Maksim Yevmenkin Date: Mon, 28 Mar 2011 23:08: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: r220116 - head/usr.sbin/bluetooth/l2ping 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, 28 Mar 2011 23:08:19 -0000 Author: emax Date: Mon Mar 28 23:08:18 2011 New Revision: 220116 URL: http://svn.freebsd.org/changeset/base/220116 Log: Do not use word 'flood' as it not entirely correct. Use better 'no delay' description. While here, replace atoi(3) with strtol(3). Submitted by: arundel MFC after: 1 week Modified: head/usr.sbin/bluetooth/l2ping/l2ping.8 head/usr.sbin/bluetooth/l2ping/l2ping.c Modified: head/usr.sbin/bluetooth/l2ping/l2ping.8 ============================================================================== --- head/usr.sbin/bluetooth/l2ping/l2ping.8 Mon Mar 28 22:50:02 2011 (r220115) +++ head/usr.sbin/bluetooth/l2ping/l2ping.8 Mon Mar 28 23:08:18 2011 (r220116) @@ -25,7 +25,7 @@ .\" $Id: l2ping.8,v 1.3 2003/05/21 01:00:19 max Exp $ .\" $FreeBSD$ .\" -.Dd June 14, 2002 +.Dd March 29, 2011 .Dt L2PING 8 .Os .Sh NAME @@ -36,7 +36,7 @@ .Op Fl fhn .Fl a Ar remote .Op Fl c Ar count -.Op Fl i Ar delay +.Op Fl i Ar wait .Op Fl S Ar source .Op Fl s Ar size .Sh DESCRIPTION @@ -63,8 +63,7 @@ If this option is not specified, .Nm will operate until interrupted. .It Fl f -.Dq Flood -ping, i.e., no delay between packets. +Don't wait between sending each packet. .It Fl h Display usage message and exit. .It Fl i Ar wait @@ -109,7 +108,7 @@ Some implementations may not like large .Xr ng_l2cap 4 , .Xr l2control 8 .Sh AUTHORS -.An Maksim Yevmenkin Aq m_evmenkin@yahoo.com +.An Maksim Yevmenkin Aq emax@FreeBSD.org .Sh BUGS Could collect more statistic. Could check for duplicated, corrupted and lost packets. Modified: head/usr.sbin/bluetooth/l2ping/l2ping.c ============================================================================== --- head/usr.sbin/bluetooth/l2ping/l2ping.c Mon Mar 28 22:50:02 2011 (r220115) +++ head/usr.sbin/bluetooth/l2ping/l2ping.c Mon Mar 28 23:08:18 2011 (r220116) @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -60,11 +61,11 @@ int main(int argc, char *argv[]) { bdaddr_t src, dst; - struct hostent *he = NULL; - uint8_t *echo_data = NULL; + struct hostent *he; + uint8_t *echo_data; struct sockaddr_l2cap sa; int32_t n, s, count, wait, flood, echo_size, numeric; - char *rname = NULL; + char *endp, *rname; /* Set defaults */ memcpy(&src, NG_HCI_BDADDR_ANY, sizeof(src)); @@ -100,8 +101,8 @@ main(int argc, char *argv[]) break; case 'c': - count = atoi(optarg); - if (count <= 0) + count = strtol(optarg, &endp, 10); + if (count <= 0 || *endp != '\0') usage(); break; @@ -110,8 +111,8 @@ main(int argc, char *argv[]) break; case 'i': - wait = atoi(optarg); - if (wait <= 0) + wait = strtol(optarg, &endp, 10); + if (wait <= 0 || *endp != '\0') usage(); break; @@ -129,9 +130,10 @@ main(int argc, char *argv[]) break; case 's': - echo_size = atoi(optarg); - if (echo_size < sizeof(int32_t) || - echo_size > NG_L2CAP_MAX_ECHO_SIZE) + echo_size = strtol(optarg, &endp, 10); + if (echo_size < sizeof(int32_t) || + echo_size > NG_L2CAP_MAX_ECHO_SIZE || + *endp != '\0') usage(); break; @@ -272,12 +274,12 @@ tv2msec(struct timeval const *tvp) static void usage(void) { - fprintf(stderr, "Usage: l2ping -a bd_addr " \ - "[-S bd_addr -c count -i wait -n -s size -h]\n"); + fprintf(stderr, "Usage: l2ping [-fhn] -a remote " \ + "[-c count] [-i wait] [-S source] [-s size]\n"); fprintf(stderr, "Where:\n"); fprintf(stderr, " -a remote Specify remote device to ping\n"); fprintf(stderr, " -c count Number of packets to send\n"); - fprintf(stderr, " -f No delay (sort of flood)\n"); + fprintf(stderr, " -f No delay between packets\n"); fprintf(stderr, " -h Display this message\n"); fprintf(stderr, " -i wait Delay between packets (sec)\n"); fprintf(stderr, " -n Numeric output only\n"); From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 23:12:38 2011 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2001:4f8:fff6::35]) by hub.freebsd.org (Postfix) with ESMTP id D0B9A1065672; Mon, 28 Mar 2011 23:12:38 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from 65-241-43-5.globalsuite.net (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx2.freebsd.org (Postfix) with ESMTP id EBA1014DF0A; Mon, 28 Mar 2011 23:12:37 +0000 (UTC) Message-ID: <4D9115E5.3040008@FreeBSD.org> Date: Mon, 28 Mar 2011 16:12:37 -0700 From: Doug Barton Organization: http://SupersetSolutions.com/ User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.15) Gecko/20110319 Thunderbird/3.1.9 MIME-Version: 1.0 To: Warner Losh References: <201103271657.p2RGvs2m063692@svn.freebsd.org> <4D8F7257.50207@FreeBSD.org> In-Reply-To: X-Enigmail-Version: 1.1.2 OpenPGP: id=1A1ABC84 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Josh Paetzel , svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, kib@FreeBSD.org Subject: Re: svn commit: r220059 - head/usr.sbin/pc-sysinstall/backend 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, 28 Mar 2011 23:12:38 -0000 On 03/27/2011 15:29, Warner Losh wrote: > > On Mar 27, 2011, at 11:22 AM, Doug Barton wrote: > >> On 03/27/2011 09:57, Josh Paetzel wrote: >>> Replace "$?" = "0" with $? -eq 0 in tests >> >> Excellent! > > Most of the time I've found that moving the command up to the if makes the code clearer too. At jobs I've had in the past when I've written code similar to what we have here, it almost always got flagged... In general I agree with you. I did take a look at the specific cases where the -eq 0 changes were made and IMO it's about 50/50 whether that would actually be an optimization, or if leaving it as is makes the code more readable. I chose to go with "focus on the positive." :) Doug -- Nothin' ever doesn't change, but nothin' changes much. -- OK Go Breadth of IT experience, and depth of knowledge in the DNS. Yours for the right price. :) http://SupersetSolutions.com/ From owner-svn-src-head@FreeBSD.ORG Mon Mar 28 23:22:55 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2001:4f8:fff6::35]) by hub.freebsd.org (Postfix) with ESMTP id 8E1361065679; Mon, 28 Mar 2011 23:22:55 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from 65-241-43-5.globalsuite.net (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx2.freebsd.org (Postfix) with ESMTP id ADF461A43D2; Mon, 28 Mar 2011 23:22:20 +0000 (UTC) Message-ID: <4D91182C.601@FreeBSD.org> Date: Mon, 28 Mar 2011 16:22:20 -0700 From: Doug Barton Organization: http://SupersetSolutions.com/ User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.15) Gecko/20110319 Thunderbird/3.1.9 MIME-Version: 1.0 To: Jeff Roberson References: <4D840BD0.4030306@freebsd.org> <201103200000.p2K00pue003373@chez.mckusick.com> <20110320162212.GI1606@alchemy.franken.de> <4D8662B0.8000705@FreeBSD.org> In-Reply-To: X-Enigmail-Version: 1.1.2 OpenPGP: id=1A1ABC84 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Tue, 29 Mar 2011 01:45:46 +0000 Cc: src-committers@freebsd.org, kvedulv@kvedulv.de, Jeff Roberson , Kirk McKusick , Gavin Atkinson , Nathan Whitehorn , Marius Strobl , svn-src-head@freebsd.org, svn-src-all@freebsd.org Subject: Re: svn commit: r219667 - 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: Mon, 28 Mar 2011 23:22:55 -0000 On 03/21/2011 00:33, Jeff Roberson wrote: > On Sun, 20 Mar 2011, Doug Barton wrote: > >> On 03/20/2011 09:22, Marius Strobl wrote: >> >>> I fear it's still a bit premature for enable SU+J by default. Rather >>> recently I was told about a SU+J filesystems lost after a panic >>> that happend after snapshotting it (report CC'ed, maybe he can >>> provide some more details) and I'm pretty sure I've seen the problem >>> described in PR 149022 also after the potential fix mentioned in its >>> feedback. >> >> +1 >> >> I tried enabling SU+J on my /var (after backing up of course) and >> after a panic random files were missing entirely. Not the last updates >> to those files, the whole file, and many of them had not been written >> to in days/weeks/months. >> > > So you're saying the directory entry was missing? I'm saying that the file wasn't visible to 'ls /var/db/pkg/foo/'. I didn't debug it past determining that the files were missing. > Can you tell me how big the directory was? Most of the damage was in /var/db/pkg/, so the individual directories that were missing files were small, no more than 10 files each. I imagine there was probably other damaged scattered throughout /var, but once I learned how many files were missing I just nuked it and restored from backup. > Number of files? I stopped counting around 20 or so. > Approximate directory size when > you consider file names? When you fsck'd were inodes recovered and > linked into lost and found? No. > What was the actual path? To the lost files? The ones that I actually noticed missing were all /var/db/pkg/*/+CONTENTS. There were probably a lot of other files missing, but those were noticeable because the ports tree was throwing errors, and a missing +CONTENTS file can't be recovered from without re-installing the port. > I'm trying to wrap my head around how this would be possible and where > the error could be and whether it could be caused by SUJ. It never happened before enabling SUJ, happened shortly after I did, and has never happened since I disabled it. It's probably worth reiterating that the damage happened after an actual panic, as opposed to during "regular" operation. > The number of > interactions with disk writes are minimal. Corruption if it occurs would > most likely be caused by a bad journal recovery. Unlikely in this case, since the damage was not confined to recently-written files. hth, Doug PS, my primary concern was that we not enable this by default until it can be demonstrated to be more robust. However Nathan has already enabled it in the new installer, so now perhaps it would be fitting to send a message to -current letting people know that the plan is to have it on by default in 9.0, and asking people to resume more rigorous testing. -- Nothin' ever doesn't change, but nothin' changes much. -- OK Go Breadth of IT experience, and depth of knowledge in the DNS. Yours for the right price. :) http://SupersetSolutions.com/ From owner-svn-src-head@FreeBSD.ORG Tue Mar 29 06:42: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 65FDA106564A; Tue, 29 Mar 2011 06:42: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 555638FC14; Tue, 29 Mar 2011 06:42:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2T6gqiJ019643; Tue, 29 Mar 2011 06:42:52 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2T6gqve019641; Tue, 29 Mar 2011 06:42:52 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201103290642.p2T6gqve019641@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Tue, 29 Mar 2011 06:42: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: r220124 - head/sys/modules/ipfw 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, 29 Mar 2011 06:42:53 -0000 Author: ae Date: Tue Mar 29 06:42:52 2011 New Revision: 220124 URL: http://svn.freebsd.org/changeset/base/220124 Log: Do not build ip_fw_nat.c for ipfw.ko. It can be build as separate module. MFC after: 1 week Modified: head/sys/modules/ipfw/Makefile Modified: head/sys/modules/ipfw/Makefile ============================================================================== --- head/sys/modules/ipfw/Makefile Tue Mar 29 05:58:09 2011 (r220123) +++ head/sys/modules/ipfw/Makefile Tue Mar 29 06:42:52 2011 (r220124) @@ -6,7 +6,7 @@ KMOD= ipfw SRCS= ip_fw2.c ip_fw_pfil.c -SRCS+= ip_fw_dynamic.c ip_fw_log.c ip_fw_nat.c +SRCS+= ip_fw_dynamic.c ip_fw_log.c SRCS+= ip_fw_sockopt.c ip_fw_table.c SRCS+= opt_inet6.h opt_ipsec.h From owner-svn-src-head@FreeBSD.ORG Tue Mar 29 12:38: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 AE6B1106566C; Tue, 29 Mar 2011 12:38:13 +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 9DE9D8FC16; Tue, 29 Mar 2011 12:38:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2TCcDPS028657; Tue, 29 Mar 2011 12:38:13 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2TCcDDB028655; Tue, 29 Mar 2011 12:38:13 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201103291238.p2TCcDDB028655@svn.freebsd.org> From: John Baldwin Date: Tue, 29 Mar 2011 12:38: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: r220126 - head/sys/isa 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, 29 Mar 2011 12:38:13 -0000 Author: jhb Date: Tue Mar 29 12:38:13 2011 New Revision: 220126 URL: http://svn.freebsd.org/changeset/base/220126 Log: - Enable an extra debugging bootverbose printf when probing ISA PNP cards listing each card as it is found on non-PC98 (PC98 already had this). - Increase the length of the DELAY() used before timing out while reading PNP resource data. Tested by: Steven Nikkel steven_nikkel ertyu org MFC after: 1 week Modified: head/sys/isa/pnp.c Modified: head/sys/isa/pnp.c ============================================================================== --- head/sys/isa/pnp.c Tue Mar 29 11:54:22 2011 (r220125) +++ head/sys/isa/pnp.c Tue Mar 29 12:38:13 2011 (r220126) @@ -209,7 +209,7 @@ pnp_get_resource_info(u_char *buffer, in for (j = 0; j < 100; j++) { if ((inb((pnp_rd_port << 2) | 0x3)) & 0x1) break; - DELAY(1); + DELAY(10); } if (j == 100) { printf("PnP device failed to report resource data\n"); @@ -743,10 +743,10 @@ pnp_isolation_protocol(device_t parent) printf("A Normal-ISA-PnP card (%s).\n", pnp_eisaformat(id.vendor_id)); } +#endif if (bootverbose) printf("Reading PnP configuration for %s.\n", pnp_eisaformat(id.vendor_id)); -#endif error = pnp_read_resources(&resources, &space, &len); if (error) break; From owner-svn-src-head@FreeBSD.ORG Tue Mar 29 15:59: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 CC0A01065670; Tue, 29 Mar 2011 15:59:07 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A05218FC13; Tue, 29 Mar 2011 15:59:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2TFx7sE033270; Tue, 29 Mar 2011 15:59:07 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2TFx7Iv033266; Tue, 29 Mar 2011 15:59:07 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103291559.p2TFx7Iv033266@svn.freebsd.org> From: Adrian Chadd Date: Tue, 29 Mar 2011 15:59: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: r220132 - head/sys/dev/ath 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, 29 Mar 2011 15:59:07 -0000 Author: adrian Date: Tue Mar 29 15:59:07 2011 New Revision: 220132 URL: http://svn.freebsd.org/changeset/base/220132 Log: According to ath9k recv.c, one shouldn't be doing self-linked descriptors in the RX path when doing 11n and block-ack'ed frames. Apparently, the MAC will loop over that self-linked descriptor and treat it as "good enough" for (incorrectly!) ACKing the frames in the block-ack. Until I figure out how to work around this issue in the future, this counter will tell me if packet RX processing ever gets to the point where it's touching the self-linked descriptor. If there's ever enough packets to get to that point, BA's will be invalid and likely very unhappy. Modified: head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_ath_sysctl.c head/sys/dev/ath/if_athioctl.h Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Tue Mar 29 15:36:43 2011 (r220131) +++ head/sys/dev/ath/if_ath.c Tue Mar 29 15:59:07 2011 (r220132) @@ -3338,6 +3338,7 @@ ath_rx_proc(void *arg, int npending) ds = bf->bf_desc; if (ds->ds_link == bf->bf_daddr) { /* NB: never process the self-linked entry at the end */ + sc->sc_stats.ast_rx_hitqueueend++; break; } /* XXX sync descriptor memory */ Modified: head/sys/dev/ath/if_ath_sysctl.c ============================================================================== --- head/sys/dev/ath/if_ath_sysctl.c Tue Mar 29 15:36:43 2011 (r220131) +++ head/sys/dev/ath/if_ath_sysctl.c Tue Mar 29 15:59:07 2011 (r220132) @@ -703,6 +703,8 @@ ath_sysctl_stats_attach(struct ath_softc &sc->sc_stats.ast_rx_hi_rx_chain, 0, ""); SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_htprotect", CTLFLAG_RD, &sc->sc_stats.ast_tx_htprotect, 0, "HT tx frames with protection"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_hitqueueend", CTLFLAG_RD, + &sc->sc_stats.ast_rx_hitqueueend, 0, "RX hit queue end"); /* Attach the RX phy error array */ ath_sysctl_stats_attach_rxphyerr(sc, child); Modified: head/sys/dev/ath/if_athioctl.h ============================================================================== --- head/sys/dev/ath/if_athioctl.h Tue Mar 29 15:36:43 2011 (r220131) +++ head/sys/dev/ath/if_athioctl.h Tue Mar 29 15:59:07 2011 (r220132) @@ -128,7 +128,8 @@ struct ath_stats { u_int32_t ast_rx_decrypt_busy_err; u_int32_t ast_rx_hi_rx_chain; u_int32_t ast_tx_htprotect; /* HT tx frames with protection */ - u_int32_t ast_pad[3]; + u_int32_t ast_rx_hitqueueend; + u_int32_t ast_pad[2]; }; #define SIOCGATHSTATS _IOWR('i', 137, struct ifreq) From owner-svn-src-head@FreeBSD.ORG Tue Mar 29 17:47: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 DF2171065672; Tue, 29 Mar 2011 17:47:25 +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 CB2E38FC08; Tue, 29 Mar 2011 17:47:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2THlPwr035889; Tue, 29 Mar 2011 17:47:25 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2THlPDa035877; Tue, 29 Mar 2011 17:47:25 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103291747.p2THlPDa035877@svn.freebsd.org> From: Edward Tomasz Napierala Date: Tue, 29 Mar 2011 17:47: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: r220137 - in head: . sys/amd64/conf sys/conf sys/kern 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: Tue, 29 Mar 2011 17:47:26 -0000 Author: trasz Date: Tue Mar 29 17:47:25 2011 New Revision: 220137 URL: http://svn.freebsd.org/changeset/base/220137 Log: Add racct. It's an API to keep per-process, per-jail, per-loginclass and per-loginclass resource accounting information, to be used by the new resource limits code. It's connected to the build, but the code that actually calls the new functions will come later. Sponsored by: The FreeBSD Foundation Reviewed by: kib (earlier version) Added: head/kern_racct.c (contents, props changed) head/sys/kern/kern_racct.c (contents, props changed) head/sys/sys/racct.h (contents, props changed) Modified: head/sys/amd64/conf/GENERIC head/sys/conf/NOTES head/sys/conf/files head/sys/conf/options head/sys/kern/init_main.c head/sys/kern/kern_exit.c head/sys/kern/kern_fork.c head/sys/kern/kern_jail.c head/sys/kern/kern_loginclass.c head/sys/kern/kern_resource.c head/sys/sys/jail.h head/sys/sys/kernel.h head/sys/sys/loginclass.h head/sys/sys/proc.h head/sys/sys/resourcevar.h Added: head/kern_racct.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/kern_racct.c Tue Mar 29 17:47:25 2011 (r220137) @@ -0,0 +1,842 @@ +/*- + * Copyright (c) 2010 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Edward Tomasz Napierala under sponsorship + * from the FreeBSD Foundation. + * + * 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 +__FBSDID("$FreeBSD$"); + +#include "opt_kdtrace.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef RCTL +#include +#endif + +#ifdef RACCT + +FEATURE(racct, "Resource Accounting"); + +static struct mtx racct_lock; +MTX_SYSINIT(racct_lock, &racct_lock, "racct lock", MTX_DEF); + +static uma_zone_t racct_zone; + +static void racct_sub_racct(struct racct *dest, const struct racct *src); +static void racct_sub_cred_locked(struct ucred *cred, int resource, + uint64_t amount); +static void racct_add_cred_locked(struct ucred *cred, int resource, + uint64_t amount); + +SDT_PROVIDER_DEFINE(racct); +SDT_PROBE_DEFINE3(racct, kernel, rusage, add, add, "struct proc *", "int", + "uint64_t"); +SDT_PROBE_DEFINE3(racct, kernel, rusage, add_failure, add-failure, + "struct proc *", "int", "uint64_t"); +SDT_PROBE_DEFINE3(racct, kernel, rusage, add_cred, add-cred, "struct ucred *", + "int", "uint64_t"); +SDT_PROBE_DEFINE3(racct, kernel, rusage, add_force, add-force, "struct proc *", + "int", "uint64_t"); +SDT_PROBE_DEFINE3(racct, kernel, rusage, set, set, "struct proc *", "int", + "uint64_t"); +SDT_PROBE_DEFINE3(racct, kernel, rusage, set_failure, set-failure, + "struct proc *", "int", "uint64_t"); +SDT_PROBE_DEFINE3(racct, kernel, rusage, sub, sub, "struct proc *", "int", + "uint64_t"); +SDT_PROBE_DEFINE3(racct, kernel, rusage, sub_cred, sub-cred, "struct ucred *", + "int", "uint64_t"); +SDT_PROBE_DEFINE1(racct, kernel, racct, create, create, "struct racct *"); +SDT_PROBE_DEFINE1(racct, kernel, racct, destroy, destroy, "struct racct *"); +SDT_PROBE_DEFINE2(racct, kernel, racct, join, join, "struct racct *", + "struct racct *"); +SDT_PROBE_DEFINE2(racct, kernel, racct, join_failure, join-failure, + "struct racct *", "struct racct *"); +SDT_PROBE_DEFINE2(racct, kernel, racct, leave, leave, "struct racct *", + "struct racct *"); + +int racct_types[] = { + [RACCT_CPU] = + RACCT_IN_THOUSANDS, + [RACCT_FSIZE] = + RACCT_RECLAIMABLE | RACCT_INHERITABLE | RACCT_DENIABLE, + [RACCT_DATA] = + RACCT_RECLAIMABLE | RACCT_INHERITABLE | RACCT_DENIABLE, + [RACCT_STACK] = + RACCT_RECLAIMABLE | RACCT_INHERITABLE | RACCT_DENIABLE, + [RACCT_CORE] = + RACCT_DENIABLE, + [RACCT_RSS] = + RACCT_RECLAIMABLE, + [RACCT_MEMLOCK] = + RACCT_RECLAIMABLE | RACCT_DENIABLE, + [RACCT_NPROC] = + RACCT_RECLAIMABLE | RACCT_DENIABLE, + [RACCT_NOFILE] = + RACCT_RECLAIMABLE | RACCT_INHERITABLE | RACCT_DENIABLE, + [RACCT_SBSIZE] = + RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, + [RACCT_VMEM] = + RACCT_RECLAIMABLE | RACCT_INHERITABLE | RACCT_DENIABLE, + [RACCT_NPTS] = + RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, + [RACCT_SWAP] = + RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, + [RACCT_NTHR] = + RACCT_RECLAIMABLE | RACCT_DENIABLE, + [RACCT_MSGQQUEUED] = + RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, + [RACCT_MSGQSIZE] = + RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, + [RACCT_NMSGQ] = + RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, + [RACCT_NSEM] = + RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, + [RACCT_NSEMOP] = + RACCT_RECLAIMABLE | RACCT_INHERITABLE | RACCT_DENIABLE, + [RACCT_NSHM] = + RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, + [RACCT_SHMSIZE] = + RACCT_RECLAIMABLE | RACCT_DENIABLE | RACCT_SLOPPY, + [RACCT_WALLCLOCK] = + RACCT_IN_THOUSANDS }; + +static void +racct_add_racct(struct racct *dest, const struct racct *src) +{ + int i; + + mtx_assert(&racct_lock, MA_OWNED); + + /* + * Update resource usage in dest. + */ + for (i = 0; i <= RACCT_MAX; i++) { + KASSERT(dest->r_resources[i] >= 0, + ("racct propagation meltdown: dest < 0")); + KASSERT(src->r_resources[i] >= 0, + ("racct propagation meltdown: src < 0")); + dest->r_resources[i] += src->r_resources[i]; + } +} + +static void +racct_sub_racct(struct racct *dest, const struct racct *src) +{ + int i; + + mtx_assert(&racct_lock, MA_OWNED); + + /* + * Update resource usage in dest. + */ + for (i = 0; i <= RACCT_MAX; i++) { + if (!racct_is_sloppy(i) && + !racct_is_dampened(i)) { + KASSERT(dest->r_resources[i] >= 0, + ("racct propagation meltdown: dest < 0")); + KASSERT(src->r_resources[i] >= 0, + ("racct propagation meltdown: src < 0")); + KASSERT(src->r_resources[i] <= dest->r_resources[i], + ("racct propagation meltdown: src > dest")); + } + if (racct_is_reclaimable(i)) { + dest->r_resources[i] -= src->r_resources[i]; + if (dest->r_resources[i] < 0) { + KASSERT(racct_is_sloppy(i) || + racct_is_dampened(i), + ("racct_sub_racct: usage < 0")); + dest->r_resources[i] = 0; + } + } + } +} + +void +racct_create(struct racct **racctp) +{ + + SDT_PROBE(racct, kernel, racct, create, racctp, 0, 0, 0, 0); + + KASSERT(*racctp == NULL, ("racct already allocated")); + + *racctp = uma_zalloc(racct_zone, M_WAITOK | M_ZERO); +} + +static void +racct_destroy_locked(struct racct **racctp) +{ + int i; + struct racct *racct; + + SDT_PROBE(racct, kernel, racct, destroy, racctp, 0, 0, 0, 0); + + mtx_assert(&racct_lock, MA_OWNED); + KASSERT(racctp != NULL, ("NULL racctp")); + KASSERT(*racctp != NULL, ("NULL racct")); + + racct = *racctp; + + for (i = 0; i <= RACCT_MAX; i++) { + if (racct_is_sloppy(i)) + continue; + if (!racct_is_reclaimable(i)) + continue; + if (racct_is_dampened(i)) + continue; + KASSERT(racct->r_resources[i] == 0, + ("destroying non-empty racct: " + "%ju allocated for resource %d\n", + racct->r_resources[i], i)); + } + uma_zfree(racct_zone, racct); + *racctp = NULL; +} + +void +racct_destroy(struct racct **racct) +{ + + mtx_lock(&racct_lock); + racct_destroy_locked(racct); + mtx_unlock(&racct_lock); +} + +/* + * Increase consumption of 'resource' by 'amount' for 'racct' + * and all its parents. Differently from other cases, 'amount' here + * may be less than zero. + */ +static void +racct_alloc_resource(struct racct *racct, int resource, + uint64_t amount) +{ + + mtx_assert(&racct_lock, MA_OWNED); + KASSERT(racct != NULL, ("NULL racct")); + + racct->r_resources[resource] += amount; + if (racct->r_resources[resource] < 0) { + KASSERT(racct_is_sloppy(resource) || + racct_is_dampened(resource), + ("racct_alloc_resource: usage < 0")); + racct->r_resources[resource] = 0; + } +} + +/* + * Increase allocation of 'resource' by 'amount' for process 'p'. + * Return 0 if it's below limits, or errno, if it's not. + */ +int +racct_add(struct proc *p, int resource, uint64_t amount) +{ +#ifdef RCTL + int error; +#endif + + if (p->p_flag & P_SYSTEM) + return (0); + + SDT_PROBE(racct, kernel, rusage, add, p, resource, amount, 0, 0); + + /* + * We need proc lock to dereference p->p_ucred. + */ + PROC_LOCK_ASSERT(p, MA_OWNED); + KASSERT(amount >= 0, ("racct_add: invalid amount for resource %d: %ju", + resource, amount)); + + mtx_lock(&racct_lock); +#ifdef RCTL + error = rctl_enforce(p, resource, amount); + if (error && racct_is_deniable(resource)) { + SDT_PROBE(racct, kernel, rusage, add_failure, p, resource, + amount, 0, 0); + mtx_unlock(&racct_lock); + return (error); + } +#endif + racct_alloc_resource(p->p_racct, resource, amount); + racct_add_cred_locked(p->p_ucred, resource, amount); + mtx_unlock(&racct_lock); + + return (0); +} + +static void +racct_add_cred_locked(struct ucred *cred, int resource, uint64_t amount) +{ + struct prison *pr; + + SDT_PROBE(racct, kernel, rusage, add_cred, cred, resource, amount, + 0, 0); + + KASSERT(amount >= 0, + ("racct_add_cred: invalid amount for resource %d: %ju", + resource, amount)); + + racct_alloc_resource(cred->cr_ruidinfo->ui_racct, resource, amount); + for (pr = cred->cr_prison; pr != NULL; pr = pr->pr_parent) + racct_alloc_resource(pr->pr_racct, resource, amount); + racct_alloc_resource(cred->cr_loginclass->lc_racct, resource, amount); +} + +/* + * Increase allocation of 'resource' by 'amount' for credential 'cred'. + * Doesn't check for limits and never fails. + * + * XXX: Shouldn't this ever return an error? + */ +void +racct_add_cred(struct ucred *cred, int resource, uint64_t amount) +{ + + mtx_lock(&racct_lock); + racct_add_cred_locked(cred, resource, amount); + mtx_unlock(&racct_lock); +} + +/* + * Increase allocation of 'resource' by 'amount' for process 'p'. + * Doesn't check for limits and never fails. + */ +void +racct_add_force(struct proc *p, int resource, uint64_t amount) +{ + + if (p->p_flag & P_SYSTEM) + return; + + SDT_PROBE(racct, kernel, rusage, add_force, p, resource, amount, 0, 0); + + /* + * We need proc lock to dereference p->p_ucred. + */ + PROC_LOCK_ASSERT(p, MA_OWNED); + KASSERT(amount >= 0, + ("racct_add_force: invalid amount for resource %d: %ju", + resource, amount)); + + mtx_lock(&racct_lock); + racct_alloc_resource(p->p_racct, resource, amount); + mtx_unlock(&racct_lock); + racct_add_cred(p->p_ucred, resource, amount); +} + +static int +racct_set_locked(struct proc *p, int resource, uint64_t amount) +{ + int64_t diff; +#ifdef RCTL + int error; +#endif + + if (p->p_flag & P_SYSTEM) + return (0); + + SDT_PROBE(racct, kernel, rusage, set, p, resource, amount, 0, 0); + + /* + * We need proc lock to dereference p->p_ucred. + */ + PROC_LOCK_ASSERT(p, MA_OWNED); + KASSERT(amount >= 0, ("racct_set: invalid amount for resource %d: %ju", + resource, amount)); + + diff = amount - p->p_racct->r_resources[resource]; +#ifdef notyet + 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)) { + SDT_PROBE(racct, kernel, rusage, set_failure, p, + resource, amount, 0, 0); + return (error); + } + } +#endif + racct_alloc_resource(p->p_racct, resource, diff); + if (diff > 0) + racct_add_cred_locked(p->p_ucred, resource, diff); + else if (diff < 0) + racct_sub_cred_locked(p->p_ucred, resource, -diff); + + return (0); +} + +/* + * Set allocation of 'resource' to 'amount' for process 'p'. + * Return 0 if it's below limits, or errno, if it's not. + * + * Note that decreasing the allocation always returns 0, + * even if it's above the limit. + */ +int +racct_set(struct proc *p, int resource, uint64_t amount) +{ + int error; + + mtx_lock(&racct_lock); + error = racct_set_locked(p, resource, amount); + mtx_unlock(&racct_lock); + return (error); +} + +void +racct_set_force(struct proc *p, int resource, uint64_t amount) +{ + int64_t diff; + + if (p->p_flag & P_SYSTEM) + return; + + SDT_PROBE(racct, kernel, rusage, set, p, resource, amount, 0, 0); + + /* + * We need proc lock to dereference p->p_ucred. + */ + PROC_LOCK_ASSERT(p, MA_OWNED); + KASSERT(amount >= 0, + ("racct_set_force: invalid amount for resource %d: %ju", + resource, amount)); + + mtx_lock(&racct_lock); + diff = amount - p->p_racct->r_resources[resource]; + racct_alloc_resource(p->p_racct, resource, diff); + if (diff > 0) + racct_add_cred_locked(p->p_ucred, resource, diff); + else if (diff < 0) + racct_sub_cred_locked(p->p_ucred, resource, -diff); + mtx_unlock(&racct_lock); +} + +/* + * Returns amount of 'resource' the process 'p' can keep allocated. + * Allocating more than that would be denied, unless the resource + * is marked undeniable. Amount of already allocated resource does + * not matter. + */ +uint64_t +racct_get_limit(struct proc *p, int resource) +{ + +#ifdef RCTL + return (rctl_get_limit(p, resource)); +#else + return (UINT64_MAX); +#endif +} + +/* + * Returns amount of 'resource' the process 'p' can keep allocated. + * Allocating more than that would be denied, unless the resource + * is marked undeniable. Amount of already allocated resource does + * matter. + */ +uint64_t +racct_get_available(struct proc *p, int resource) +{ + +#ifdef RCTL + return (rctl_get_available(p, resource)); +#else + return (UINT64_MAX); +#endif +} + +/* + * Decrease allocation of 'resource' by 'amount' for process 'p'. + */ +void +racct_sub(struct proc *p, int resource, uint64_t amount) +{ + + if (p->p_flag & P_SYSTEM) + return; + + SDT_PROBE(racct, kernel, rusage, sub, p, resource, amount, 0, 0); + + /* + * We need proc lock to dereference p->p_ucred. + */ + PROC_LOCK_ASSERT(p, MA_OWNED); + KASSERT(amount >= 0, ("racct_sub: invalid amount for resource %d: %ju", + resource, amount)); + KASSERT(racct_is_reclaimable(resource), + ("racct_sub: called for non-reclaimable resource %d", resource)); + + mtx_lock(&racct_lock); + KASSERT(amount <= p->p_racct->r_resources[resource], + ("racct_sub: freeing %ju of resource %d, which is more " + "than allocated %jd for %s (pid %d)", amount, resource, + (intmax_t)p->p_racct->r_resources[resource], p->p_comm, p->p_pid)); + + racct_alloc_resource(p->p_racct, resource, -amount); + racct_sub_cred_locked(p->p_ucred, resource, amount); + mtx_unlock(&racct_lock); +} + +static void +racct_sub_cred_locked(struct ucred *cred, int resource, uint64_t amount) +{ + struct prison *pr; + + SDT_PROBE(racct, kernel, rusage, sub_cred, cred, resource, amount, + 0, 0); + + KASSERT(amount >= 0, + ("racct_sub_cred: invalid amount for resource %d: %ju", + resource, amount)); +#ifdef notyet + KASSERT(racct_is_reclaimable(resource), + ("racct_sub_cred: called for non-reclaimable resource %d", + resource)); +#endif + + racct_alloc_resource(cred->cr_ruidinfo->ui_racct, resource, -amount); + for (pr = cred->cr_prison; pr != NULL; pr = pr->pr_parent) + racct_alloc_resource(pr->pr_racct, resource, -amount); + racct_alloc_resource(cred->cr_loginclass->lc_racct, resource, -amount); +} + +/* + * Decrease allocation of 'resource' by 'amount' for credential 'cred'. + */ +void +racct_sub_cred(struct ucred *cred, int resource, uint64_t amount) +{ + + mtx_lock(&racct_lock); + racct_sub_cred_locked(cred, resource, amount); + mtx_unlock(&racct_lock); +} + +/* + * Inherit resource usage information from the parent process. + */ +int +racct_proc_fork(struct proc *parent, struct proc *child) +{ + int i, error = 0; + + /* + * Create racct for the child process. + */ + racct_create(&child->p_racct); + + /* + * No resource accounting for kernel processes. + */ + if (child->p_flag & P_SYSTEM) + return (0); + + PROC_LOCK(parent); + PROC_LOCK(child); + mtx_lock(&racct_lock); + + /* + * Inherit resource usage. + */ + for (i = 0; i <= RACCT_MAX; i++) { + if (parent->p_racct->r_resources[i] == 0 || + !racct_is_inheritable(i)) + continue; + + error = racct_set_locked(child, i, + parent->p_racct->r_resources[i]); + if (error != 0) { + /* + * XXX: The only purpose of these two lines is + * to prevent from tripping checks in racct_destroy(). + */ + for (i = 0; i <= RACCT_MAX; i++) + racct_set_locked(child, i, 0); + goto out; + } + } + +#ifdef RCTL + error = rctl_proc_fork(parent, child); + if (error != 0) { + /* + * XXX: The only purpose of these two lines is to prevent from + * tripping checks in racct_destroy(). + */ + for (i = 0; i <= RACCT_MAX; i++) + racct_set_locked(child, i, 0); + } +#endif + +out: + if (error != 0) + racct_destroy_locked(&child->p_racct); + mtx_unlock(&racct_lock); + PROC_UNLOCK(child); + PROC_UNLOCK(parent); + + return (error); +} + +void +racct_proc_exit(struct proc *p) +{ + uint64_t runtime; + + PROC_LOCK(p); + /* + * We don't need to calculate rux, proc_reap() has already done this. + */ + runtime = cputick2usec(p->p_rux.rux_runtime); +#ifdef notyet + KASSERT(runtime >= p->p_prev_runtime, ("runtime < p_prev_runtime")); +#else + if (runtime < p->p_prev_runtime) + runtime = p->p_prev_runtime; +#endif + racct_set(p, RACCT_CPU, runtime); + + /* + * XXX: Free this some other way. + */ + racct_set(p, RACCT_FSIZE, 0); + racct_set(p, RACCT_NPTS, 0); + racct_set(p, RACCT_NTHR, 0); + racct_set(p, RACCT_RSS, 0); + PROC_UNLOCK(p); + +#ifdef RCTL + rctl_racct_release(p->p_racct); +#endif + racct_destroy(&p->p_racct); +} + +/* + * Called after credentials change, to move resource utilisation + * between raccts. + */ +void +racct_proc_ucred_changed(struct proc *p, struct ucred *oldcred, + struct ucred *newcred) +{ + struct uidinfo *olduip, *newuip; + struct loginclass *oldlc, *newlc; + struct prison *oldpr, *newpr, *pr; + + PROC_LOCK_ASSERT(p, MA_NOTOWNED); + + newuip = newcred->cr_ruidinfo; + olduip = oldcred->cr_ruidinfo; + newlc = newcred->cr_loginclass; + oldlc = oldcred->cr_loginclass; + newpr = newcred->cr_prison; + oldpr = oldcred->cr_prison; + + mtx_lock(&racct_lock); + if (newuip != olduip) { + racct_sub_racct(olduip->ui_racct, p->p_racct); + racct_add_racct(newuip->ui_racct, p->p_racct); + } + if (newlc != oldlc) { + racct_sub_racct(oldlc->lc_racct, p->p_racct); + racct_add_racct(newlc->lc_racct, p->p_racct); + } + if (newpr != oldpr) { + for (pr = oldpr; pr != NULL; pr = pr->pr_parent) + racct_sub_racct(pr->pr_racct, p->p_racct); + for (pr = newpr; pr != NULL; pr = pr->pr_parent) + racct_add_racct(pr->pr_racct, p->p_racct); + } + mtx_unlock(&racct_lock); + +#ifdef RCTL + rctl_proc_ucred_changed(p, newcred); +#endif +} + +static void +racctd(void) +{ + struct thread *td; + struct proc *p; + struct timeval wallclock; + uint64_t runtime; + + for (;;) { + sx_slock(&allproc_lock); + + FOREACH_PROC_IN_SYSTEM(p) { + if (p->p_state != PRS_NORMAL) + continue; + if (p->p_flag & P_SYSTEM) + continue; + + microuptime(&wallclock); + timevalsub(&wallclock, &p->p_stats->p_start); + PROC_LOCK(p); + PROC_SLOCK(p); + FOREACH_THREAD_IN_PROC(p, td) { + ruxagg(p, td); + thread_lock(td); + thread_unlock(td); + } + runtime = cputick2usec(p->p_rux.rux_runtime); + PROC_SUNLOCK(p); +#ifdef notyet + KASSERT(runtime >= p->p_prev_runtime, + ("runtime < p_prev_runtime")); +#else + if (runtime < p->p_prev_runtime) + runtime = p->p_prev_runtime; +#endif + p->p_prev_runtime = runtime; + mtx_lock(&racct_lock); + racct_set_locked(p, RACCT_CPU, runtime); + racct_set_locked(p, RACCT_WALLCLOCK, + wallclock.tv_sec * 1000000 + wallclock.tv_usec); + mtx_unlock(&racct_lock); + PROC_UNLOCK(p); + } + sx_sunlock(&allproc_lock); + pause("-", hz); + } +} + +static struct kproc_desc racctd_kp = { + "racctd", + racctd, + NULL +}; +SYSINIT(racctd, SI_SUB_RACCTD, SI_ORDER_FIRST, kproc_start, &racctd_kp); + +static void +racct_init(void) +{ + + racct_zone = uma_zcreate("racct", sizeof(struct racct), + NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); + /* + * XXX: Move this somewhere. + */ + racct_create(&prison0.pr_racct); +} +SYSINIT(racct, SI_SUB_RACCT, SI_ORDER_FIRST, racct_init, NULL); + +#else /* !RACCT */ + +int +racct_add(struct proc *p, int resource, uint64_t amount) +{ + + return (0); +} + +void +racct_add_cred(struct ucred *cred, int resource, uint64_t amount) +{ +} + +void +racct_add_force(struct proc *p, int resource, uint64_t amount) +{ + + return (0); +} + +int +racct_set(struct proc *p, int resource, uint64_t amount) +{ + + return (0); +} + +void +racct_sub(struct proc *p, int resource, uint64_t amount) +{ +} + +void +racct_sub_cred(struct ucred *cred, int resource, uint64_t amount) +{ +} + +uint64_t +racct_get_limit(struct proc *p, int resource) +{ + + return (UINT64_MAX); +} + +void +racct_create(struct racct **racctp) +{ +} + +void +racct_destroy(struct racct **racctp) +{ +} + +int +racct_proc_fork(struct proc *parent, struct proc *child) +{ + + return (0); +} + +void +racct_proc_exit(struct proc *p) +{ +} + +#endif /* !RACCT */ Modified: head/sys/amd64/conf/GENERIC ============================================================================== --- head/sys/amd64/conf/GENERIC Tue Mar 29 16:49:50 2011 (r220136) +++ head/sys/amd64/conf/GENERIC Tue Mar 29 17:47:25 2011 (r220137) @@ -65,6 +65,8 @@ options MAC # TrustedBSD MAC Framewor #options KDTRACE_HOOKS # Kernel DTrace hooks options INCLUDE_CONFIG_FILE # Include this file in kernel +options RACCT + # Debugging for use in -current options KDB # Enable kernel debugger support. options DDB # Support DDB. Modified: head/sys/conf/NOTES ============================================================================== --- head/sys/conf/NOTES Tue Mar 29 16:49:50 2011 (r220136) +++ head/sys/conf/NOTES Tue Mar 29 17:47:25 2011 (r220137) @@ -2930,6 +2930,9 @@ options AAC_DEBUG # Debugging levels: # 2 - extremely noisy, emit trace # items in loops, etc. +# Resource Accounting +options RACCT + # Yet more undocumented options for linting. # BKTR_ALLOC_PAGES has no effect except to cause warnings, and # BROOKTREE_ALLOC_PAGES hasn't actually been superseded by it, since the Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Tue Mar 29 16:49:50 2011 (r220136) +++ head/sys/conf/files Tue Mar 29 17:47:25 2011 (r220137) @@ -2225,6 +2225,7 @@ kern/kern_poll.c optional device_pollin kern/kern_priv.c standard kern/kern_proc.c standard kern/kern_prot.c standard +kern/kern_racct.c standard kern/kern_resource.c standard kern/kern_rmlock.c standard kern/kern_rwlock.c standard Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Tue Mar 29 16:49:50 2011 (r220136) +++ head/sys/conf/options Tue Mar 29 17:47:25 2011 (r220137) @@ -873,6 +873,9 @@ SDP_DEBUG opt_ofed.h IPOIB_DEBUG opt_ofed.h IPOIB_CM opt_ofed.h +# Resource Accounting +RACCT opt_global.h + # At least one of the AR71XX ubiquiti boards has a Redboot configuration # that "lies" about the amount of RAM it has. Until a cleaner method is # defined, this option will suffice in overriding what Redboot says. Modified: head/sys/kern/init_main.c ============================================================================== --- head/sys/kern/init_main.c Tue Mar 29 16:49:50 2011 (r220136) +++ head/sys/kern/init_main.c Tue Mar 29 17:47:25 2011 (r220137) @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -526,6 +527,9 @@ proc0_init(void *dummy __unused) p->p_limit->pl_rlimit[RLIMIT_MEMLOCK].rlim_max = pageablemem; p->p_cpulimit = RLIM_INFINITY; + /* Initialize resource accounting structures. */ + racct_create(&p->p_racct); + p->p_stats = pstats_alloc(); /* Allocate a prototype map so we have something to fork. */ Modified: head/sys/kern/kern_exit.c ============================================================================== --- head/sys/kern/kern_exit.c Tue Mar 29 16:49:50 2011 (r220136) +++ head/sys/kern/kern_exit.c Tue Mar 29 17:47:25 2011 (r220137) @@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -741,6 +742,11 @@ proc_reap(struct thread *td, struct proc (void)chgproccnt(p->p_ucred->cr_ruidinfo, -1, 0); /* + * Destroy resource accounting information associated with the process. + */ + racct_proc_exit(p); + + /* * Free credentials, arguments, and sigacts. */ crfree(p->p_ucred); Modified: head/sys/kern/kern_fork.c ============================================================================== --- head/sys/kern/kern_fork.c Tue Mar 29 16:49:50 2011 (r220136) +++ head/sys/kern/kern_fork.c Tue Mar 29 17:47:25 2011 (r220137) @@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -783,6 +784,21 @@ fork1(struct thread *td, int flags, int knlist_init_mtx(&newproc->p_klist, &newproc->p_mtx); STAILQ_INIT(&newproc->p_ktr); + /* + * XXX: This is ugly; when we copy resource usage, we need to bump + * per-cred resource counters. + */ + newproc->p_ucred = p1->p_ucred; + + /* + * Initialize resource accounting for the child process. + */ + error = racct_proc_fork(p1, newproc); + if (error != 0) { + error = EAGAIN; + goto fail1; + } + /* We have to lock the process tree while we look for a pid. */ sx_slock(&proctree_lock); @@ -827,6 +843,7 @@ fork1(struct thread *td, int flags, int error = EAGAIN; fail: + racct_proc_exit(newproc); sx_sunlock(&proctree_lock); if (ppsratecheck(&lastfail, &curfail, 1)) printf("maxproc limit exceeded by uid %i, please see tuning(7) and login.conf(5).\n", Modified: head/sys/kern/kern_jail.c ============================================================================== --- head/sys/kern/kern_jail.c Tue Mar 29 16:49:50 2011 (r220136) +++ head/sys/kern/kern_jail.c Tue Mar 29 17:47:25 2011 (r220137) @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1195,6 +1196,7 @@ kern_jail_set(struct thread *td, struct root = mypr->pr_root; vref(root); } + racct_create(&pr->pr_racct); strlcpy(pr->pr_hostuuid, DEFAULT_HOSTUUID, HOSTUUIDLEN); pr->pr_flags |= PR_HOST; #if defined(INET) || defined(INET6) @@ -2295,6 +2297,9 @@ do_jail_attach(struct thread *td, struct newcred->cr_prison = pr; p->p_ucred = newcred; PROC_UNLOCK(p); +#ifdef RACCT + racct_proc_ucred_changed(p, oldcred, newcred); +#endif crfree(oldcred); prison_deref(ppr, PD_DEREF | PD_DEUREF); return (0); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Tue Mar 29 18:01: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 1DFFF106566B; Tue, 29 Mar 2011 18:01:05 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id E71508FC1A; Tue, 29 Mar 2011 18:01:04 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 8651F46B09; Tue, 29 Mar 2011 14:01:04 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 07B6B8A01B; Tue, 29 Mar 2011 14:01:04 -0400 (EDT) From: John Baldwin To: Randall Stewart Date: Tue, 29 Mar 2011 14:01:03 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> In-Reply-To: <201101191907.p0JJ7GMp086060@svn.freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201103291401.03565.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Tue, 29 Mar 2011 14:01:04 -0400 (EDT) Cc: svn-src-head@freebsd.org, deischen@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r217592 - 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, 29 Mar 2011 18:01:05 -0000 On Wednesday, January 19, 2011 2:07:16 pm Randall Stewart wrote: > Author: rrs > Date: Wed Jan 19 19:07:16 2011 > New Revision: 217592 > URL: http://svn.freebsd.org/changeset/base/217592 > > Log: > Fix a bug where Multicast packets sent from a > udp endpoint may end up echoing back to the sender > even with OUT joining the multi-cast group. > > Reviewed by: gnn, bms, bz? > Obtained from: deischen (with help from) > > Modified: > head/sys/netinet/udp_usrreq.c > > Modified: head/sys/netinet/udp_usrreq.c > ============================================================================== > --- head/sys/netinet/udp_usrreq.c Wed Jan 19 18:20:11 2011 (r217591) > +++ head/sys/netinet/udp_usrreq.c Wed Jan 19 19:07:16 2011 (r217592) > @@ -479,11 +479,13 @@ udp_input(struct mbuf *m, int off) > * and source-specific multicast. [RFC3678] > */ > imo = inp->inp_moptions; > - if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && > - imo != NULL) { > + if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { > struct sockaddr_in group; > int blocked; > - > + if(imo == NULL) { > + INP_RUNLOCK(inp); > + continue; > + } > bzero(&group, sizeof(struct sockaddr_in)); > group.sin_len = sizeof(struct sockaddr_in); > group.sin_family = AF_INET; So it turns out that this is a feature, not a bug, and is how multicast has always worked. Specifically, if you bind a UDP socket with a wildcard address, it should receive all traffic for the bound port, unicast or multicast. When you join a group, you have switched the socket into a mode where it now has a whitelist of acceptable multicast groups, but if a socket has no joined groups, it should receive all multicast traffic, not none. This change breaks that. I did not find this behavior intuitive at first, but it does seem to be required. Note the description of IP_ADD_MEMBERSHIP from RFC 3678 for example: 3. Overview of APIs There are a number of different APIs described in this document that are appropriate for a number of different application types and IP versions. Before providing detailed descriptions, this section provides a "taxonomy" with a brief description of each. There are two categories of source-filter APIs, both of which are designed to allow multicast receiver applications to designate the unicast address(es) of sender(s) along with the multicast group (destination address) to receive. o Basic (Delta-based): Some applications desire the simplicity of a delta-based API in which each function call specifies a single source address which should be added to or removed from the existing filter for a given multicast group address on which to listen. Such applications typically fall into either of two categories: + Any-Source Multicast: By default, all sources are accepted. Individual sources may be turned off and back on as needed over time. This is also known as "exclude" mode, since the source filter contains a list of excluded sources. + Source-Specific Multicast: Only sources in a given list are allowed. The list may change over time. This is also known as "include" mode, since the source filter contains a list of included sources. This API would be used, for example, by "single-source" applications such as audio/video broadcasting. It would also be used for logical multi-source sessions where each source independently allocates its own Source-Specific Multicast group address. ..... 4.1.1. IPv4 Any-Source Multicast API The following socket options are defined in for applications in the Any-Source Multicast category: Socket option Argument type IP_ADD_MEMBERSHIP struct ip_mreq IP_BLOCK_SOURCE struct ip_mreq_source IP_UNBLOCK_SOURCE struct ip_mreq_source IP_DROP_MEMBERSHIP struct ip_mreq IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP are already implemented on most operating systems, and are used to join and leave an any-source group. IP_BLOCK_SOURCE can be used to block data from a given source to a given group (e.g., if the user "mutes" that source), and IP_UNBLOCK_SOURCE can be used to undo this (e.g., if the user then "unmutes" the source). As to why the packets loop back to the receiver, I believe that is a separate issue on the output side, not the receive side. -- John Baldwin From owner-svn-src-head@FreeBSD.ORG Tue Mar 29 18:16: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 08184106564A; Tue, 29 Mar 2011 18:16:50 +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 EAA978FC1F; Tue, 29 Mar 2011 18:16:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2TIGnTa036908; Tue, 29 Mar 2011 18:16:49 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2TIGnru036906; Tue, 29 Mar 2011 18:16:49 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103291816.p2TIGnru036906@svn.freebsd.org> From: Edward Tomasz Napierala Date: Tue, 29 Mar 2011 18:16:49 +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: r220143 - head/sys/amd64/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: Tue, 29 Mar 2011 18:16:50 -0000 Author: trasz Date: Tue Mar 29 18:16:49 2011 New Revision: 220143 URL: http://svn.freebsd.org/changeset/base/220143 Log: Revert part of r220137, committed by mistake - RACCT is _not_ supposed to be enabled in GENERIC. Modified: head/sys/amd64/conf/GENERIC Modified: head/sys/amd64/conf/GENERIC ============================================================================== --- head/sys/amd64/conf/GENERIC Tue Mar 29 18:07:19 2011 (r220142) +++ head/sys/amd64/conf/GENERIC Tue Mar 29 18:16:49 2011 (r220143) @@ -65,8 +65,6 @@ options MAC # TrustedBSD MAC Framewor #options KDTRACE_HOOKS # Kernel DTrace hooks options INCLUDE_CONFIG_FILE # Include this file in kernel -options RACCT - # Debugging for use in -current options KDB # Enable kernel debugger support. options DDB # Support DDB. From owner-svn-src-head@FreeBSD.ORG Tue Mar 29 18:44: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 60FE7106566B; Tue, 29 Mar 2011 18:44:08 +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 35D458FC0C; Tue, 29 Mar 2011 18:44:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2TIi84S037667; Tue, 29 Mar 2011 18:44:08 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2TIi8oN037666; Tue, 29 Mar 2011 18:44:08 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103291844.p2TIi8oN037666@svn.freebsd.org> From: Edward Tomasz Napierala Date: Tue, 29 Mar 2011 18:44: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: r220145 - 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, 29 Mar 2011 18:44:08 -0000 Author: trasz Date: Tue Mar 29 18:44:07 2011 New Revision: 220145 URL: http://svn.freebsd.org/changeset/base/220145 Log: Revert file added in a wrong place by mistake. D'oh. Deleted: head/kern_racct.c From owner-svn-src-head@FreeBSD.ORG Tue Mar 29 19:19: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 F3D4F106564A; Tue, 29 Mar 2011 19:19:10 +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 C84F78FC0A; Tue, 29 Mar 2011 19:19:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2TJJAHW038498; Tue, 29 Mar 2011 19:19:10 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2TJJA0W038496; Tue, 29 Mar 2011 19:19:10 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103291919.p2TJJA0W038496@svn.freebsd.org> From: Edward Tomasz Napierala Date: Tue, 29 Mar 2011 19:19: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: r220146 - 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: Tue, 29 Mar 2011 19:19:11 -0000 Author: trasz Date: Tue Mar 29 19:19:10 2011 New Revision: 220146 URL: http://svn.freebsd.org/changeset/base/220146 Log: Remove pointless (always true) KASSERTs. Submitted by: pjd Modified: head/sys/kern/kern_racct.c Modified: head/sys/kern/kern_racct.c ============================================================================== --- head/sys/kern/kern_racct.c Tue Mar 29 18:44:07 2011 (r220145) +++ head/sys/kern/kern_racct.c Tue Mar 29 19:19:10 2011 (r220146) @@ -285,8 +285,6 @@ racct_add(struct proc *p, int resource, * We need proc lock to dereference p->p_ucred. */ PROC_LOCK_ASSERT(p, MA_OWNED); - KASSERT(amount >= 0, ("racct_add: invalid amount for resource %d: %ju", - resource, amount)); mtx_lock(&racct_lock); #ifdef RCTL @@ -313,10 +311,6 @@ racct_add_cred_locked(struct ucred *cred SDT_PROBE(racct, kernel, rusage, add_cred, cred, resource, amount, 0, 0); - KASSERT(amount >= 0, - ("racct_add_cred: invalid amount for resource %d: %ju", - resource, amount)); - racct_alloc_resource(cred->cr_ruidinfo->ui_racct, resource, amount); for (pr = cred->cr_prison; pr != NULL; pr = pr->pr_parent) racct_alloc_resource(pr->pr_racct, resource, amount); @@ -355,9 +349,6 @@ racct_add_force(struct proc *p, int reso * We need proc lock to dereference p->p_ucred. */ PROC_LOCK_ASSERT(p, MA_OWNED); - KASSERT(amount >= 0, - ("racct_add_force: invalid amount for resource %d: %ju", - resource, amount)); mtx_lock(&racct_lock); racct_alloc_resource(p->p_racct, resource, amount); @@ -382,8 +373,6 @@ racct_set_locked(struct proc *p, int res * We need proc lock to dereference p->p_ucred. */ PROC_LOCK_ASSERT(p, MA_OWNED); - KASSERT(amount >= 0, ("racct_set: invalid amount for resource %d: %ju", - resource, amount)); diff = amount - p->p_racct->r_resources[resource]; #ifdef notyet @@ -442,9 +431,6 @@ racct_set_force(struct proc *p, int reso * We need proc lock to dereference p->p_ucred. */ PROC_LOCK_ASSERT(p, MA_OWNED); - KASSERT(amount >= 0, - ("racct_set_force: invalid amount for resource %d: %ju", - resource, amount)); mtx_lock(&racct_lock); diff = amount - p->p_racct->r_resources[resource]; @@ -506,8 +492,6 @@ racct_sub(struct proc *p, int resource, * We need proc lock to dereference p->p_ucred. */ PROC_LOCK_ASSERT(p, MA_OWNED); - KASSERT(amount >= 0, ("racct_sub: invalid amount for resource %d: %ju", - resource, amount)); KASSERT(racct_is_reclaimable(resource), ("racct_sub: called for non-reclaimable resource %d", resource)); @@ -530,9 +514,6 @@ racct_sub_cred_locked(struct ucred *cred SDT_PROBE(racct, kernel, rusage, sub_cred, cred, resource, amount, 0, 0); - KASSERT(amount >= 0, - ("racct_sub_cred: invalid amount for resource %d: %ju", - resource, amount)); #ifdef notyet KASSERT(racct_is_reclaimable(resource), ("racct_sub_cred: called for non-reclaimable resource %d", From owner-svn-src-head@FreeBSD.ORG Tue Mar 29 19:48: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 DC5971065675; Tue, 29 Mar 2011 19:48:03 +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 BBF778FC08; Tue, 29 Mar 2011 19:48:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2TJm3ZK039129; Tue, 29 Mar 2011 19:48:03 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2TJm3Z2039126; Tue, 29 Mar 2011 19:48:03 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201103291948.p2TJm3Z2039126@svn.freebsd.org> From: Marius Strobl Date: Tue, 29 Mar 2011 19:48: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: r220147 - head/sys/sparc64/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: Tue, 29 Mar 2011 19:48:04 -0000 Author: marius Date: Tue Mar 29 19:48:03 2011 New Revision: 220147 URL: http://svn.freebsd.org/changeset/base/220147 Log: Allocate memory for a DMA method table only in case we need to override the iommu(4) provided one, i.e. in case of Hummingbird and Sabre bridges, otherwise just use the iommu(4) one. This also fixes a bug introduced in r220039 which caused an empty DMA method table to be used for the second of a pair of Psycho bridges. Modified: head/sys/sparc64/pci/psycho.c head/sys/sparc64/pci/psychovar.h Modified: head/sys/sparc64/pci/psycho.c ============================================================================== --- head/sys/sparc64/pci/psycho.c Tue Mar 29 19:19:10 2011 (r220146) +++ head/sys/sparc64/pci/psycho.c Tue Mar 29 19:48:03 2011 (r220147) @@ -529,21 +529,29 @@ psycho_attach(device_t dev) * * For the moment, 32KB should be more than enough. */ - memcpy(&sc->sc_dma_methods, &iommu_dma_methods, - sizeof(sc->sc_dma_methods)); - sc->sc_is = malloc(sizeof(struct iommu_state), M_DEVBUF, - M_NOWAIT | M_ZERO); + sc->sc_is = malloc(sizeof(*sc->sc_is), M_DEVBUF, M_NOWAIT | + M_ZERO); if (sc->sc_is == NULL) - panic("%s: malloc iommu_state failed", __func__); + panic("%s: could not malloc IOMMU state", __func__); sc->sc_is->is_flags = IOMMU_PRESERVE_PROM; if (sc->sc_mode == PSYCHO_MODE_SABRE) { - sc->sc_dma_methods.dm_dmamap_sync = + sc->sc_dma_methods = + malloc(sizeof(*sc->sc_dma_methods), M_DEVBUF, + M_NOWAIT); + if (sc->sc_dma_methods == NULL) + panic("%s: could not malloc DMA methods", + __func__); + memcpy(sc->sc_dma_methods, &iommu_dma_methods, + sizeof(*sc->sc_dma_methods)); + sc->sc_dma_methods->dm_dmamap_sync = sabre_dmamap_sync; sc->sc_is->is_pmaxaddr = IOMMU_MAXADDR(SABRE_IOMMU_BITS); - } else + } else { + sc->sc_dma_methods = &iommu_dma_methods; sc->sc_is->is_pmaxaddr = IOMMU_MAXADDR(PSYCHO_IOMMU_BITS); + } sc->sc_is->is_sb[0] = sc->sc_is->is_sb[1] = 0; if (OF_getproplen(node, "no-streaming-cache") < 0) sc->sc_is->is_sb[0] = sc->sc_pcictl + PCR_STRBUF; @@ -551,6 +559,7 @@ psycho_attach(device_t dev) psycho_iommu_init(sc, 3, dvmabase); } else { /* Just copy IOMMU state, config tag and address. */ + sc->sc_dma_methods = &iommu_dma_methods; sc->sc_is = osc->sc_is; if (OF_getproplen(node, "no-streaming-cache") < 0) sc->sc_is->is_sb[1] = sc->sc_pcictl + PCR_STRBUF; @@ -567,7 +576,7 @@ psycho_attach(device_t dev) panic("%s: bus_dma_tag_create failed", __func__); /* Customize the tag. */ sc->sc_pci_dmat->dt_cookie = sc->sc_is; - sc->sc_pci_dmat->dt_mt = &sc->sc_dma_methods; + sc->sc_pci_dmat->dt_mt = sc->sc_dma_methods; i = OF_getprop(node, "bus-range", (void *)prop_array, sizeof(prop_array)); Modified: head/sys/sparc64/pci/psychovar.h ============================================================================== --- head/sys/sparc64/pci/psychovar.h Tue Mar 29 19:19:10 2011 (r220146) +++ head/sys/sparc64/pci/psychovar.h Tue Mar 29 19:48:03 2011 (r220147) @@ -36,7 +36,7 @@ * per pair of psychos. */ struct psycho_softc { - struct bus_dma_methods sc_dma_methods; + struct bus_dma_methods *sc_dma_methods; device_t sc_dev; From owner-svn-src-head@FreeBSD.ORG Tue Mar 29 20:53: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 F31C31065670; Tue, 29 Mar 2011 20:53:52 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DC1C48FC14; Tue, 29 Mar 2011 20:53:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2TKrqFX040672; Tue, 29 Mar 2011 20:53:52 GMT (envelope-from mm@svn.freebsd.org) Received: (from mm@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2TKrpP5040638; Tue, 29 Mar 2011 20:53:51 GMT (envelope-from mm@svn.freebsd.org) Message-Id: <201103292053.p2TKrpP5040638@svn.freebsd.org> From: Martin Matuska Date: Tue, 29 Mar 2011 20:53: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: r220150 - in head: contrib/gcc contrib/gcc/config/mips contrib/gcc/config/rs6000 contrib/gcc/config/s390 contrib/gcc/cp contrib/gcc/doc contrib/libstdc++ contrib/libstdc++/include/std c... 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, 29 Mar 2011 20:53:53 -0000 Author: mm Date: Tue Mar 29 20:53:51 2011 New Revision: 220150 URL: http://svn.freebsd.org/changeset/base/220150 Log: Upgrade of base gcc and libstdc++ to the last GPLv2-licensed revision (rev. 127959 of gcc-4_2-branch). Resolved GCC bugs: c++: 17763, 29365, 30535, 30917, 31337, 31941, 32108, 32112, 32346, 32898, 32992 debug: 32610, 32914 libstdc++: 33084, 33128 middle-end: 32563 rtl-optimization: 33148 tree-optimization: 25413, 32723 target: 32218 Tested by: pointyhat (miwi) Obtained from: gcc (gcc-4_2-branch up to rev. 127959) PR: gnu/153298, gnu/153959, gnu/154385 MFC after: 1 month Modified: head/contrib/gcc/BASE-VER head/contrib/gcc/ChangeLog head/contrib/gcc/DATESTAMP head/contrib/gcc/DEV-PHASE head/contrib/gcc/config/mips/predicates.md head/contrib/gcc/config/rs6000/rs6000.c head/contrib/gcc/config/s390/s390.md head/contrib/gcc/cp/ChangeLog head/contrib/gcc/cp/call.c head/contrib/gcc/cp/cp-tree.h head/contrib/gcc/cp/cxx-pretty-print.c head/contrib/gcc/cp/decl.c head/contrib/gcc/cp/decl2.c head/contrib/gcc/cp/error.c head/contrib/gcc/cp/lex.c head/contrib/gcc/cp/name-lookup.c head/contrib/gcc/cp/pt.c head/contrib/gcc/cp/semantics.c head/contrib/gcc/cp/typeck.c head/contrib/gcc/doc/contrib.texi head/contrib/gcc/dwarf2out.c head/contrib/gcc/expr.c head/contrib/gcc/fold-const.c head/contrib/gcc/gimplify.c head/contrib/gcc/reload1.c head/contrib/gcc/simplify-rtx.c head/contrib/gcc/target-def.h head/contrib/gcc/target.h head/contrib/gcc/targhooks.c head/contrib/gcc/targhooks.h head/contrib/gcc/tree-if-conv.c head/contrib/gcc/tree-ssa-structalias.c head/contrib/gcc/tree-vect-analyze.c head/contrib/gcc/tree-vect-patterns.c head/contrib/gcc/tree.c head/contrib/gcc/tree.h head/contrib/libstdc++/ChangeLog head/contrib/libstdc++/include/std/std_valarray.h head/contrib/libstdc++/include/tr1/random head/sys/sys/param.h Directory Properties: head/contrib/gcc/ (props changed) head/contrib/libstdc++/ (props changed) Modified: head/contrib/gcc/BASE-VER ============================================================================== --- head/contrib/gcc/BASE-VER Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/BASE-VER Tue Mar 29 20:53:51 2011 (r220150) @@ -1 +1 @@ -4.2.1 +4.2.2 Modified: head/contrib/gcc/ChangeLog ============================================================================== --- head/contrib/gcc/ChangeLog Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/ChangeLog Tue Mar 29 20:53:51 2011 (r220150) @@ -1,3 +1,121 @@ +2007-08-31 Jakub Jelinek + + PR rtl-optimization/33148 + * simplify-rtx.c (simplify_unary_operation_1): Only optimize + (neg (lt X 0)) if X has scalar int mode. + + PR debug/32914 + * dwarf2out.c (rtl_for_decl_init): If vector decl has CONSTRUCTOR + initializer, use build_vector_from_ctor if possible to create + VECTOR_CST out of it. If vector initializer is not VECTOR_CST + even after this, return NULL. + +2007-08-27 Jason Merrill + + PR c++/31337 + * gimplify.c (gimplify_modify_expr): Discard the assignment of + zero-sized types after calling gimplify_modify_expr_rhs. + +2007-08-24 Jakub Jelinek + + PR debug/32610 + * dwarf2out.c (gen_decl_die): Don't call + gen_tagged_type_instantiation_die if decl doesn't have tagged type. + +2007-08-24 Richard Guenther + + * expr.c (get_inner_reference): Remove unused variable. + +2007-08-24 Richard Guenther + + * expr.c (get_inner_reference): Do computation of bitoffset + from offset in a way we can detect overflow reliably. + +2007-08-22 Richard Guenther + + PR middle-end/32563 + * tree.c (host_integerp): Treat sizetype as signed as it is + sign-extended. + +2007-08-20 Adam Nemet + + * config/mips/predicates.md (const_call_insn_operand): Invoke + SYMBOL_REF_LONG_CALL_P only on SYMBOL_REFs. + +2007-08-17 Chen liqin + + * config/score/score.md : Update pattern tablejump. + * config/score/score.c : Update score_initialize_trampoline + function. + * config/score/score.h (TRAMPOLINE_TEMPLATE): Added macro. + (TRAMPOLINE_INSNS, TRAMPOLINE_SIZE) Update macro. + * doc/contrib.texi: Add my entry. + +2007-08-02 Andreas Krebbel + + * config/s390/s390.md ("*xordi3_cconly"): Change xr to xg. + +2007-08-01 Andreas Krebbel + + * config/s390/s390.md (TF in GPR splitter): Change operand_subword + parameter to TFmode. + +2007-07-30 Mark Mitchell + + * BASE-VER: Bump. + * DEV-PHASE: Mark as prerelease. + +2007-07-25 Steve Ellcey + + PR target/32218 + * tree-vect-patterns.c (vect_pattern_recog_1): Check for valid type. + +2007-07-25 Dorit Nuzman + Devang Patel + + PR tree-optimization/25413 + * targhooks.c (default_builtin_vector_alignment_reachable): New. + * targhooks.h (default_builtin_vector_alignment_reachable): New. + * tree.h (contains_packed_reference): New. + * expr.c (contains_packed_reference): New. + * tree-vect-analyze.c (vector_alignment_reachable_p): New. + (vect_enhance_data_refs_alignment): Call + vector_alignment_reachable_p. + * target.h (vector_alignment_reachable): New builtin. + * target-def.h (TARGET_VECTOR_ALIGNMENT_REACHABLE): New. + * config/rs6000/rs6000.c (rs6000_vector_alignment_reachable): New. + (TARGET_VECTOR_ALIGNMENT_REACHABLE): Define. + +2007-07-24 Richard Guenther + + Backport from mainline: + 2007-07-16 Richard Guenther + Uros Bizjak + + * tree-if-conv.c (find_phi_replacement_condition): Unshare "*cond" + before forcing it to gimple operand. + +2007-07-24 Richard Guenther + + PR tree-optimization/32723 + Backport from mainline: + 2007-03-09 Daniel Berlin + + * tree-ssa-structalias.c (shared_bitmap_info_t): New structure. + (shared_bitmap_table): New variable. + (shared_bitmap_hash): New function. + (shared_bitmap_eq): Ditto + (shared_bitmap_lookup): Ditto. + (shared_bitmap_add): Ditto. + (find_what_p_points_to): Rewrite to use shared bitmap hashtable. + (init_alias_vars): Init shared bitmap hashtable. + (delete_points_to_sets): Delete shared bitmap hashtable. + +2007-07-23 Bernd Schmidt + + * reload1.c (choose_reload_regs): Set reload_spill_index for regs + chosen during find_reloads. + 2007-07-19 Release Manager * GCC 4.2.1 released. Modified: head/contrib/gcc/DATESTAMP ============================================================================== --- head/contrib/gcc/DATESTAMP Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/DATESTAMP Tue Mar 29 20:53:51 2011 (r220150) @@ -1 +1 @@ -20070719 +20070831 Modified: head/contrib/gcc/DEV-PHASE ============================================================================== --- head/contrib/gcc/DEV-PHASE Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/DEV-PHASE Tue Mar 29 20:53:51 2011 (r220150) @@ -0,0 +1 @@ +prerelease Modified: head/contrib/gcc/config/mips/predicates.md ============================================================================== --- head/contrib/gcc/config/mips/predicates.md Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/config/mips/predicates.md Tue Mar 29 20:53:51 2011 (r220150) @@ -116,7 +116,9 @@ /* If -mlong-calls, force all calls to use register addressing. Also, if this function has the long_call attribute, we must use register addressing. */ - return !TARGET_LONG_CALLS && !SYMBOL_REF_LONG_CALL_P (op); + return (!TARGET_LONG_CALLS + && !(GET_CODE (op) == SYMBOL_REF + && SYMBOL_REF_LONG_CALL_P (op))); case SYMBOL_GOT_GLOBAL: /* Without explicit relocs, there is no special syntax for Modified: head/contrib/gcc/config/rs6000/rs6000.c ============================================================================== --- head/contrib/gcc/config/rs6000/rs6000.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/config/rs6000/rs6000.c Tue Mar 29 20:53:51 2011 (r220150) @@ -664,6 +664,7 @@ static int rs6000_use_sched_lookahead (v static tree rs6000_builtin_mask_for_load (void); static void def_builtin (int, const char *, tree, int); +static bool rs6000_vector_alignment_reachable (tree, bool); static void rs6000_init_builtins (void); static rtx rs6000_expand_unop_builtin (enum insn_code, tree, rtx); static rtx rs6000_expand_binop_builtin (enum insn_code, tree, rtx); @@ -915,6 +916,9 @@ static const char alt_reg_names[][8] = #undef TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD rs6000_builtin_mask_for_load +#undef TARGET_VECTOR_ALIGNMENT_REACHABLE +#define TARGET_VECTOR_ALIGNMENT_REACHABLE rs6000_vector_alignment_reachable + #undef TARGET_INIT_BUILTINS #define TARGET_INIT_BUILTINS rs6000_init_builtins @@ -1584,6 +1588,37 @@ rs6000_builtin_mask_for_load (void) return 0; } + +/* Return true iff, data reference of TYPE can reach vector alignment (16) + after applying N number of iterations. This routine does not determine + how may iterations are required to reach desired alignment. */ + +static bool +rs6000_vector_alignment_reachable (tree type ATTRIBUTE_UNUSED, bool is_packed) +{ + if (is_packed) + return false; + + if (TARGET_32BIT) + { + if (rs6000_alignment_flags == MASK_ALIGN_NATURAL) + return true; + + if (rs6000_alignment_flags == MASK_ALIGN_POWER) + return true; + + return false; + } + else + { + if (TARGET_MACHO) + return false; + + /* Assuming that all other types are naturally aligned. CHECKME! */ + return true; + } +} + /* Handle generic options of the form -mfoo=yes/no. NAME is the option name. VALUE is the option value. Modified: head/contrib/gcc/config/s390/s390.md ============================================================================== --- head/contrib/gcc/config/s390/s390.md Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/config/s390/s390.md Tue Mar 29 20:53:51 2011 (r220150) @@ -1500,7 +1500,7 @@ && !s_operand (operands[1], VOIDmode)" [(set (match_dup 0) (match_dup 1))] { - rtx addr = operand_subword (operands[0], 1, 0, DFmode); + rtx addr = operand_subword (operands[0], 1, 0, TFmode); s390_load_address (addr, XEXP (operands[1], 0)); operands[1] = replace_equiv_address (operands[1], addr); }) @@ -5624,7 +5624,7 @@ "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT" "@ xgr\t%0,%2 - xr\t%0,%2" + xg\t%0,%2" [(set_attr "op_type" "RRE,RXY")]) (define_insn "*xordi3_extimm" Modified: head/contrib/gcc/cp/ChangeLog ============================================================================== --- head/contrib/gcc/cp/ChangeLog Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/ChangeLog Tue Mar 29 20:53:51 2011 (r220150) @@ -1,3 +1,66 @@ +2007-08-24 Jakub Jelinek + + PR c++/31941 + * error.c (resolve_virtual_fun_from_obj_type_ref): Handle + TARGET_VTABLE_USES_DESCRIPTORS targets properly. + + PR c++/32898 + * name-lookup.c (set_decl_namespace): lookup_qualified_name failure + is error_mark_node rather than NULL_TREE. + * pt.c (check_explicit_specialization): Likewise. + +2007-08-22 Jason Merrill + + PR c++/29365 + * pt.c (outermost_tinst_level): New function. + * lex.c (in_main_input_context): New function. + * cp-tree.h: Declare it. + * decl2.c (constrain_class_visibility): Use it to avoid warning + about uses of the anonymous namespace in the main input file. + +2007-08-20 Jakub Jelinek + + PR c++/32992 + * typeck.c (check_return_expr): Don't NRV optimize vars in + anonymous unions. + * decl.c (finish_function): Comment fix. + +2007-08-18 Paolo Carlini + + PR c++/32112 + * error.c (dump_decl): Deal with UNBOUND_CLASS_TEMPLATE. + * cxx-pretty-print.c (pp_cxx_unqualified_id): Likewise. + +2007-08-10 Paolo Carlini + + PR c++/17763 + * error.c (dump_expr): Consistently use the *_cxx_* + variants of the pretty-print functions. + +2007-07-30 Paolo Carlini + + PR c++/32108 + * semantics.c (finish_label_stmt): Reject the __label__ + extension outside function scopes. + +2007-07-28 Simon Martin + Mark Mitchell + + PR c++/30917 + * name-lookup.c (lookup_name_real): Non namespace-scope bindings can be + hidden due to friend declarations in local classes. + +2007-07-27 Mark Mitchell + + PR c++/32346 + * call.c (convert_for_arg_passing): Only widen bitfields to their + declared types if necessary. + +2007-07-24 Paolo Carlini + + PR c++/30535 + * pt.c (unify): Never pass error_mark_node to template_decl_level. + 2007-07-19 Release Manager * GCC 4.2.1 released. Modified: head/contrib/gcc/cp/call.c ============================================================================== --- head/contrib/gcc/cp/call.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/call.c Tue Mar 29 20:53:51 2011 (r220150) @@ -4674,7 +4674,27 @@ type_passed_as (tree type) tree convert_for_arg_passing (tree type, tree val) { - val = convert_bitfield_to_declared_type (val); + tree bitfield_type; + + /* If VAL is a bitfield, then -- since it has already been converted + to TYPE -- it cannot have a precision greater than TYPE. + + If it has a smaller precision, we must widen it here. For + example, passing "int f:3;" to a function expecting an "int" will + not result in any conversion before this point. + + If the precision is the same we must not risk widening. For + example, the COMPONENT_REF for a 32-bit "long long" bitfield will + often have type "int", even though the C++ type for the field is + "long long". If the value is being passed to a function + expecting an "int", then no conversions will be required. But, + if we call convert_bitfield_to_declared_type, the bitfield will + be converted to "long long". */ + bitfield_type = is_bitfield_expr_with_lowered_type (val); + if (bitfield_type + && TYPE_PRECISION (TREE_TYPE (val)) < TYPE_PRECISION (type)) + val = convert_to_integer (TYPE_MAIN_VARIANT (bitfield_type), val); + if (val == error_mark_node) ; /* Pass classes with copy ctors by invisible reference. */ Modified: head/contrib/gcc/cp/cp-tree.h ============================================================================== --- head/contrib/gcc/cp/cp-tree.h Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/cp-tree.h Tue Mar 29 20:53:51 2011 (r220150) @@ -4079,6 +4079,7 @@ extern void yyerror (const char *); extern void yyhook (int); extern bool cxx_init (void); extern void cxx_finish (void); +extern bool in_main_input_context (void); /* in method.c */ extern void init_method (void); @@ -4161,6 +4162,7 @@ extern tree build_non_dependent_args (t extern bool reregister_specialization (tree, tree, tree); extern tree fold_non_dependent_expr (tree); extern bool explicit_class_specialization_p (tree); +extern tree outermost_tinst_level (void); /* in repo.c */ extern void init_repo (void); Modified: head/contrib/gcc/cp/cxx-pretty-print.c ============================================================================== --- head/contrib/gcc/cp/cxx-pretty-print.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/cxx-pretty-print.c Tue Mar 29 20:53:51 2011 (r220150) @@ -204,6 +204,10 @@ pp_cxx_unqualified_id (cxx_pretty_printe pp_cxx_unqualified_id (pp, TEMPLATE_PARM_DECL (t)); break; + case UNBOUND_CLASS_TEMPLATE: + pp_cxx_unqualified_id (pp, TYPE_NAME (t)); + break; + default: pp_unsupported_tree (pp, t); break; Modified: head/contrib/gcc/cp/decl.c ============================================================================== --- head/contrib/gcc/cp/decl.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/decl.c Tue Mar 29 20:53:51 2011 (r220150) @@ -11273,7 +11273,7 @@ finish_function (int flags) gcc_assert (stmts_are_full_exprs_p ()); /* Set up the named return value optimization, if we can. Candidate - variables are selected in check_return_value. */ + variables are selected in check_return_expr. */ if (current_function_return_value) { tree r = current_function_return_value; Modified: head/contrib/gcc/cp/decl2.c ============================================================================== --- head/contrib/gcc/cp/decl2.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/decl2.c Tue Mar 29 20:53:51 2011 (r220150) @@ -1860,9 +1860,12 @@ constrain_class_visibility (tree type) int subvis = type_visibility (ftype); if (subvis == VISIBILITY_ANON) - warning (0, "\ + { + if (!in_main_input_context ()) + warning (0, "\ %qT has a field %qD whose type uses the anonymous namespace", type, t); + } else if (IS_AGGR_TYPE (ftype) && vis < VISIBILITY_HIDDEN && subvis >= VISIBILITY_HIDDEN) @@ -1877,9 +1880,12 @@ constrain_class_visibility (tree type) int subvis = type_visibility (TREE_TYPE (t)); if (subvis == VISIBILITY_ANON) - warning (0, "\ + { + if (!in_main_input_context()) + warning (0, "\ %qT has a base %qT whose type uses the anonymous namespace", type, TREE_TYPE (t)); + } else if (vis < VISIBILITY_HIDDEN && subvis >= VISIBILITY_HIDDEN) warning (OPT_Wattributes, "\ Modified: head/contrib/gcc/cp/error.c ============================================================================== --- head/contrib/gcc/cp/error.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/error.c Tue Mar 29 20:53:51 2011 (r220150) @@ -901,6 +901,10 @@ dump_decl (tree t, int flags) pp_type_id (cxx_pp, t); break; + case UNBOUND_CLASS_TEMPLATE: + dump_type (t, flags); + break; + default: pp_unsupported_tree (cxx_pp, t); /* Fall through to error. */ @@ -1301,10 +1305,14 @@ static tree resolve_virtual_fun_from_obj_type_ref (tree ref) { tree obj_type = TREE_TYPE (OBJ_TYPE_REF_OBJECT (ref)); - int index = tree_low_cst (OBJ_TYPE_REF_TOKEN (ref), 1); + HOST_WIDE_INT index = tree_low_cst (OBJ_TYPE_REF_TOKEN (ref), 1); tree fun = BINFO_VIRTUALS (TYPE_BINFO (TREE_TYPE (obj_type))); - while (index--) + while (index) + { fun = TREE_CHAIN (fun); + index -= (TARGET_VTABLE_USES_DESCRIPTORS + ? TARGET_VTABLE_USES_DESCRIPTORS : 1); + } return BV_FN (fun); } @@ -1420,13 +1428,13 @@ dump_expr (tree t, int flags) if (TREE_CODE (ob) == ADDR_EXPR) { dump_expr (TREE_OPERAND (ob, 0), flags | TFF_EXPR_IN_PARENS); - pp_dot (cxx_pp); + pp_cxx_dot (cxx_pp); } else if (TREE_CODE (ob) != PARM_DECL || strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this")) { dump_expr (ob, flags | TFF_EXPR_IN_PARENS); - pp_arrow (cxx_pp); + pp_cxx_arrow (cxx_pp); } args = TREE_CHAIN (args); } Modified: head/contrib/gcc/cp/lex.c ============================================================================== --- head/contrib/gcc/cp/lex.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/lex.c Tue Mar 29 20:53:51 2011 (r220150) @@ -827,3 +827,18 @@ make_aggr_type (enum tree_code code) return t; } + +/* Returns true if we are currently in the main source file, or in a + template instantiation started from the main source file. */ + +bool +in_main_input_context (void) +{ + tree tl = outermost_tinst_level(); + + if (tl) + return strcmp (main_input_filename, + LOCATION_FILE (TINST_LOCATION (tl))) == 0; + else + return strcmp (main_input_filename, input_filename) == 0; +} Modified: head/contrib/gcc/cp/name-lookup.c ============================================================================== --- head/contrib/gcc/cp/name-lookup.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/name-lookup.c Tue Mar 29 20:53:51 2011 (r220150) @@ -2924,7 +2924,7 @@ set_decl_namespace (tree decl, tree scop /* See whether this has been declared in the namespace. */ old = lookup_qualified_name (scope, DECL_NAME (decl), false, true); - if (!old) + if (old == error_mark_node) /* No old declaration at all. */ goto complain; if (!is_overloaded_fn (decl)) @@ -3996,8 +3996,49 @@ lookup_name_real (tree name, int prefer_ if (binding) { - /* Only namespace-scope bindings can be hidden. */ - gcc_assert (!hidden_name_p (binding)); + if (hidden_name_p (binding)) + { + /* A non namespace-scope binding can only be hidden if + we are in a local class, due to friend declarations. + In particular, consider: + + void f() { + struct A { + friend struct B; + void g() { B* b; } // error: B is hidden + } + struct B {}; + } + + The standard says that "B" is a local class in "f" + (but not nested within "A") -- but that name lookup + for "B" does not find this declaration until it is + declared directly with "f". + + In particular: + + [class.friend] + + If a friend declaration appears in a local class and + the name specified is an unqualified name, a prior + declaration is looked up without considering scopes + that are outside the innermost enclosing non-class + scope. For a friend class declaration, if there is no + prior declaration, the class that is specified + belongs to the innermost enclosing non-class scope, + but if it is subsequently referenced, its name is not + found by name lookup until a matching declaration is + provided in the innermost enclosing nonclass scope. + */ + gcc_assert (current_class_type && + LOCAL_CLASS_P (current_class_type)); + + /* This binding comes from a friend declaration in the local + class. The standard (11.4.8) states that the lookup can + only succeed if there is a non-hidden declaration in the + current scope, which is not the case here. */ + POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE); + } val = binding; break; } Modified: head/contrib/gcc/cp/pt.c ============================================================================== --- head/contrib/gcc/cp/pt.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/pt.c Tue Mar 29 20:53:51 2011 (r220150) @@ -1971,7 +1971,7 @@ check_explicit_specialization (tree decl context. */ fns = lookup_qualified_name (CP_DECL_CONTEXT (decl), dname, false, true); - if (!fns || !is_overloaded_fn (fns)) + if (fns == error_mark_node || !is_overloaded_fn (fns)) { error ("%qD is not a template function", dname); fns = error_mark_node; @@ -5288,6 +5288,15 @@ reopen_tinst_level (tree level) pop_tinst_level (); } +/* Returns the TINST_LEVEL which gives the original instantiation + context. */ + +tree +outermost_tinst_level (void) +{ + return tree_last (current_tinst_level); +} + /* DECL is a friend FUNCTION_DECL or TEMPLATE_DECL. ARGS is the vector of template arguments, as for tsubst. @@ -10453,6 +10462,8 @@ unify (tree tparms, tree targs, tree par case TEMPLATE_TEMPLATE_PARM: case BOUND_TEMPLATE_TEMPLATE_PARM: tparm = TREE_VALUE (TREE_VEC_ELT (tparms, 0)); + if (tparm == error_mark_node) + return 1; if (TEMPLATE_TYPE_LEVEL (parm) != template_decl_level (tparm)) Modified: head/contrib/gcc/cp/semantics.c ============================================================================== --- head/contrib/gcc/cp/semantics.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/semantics.c Tue Mar 29 20:53:51 2011 (r220150) @@ -1320,8 +1320,13 @@ finish_label_stmt (tree name) void finish_label_decl (tree name) { - tree decl = declare_local_label (name); - add_decl_expr (decl); + if (!at_function_scope_p ()) + { + error ("__label__ declarations are only allowed in function scopes"); + return; + } + + add_decl_expr (declare_local_label (name)); } /* When DECL goes out of scope, make sure that CLEANUP is executed. */ Modified: head/contrib/gcc/cp/typeck.c ============================================================================== --- head/contrib/gcc/cp/typeck.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/cp/typeck.c Tue Mar 29 20:53:51 2011 (r220150) @@ -6604,6 +6604,7 @@ check_return_expr (tree retval, bool *no && TREE_CODE (retval) == VAR_DECL && DECL_CONTEXT (retval) == current_function_decl && ! TREE_STATIC (retval) + && ! DECL_ANON_UNION_VAR_P (retval) && (DECL_ALIGN (retval) >= DECL_ALIGN (DECL_RESULT (current_function_decl))) && same_type_p ((TYPE_MAIN_VARIANT Modified: head/contrib/gcc/doc/contrib.texi ============================================================================== --- head/contrib/gcc/doc/contrib.texi Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/doc/contrib.texi Tue Mar 29 20:53:51 2011 (r220150) @@ -514,6 +514,10 @@ patches. Robert Lipe for OpenServer support, new testsuites, testing, etc. @item +Chen Liqin for various S+core related fixes/improvement, and for +maintaining the S+core port. + +@item Weiwen Liu for testing and various bug fixes. @item Modified: head/contrib/gcc/dwarf2out.c ============================================================================== --- head/contrib/gcc/dwarf2out.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/dwarf2out.c Tue Mar 29 20:53:51 2011 (r220150) @@ -10065,6 +10065,43 @@ rtl_for_decl_init (tree init, tree type) else if (initializer_constant_valid_p (init, type) && ! walk_tree (&init, reference_to_unused, NULL, NULL)) { + /* Convert vector CONSTRUCTOR initializers to VECTOR_CST if + possible. */ + if (TREE_CODE (type) == VECTOR_TYPE) + switch (TREE_CODE (init)) + { + case VECTOR_CST: + break; + case CONSTRUCTOR: + if (TREE_CONSTANT (init)) + { + VEC(constructor_elt,gc) *elts = CONSTRUCTOR_ELTS (init); + bool constant_p = true; + tree value; + unsigned HOST_WIDE_INT ix; + + /* Even when ctor is constant, it might contain non-*_CST + elements (e.g. { 1.0/0.0 - 1.0/0.0, 0.0 }) and those don't + belong into VECTOR_CST nodes. */ + FOR_EACH_CONSTRUCTOR_VALUE (elts, ix, value) + if (!CONSTANT_CLASS_P (value)) + { + constant_p = false; + break; + } + + if (constant_p) + { + init = build_vector_from_ctor (type, elts); + break; + } + } + /* FALLTHRU */ + + default: + return NULL; + } + rtl = expand_expr (init, NULL_RTX, VOIDmode, EXPAND_INITIALIZER); /* If expand_expr returns a MEM, it wasn't immediate. */ @@ -13197,7 +13234,8 @@ gen_decl_die (tree decl, dw_die_ref cont was generated within the original definition of an inline function) we have to generate a special (abbreviated) DW_TAG_structure_type, DW_TAG_union_type, or DW_TAG_enumeration_type DIE here. */ - if (TYPE_DECL_IS_STUB (decl) && decl_ultimate_origin (decl) != NULL_TREE) + if (TYPE_DECL_IS_STUB (decl) && decl_ultimate_origin (decl) != NULL_TREE + && is_tagged_type (TREE_TYPE (decl))) { gen_tagged_type_instantiation_die (TREE_TYPE (decl), context_die); break; Modified: head/contrib/gcc/expr.c ============================================================================== --- head/contrib/gcc/expr.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/expr.c Tue Mar 29 20:53:51 2011 (r220150) @@ -5654,7 +5654,6 @@ get_inner_reference (tree exp, HOST_WIDE enum machine_mode mode = VOIDmode; tree offset = size_zero_node; tree bit_offset = bitsize_zero_node; - tree tem; /* First get the mode, signedness, and size. We do this from just the outermost expression. */ @@ -5690,6 +5689,8 @@ get_inner_reference (tree exp, HOST_WIDE *pbitsize = tree_low_cst (size_tree, 1); } + *pmode = mode; + /* Compute cumulative bit-offset for nested component-refs and array-refs, and find the ultimate containing object. */ while (1) @@ -5774,21 +5775,69 @@ get_inner_reference (tree exp, HOST_WIDE done: /* If OFFSET is constant, see if we can return the whole thing as a - constant bit position. Otherwise, split it up. */ - if (host_integerp (offset, 0) - && 0 != (tem = size_binop (MULT_EXPR, - fold_convert (bitsizetype, offset), - bitsize_unit_node)) - && 0 != (tem = size_binop (PLUS_EXPR, tem, bit_offset)) - && host_integerp (tem, 0)) - *pbitpos = tree_low_cst (tem, 0), *poffset = 0; - else - *pbitpos = tree_low_cst (bit_offset, 0), *poffset = offset; + constant bit position. Make sure to handle overflow during + this conversion. */ + if (host_integerp (offset, 0)) + { + double_int tem = double_int_mul (tree_to_double_int (offset), + uhwi_to_double_int (BITS_PER_UNIT)); + tem = double_int_add (tem, tree_to_double_int (bit_offset)); + if (double_int_fits_in_shwi_p (tem)) + { + *pbitpos = double_int_to_shwi (tem); + *poffset = NULL_TREE; + return exp; + } + } + + /* Otherwise, split it up. */ + *pbitpos = tree_low_cst (bit_offset, 0); + *poffset = offset; - *pmode = mode; return exp; } +/* Given an expression EXP that may be a COMPONENT_REF or an ARRAY_REF, + look for whether EXP or any nested component-refs within EXP is marked + as PACKED. */ + +bool +contains_packed_reference (tree exp) +{ + bool packed_p = false; + + while (1) + { + switch (TREE_CODE (exp)) + { + case COMPONENT_REF: + { + tree field = TREE_OPERAND (exp, 1); + packed_p = DECL_PACKED (field) + || TYPE_PACKED (TREE_TYPE (field)) + || TYPE_PACKED (TREE_TYPE (exp)); + if (packed_p) + goto done; + } + break; + + case BIT_FIELD_REF: + case ARRAY_REF: + case ARRAY_RANGE_REF: + case REALPART_EXPR: + case IMAGPART_EXPR: + case VIEW_CONVERT_EXPR: + break; + + default: + goto done; + } + exp = TREE_OPERAND (exp, 0); + } + done: + return packed_p; +} + /* Return a tree of sizetype representing the size, in bytes, of the element of EXP, an ARRAY_REF. */ Modified: head/contrib/gcc/fold-const.c ============================================================================== --- head/contrib/gcc/fold-const.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/fold-const.c Tue Mar 29 20:53:51 2011 (r220150) @@ -9387,6 +9387,7 @@ fold_binary (enum tree_code code, tree t /* ~X | X is -1. */ if (TREE_CODE (arg0) == BIT_NOT_EXPR + && INTEGRAL_TYPE_P (TREE_TYPE (arg1)) && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0)) { t1 = build_int_cst (type, -1); @@ -9396,6 +9397,7 @@ fold_binary (enum tree_code code, tree t /* X | ~X is -1. */ if (TREE_CODE (arg1) == BIT_NOT_EXPR + && INTEGRAL_TYPE_P (TREE_TYPE (arg0)) && operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0)) { t1 = build_int_cst (type, -1); @@ -9503,6 +9505,7 @@ fold_binary (enum tree_code code, tree t /* ~X ^ X is -1. */ if (TREE_CODE (arg0) == BIT_NOT_EXPR + && INTEGRAL_TYPE_P (TREE_TYPE (arg1)) && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0)) { t1 = build_int_cst (type, -1); @@ -9512,6 +9515,7 @@ fold_binary (enum tree_code code, tree t /* X ^ ~X is -1. */ if (TREE_CODE (arg1) == BIT_NOT_EXPR + && INTEGRAL_TYPE_P (TREE_TYPE (arg0)) && operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0)) { t1 = build_int_cst (type, -1); Modified: head/contrib/gcc/gimplify.c ============================================================================== --- head/contrib/gcc/gimplify.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/gimplify.c Tue Mar 29 20:53:51 2011 (r220150) @@ -3532,8 +3532,16 @@ gimplify_modify_expr (tree *expr_p, tree gcc_assert (TREE_CODE (*expr_p) == MODIFY_EXPR || TREE_CODE (*expr_p) == INIT_EXPR); - /* For zero sized types only gimplify the left hand side and right hand side - as statements and throw away the assignment. */ + /* See if any simplifications can be done based on what the RHS is. */ + ret = gimplify_modify_expr_rhs (expr_p, from_p, to_p, pre_p, post_p, + want_value); + if (ret != GS_UNHANDLED) + return ret; + + /* For zero sized types only gimplify the left hand side and right hand + side as statements and throw away the assignment. Do this after + gimplify_modify_expr_rhs so we handle TARGET_EXPRs of addressable + types properly. */ if (zero_sized_type (TREE_TYPE (*from_p))) { gimplify_stmt (from_p); @@ -3544,12 +3552,6 @@ gimplify_modify_expr (tree *expr_p, tree return GS_ALL_DONE; } - /* See if any simplifications can be done based on what the RHS is. */ - ret = gimplify_modify_expr_rhs (expr_p, from_p, to_p, pre_p, post_p, - want_value); - if (ret != GS_UNHANDLED) - return ret; - /* If the value being copied is of variable width, compute the length of the copy into a WITH_SIZE_EXPR. Note that we need to do this before gimplifying any of the operands so that we can resolve any Modified: head/contrib/gcc/reload1.c ============================================================================== --- head/contrib/gcc/reload1.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/reload1.c Tue Mar 29 20:53:51 2011 (r220150) @@ -5451,7 +5451,14 @@ choose_reload_regs (struct insn_chain *c for (j = 0; j < n_reloads; j++) { reload_order[j] = j; - reload_spill_index[j] = -1; + if (rld[j].reg_rtx != NULL_RTX) + { + gcc_assert (REG_P (rld[j].reg_rtx) + && HARD_REGISTER_P (rld[j].reg_rtx)); + reload_spill_index[j] = REGNO (rld[j].reg_rtx); + } + else + reload_spill_index[j] = -1; if (rld[j].nregs > 1) { Modified: head/contrib/gcc/simplify-rtx.c ============================================================================== --- head/contrib/gcc/simplify-rtx.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/simplify-rtx.c Tue Mar 29 20:53:51 2011 (r220150) @@ -589,7 +589,8 @@ simplify_unary_operation_1 (enum rtx_cod /* (neg (lt x 0)) is (ashiftrt X C) if STORE_FLAG_VALUE is 1. */ /* (neg (lt x 0)) is (lshiftrt X C) if STORE_FLAG_VALUE is -1. */ if (GET_CODE (op) == LT - && XEXP (op, 1) == const0_rtx) + && XEXP (op, 1) == const0_rtx + && SCALAR_INT_MODE_P (GET_MODE (XEXP (op, 0)))) { enum machine_mode inner = GET_MODE (XEXP (op, 0)); int isize = GET_MODE_BITSIZE (inner); Modified: head/contrib/gcc/target-def.h ============================================================================== --- head/contrib/gcc/target-def.h Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/target-def.h Tue Mar 29 20:53:51 2011 (r220150) @@ -337,9 +337,12 @@ Foundation, 51 Franklin Street, Fifth Fl TARGET_SCHED_SET_SCHED_FLAGS} #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD 0 +#define TARGET_VECTOR_ALIGNMENT_REACHABLE \ + default_builtin_vector_alignment_reachable #define TARGET_VECTORIZE \ - {TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD} + {TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD, \ + TARGET_VECTOR_ALIGNMENT_REACHABLE} #define TARGET_DEFAULT_TARGET_FLAGS 0 Modified: head/contrib/gcc/target.h ============================================================================== --- head/contrib/gcc/target.h Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/target.h Tue Mar 29 20:53:51 2011 (r220150) @@ -375,6 +375,10 @@ struct gcc_target by the vectorizer, and return the decl of the target builtin function. */ tree (* builtin_mask_for_load) (void); + + /* Return true if vector alignment is reachable (by peeling N + interations) for the given type. */ + bool (* vector_alignment_reachable) (tree, bool); } vectorize; /* The initial value of target_flags. */ Modified: head/contrib/gcc/targhooks.c ============================================================================== --- head/contrib/gcc/targhooks.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/targhooks.c Tue Mar 29 20:53:51 2011 (r220150) @@ -604,4 +604,20 @@ default_reloc_rw_mask (void) return flag_pic ? 3 : 0; } +bool +default_builtin_vector_alignment_reachable (tree type, bool is_packed) +{ + if (is_packed) + return false; + + /* Assuming that types whose size is > pointer-size are not guaranteed to be + naturally aligned. */ + if (tree_int_cst_compare (TYPE_SIZE (type), bitsize_int (POINTER_SIZE)) > 0) + return false; + + /* Assuming that types whose size is <= pointer-size + are naturally aligned. */ + return true; +} + #include "gt-targhooks.h" Modified: head/contrib/gcc/targhooks.h ============================================================================== --- head/contrib/gcc/targhooks.h Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/targhooks.h Tue Mar 29 20:53:51 2011 (r220150) @@ -57,6 +57,8 @@ extern const char * default_invalid_with extern bool default_narrow_bitfield (void); +extern bool default_builtin_vector_alignment_reachable (tree, bool); + /* These are here, and not in hooks.[ch], because not all users of hooks.h include tm.h, and thus we don't have CUMULATIVE_ARGS. */ Modified: head/contrib/gcc/tree-if-conv.c ============================================================================== --- head/contrib/gcc/tree-if-conv.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/tree-if-conv.c Tue Mar 29 20:53:51 2011 (r220150) @@ -743,7 +743,7 @@ find_phi_replacement_condition (struct l if (TREE_CODE (*cond) == TRUTH_NOT_EXPR) /* We can be smart here and choose inverted condition without switching bbs. */ - *cond = invert_truthvalue (*cond); + *cond = invert_truthvalue (*cond); else /* Select non loop header bb. */ first_edge = second_edge; @@ -762,9 +762,11 @@ find_phi_replacement_condition (struct l /* Create temp. for the condition. Vectorizer prefers to have gimple value as condition. Various targets use different means to communicate - condition in vector compare operation. Using gimple value allows compiler - to emit vector compare and select RTL without exposing compare's result. */ - *cond = force_gimple_operand (*cond, &new_stmts, false, NULL_TREE); + condition in vector compare operation. Using gimple value allows + compiler to emit vector compare and select RTL without exposing + compare's result. */ + *cond = force_gimple_operand (unshare_expr (*cond), &new_stmts, + false, NULL_TREE); if (new_stmts) bsi_insert_before (bsi, new_stmts, BSI_SAME_STMT); if (!is_gimple_reg (*cond) && !is_gimple_condexpr (*cond)) Modified: head/contrib/gcc/tree-ssa-structalias.c ============================================================================== --- head/contrib/gcc/tree-ssa-structalias.c Tue Mar 29 20:23:56 2011 (r220149) +++ head/contrib/gcc/tree-ssa-structalias.c Tue Mar 29 20:53:51 2011 (r220150) @@ -4350,6 +4350,75 @@ intra_create_variable_infos (void) process_constraint (new_constraint (lhs, rhs)); } +/* Structure used to put solution bitmaps in a hashtable so they can + be shared among variables with the same points-to set. */ + +typedef struct shared_bitmap_info +{ + bitmap pt_vars; + hashval_t hashcode; +} *shared_bitmap_info_t; + +static htab_t shared_bitmap_table; + +/* Hash function for a shared_bitmap_info_t */ + +static hashval_t +shared_bitmap_hash (const void *p) +{ + const shared_bitmap_info_t bi = (shared_bitmap_info_t) p; + return bi->hashcode; +} + +/* Equality function for two shared_bitmap_info_t's. */ + +static int +shared_bitmap_eq (const void *p1, const void *p2) +{ + const shared_bitmap_info_t sbi1 = (shared_bitmap_info_t) p1; + const shared_bitmap_info_t sbi2 = (shared_bitmap_info_t) p2; + return bitmap_equal_p (sbi1->pt_vars, sbi2->pt_vars); +} + +/* Lookup a bitmap in the shared bitmap hashtable, and return an already + existing instance if there is one, NULL otherwise. */ + +static bitmap +shared_bitmap_lookup (bitmap pt_vars) +{ + void **slot; + struct shared_bitmap_info sbi; + + sbi.pt_vars = pt_vars; + sbi.hashcode = bitmap_hash (pt_vars); + + slot = htab_find_slot_with_hash (shared_bitmap_table, &sbi, *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 01:10: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 1F9BA1065670; Wed, 30 Mar 2011 01:10:12 +0000 (UTC) (envelope-from zack@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E8EE48FC0C; Wed, 30 Mar 2011 01:10:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2U1ABTK046033; Wed, 30 Mar 2011 01:10:11 GMT (envelope-from zack@svn.freebsd.org) Received: (from zack@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2U1ABB1046030; Wed, 30 Mar 2011 01:10:11 GMT (envelope-from zack@svn.freebsd.org) Message-Id: <201103300110.p2U1ABB1046030@svn.freebsd.org> From: Zack Kirsch Date: Wed, 30 Mar 2011 01:10:11 +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: r220152 - 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: Wed, 30 Mar 2011 01:10:12 -0000 Author: zack Date: Wed Mar 30 01:10:11 2011 New Revision: 220152 URL: http://svn.freebsd.org/changeset/base/220152 Log: This patch fixes the Experimental NFS client to properly deal with 32 bit or 64 bit fileid's in NFSv2 and NFSv3. Without this fix, invalid casting (and sign extension) was creating problems for any fileid greater than 2^31. We discovered this because we have test clusters with more than 2 billion allocated files and 64-bit ino_t's (and friend structures). Reviewed by: rmacklem Approved by: zml (mentor) MFC after: 2 weeks Modified: head/sys/fs/nfsclient/nfs_clcomsubs.c head/sys/fs/nfsclient/nfs_clrpcops.c Modified: head/sys/fs/nfsclient/nfs_clcomsubs.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clcomsubs.c Tue Mar 29 20:58:25 2011 (r220151) +++ head/sys/fs/nfsclient/nfs_clcomsubs.c Wed Mar 30 01:10:11 2011 (r220152) @@ -289,8 +289,7 @@ nfsm_loadattr(struct nfsrv_descript *nd, nap->na_size = fxdr_hyper(&fp->fa3_size); nap->na_blocksize = NFS_FABLKSIZE; nap->na_bytes = fxdr_hyper(&fp->fa3_used); - nap->na_fileid = fxdr_unsigned(int32_t, - fp->fa3_fileid.nfsuquad[1]); + nap->na_fileid = fxdr_hyper(&fp->fa3_fileid); fxdr_nfsv3time(&fp->fa3_atime, &nap->na_atime); fxdr_nfsv3time(&fp->fa3_ctime, &nap->na_ctime); fxdr_nfsv3time(&fp->fa3_mtime, &nap->na_mtime); @@ -317,7 +316,7 @@ nfsm_loadattr(struct nfsrv_descript *nd, nap->na_bytes = (u_quad_t)fxdr_unsigned(int32_t, fp->fa2_blocks) * NFS_FABLKSIZE; - nap->na_fileid = fxdr_unsigned(int32_t, fp->fa2_fileid); + nap->na_fileid = fxdr_unsigned(uint64_t, fp->fa2_fileid); fxdr_nfsv2time(&fp->fa2_atime, &nap->na_atime); fxdr_nfsv2time(&fp->fa2_mtime, &nap->na_mtime); nap->na_flags = 0; Modified: head/sys/fs/nfsclient/nfs_clrpcops.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clrpcops.c Tue Mar 29 20:58:25 2011 (r220151) +++ head/sys/fs/nfsclient/nfs_clrpcops.c Wed Mar 30 01:10:11 2011 (r220152) @@ -2738,9 +2738,9 @@ nfsrpc_readdir(vnode_t vp, struct uio *u len = fxdr_unsigned(int, *tl); } else if (nd->nd_flag & ND_NFSV3) { NFSM_DISSECT(tl, u_int32_t *, 3*NFSX_UNSIGNED); - nfsva.na_fileid = - fxdr_unsigned(long, *++tl); - len = fxdr_unsigned(int, *++tl); + nfsva.na_fileid = fxdr_hyper(tl); + tl += 2; + len = fxdr_unsigned(int, *tl); } else { NFSM_DISSECT(tl, u_int32_t *, 2*NFSX_UNSIGNED); nfsva.na_fileid = From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 01:19: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 561C0106567B; Wed, 30 Mar 2011 01:19:01 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 442CC8FC1A; Wed, 30 Mar 2011 01:19:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2U1J1xq046344; Wed, 30 Mar 2011 01:19:01 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2U1J18L046334; Wed, 30 Mar 2011 01:19:01 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201103300119.p2U1J18L046334@svn.freebsd.org> From: Ed Maste Date: Wed, 30 Mar 2011 01:19:01 +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: r220153 - 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: Wed, 30 Mar 2011 01:19:01 -0000 Author: emaste Date: Wed Mar 30 01:19:00 2011 New Revision: 220153 URL: http://svn.freebsd.org/changeset/base/220153 Log: Replace ${SYSCTL_W} with ${SYSCTL} in rc.d scripts, as they are identical. This is a further clean up after r202988. SYSCTL_W is still initialized in rc.subr as some ports may still use it. Modified: head/etc/rc.d/faith head/etc/rc.d/hostid head/etc/rc.d/initrandom head/etc/rc.d/ipfw head/etc/rc.d/jail head/etc/rc.d/netoptions head/etc/rc.d/routing head/etc/rc.d/securelevel Modified: head/etc/rc.d/faith ============================================================================== --- head/etc/rc.d/faith Wed Mar 30 01:10:11 2011 (r220152) +++ head/etc/rc.d/faith Wed Mar 30 01:19:00 2011 (r220153) @@ -21,7 +21,7 @@ faith_up() *) echo "Configuring IPv6-to-IPv4 TCP relay capturing interface:" \ " faith0." - ${SYSCTL_W} net.inet6.ip6.keepfaith=1 + ${SYSCTL} net.inet6.ip6.keepfaith=1 ifconfig faith0 create >/dev/null 2>&1 ifconfig faith0 up for prefix in ${ipv6_faith_prefix}; do @@ -48,7 +48,7 @@ faith_down() { echo "Removing IPv6-to-IPv4 TCP relay capturing interface: faith0." ifconfig faith0 destroy - ${SYSCTL_W} net.inet6.ip6.keepfaith=0 + ${SYSCTL} net.inet6.ip6.keepfaith=0 case ${ipv6_faith_prefix} in [Nn][Oo] | '') Modified: head/etc/rc.d/hostid ============================================================================== --- head/etc/rc.d/hostid Wed Mar 30 01:10:11 2011 (r220152) +++ head/etc/rc.d/hostid Wed Mar 30 01:19:00 2011 (r220153) @@ -50,9 +50,9 @@ hostid_set() # Set both kern.hostuuid and kern.hostid. # check_startmsgs && echo "Setting hostuuid: ${uuid}." - ${SYSCTL_W} kern.hostuuid="${uuid}" >/dev/null + ${SYSCTL} kern.hostuuid="${uuid}" >/dev/null check_startmsgs && echo "Setting hostid: ${id}." - ${SYSCTL_W} kern.hostid=${id} >/dev/null + ${SYSCTL} kern.hostid=${id} >/dev/null } hostid_hardware() Modified: head/etc/rc.d/initrandom ============================================================================== --- head/etc/rc.d/initrandom Wed Mar 30 01:10:11 2011 (r220152) +++ head/etc/rc.d/initrandom Wed Mar 30 01:19:00 2011 (r220153) @@ -31,24 +31,24 @@ initrandom_start() if [ -w /dev/random ]; then if checkyesno harvest_interrupt; then - ${SYSCTL_W} kern.random.sys.harvest.interrupt=1 >/dev/null + ${SYSCTL} kern.random.sys.harvest.interrupt=1 >/dev/null echo -n ' interrupts' else - ${SYSCTL_W} kern.random.sys.harvest.interrupt=0 >/dev/null + ${SYSCTL} kern.random.sys.harvest.interrupt=0 >/dev/null fi if checkyesno harvest_ethernet; then - ${SYSCTL_W} kern.random.sys.harvest.ethernet=1 >/dev/null + ${SYSCTL} kern.random.sys.harvest.ethernet=1 >/dev/null echo -n ' ethernet' else - ${SYSCTL_W} kern.random.sys.harvest.ethernet=0 >/dev/null + ${SYSCTL} kern.random.sys.harvest.ethernet=0 >/dev/null fi if checkyesno harvest_p_to_p; then - ${SYSCTL_W} kern.random.sys.harvest.point_to_point=1 >/dev/null + ${SYSCTL} kern.random.sys.harvest.point_to_point=1 >/dev/null echo -n ' point_to_point' else - ${SYSCTL_W} kern.random.sys.harvest.point_to_point=0 >/dev/null + ${SYSCTL} kern.random.sys.harvest.point_to_point=0 >/dev/null fi fi Modified: head/etc/rc.d/ipfw ============================================================================== --- head/etc/rc.d/ipfw Wed Mar 30 01:10:11 2011 (r220152) +++ head/etc/rc.d/ipfw Wed Mar 30 01:19:00 2011 (r220153) @@ -73,11 +73,11 @@ ipfw_poststart() # Enable the firewall # - if ! ${SYSCTL_W} net.inet.ip.fw.enable=1 1>/dev/null 2>&1; then + if ! ${SYSCTL} net.inet.ip.fw.enable=1 1>/dev/null 2>&1; then warn "failed to enable IPv4 firewall" fi if afexists inet6; then - if ! ${SYSCTL_W} net.inet6.ip6.fw.enable=1 1>/dev/null 2>&1 + if ! ${SYSCTL} net.inet6.ip6.fw.enable=1 1>/dev/null 2>&1 then warn "failed to enable IPv6 firewall" fi @@ -90,9 +90,9 @@ ipfw_stop() # Disable the firewall # - ${SYSCTL_W} net.inet.ip.fw.enable=0 + ${SYSCTL} net.inet.ip.fw.enable=0 if afexists inet6; then - ${SYSCTL_W} net.inet6.ip6.fw.enable=0 + ${SYSCTL} net.inet6.ip6.fw.enable=0 fi # Stop firewall coscripts Modified: head/etc/rc.d/jail ============================================================================== --- head/etc/rc.d/jail Wed Mar 30 01:10:11 2011 (r220152) +++ head/etc/rc.d/jail Wed Mar 30 01:19:00 2011 (r220153) @@ -219,12 +219,12 @@ set_sysctl() if checkyesno $_knob ; then if [ "$_current" -ne 1 ]; then echo -n " ${_msg}=YES" - ${SYSCTL_W} 1>/dev/null ${_mib}=1 + ${SYSCTL} 1>/dev/null ${_mib}=1 fi else if [ "$_current" -ne 0 ]; then echo -n " ${_msg}=NO" - ${SYSCTL_W} 1>/dev/null ${_mib}=0 + ${SYSCTL} 1>/dev/null ${_mib}=0 fi fi } Modified: head/etc/rc.d/netoptions ============================================================================== --- head/etc/rc.d/netoptions Wed Mar 30 01:10:11 2011 (r220152) +++ head/etc/rc.d/netoptions Wed Mar 30 01:19:00 2011 (r220153) @@ -40,44 +40,44 @@ netoptions_inet() [12]) netoptions_init echo -n " log_in_vain=${log_in_vain}" - ${SYSCTL_W} net.inet.tcp.log_in_vain=${log_in_vain} >/dev/null - ${SYSCTL_W} net.inet.udp.log_in_vain=${log_in_vain} >/dev/null + ${SYSCTL} net.inet.tcp.log_in_vain=${log_in_vain} >/dev/null + ${SYSCTL} net.inet.udp.log_in_vain=${log_in_vain} >/dev/null ;; *) - ${SYSCTL_W} net.inet.tcp.log_in_vain=0 >/dev/null - ${SYSCTL_W} net.inet.udp.log_in_vain=0 >/dev/null + ${SYSCTL} net.inet.tcp.log_in_vain=0 >/dev/null + ${SYSCTL} net.inet.udp.log_in_vain=0 >/dev/null ;; esac if checkyesno tcp_extensions; then - ${SYSCTL_W} net.inet.tcp.rfc1323=1 >/dev/null + ${SYSCTL} net.inet.tcp.rfc1323=1 >/dev/null else netoptions_init echo -n " rfc1323 extensions=${tcp_extensions}" - ${SYSCTL_W} net.inet.tcp.rfc1323=0 >/dev/null + ${SYSCTL} net.inet.tcp.rfc1323=0 >/dev/null fi if checkyesno tcp_keepalive; then - ${SYSCTL_W} net.inet.tcp.always_keepalive=1 >/dev/null + ${SYSCTL} net.inet.tcp.always_keepalive=1 >/dev/null else netoptions_init echo -n " TCP keepalive=${tcp_keepalive}" - ${SYSCTL_W} net.inet.tcp.always_keepalive=0 >/dev/null + ${SYSCTL} net.inet.tcp.always_keepalive=0 >/dev/null fi if checkyesno tcp_drop_synfin; then netoptions_init echo -n " drop SYN+FIN packets=${tcp_drop_synfin}" - ${SYSCTL_W} net.inet.tcp.drop_synfin=1 >/dev/null + ${SYSCTL} net.inet.tcp.drop_synfin=1 >/dev/null else - ${SYSCTL_W} net.inet.tcp.drop_synfin=0 >/dev/null + ${SYSCTL} net.inet.tcp.drop_synfin=0 >/dev/null fi case ${ip_portrange_first} in [0-9]*) netoptions_init echo -n " ip_portrange_first=$ip_portrange_first" - ${SYSCTL_W} net.inet.ip.portrange.first=$ip_portrange_first >/dev/null + ${SYSCTL} net.inet.ip.portrange.first=$ip_portrange_first >/dev/null ;; esac @@ -85,7 +85,7 @@ netoptions_inet() [0-9]*) netoptions_init echo -n " ip_portrange_last=$ip_portrange_last" - ${SYSCTL_W} net.inet.ip.portrange.last=$ip_portrange_last >/dev/null + ${SYSCTL} net.inet.ip.portrange.last=$ip_portrange_last >/dev/null ;; esac } @@ -95,16 +95,16 @@ netoptions_inet6() if checkyesno ipv6_ipv4mapping; then netoptions_init echo -n " ipv4-mapped-ipv6=${ipv6_ipv4mapping}" - ${SYSCTL_W} net.inet6.ip6.v6only=0 >/dev/null + ${SYSCTL} net.inet6.ip6.v6only=0 >/dev/null else - ${SYSCTL_W} net.inet6.ip6.v6only=1 >/dev/null + ${SYSCTL} net.inet6.ip6.v6only=1 >/dev/null fi if checkyesno ipv6_privacy; then netoptions_init echo -n " IPv6 Privacy Addresses" - ${SYSCTL_W} net.inet6.ip6.use_tempaddr=1 >/dev/null - ${SYSCTL_W} net.inet6.ip6.prefer_tempaddr=1 >/dev/null + ${SYSCTL} net.inet6.ip6.use_tempaddr=1 >/dev/null + ${SYSCTL} net.inet6.ip6.prefer_tempaddr=1 >/dev/null fi } Modified: head/etc/rc.d/routing ============================================================================== --- head/etc/rc.d/routing Wed Mar 30 01:10:11 2011 (r220152) +++ head/etc/rc.d/routing Wed Mar 30 01:19:00 2011 (r220153) @@ -264,57 +264,57 @@ options_inet() if checkyesno icmp_bmcastecho; then ropts_init echo -n ' broadcast ping responses=YES' - ${SYSCTL_W} net.inet.icmp.bmcastecho=1 > /dev/null + ${SYSCTL} net.inet.icmp.bmcastecho=1 > /dev/null else - ${SYSCTL_W} net.inet.icmp.bmcastecho=0 > /dev/null + ${SYSCTL} net.inet.icmp.bmcastecho=0 > /dev/null fi if checkyesno icmp_drop_redirect; then ropts_init echo -n ' ignore ICMP redirect=YES' - ${SYSCTL_W} net.inet.icmp.drop_redirect=1 > /dev/null + ${SYSCTL} net.inet.icmp.drop_redirect=1 > /dev/null else - ${SYSCTL_W} net.inet.icmp.drop_redirect=0 > /dev/null + ${SYSCTL} net.inet.icmp.drop_redirect=0 > /dev/null fi if checkyesno icmp_log_redirect; then ropts_init echo -n ' log ICMP redirect=YES' - ${SYSCTL_W} net.inet.icmp.log_redirect=1 > /dev/null + ${SYSCTL} net.inet.icmp.log_redirect=1 > /dev/null else - ${SYSCTL_W} net.inet.icmp.log_redirect=0 > /dev/null + ${SYSCTL} net.inet.icmp.log_redirect=0 > /dev/null fi if checkyesno gateway_enable; then ropts_init echo -n ' IPv4 gateway=YES' - ${SYSCTL_W} net.inet.ip.forwarding=1 > /dev/null + ${SYSCTL} net.inet.ip.forwarding=1 > /dev/null else - ${SYSCTL_W} net.inet.ip.forwarding=0 > /dev/null + ${SYSCTL} net.inet.ip.forwarding=0 > /dev/null fi if checkyesno forward_sourceroute; then ropts_init echo -n ' do source routing=YES' - ${SYSCTL_W} net.inet.ip.sourceroute=1 > /dev/null + ${SYSCTL} net.inet.ip.sourceroute=1 > /dev/null else - ${SYSCTL_W} net.inet.ip.sourceroute=0 > /dev/null + ${SYSCTL} net.inet.ip.sourceroute=0 > /dev/null fi if checkyesno accept_sourceroute; then ropts_init echo -n ' accept source routing=YES' - ${SYSCTL_W} net.inet.ip.accept_sourceroute=1 > /dev/null + ${SYSCTL} net.inet.ip.accept_sourceroute=1 > /dev/null else - ${SYSCTL_W} net.inet.ip.accept_sourceroute=0 > /dev/null + ${SYSCTL} net.inet.ip.accept_sourceroute=0 > /dev/null fi if checkyesno arpproxy_all; then ropts_init echo -n ' ARP proxyall=YES' - ${SYSCTL_W} net.link.ether.inet.proxyall=1 > /dev/null + ${SYSCTL} net.link.ether.inet.proxyall=1 > /dev/null else - ${SYSCTL_W} net.link.ether.inet.proxyall=0 > /dev/null + ${SYSCTL} net.link.ether.inet.proxyall=0 > /dev/null fi } @@ -323,9 +323,9 @@ options_inet6() if checkyesno ipv6_gateway_enable; then ropts_init echo -n ' IPv6 gateway=YES' - ${SYSCTL_W} net.inet6.ip6.forwarding=1 > /dev/null + ${SYSCTL} net.inet6.ip6.forwarding=1 > /dev/null else - ${SYSCTL_W} net.inet6.ip6.forwarding=0 > /dev/null + ${SYSCTL} net.inet6.ip6.forwarding=0 > /dev/null fi } @@ -338,9 +338,9 @@ options_ipx() if checkyesno ipxgateway_enable; then ropts_init echo -n ' IPX gateway=YES' - ${SYSCTL_W} net.ipx.ipx.ipxforwarding=1 > /dev/null + ${SYSCTL} net.ipx.ipx.ipxforwarding=1 > /dev/null else - ${SYSCTL_W} net.ipx.ipx.ipxforwarding=0 > /dev/null + ${SYSCTL} net.ipx.ipx.ipxforwarding=0 > /dev/null fi } Modified: head/etc/rc.d/securelevel ============================================================================== --- head/etc/rc.d/securelevel Wed Mar 30 01:10:11 2011 (r220152) +++ head/etc/rc.d/securelevel Wed Mar 30 01:19:00 2011 (r220153) @@ -20,7 +20,7 @@ securelevel_start() { if [ ${kern_securelevel} -ge 0 ]; then echo 'Raising kernel security level: ' - ${SYSCTL_W} kern.securelevel=${kern_securelevel} + ${SYSCTL} kern.securelevel=${kern_securelevel} fi } From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 08:07: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 6B7821065670; Wed, 30 Mar 2011 08:07:25 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 383B98FC08; Wed, 30 Mar 2011 08:07:24 +0000 (UTC) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.4/8.14.4/NETPLEX) with ESMTP id p2U7oIFt015208; Wed, 30 Mar 2011 03:50:18 -0400 X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.2.6 (mail.netplex.net [204.213.176.10]); Wed, 30 Mar 2011 03:50:18 -0400 (EDT) Date: Wed, 30 Mar 2011 03:50:18 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: John Baldwin In-Reply-To: <201103291401.03565.jhb@freebsd.org> Message-ID: References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> <201103291401.03565.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, Randall Stewart , svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r217592 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen 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, 30 Mar 2011 08:07:25 -0000 On Tue, 29 Mar 2011, John Baldwin wrote: > On Wednesday, January 19, 2011 2:07:16 pm Randall Stewart wrote: >> Author: rrs >> Date: Wed Jan 19 19:07:16 2011 >> New Revision: 217592 >> URL: http://svn.freebsd.org/changeset/base/217592 >> >> Log: >> Fix a bug where Multicast packets sent from a >> udp endpoint may end up echoing back to the sender >> even with OUT joining the multi-cast group. >> >> Reviewed by: gnn, bms, bz? >> Obtained from: deischen (with help from) >> >> Modified: >> head/sys/netinet/udp_usrreq.c >> >> Modified: head/sys/netinet/udp_usrreq.c >> > ============================================================================== >> --- head/sys/netinet/udp_usrreq.c Wed Jan 19 18:20:11 2011 (r217591) >> +++ head/sys/netinet/udp_usrreq.c Wed Jan 19 19:07:16 2011 (r217592) >> @@ -479,11 +479,13 @@ udp_input(struct mbuf *m, int off) >> * and source-specific multicast. [RFC3678] >> */ >> imo = inp->inp_moptions; >> - if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && >> - imo != NULL) { >> + if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { >> struct sockaddr_in group; >> int blocked; >> - >> + if(imo == NULL) { >> + INP_RUNLOCK(inp); >> + continue; >> + } >> bzero(&group, sizeof(struct sockaddr_in)); >> group.sin_len = sizeof(struct sockaddr_in); >> group.sin_family = AF_INET; > > So it turns out that this is a feature, not a bug, and is how multicast has > always worked. Specifically, if you bind a UDP socket with a wildcard > address, it should receive all traffic for the bound port, unicast or > multicast. When you join a group, you have switched the socket into a mode > where it now has a whitelist of acceptable multicast groups, but if a socket > has no joined groups, it should receive all multicast traffic, not none. This > change breaks that. > > I did not find this behavior intuitive at first, but it does seem to be > required. Note the description of IP_ADD_MEMBERSHIP from RFC 3678 for > example: > > 3. Overview of APIs > > There are a number of different APIs described in this document that > are appropriate for a number of different application types and IP > versions. Before providing detailed descriptions, this section > provides a "taxonomy" with a brief description of each. > > There are two categories of source-filter APIs, both of which are > designed to allow multicast receiver applications to designate the > unicast address(es) of sender(s) along with the multicast group > (destination address) to receive. > > o Basic (Delta-based): Some applications desire the simplicity of > a delta-based API in which each function call specifies a > single source address which should be added to or removed from > the existing filter for a given multicast group address on > which to listen. Such applications typically fall into either > of two categories: > > + Any-Source Multicast: By default, all sources are accepted. > Individual sources may be turned off and back on as needed > over time. This is also known as "exclude" mode, since the > source filter contains a list of excluded sources. > > + Source-Specific Multicast: Only sources in a given list are > allowed. The list may change over time. This is also known > as "include" mode, since the source filter contains a list > of included sources. > > This API would be used, for example, by "single-source" > applications such as audio/video broadcasting. It would > also be used for logical multi-source sessions where each > source independently allocates its own Source-Specific > Multicast group address. > > > ..... > > 4.1.1. IPv4 Any-Source Multicast API > > The following socket options are defined in for > applications in the Any-Source Multicast category: > > Socket option Argument type > IP_ADD_MEMBERSHIP struct ip_mreq > IP_BLOCK_SOURCE struct ip_mreq_source > IP_UNBLOCK_SOURCE struct ip_mreq_source > IP_DROP_MEMBERSHIP struct ip_mreq > > IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP are already implemented on > most operating systems, and are used to join and leave an any-source > group. > > IP_BLOCK_SOURCE can be used to block data from a given source to a > given group (e.g., if the user "mutes" that source), and > IP_UNBLOCK_SOURCE can be used to undo this (e.g., if the user then > "unmutes" the source). > > As to why the packets loop back to the receiver, I believe that is a separate > issue on the output side, not the receive side. That may be, but the behavior is undesired if the no process on the system has joined the multicast group. I believe it was broke with r189359, and the comment in the code that broke it says: /* * Loop back multicast datagram if not expressly * forbidden to do so, even if we are not a member * of the group; ip_input() will filter it later, * thus deferring a hash lookup and mutex acquisition * at the expense of a cheap copy using m_copym(). */ The previous revision did a lookup of the multicast address and looped it if an entry was found for it. -- DE From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 08:22: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 A6EEB1065675; Wed, 30 Mar 2011 08:22:29 +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 93CA88FC15; Wed, 30 Mar 2011 08:22:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2U8MTBC057056; Wed, 30 Mar 2011 08:22:29 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2U8MT2E057047; Wed, 30 Mar 2011 08:22:29 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201103300822.p2U8MT2E057047@svn.freebsd.org> From: Ed Schouten Date: Wed, 30 Mar 2011 08:22: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: r220154 - in head/etc: etc.amd64 etc.arm etc.i386 etc.ia64 etc.mips etc.pc98 etc.powerpc etc.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: Wed, 30 Mar 2011 08:22:29 -0000 Author: ed Date: Wed Mar 30 08:22:29 2011 New Revision: 220154 URL: http://svn.freebsd.org/changeset/base/220154 Log: Remove the reference to pseudo-terminals from the description. Pseudo-terminals are no longer listed in this file, since the utmpx implementation doesn't depend on ttyslot(). Modified: head/etc/etc.amd64/ttys head/etc/etc.arm/ttys head/etc/etc.i386/ttys head/etc/etc.ia64/ttys head/etc/etc.mips/ttys head/etc/etc.pc98/ttys head/etc/etc.powerpc/ttys head/etc/etc.sparc64/ttys Modified: head/etc/etc.amd64/ttys ============================================================================== --- head/etc/etc.amd64/ttys Wed Mar 30 01:19:00 2011 (r220153) +++ head/etc/etc.amd64/ttys Wed Mar 30 08:22:29 2011 (r220154) @@ -16,9 +16,8 @@ # type The initial terminal type for this port. For hardwired # terminal lines, this will contain the type of terminal used. # For virtual consoles, the correct type is typically xterm. -# Other common values include network for network connections on -# pseudo-terminals, dialup for incoming modem ports, and unknown -# when the terminal type cannot be predetermined. +# Other common values include dialup for incoming modem ports, and +# unknown when the terminal type cannot be predetermined. # # status Must be on or off. If on, init will run the getty program on # the specified port. If the word "secure" appears, this tty Modified: head/etc/etc.arm/ttys ============================================================================== --- head/etc/etc.arm/ttys Wed Mar 30 01:19:00 2011 (r220153) +++ head/etc/etc.arm/ttys Wed Mar 30 08:22:29 2011 (r220154) @@ -16,9 +16,8 @@ # type The initial terminal type for this port. For hardwired # terminal lines, this will contain the type of terminal used. # For virtual consoles, the correct type is typically xterm. -# Other common values include network for network connections on -# pseudo-terminals, dialup for incoming modem ports, and unknown -# when the terminal type cannot be predetermined. +# Other common values include dialup for incoming modem ports, and +# unknown when the terminal type cannot be predetermined. # # status Must be on or off. If on, init will run the getty program on # the specified port. If the word "secure" appears, this tty Modified: head/etc/etc.i386/ttys ============================================================================== --- head/etc/etc.i386/ttys Wed Mar 30 01:19:00 2011 (r220153) +++ head/etc/etc.i386/ttys Wed Mar 30 08:22:29 2011 (r220154) @@ -16,9 +16,8 @@ # type The initial terminal type for this port. For hardwired # terminal lines, this will contain the type of terminal used. # For virtual consoles, the correct type is typically xterm. -# Other common values include network for network connections on -# pseudo-terminals, dialup for incoming modem ports, and unknown -# when the terminal type cannot be predetermined. +# Other common values include dialup for incoming modem ports, and +# unknown when the terminal type cannot be predetermined. # # status Must be on or off. If on, init will run the getty program on # the specified port. If the word "secure" appears, this tty Modified: head/etc/etc.ia64/ttys ============================================================================== --- head/etc/etc.ia64/ttys Wed Mar 30 01:19:00 2011 (r220153) +++ head/etc/etc.ia64/ttys Wed Mar 30 08:22:29 2011 (r220154) @@ -16,9 +16,8 @@ # type The initial terminal type for this port. For hardwired # terminal lines, this will contain the type of terminal used. # For virtual consoles, the correct type is typically xterm. -# Other common values include network for network connections on -# pseudo-terminals, dialup for incoming modem ports, and unknown -# when the terminal type cannot be predetermined. +# Other common values include dialup for incoming modem ports, and +# unknown when the terminal type cannot be predetermined. # # status Must be on or off. If on, init will run the getty program on # the specified port. If the word "secure" appears, this tty Modified: head/etc/etc.mips/ttys ============================================================================== --- head/etc/etc.mips/ttys Wed Mar 30 01:19:00 2011 (r220153) +++ head/etc/etc.mips/ttys Wed Mar 30 08:22:29 2011 (r220154) @@ -16,9 +16,8 @@ # type The initial terminal type for this port. For hardwired # terminal lines, this will contain the type of terminal used. # For virtual consoles, the correct type is typically xterm. -# Other common values include network for network connections on -# pseudo-terminals, dialup for incoming modem ports, and unknown -# when the terminal type cannot be predetermined. +# Other common values include dialup for incoming modem ports, and +# unknown when the terminal type cannot be predetermined. # # status Must be on or off. If on, init will run the getty program on # the specified port. If the word "secure" appears, this tty Modified: head/etc/etc.pc98/ttys ============================================================================== --- head/etc/etc.pc98/ttys Wed Mar 30 01:19:00 2011 (r220153) +++ head/etc/etc.pc98/ttys Wed Mar 30 08:22:29 2011 (r220154) @@ -16,9 +16,8 @@ # type The initial terminal type for this port. For hardwired # terminal lines, this will contain the type of terminal used. # For virtual consoles, the correct type is typically cons25w. -# Other common values include network for network connections on -# pseudo-terminals, dialup for incoming modem ports, and unknown -# when the terminal type cannot be predetermined. +# Other common values include dialup for incoming modem ports, and +# unknown when the terminal type cannot be predetermined. # # status Must be on or off. If on, init will run the getty program on # the specified port. If the word "secure" appears, this tty Modified: head/etc/etc.powerpc/ttys ============================================================================== --- head/etc/etc.powerpc/ttys Wed Mar 30 01:19:00 2011 (r220153) +++ head/etc/etc.powerpc/ttys Wed Mar 30 08:22:29 2011 (r220154) @@ -16,9 +16,8 @@ # type The initial terminal type for this port. For hardwired # terminal lines, this will contain the type of terminal used. # For virtual consoles, the correct type is typically xterm. -# Other common values include network for network connections on -# pseudo-terminals, dialup for incoming modem ports, and unknown -# when the terminal type cannot be predetermined. +# Other common values include dialup for incoming modem ports, and +# unknown when the terminal type cannot be predetermined. # # status Must be on or off. If on, init will run the getty program on # the specified port. If the word "secure" appears, this tty Modified: head/etc/etc.sparc64/ttys ============================================================================== --- head/etc/etc.sparc64/ttys Wed Mar 30 01:19:00 2011 (r220153) +++ head/etc/etc.sparc64/ttys Wed Mar 30 08:22:29 2011 (r220154) @@ -16,9 +16,8 @@ # type The initial terminal type for this port. For hardwired # terminal lines, this will contain the type of terminal used. # For virtual consoles, the correct type is typically xterm. -# Other common values include network for network connections on -# pseudo-terminals, dialup for incoming modem ports, and unknown -# when the terminal type cannot be predetermined. +# Other common values include dialup for incoming modem ports, and +# unknown when the terminal type cannot be predetermined. # # status Must be on or off. If on, init will run the getty program on # the specified port. If the word "secure" appears, this tty From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 11:27:43 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 6F718106566B; Wed, 30 Mar 2011 11:27:43 +0000 (UTC) (envelope-from rrs@lakerest.net) Received: from lakerest.net (unknown [IPv6:2001:240:585:2:213:d4ff:fef3:2d8d]) by mx1.freebsd.org (Postfix) with ESMTP id F18358FC12; Wed, 30 Mar 2011 11:27:42 +0000 (UTC) Received: from dhcp-54bc.meeting.ietf.org (dhcp-54bc.meeting.ietf.org [130.129.84.188]) (authenticated bits=0) by lakerest.net (8.14.4/8.14.3) with ESMTP id p2UBRbO7098163 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Wed, 30 Mar 2011 07:27:39 -0400 (EDT) (envelope-from rrs@lakerest.net) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Randall Stewart In-Reply-To: <201103291401.03565.jhb@freebsd.org> Date: Wed, 30 Mar 2011 07:27:36 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: <99FEFE99-455A-4A28-8C02-08DFAD28B6CD@lakerest.net> References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> <201103291401.03565.jhb@freebsd.org> To: John Baldwin X-Mailer: Apple Mail (2.1084) Cc: svn-src-head@FreeBSD.org, Daniel Eischen , svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r217592 - 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: Wed, 30 Mar 2011 11:27:43 -0000 John: The original complaint on this came from Daniel... I believe he claimed that up until bms's multi-cast work.. you would NOT get a packet sent to you if you did not join the multi-cast group. I will also comment in-line below... On Mar 29, 2011, at 2:01 PM, John Baldwin wrote: > On Wednesday, January 19, 2011 2:07:16 pm Randall Stewart wrote: >> Author: rrs >> Date: Wed Jan 19 19:07:16 2011 >> New Revision: 217592 >> URL: http://svn.freebsd.org/changeset/base/217592 >>=20 >> Log: >> Fix a bug where Multicast packets sent from a >> udp endpoint may end up echoing back to the sender >> even with OUT joining the multi-cast group. >>=20 >> Reviewed by: gnn, bms, bz? >> Obtained from: deischen (with help from) >>=20 >> Modified: >> head/sys/netinet/udp_usrreq.c >>=20 >> Modified: head/sys/netinet/udp_usrreq.c >>=20 > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/netinet/udp_usrreq.c Wed Jan 19 18:20:11 2011 = (r217591) >> +++ head/sys/netinet/udp_usrreq.c Wed Jan 19 19:07:16 2011 = (r217592) >> @@ -479,11 +479,13 @@ udp_input(struct mbuf *m, int off) >> * and source-specific multicast. [RFC3678] >> */ >> imo =3D inp->inp_moptions; >> - if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && >> - imo !=3D NULL) { >> + if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { >> struct sockaddr_in group; >> int blocked; >> - >> + if(imo =3D=3D NULL) { >> + INP_RUNLOCK(inp); >> + continue; >> + } >> bzero(&group, sizeof(struct = sockaddr_in)); >> group.sin_len =3D sizeof(struct = sockaddr_in); >> group.sin_family =3D AF_INET; >=20 > So it turns out that this is a feature, not a bug, and is how = multicast has=20 > always worked. Specifically, if you bind a UDP socket with a wildcard=20= > address, it should receive all traffic for the bound port, unicast or=20= > multicast. When you join a group, you have switched the socket into a = mode=20 > where it now has a whitelist of acceptable multicast groups, but if a = socket=20 > has no joined groups, it should receive all multicast traffic, not = none. This=20 > change breaks that. >=20 > I did not find this behavior intuitive at first, but it does seem to = be=20 > required. Note the description of IP_ADD_MEMBERSHIP from RFC 3678 for=20= > example: I agree getting a packet that is coming to your port without joining the multi-cast group is not intuitive to me...=20 >=20 > 3. Overview of APIs >=20 > There are a number of different APIs described in this document that > are appropriate for a number of different application types and IP > versions. Before providing detailed descriptions, this section > provides a "taxonomy" with a brief description of each. >=20 > There are two categories of source-filter APIs, both of which are > designed to allow multicast receiver applications to designate the > unicast address(es) of sender(s) along with the multicast group > (destination address) to receive. >=20 > o Basic (Delta-based): Some applications desire the simplicity = of > a delta-based API in which each function call specifies a > single source address which should be added to or removed from > the existing filter for a given multicast group address on > which to listen. Such applications typically fall into either > of two categories: >=20 > + Any-Source Multicast: By default, all sources are accepted. > Individual sources may be turned off and back on as needed > over time. This is also known as "exclude" mode, since the > source filter contains a list of excluded sources. >=20 > + Source-Specific Multicast: Only sources in a given list are > allowed. The list may change over time. This is also = known > as "include" mode, since the source filter contains a list > of included sources. >=20 > This API would be used, for example, by "single-source" > applications such as audio/video broadcasting. It would > also be used for logical multi-source sessions where each > source independently allocates its own Source-Specific > Multicast group address. Not the above document is talking about a receiver that as joined the multicast group (or is joining it and wants some filtering)... I don't see how that applies to a UDP socket that has NOT joined the M-cast = group.. >=20 >=20 > ..... >=20 > 4.1.1. IPv4 Any-Source Multicast API >=20 > The following socket options are defined in for > applications in the Any-Source Multicast category: >=20 > Socket option Argument type > IP_ADD_MEMBERSHIP struct ip_mreq > IP_BLOCK_SOURCE struct ip_mreq_source > IP_UNBLOCK_SOURCE struct ip_mreq_source > IP_DROP_MEMBERSHIP struct ip_mreq >=20 > IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP are already implemented on > most operating systems, and are used to join and leave an any-source > group. >=20 > IP_BLOCK_SOURCE can be used to block data from a given source to a > given group (e.g., if the user "mutes" that source), and > IP_UNBLOCK_SOURCE can be used to undo this (e.g., if the user then > "unmutes" the source). >=20 > As to why the packets loop back to the receiver, I believe that is a = separate=20 > issue on the output side, not the receive side. But that is what the commit fixes... and as to the above, it again is talking about Multicast members.. AFAIKT... I am actually at the IETF so if you would like I can gladly go talk to the authors of this RFC (if they are here) and get their opinion on this. One other thing.. note this is NOT a standard but a informational RFC. = Informational RFC are guidelines and NOT mandatory at all.. there will never be a = MUST/SHOULD etc within them. I see that the authors are Dave Thaler, Bill Fenner and B Quinn I don't know B Quinn.. not sure if Fenner is here (have not seen him).. = but I have seen Dave around.. I will look him up and ask him his opinion.. R >=20 > --=20 > John Baldwin >=20 ------------------------------ Randall Stewart 803-317-4952 (cell) From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 11:34: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 78EA0106564A; Wed, 30 Mar 2011 11:34:40 +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 69A6C8FC15; Wed, 30 Mar 2011 11:34:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UBYemL062387; Wed, 30 Mar 2011 11:34:40 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UBYenv062385; Wed, 30 Mar 2011 11:34:40 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201103301134.p2UBYenv062385@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Wed, 30 Mar 2011 11:34: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: r220155 - 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: Wed, 30 Mar 2011 11:34:40 -0000 Author: ae Date: Wed Mar 30 11:34:40 2011 New Revision: 220155 URL: http://svn.freebsd.org/changeset/base/220155 Log: Remove duplicate sentence. Modified: head/share/man/man9/sbuf.9 Modified: head/share/man/man9/sbuf.9 ============================================================================== --- head/share/man/man9/sbuf.9 Wed Mar 30 08:22:29 2011 (r220154) +++ head/share/man/man9/sbuf.9 Wed Mar 30 11:34:40 2011 (r220155) @@ -395,10 +395,6 @@ returns the length of the un-drained dat returns non-zero if the .Fa sbuf is finished. -.Fn sbuf_done -returns non-zero if the -.Fa sbuf -is finished. .Sh NOTES If an operation caused an .Fa sbuf From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 12:27: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 DE9C8106564A; Wed, 30 Mar 2011 12:27:27 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id A245D8FC14; Wed, 30 Mar 2011 12:27:27 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 414F146B4C; Wed, 30 Mar 2011 08:27:27 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id CE4658A027; Wed, 30 Mar 2011 08:27:26 -0400 (EDT) From: John Baldwin To: Randall Stewart Date: Wed, 30 Mar 2011 08:23:53 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> <201103291401.03565.jhb@freebsd.org> <99FEFE99-455A-4A28-8C02-08DFAD28B6CD@lakerest.net> In-Reply-To: <99FEFE99-455A-4A28-8C02-08DFAD28B6CD@lakerest.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201103300823.53986.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Wed, 30 Mar 2011 08:27:26 -0400 (EDT) Cc: svn-src-head@freebsd.org, Daniel Eischen , svn-src-all@freebsd.org, src-committers@freebsd.org, George Neville-Neil Subject: Re: svn commit: r217592 - 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: Wed, 30 Mar 2011 12:27:28 -0000 On Wednesday, March 30, 2011 7:27:36 am Randall Stewart wrote: > John: > > The original complaint on this came from Daniel... I believe he > claimed that up until bms's multi-cast work.. you would NOT > get a packet sent to you if you did not join the multi-cast group. Not necessarily. :( See below.. > I will also comment in-line below... > > On Mar 29, 2011, at 2:01 PM, John Baldwin wrote: > > > On Wednesday, January 19, 2011 2:07:16 pm Randall Stewart wrote: > >> Author: rrs > >> Date: Wed Jan 19 19:07:16 2011 > >> New Revision: 217592 > >> URL: http://svn.freebsd.org/changeset/base/217592 > >> > >> Log: > >> Fix a bug where Multicast packets sent from a > >> udp endpoint may end up echoing back to the sender > >> even with OUT joining the multi-cast group. > >> > >> Reviewed by: gnn, bms, bz? > >> Obtained from: deischen (with help from) > >> > >> Modified: > >> head/sys/netinet/udp_usrreq.c > >> > >> Modified: head/sys/netinet/udp_usrreq.c > >> > > ============================================================================== > >> --- head/sys/netinet/udp_usrreq.c Wed Jan 19 18:20:11 2011 (r217591) > >> +++ head/sys/netinet/udp_usrreq.c Wed Jan 19 19:07:16 2011 (r217592) > >> @@ -479,11 +479,13 @@ udp_input(struct mbuf *m, int off) > >> * and source-specific multicast. [RFC3678] > >> */ > >> imo = inp->inp_moptions; > >> - if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && > >> - imo != NULL) { > >> + if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { > >> struct sockaddr_in group; > >> int blocked; > >> - > >> + if(imo == NULL) { > >> + INP_RUNLOCK(inp); > >> + continue; > >> + } > >> bzero(&group, sizeof(struct sockaddr_in)); > >> group.sin_len = sizeof(struct sockaddr_in); > >> group.sin_family = AF_INET; > > > > So it turns out that this is a feature, not a bug, and is how multicast has > > always worked. Specifically, if you bind a UDP socket with a wildcard > > address, it should receive all traffic for the bound port, unicast or > > multicast. When you join a group, you have switched the socket into a mode > > where it now has a whitelist of acceptable multicast groups, but if a socket > > has no joined groups, it should receive all multicast traffic, not none. This > > change breaks that. > > > > I did not find this behavior intuitive at first, but it does seem to be > > required. Note the description of IP_ADD_MEMBERSHIP from RFC 3678 for > > example: > > > I agree getting a packet that is coming to your port without joining the > multi-cast group is not intuitive to me... > > > > > 3. Overview of APIs > > > > There are a number of different APIs described in this document that > > are appropriate for a number of different application types and IP > > versions. Before providing detailed descriptions, this section > > provides a "taxonomy" with a brief description of each. > > > > There are two categories of source-filter APIs, both of which are > > designed to allow multicast receiver applications to designate the > > unicast address(es) of sender(s) along with the multicast group > > (destination address) to receive. > > > > o Basic (Delta-based): Some applications desire the simplicity of > > a delta-based API in which each function call specifies a > > single source address which should be added to or removed from > > the existing filter for a given multicast group address on > > which to listen. Such applications typically fall into either > > of two categories: > > > > + Any-Source Multicast: By default, all sources are accepted. > > Individual sources may be turned off and back on as needed > > over time. This is also known as "exclude" mode, since the > > source filter contains a list of excluded sources. > > > > + Source-Specific Multicast: Only sources in a given list are > > allowed. The list may change over time. This is also known > > as "include" mode, since the source filter contains a list > > of included sources. > > > > This API would be used, for example, by "single-source" > > applications such as audio/video broadcasting. It would > > also be used for logical multi-source sessions where each > > source independently allocates its own Source-Specific > > Multicast group address. > > > Not the above document is talking about a receiver that as joined the > multicast group (or is joining it and wants some filtering)... I don't > see how that applies to a UDP socket that has NOT joined the M-cast group.. > > > > > > > ..... > > > > 4.1.1. IPv4 Any-Source Multicast API > > > > The following socket options are defined in for > > applications in the Any-Source Multicast category: > > > > Socket option Argument type > > IP_ADD_MEMBERSHIP struct ip_mreq > > IP_BLOCK_SOURCE struct ip_mreq_source > > IP_UNBLOCK_SOURCE struct ip_mreq_source > > IP_DROP_MEMBERSHIP struct ip_mreq > > > > IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP are already implemented on > > most operating systems, and are used to join and leave an any-source > > group. > > > > IP_BLOCK_SOURCE can be used to block data from a given source to a > > given group (e.g., if the user "mutes" that source), and > > IP_UNBLOCK_SOURCE can be used to undo this (e.g., if the user then > > "unmutes" the source). > > > > As to why the packets loop back to the receiver, I believe that is a separate > > issue on the output side, not the receive side. > > > > But that is what the commit fixes... Except you change receive, not transmit. I think the error in Daniel's case is on the transmit side, not receive. I would be happy to know what the true "official" behavior is for a socket that binds to INADDR_ANY but does not join any groups. As far as prior to BMS's changes: in the older version of udp_input() we only checked the membership list if inp->inp_moptions was != NULL. If it was NULL, we would send all multicast packets to a given socket for which the address fields matched (addr, port). BMS preserved this behavior and your patch changes it. UDP sockets start off with inp_moptions == NULL, so if you never do any multicast-related setsockopt() you will receive all matching multicast packets. However, once you do any multicast-related setsockopt() (IP_MULTICAST_LOOP, IP_ADD_MEMBERSHIP, etc.) then inp_moptions is allocated and is non-NULL. At that point it only accepts packets that match, except that even then we used a sysctl which defaulted to off (!) to see if we should check the list of memberships (net.inet.udp.strict_mcast_mship). This options structure was never free'd, however, so you could get the truly bizarre behavior of: - bind a new socket, it will not receive all matching multicast traffic - use IP_ADD_MEMBERSHIP to add a group, it will now receive only matching multicast traffic for the group - use IP_DROP_MEMBERSHIP to remove the group, it will now receive no multicast traffic The different behavior in states 1 and 3 I find confusing and odd. By default all sockets just always received all matching multicast traffic though. :) However, this change is not restoring "old" behavior, it is a change in behavior compared to the pre-BMS changes. > and as to the above, it again is > talking about Multicast members.. AFAIKT... I am actually at the IETF > so if you would like I can gladly go talk to the authors of this RFC > (if they are here) and get their opinion on this. > > One other thing.. note this is NOT a standard but a informational RFC. Informational > RFC are guidelines and NOT mandatory at all.. there will never be a MUST/SHOULD etc > within them. Well, for lack of anything else I was looking to that. I would really prefer the behavior in your change as I find it far more intuitive. I wasn't able to find anything else in Stevens or elsewhere that seemed to indicate what the proper behavior was beyond this. > I see that the authors are Dave Thaler, Bill Fenner and B Quinn > > I don't know B Quinn.. not sure if Fenner is here (have not seen him).. but I have > seen Dave around.. I will look him up and ask him his opinion.. > > R > > > > > > -- > > John Baldwin > > > > ------------------------------ > Randall Stewart > 803-317-4952 (cell) > > -- John Baldwin From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 12:27: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 4F76E1065673; Wed, 30 Mar 2011 12:27:28 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 24E6F8FC15; Wed, 30 Mar 2011 12:27:28 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id AC17E46B0D; Wed, 30 Mar 2011 08:27:27 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 372F58A02A; Wed, 30 Mar 2011 08:27:27 -0400 (EDT) From: John Baldwin To: Daniel Eischen Date: Wed, 30 Mar 2011 08:27:25 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> <201103291401.03565.jhb@freebsd.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201103300827.25260.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Wed, 30 Mar 2011 08:27:27 -0400 (EDT) Cc: svn-src-head@freebsd.org, Randall Stewart , svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r217592 - 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: Wed, 30 Mar 2011 12:27:28 -0000 On Wednesday, March 30, 2011 3:50:18 am Daniel Eischen wrote: > On Tue, 29 Mar 2011, John Baldwin wrote: > > > On Wednesday, January 19, 2011 2:07:16 pm Randall Stewart wrote: > >> Author: rrs > >> Date: Wed Jan 19 19:07:16 2011 > >> New Revision: 217592 > >> URL: http://svn.freebsd.org/changeset/base/217592 > >> > >> Log: > >> Fix a bug where Multicast packets sent from a > >> udp endpoint may end up echoing back to the sender > >> even with OUT joining the multi-cast group. > >> > >> Reviewed by: gnn, bms, bz? > >> Obtained from: deischen (with help from) > >> > >> Modified: > >> head/sys/netinet/udp_usrreq.c > >> > >> Modified: head/sys/netinet/udp_usrreq.c > >> > > ============================================================================== > >> --- head/sys/netinet/udp_usrreq.c Wed Jan 19 18:20:11 2011 (r217591) > >> +++ head/sys/netinet/udp_usrreq.c Wed Jan 19 19:07:16 2011 (r217592) > >> @@ -479,11 +479,13 @@ udp_input(struct mbuf *m, int off) > >> * and source-specific multicast. [RFC3678] > >> */ > >> imo = inp->inp_moptions; > >> - if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && > >> - imo != NULL) { > >> + if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { > >> struct sockaddr_in group; > >> int blocked; > >> - > >> + if(imo == NULL) { > >> + INP_RUNLOCK(inp); > >> + continue; > >> + } > >> bzero(&group, sizeof(struct sockaddr_in)); > >> group.sin_len = sizeof(struct sockaddr_in); > >> group.sin_family = AF_INET; > > > > So it turns out that this is a feature, not a bug, and is how multicast has > > always worked. Specifically, if you bind a UDP socket with a wildcard > > address, it should receive all traffic for the bound port, unicast or > > multicast. When you join a group, you have switched the socket into a mode > > where it now has a whitelist of acceptable multicast groups, but if a socket > > has no joined groups, it should receive all multicast traffic, not none. This > > change breaks that. > > > > I did not find this behavior intuitive at first, but it does seem to be > > required. Note the description of IP_ADD_MEMBERSHIP from RFC 3678 for > > example: > > > > 3. Overview of APIs > > > > There are a number of different APIs described in this document that > > are appropriate for a number of different application types and IP > > versions. Before providing detailed descriptions, this section > > provides a "taxonomy" with a brief description of each. > > > > There are two categories of source-filter APIs, both of which are > > designed to allow multicast receiver applications to designate the > > unicast address(es) of sender(s) along with the multicast group > > (destination address) to receive. > > > > o Basic (Delta-based): Some applications desire the simplicity of > > a delta-based API in which each function call specifies a > > single source address which should be added to or removed from > > the existing filter for a given multicast group address on > > which to listen. Such applications typically fall into either > > of two categories: > > > > + Any-Source Multicast: By default, all sources are accepted. > > Individual sources may be turned off and back on as needed > > over time. This is also known as "exclude" mode, since the > > source filter contains a list of excluded sources. > > > > + Source-Specific Multicast: Only sources in a given list are > > allowed. The list may change over time. This is also known > > as "include" mode, since the source filter contains a list > > of included sources. > > > > This API would be used, for example, by "single-source" > > applications such as audio/video broadcasting. It would > > also be used for logical multi-source sessions where each > > source independently allocates its own Source-Specific > > Multicast group address. > > > > > > ..... > > > > 4.1.1. IPv4 Any-Source Multicast API > > > > The following socket options are defined in for > > applications in the Any-Source Multicast category: > > > > Socket option Argument type > > IP_ADD_MEMBERSHIP struct ip_mreq > > IP_BLOCK_SOURCE struct ip_mreq_source > > IP_UNBLOCK_SOURCE struct ip_mreq_source > > IP_DROP_MEMBERSHIP struct ip_mreq > > > > IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP are already implemented on > > most operating systems, and are used to join and leave an any-source > > group. > > > > IP_BLOCK_SOURCE can be used to block data from a given source to a > > given group (e.g., if the user "mutes" that source), and > > IP_UNBLOCK_SOURCE can be used to undo this (e.g., if the user then > > "unmutes" the source). > > > > As to why the packets loop back to the receiver, I believe that is a separate > > issue on the output side, not the receive side. > > That may be, but the behavior is undesired if the no process > on the system has joined the multicast group. I believe it > was broke with r189359, and the comment in the code that broke > it says: > > /* > * Loop back multicast datagram if not expressly > * forbidden to do so, even if we are not a member > * of the group; ip_input() will filter it later, > * thus deferring a hash lookup and mutex acquisition > * at the expense of a cheap copy using m_copym(). > */ > > The previous revision did a lookup of the multicast address > and looped it if an entry was found for it. Well, for one, this patch changes the behavior even if there is a socket joined to the group. However, I suspect that in your case your app should probably be turning IP_MULTICAST_LOOP off explicitly regardless of what the changes end up being (or do you write to multiple groups and want a subset of those groups to loop back?). -- John Baldwin From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 12:35: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 0C5E6106566B; Wed, 30 Mar 2011 12:35:40 +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 F16CC8FC08; Wed, 30 Mar 2011 12:35:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UCZds1063677; Wed, 30 Mar 2011 12:35:39 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UCZdwP063675; Wed, 30 Mar 2011 12:35:39 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201103301235.p2UCZdwP063675@svn.freebsd.org> From: John Baldwin Date: Wed, 30 Mar 2011 12:35: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: r220156 - 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: Wed, 30 Mar 2011 12:35:40 -0000 Author: jhb Date: Wed Mar 30 12:35:39 2011 New Revision: 220156 URL: http://svn.freebsd.org/changeset/base/220156 Log: Clamp the initial advertised receive window when responding to a SYN/ACK to the maximum allowed window. Growing the window too large would cause an underflow in the calculations in tcp_output() to decide if a window update should be sent which would prevent the persist timer from being started if data was pending and the other end of the connection advertised an initial window size of 0. PR: kern/154006 Submitted by: Stefan `Sec` Zehl sec 42 org Reviewed by: bz MFC after: 1 week Modified: head/sys/netinet/tcp_input.c Modified: head/sys/netinet/tcp_input.c ============================================================================== --- head/sys/netinet/tcp_input.c Wed Mar 30 11:34:40 2011 (r220155) +++ head/sys/netinet/tcp_input.c Wed Mar 30 12:35:39 2011 (r220156) @@ -1756,7 +1756,8 @@ tcp_do_segment(struct mbuf *m, struct tc (TF_RCVD_SCALE|TF_REQ_SCALE)) { tp->rcv_scale = tp->request_r_scale; } - tp->rcv_adv += tp->rcv_wnd; + tp->rcv_adv += imin(tp->rcv_wnd, + TCP_MAXWIN << tp->rcv_scale); tp->snd_una++; /* SYN is acked */ /* * If there's data, delay ACK; if there's also a FIN From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 14:15: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 833501065686; Wed, 30 Mar 2011 14:15:18 +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 732E08FC0C; Wed, 30 Mar 2011 14:15:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UEFIC2065842; Wed, 30 Mar 2011 14:15:18 GMT (envelope-from pluknet@svn.freebsd.org) Received: (from pluknet@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UEFIkU065840; Wed, 30 Mar 2011 14:15:18 GMT (envelope-from pluknet@svn.freebsd.org) Message-Id: <201103301415.p2UEFIkU065840@svn.freebsd.org> From: Sergey Kandaurov Date: Wed, 30 Mar 2011 14:15: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: r220157 - head/lib/libc/gen 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, 30 Mar 2011 14:15:18 -0000 Author: pluknet Date: Wed Mar 30 14:15:18 2011 New Revision: 220157 URL: http://svn.freebsd.org/changeset/base/220157 Log: Use FD_CLOEXEC explicitly. MFC after: 3 days Modified: head/lib/libc/gen/syslog.c Modified: head/lib/libc/gen/syslog.c ============================================================================== --- head/lib/libc/gen/syslog.c Wed Mar 30 12:35:39 2011 (r220156) +++ head/lib/libc/gen/syslog.c Wed Mar 30 14:15:18 2011 (r220157) @@ -342,7 +342,7 @@ connectlog(void) if (LogFile == -1) { if ((LogFile = _socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) return; - (void)_fcntl(LogFile, F_SETFD, 1); + (void)_fcntl(LogFile, F_SETFD, FD_CLOEXEC); } if (LogFile != -1 && status == NOCONN) { SyslogAddr.sun_len = sizeof(SyslogAddr); From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 14:46: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 632CF106564A; Wed, 30 Mar 2011 14:46: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 51DAC8FC25; Wed, 30 Mar 2011 14:46:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UEkDLb066517; Wed, 30 Mar 2011 14:46:13 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UEkDDk066511; Wed, 30 Mar 2011 14:46:13 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201103301446.p2UEkDDk066511@svn.freebsd.org> From: Konstantin Belousov Date: Wed, 30 Mar 2011 14:46: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: r220158 - in head/sys: compat/freebsd32 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: Wed, 30 Mar 2011 14:46:13 -0000 Author: kib Date: Wed Mar 30 14:46:12 2011 New Revision: 220158 URL: http://svn.freebsd.org/changeset/base/220158 Log: Provide compat32 shims for kldstat(2). Requested and tested by: jpaetzel MFC after: 1 week Modified: head/sys/compat/freebsd32/freebsd32.h head/sys/compat/freebsd32/freebsd32_misc.c head/sys/compat/freebsd32/syscalls.master head/sys/kern/kern_linker.c head/sys/sys/syscallsubr.h Modified: head/sys/compat/freebsd32/freebsd32.h ============================================================================== --- head/sys/compat/freebsd32/freebsd32.h Wed Mar 30 14:15:18 2011 (r220157) +++ head/sys/compat/freebsd32/freebsd32.h Wed Mar 30 14:46:12 2011 (r220158) @@ -336,4 +336,23 @@ struct kinfo_proc32 { int ki_tdflags; }; +struct kld32_file_stat_1 { + int version; /* set to sizeof(struct kld_file_stat_1) */ + char name[MAXPATHLEN]; + int refs; + int id; + uint32_t address; /* load address */ + uint32_t size; /* size in bytes */ +}; + +struct kld32_file_stat { + int version; /* set to sizeof(struct kld_file_stat) */ + char name[MAXPATHLEN]; + int refs; + int id; + uint32_t address; /* load address */ + uint32_t size; /* size in bytes */ + char pathname[MAXPATHLEN]; +}; + #endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */ Modified: head/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_misc.c Wed Mar 30 14:15:18 2011 (r220157) +++ head/sys/compat/freebsd32/freebsd32_misc.c Wed Mar 30 14:46:12 2011 (r220158) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include /* Must come after sys/malloc.h */ @@ -2669,3 +2670,29 @@ freebsd32_copyout_strings(struct image_p return ((register_t *)stack_base); } +int +freebsd32_kldstat(struct thread *td, struct freebsd32_kldstat_args *uap) +{ + struct kld_file_stat stat; + struct kld32_file_stat stat32; + int error, version; + + if ((error = copyin(&uap->stat->version, &version, sizeof(version))) + != 0) + return (error); + if (version != sizeof(struct kld32_file_stat_1) && + version != sizeof(struct kld32_file_stat)) + return (EINVAL); + + error = kern_kldstat(td, uap->fileid, &stat); + if (error != 0) + return (error); + + bcopy(&stat.name[0], &stat32.name[0], sizeof(stat.name)); + CP(stat, stat32, refs); + CP(stat, stat32, id); + PTROUT_CP(stat, stat32, address); + CP(stat, stat32, size); + bcopy(&stat.pathname[0], &stat32.pathname[0], sizeof(stat.pathname)); + return (copyout(&stat32, uap->stat, version)); +} Modified: head/sys/compat/freebsd32/syscalls.master ============================================================================== --- head/sys/compat/freebsd32/syscalls.master Wed Mar 30 14:15:18 2011 (r220157) +++ head/sys/compat/freebsd32/syscalls.master Wed Mar 30 14:46:12 2011 (r220158) @@ -533,8 +533,8 @@ 305 AUE_MODUNLOAD NOPROTO { int kldunload(int fileid); } 306 AUE_NULL NOPROTO { int kldfind(const char *file); } 307 AUE_NULL NOPROTO { int kldnext(int fileid); } -308 AUE_NULL NOPROTO { int kldstat(int fileid, \ - struct kld_file_stat* stat); } +308 AUE_NULL STD { int freebsd32_kldstat(int fileid, \ + struct kld32_file_stat* stat); } 309 AUE_NULL NOPROTO { int kldfirstmod(int fileid); } 310 AUE_GETSID NOPROTO { int getsid(pid_t pid); } 311 AUE_SETRESUID NOPROTO { int setresuid(uid_t ruid, uid_t euid, \ Modified: head/sys/kern/kern_linker.c ============================================================================== --- head/sys/kern/kern_linker.c Wed Mar 30 14:15:18 2011 (r220157) +++ head/sys/kern/kern_linker.c Wed Mar 30 14:46:12 2011 (r220158) @@ -1201,29 +1201,39 @@ int kldstat(struct thread *td, struct kldstat_args *uap) { struct kld_file_stat stat; - linker_file_t lf; - int error, namelen, version, version_num; + int error, version; /* * Check the version of the user's structure. */ - if ((error = copyin(&uap->stat->version, &version, sizeof(version))) != 0) + if ((error = copyin(&uap->stat->version, &version, sizeof(version))) + != 0) return (error); - if (version == sizeof(struct kld_file_stat_1)) - version_num = 1; - else if (version == sizeof(struct kld_file_stat)) - version_num = 2; - else + if (version != sizeof(struct kld_file_stat_1) && + version != sizeof(struct kld_file_stat)) return (EINVAL); + error = kern_kldstat(td, uap->fileid, &stat); + if (error != 0) + return (error); + return (copyout(&stat, uap->stat, version)); +} + +int +kern_kldstat(struct thread *td, int fileid, struct kld_file_stat *stat) +{ + linker_file_t lf; + int namelen; #ifdef MAC + int error; + error = mac_kld_check_stat(td->td_ucred); if (error) return (error); #endif KLD_LOCK(); - lf = linker_find_file_by_id(uap->fileid); + lf = linker_find_file_by_id(fileid); if (lf == NULL) { KLD_UNLOCK(); return (ENOENT); @@ -1233,23 +1243,20 @@ kldstat(struct thread *td, struct kldsta namelen = strlen(lf->filename) + 1; if (namelen > MAXPATHLEN) namelen = MAXPATHLEN; - bcopy(lf->filename, &stat.name[0], namelen); - stat.refs = lf->refs; - stat.id = lf->id; - stat.address = lf->address; - stat.size = lf->size; - if (version_num > 1) { - /* Version 2 fields: */ - namelen = strlen(lf->pathname) + 1; - if (namelen > MAXPATHLEN) - namelen = MAXPATHLEN; - bcopy(lf->pathname, &stat.pathname[0], namelen); - } + bcopy(lf->filename, &stat->name[0], namelen); + stat->refs = lf->refs; + stat->id = lf->id; + stat->address = lf->address; + stat->size = lf->size; + /* Version 2 fields: */ + namelen = strlen(lf->pathname) + 1; + if (namelen > MAXPATHLEN) + namelen = MAXPATHLEN; + bcopy(lf->pathname, &stat->pathname[0], namelen); KLD_UNLOCK(); td->td_retval[0] = 0; - - return (copyout(&stat, uap->stat, version)); + return (0); } int Modified: head/sys/sys/syscallsubr.h ============================================================================== --- head/sys/sys/syscallsubr.h Wed Mar 30 14:15:18 2011 (r220157) +++ head/sys/sys/syscallsubr.h Wed Mar 30 14:46:12 2011 (r220158) @@ -48,6 +48,7 @@ struct sockaddr; struct stat; struct kevent; struct kevent_copyops; +struct kld_file_stat; struct ksiginfo; struct sendfile_args; struct thr_param; @@ -113,6 +114,7 @@ int kern_jail_set(struct thread *td, str int kern_kevent(struct thread *td, int fd, int nchanges, int nevents, struct kevent_copyops *k_ops, const struct timespec *timeout); int kern_kldload(struct thread *td, const char *file, int *fileid); +int kern_kldstat(struct thread *td, int fileid, struct kld_file_stat *stat); int kern_kldunload(struct thread *td, int fileid, int flags); int kern_lchown(struct thread *td, char *path, enum uio_seg pathseg, int uid, int gid); From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 14:46: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 5722F106566B; Wed, 30 Mar 2011 14:46:56 +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 465688FC21; Wed, 30 Mar 2011 14:46:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UEkuY8066567; Wed, 30 Mar 2011 14:46:56 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UEkurU066561; Wed, 30 Mar 2011 14:46:56 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201103301446.p2UEkurU066561@svn.freebsd.org> From: Konstantin Belousov Date: Wed, 30 Mar 2011 14:46: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: r220159 - head/sys/compat/freebsd32 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, 30 Mar 2011 14:46:56 -0000 Author: kib Date: Wed Mar 30 14:46:55 2011 New Revision: 220159 URL: http://svn.freebsd.org/changeset/base/220159 Log: Regen. Modified: head/sys/compat/freebsd32/freebsd32_proto.h head/sys/compat/freebsd32/freebsd32_syscall.h head/sys/compat/freebsd32/freebsd32_syscalls.c head/sys/compat/freebsd32/freebsd32_sysent.c head/sys/compat/freebsd32/freebsd32_systrace_args.c Modified: head/sys/compat/freebsd32/freebsd32_proto.h ============================================================================== --- head/sys/compat/freebsd32/freebsd32_proto.h Wed Mar 30 14:46:12 2011 (r220158) +++ head/sys/compat/freebsd32/freebsd32_proto.h Wed Mar 30 14:46:55 2011 (r220159) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 219304 2011-03-05 12:40:35Z trasz + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220158 2011-03-30 14:46:12Z kib */ #ifndef _FREEBSD32_SYSPROTO_H_ @@ -240,6 +240,10 @@ struct freebsd32_modstat_args { char modid_l_[PADL_(int)]; int modid; char modid_r_[PADR_(int)]; char stat_l_[PADL_(struct module_stat32 *)]; struct module_stat32 * stat; char stat_r_[PADR_(struct module_stat32 *)]; }; +struct freebsd32_kldstat_args { + char fileid_l_[PADL_(int)]; int fileid; char fileid_r_[PADR_(int)]; + char stat_l_[PADL_(struct kld32_file_stat *)]; struct kld32_file_stat * stat; char stat_r_[PADR_(struct kld32_file_stat *)]; +}; struct freebsd32_aio_return_args { char aiocbp_l_[PADL_(struct aiocb32 *)]; struct aiocb32 * aiocbp; char aiocbp_r_[PADR_(struct aiocb32 *)]; }; @@ -607,6 +611,7 @@ int freebsd32_lutimes(struct thread *, s int freebsd32_preadv(struct thread *, struct freebsd32_preadv_args *); int freebsd32_pwritev(struct thread *, struct freebsd32_pwritev_args *); int freebsd32_modstat(struct thread *, struct freebsd32_modstat_args *); +int freebsd32_kldstat(struct thread *, struct freebsd32_kldstat_args *); int freebsd32_aio_return(struct thread *, struct freebsd32_aio_return_args *); int freebsd32_aio_suspend(struct thread *, struct freebsd32_aio_suspend_args *); int freebsd32_aio_cancel(struct thread *, struct freebsd32_aio_cancel_args *); @@ -939,6 +944,7 @@ int freebsd7_freebsd32_shmctl(struct thr #define FREEBSD32_SYS_AUE_freebsd32_pwritev AUE_PWRITEV #define FREEBSD32_SYS_AUE_freebsd4_freebsd32_fhstatfs AUE_FHSTATFS #define FREEBSD32_SYS_AUE_freebsd32_modstat AUE_NULL +#define FREEBSD32_SYS_AUE_freebsd32_kldstat AUE_NULL #define FREEBSD32_SYS_AUE_freebsd32_aio_return AUE_NULL #define FREEBSD32_SYS_AUE_freebsd32_aio_suspend AUE_NULL #define FREEBSD32_SYS_AUE_freebsd32_aio_cancel AUE_NULL Modified: head/sys/compat/freebsd32/freebsd32_syscall.h ============================================================================== --- head/sys/compat/freebsd32/freebsd32_syscall.h Wed Mar 30 14:46:12 2011 (r220158) +++ head/sys/compat/freebsd32/freebsd32_syscall.h Wed Mar 30 14:46:55 2011 (r220159) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 219304 2011-03-05 12:40:35Z trasz + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220158 2011-03-30 14:46:12Z kib */ #define FREEBSD32_SYS_syscall 0 @@ -234,7 +234,7 @@ #define FREEBSD32_SYS_kldunload 305 #define FREEBSD32_SYS_kldfind 306 #define FREEBSD32_SYS_kldnext 307 -#define FREEBSD32_SYS_kldstat 308 +#define FREEBSD32_SYS_freebsd32_kldstat 308 #define FREEBSD32_SYS_kldfirstmod 309 #define FREEBSD32_SYS_getsid 310 #define FREEBSD32_SYS_setresuid 311 Modified: head/sys/compat/freebsd32/freebsd32_syscalls.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_syscalls.c Wed Mar 30 14:46:12 2011 (r220158) +++ head/sys/compat/freebsd32/freebsd32_syscalls.c Wed Mar 30 14:46:55 2011 (r220159) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 219304 2011-03-05 12:40:35Z trasz + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220158 2011-03-30 14:46:12Z kib */ const char *freebsd32_syscallnames[] = { @@ -318,7 +318,7 @@ const char *freebsd32_syscallnames[] = { "kldunload", /* 305 = kldunload */ "kldfind", /* 306 = kldfind */ "kldnext", /* 307 = kldnext */ - "kldstat", /* 308 = kldstat */ + "freebsd32_kldstat", /* 308 = freebsd32_kldstat */ "kldfirstmod", /* 309 = kldfirstmod */ "getsid", /* 310 = getsid */ "setresuid", /* 311 = setresuid */ Modified: head/sys/compat/freebsd32/freebsd32_sysent.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_sysent.c Wed Mar 30 14:46:12 2011 (r220158) +++ head/sys/compat/freebsd32/freebsd32_sysent.c Wed Mar 30 14:46:55 2011 (r220159) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 219304 2011-03-05 12:40:35Z trasz + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220158 2011-03-30 14:46:12Z kib */ #include "opt_compat.h" @@ -355,7 +355,7 @@ struct sysent freebsd32_sysent[] = { { AS(kldunload_args), (sy_call_t *)kldunload, AUE_MODUNLOAD, NULL, 0, 0, 0, SY_THR_STATIC }, /* 305 = kldunload */ { AS(kldfind_args), (sy_call_t *)kldfind, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 306 = kldfind */ { AS(kldnext_args), (sy_call_t *)kldnext, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 307 = kldnext */ - { AS(kldstat_args), (sy_call_t *)kldstat, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 308 = kldstat */ + { AS(freebsd32_kldstat_args), (sy_call_t *)freebsd32_kldstat, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 308 = freebsd32_kldstat */ { AS(kldfirstmod_args), (sy_call_t *)kldfirstmod, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 309 = kldfirstmod */ { AS(getsid_args), (sy_call_t *)getsid, AUE_GETSID, NULL, 0, 0, 0, SY_THR_STATIC }, /* 310 = getsid */ { AS(setresuid_args), (sy_call_t *)setresuid, AUE_SETRESUID, NULL, 0, 0, 0, SY_THR_STATIC }, /* 311 = setresuid */ Modified: head/sys/compat/freebsd32/freebsd32_systrace_args.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_systrace_args.c Wed Mar 30 14:46:12 2011 (r220158) +++ head/sys/compat/freebsd32/freebsd32_systrace_args.c Wed Mar 30 14:46:55 2011 (r220159) @@ -1428,11 +1428,11 @@ systrace_args(int sysnum, void *params, *n_args = 1; break; } - /* kldstat */ + /* freebsd32_kldstat */ case 308: { - struct kldstat_args *p = params; + struct freebsd32_kldstat_args *p = params; iarg[0] = p->fileid; /* int */ - uarg[1] = (intptr_t) p->stat; /* struct kld_file_stat * */ + uarg[1] = (intptr_t) p->stat; /* struct kld32_file_stat * */ *n_args = 2; break; } @@ -5217,14 +5217,14 @@ systrace_setargdesc(int sysnum, int ndx, break; }; break; - /* kldstat */ + /* freebsd32_kldstat */ case 308: switch(ndx) { case 0: p = "int"; break; case 1: - p = "struct kld_file_stat *"; + p = "struct kld32_file_stat *"; break; default: break; From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 15:23: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 983F41065674; Wed, 30 Mar 2011 15:23:14 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 2422C8FC1F; Wed, 30 Mar 2011 15:23:13 +0000 (UTC) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.4/8.14.4/NETPLEX) with ESMTP id p2UFNDti020328; Wed, 30 Mar 2011 11:23:13 -0400 X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.2.6 (mail.netplex.net [204.213.176.10]); Wed, 30 Mar 2011 11:23:13 -0400 (EDT) Date: Wed, 30 Mar 2011 11:23:13 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: John Baldwin In-Reply-To: <201103300827.25260.jhb@freebsd.org> Message-ID: References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> <201103291401.03565.jhb@freebsd.org> <201103300827.25260.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, Randall Stewart , svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r217592 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen 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, 30 Mar 2011 15:23:14 -0000 On Wed, 30 Mar 2011, John Baldwin wrote: > On Wednesday, March 30, 2011 3:50:18 am Daniel Eischen wrote: >> On Tue, 29 Mar 2011, John Baldwin wrote: >>> >>> As to why the packets loop back to the receiver, I believe that is a separate >>> issue on the output side, not the receive side. >> >> That may be, but the behavior is undesired if the no process >> on the system has joined the multicast group. I believe it >> was broke with r189359, and the comment in the code that broke >> it says: >> >> /* >> * Loop back multicast datagram if not expressly >> * forbidden to do so, even if we are not a member >> * of the group; ip_input() will filter it later, >> * thus deferring a hash lookup and mutex acquisition >> * at the expense of a cheap copy using m_copym(). >> */ >> >> The previous revision did a lookup of the multicast address >> and looped it if an entry was found for it. > > Well, for one, this patch changes the behavior even if there is a socket > joined to the group. Yes, I understand that. But before this patch, the behavior was correct for what you have stated, and for my particular case. When we fixed the problem, we took BMS' comment as guidance and filtered on the input side. > However, I suspect that in your case your app should > probably be turning IP_MULTICAST_LOOP off explicitly regardless of what the > changes end up being (or do you write to multiple groups and want a subset > of those groups to loop back?). In the _absence_ of setting multicast loopback on the socket, we should not be getting looped-back packets. This is the behavior we've seen on other OS's. -- DE From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 15:42: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 BDE70106564A; Wed, 30 Mar 2011 15:42:02 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 742C68FC0A; Wed, 30 Mar 2011 15:42:02 +0000 (UTC) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.4/8.14.4/NETPLEX) with ESMTP id p2UFg1k4009790; Wed, 30 Mar 2011 11:42:01 -0400 X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.2.6 (mail.netplex.net [204.213.176.10]); Wed, 30 Mar 2011 11:42:01 -0400 (EDT) Date: Wed, 30 Mar 2011 11:42:01 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: John Baldwin In-Reply-To: <201103300823.53986.jhb@freebsd.org> Message-ID: References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> <201103291401.03565.jhb@freebsd.org> <99FEFE99-455A-4A28-8C02-08DFAD28B6CD@lakerest.net> <201103300823.53986.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, George Neville-Neil , svn-src-all@freebsd.org, src-committers@freebsd.org, Randall Stewart Subject: Re: svn commit: r217592 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen 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, 30 Mar 2011 15:42:02 -0000 On Wed, 30 Mar 2011, John Baldwin wrote: > On Wednesday, March 30, 2011 7:27:36 am Randall Stewart wrote: >> John: >> >> The original complaint on this came from Daniel... I believe he >> claimed that up until bms's multi-cast work.. you would NOT >> get a packet sent to you if you did not join the multi-cast group. > > Not necessarily. :( See below.. > >> I will also comment in-line below... >> >> On Mar 29, 2011, at 2:01 PM, John Baldwin wrote: >> >>> On Wednesday, January 19, 2011 2:07:16 pm Randall Stewart wrote: >>>> Author: rrs >>>> Date: Wed Jan 19 19:07:16 2011 >>>> New Revision: 217592 >>>> URL: http://svn.freebsd.org/changeset/base/217592 >>>> >>>> Log: >>>> Fix a bug where Multicast packets sent from a >>>> udp endpoint may end up echoing back to the sender >>>> even with OUT joining the multi-cast group. >>>> >>>> Reviewed by: gnn, bms, bz? >>>> Obtained from: deischen (with help from) >>>> >>>> Modified: >>>> head/sys/netinet/udp_usrreq.c >>>> >>>> Modified: head/sys/netinet/udp_usrreq.c >>>> >>> ============================================================================== >>>> --- head/sys/netinet/udp_usrreq.c Wed Jan 19 18:20:11 2011 (r217591) >>>> +++ head/sys/netinet/udp_usrreq.c Wed Jan 19 19:07:16 2011 (r217592) >>>> @@ -479,11 +479,13 @@ udp_input(struct mbuf *m, int off) >>>> * and source-specific multicast. [RFC3678] >>>> */ >>>> imo = inp->inp_moptions; >>>> - if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && >>>> - imo != NULL) { >>>> + if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { >>>> struct sockaddr_in group; >>>> int blocked; >>>> - >>>> + if(imo == NULL) { >>>> + INP_RUNLOCK(inp); >>>> + continue; >>>> + } >>>> bzero(&group, sizeof(struct sockaddr_in)); >>>> group.sin_len = sizeof(struct sockaddr_in); >>>> group.sin_family = AF_INET; >>> >>> So it turns out that this is a feature, not a bug, and is how multicast has >>> always worked. Specifically, if you bind a UDP socket with a wildcard >>> address, it should receive all traffic for the bound port, unicast or >>> multicast. When you join a group, you have switched the socket into a mode >>> where it now has a whitelist of acceptable multicast groups, but if a socket >>> has no joined groups, it should receive all multicast traffic, not none. This >>> change breaks that. >>> >>> I did not find this behavior intuitive at first, but it does seem to be >>> required. Note the description of IP_ADD_MEMBERSHIP from RFC 3678 for >>> example: >> >> >> I agree getting a packet that is coming to your port without joining the >> multi-cast group is not intuitive to me... >> >>> >>> 3. Overview of APIs >>> >>> There are a number of different APIs described in this document that >>> are appropriate for a number of different application types and IP >>> versions. Before providing detailed descriptions, this section >>> provides a "taxonomy" with a brief description of each. >>> >>> There are two categories of source-filter APIs, both of which are >>> designed to allow multicast receiver applications to designate the >>> unicast address(es) of sender(s) along with the multicast group >>> (destination address) to receive. >>> >>> o Basic (Delta-based): Some applications desire the simplicity of >>> a delta-based API in which each function call specifies a >>> single source address which should be added to or removed from >>> the existing filter for a given multicast group address on >>> which to listen. Such applications typically fall into either >>> of two categories: >>> >>> + Any-Source Multicast: By default, all sources are accepted. >>> Individual sources may be turned off and back on as needed >>> over time. This is also known as "exclude" mode, since the >>> source filter contains a list of excluded sources. >>> >>> + Source-Specific Multicast: Only sources in a given list are >>> allowed. The list may change over time. This is also known >>> as "include" mode, since the source filter contains a list >>> of included sources. >>> >>> This API would be used, for example, by "single-source" >>> applications such as audio/video broadcasting. It would >>> also be used for logical multi-source sessions where each >>> source independently allocates its own Source-Specific >>> Multicast group address. >> >> >> Not the above document is talking about a receiver that as joined the >> multicast group (or is joining it and wants some filtering)... I don't >> see how that applies to a UDP socket that has NOT joined the M-cast group.. >> >>> >>> >>> ..... >>> >>> 4.1.1. IPv4 Any-Source Multicast API >>> >>> The following socket options are defined in for >>> applications in the Any-Source Multicast category: >>> >>> Socket option Argument type >>> IP_ADD_MEMBERSHIP struct ip_mreq >>> IP_BLOCK_SOURCE struct ip_mreq_source >>> IP_UNBLOCK_SOURCE struct ip_mreq_source >>> IP_DROP_MEMBERSHIP struct ip_mreq >>> >>> IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP are already implemented on >>> most operating systems, and are used to join and leave an any-source >>> group. >>> >>> IP_BLOCK_SOURCE can be used to block data from a given source to a >>> given group (e.g., if the user "mutes" that source), and >>> IP_UNBLOCK_SOURCE can be used to undo this (e.g., if the user then >>> "unmutes" the source). >>> >>> As to why the packets loop back to the receiver, I believe that is a separate >>> issue on the output side, not the receive side. >> >> >> >> But that is what the commit fixes... > > Except you change receive, not transmit. I think the error in Daniel's case > is on the transmit side, not receive. I would be happy to know what the true > "official" behavior is for a socket that binds to INADDR_ANY but does not join > any groups. > > As far as prior to BMS's changes: in the older version of udp_input() we only > checked the membership list if inp->inp_moptions was != NULL. If it was NULL, > we would send all multicast packets to a given socket for which the address > fields matched (addr, port). > > BMS preserved this behavior and your patch changes But he changed the behavior on output. Pre-BMS and post-BMS behave differently and not like Solaris 10 or VxWorks. Haven't tried Linux. > it. UDP sockets start off with inp_moptions == NULL, so if you never do any > multicast-related setsockopt() you will receive all matching multicast packets. > However, once you do any multicast-related setsockopt() (IP_MULTICAST_LOOP, > IP_ADD_MEMBERSHIP, etc.) then inp_moptions is allocated and is non-NULL. > At that point it only accepts packets that match, except that even then we > used a sysctl which defaulted to off (!) to see if we should check the list of > memberships (net.inet.udp.strict_mcast_mship). This options structure was never > free'd, however, so you could get the truly bizarre behavior of: > > - bind a new socket, it will not receive all matching multicast traffic > - use IP_ADD_MEMBERSHIP to add a group, it will now receive only matching multicast > traffic for the group > - use IP_DROP_MEMBERSHIP to remove the group, it will now receive no multicast > traffic > > The different behavior in states 1 and 3 I find confusing and odd. By default > all sockets just always received all matching multicast traffic though. :) Not if a multicast group was not joined. The pre-BMS changes did not loop back multicast packets in ip_output.c. > However, this change is not restoring "old" behavior, it is a change in behavior > compared to the pre-BMS changes. Agreed, to preserve pre-BMS behavior, the change should be made on output. >> and as to the above, it again is >> talking about Multicast members.. AFAIKT... I am actually at the IETF >> so if you would like I can gladly go talk to the authors of this RFC >> (if they are here) and get their opinion on this. >> >> One other thing.. note this is NOT a standard but a informational RFC. Informational >> RFC are guidelines and NOT mandatory at all.. there will never be a MUST/SHOULD etc >> within them. > > Well, for lack of anything else I was looking to that. I would really prefer > the behavior in your change as I find it far more intuitive. I wasn't able to > find anything else in Stevens or elsewhere that seemed to indicate what the > proper behavior was beyond this. I also agree :-) -- DE From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 17:33: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 3D8111065673; Wed, 30 Mar 2011 17:33:53 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2B40A8FC14; Wed, 30 Mar 2011 17:33:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UHXrcp070240; Wed, 30 Mar 2011 17:33:53 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UHXriT070238; Wed, 30 Mar 2011 17:33:53 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201103301733.p2UHXriT070238@svn.freebsd.org> From: Josh Paetzel Date: Wed, 30 Mar 2011 17:33: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: r220161 - head/usr.sbin/pc-sysinstall/backend 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, 30 Mar 2011 17:33:53 -0000 Author: jpaetzel Date: Wed Mar 30 17:33:52 2011 New Revision: 220161 URL: http://svn.freebsd.org/changeset/base/220161 Log: Fix syntax error from previous commit. Approved by: kib (mentor) Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Wed Mar 30 14:48:49 2011 (r220160) +++ head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Wed Mar 30 17:33:52 2011 (r220161) @@ -421,7 +421,7 @@ setup_disk_slice() # Check if we have an image file defined echo $line | grep -q "^image=" 2>/dev/null - if [ $? eq 0 ] ; then + if [ $? -eq 0 ] ; then # Found an image= entry, lets read / set it get_value_from_string "${line}" strip_white_space "$VAL" From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 17:37: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 7CAD8106566B; Wed, 30 Mar 2011 17:37:04 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6A2788FC0C; Wed, 30 Mar 2011 17:37:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UHb4MA070334; Wed, 30 Mar 2011 17:37:04 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UHb4j7070331; Wed, 30 Mar 2011 17:37:04 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201103301737.p2UHb4j7070331@svn.freebsd.org> From: Josh Paetzel Date: Wed, 30 Mar 2011 17:37: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: r220162 - head/usr.sbin/pc-sysinstall/backend-partmanager 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, 30 Mar 2011 17:37:04 -0000 Author: jpaetzel Date: Wed Mar 30 17:37:04 2011 New Revision: 220162 URL: http://svn.freebsd.org/changeset/base/220162 Log: Check in two missing files missed in cleanup. Change expr to $(()) Switch test from "$?" = "0" to $? -eq 0 Approved by: kib (mentor) Modified: head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh head/usr.sbin/pc-sysinstall/backend-partmanager/delete-part.sh Modified: head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh Wed Mar 30 17:33:52 2011 (r220161) +++ head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh Wed Mar 30 17:37:04 2011 (r220162) @@ -85,7 +85,7 @@ fi # If this is an empty disk, see if we need to create a new scheme for it gpart show ${DISK} >/dev/null 2>/dev/null -if [ "$?" != "0" -a "${SLICENUM}" = "1" ] ; then +if [ $? -eq 0 -a "${SLICENUM}" = "1" ] ; then gpart create -s ${TYPE} ${DISK} fi Modified: head/usr.sbin/pc-sysinstall/backend-partmanager/delete-part.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend-partmanager/delete-part.sh Wed Mar 30 17:33:52 2011 (r220161) +++ head/usr.sbin/pc-sysinstall/backend-partmanager/delete-part.sh Wed Mar 30 17:37:04 2011 (r220162) @@ -57,10 +57,10 @@ PARTINDEX="" while z=1 do - CHARS=`expr $CHARS - 1` + CHARS=$((CHARS-1)) LAST_CHAR=`echo "${PARTITION}" | cut -c $CHARS` - echo "${LAST_CHAR}" | grep "^[0-9]$" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then + echo "${LAST_CHAR}" | grep -q "^[0-9]$" 2>/dev/null + if [ $? -eq 0 ] ; then PARTINDEX="${LAST_CHAR}${PARTINDEX}" else break From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 17:48: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 601FA1065670; Wed, 30 Mar 2011 17:48:15 +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 4B73E8FC19; Wed, 30 Mar 2011 17:48:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UHmFBD070610; Wed, 30 Mar 2011 17:48:15 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UHmF0g070602; Wed, 30 Mar 2011 17:48:15 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103301748.p2UHmF0g070602@svn.freebsd.org> From: Edward Tomasz Napierala Date: Wed, 30 Mar 2011 17:48: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: r220163 - in head/sys: compat/freebsd32 conf 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: Wed, 30 Mar 2011 17:48:15 -0000 Author: trasz Date: Wed Mar 30 17:48:15 2011 New Revision: 220163 URL: http://svn.freebsd.org/changeset/base/220163 Log: Add rctl. It's used by racct to take user-configurable actions based on the set of rules it maintains and the current resource usage. It also privides userland API to manage that ruleset. Sponsored by: The FreeBSD Foundation Reviewed by: kib (earlier version) Added: head/sys/kern/kern_rctl.c (contents, props changed) head/sys/sys/rctl.h (contents, props changed) Modified: head/sys/compat/freebsd32/syscalls.master head/sys/conf/NOTES head/sys/conf/files head/sys/conf/options head/sys/kern/kern_jail.c head/sys/kern/syscalls.master head/sys/sys/priv.h Modified: head/sys/compat/freebsd32/syscalls.master ============================================================================== --- head/sys/compat/freebsd32/syscalls.master Wed Mar 30 17:37:04 2011 (r220162) +++ head/sys/compat/freebsd32/syscalls.master Wed Mar 30 17:48:15 2011 (r220163) @@ -965,3 +965,18 @@ 523 AUE_NULL NOPROTO { int getloginclass(char *namebuf, \ size_t namelen); } 524 AUE_NULL NOPROTO { int setloginclass(const char *namebuf); } +525 AUE_NULL NOPROTO { int rctl_get_racct(const void *inbufp, \ + size_t inbuflen, void *outbufp, \ + size_t outbuflen); } +526 AUE_NULL NOPROTO { int rctl_get_rules(const void *inbufp, \ + size_t inbuflen, void *outbufp, \ + size_t outbuflen); } +527 AUE_NULL NOPROTO { int rctl_get_limits(const void *inbufp, \ + size_t inbuflen, void *outbufp, \ + size_t outbuflen); } +528 AUE_NULL NOPROTO { int rctl_add_rule(const void *inbufp, \ + size_t inbuflen, void *outbufp, \ + size_t outbuflen); } +529 AUE_NULL NOPROTO { int rctl_remove_rule(const void *inbufp, \ + size_t inbuflen, void *outbufp, \ + size_t outbuflen); } Modified: head/sys/conf/NOTES ============================================================================== --- head/sys/conf/NOTES Wed Mar 30 17:37:04 2011 (r220162) +++ head/sys/conf/NOTES Wed Mar 30 17:48:15 2011 (r220163) @@ -2933,6 +2933,9 @@ options AAC_DEBUG # Debugging levels: # Resource Accounting options RACCT +# Resource Limits +options RCTL + # Yet more undocumented options for linting. # BKTR_ALLOC_PAGES has no effect except to cause warnings, and # BROOKTREE_ALLOC_PAGES hasn't actually been superseded by it, since the Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Wed Mar 30 17:37:04 2011 (r220162) +++ head/sys/conf/files Wed Mar 30 17:48:15 2011 (r220163) @@ -2226,6 +2226,7 @@ kern/kern_priv.c standard kern/kern_proc.c standard kern/kern_prot.c standard kern/kern_racct.c standard +kern/kern_rctl.c standard kern/kern_resource.c standard kern/kern_rmlock.c standard kern/kern_rwlock.c standard Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Wed Mar 30 17:37:04 2011 (r220162) +++ head/sys/conf/options Wed Mar 30 17:48:15 2011 (r220163) @@ -876,6 +876,9 @@ IPOIB_CM opt_ofed.h # Resource Accounting RACCT opt_global.h +# Resource Limits +RCTL opt_global.h + # At least one of the AR71XX ubiquiti boards has a Redboot configuration # that "lies" about the amount of RAM it has. Until a cleaner method is # defined, this option will suffice in overriding what Redboot says. Modified: head/sys/kern/kern_jail.c ============================================================================== --- head/sys/kern/kern_jail.c Wed Mar 30 17:37:04 2011 (r220162) +++ head/sys/kern/kern_jail.c Wed Mar 30 17:48:15 2011 (r220163) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -2532,6 +2533,9 @@ prison_deref(struct prison *pr, int flag if (pr->pr_cpuset != NULL) cpuset_rel(pr->pr_cpuset); osd_jail_exit(pr); +#ifdef RCTL + rctl_racct_release(pr->pr_racct); +#endif racct_destroy(&pr->pr_racct); free(pr, M_PRISON); Added: head/sys/kern/kern_rctl.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/kern/kern_rctl.c Wed Mar 30 17:48:15 2011 (r220163) @@ -0,0 +1,1850 @@ +/*- + * Copyright (c) 2010 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Edward Tomasz Napierala under sponsorship + * from the FreeBSD Foundation. + * + * 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 +__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 + +#ifdef RCTL +#ifndef RACCT +#error "The RCTL option requires the RACCT option" +#endif + +FEATURE(rctl, "Resource Limits"); + +#define HRF_DEFAULT 0 +#define HRF_DONT_INHERIT 1 +#define HRF_DONT_ACCUMULATE 2 + +/* Default buffer size for rctl_get_rules(2). */ +#define RCTL_DEFAULT_BUFSIZE 4096 +#define RCTL_LOG_BUFSIZE 128 + +/* + * 'rctl_rule_link' connects a rule with every racct it's related to. + * For example, rule 'user:X:openfiles:deny=N/process' is linked + * with uidinfo for user X, and to each process of that user. + */ +struct rctl_rule_link { + LIST_ENTRY(rctl_rule_link) rrl_next; + struct rctl_rule *rrl_rule; + int rrl_exceeded; +}; + +struct dict { + const char *d_name; + int d_value; +}; + +static struct dict subjectnames[] = { + { "process", RCTL_SUBJECT_TYPE_PROCESS }, + { "user", RCTL_SUBJECT_TYPE_USER }, + { "loginclass", RCTL_SUBJECT_TYPE_LOGINCLASS }, + { "jail", RCTL_SUBJECT_TYPE_JAIL }, + { NULL, -1 }}; + +static struct dict resourcenames[] = { + { "cpu", RACCT_CPU }, + { "fsize", RACCT_FSIZE }, + { "data", RACCT_DATA }, + { "stack", RACCT_STACK }, + { "core", RACCT_CORE }, + { "rss", RACCT_RSS }, + { "memlock", RACCT_MEMLOCK }, + { "nproc", RACCT_NPROC }, + { "nofile", RACCT_NOFILE }, + { "sbsize", RACCT_SBSIZE }, + { "vmem", RACCT_VMEM }, + { "npts", RACCT_NPTS }, + { "swap", RACCT_SWAP }, + { "nthr", RACCT_NTHR }, + { "msgqqueued", RACCT_MSGQQUEUED }, + { "msgqsize", RACCT_MSGQSIZE }, + { "nmsgq", RACCT_NMSGQ }, + { "nsem", RACCT_NSEM }, + { "nsemop", RACCT_NSEMOP }, + { "nshm", RACCT_NSHM }, + { "shmsize", RACCT_SHMSIZE }, + { "wallclock", RACCT_WALLCLOCK }, + { NULL, -1 }}; + +static struct dict actionnames[] = { + { "sighup", RCTL_ACTION_SIGHUP }, + { "sigint", RCTL_ACTION_SIGINT }, + { "sigquit", RCTL_ACTION_SIGQUIT }, + { "sigill", RCTL_ACTION_SIGILL }, + { "sigtrap", RCTL_ACTION_SIGTRAP }, + { "sigabrt", RCTL_ACTION_SIGABRT }, + { "sigemt", RCTL_ACTION_SIGEMT }, + { "sigfpe", RCTL_ACTION_SIGFPE }, + { "sigkill", RCTL_ACTION_SIGKILL }, + { "sigbus", RCTL_ACTION_SIGBUS }, + { "sigsegv", RCTL_ACTION_SIGSEGV }, + { "sigsys", RCTL_ACTION_SIGSYS }, + { "sigpipe", RCTL_ACTION_SIGPIPE }, + { "sigalrm", RCTL_ACTION_SIGALRM }, + { "sigterm", RCTL_ACTION_SIGTERM }, + { "sigurg", RCTL_ACTION_SIGURG }, + { "sigstop", RCTL_ACTION_SIGSTOP }, + { "sigtstp", RCTL_ACTION_SIGTSTP }, + { "sigchld", RCTL_ACTION_SIGCHLD }, + { "sigttin", RCTL_ACTION_SIGTTIN }, + { "sigttou", RCTL_ACTION_SIGTTOU }, + { "sigio", RCTL_ACTION_SIGIO }, + { "sigxcpu", RCTL_ACTION_SIGXCPU }, + { "sigxfsz", RCTL_ACTION_SIGXFSZ }, + { "sigvtalrm", RCTL_ACTION_SIGVTALRM }, + { "sigprof", RCTL_ACTION_SIGPROF }, + { "sigwinch", RCTL_ACTION_SIGWINCH }, + { "siginfo", RCTL_ACTION_SIGINFO }, + { "sigusr1", RCTL_ACTION_SIGUSR1 }, + { "sigusr2", RCTL_ACTION_SIGUSR2 }, + { "sigthr", RCTL_ACTION_SIGTHR }, + { "deny", RCTL_ACTION_DENY }, + { "log", RCTL_ACTION_LOG }, + { "devctl", RCTL_ACTION_DEVCTL }, + { NULL, -1 }}; + +static void rctl_init(void); +SYSINIT(rctl, SI_SUB_RACCT, SI_ORDER_FIRST, rctl_init, NULL); + +static uma_zone_t rctl_rule_link_zone; +static uma_zone_t rctl_rule_zone; +static struct rwlock rctl_lock; +RW_SYSINIT(rctl_lock, &rctl_lock, "RCTL lock"); + +static int rctl_rule_fully_specified(const struct rctl_rule *rule); +static void rctl_rule_to_sbuf(struct sbuf *sb, const struct rctl_rule *rule); + +MALLOC_DEFINE(M_RCTL, "rctl", "Resource Limits"); + +static const char * +rctl_subject_type_name(int subject) +{ + int i; + + for (i = 0; subjectnames[i].d_name != NULL; i++) { + if (subjectnames[i].d_value == subject) + return (subjectnames[i].d_name); + } + + panic("rctl_subject_type_name: unknown subject type %d", subject); +} + +static const char * +rctl_action_name(int action) +{ + int i; + + for (i = 0; actionnames[i].d_name != NULL; i++) { + if (actionnames[i].d_value == action) + return (actionnames[i].d_name); + } + + panic("rctl_action_name: unknown action %d", action); +} + +const char * +rctl_resource_name(int resource) +{ + int i; + + for (i = 0; resourcenames[i].d_name != NULL; i++) { + if (resourcenames[i].d_value == resource) + return (resourcenames[i].d_name); + } + + panic("rctl_resource_name: unknown resource %d", resource); +} + +/* + * Return the amount of resource that can be allocated by 'p' before + * hitting 'rule'. + */ +static int64_t +rctl_available_resource(const struct proc *p, const struct rctl_rule *rule) +{ + int resource; + int64_t available = INT64_MAX; + struct ucred *cred = p->p_ucred; + + rw_assert(&rctl_lock, RA_LOCKED); + + resource = rule->rr_resource; + switch (rule->rr_per) { + case RCTL_SUBJECT_TYPE_PROCESS: + available = rule->rr_amount - + p->p_racct->r_resources[resource]; + break; + case RCTL_SUBJECT_TYPE_USER: + available = rule->rr_amount - + cred->cr_ruidinfo->ui_racct->r_resources[resource]; + break; + case RCTL_SUBJECT_TYPE_LOGINCLASS: + available = rule->rr_amount - + cred->cr_loginclass->lc_racct->r_resources[resource]; + break; + case RCTL_SUBJECT_TYPE_JAIL: + available = rule->rr_amount - + cred->cr_prison->pr_racct->r_resources[resource]; + break; + default: + panic("rctl_compute_available: unknown per %d", + rule->rr_per); + } + + return (available); +} + +/* + * Return non-zero if allocating 'amount' by proc 'p' would exceed + * resource limit specified by 'rule'. + */ +static int +rctl_would_exceed(const struct proc *p, const struct rctl_rule *rule, + int64_t amount) +{ + int64_t available; + + rw_assert(&rctl_lock, RA_LOCKED); + + available = rctl_available_resource(p, rule); + if (available >= amount) + return (0); + + return (1); +} + +/* + * Check whether the proc 'p' can allocate 'amount' of 'resource' in addition + * to what it keeps allocated now. Returns non-zero if the allocation should + * be denied, 0 otherwise. + */ +int +rctl_enforce(struct proc *p, int resource, uint64_t amount) +{ + struct rctl_rule *rule; + struct rctl_rule_link *link; + struct sbuf sb; + int should_deny = 0; + char *buf; + static int curtime = 0; + static struct timeval lasttime; + + rw_rlock(&rctl_lock); + + /* + * There may be more than one matching rule; go through all of them. + * Denial should be done last, after logging and sending signals. + */ + LIST_FOREACH(link, &p->p_racct->r_rule_links, rrl_next) { + rule = link->rrl_rule; + if (rule->rr_resource != resource) + continue; + if (!rctl_would_exceed(p, rule, amount)) { + link->rrl_exceeded = 0; + continue; + } + + switch (rule->rr_action) { + case RCTL_ACTION_DENY: + should_deny = 1; + continue; + case RCTL_ACTION_LOG: + /* + * If rrl_exceeded != 0, it means we've already + * logged a warning for this process. + */ + if (link->rrl_exceeded != 0) + continue; + + if (!ppsratecheck(&lasttime, &curtime, 10)) + continue; + + buf = malloc(RCTL_LOG_BUFSIZE, M_RCTL, M_NOWAIT); + if (buf == NULL) { + printf("rctl_enforce: out of memory\n"); + continue; + } + sbuf_new(&sb, buf, RCTL_LOG_BUFSIZE, SBUF_FIXEDLEN); + rctl_rule_to_sbuf(&sb, rule); + sbuf_finish(&sb); + printf("rctl: rule \"%s\" matched by pid %d " + "(%s), uid %d, jail %s\n", sbuf_data(&sb), + p->p_pid, p->p_comm, p->p_ucred->cr_uid, + p->p_ucred->cr_prison->pr_name); + sbuf_delete(&sb); + free(buf, M_RCTL); + link->rrl_exceeded = 1; + continue; + case RCTL_ACTION_DEVCTL: + if (link->rrl_exceeded != 0) + continue; + + buf = malloc(RCTL_LOG_BUFSIZE, M_RCTL, M_NOWAIT); + if (buf == NULL) { + printf("rctl_enforce: out of memory\n"); + continue; + } + sbuf_new(&sb, buf, RCTL_LOG_BUFSIZE, SBUF_FIXEDLEN); + sbuf_printf(&sb, "rule="); + rctl_rule_to_sbuf(&sb, rule); + sbuf_printf(&sb, " pid=%d ruid=%d jail=%s", + p->p_pid, p->p_ucred->cr_ruid, + p->p_ucred->cr_prison->pr_name); + sbuf_finish(&sb); + devctl_notify_f("RCTL", "rule", "matched", + sbuf_data(&sb), M_NOWAIT); + sbuf_delete(&sb); + free(buf, M_RCTL); + link->rrl_exceeded = 1; + continue; + default: + if (link->rrl_exceeded != 0) + continue; + + KASSERT(rule->rr_action > 0 && + rule->rr_action <= RCTL_ACTION_SIGNAL_MAX, + ("rctl_enforce: unknown action %d", + rule->rr_action)); + + /* + * We're using the fact that RCTL_ACTION_SIG* values + * are equal to their counterparts from sys/signal.h. + */ + psignal(p, rule->rr_action); + link->rrl_exceeded = 1; + continue; + } + } + + rw_runlock(&rctl_lock); + + if (should_deny) { + /* + * Return fake error code; the caller should change it + * into one proper for the situation - EFSIZ, ENOMEM etc. + */ + return (EDOOFUS); + } + + return (0); +} + +uint64_t +rctl_get_limit(struct proc *p, int resource) +{ + struct rctl_rule *rule; + struct rctl_rule_link *link; + uint64_t amount = UINT64_MAX; + + rw_rlock(&rctl_lock); + + /* + * There may be more than one matching rule; go through all of them. + * Denial should be done last, after logging and sending signals. + */ + LIST_FOREACH(link, &p->p_racct->r_rule_links, rrl_next) { + rule = link->rrl_rule; + if (rule->rr_resource != resource) + continue; + if (rule->rr_action != RCTL_ACTION_DENY) + continue; + if (rule->rr_amount < amount) + amount = rule->rr_amount; + } + + rw_runlock(&rctl_lock); + + return (amount); +} + +uint64_t +rctl_get_available(struct proc *p, int resource) +{ + struct rctl_rule *rule; + struct rctl_rule_link *link; + int64_t available, minavailable, allocated; + + minavailable = INT64_MAX; + + rw_rlock(&rctl_lock); + + /* + * There may be more than one matching rule; go through all of them. + * Denial should be done last, after logging and sending signals. + */ + LIST_FOREACH(link, &p->p_racct->r_rule_links, rrl_next) { + rule = link->rrl_rule; + if (rule->rr_resource != resource) + continue; + if (rule->rr_action != RCTL_ACTION_DENY) + continue; + available = rctl_available_resource(p, rule); + if (available < minavailable) + minavailable = available; + } + + rw_runlock(&rctl_lock); + + /* + * XXX: Think about this _hard_. + */ + allocated = p->p_racct->r_resources[resource]; + if (minavailable < INT64_MAX - allocated) + minavailable += allocated; + if (minavailable < 0) + minavailable = 0; + return (minavailable); +} + +static int +rctl_rule_matches(const struct rctl_rule *rule, const struct rctl_rule *filter) +{ + + if (filter->rr_subject_type != RCTL_SUBJECT_TYPE_UNDEFINED) { + if (rule->rr_subject_type != filter->rr_subject_type) + return (0); + + switch (filter->rr_subject_type) { + case RCTL_SUBJECT_TYPE_PROCESS: + if (filter->rr_subject.rs_proc != NULL && + rule->rr_subject.rs_proc != + filter->rr_subject.rs_proc) + return (0); + break; + case RCTL_SUBJECT_TYPE_USER: + if (filter->rr_subject.rs_uip != NULL && + rule->rr_subject.rs_uip != + filter->rr_subject.rs_uip) + return (0); + break; + case RCTL_SUBJECT_TYPE_LOGINCLASS: + if (filter->rr_subject.hr_loginclass != NULL && + rule->rr_subject.hr_loginclass != + filter->rr_subject.hr_loginclass) + return (0); + break; + case RCTL_SUBJECT_TYPE_JAIL: + if (filter->rr_subject.rs_prison != NULL && + rule->rr_subject.rs_prison != + filter->rr_subject.rs_prison) + return (0); + break; + default: + panic("rctl_rule_matches: unknown subject type %d", + filter->rr_subject_type); + } + } + + if (filter->rr_resource != RACCT_UNDEFINED) { + if (rule->rr_resource != filter->rr_resource) + return (0); + } + + if (filter->rr_action != RCTL_ACTION_UNDEFINED) { + if (rule->rr_action != filter->rr_action) + return (0); + } + + if (filter->rr_amount != RCTL_AMOUNT_UNDEFINED) { + if (rule->rr_amount != filter->rr_amount) + return (0); + } + + if (filter->rr_per != RCTL_SUBJECT_TYPE_UNDEFINED) { + if (rule->rr_per != filter->rr_per) + return (0); + } + + return (1); +} + +static int +str2value(const char *str, int *value, struct dict *table) +{ + int i; + + if (value == NULL) + return (EINVAL); + + for (i = 0; table[i].d_name != NULL; i++) { + if (strcasecmp(table[i].d_name, str) == 0) { + *value = table[i].d_value; + return (0); + } + } + + return (EINVAL); +} + +static int +str2id(const char *str, id_t *value) +{ + char *end; + + if (str == NULL) + return (EINVAL); + + *value = strtoul(str, &end, 10); + if ((size_t)(end - str) != strlen(str)) + return (EINVAL); + + return (0); +} + +static int +str2int64(const char *str, int64_t *value) +{ + char *end; + + if (str == NULL) + return (EINVAL); + + *value = strtoul(str, &end, 10); + if ((size_t)(end - str) != strlen(str)) + return (EINVAL); + + return (0); +} + +/* + * Connect the rule to the racct, increasing refcount for the rule. + */ +static void +rctl_racct_add_rule(struct racct *racct, struct rctl_rule *rule) +{ + struct rctl_rule_link *link; + + KASSERT(rctl_rule_fully_specified(rule), ("rule not fully specified")); + + rctl_rule_acquire(rule); + link = uma_zalloc(rctl_rule_link_zone, M_WAITOK); + link->rrl_rule = rule; + link->rrl_exceeded = 0; + + rw_wlock(&rctl_lock); + LIST_INSERT_HEAD(&racct->r_rule_links, link, rrl_next); + rw_wunlock(&rctl_lock); +} + +static int +rctl_racct_add_rule_locked(struct racct *racct, struct rctl_rule *rule) +{ + struct rctl_rule_link *link; + + KASSERT(rctl_rule_fully_specified(rule), ("rule not fully specified")); + rw_assert(&rctl_lock, RA_WLOCKED); + + link = uma_zalloc(rctl_rule_link_zone, M_NOWAIT); + if (link == NULL) + return (ENOMEM); + rctl_rule_acquire(rule); + link->rrl_rule = rule; + link->rrl_exceeded = 0; + + LIST_INSERT_HEAD(&racct->r_rule_links, link, rrl_next); + return (0); +} + +/* + * Remove limits for a rules matching the filter and release + * the refcounts for the rules, possibly freeing them. Returns + * the number of limit structures removed. + */ +static int +rctl_racct_remove_rules(struct racct *racct, + const struct rctl_rule *filter) +{ + int removed = 0; + struct rctl_rule_link *link, *linktmp; + + rw_assert(&rctl_lock, RA_WLOCKED); + + LIST_FOREACH_SAFE(link, &racct->r_rule_links, rrl_next, linktmp) { + if (!rctl_rule_matches(link->rrl_rule, filter)) + continue; + + LIST_REMOVE(link, rrl_next); + rctl_rule_release(link->rrl_rule); + uma_zfree(rctl_rule_link_zone, link); + removed++; + } + return (removed); +} + +static void +rctl_rule_acquire_subject(struct rctl_rule *rule) +{ + + switch (rule->rr_subject_type) { + case RCTL_SUBJECT_TYPE_UNDEFINED: + case RCTL_SUBJECT_TYPE_PROCESS: + case RCTL_SUBJECT_TYPE_JAIL: + break; + case RCTL_SUBJECT_TYPE_USER: + if (rule->rr_subject.rs_uip != NULL) + uihold(rule->rr_subject.rs_uip); + break; + case RCTL_SUBJECT_TYPE_LOGINCLASS: + if (rule->rr_subject.hr_loginclass != NULL) + loginclass_hold(rule->rr_subject.hr_loginclass); + break; + default: + panic("rctl_rule_acquire_subject: unknown subject type %d", + rule->rr_subject_type); + } +} + +static void +rctl_rule_release_subject(struct rctl_rule *rule) +{ + + switch (rule->rr_subject_type) { + case RCTL_SUBJECT_TYPE_UNDEFINED: + case RCTL_SUBJECT_TYPE_PROCESS: + case RCTL_SUBJECT_TYPE_JAIL: + break; + case RCTL_SUBJECT_TYPE_USER: + if (rule->rr_subject.rs_uip != NULL) + uifree(rule->rr_subject.rs_uip); + break; + case RCTL_SUBJECT_TYPE_LOGINCLASS: + if (rule->rr_subject.hr_loginclass != NULL) + loginclass_free(rule->rr_subject.hr_loginclass); + break; + default: + panic("rctl_rule_release_subject: unknown subject type %d", + rule->rr_subject_type); + } +} + +struct rctl_rule * +rctl_rule_alloc(int flags) +{ + struct rctl_rule *rule; + + rule = uma_zalloc(rctl_rule_zone, flags); + if (rule == NULL) + return (NULL); + rule->rr_subject_type = RCTL_SUBJECT_TYPE_UNDEFINED; + rule->rr_subject.rs_proc = NULL; + rule->rr_subject.rs_uip = NULL; + rule->rr_subject.hr_loginclass = NULL; + rule->rr_subject.rs_prison = NULL; + rule->rr_per = RCTL_SUBJECT_TYPE_UNDEFINED; + rule->rr_resource = RACCT_UNDEFINED; + rule->rr_action = RCTL_ACTION_UNDEFINED; + rule->rr_amount = RCTL_AMOUNT_UNDEFINED; + refcount_init(&rule->rr_refcount, 1); + + return (rule); +} + +struct rctl_rule * +rctl_rule_duplicate(const struct rctl_rule *rule, int flags) +{ + struct rctl_rule *copy; + + copy = uma_zalloc(rctl_rule_zone, flags); + if (copy == NULL) + return (NULL); + copy->rr_subject_type = rule->rr_subject_type; + copy->rr_subject.rs_proc = rule->rr_subject.rs_proc; + copy->rr_subject.rs_uip = rule->rr_subject.rs_uip; + copy->rr_subject.hr_loginclass = rule->rr_subject.hr_loginclass; + copy->rr_subject.rs_prison = rule->rr_subject.rs_prison; + copy->rr_per = rule->rr_per; + copy->rr_resource = rule->rr_resource; + copy->rr_action = rule->rr_action; + copy->rr_amount = rule->rr_amount; + refcount_init(©->rr_refcount, 1); + rctl_rule_acquire_subject(copy); + + return (copy); +} + +void +rctl_rule_acquire(struct rctl_rule *rule) +{ + + KASSERT(rule->rr_refcount > 0, ("rule->rr_refcount <= 0")); + + refcount_acquire(&rule->rr_refcount); +} + +static void +rctl_rule_free(void *context, int pending) +{ + struct rctl_rule *rule; + + rule = (struct rctl_rule *)context; + + KASSERT(rule->rr_refcount == 0, ("rule->rr_refcount != 0")); + + /* + * We don't need locking here; rule is guaranteed to be inaccessible. + */ + + rctl_rule_release_subject(rule); + uma_zfree(rctl_rule_zone, rule); +} + +void +rctl_rule_release(struct rctl_rule *rule) +{ + + KASSERT(rule->rr_refcount > 0, ("rule->rr_refcount <= 0")); + + if (refcount_release(&rule->rr_refcount)) { + /* + * rctl_rule_release() is often called when iterating + * over all the uidinfo structures in the system, + * holding uihashtbl_lock. Since rctl_rule_free() + * might end up calling uifree(), this would lead + * to lock recursion. Use taskqueue to avoid this. + */ + TASK_INIT(&rule->rr_task, 0, rctl_rule_free, rule); + taskqueue_enqueue(taskqueue_thread, &rule->rr_task); + } +} + +static int +rctl_rule_fully_specified(const struct rctl_rule *rule) +{ + + switch (rule->rr_subject_type) { + case RCTL_SUBJECT_TYPE_UNDEFINED: + return (0); + case RCTL_SUBJECT_TYPE_PROCESS: + if (rule->rr_subject.rs_proc == NULL) + return (0); + break; + case RCTL_SUBJECT_TYPE_USER: + if (rule->rr_subject.rs_uip == NULL) + return (0); + break; + case RCTL_SUBJECT_TYPE_LOGINCLASS: + if (rule->rr_subject.hr_loginclass == NULL) + return (0); + break; + case RCTL_SUBJECT_TYPE_JAIL: + if (rule->rr_subject.rs_prison == NULL) + return (0); + break; + default: + panic("rctl_rule_fully_specified: unknown subject type %d", + rule->rr_subject_type); + } + if (rule->rr_resource == RACCT_UNDEFINED) + return (0); + if (rule->rr_action == RCTL_ACTION_UNDEFINED) + return (0); + if (rule->rr_amount == RCTL_AMOUNT_UNDEFINED) + return (0); + if (rule->rr_per == RCTL_SUBJECT_TYPE_UNDEFINED) + return (0); + + return (1); +} + +static int +rctl_string_to_rule(char *rulestr, struct rctl_rule **rulep) +{ + int error = 0; + char *subjectstr, *subject_idstr, *resourcestr, *actionstr, + *amountstr, *perstr; + struct rctl_rule *rule; + id_t id; + + rule = rctl_rule_alloc(M_WAITOK); + + subjectstr = strsep(&rulestr, ":"); + subject_idstr = strsep(&rulestr, ":"); + resourcestr = strsep(&rulestr, ":"); + actionstr = strsep(&rulestr, "=/"); + amountstr = strsep(&rulestr, "/"); + perstr = rulestr; + + if (subjectstr == NULL || subjectstr[0] == '\0') + rule->rr_subject_type = RCTL_SUBJECT_TYPE_UNDEFINED; + else { + error = str2value(subjectstr, &rule->rr_subject_type, subjectnames); + if (error != 0) + goto out; + } + + if (subject_idstr == NULL || subject_idstr[0] == '\0') { + rule->rr_subject.rs_proc = NULL; + rule->rr_subject.rs_uip = NULL; + rule->rr_subject.hr_loginclass = NULL; + rule->rr_subject.rs_prison = NULL; + } else { + switch (rule->rr_subject_type) { + case RCTL_SUBJECT_TYPE_UNDEFINED: + error = EINVAL; + goto out; + case RCTL_SUBJECT_TYPE_PROCESS: + error = str2id(subject_idstr, &id); + if (error != 0) + goto out; + sx_assert(&allproc_lock, SA_LOCKED); + rule->rr_subject.rs_proc = pfind(id); + if (rule->rr_subject.rs_proc == NULL) { + error = ESRCH; + goto out; + } + PROC_UNLOCK(rule->rr_subject.rs_proc); + break; + case RCTL_SUBJECT_TYPE_USER: + error = str2id(subject_idstr, &id); + if (error != 0) + goto out; + rule->rr_subject.rs_uip = uifind(id); + break; + case RCTL_SUBJECT_TYPE_LOGINCLASS: + rule->rr_subject.hr_loginclass = + loginclass_find(subject_idstr); + if (rule->rr_subject.hr_loginclass == NULL) { + error = ENAMETOOLONG; + goto out; + } + break; + case RCTL_SUBJECT_TYPE_JAIL: + rule->rr_subject.rs_prison = + prison_find_name(&prison0, subject_idstr); + if (rule->rr_subject.rs_prison == NULL) { + /* + * No jail with that name; try with the JID. + */ + error = str2id(subject_idstr, &id); + if (error != 0) + goto out; + rule->rr_subject.rs_prison = prison_find(id); + if (rule->rr_subject.rs_prison == NULL) { + error = ESRCH; + goto out; + } + } + /* prison_find() returns with mutex held. */ + mtx_unlock(&rule->rr_subject.rs_prison->pr_mtx); + break; + default: + panic("rctl_string_to_rule: unknown subject type %d", + rule->rr_subject_type); + } + } + + if (resourcestr == NULL || resourcestr[0] == '\0') + rule->rr_resource = RACCT_UNDEFINED; + else { + error = str2value(resourcestr, &rule->rr_resource, + resourcenames); + if (error != 0) + goto out; + } + + if (actionstr == NULL || actionstr[0] == '\0') + rule->rr_action = RCTL_ACTION_UNDEFINED; + else { + error = str2value(actionstr, &rule->rr_action, actionnames); + if (error != 0) + goto out; + } + + if (amountstr == NULL || amountstr[0] == '\0') + rule->rr_amount = RCTL_AMOUNT_UNDEFINED; + else { + error = str2int64(amountstr, &rule->rr_amount); + if (error != 0) + goto out; + if (racct_is_in_thousands(rule->rr_resource)) + rule->rr_amount *= 1000; + } + + if (perstr == NULL || perstr[0] == '\0') + rule->rr_per = RCTL_SUBJECT_TYPE_UNDEFINED; + else { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 17:59: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 7FAC1106564A; Wed, 30 Mar 2011 17:59:54 +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 6B96D8FC19; Wed, 30 Mar 2011 17:59:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UHxso1070913; Wed, 30 Mar 2011 17:59:54 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UHxsTW070901; Wed, 30 Mar 2011 17:59:54 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103301759.p2UHxsTW070901@svn.freebsd.org> From: Edward Tomasz Napierala Date: Wed, 30 Mar 2011 17:59: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: r220164 - in head/sys: compat/freebsd32 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: Wed, 30 Mar 2011 17:59:54 -0000 Author: trasz Date: Wed Mar 30 17:59:54 2011 New Revision: 220164 URL: http://svn.freebsd.org/changeset/base/220164 Log: Regenerate. Modified: head/sys/compat/freebsd32/freebsd32_proto.h head/sys/compat/freebsd32/freebsd32_syscall.h head/sys/compat/freebsd32/freebsd32_syscalls.c head/sys/compat/freebsd32/freebsd32_sysent.c head/sys/compat/freebsd32/freebsd32_systrace_args.c head/sys/kern/init_sysent.c head/sys/kern/syscalls.c head/sys/kern/systrace_args.c head/sys/sys/syscall.h head/sys/sys/syscall.mk head/sys/sys/sysproto.h Modified: head/sys/compat/freebsd32/freebsd32_proto.h ============================================================================== --- head/sys/compat/freebsd32/freebsd32_proto.h Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/compat/freebsd32/freebsd32_proto.h Wed Mar 30 17:59:54 2011 (r220164) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220158 2011-03-30 14:46:12Z kib + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220163 2011-03-30 17:48:15Z trasz */ #ifndef _FREEBSD32_SYSPROTO_H_ Modified: head/sys/compat/freebsd32/freebsd32_syscall.h ============================================================================== --- head/sys/compat/freebsd32/freebsd32_syscall.h Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/compat/freebsd32/freebsd32_syscall.h Wed Mar 30 17:59:54 2011 (r220164) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220158 2011-03-30 14:46:12Z kib + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220163 2011-03-30 17:48:15Z trasz */ #define FREEBSD32_SYS_syscall 0 @@ -414,4 +414,9 @@ #define FREEBSD32_SYS_freebsd32_pselect 522 #define FREEBSD32_SYS_getloginclass 523 #define FREEBSD32_SYS_setloginclass 524 -#define FREEBSD32_SYS_MAXSYSCALL 525 +#define FREEBSD32_SYS_rctl_get_racct 525 +#define FREEBSD32_SYS_rctl_get_rules 526 +#define FREEBSD32_SYS_rctl_get_limits 527 +#define FREEBSD32_SYS_rctl_add_rule 528 +#define FREEBSD32_SYS_rctl_remove_rule 529 +#define FREEBSD32_SYS_MAXSYSCALL 530 Modified: head/sys/compat/freebsd32/freebsd32_syscalls.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_syscalls.c Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/compat/freebsd32/freebsd32_syscalls.c Wed Mar 30 17:59:54 2011 (r220164) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220158 2011-03-30 14:46:12Z kib + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220163 2011-03-30 17:48:15Z trasz */ const char *freebsd32_syscallnames[] = { @@ -548,4 +548,9 @@ const char *freebsd32_syscallnames[] = { "freebsd32_pselect", /* 522 = freebsd32_pselect */ "getloginclass", /* 523 = getloginclass */ "setloginclass", /* 524 = setloginclass */ + "rctl_get_racct", /* 525 = rctl_get_racct */ + "rctl_get_rules", /* 526 = rctl_get_rules */ + "rctl_get_limits", /* 527 = rctl_get_limits */ + "rctl_add_rule", /* 528 = rctl_add_rule */ + "rctl_remove_rule", /* 529 = rctl_remove_rule */ }; Modified: head/sys/compat/freebsd32/freebsd32_sysent.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_sysent.c Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/compat/freebsd32/freebsd32_sysent.c Wed Mar 30 17:59:54 2011 (r220164) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220158 2011-03-30 14:46:12Z kib + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220163 2011-03-30 17:48:15Z trasz */ #include "opt_compat.h" @@ -585,4 +585,9 @@ struct sysent freebsd32_sysent[] = { { AS(freebsd32_pselect_args), (sy_call_t *)freebsd32_pselect, AUE_SELECT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 522 = freebsd32_pselect */ { AS(getloginclass_args), (sy_call_t *)getloginclass, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 523 = getloginclass */ { AS(setloginclass_args), (sy_call_t *)setloginclass, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 524 = setloginclass */ + { AS(rctl_get_racct_args), (sy_call_t *)rctl_get_racct, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 525 = rctl_get_racct */ + { AS(rctl_get_rules_args), (sy_call_t *)rctl_get_rules, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 526 = rctl_get_rules */ + { AS(rctl_get_limits_args), (sy_call_t *)rctl_get_limits, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 527 = rctl_get_limits */ + { AS(rctl_add_rule_args), (sy_call_t *)rctl_add_rule, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 528 = rctl_add_rule */ + { AS(rctl_remove_rule_args), (sy_call_t *)rctl_remove_rule, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 529 = rctl_remove_rule */ }; Modified: head/sys/compat/freebsd32/freebsd32_systrace_args.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_systrace_args.c Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/compat/freebsd32/freebsd32_systrace_args.c Wed Mar 30 17:59:54 2011 (r220164) @@ -2957,6 +2957,56 @@ systrace_args(int sysnum, void *params, *n_args = 1; break; } + /* rctl_get_racct */ + case 525: { + struct rctl_get_racct_args *p = params; + uarg[0] = (intptr_t) p->inbufp; /* const void * */ + uarg[1] = p->inbuflen; /* size_t */ + uarg[2] = (intptr_t) p->outbufp; /* void * */ + uarg[3] = p->outbuflen; /* size_t */ + *n_args = 4; + break; + } + /* rctl_get_rules */ + case 526: { + struct rctl_get_rules_args *p = params; + uarg[0] = (intptr_t) p->inbufp; /* const void * */ + uarg[1] = p->inbuflen; /* size_t */ + uarg[2] = (intptr_t) p->outbufp; /* void * */ + uarg[3] = p->outbuflen; /* size_t */ + *n_args = 4; + break; + } + /* rctl_get_limits */ + case 527: { + struct rctl_get_limits_args *p = params; + uarg[0] = (intptr_t) p->inbufp; /* const void * */ + uarg[1] = p->inbuflen; /* size_t */ + uarg[2] = (intptr_t) p->outbufp; /* void * */ + uarg[3] = p->outbuflen; /* size_t */ + *n_args = 4; + break; + } + /* rctl_add_rule */ + case 528: { + struct rctl_add_rule_args *p = params; + uarg[0] = (intptr_t) p->inbufp; /* const void * */ + uarg[1] = p->inbuflen; /* size_t */ + uarg[2] = (intptr_t) p->outbufp; /* void * */ + uarg[3] = p->outbuflen; /* size_t */ + *n_args = 4; + break; + } + /* rctl_remove_rule */ + case 529: { + struct rctl_remove_rule_args *p = params; + uarg[0] = (intptr_t) p->inbufp; /* const void * */ + uarg[1] = p->inbuflen; /* size_t */ + uarg[2] = (intptr_t) p->outbufp; /* void * */ + uarg[3] = p->outbuflen; /* size_t */ + *n_args = 4; + break; + } default: *n_args = 0; break; @@ -7873,6 +7923,101 @@ systrace_setargdesc(int sysnum, int ndx, break; }; break; + /* rctl_get_racct */ + case 525: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "void *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; + /* rctl_get_rules */ + case 526: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "void *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; + /* rctl_get_limits */ + case 527: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "void *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; + /* rctl_add_rule */ + case 528: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "void *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; + /* rctl_remove_rule */ + case 529: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "void *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; default: break; }; Modified: head/sys/kern/init_sysent.c ============================================================================== --- head/sys/kern/init_sysent.c Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/kern/init_sysent.c Wed Mar 30 17:59:54 2011 (r220164) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/kern/syscalls.master 219304 2011-03-05 12:40:35Z trasz + * created from FreeBSD: head/sys/kern/syscalls.master 220163 2011-03-30 17:48:15Z trasz */ #include "opt_compat.h" @@ -559,4 +559,9 @@ struct sysent sysent[] = { { AS(pselect_args), (sy_call_t *)pselect, AUE_SELECT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 522 = pselect */ { AS(getloginclass_args), (sy_call_t *)getloginclass, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 523 = getloginclass */ { AS(setloginclass_args), (sy_call_t *)setloginclass, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 524 = setloginclass */ + { AS(rctl_get_racct_args), (sy_call_t *)rctl_get_racct, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 525 = rctl_get_racct */ + { AS(rctl_get_rules_args), (sy_call_t *)rctl_get_rules, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 526 = rctl_get_rules */ + { AS(rctl_get_limits_args), (sy_call_t *)rctl_get_limits, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 527 = rctl_get_limits */ + { AS(rctl_add_rule_args), (sy_call_t *)rctl_add_rule, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 528 = rctl_add_rule */ + { AS(rctl_remove_rule_args), (sy_call_t *)rctl_remove_rule, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 529 = rctl_remove_rule */ }; Modified: head/sys/kern/syscalls.c ============================================================================== --- head/sys/kern/syscalls.c Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/kern/syscalls.c Wed Mar 30 17:59:54 2011 (r220164) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/kern/syscalls.master 219304 2011-03-05 12:40:35Z trasz + * created from FreeBSD: head/sys/kern/syscalls.master 220163 2011-03-30 17:48:15Z trasz */ const char *syscallnames[] = { @@ -532,4 +532,9 @@ const char *syscallnames[] = { "pselect", /* 522 = pselect */ "getloginclass", /* 523 = getloginclass */ "setloginclass", /* 524 = setloginclass */ + "rctl_get_racct", /* 525 = rctl_get_racct */ + "rctl_get_rules", /* 526 = rctl_get_rules */ + "rctl_get_limits", /* 527 = rctl_get_limits */ + "rctl_add_rule", /* 528 = rctl_add_rule */ + "rctl_remove_rule", /* 529 = rctl_remove_rule */ }; Modified: head/sys/kern/systrace_args.c ============================================================================== --- head/sys/kern/systrace_args.c Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/kern/systrace_args.c Wed Mar 30 17:59:54 2011 (r220164) @@ -3135,6 +3135,56 @@ systrace_args(int sysnum, void *params, *n_args = 1; break; } + /* rctl_get_racct */ + case 525: { + struct rctl_get_racct_args *p = params; + uarg[0] = (intptr_t) p->inbufp; /* const void * */ + uarg[1] = p->inbuflen; /* size_t */ + uarg[2] = (intptr_t) p->outbufp; /* void * */ + uarg[3] = p->outbuflen; /* size_t */ + *n_args = 4; + break; + } + /* rctl_get_rules */ + case 526: { + struct rctl_get_rules_args *p = params; + uarg[0] = (intptr_t) p->inbufp; /* const void * */ + uarg[1] = p->inbuflen; /* size_t */ + uarg[2] = (intptr_t) p->outbufp; /* void * */ + uarg[3] = p->outbuflen; /* size_t */ + *n_args = 4; + break; + } + /* rctl_get_limits */ + case 527: { + struct rctl_get_limits_args *p = params; + uarg[0] = (intptr_t) p->inbufp; /* const void * */ + uarg[1] = p->inbuflen; /* size_t */ + uarg[2] = (intptr_t) p->outbufp; /* void * */ + uarg[3] = p->outbuflen; /* size_t */ + *n_args = 4; + break; + } + /* rctl_add_rule */ + case 528: { + struct rctl_add_rule_args *p = params; + uarg[0] = (intptr_t) p->inbufp; /* const void * */ + uarg[1] = p->inbuflen; /* size_t */ + uarg[2] = (intptr_t) p->outbufp; /* void * */ + uarg[3] = p->outbuflen; /* size_t */ + *n_args = 4; + break; + } + /* rctl_remove_rule */ + case 529: { + struct rctl_remove_rule_args *p = params; + uarg[0] = (intptr_t) p->inbufp; /* const void * */ + uarg[1] = p->inbuflen; /* size_t */ + uarg[2] = (intptr_t) p->outbufp; /* void * */ + uarg[3] = p->outbuflen; /* size_t */ + *n_args = 4; + break; + } default: *n_args = 0; break; @@ -8328,6 +8378,101 @@ systrace_setargdesc(int sysnum, int ndx, break; }; break; + /* rctl_get_racct */ + case 525: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "void *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; + /* rctl_get_rules */ + case 526: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "void *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; + /* rctl_get_limits */ + case 527: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "void *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; + /* rctl_add_rule */ + case 528: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "void *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; + /* rctl_remove_rule */ + case 529: + switch(ndx) { + case 0: + p = "const void *"; + break; + case 1: + p = "size_t"; + break; + case 2: + p = "void *"; + break; + case 3: + p = "size_t"; + break; + default: + break; + }; + break; default: break; }; Modified: head/sys/sys/syscall.h ============================================================================== --- head/sys/sys/syscall.h Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/sys/syscall.h Wed Mar 30 17:59:54 2011 (r220164) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/kern/syscalls.master 219304 2011-03-05 12:40:35Z trasz + * created from FreeBSD: head/sys/kern/syscalls.master 220163 2011-03-30 17:48:15Z trasz */ #define SYS_syscall 0 @@ -435,4 +435,9 @@ #define SYS_pselect 522 #define SYS_getloginclass 523 #define SYS_setloginclass 524 -#define SYS_MAXSYSCALL 525 +#define SYS_rctl_get_racct 525 +#define SYS_rctl_get_rules 526 +#define SYS_rctl_get_limits 527 +#define SYS_rctl_add_rule 528 +#define SYS_rctl_remove_rule 529 +#define SYS_MAXSYSCALL 530 Modified: head/sys/sys/syscall.mk ============================================================================== --- head/sys/sys/syscall.mk Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/sys/syscall.mk Wed Mar 30 17:59:54 2011 (r220164) @@ -1,7 +1,7 @@ # FreeBSD system call names. # DO NOT EDIT-- this file is automatically generated. # $FreeBSD$ -# created from FreeBSD: head/sys/kern/syscalls.master 219304 2011-03-05 12:40:35Z trasz +# created from FreeBSD: head/sys/kern/syscalls.master 220163 2011-03-30 17:48:15Z trasz MIASM = \ syscall.o \ exit.o \ @@ -383,4 +383,9 @@ MIASM = \ cap_getmode.o \ pselect.o \ getloginclass.o \ - setloginclass.o + setloginclass.o \ + rctl_get_racct.o \ + rctl_get_rules.o \ + rctl_get_limits.o \ + rctl_add_rule.o \ + rctl_remove_rule.o Modified: head/sys/sys/sysproto.h ============================================================================== --- head/sys/sys/sysproto.h Wed Mar 30 17:48:15 2011 (r220163) +++ head/sys/sys/sysproto.h Wed Mar 30 17:59:54 2011 (r220164) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/kern/syscalls.master 219304 2011-03-05 12:40:35Z trasz + * created from FreeBSD: head/sys/kern/syscalls.master 220163 2011-03-30 17:48:15Z trasz */ #ifndef _SYS_SYSPROTO_H_ @@ -1678,6 +1678,36 @@ struct getloginclass_args { struct setloginclass_args { char namebuf_l_[PADL_(const char *)]; const char * namebuf; char namebuf_r_[PADR_(const char *)]; }; +struct rctl_get_racct_args { + char inbufp_l_[PADL_(const void *)]; const void * inbufp; char inbufp_r_[PADR_(const void *)]; + char inbuflen_l_[PADL_(size_t)]; size_t inbuflen; char inbuflen_r_[PADR_(size_t)]; + char outbufp_l_[PADL_(void *)]; void * outbufp; char outbufp_r_[PADR_(void *)]; + char outbuflen_l_[PADL_(size_t)]; size_t outbuflen; char outbuflen_r_[PADR_(size_t)]; +}; +struct rctl_get_rules_args { + char inbufp_l_[PADL_(const void *)]; const void * inbufp; char inbufp_r_[PADR_(const void *)]; + char inbuflen_l_[PADL_(size_t)]; size_t inbuflen; char inbuflen_r_[PADR_(size_t)]; + char outbufp_l_[PADL_(void *)]; void * outbufp; char outbufp_r_[PADR_(void *)]; + char outbuflen_l_[PADL_(size_t)]; size_t outbuflen; char outbuflen_r_[PADR_(size_t)]; +}; +struct rctl_get_limits_args { + char inbufp_l_[PADL_(const void *)]; const void * inbufp; char inbufp_r_[PADR_(const void *)]; + char inbuflen_l_[PADL_(size_t)]; size_t inbuflen; char inbuflen_r_[PADR_(size_t)]; + char outbufp_l_[PADL_(void *)]; void * outbufp; char outbufp_r_[PADR_(void *)]; + char outbuflen_l_[PADL_(size_t)]; size_t outbuflen; char outbuflen_r_[PADR_(size_t)]; +}; +struct rctl_add_rule_args { + char inbufp_l_[PADL_(const void *)]; const void * inbufp; char inbufp_r_[PADR_(const void *)]; + char inbuflen_l_[PADL_(size_t)]; size_t inbuflen; char inbuflen_r_[PADR_(size_t)]; + char outbufp_l_[PADL_(void *)]; void * outbufp; char outbufp_r_[PADR_(void *)]; + char outbuflen_l_[PADL_(size_t)]; size_t outbuflen; char outbuflen_r_[PADR_(size_t)]; +}; +struct rctl_remove_rule_args { + char inbufp_l_[PADL_(const void *)]; const void * inbufp; char inbufp_r_[PADR_(const void *)]; + char inbuflen_l_[PADL_(size_t)]; size_t inbuflen; char inbuflen_r_[PADR_(size_t)]; + char outbufp_l_[PADL_(void *)]; void * outbufp; char outbufp_r_[PADR_(void *)]; + char outbuflen_l_[PADL_(size_t)]; size_t outbuflen; char outbuflen_r_[PADR_(size_t)]; +}; int nosys(struct thread *, struct nosys_args *); void sys_exit(struct thread *, struct sys_exit_args *); int fork(struct thread *, struct fork_args *); @@ -2043,6 +2073,11 @@ int cap_getmode(struct thread *, struct int pselect(struct thread *, struct pselect_args *); int getloginclass(struct thread *, struct getloginclass_args *); int setloginclass(struct thread *, struct setloginclass_args *); +int rctl_get_racct(struct thread *, struct rctl_get_racct_args *); +int rctl_get_rules(struct thread *, struct rctl_get_rules_args *); +int rctl_get_limits(struct thread *, struct rctl_get_limits_args *); +int rctl_add_rule(struct thread *, struct rctl_add_rule_args *); +int rctl_remove_rule(struct thread *, struct rctl_remove_rule_args *); #ifdef COMPAT_43 @@ -2722,6 +2757,11 @@ int freebsd7_shmctl(struct thread *, str #define SYS_AUE_pselect AUE_SELECT #define SYS_AUE_getloginclass AUE_NULL #define SYS_AUE_setloginclass AUE_NULL +#define SYS_AUE_rctl_get_racct AUE_NULL +#define SYS_AUE_rctl_get_rules AUE_NULL +#define SYS_AUE_rctl_get_limits AUE_NULL +#define SYS_AUE_rctl_add_rule AUE_NULL +#define SYS_AUE_rctl_remove_rule AUE_NULL #undef PAD_ #undef PADL_ From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 18:08: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 6FCEE106564A; Wed, 30 Mar 2011 18:08:31 +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 5D4708FC08; Wed, 30 Mar 2011 18:08:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UI8VL3071161; Wed, 30 Mar 2011 18:08:31 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UI8Vj3071159; Wed, 30 Mar 2011 18:08:31 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103301808.p2UI8Vj3071159@svn.freebsd.org> From: Edward Tomasz Napierala Date: Wed, 30 Mar 2011 18:08: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: r220165 - head/lib/libc/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: Wed, 30 Mar 2011 18:08:31 -0000 Author: trasz Date: Wed Mar 30 18:08:31 2011 New Revision: 220165 URL: http://svn.freebsd.org/changeset/base/220165 Log: Expose the rctl(2) API in libc. Modified: head/lib/libc/sys/Symbol.map Modified: head/lib/libc/sys/Symbol.map ============================================================================== --- head/lib/libc/sys/Symbol.map Wed Mar 30 17:59:54 2011 (r220164) +++ head/lib/libc/sys/Symbol.map Wed Mar 30 18:08:31 2011 (r220165) @@ -364,6 +364,11 @@ FBSD_1.2 { cap_enter; cap_getmode; getloginclass; + rctl_get_racct; + rctl_get_rules; + rctl_get_limits; + rctl_add_rule; + rctl_remove_rule; setloginclass; }; From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 18:27: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 860B81065676; Wed, 30 Mar 2011 18:27:51 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 585E58FC1C; Wed, 30 Mar 2011 18:27:51 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id EB45546B06; Wed, 30 Mar 2011 14:27:50 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 76E258A01B; Wed, 30 Mar 2011 14:27:50 -0400 (EDT) From: John Baldwin To: Daniel Eischen Date: Wed, 30 Mar 2011 13:59:37 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> <201103300823.53986.jhb@freebsd.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201103301359.37444.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Wed, 30 Mar 2011 14:27:50 -0400 (EDT) Cc: svn-src-head@freebsd.org, George Neville-Neil , svn-src-all@freebsd.org, src-committers@freebsd.org, Randall Stewart Subject: Re: svn commit: r217592 - 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: Wed, 30 Mar 2011 18:27:51 -0000 On Wednesday, March 30, 2011 11:42:01 am Daniel Eischen wrote: > > BMS preserved this behavior and your patch changes > > But he changed the behavior on output. Pre-BMS and post-BMS > behave differently and not like Solaris 10 or VxWorks. Haven't > tried Linux. Yes, I am not debating that. I'm merely talking about the input side. > > it. UDP sockets start off with inp_moptions == NULL, so if you never do any > > multicast-related setsockopt() you will receive all matching multicast packets. > > However, once you do any multicast-related setsockopt() (IP_MULTICAST_LOOP, > > IP_ADD_MEMBERSHIP, etc.) then inp_moptions is allocated and is non-NULL. > > At that point it only accepts packets that match, except that even then we > > used a sysctl which defaulted to off (!) to see if we should check the list of > > memberships (net.inet.udp.strict_mcast_mship). This options structure was never > > free'd, however, so you could get the truly bizarre behavior of: > > > > - bind a new socket, it will not receive all matching multicast traffic > > - use IP_ADD_MEMBERSHIP to add a group, it will now receive only matching multicast > > traffic for the group > > - use IP_DROP_MEMBERSHIP to remove the group, it will now receive no multicast > > traffic > > > > The different behavior in states 1 and 3 I find confusing and odd. By default > > all sockets just always received all matching multicast traffic though. :) > > Not if a multicast group was not joined. The pre-BMS changes > did not loop back multicast packets in ip_output.c. Well, they would receive all multicast traffic that wasn't loopback traffic. That is, if I had two sockets bound to *:2000 and *:4000 and one socket joined a group 224.1.2.3, then both sockets would receive traffic bound for 224.1.2.3 if it matched their ports in both the pre-BMS code and in post-BMS but pre-RRS. Now only the socket that did the join will receive the packets, so it is a change in behavior. Now I find this unintuitive, but other folks I have talked to have pointed out that that could be a valid interpretation of binding to INADDR_ANY. -- John Baldwin From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 18:27: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 3BCD21065670; Wed, 30 Mar 2011 18:27:53 +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 26DE88FC1D; Wed, 30 Mar 2011 18:27:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UIRrV4071629; Wed, 30 Mar 2011 18:27:53 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UIRrtJ071624; Wed, 30 Mar 2011 18:27:53 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103301827.p2UIRrtJ071624@svn.freebsd.org> From: Edward Tomasz Napierala Date: Wed, 30 Mar 2011 18:27: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: r220166 - in head/usr.bin: . rctl 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, 30 Mar 2011 18:27:53 -0000 Author: trasz Date: Wed Mar 30 18:27:52 2011 New Revision: 220166 URL: http://svn.freebsd.org/changeset/base/220166 Log: Add rctl(8), the utility to manage rctl rules. Sponsored by: The FreeBSD Foundation Reviewed by: kib (earlier version) Added: head/usr.bin/rctl/ head/usr.bin/rctl/Makefile (contents, props changed) head/usr.bin/rctl/rctl.8 (contents, props changed) head/usr.bin/rctl/rctl.c (contents, props changed) Modified: head/usr.bin/Makefile Modified: head/usr.bin/Makefile ============================================================================== --- head/usr.bin/Makefile Wed Mar 30 18:08:31 2011 (r220165) +++ head/usr.bin/Makefile Wed Mar 30 18:27:52 2011 (r220166) @@ -126,6 +126,7 @@ SUBDIR= alias \ printenv \ printf \ procstat \ + rctl \ renice \ rev \ revoke \ Added: head/usr.bin/rctl/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/rctl/Makefile Wed Mar 30 18:27:52 2011 (r220166) @@ -0,0 +1,11 @@ +# $FreeBSD$ + +PROG= rctl +MAN= rctl.8 + +DPADD= ${LIBUTIL} +LDADD= -lutil + +WARNS?= 6 + +.include Added: head/usr.bin/rctl/rctl.8 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/rctl/rctl.8 Wed Mar 30 18:27:52 2011 (r220166) @@ -0,0 +1,200 @@ +.\"- +.\" Copyright (c) 2009 Edward Tomasz Napierala +.\" 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 THE VOICES IN HIS HEAD 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$ +.\" +.Dd February 13, 2011 +.Dt RCTL 8 +.Os +.Sh NAME +.Nm rctl +.Nd display and update resource limits database +.Sh SYNOPSIS +.Nm +.Op Fl h +.Op Fl n +.Op Ar filter +.Nm +.Fl a +.Op Ar rule +.Nm +.Op Fl h +.Op Fl n +.Fl l +.Op Ar filter +.Nm +.Fl r +.Op Ar filter +.Nm +.Op Fl h +.Fl u +.Op Ar filter +.Sh DESCRIPTION +When called without options, the +.Nm +command writes currently defined RCTL rules to standard output. +.Pp +If a +.Ar filter +argument is specified, only rules matching the filter are displayed. +The options are as follows: +.Bl -tag -width indent +.It Fl a Ar rule +Add +.Ar rule +to the RCTL database. +.It Fl l Ar filter +Display rules applicable to the process defined by +.Ar filter . +.It Fl r Ar filter +Remove rules matching +.Ar filter +from the RCTL database. +.It Fl u Ar filter +Display resource usage for a subject (process, user, login class +or jail) matching the +.Ar filter . +.It Fl h +"Human-readable" output. +Use unit suffixes: Byte, Kilobyte, Megabyte, +Gigabyte, Terabyte and Petabyte. +.It Fl n +Display user IDs numerically rather than converting them to a user name. +.Pp +.Sh RULE SYNTAX +Syntax for a rule is subject:subject-id:resource:action=amount/per. +.Pp +Subject defines the kind of entity the rule applies to. +It can be either process, user, login class, or jail. +.Pp +Subject ID identifies the subject. It can be user name, +numerical user ID, login class name, jail name, or numerical jail ID. +.Pp +Resource identifies the resource the rule controls. +.Pp +Action defines what will happen when a process exceeds the allowed amount. +.Pp +Amount defines how much of the resource a process can use before +the defined action triggers. +.Pp +The per field defines what entity the amount gets accounted for. +For example, rule "loginclass:users:vmem:deny=100M/process" means +that each process of any user belonging to login class "users" may allocate +up to 100MB of virtual memory. +Rule "loginclass:users:vmem:deny=100M/user" would mean that for each +user belonging to the login class "users", the sum of virtual memory allocated +by all the processes of a that user will not exceed 100MB. +Rule "loginclass:users:vmem:deny=100M/loginclass" would mean that the sum of +virtual memory allocated by all processes of all users belonging to that login +class will not exceed 100MB. +.Pp +Valid rule has all those fields specified, except for the per, which defaults +to the value of subject. +.Pp +A filter is a rule for which one of more fields other than per is left empty. +For example, a filter that matches every rule could be written as ":::=/", +or, in short, ":". +A filter that matches all the login classes would be "loginclass:". +A filter that matches all defined rules for nproc resource would be +"::nproc". +.Pp +.Sh RESOURCES +.Bl -column -offset 3n "msgqqueued" +.It cpu CPU time, in milliseconds +.It fsize maximum file size, in bytes +.It data data size, in bytes +.It stack stack size, in bytes +.It core core dump size, in bytes +.It rss resident set size, in bytes +.It memlock locked memory, in bytes +.It nproc number of processes +.It nofile file descriptor table size +.It sbsize memory consumed by socket buffers, in bytes +.It vmem address space limit, in bytes +.It npts number of PTYs +.It swap swap usage, in bytes +.It nthr number of threads +.It msgqqueued number of queued SysV messages +.It msgqsize SysV message queue size, in bytes +.It nmsgq number of SysV message queues +.It nsem number of SysV semaphores +.It nsemop number of SysV semaphores modified in a single semop(2) call +.It nshm number of SysV shared memory segments +.It shmsize SysV shared memory size, in bytes +.It wallclock wallclock time, in milliseconds +.It pctcpu %cpu time +.El +.Pp +.Sh ACTIONS +.Bl -column -offset 3n "msgqqueued" +.It deny deny the allocation; not supported for cpu and wallclock +.It log log a warning to the console +.It devctl send notification to +.Xr devd 8 +.It sig* e.g. sigterm; send a signal to the offending process +.El +.Pp +See +.Xr signal 3 +for a list of supported signals. +.Pp +Not all actions are supported for all resources. +Attempt to add rule with action not supported by a given resouce will result +in error. +.Pp +Note that limiting RSS may kill the machine due to thrashing. +.Pp +.Sh EXIT STATUS +.Ex -std +.Sh EXAMPLES +.Dl rctl -a user:joe:vmem:deny=1g +.Pp +Prevent user "joe" from allocating more than 1GB of virtual memory. +.Pp +.Dl rctl -r : +.Pp +Remove all RCTL rules. +.Pp +.Dl rctl -hu jail:5 +.Pp +Display resource usage information for jail with JID 5. +.Pp +.Dl rctl -l process:512 +.Pp +Display all the rules applicable to process with PID 512. +.Sh SEE ALSO +.Xr jailstat 8 , +.Xr userstat 8 +.Sh HISTORY +The +.Nm +command appeared in +.Fx 9.0. +.Sh AUTHORS +.An -nosplit +The +.Nm +command was written by +.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . Added: head/usr.bin/rctl/rctl.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/rctl/rctl.c Wed Mar 30 18:27:52 2011 (r220166) @@ -0,0 +1,539 @@ +/*- + * Copyright (c) 2010 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Edward Tomasz Napierala under sponsorship + * from the FreeBSD Foundation. + * + * 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define RCTL_DEFAULT_BUFSIZE 4096 + +static id_t +parse_user(const char *s) +{ + id_t id; + char *end; + struct passwd *pwd; + + pwd = getpwnam(s); + if (pwd != NULL) + return (pwd->pw_uid); + + if (!isnumber(s[0])) + errx(1, "uknown user '%s'", s); + + id = strtod(s, &end); + if ((size_t)(end - s) != strlen(s)) + errx(1, "trailing characters after numerical id"); + + return (id); +} + +static id_t +parse_group(const char *s) +{ + id_t id; + char *end; + struct group *grp; + + grp = getgrnam(s); + if (grp != NULL) + return (grp->gr_gid); + + if (!isnumber(s[0])) + errx(1, "uknown group '%s'", s); + + id = strtod(s, &end); + if ((size_t)(end - s) != strlen(s)) + errx(1, "trailing characters after numerical id"); + + return (id); +} + +/* + * This routine replaces user/group name with numeric id. + */ +static char * +resolve_ids(char *rule) +{ + id_t id; + const char *subject, *textid, *rest; + char *resolved; + + subject = strsep(&rule, ":"); + textid = strsep(&rule, ":"); + if (textid == NULL) + errx(1, "error in rule specification -- no subject"); + if (rule != NULL) + rest = rule; + else + rest = ""; + + if (strcasecmp(subject, "u") == 0) + subject = "user"; + else if (strcasecmp(subject, "g") == 0) + subject = "group"; + else if (strcasecmp(subject, "p") == 0) + subject = "process"; + else if (strcasecmp(subject, "l") == 0 || + strcasecmp(subject, "c") == 0 || + strcasecmp(subject, "class") == 0) + subject = "loginclass"; + else if (strcasecmp(subject, "j") == 0) + subject = "jail"; + + if (strcasecmp(subject, "user") == 0 && strlen(textid) > 0) { + id = parse_user(textid); + asprintf(&resolved, "%s:%d:%s", subject, (int)id, rest); + } else if (strcasecmp(subject, "group") == 0 && strlen(textid) > 0) { + id = parse_group(textid); + asprintf(&resolved, "%s:%d:%s", subject, (int)id, rest); + } else + asprintf(&resolved, "%s:%s:%s", subject, textid, rest); + + if (resolved == NULL) + err(1, "asprintf"); + + return (resolved); +} + +/* + * This routine replaces "human-readable" number with its expanded form. + */ +static char * +expand_amount(char *rule) +{ + uint64_t num; + const char *subject, *subject_id, *resource, *action, *amount, *per; + char *copy, *expanded; + + copy = strdup(rule); + if (copy == NULL) + err(1, "strdup"); + + subject = strsep(©, ":"); + subject_id = strsep(©, ":"); + resource = strsep(©, ":"); + action = strsep(©, "=/"); + amount = strsep(©, "/"); + per = copy; + + if (amount == NULL || strlen(amount) == 0) { + free(copy); + return (rule); + } + + assert(subject != NULL); + assert(subject_id != NULL); + assert(resource != NULL); + assert(action != NULL); + + if (expand_number(amount, &num)) + err(1, "expand_number"); + + if (per == NULL) + asprintf(&expanded, "%s:%s:%s:%s=%ju", subject, subject_id, + resource, action, (uintmax_t)num); + else + asprintf(&expanded, "%s:%s:%s:%s=%ju/%s", subject, subject_id, + resource, action, (uintmax_t)num, per); + + if (expanded == NULL) + err(1, "asprintf"); + + return (expanded); +} + +static char * +humanize_ids(char *rule) +{ + id_t id; + struct passwd *pwd; + struct group *grp; + const char *subject, *textid, *rest; + char *humanized; + + subject = strsep(&rule, ":"); + textid = strsep(&rule, ":"); + if (textid == NULL) + errx(1, "rule passed from the kernel didn't contain subject"); + if (rule != NULL) + rest = rule; + else + rest = ""; + + /* Replace numerical user and group ids with names. */ + if (strcasecmp(subject, "user") == 0) { + id = parse_user(textid); + pwd = getpwuid(id); + if (pwd != NULL) + textid = pwd->pw_name; + } else if (strcasecmp(subject, "group") == 0) { + id = parse_group(textid); + grp = getgrgid(id); + if (grp != NULL) + textid = grp->gr_name; + } + + asprintf(&humanized, "%s:%s:%s", subject, textid, rest); + + if (humanized == NULL) + err(1, "asprintf"); + + return (humanized); +} + +static int +str2int64(const char *str, int64_t *value) +{ + char *end; + + if (str == NULL) + return (EINVAL); + + *value = strtoul(str, &end, 10); + if ((size_t)(end - str) != strlen(str)) + return (EINVAL); + + return (0); +} + +static char * +humanize_amount(char *rule) +{ + int64_t num; + const char *subject, *subject_id, *resource, *action, *amount, *per; + char *copy, *humanized, buf[6]; + + copy = strdup(rule); + if (copy == NULL) + err(1, "strdup"); + + subject = strsep(©, ":"); + subject_id = strsep(©, ":"); + resource = strsep(©, ":"); + action = strsep(©, "=/"); + amount = strsep(©, "/"); + per = copy; + + if (amount == NULL || strlen(amount) == 0 || + str2int64(amount, &num) != 0) { + free(copy); + return (rule); + } + + assert(subject != NULL); + assert(subject_id != NULL); + assert(resource != NULL); + assert(action != NULL); + + if (humanize_number(buf, sizeof(buf), num, "", HN_AUTOSCALE, + HN_DECIMAL | HN_NOSPACE) == -1) + err(1, "humanize_number"); + + if (per == NULL) + asprintf(&humanized, "%s:%s:%s:%s=%s", subject, subject_id, + resource, action, buf); + else + asprintf(&humanized, "%s:%s:%s:%s=%s/%s", subject, subject_id, + resource, action, buf, per); + + if (humanized == NULL) + err(1, "asprintf"); + + return (humanized); +} + +/* + * Print rules, one per line. + */ +static void +print_rules(char *rules, int hflag, int nflag) +{ + char *rule; + + while ((rule = strsep(&rules, ",")) != NULL) { + if (rule[0] == '\0') + break; /* XXX */ + if (nflag == 0) + rule = humanize_ids(rule); + if (hflag) + rule = humanize_amount(rule); + printf("%s\n", rule); + } +} + +static void +add_rule(char *rule) +{ + int error; + + error = rctl_add_rule(rule, strlen(rule) + 1, NULL, 0); + if (error != 0) + err(1, "rctl_add_rule"); + free(rule); +} + +static void +show_limits(char *filter, int hflag, int nflag) +{ + int error; + char *outbuf = NULL; + size_t outbuflen = RCTL_DEFAULT_BUFSIZE / 4; + + do { + outbuflen *= 4; + outbuf = realloc(outbuf, outbuflen); + if (outbuf == NULL) + err(1, "realloc"); + + error = rctl_get_limits(filter, strlen(filter) + 1, outbuf, + outbuflen); + if (error && errno != ERANGE) + err(1, "rctl_get_limits"); + } while (error && errno == ERANGE); + + print_rules(outbuf, hflag, nflag); + free(filter); + free(outbuf); +} + +static void +remove_rule(char *filter) +{ + int error; + + error = rctl_remove_rule(filter, strlen(filter) + 1, NULL, 0); + if (error != 0) + err(1, "rctl_remove_rule"); + free(filter); +} + +static char * +humanize_usage_amount(char *usage) +{ + int64_t num; + const char *resource, *amount; + char *copy, *humanized, buf[6]; + + copy = strdup(usage); + if (copy == NULL) + err(1, "strdup"); + + resource = strsep(©, "="); + amount = copy; + + assert(resource != NULL); + assert(amount != NULL); + + if (str2int64(amount, &num) != 0 || + humanize_number(buf, sizeof(buf), num, "", HN_AUTOSCALE, + HN_DECIMAL | HN_NOSPACE) == -1) { + free(copy); + return (usage); + } + + asprintf(&humanized, "%s=%s", resource, buf); + if (humanized == NULL) + err(1, "asprintf"); + + return (humanized); +} + +/* + * Query the kernel about a resource usage and print it out. + */ +static void +show_usage(char *filter, int hflag) +{ + int error; + char *outbuf = NULL, *tmp; + size_t outbuflen = RCTL_DEFAULT_BUFSIZE / 4; + + do { + outbuflen *= 4; + outbuf = realloc(outbuf, outbuflen); + if (outbuf == NULL) + err(1, "realloc"); + + error = rctl_get_racct(filter, strlen(filter) + 1, outbuf, + outbuflen); + if (error && errno != ERANGE) + err(1, "rctl_get_racct"); + } while (error && errno == ERANGE); + + while ((tmp = strsep(&outbuf, ",")) != NULL) { + if (tmp[0] == '\0') + break; /* XXX */ + + if (hflag) + tmp = humanize_usage_amount(tmp); + + printf("%s\n", tmp); + } + + free(filter); + free(outbuf); +} + +/* + * Query the kernel about resource limit rules and print them out. + */ +static void +show_rules(char *filter, int hflag, int nflag) +{ + int error; + char *outbuf = NULL; + size_t filterlen, outbuflen = RCTL_DEFAULT_BUFSIZE / 4; + + if (filter != NULL) + filterlen = strlen(filter) + 1; + else + filterlen = 0; + + do { + outbuflen *= 4; + outbuf = realloc(outbuf, outbuflen); + if (outbuf == NULL) + err(1, "realloc"); + + error = rctl_get_rules(filter, filterlen, outbuf, outbuflen); + if (error && errno != ERANGE) + err(1, "rctl_get_rules"); + } while (error && errno == ERANGE); + + print_rules(outbuf, hflag, nflag); + free(outbuf); +} + +static void +usage(void) +{ + + fprintf(stderr, "usage: rctl [ -h ] [-a rule | -l filter | -r filter " + "| -u filter | filter]\n"); + exit(1); +} + +int +main(int argc __unused, char **argv __unused) +{ + int ch, aflag = 0, hflag = 0, nflag = 0, lflag = 0, rflag = 0, + uflag = 0; + char *rule = NULL; + + while ((ch = getopt(argc, argv, "a:hl:nr:u:")) != -1) { + switch (ch) { + case 'a': + aflag = 1; + rule = strdup(optarg); + break; + case 'h': + hflag = 1; + break; + case 'l': + lflag = 1; + rule = strdup(optarg); + break; + case 'n': + nflag = 1; + break; + case 'r': + rflag = 1; + rule = strdup(optarg); + break; + case 'u': + uflag = 1; + rule = strdup(optarg); + break; + + case '?': + default: + usage(); + } + } + + argc -= optind; + argv += optind; + + if (argc > 1) + usage(); + + if (rule == NULL) { + if (argc == 1) + rule = strdup(argv[0]); + else + rule = strdup("::"); + } + + if (aflag + lflag + rflag + uflag + argc > 1) + errx(1, "only one flag or argument may be specified " + "at the same time"); + + rule = resolve_ids(rule); + rule = expand_amount(rule); + + if (aflag) { + add_rule(rule); + return (0); + } + + if (lflag) { + show_limits(rule, hflag, nflag); + return (0); + } + + if (rflag) { + remove_rule(rule); + return (0); + } + + if (uflag) { + show_usage(rule, hflag); + return (0); + } + + show_rules(rule, hflag, nflag); + return (0); +} From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 18:32: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 664D11065676; Wed, 30 Mar 2011 18:32: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 53AF58FC16; Wed, 30 Mar 2011 18:32:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UIWjK5071778; Wed, 30 Mar 2011 18:32:45 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UIWjH0071775; Wed, 30 Mar 2011 18:32:45 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103301832.p2UIWjH0071775@svn.freebsd.org> From: Edward Tomasz Napierala Date: Wed, 30 Mar 2011 18:32: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: r220167 - 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: Wed, 30 Mar 2011 18:32:45 -0000 Author: trasz Date: Wed Mar 30 18:32:45 2011 New Revision: 220167 URL: http://svn.freebsd.org/changeset/base/220167 Log: Add startup script, to load rules from /etc/rctl.conf. Sponsored by: The FreeBSD Foundation Reviewed by: kib (ealier version) Added: head/etc/rc.d/rctl (contents, props changed) Modified: head/etc/rc.d/Makefile Modified: head/etc/rc.d/Makefile ============================================================================== --- head/etc/rc.d/Makefile Wed Mar 30 18:27:52 2011 (r220166) +++ head/etc/rc.d/Makefile Wed Mar 30 18:32:45 2011 (r220167) @@ -29,7 +29,7 @@ FILES= DAEMON FILESYSTEMS LOGIN NETWORKI pf pflog pfsync \ powerd power_profile ppp pppoed pwcheck \ quota \ - random rarpd resolv rfcomm_pppd_server root \ + random rarpd rctl resolv rfcomm_pppd_server root \ route6d routed routing rpcbind rtadvd rtsold rwho \ savecore sdpd securelevel sendmail \ serial sppp statd static_arp stf swap1 \ Added: head/etc/rc.d/rctl ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/etc/rc.d/rctl Wed Mar 30 18:32:45 2011 (r220167) @@ -0,0 +1,39 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: rctl +# BEFORE: LOGIN +# KEYWORD: nojail + +. /etc/rc.subr + +name="rctl" +start_cmd="rctl_start" +stop_cmd="rctl_stop" + +rctl_start() +{ + if [ -f /etc/rctl.conf ]; then + while read var comments + do + case ${var} in + \#*|'') + ;; + *) + rctl -a "${var}" + ;; + esac + done < /etc/rctl.conf + fi +} + +rctl_stop() +{ + + rctl -r : +} + +load_rc_config $name +run_rc_command "$1" From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 18:35: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 B96D4106566B; Wed, 30 Mar 2011 18:35:02 +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 A2A418FC15; Wed, 30 Mar 2011 18:35:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UIZ2bg071887; Wed, 30 Mar 2011 18:35:02 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UIZ2O8071886; Wed, 30 Mar 2011 18:35:02 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103301835.p2UIZ2O8071886@svn.freebsd.org> From: Edward Tomasz Napierala Date: Wed, 30 Mar 2011 18:35: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: r220168 - head/etc 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, 30 Mar 2011 18:35:02 -0000 Author: trasz Date: Wed Mar 30 18:35:02 2011 New Revision: 220168 URL: http://svn.freebsd.org/changeset/base/220168 Log: Add example devd.conf entry. Modified: head/etc/devd.conf Modified: head/etc/devd.conf ============================================================================== --- head/etc/devd.conf Wed Mar 30 18:32:45 2011 (r220167) +++ head/etc/devd.conf Wed Mar 30 18:35:02 2011 (r220168) @@ -301,6 +301,7 @@ detach 10 { # Button: Button pressed (0 for power, 1 for sleep) # CMBAT: ACPI battery events # Lid: Lid state (0 is closed, 1 is open) +# RCTL: Resource limits # Suspend, Resume: Suspend and resume notification # Thermal: ACPI thermal zone events # @@ -313,4 +314,13 @@ notify 10 { match "subsystem" "ACAD"; action "/etc/acpi_ac $notify"; }; + +# This example works around a memory leak in PostgreSQL, restarting +# it when "user:pgsql:swap:devctl=1G" rctl(8) rule gets triggered. +notify 0 { + match "system" "RCTL"; + match "rule" "user:70:swap:.*"; + action "/usr/local/etc/rc.d/postgresql restart" +}; + */ From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 20:13: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 A3ACB106566B; Wed, 30 Mar 2011 20:13:55 +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 90D768FC1B; Wed, 30 Mar 2011 20:13:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2UKDtFa079850; Wed, 30 Mar 2011 20:13:55 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2UKDtlV079848; Wed, 30 Mar 2011 20:13:55 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103302013.p2UKDtlV079848@svn.freebsd.org> From: Edward Tomasz Napierala Date: Wed, 30 Mar 2011 20:13: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: r220169 - head/usr.bin/rctl 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, 30 Mar 2011 20:13:55 -0000 Author: trasz Date: Wed Mar 30 20:13:55 2011 New Revision: 220169 URL: http://svn.freebsd.org/changeset/base/220169 Log: Fix grammar and bump date. Submitted by: trociny Modified: head/usr.bin/rctl/rctl.8 Modified: head/usr.bin/rctl/rctl.8 ============================================================================== --- head/usr.bin/rctl/rctl.8 Wed Mar 30 18:35:02 2011 (r220168) +++ head/usr.bin/rctl/rctl.8 Wed Mar 30 20:13:55 2011 (r220169) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 13, 2011 +.Dd March 30, 2011 .Dt RCTL 8 .Os .Sh NAME @@ -105,7 +105,7 @@ that each process of any user belonging up to 100MB of virtual memory. Rule "loginclass:users:vmem:deny=100M/user" would mean that for each user belonging to the login class "users", the sum of virtual memory allocated -by all the processes of a that user will not exceed 100MB. +by all the processes of that user will not exceed 100MB. Rule "loginclass:users:vmem:deny=100M/loginclass" would mean that the sum of virtual memory allocated by all processes of all users belonging to that login class will not exceed 100MB. From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 21:33: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 6881A1065672; Wed, 30 Mar 2011 21:33:23 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 557038FC0C; Wed, 30 Mar 2011 21:33:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2ULXNnA081574; Wed, 30 Mar 2011 21:33:23 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2ULXNGk081572; Wed, 30 Mar 2011 21:33:23 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <201103302133.p2ULXNGk081572@svn.freebsd.org> From: Edwin Groothuis Date: Wed, 30 Mar 2011 21:33: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: r220172 - head/usr.sbin/tzsetup 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, 30 Mar 2011 21:33:23 -0000 Author: edwin Date: Wed Mar 30 21:33:23 2011 New Revision: 220172 URL: http://svn.freebsd.org/changeset/base/220172 Log: Add a menu entry for UTC in the main menu. PR: bin/156019 Submitted by: Daniel O'Conner Reviewed by: Garrett Cooper MFC after: 1 week Modified: head/usr.sbin/tzsetup/tzsetup.c Modified: head/usr.sbin/tzsetup/tzsetup.c ============================================================================== --- head/usr.sbin/tzsetup/tzsetup.c Wed Mar 30 21:22:25 2011 (r220171) +++ head/usr.sbin/tzsetup/tzsetup.c Wed Mar 30 21:33:23 2011 (r220172) @@ -66,10 +66,13 @@ static int usedialog = 1; static char *chrootenv = NULL; static void usage(void); +static int confirm_zone(const char *filename); static int continent_country_menu(dialogMenuItem *); +static int install_zoneinfo_file(const char *zoneinfo_file); static int set_zone_multi(dialogMenuItem *); static int set_zone_whole_country(dialogMenuItem *); static int set_zone_menu(dialogMenuItem *); +static int set_zone_utc(void); struct continent { dialogMenuItem *menu; @@ -79,7 +82,7 @@ struct continent { }; static struct continent africa, america, antarctica, arctic, asia, atlantic; -static struct continent australia, europe, indian, pacific; +static struct continent australia, europe, indian, pacific, utc; static struct continent_names { const char *name; @@ -94,7 +97,8 @@ static struct continent_names { { "Australia", &australia }, { "Europe", &europe }, { "Indian", &indian }, - { "Pacific", &pacific } + { "Pacific", &pacific }, + { "UTC", &utc } }; static struct continent_items { @@ -110,7 +114,8 @@ static struct continent_items { { "7", "Australia" }, { "8", "Europe" }, { "9", "Indian Ocean" }, - { "0", "Pacific Ocean" } + { "0", "Pacific Ocean" }, + { "a", "UTC" } }; #define NCONTINENTS \ @@ -128,6 +133,9 @@ continent_country_menu(dialogMenuItem *c int menulen; int rv; + if (strcmp(continent->title, "UTC") == 0) + return set_zone_utc(); + /* Short cut -- if there's only one country, don't post a menu. */ if (contp->nitems == 1) return (contp->menu[0].fire(&contp->menu[0])); @@ -502,6 +510,15 @@ set_zone_menu(dialogMenuItem *dmi) return (DITEM_LEAVE_MENU); } +int +set_zone_utc(void) +{ + if (!confirm_zone(NULL)) + return (DITEM_FAILURE | DITEM_RECREATE); + + return (install_zoneinfo_file(NULL)); +} + static int install_zoneinfo_file(const char *zoneinfo_file) { @@ -526,7 +543,8 @@ install_zoneinfo_file(const char *zonein else snprintf(prompt, sizeof(prompt), "Creating symbolic link %s to %s", - path_localtime, zoneinfo_file); + path_localtime, + zoneinfo_file == NULL ? "(UTC)" : zoneinfo_file); if (usedialog) dialog_notify(prompt); else @@ -534,6 +552,22 @@ install_zoneinfo_file(const char *zonein #endif if (reallydoit) { + if (zoneinfo_file == NULL) { + if (unlink(path_localtime) < 0 && errno != ENOENT) { + snprintf(title, sizeof(title), "Error"); + snprintf(prompt, sizeof(prompt), + "Could not delete %s: %s", path_localtime, + strerror(errno)); + if (usedialog) + dialog_mesgbox(title, prompt, 8, 72); + else + fprintf(stderr, "%s\n", prompt); + + return (DITEM_FAILURE | DITEM_RECREATE); + } + return (DITEM_LEAVE_MENU); + } + if (copymode) { fd1 = open(zoneinfo_file, O_RDONLY, 0); if (fd1 < 0) { @@ -656,7 +690,7 @@ confirm_zone(const char *filename) struct tm *tm; int rv; - setenv("TZ", filename, 1); + setenv("TZ", filename == NULL ? "" : filename, 1); tzset(); tm = localtime(&t); From owner-svn-src-head@FreeBSD.ORG Wed Mar 30 21:40: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 CF4FB1065670; Wed, 30 Mar 2011 21:40:14 +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 BC5B48FC1B; Wed, 30 Mar 2011 21:40:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2ULeEpd081780; Wed, 30 Mar 2011 21:40:14 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2ULeE6G081778; Wed, 30 Mar 2011 21:40:14 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201103302140.p2ULeE6G081778@svn.freebsd.org> From: Mikolaj Golub Date: Wed, 30 Mar 2011 21:40: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: r220173 - head/sys/geom/gate 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, 30 Mar 2011 21:40:14 -0000 Author: trociny Date: Wed Mar 30 21:40:14 2011 New Revision: 220173 URL: http://svn.freebsd.org/changeset/base/220173 Log: Increase debug level on g_gate device destruction and add message on device creation. Suggested by: danger Approved by: pjd (mentor) MFC after: 3 days Modified: head/sys/geom/gate/g_gate.c Modified: head/sys/geom/gate/g_gate.c ============================================================================== --- head/sys/geom/gate/g_gate.c Wed Mar 30 21:33:23 2011 (r220172) +++ head/sys/geom/gate/g_gate.c Wed Mar 30 21:40:14 2011 (r220173) @@ -136,7 +136,7 @@ g_gate_destroy(struct g_gate_softc *sc, mtx_unlock(&g_gate_units_lock); mtx_destroy(&sc->sc_queue_mtx); g_topology_lock(); - G_GATE_DEBUG(0, "Device %s destroyed.", gp->name); + G_GATE_DEBUG(1, "Device %s destroyed.", gp->name); gp->softc = NULL; g_wither_geom(gp, ENXIO); sc->sc_provider = NULL; @@ -438,6 +438,7 @@ g_gate_create(struct g_gate_ctl_create * mtx_lock(&g_gate_units_lock); sc->sc_name = sc->sc_provider->name; mtx_unlock(&g_gate_units_lock); + G_GATE_DEBUG(1, "Device %s created.", gp->name); if (sc->sc_timeout > 0) { callout_reset(&sc->sc_callout, sc->sc_timeout * hz, From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 01:26: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 A7C20106564A; Thu, 31 Mar 2011 01:26:18 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-iy0-f182.google.com (mail-iy0-f182.google.com [209.85.210.182]) by mx1.freebsd.org (Postfix) with ESMTP id 46EDF8FC16; Thu, 31 Mar 2011 01:26:18 +0000 (UTC) Received: by iyj12 with SMTP id 12so2378986iyj.13 for ; Wed, 30 Mar 2011 18:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=jy/2Ls3Vr08SXeNeGkjAItzFMDxP2/NcahZQXYrsNWY=; b=uuIdHGe5hei6uRRk1M4iVSC1C74l7odVheHX8fItTb5+nilT5rNQqJ6gJr71AzPzDj IwZ0lyf9Zepl3p77/zSDNAE6EcFBC2JTyzKOCSOCkUXRDNEHgnn5zNvdLkyv+tCTurls 9YtPIUH9cWx8KQBRqskhzoRDeFXHYqZ8Kb5hE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=HO3A5llL/tRvoWDs/tpwEmHsLIutmOQa5jUku6cfPK7niUKeIrO0Vf70y/VIh4l8X8 ApiTTUsH07BULieChVzSztUWYyWR5+nPvosMCpOLTlJ2gY3o6TDvtmpcmvXBJ+B+4Hcd fypMKOuqX3TWE9UexWFdw43PUFxF/iwCXwyMk= MIME-Version: 1.0 Received: by 10.43.45.7 with SMTP id ui7mr1946638icb.262.1301534775964; Wed, 30 Mar 2011 18:26:15 -0700 (PDT) Received: by 10.231.168.74 with HTTP; Wed, 30 Mar 2011 18:26:15 -0700 (PDT) In-Reply-To: <201103301737.p2UHb4j7070331@svn.freebsd.org> References: <201103301737.p2UHb4j7070331@svn.freebsd.org> Date: Wed, 30 Mar 2011 18:26:15 -0700 Message-ID: From: Garrett Cooper To: Josh Paetzel 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: r220162 - head/usr.sbin/pc-sysinstall/backend-partmanager 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, 31 Mar 2011 01:26:18 -0000 On Wed, Mar 30, 2011 at 10:37 AM, Josh Paetzel wrote= : > Author: jpaetzel > Date: Wed Mar 30 17:37:04 2011 > New Revision: 220162 > URL: http://svn.freebsd.org/changeset/base/220162 > > Log: > =A0Check in two missing files missed in cleanup. > =A0Change expr to $(()) > =A0Switch test from "$?" =3D "0" to $? -eq 0 > > =A0Approved by: =A0kib (mentor) > > Modified: > =A0head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh > =A0head/usr.sbin/pc-sysinstall/backend-partmanager/delete-part.sh > > Modified: head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=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/pc-sysinstall/backend-partmanager/create-part.sh =A0 = =A0 =A0Wed Mar 30 17:33:52 2011 =A0 =A0 =A0 =A0(r220161) > +++ head/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh =A0 = =A0 =A0Wed Mar 30 17:37:04 2011 =A0 =A0 =A0 =A0(r220162) > @@ -85,7 +85,7 @@ fi > > =A0# If this is an empty disk, see if we need to create a new scheme for = it > =A0gpart show ${DISK} >/dev/null 2>/dev/null > -if [ "$?" !=3D "0" -a "${SLICENUM}" =3D "1" ] ; then > +if [ $? -eq 0 -a "${SLICENUM}" =3D "1" ] ; then > =A0gpart create -s ${TYPE} ${DISK} > =A0fi > > > Modified: head/usr.sbin/pc-sysinstall/backend-partmanager/delete-part.sh > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=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/pc-sysinstall/backend-partmanager/delete-part.sh =A0 = =A0 =A0Wed Mar 30 17:33:52 2011 =A0 =A0 =A0 =A0(r220161) > +++ head/usr.sbin/pc-sysinstall/backend-partmanager/delete-part.sh =A0 = =A0 =A0Wed Mar 30 17:37:04 2011 =A0 =A0 =A0 =A0(r220162) > @@ -57,10 +57,10 @@ PARTINDEX=3D"" > =A0while > =A0z=3D1 > =A0do > - =A0CHARS=3D`expr $CHARS - 1` > + =A0CHARS=3D$((CHARS-1)) This can also be done with the null operator: : $(( CHARS -=3D 1 )) it's the way that the LTP project (which I'm still a member of) does things in order to be 'portable' (non-portable being bash/korn shell isms for what little it's worth :)..). > =A0 LAST_CHAR=3D`echo "${PARTITION}" | cut -c $CHARS` > - =A0echo "${LAST_CHAR}" | grep "^[0-9]$" >/dev/null 2>/dev/null > - =A0if [ "$?" =3D "0" ] ; then > + =A0echo "${LAST_CHAR}" | grep -q "^[0-9]$" 2>/dev/null > + =A0if [ $? -eq 0 ] ; then > =A0 =A0 PARTINDEX=3D"${LAST_CHAR}${PARTINDEX}" > =A0 else > =A0 =A0 break Thanks! -Garrett From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 02:36:22 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 F1FBF106564A; Thu, 31 Mar 2011 02:36:22 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C74AB8FC21; Thu, 31 Mar 2011 02:36:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V2aMLX088679; Thu, 31 Mar 2011 02:36:22 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V2aMwD088676; Thu, 31 Mar 2011 02:36:22 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103310236.p2V2aMwD088676@svn.freebsd.org> From: Adrian Chadd Date: Thu, 31 Mar 2011 02:36:22 +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: r220180 - head/sys/mips/atheros 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, 31 Mar 2011 02:36:23 -0000 Author: adrian Date: Thu Mar 31 02:36:22 2011 New Revision: 220180 URL: http://svn.freebsd.org/changeset/base/220180 Log: Implement AR724x USB initialisation code. This (again) still requires an offset for the AR913x/AR724x before USB will function. Submitted by: Luiz Otavio O Souzau Modified: head/sys/mips/atheros/ar724x_chip.c head/sys/mips/atheros/ar724xreg.h Modified: head/sys/mips/atheros/ar724x_chip.c ============================================================================== --- head/sys/mips/atheros/ar724x_chip.c Thu Mar 31 01:14:06 2011 (r220179) +++ head/sys/mips/atheros/ar724x_chip.c Thu Mar 31 02:36:22 2011 (r220180) @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include static void @@ -151,6 +152,50 @@ ar724x_chip_get_eth_pll(unsigned int mac return 0; } +static void +ar724x_chip_init_usb_peripheral(void) +{ + + switch (ar71xx_soc) { + case AR71XX_SOC_AR7240: + + ar71xx_device_stop(AR724X_RESET_MODULE_USB_OHCI_DLL | + AR724X_RESET_USB_HOST); + DELAY(1000); + + ar71xx_device_start(AR724X_RESET_MODULE_USB_OHCI_DLL | + AR724X_RESET_USB_HOST); + DELAY(1000); + + /* + * WAR for HW bug. Here it adjusts the duration + * between two SOFS. + */ + ATH_WRITE_REG(AR71XX_USB_CTRL_FLADJ, + (3 << USB_CTRL_FLADJ_A0_SHIFT)); + + break; + + case AR71XX_SOC_AR7241: + case AR71XX_SOC_AR7242: + + ar71xx_device_start(AR724X_RESET_MODULE_USB_OHCI_DLL); + DELAY(100); + + ar71xx_device_start(AR724X_RESET_USB_HOST); + DELAY(100); + + ar71xx_device_start(AR724X_RESET_USB_PHY); + DELAY(100); + + break; + + default: + /* fallthrough */ + break; + } +} + struct ar71xx_cpu_def ar724x_chip_def = { &ar724x_chip_detect_mem_size, &ar724x_chip_detect_sys_frequency, @@ -163,5 +208,5 @@ struct ar71xx_cpu_def ar724x_chip_def = &ar724x_chip_ddr_flush_ge1, &ar724x_chip_get_eth_pll, NULL, /* ar71xx_chip_irq_flush_ip2 */ - NULL /* ar71xx_chip_init_usb_peripheral */ + &ar724x_chip_init_usb_peripheral }; Modified: head/sys/mips/atheros/ar724xreg.h ============================================================================== --- head/sys/mips/atheros/ar724xreg.h Thu Mar 31 01:14:06 2011 (r220179) +++ head/sys/mips/atheros/ar724xreg.h Thu Mar 31 02:36:22 2011 (r220180) @@ -51,6 +51,8 @@ #define AR724X_DDR_REG_FLUSH_GE1 (AR71XX_DDR_CONFIG + 0x80) #define AR724X_RESET_REG_RESET_MODULE AR71XX_RST_BLOCK_BASE + 0x1c +#define AR724X_RESET_USB_HOST (1 << 5) +#define AR724X_RESET_USB_PHY (1 << 4) #define AR724X_RESET_MODULE_USB_OHCI_DLL (1 << 3) /* XXX so USB requires different init code? -adrian */ From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 06:11: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 546EA106566C; Thu, 31 Mar 2011 06:11:50 +0000 (UTC) (envelope-from martymac@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 290DA8FC08; Thu, 31 Mar 2011 06:11:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V6Bob0093483; Thu, 31 Mar 2011 06:11:50 GMT (envelope-from martymac@svn.freebsd.org) Received: (from martymac@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V6Bowt093481; Thu, 31 Mar 2011 06:11:50 GMT (envelope-from martymac@svn.freebsd.org) Message-Id: <201103310611.p2V6Bowt093481@svn.freebsd.org> From: Ganael LAPLANCHE Date: Thu, 31 Mar 2011 06:11: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: r220182 - head/share/misc 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, 31 Mar 2011 06:11:50 -0000 Author: martymac (ports committer) Date: Thu Mar 31 06:11:49 2011 New Revision: 220182 URL: http://svn.freebsd.org/changeset/base/220182 Log: Add relation to my mentor (ehaupt) Modified: head/share/misc/committers-ports.dot Modified: head/share/misc/committers-ports.dot ============================================================================== --- head/share/misc/committers-ports.dot Thu Mar 31 04:49:07 2011 (r220181) +++ head/share/misc/committers-ports.dot Thu Mar 31 06:11:49 2011 (r220182) @@ -231,6 +231,7 @@ edwin -> linimon edwin -> lx ehaupt -> db +ehaupt -> martymac eik -> sem eik -> trhodes From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 06:31:00 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 33F941065670; Thu, 31 Mar 2011 06:31:00 +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 22FB38FC19; Thu, 31 Mar 2011 06:31:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V6V0bt093993; Thu, 31 Mar 2011 06:31:00 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V6V0ap093991; Thu, 31 Mar 2011 06:31:00 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201103310631.p2V6V0ap093991@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Thu, 31 Mar 2011 06:31:00 +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: r220184 - head/sys/geom/nop 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, 31 Mar 2011 06:31:00 -0000 Author: ae Date: Thu Mar 31 06:30:59 2011 New Revision: 220184 URL: http://svn.freebsd.org/changeset/base/220184 Log: Remove unneeded checks, g_new_xxx functions can not return NULL. Reviewed by: pjd MFC after: 1 week Modified: head/sys/geom/nop/g_nop.c Modified: head/sys/geom/nop/g_nop.c ============================================================================== --- head/sys/geom/nop/g_nop.c Thu Mar 31 06:29:15 2011 (r220183) +++ head/sys/geom/nop/g_nop.c Thu Mar 31 06:30:59 2011 (r220184) @@ -189,10 +189,6 @@ g_nop_create(struct gctl_req *req, struc } } gp = g_new_geomf(mp, name); - if (gp == NULL) { - gctl_error(req, "Cannot create geom %s.", name); - return (ENOMEM); - } sc = g_malloc(sizeof(*sc), M_WAITOK); sc->sc_offset = offset; sc->sc_error = ioerror; @@ -209,20 +205,10 @@ g_nop_create(struct gctl_req *req, struc gp->dumpconf = g_nop_dumpconf; newpp = g_new_providerf(gp, gp->name); - if (newpp == NULL) { - gctl_error(req, "Cannot create provider %s.", name); - error = ENOMEM; - goto fail; - } newpp->mediasize = size; newpp->sectorsize = secsize; cp = g_new_consumer(gp); - if (cp == NULL) { - gctl_error(req, "Cannot create consumer for %s.", gp->name); - error = ENOMEM; - goto fail; - } error = g_attach(cp, pp); if (error != 0) { gctl_error(req, "Cannot attach to provider %s.", pp->name); @@ -233,18 +219,12 @@ g_nop_create(struct gctl_req *req, struc G_NOP_DEBUG(0, "Device %s created.", gp->name); return (0); fail: - if (cp != NULL) { - if (cp->provider != NULL) - g_detach(cp); - g_destroy_consumer(cp); - } - if (newpp != NULL) - g_destroy_provider(newpp); - if (gp != NULL) { - if (gp->softc != NULL) - g_free(gp->softc); - g_destroy_geom(gp); - } + if (cp->provider != NULL) + g_detach(cp); + g_destroy_consumer(cp); + g_destroy_provider(newpp); + g_free(gp->softc); + g_destroy_geom(gp); return (error); } From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 07: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 74B8B106564A; Thu, 31 Mar 2011 07:33:21 +0000 (UTC) (envelope-from inyaoo@gmail.com) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id 894948FC15; Thu, 31 Mar 2011 07:33:20 +0000 (UTC) Received: by wwc33 with SMTP id 33so2361436wwc.31 for ; Thu, 31 Mar 2011 00:33:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=klQiR4eO0devedTFbYsUS75UNr9DnuDCw4enHfMdjZA=; b=ofoJGIRdmSn+BRa86cfQ5nITjnLj5/Cn1zMmFpRcGyZXzRJ2tJ7pxy7g6Z29WPd2jG buz0COpypeg0CNOyjeH/i6bOmbTko1ddMKLa9yyhWTusollyV6OOzov0oOzFe9wG8k7U a5d+YIKOfCUDIyl+74SkFO5hUPEm01MdQFeDU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=f+EAdj7MDPUtzTyUj9IwDNt915L9KoSCaDZ+c6Ropmz1m2S8L8RjK/fYzX3MvG9G96 i4CAdjuT0C3Ig5wCEqbgCtdFOpn5ToF1kkX6oYwx0MrYGvc8t8ulA7hoz1D/EAOhuhCP xZdikyZ3rd2cojnOBcnkRYXYdNnQ8Y2P9Pi5Y= Received: by 10.227.200.75 with SMTP id ev11mr2384763wbb.56.1301555274140; Thu, 31 Mar 2011 00:07:54 -0700 (PDT) Received: from localhost (tor6.anonymizer.ccc.de [80.237.226.76]) by mx.google.com with ESMTPS id x1sm474230wbh.2.2011.03.31.00.07.48 (version=SSLv3 cipher=OTHER); Thu, 31 Mar 2011 00:07:52 -0700 (PDT) From: Pan Tsu To: Konstantin Belousov References: <201103301446.p2UEkDDk066511@svn.freebsd.org> Date: Thu, 31 Mar 2011 11:07:36 +0400 In-Reply-To: <201103301446.p2UEkDDk066511@svn.freebsd.org> (Konstantin Belousov's message of "Wed, 30 Mar 2011 14:46:13 +0000 (UTC)") Message-ID: <8662qzu5s7.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r220158 - in head/sys: compat/freebsd32 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, 31 Mar 2011 07:33:21 -0000 Konstantin Belousov writes: > Author: kib > Date: Wed Mar 30 14:46:12 2011 > New Revision: 220158 > URL: http://svn.freebsd.org/changeset/base/220158 > > Log: > Provide compat32 shims for kldstat(2). > > Requested and tested by: jpaetzel > MFC after: 1 week It breaks loading modules from loader(8) for me. The box panics early #13 0xffffffff804f2f2a in sysctl_find_oidname (name=0xffffffff80eec156 "kstat", list=0x657a69735f796c) at /usr/src/sys/kern/kern_sysctl.c:106 #14 0xffffffff804f3e69 in sysctl_register_oid (oidp=0xffffffff80ef0a80) at /usr/src/sys/kern/kern_sysctl.c:149 #15 0xffffffff804cb83c in linker_file_register_sysctls (lf=Variable "lf" is not available. ) at /usr/src/sys/kern/kern_linker.c:301 #16 0xffffffff804cd112 in linker_preload (arg=Variable "arg" is not available. ) at /usr/src/sys/kern/kern_linker.c:1624 #17 0xffffffff80499ad7 in mi_startup () at /usr/src/sys/kern/init_main.c:258 #18 0xffffffff80299a3c in btext () at /usr/src/sys/amd64/amd64/locore.S:81 [...] From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 08: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 A8532106566C; Thu, 31 Mar 2011 08:07:13 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 962CC8FC15; Thu, 31 Mar 2011 08:07:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V87DGs096069; Thu, 31 Mar 2011 08:07:13 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V87DHV096049; Thu, 31 Mar 2011 08:07:13 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103310807.p2V87DHV096049@svn.freebsd.org> From: Adrian Chadd Date: Thu, 31 Mar 2011 08:07: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: r220185 - in head/sys: amd64/conf arm/conf conf dev/ath i386/conf mips/conf modules modules/ath modules/ath_ahb modules/ath_pci pc98/conf sparc64/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: Thu, 31 Mar 2011 08:07:13 -0000 Author: adrian Date: Thu Mar 31 08:07:13 2011 New Revision: 220185 URL: http://svn.freebsd.org/changeset/base/220185 Log: Break out the ath PCI logic into a separate device/module. Introduce the AHB glue for Atheros embedded systems. Right now it's hard-coded for the AR9130 chip whose support isn't yet in this HAL; it'll be added in a subsequent commit. Kernel configuration files now need both 'ath' and 'ath_pci' devices; both modules need to be loaded for the ath device to work. Added: head/sys/dev/ath/if_ath_ahb.c (contents, props changed) head/sys/modules/ath_ahb/ head/sys/modules/ath_ahb/Makefile (contents, props changed) head/sys/modules/ath_pci/ head/sys/modules/ath_pci/Makefile (contents, props changed) Modified: head/sys/amd64/conf/GENERIC head/sys/arm/conf/AVILA head/sys/arm/conf/CAMBRIA head/sys/conf/files head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_ath_pci.c head/sys/i386/conf/GENERIC head/sys/i386/conf/PAE head/sys/mips/conf/AR71XX head/sys/mips/conf/IDT head/sys/mips/conf/OCTEON1 head/sys/mips/conf/SENTRY5 head/sys/modules/Makefile head/sys/modules/ath/Makefile head/sys/pc98/conf/GENERIC head/sys/sparc64/conf/GENERIC Modified: head/sys/amd64/conf/GENERIC ============================================================================== --- head/sys/amd64/conf/GENERIC Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/amd64/conf/GENERIC Thu Mar 31 08:07:13 2011 (r220185) @@ -257,7 +257,8 @@ device wlan_ccmp # 802.11 CCMP support device wlan_tkip # 802.11 TKIP support device wlan_amrr # AMRR transmit rate control algorithm device an # Aironet 4500/4800 802.11 wireless NICs. -device ath # Atheros pci/cardbus NIC's +device ath # Atheros NIC's +device ath_pci # Atheros pci/cardbus glue device ath_hal # pci/cardbus chip support options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors device ath_rate_sample # SampleRate tx rate control for ath Modified: head/sys/arm/conf/AVILA ============================================================================== --- head/sys/arm/conf/AVILA Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/arm/conf/AVILA Thu Mar 31 08:07:13 2011 (r220185) @@ -120,7 +120,8 @@ device wlan_ccmp # 802.11 CCMP support device wlan_tkip # 802.11 TKIP support device wlan_xauth -device ath # Atheros pci/cardbus NIC's +device ath # Atheros NIC's +device ath_pci # Atheros pci/cardbus glue options ATH_DEBUG options ATH_DIAGAPI #options ATH_TX99_DIAG Modified: head/sys/arm/conf/CAMBRIA ============================================================================== --- head/sys/arm/conf/CAMBRIA Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/arm/conf/CAMBRIA Thu Mar 31 08:07:13 2011 (r220185) @@ -123,7 +123,8 @@ device wlan_ccmp # 802.11 CCMP support device wlan_tkip # 802.11 TKIP support device wlan_xauth -device ath # Atheros pci/cardbus NIC's +device ath # Atheros NIC's +device ath_pci # Atheros pci/cardbus glue options ATH_DEBUG options ATH_DIAGAPI #options ATH_TX99_DIAG Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/conf/files Thu Mar 31 08:07:13 2011 (r220185) @@ -570,6 +570,12 @@ dev/ata/atapi-fd.c optional atapifd dev/ata/atapi-tape.c optional atapist dev/ata/atapi-cam.c optional atapicam # +dev/ath/if_ath_pci.c optional ath_pci pci \ + compile-with "${NORMAL_C} -I$S/dev/ath" +# +dev/ath/if_ath_ahb.c optional ath_ahb \ + compile-with "${NORMAL_C} -I$S/dev/ath" +# dev/ath/if_ath.c optional ath \ compile-with "${NORMAL_C} -I$S/dev/ath" dev/ath/if_ath_debug.c optional ath \ @@ -582,8 +588,6 @@ dev/ath/if_ath_tx_ht.c optional ath \ compile-with "${NORMAL_C} -I$S/dev/ath" dev/ath/if_ath_sysctl.c optional ath \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/if_ath_pci.c optional ath pci \ - compile-with "${NORMAL_C} -I$S/dev/ath" dev/ath/ah_osdep.c optional ath \ compile-with "${NORMAL_C} -I$S/dev/ath" # Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/dev/ath/if_ath.c Thu Mar 31 08:07:13 2011 (r220185) @@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -5591,3 +5592,5 @@ ath_tdma_beacon_send(struct ath_softc *s } #endif /* IEEE80211_SUPPORT_TDMA */ +MODULE_VERSION(if_ath, 1); +MODULE_DEPEND(if_ath, wlan, 1, 1, 1); /* 802.11 media layer */ Added: head/sys/dev/ath/if_ath_ahb.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/ath/if_ath_ahb.c Thu Mar 31 08:07:13 2011 (r220185) @@ -0,0 +1,287 @@ +/*- + * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting + * Copyright (c) 2010-2011 Adrian Chadd, Xenion Pty Ltd + * 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, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any + * redistribution must be conditioned upon including a substantially + * similar Disclaimer requirement for further binary redistribution. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * AHB bus front-end for the Atheros Wireless LAN controller driver. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include + +#include + +#include +#include +#include + +/* + * bus glue. + */ + +/* number of 16 bit words */ +#define ATH_EEPROM_DATA_SIZE 2048 + +struct ath_ahb_softc { + struct ath_softc sc_sc; + struct resource *sc_sr; /* memory resource */ + struct resource *sc_irq; /* irq resource */ + struct resource *sc_eeprom; /* eeprom location */ + void *sc_ih; /* interrupt handler */ +}; + +#define VENDOR_ATHEROS 0x168c +#define AR9100_DEVID 0x000b + +static int +ath_ahb_probe(device_t dev) +{ + const char* devname; + + /* Atheros / ar9100 */ + devname = ath_hal_probe(VENDOR_ATHEROS, AR9100_DEVID); + + if (devname != NULL) { + device_set_desc(dev, devname); + return BUS_PROBE_DEFAULT; + } + return ENXIO; +} + +static int +ath_ahb_attach(device_t dev) +{ + struct ath_ahb_softc *psc = device_get_softc(dev); + struct ath_softc *sc = &psc->sc_sc; + int error = ENXIO; + int rid; + long eepromaddr; + uint8_t *p; + + sc->sc_dev = dev; + + rid = 0; + psc->sc_sr = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); + if (psc->sc_sr == NULL) { + device_printf(dev, "cannot map register space\n"); + goto bad; + } + + if (resource_long_value(device_get_name(dev), device_get_unit(dev), + "eepromaddr", &eepromaddr) != 0) { + device_printf(dev, "cannot fetch 'eepromaddr' from hints\n"); + goto bad0; + } + rid = 0; + device_printf(sc->sc_dev, "eeprom @ %p\n", (void *) eepromaddr); + psc->sc_eeprom = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, (uintptr_t) eepromaddr, + (uintptr_t) eepromaddr + (uintptr_t) ((ATH_EEPROM_DATA_SIZE * 2) - 1), 0, RF_ACTIVE); + if (psc->sc_sr == NULL) { + device_printf(dev, "cannot map eeprom space\n"); + goto bad0; + } + + /* XXX uintptr_t is a bandaid for ia64; to be fixed */ + sc->sc_st = (HAL_BUS_TAG)(uintptr_t) rman_get_bustag(psc->sc_sr); + sc->sc_sh = (HAL_BUS_HANDLE) rman_get_bushandle(psc->sc_sr); + /* + * Mark device invalid so any interrupts (shared or otherwise) + * that arrive before the HAL is setup are discarded. + */ + sc->sc_invalid = 1; + + /* Copy the EEPROM data out */ + sc->sc_eepromdata = malloc(ATH_EEPROM_DATA_SIZE * 2, M_TEMP, M_NOWAIT | M_ZERO); + device_printf(sc->sc_dev, "eeprom data @ %p\n", (void *) rman_get_bushandle(psc->sc_eeprom)); + /* XXX why doesn't this work? -adrian */ +#if 0 + bus_space_read_multi_1( + rman_get_bustag(psc->sc_eeprom), + rman_get_bushandle(psc->sc_eeprom), + 0, (u_int8_t *) sc->sc_eepromdata, ATH_EEPROM_DATA_SIZE * 2); +#endif + p = (void *) rman_get_bushandle(psc->sc_eeprom); + memcpy(sc->sc_eepromdata, p, ATH_EEPROM_DATA_SIZE * 2); + + /* + * Arrange interrupt line. + */ + rid = 0; + psc->sc_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_SHAREABLE|RF_ACTIVE); + if (psc->sc_irq == NULL) { + device_printf(dev, "could not map interrupt\n"); + goto bad1; + } + if (bus_setup_intr(dev, psc->sc_irq, + INTR_TYPE_NET | INTR_MPSAFE, + NULL, ath_intr, sc, &psc->sc_ih)) { + device_printf(dev, "could not establish interrupt\n"); + goto bad2; + } + + /* + * Setup DMA descriptor area. + */ + if (bus_dma_tag_create(bus_get_dma_tag(dev), /* parent */ + 1, 0, /* alignment, bounds */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + 0x3ffff, /* maxsize XXX */ + ATH_MAX_SCATTER, /* nsegments */ + 0x3ffff, /* maxsegsize XXX */ + BUS_DMA_ALLOCNOW, /* flags */ + NULL, /* lockfunc */ + NULL, /* lockarg */ + &sc->sc_dmat)) { + device_printf(dev, "cannot allocate DMA tag\n"); + goto bad3; + } + + ATH_LOCK_INIT(sc); + + error = ath_attach(AR9100_DEVID, sc); + if (error == 0) /* success */ + return 0; + + ATH_LOCK_DESTROY(sc); + bus_dma_tag_destroy(sc->sc_dmat); +bad3: + bus_teardown_intr(dev, psc->sc_irq, psc->sc_ih); +bad2: + bus_release_resource(dev, SYS_RES_IRQ, 0, psc->sc_irq); +bad1: + bus_release_resource(dev, SYS_RES_MEMORY, 0, psc->sc_eeprom); +bad0: + bus_release_resource(dev, SYS_RES_MEMORY, 0, psc->sc_sr); +bad: + /* XXX?! */ + if (sc->sc_eepromdata) + free(sc->sc_eepromdata, M_TEMP); + return (error); +} + +static int +ath_ahb_detach(device_t dev) +{ + struct ath_ahb_softc *psc = device_get_softc(dev); + struct ath_softc *sc = &psc->sc_sc; + + /* check if device was removed */ + sc->sc_invalid = !bus_child_present(dev); + + ath_detach(sc); + + bus_generic_detach(dev); + bus_teardown_intr(dev, psc->sc_irq, psc->sc_ih); + bus_release_resource(dev, SYS_RES_IRQ, 0, psc->sc_irq); + + bus_dma_tag_destroy(sc->sc_dmat); + bus_release_resource(dev, SYS_RES_MEMORY, 0, psc->sc_sr); + bus_release_resource(dev, SYS_RES_MEMORY, 0, psc->sc_eeprom); + /* XXX?! */ + if (sc->sc_eepromdata) + free(sc->sc_eepromdata, M_TEMP); + + ATH_LOCK_DESTROY(sc); + + return (0); +} + +static int +ath_ahb_shutdown(device_t dev) +{ + struct ath_ahb_softc *psc = device_get_softc(dev); + + ath_shutdown(&psc->sc_sc); + return (0); +} + +static int +ath_ahb_suspend(device_t dev) +{ + struct ath_ahb_softc *psc = device_get_softc(dev); + + ath_suspend(&psc->sc_sc); + + return (0); +} + +static int +ath_ahb_resume(device_t dev) +{ + struct ath_ahb_softc *psc = device_get_softc(dev); + + ath_resume(&psc->sc_sc); + + return (0); +} + +static device_method_t ath_ahb_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, ath_ahb_probe), + DEVMETHOD(device_attach, ath_ahb_attach), + DEVMETHOD(device_detach, ath_ahb_detach), + DEVMETHOD(device_shutdown, ath_ahb_shutdown), + DEVMETHOD(device_suspend, ath_ahb_suspend), + DEVMETHOD(device_resume, ath_ahb_resume), + + { 0,0 } +}; +static driver_t ath_ahb_driver = { + "ath", + ath_ahb_methods, + sizeof (struct ath_ahb_softc) +}; +static devclass_t ath_devclass; +DRIVER_MODULE(ath, nexus, ath_ahb_driver, ath_devclass, 0, 0); +MODULE_VERSION(ath, 1); +MODULE_DEPEND(ath, wlan, 1, 1, 1); /* 802.11 media layer */ +MODULE_DEPEND(ath, if_ath, 1, 1, 1); /* if_ath driver */ Modified: head/sys/dev/ath/if_ath_pci.c ============================================================================== --- head/sys/dev/ath/if_ath_pci.c Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/dev/ath/if_ath_pci.c Thu Mar 31 08:07:13 2011 (r220185) @@ -250,6 +250,7 @@ static driver_t ath_pci_driver = { sizeof (struct ath_pci_softc) }; static devclass_t ath_devclass; -DRIVER_MODULE(ath, pci, ath_pci_driver, ath_devclass, 0, 0); -MODULE_VERSION(ath, 1); -MODULE_DEPEND(ath, wlan, 1, 1, 1); /* 802.11 media layer */ +DRIVER_MODULE(ath_pci, pci, ath_pci_driver, ath_devclass, 0, 0); +MODULE_VERSION(ath_pci, 1); +MODULE_DEPEND(ath_pci, wlan, 1, 1, 1); /* 802.11 media layer */ +MODULE_DEPEND(ath_pci, if_ath, 1, 1, 1); /* if_ath driver */ Modified: head/sys/i386/conf/GENERIC ============================================================================== --- head/sys/i386/conf/GENERIC Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/i386/conf/GENERIC Thu Mar 31 08:07:13 2011 (r220185) @@ -269,7 +269,8 @@ device wlan_ccmp # 802.11 CCMP support device wlan_tkip # 802.11 TKIP support device wlan_amrr # AMRR transmit rate control algorithm device an # Aironet 4500/4800 802.11 wireless NICs. -device ath # Atheros pci/cardbus NIC's +device ath # Atheros NIC's +device ath_pci # Atheros pci/cardbus glue device ath_hal # pci/cardbus chip support options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors device ath_rate_sample # SampleRate tx rate control for ath Modified: head/sys/i386/conf/PAE ============================================================================== --- head/sys/i386/conf/PAE Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/i386/conf/PAE Thu Mar 31 08:07:13 2011 (r220185) @@ -74,6 +74,7 @@ nodevice xe nodevice an nodevice ath # Atheros pci/cardbus NIC's +nodevice ath_pci nodevice ath_hal nodevice ath_rate_sample # SampleRate tx rate control for ath nodevice ral Modified: head/sys/mips/conf/AR71XX ============================================================================== --- head/sys/mips/conf/AR71XX Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/mips/conf/AR71XX Thu Mar 31 08:07:13 2011 (r220185) @@ -55,7 +55,8 @@ device wlan_wep # 802.11 WEP sup device wlan_ccmp # 802.11 CCMP support device wlan_tkip # 802.11 TKIP support -device ath # Atheros pci/cardbus NIC's +device ath # Atheros NIC's +device ath_pci # Atheros pci/cardbus glue options ATH_DEBUG device ath_hal option AH_SUPPORT_AR5416 Modified: head/sys/mips/conf/IDT ============================================================================== --- head/sys/mips/conf/IDT Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/mips/conf/IDT Thu Mar 31 08:07:13 2011 (r220185) @@ -44,7 +44,8 @@ device md device wlan # 802.11 support device wlan_wep # 802.11 WEP support device wlan_tkip # 802.11 TKIP support -device ath # Atheros pci/cardbus NIC's +device ath # Atheros NIC's +device ath_pci # Atheros pci/cardbus glue device ath_hal # pci/cardbus chip support options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors device ath_rate_sample # SampleRate tx rate control for ath Modified: head/sys/mips/conf/OCTEON1 ============================================================================== --- head/sys/mips/conf/OCTEON1 Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/mips/conf/OCTEON1 Thu Mar 31 08:07:13 2011 (r220185) @@ -237,7 +237,7 @@ device wlan_ccmp # 802.11 CCMP support device wlan_tkip # 802.11 TKIP support device wlan_amrr # AMRR transmit rate control algorithm device an # Aironet 4500/4800 802.11 wireless NICs. -device ath # Atheros pci/cardbus NIC's +device ath # Atheros NIC's device ath_hal # pci/cardbus chip support options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors device ath_rate_sample # SampleRate tx rate control for ath Modified: head/sys/mips/conf/SENTRY5 ============================================================================== --- head/sys/mips/conf/SENTRY5 Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/mips/conf/SENTRY5 Thu Mar 31 08:07:13 2011 (r220185) @@ -66,6 +66,7 @@ device pci # siba_pcib # pci devices # notyet: #device ath # in pci slot +#device ath_pci # Atheros pci/cardbus glue #device ath_hal # pci chip support #options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors Modified: head/sys/modules/Makefile ============================================================================== --- head/sys/modules/Makefile Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/modules/Makefile Thu Mar 31 08:07:13 2011 (r220185) @@ -35,6 +35,8 @@ SUBDIR= ${_3dfx} \ ${_asr} \ ata \ ath \ + ath_ahb \ + ath_pci \ ${_auxio} \ bce \ bfe \ Modified: head/sys/modules/ath/Makefile ============================================================================== --- head/sys/modules/ath/Makefile Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/modules/ath/Makefile Thu Mar 31 08:07:13 2011 (r220185) @@ -35,7 +35,7 @@ ATH_RATE?= sample # tx rate control alg .PATH: ${.CURDIR}/../../dev/ath/ath_hal KMOD= if_ath -SRCS= if_ath.c if_ath_pci.c if_ath_debug.c if_ath_keycache.c if_ath_sysctl.c +SRCS= if_ath.c if_ath_debug.c if_ath_keycache.c if_ath_sysctl.c SRCS+= if_ath_tx.c if_ath_tx_ht.c # NB: v3 eeprom support used by both AR5211 and AR5212; just include it SRCS+= ah_osdep.c ah.c ah_regdomain.c ah_eeprom_v3.c Added: head/sys/modules/ath_ahb/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/modules/ath_ahb/Makefile Thu Mar 31 08:07:13 2011 (r220185) @@ -0,0 +1,41 @@ +# +# Copyright (c) 2011 Adrian Chadd, Xenion Pty Ltd +# 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, +# without modification. +# 2. Redistributions in binary form must reproduce at minimum a disclaimer +# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any +# redistribution must be conditioned upon including a substantially +# similar Disclaimer requirement for further binary redistribution. +# +# NO WARRANTY +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY +# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES. +# +# $FreeBSD$ +# + +.PATH: ${.CURDIR}/../../dev/ath +.PATH: ${.CURDIR}/../../dev/ath/ath_hal + +KMOD= if_ath_ahb +SRCS= if_ath_ahb.c +SRCS+= device_if.h bus_if.h + +CFLAGS+= -I. -I${.CURDIR}/../../dev/ath -I${.CURDIR}/../../dev/ath/ath_hal + +.include Added: head/sys/modules/ath_pci/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/modules/ath_pci/Makefile Thu Mar 31 08:07:13 2011 (r220185) @@ -0,0 +1,41 @@ +# +# Copyright (c) 2011 Adrian Chadd, Xenion Pty Ltd +# 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, +# without modification. +# 2. Redistributions in binary form must reproduce at minimum a disclaimer +# similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any +# redistribution must be conditioned upon including a substantially +# similar Disclaimer requirement for further binary redistribution. +# +# NO WARRANTY +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY +# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +# THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES. +# +# $FreeBSD$ +# + +.PATH: ${.CURDIR}/../../dev/ath +.PATH: ${.CURDIR}/../../dev/ath/ath_hal + +KMOD= if_ath_pci +SRCS= if_ath_pci.c +SRCS+= device_if.h bus_if.h pci_if.h + +CFLAGS+= -I. -I${.CURDIR}/../../dev/ath -I${.CURDIR}/../../dev/ath/ath_hal + +.include Modified: head/sys/pc98/conf/GENERIC ============================================================================== --- head/sys/pc98/conf/GENERIC Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/pc98/conf/GENERIC Thu Mar 31 08:07:13 2011 (r220185) @@ -221,7 +221,8 @@ device xe # Xircom pccard Ethernet #device wlan_tkip # 802.11 TKIP support #device wlan_amrr # AMRR transmit rate control algorithm #device an # Aironet 4500/4800 802.11 wireless NICs. -#device ath # Atheros pci/cardbus NIC's +#device ath # Atheros NIC's +#device ath_pci # Atheros pci/cardbus glue #device ath_hal # pci/cardbus chip support #options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors #device ath_rate_sample # SampleRate tx rate control for ath Modified: head/sys/sparc64/conf/GENERIC ============================================================================== --- head/sys/sparc64/conf/GENERIC Thu Mar 31 06:30:59 2011 (r220184) +++ head/sys/sparc64/conf/GENERIC Thu Mar 31 08:07:13 2011 (r220185) @@ -203,7 +203,8 @@ device wlan_wep # 802.11 WEP support device wlan_ccmp # 802.11 CCMP support device wlan_tkip # 802.11 TKIP support device wlan_amrr # AMRR transmit rate control algorithm -device ath # Atheros pci/cardbus NIC's +device ath # Atheros NIC's +device ath_pci # Atheros pci/cardbus glue device ath_hal # Atheros HAL (Hardware Access Layer) options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors device ath_rate_sample # SampleRate tx rate control for ath From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 08:14: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 3476C106564A; Thu, 31 Mar 2011 08:14:52 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0AE728FC0A; Thu, 31 Mar 2011 08:14:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V8EpHV096313; Thu, 31 Mar 2011 08:14:51 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V8Epds096309; Thu, 31 Mar 2011 08:14:51 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201103310814.p2V8Epds096309@svn.freebsd.org> From: Andriy Gapon Date: Thu, 31 Mar 2011 08:14: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: r220186 - in head/sys: amd64/linux32 compat/linux i386/linux 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, 31 Mar 2011 08:14:52 -0000 Author: avg Date: Thu Mar 31 08:14:51 2011 New Revision: 220186 URL: http://svn.freebsd.org/changeset/base/220186 Log: Revert r220032:linux compat: add SO_PASSCRED option with basic handling I have not properly thought through the commit. After r220031 (linux compat: improve and fix sendmsg/recvmsg compatibility) the basic handling for SO_PASSCRED is not sufficient as it breaks recvmsg functionality for SCM_CREDS messages because now we would need to handle sockcred data in addition to cmsgcred. And that is not implemented yet. Pointyhat to: avg Modified: head/sys/amd64/linux32/linux.h head/sys/compat/linux/linux_socket.c head/sys/i386/linux/linux.h Modified: head/sys/amd64/linux32/linux.h ============================================================================== --- head/sys/amd64/linux32/linux.h Thu Mar 31 08:07:13 2011 (r220185) +++ head/sys/amd64/linux32/linux.h Thu Mar 31 08:14:51 2011 (r220186) @@ -695,7 +695,6 @@ union l_semun { #define LINUX_SO_NO_CHECK 11 #define LINUX_SO_PRIORITY 12 #define LINUX_SO_LINGER 13 -#define LINUX_SO_PASSCRED 16 #define LINUX_SO_PEERCRED 17 #define LINUX_SO_RCVLOWAT 18 #define LINUX_SO_SNDLOWAT 19 Modified: head/sys/compat/linux/linux_socket.c ============================================================================== --- head/sys/compat/linux/linux_socket.c Thu Mar 31 08:07:13 2011 (r220185) +++ head/sys/compat/linux/linux_socket.c Thu Mar 31 08:14:51 2011 (r220186) @@ -300,8 +300,6 @@ linux_to_bsd_so_sockopt(int opt) return (SO_OOBINLINE); case LINUX_SO_LINGER: return (SO_LINGER); - case LINUX_SO_PASSCRED: - return (LOCAL_CREDS); case LINUX_SO_PEERCRED: return (LOCAL_PEERCRED); case LINUX_SO_RCVLOWAT: @@ -1469,12 +1467,6 @@ linux_setsockopt(struct thread *td, stru switch (bsd_args.level) { case SOL_SOCKET: name = linux_to_bsd_so_sockopt(args->optname); - switch (args->optname) { - case LINUX_SO_PASSCRED: - /* FreeBSD bug? socket level opts at non socket level */ - bsd_args.level = 0; - break; - } switch (name) { case SO_RCVTIMEO: /* FALLTHROUGH */ @@ -1552,12 +1544,6 @@ linux_getsockopt(struct thread *td, stru switch (bsd_args.level) { case SOL_SOCKET: name = linux_to_bsd_so_sockopt(args->optname); - switch (args->optname) { - case LINUX_SO_PASSCRED: - /* FreeBSD bug? socket level opts at non socket level */ - bsd_args.level = 0; - break; - } switch (name) { case SO_RCVTIMEO: /* FALLTHROUGH */ Modified: head/sys/i386/linux/linux.h ============================================================================== --- head/sys/i386/linux/linux.h Thu Mar 31 08:07:13 2011 (r220185) +++ head/sys/i386/linux/linux.h Thu Mar 31 08:14:51 2011 (r220186) @@ -671,7 +671,6 @@ union l_semun { #define LINUX_SO_NO_CHECK 11 #define LINUX_SO_PRIORITY 12 #define LINUX_SO_LINGER 13 -#define LINUX_SO_PASSCRED 16 #define LINUX_SO_PEERCRED 17 #define LINUX_SO_RCVLOWAT 18 #define LINUX_SO_SNDLOWAT 19 From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 08:32: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 35AE9106566C; Thu, 31 Mar 2011 08:32:54 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2762C8FC1C; Thu, 31 Mar 2011 08:32:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V8WsxW096771; Thu, 31 Mar 2011 08:32:54 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V8WsBD096769; Thu, 31 Mar 2011 08:32:54 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103310832.p2V8WsBD096769@svn.freebsd.org> From: Adrian Chadd Date: Thu, 31 Mar 2011 08:32: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: r220187 - 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: Thu, 31 Mar 2011 08:32:54 -0000 Author: adrian Date: Thu Mar 31 08:32:53 2011 New Revision: 220187 URL: http://svn.freebsd.org/changeset/base/220187 Log: Document the ath glue changes. Modified: head/UPDATING Modified: head/UPDATING ============================================================================== --- head/UPDATING Thu Mar 31 08:14:51 2011 (r220186) +++ head/UPDATING Thu Mar 31 08:32:53 2011 (r220187) @@ -22,6 +22,16 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9. machines to maximize performance. (To disable malloc debugging, run ln -s aj /etc/malloc.conf.) +20110331: + ath(4) has been split into bus- and device- modules. if_ath contains + the HAL, the TX rate control and the network device code. if_ath_pci + contains the PCI bus glue. For Atheros MIPS embedded systems, if_ath_ahb + contains the AHB glue. Users need to load both if_ath_pci and if_ath + in order to use ath on everything else. + + TO REPEAT: if_ath_ahb is not needed for normal users. Normal users only + need to load if_ath and if_ath_pci for ath(4) operation. + 20110218: GNU binutils 2.17.50 (as of 2007-07-03) has been merged to -HEAD. This is the last available version under GPLv2. It brings a number of new From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 08:48: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 625941065674; Thu, 31 Mar 2011 08:48:06 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 393DB8FC14; Thu, 31 Mar 2011 08:48:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V8m6p2097270; Thu, 31 Mar 2011 08:48:06 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V8m6g8097266; Thu, 31 Mar 2011 08:48:06 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103310848.p2V8m6g8097266@svn.freebsd.org> From: Adrian Chadd Date: Thu, 31 Mar 2011 08:48: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: r220188 - in head/sys: conf dev/ath/ath_hal/ar5416 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, 31 Mar 2011 08:48:06 -0000 Author: adrian Date: Thu Mar 31 08:48:05 2011 New Revision: 220188 URL: http://svn.freebsd.org/changeset/base/220188 Log: Introduce AH_AR5416_INTERRUPT_MITIGATION which enables interrupt mitigation for the AR5416 and later. Rename the older HAL option to use this. Modified: head/sys/conf/options head/sys/dev/ath/ath_hal/ar5416/ar5416_interrupts.c head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Thu Mar 31 08:32:53 2011 (r220187) +++ head/sys/conf/options Thu Mar 31 08:48:05 2011 (r220188) @@ -786,6 +786,9 @@ AH_USE_INIPDGAIN opt_ah.h AH_MAXCHAN opt_ah.h AH_RXCFG_SDMAMW_4BYTES opt_ah.h +# AR5416 and later interrupt mitigation +AH_AR5416_INTERRUPT_MITIGATION opt_ah.h + # options for the Broadcom BCM43xx driver (bwi) BWI_DEBUG opt_bwi.h BWI_DEBUG_VERBOSE opt_bwi.h Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_interrupts.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416_interrupts.c Thu Mar 31 08:32:53 2011 (r220187) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416_interrupts.c Thu Mar 31 08:48:05 2011 (r220188) @@ -128,7 +128,7 @@ ar5416GetPendingInterrupts(struct ath_ha } /* Interrupt Mitigation on AR5416 */ -#ifdef AR5416_INT_MITIGATION +#ifdef AH_AR5416_INTERRUPT_MITIGATION if (isr & (AR_ISR_RXMINTR | AR_ISR_RXINTM)) *masked |= HAL_INT_RX; if (isr & (AR_ISR_TXMINTR | AR_ISR_TXINTM)) @@ -194,7 +194,7 @@ ar5416SetInterrupts(struct ath_hal *ah, mask = ints & HAL_INT_COMMON; mask2 = 0; -#ifdef AR5416_INT_MITIGATION +#ifdef AH_AR5416_INTERRUPT_MITIGATION /* * Overwrite default mask if Interrupt mitigation * is specified for AR5416 Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c Thu Mar 31 08:32:53 2011 (r220187) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c Thu Mar 31 08:48:05 2011 (r220188) @@ -305,7 +305,7 @@ ar5416Reset(struct ath_hal *ah, HAL_OPMO */ OS_REG_WRITE(ah, AR_OBS, 8); -#ifdef AR5416_INT_MITIGATION +#ifdef AH_AR5416_INTERRUPT_MITIGATION OS_REG_WRITE(ah, AR_MIRT, 0); OS_REG_RMW_FIELD(ah, AR_RIMT, AR_RIMT_LAST, 500); @@ -538,7 +538,7 @@ ar5416InitIMR(struct ath_hal *ah, HAL_OP | AR_IMR_RXERR | AR_IMR_RXORN | AR_IMR_BCNMISC; -#ifdef AR5416_INT_MITIGATION +#ifdef AH_AR5416_INTERRUPT_MITIGATION ahp->ah_maskReg |= AR_IMR_TXINTM | AR_IMR_RXINTM | AR_IMR_TXMINTR | AR_IMR_RXMINTR; #else From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 09:34: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 7D61D106564A; Thu, 31 Mar 2011 09:34:56 +0000 (UTC) (envelope-from gavin@FreeBSD.org) Received: from ixe-mta-27.emailfiltering.com (ixe-mta-27-tx.emailfiltering.com [194.116.199.158]) by mx1.freebsd.org (Postfix) with ESMTP id 49FE28FC14; Thu, 31 Mar 2011 09:34:55 +0000 (UTC) Received: from mail-gw13.york.ac.uk ([144.32.129.163]) by ixe-mta-27.emailfiltering.com with emfmta (version 4.8.0.437) by TLS id 1016860602 for trasz@FreeBSD.org; 62062b75f56ea33b; Thu, 31 Mar 2011 10:34:54 +0100 Received: from buffy-128.york.ac.uk ([144.32.128.160]:10082 helo=buffy.york.ac.uk) by mail-gw13.york.ac.uk with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1Q5EHF-0002wJ-MT; Thu, 31 Mar 2011 10:34:53 +0100 Received: from buffy.york.ac.uk (localhost [127.0.0.1]) by buffy.york.ac.uk (8.14.4/8.14.4) with ESMTP id p2V9YrDm037579; Thu, 31 Mar 2011 10:34:53 +0100 (BST) (envelope-from gavin@FreeBSD.org) Received: (from ga9@localhost) by buffy.york.ac.uk (8.14.4/8.14.4/Submit) id p2V9YrHY037578; Thu, 31 Mar 2011 10:34:53 +0100 (BST) (envelope-from gavin@FreeBSD.org) X-Authentication-Warning: buffy.york.ac.uk: ga9 set sender to gavin@FreeBSD.org using -f From: Gavin Atkinson To: Edward Tomasz Napierala In-Reply-To: <201103301835.p2UIZ2O8071886@svn.freebsd.org> References: <201103301835.p2UIZ2O8071886@svn.freebsd.org> Content-Type: text/plain; charset="ASCII" Content-Transfer-Encoding: quoted-printable Date: Thu, 31 Mar 2011 10:34:52 +0100 Message-ID: <1301564092.37476.1.camel@buffy.york.ac.uk> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r220168 - head/etc 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, 31 Mar 2011 09:34:56 -0000 On Wed, 2011-03-30 at 18:35 +0000, Edward Tomasz Napierala wrote: > Author: trasz > Date: Wed Mar 30 18:35:02 2011 > New Revision: 220168 > URL: http://svn.freebsd.org/changeset/base/220168 >=20 > Log: > Add example devd.conf entry. >=20 > + > +# This example works around a memory leak in PostgreSQL, restarting > +# it when "user:pgsql:swap:devctl=3D1G" rctl(8) rule gets triggered. > +notify 0 { > + match "system" "RCTL"; > + match "rule" "user:70:swap:.*"; > + action "/usr/local/etc/rc.d/postgresql restart" > +}; > + > */ This seems like a dangerous rule to have enabled by default? Gavin --=20 Gavin Atkinson FreeBSD committer and bugmeister GPG: A093262B (313A A79F 697D 3A5C 216A EDF5 935D EF44 A093 262B) From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 10:05: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 CE3AC1065673; Thu, 31 Mar 2011 10:05:04 +0000 (UTC) (envelope-from etnapierala@googlemail.com) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id D8B298FC0A; Thu, 31 Mar 2011 10:05:03 +0000 (UTC) Received: by wwc33 with SMTP id 33so2487118wwc.31 for ; Thu, 31 Mar 2011 03:05:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:sender:subject:mime-version:content-type:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to:x-mailer; bh=H0eqCsWe1P+rS78rou68bYuBco3lQXepfGT0K+awJJQ=; b=eS6myfSp+uolsKw1JB9hJVy6fNZQOsDcV/Am3ZpRmUfkZB6Fw1hxt3velVS3XA3c0U hlhVHBOykVo5PnhyW3u+DGi+fELcX8ExMKRirukiqX+1yv3wC91FXZi9YoYbgy79JWIs 1z9c+jKgwr8c2jHfPXijO/aj0vlxofU83s11o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=sender:subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; b=IHt7REkwWSKmz81TsxeAMt+IL4Z0izVbFxXsQzoHc66Ix/AjMcQfeK9aDsYCkgCV1h 4qW7m6Ivy/SgGPFPTatqr/646TNsvxkTdgLgl79DgL8y+y7MRRFHuqng7VZxfRmJXy2c lb1ic+qieNA7Cy/e0P7xd/FWZpfYmz5iPO9yU= Received: by 10.227.195.143 with SMTP id ec15mr2527165wbb.213.1301564559547; Thu, 31 Mar 2011 02:42:39 -0700 (PDT) Received: from enapierala.whl (58.wheelsystems.com [83.12.187.58]) by mx.google.com with ESMTPS id l24sm538749wbc.47.2011.03.31.02.42.37 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 31 Mar 2011 02:42:38 -0700 (PDT) Sender: =?UTF-8?Q?Edward_Tomasz_Napiera=C5=82a?= Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=iso-8859-2 From: =?iso-8859-2?Q?Edward_Tomasz_Napiera=B3a?= In-Reply-To: <1301564092.37476.1.camel@buffy.york.ac.uk> Date: Thu, 31 Mar 2011 11:42:35 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: References: <201103301835.p2UIZ2O8071886@svn.freebsd.org> <1301564092.37476.1.camel@buffy.york.ac.uk> To: Gavin Atkinson X-Mailer: Apple Mail (2.1084) Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r220168 - head/etc 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, 31 Mar 2011 10:05:05 -0000 Wiadomo=B6=E6 napisana przez Gavin Atkinson w dniu 2011-03-31, o godz. = 11:34: > On Wed, 2011-03-30 at 18:35 +0000, Edward Tomasz Napierala wrote: >> Author: trasz >> Date: Wed Mar 30 18:35:02 2011 >> New Revision: 220168 >> URL: http://svn.freebsd.org/changeset/base/220168 >>=20 >> Log: >> Add example devd.conf entry. >>=20 >> + >> +# This example works around a memory leak in PostgreSQL, restarting >> +# it when "user:pgsql:swap:devctl=3D1G" rctl(8) rule gets triggered. >> +notify 0 { >> + match "system" "RCTL"; >> + match "rule" "user:70:swap:.*"; >> + action "/usr/local/etc/rc.d/postgresql restart" >> +}; >> + >> */ >=20 > This seems like a dangerous rule to have enabled by default? Yes. Note, however, the "*/" in the last line above - the whole block is commented out. -- If you cut off my head, what would I say? Me and my head, or me and my = body? From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 10:05: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 041A9106566B; Thu, 31 Mar 2011 10:05:27 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-iy0-f182.google.com (mail-iy0-f182.google.com [209.85.210.182]) by mx1.freebsd.org (Postfix) with ESMTP id 9409F8FC0C; Thu, 31 Mar 2011 10:05:26 +0000 (UTC) Received: by iyj12 with SMTP id 12so2824657iyj.13 for ; Thu, 31 Mar 2011 03:05:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:references:in-reply-to:mime-version :content-transfer-encoding:content-type:message-id:cc:x-mailer:from :subject:date:to; bh=3iuWKbAx3jkxNKRW3lI3tLAzBpfBlQlQFZtCXPu8//4=; b=oUSlWypVhWKyQmAPNN5MzT0ej4xDBE4phDLLHr7noMqELyoNZWyJG73GYzj48e2CjW T49TVBJZladsMTlym/Peq7aoxhpPP3IQVB8Xeza9OU6R3SAFJVVYafEo/zD3+Pcai31A utLEeDBNMguZm+4uz5UX68dwPVOlUXq4768jU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=references:in-reply-to:mime-version:content-transfer-encoding :content-type:message-id:cc:x-mailer:from:subject:date:to; b=XG3Ov9nQPQyGzgfr27EAQbasDkK/peEX/G7ltJdG067vy14PsRGhMg27XL0snN2nKt yrqhguUJtAZF9FBgUJWjSDxgB5fddfVUYWPznh59mKytXkb5BjD4GIvxeMWMd1DFS5jV b5Dmz7UkHDbLYsW7w/mg8Yjv0hbsAUF7J9wP8= Received: by 10.231.113.194 with SMTP id b2mr2376332ibq.103.1301565925918; Thu, 31 Mar 2011 03:05:25 -0700 (PDT) Received: from [192.168.20.50] (c-24-4-33-131.hsd1.ca.comcast.net [24.4.33.131]) by mx.google.com with ESMTPS id o3sm649039ibd.61.2011.03.31.03.05.22 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 31 Mar 2011 03:05:24 -0700 (PDT) References: <201103301835.p2UIZ2O8071886@svn.freebsd.org> <1301564092.37476.1.camel@buffy.york.ac.uk> In-Reply-To: <1301564092.37476.1.camel@buffy.york.ac.uk> Mime-Version: 1.0 (iPhone Mail 8C148) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Message-Id: <2C7FCC70-E923-4EE3-8C32-1DE0E1FADCEC@gmail.com> X-Mailer: iPhone Mail (8C148) From: Garrett Cooper Date: Thu, 31 Mar 2011 03:05:15 -0700 To: Gavin Atkinson Cc: "svn-src-head@FreeBSD.org" , "svn-src-all@FreeBSD.org" , "src-committers@FreeBSD.org" , Edward Tomasz Napierala Subject: Re: svn commit: r220168 - head/etc 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, 31 Mar 2011 10:05:27 -0000 On Mar 31, 2011, at 2:34 AM, Gavin Atkinson wrote: > On Wed, 2011-03-30 at 18:35 +0000, Edward Tomasz Napierala wrote: >> Author: trasz >> Date: Wed Mar 30 18:35:02 2011 >> New Revision: 220168 >> URL: http://svn.freebsd.org/changeset/base/220168 >>=20 >> Log: >> Add example devd.conf entry. >>=20 >> + >> +# This example works around a memory leak in PostgreSQL, restarting >> +# it when "user:pgsql:swap:devctl=3D1G" rctl(8) rule gets triggered. >> +notify 0 { >> + match "system" "RCTL"; >> + match "rule" "user:70:swap:.*"; >> + action "/usr/local/etc/rc.d/postgresql restart" >> +}; >> + >> */ >=20 > This seems like a dangerous rule to have enabled by default? It's commented out (devd.conf supports multiline C-style comments and this w= as added at the end of the file). Hth, -Garrett= From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 10:27: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 4EC151065673; Thu, 31 Mar 2011 10:27:06 +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 BEF798FC1E; Thu, 31 Mar 2011 10:27:05 +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 p2VAR1Vb084911 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 31 Mar 2011 13:27:01 +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 p2VAR1Mk047110; Thu, 31 Mar 2011 13:27:01 +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 p2VAR19A047109; Thu, 31 Mar 2011 13:27:01 +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: Thu, 31 Mar 2011 13:27:01 +0300 From: Kostik Belousov To: Pan Tsu Message-ID: <20110331102700.GH78089@deviant.kiev.zoral.com.ua> References: <201103301446.p2UEkDDk066511@svn.freebsd.org> <8662qzu5s7.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="n/ThMq0iISHMWp2N" Content-Disposition: inline In-Reply-To: <8662qzu5s7.fsf@gmail.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.4 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: r220158 - in head/sys: compat/freebsd32 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, 31 Mar 2011 10:27:06 -0000 --n/ThMq0iISHMWp2N Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Mar 31, 2011 at 11:07:36AM +0400, Pan Tsu wrote: > Konstantin Belousov writes: >=20 > > Author: kib > > Date: Wed Mar 30 14:46:12 2011 > > New Revision: 220158 > > URL: http://svn.freebsd.org/changeset/base/220158 > > > > Log: > > Provide compat32 shims for kldstat(2). > > =20 > > Requested and tested by: jpaetzel > > MFC after: 1 week >=20 > It breaks loading modules from loader(8) for me. The box panics early >=20 > #13 0xffffffff804f2f2a in sysctl_find_oidname (name=3D0xffffffff80eec15= 6 "kstat", list=3D0x657a69735f796c) > at /usr/src/sys/kern/kern_sysctl.c:106 > #14 0xffffffff804f3e69 in sysctl_register_oid (oidp=3D0xffffffff80ef0a8= 0) > at /usr/src/sys/kern/kern_sysctl.c:149 > #15 0xffffffff804cb83c in linker_file_register_sysctls (lf=3DVariable "= lf" is not available. > ) at /usr/src/sys/kern/kern_linker.c:301 > #16 0xffffffff804cd112 in linker_preload (arg=3DVariable "arg" is not a= vailable. > ) at /usr/src/sys/kern/kern_linker.c:1624 > #17 0xffffffff80499ad7 in mi_startup () at /usr/src/sys/kern/init_main.= c:258 > #18 0xffffffff80299a3c in btext () at /usr/src/sys/amd64/amd64/locore.S= :81 > [...] What supports your claim that the referenced commit breaks early module loading ? You even did not provided the panic message, btw. Commit only changed the wrapper around kldstat(2) syscall, that cannot be used during bootstrap, and the changed code does not reference kldstat(9= ). The later cannot prove that the change did not break something, but due to its nature, it is unlikely. --n/ThMq0iISHMWp2N Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk2UVvQACgkQC3+MBN1Mb4gqdgCfYY9BaWEtFbDTYm8/MUIPa8G9 aIQAn37G3mqOOmD8Mp2xQTUOQ997iuI1 =3m6w -----END PGP SIGNATURE----- --n/ThMq0iISHMWp2N-- From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 11:09: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 C4C60106564A; Thu, 31 Mar 2011 11:09:45 +0000 (UTC) (envelope-from gavin@FreeBSD.org) Received: from gse-mta-27.emailfiltering.com (gse-mta-27-tx.emailfiltering.com [194.116.198.158]) by mx1.freebsd.org (Postfix) with ESMTP id 9A49C8FC14; Thu, 31 Mar 2011 11:09:44 +0000 (UTC) Received: from mail-gw13.york.ac.uk ([144.32.129.163]) by gse-mta-27.emailfiltering.com with emfmta (version 4.8.0.437) by TLS id 956194972 for trasz@FreeBSD.org; f07e01c26ff13416; Thu, 31 Mar 2011 12:09:43 +0100 Received: from buffy-128.york.ac.uk ([144.32.128.160]:18090 helo=buffy.york.ac.uk) by mail-gw13.york.ac.uk with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1Q5FbO-0002Om-5f; Thu, 31 Mar 2011 11:59:46 +0100 Received: from buffy.york.ac.uk (localhost [127.0.0.1]) by buffy.york.ac.uk (8.14.4/8.14.4) with ESMTP id p2VAxjv4037847; Thu, 31 Mar 2011 11:59:45 +0100 (BST) (envelope-from gavin@FreeBSD.org) Received: (from ga9@localhost) by buffy.york.ac.uk (8.14.4/8.14.4/Submit) id p2VAxjVu037846; Thu, 31 Mar 2011 11:59:45 +0100 (BST) (envelope-from gavin@FreeBSD.org) X-Authentication-Warning: buffy.york.ac.uk: ga9 set sender to gavin@FreeBSD.org using -f From: Gavin Atkinson To: Edward Tomasz =?iso-8859-2?Q?Napiera=B3a?= In-Reply-To: References: <201103301835.p2UIZ2O8071886@svn.freebsd.org> <1301564092.37476.1.camel@buffy.york.ac.uk> Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable Date: Thu, 31 Mar 2011 11:59:45 +0100 Message-ID: <1301569185.37476.2.camel@buffy.york.ac.uk> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r220168 - head/etc 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, 31 Mar 2011 11:09:45 -0000 On Thu, 2011-03-31 at 11:42 +0200, Edward Tomasz Napiera=B3a wrote: > Wiadomo=B6=E6 napisana przez Gavin Atkinson w dniu 2011-03-31, o godz. 11= :34: > > On Wed, 2011-03-30 at 18:35 +0000, Edward Tomasz Napierala wrote: > >> Author: trasz > >> Date: Wed Mar 30 18:35:02 2011 > >> New Revision: 220168 > >> URL: http://svn.freebsd.org/changeset/base/220168 > >>=20 > >> Log: > >> Add example devd.conf entry. > >>=20 > >> + > >> +# This example works around a memory leak in PostgreSQL, restarting > >> +# it when "user:pgsql:swap:devctl=3D1G" rctl(8) rule gets triggered. > >> +notify 0 { > >> + match "system" "RCTL"; > >> + match "rule" "user:70:swap:.*"; > >> + action "/usr/local/etc/rc.d/postgresql restart" > >> +}; > >> + > >> */ > >=20 > > This seems like a dangerous rule to have enabled by default? >=20 > Yes. Note, however, the "*/" in the last line above - the whole block > is commented out. Gah, sorry for the noise. Gavin From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 11:40: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 E1BC2106566B; Thu, 31 Mar 2011 11:40:21 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id B4BED8FC0C; Thu, 31 Mar 2011 11:40:21 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 2471046B51; Thu, 31 Mar 2011 07:40:21 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id B74508A01B; Thu, 31 Mar 2011 07:40:20 -0400 (EDT) From: John Baldwin To: Adrian Chadd Date: Thu, 31 Mar 2011 07:40:20 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <201103310807.p2V87DHV096049@svn.freebsd.org> In-Reply-To: <201103310807.p2V87DHV096049@svn.freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201103310740.20265.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Thu, 31 Mar 2011 07:40:20 -0400 (EDT) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r220185 - in head/sys: amd64/conf arm/conf conf dev/ath i386/conf mips/conf modules modules/ath modules/ath_ahb modules/ath_pci pc98/conf sparc64/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: Thu, 31 Mar 2011 11:40:22 -0000 On Thursday, March 31, 2011 4:07:13 am Adrian Chadd wrote: > Author: adrian > Date: Thu Mar 31 08:07:13 2011 > New Revision: 220185 > URL: http://svn.freebsd.org/changeset/base/220185 > > Log: > Break out the ath PCI logic into a separate device/module. > > Introduce the AHB glue for Atheros embedded systems. Right now it's > hard-coded for the AR9130 chip whose support isn't yet in this HAL; > it'll be added in a subsequent commit. > > Kernel configuration files now need both 'ath' and 'ath_pci' devices; both > modules need to be loaded for the ath device to work. Err, there's no need to break the kernel config. Just have the kernel DTRT if both ath and pci are enabled using something like: sys/dev/ath/if_ath_pci.c ath pci in sys/conf/files. You can still have an if_ath_pci.ko module with this arrangement. This is what almost all other drivers due that have multiple bus backends. -- John Baldwin From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 12:03: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 C09E2106566C; Thu, 31 Mar 2011 12:03:30 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A15108FC14; Thu, 31 Mar 2011 12:03:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VC3UDC005526; Thu, 31 Mar 2011 12:03:30 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VC3U40005524; Thu, 31 Mar 2011 12:03:30 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201103311203.p2VC3U40005524@svn.freebsd.org> From: Adrian Chadd Date: Thu, 31 Mar 2011 12:03:30 +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: r220190 - head/sys/modules 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, 31 Mar 2011 12:03:30 -0000 Author: adrian Date: Thu Mar 31 12:03:30 2011 New Revision: 220190 URL: http://svn.freebsd.org/changeset/base/220190 Log: ath_ahb shouldn't be compiled normally; it is atheros chip specific. Remove it from here; users can compile it manually if needed. Modified: head/sys/modules/Makefile Modified: head/sys/modules/Makefile ============================================================================== --- head/sys/modules/Makefile Thu Mar 31 08:55:00 2011 (r220189) +++ head/sys/modules/Makefile Thu Mar 31 12:03:30 2011 (r220190) @@ -35,7 +35,6 @@ SUBDIR= ${_3dfx} \ ${_asr} \ ata \ ath \ - ath_ahb \ ath_pci \ ${_auxio} \ bce \ From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 13:14: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 D2932106564A; Thu, 31 Mar 2011 13:14:24 +0000 (UTC) (envelope-from fabient@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C27A98FC13; Thu, 31 Mar 2011 13:14:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VDEOig007307; Thu, 31 Mar 2011 13:14:24 GMT (envelope-from fabient@svn.freebsd.org) Received: (from fabient@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VDEOro007304; Thu, 31 Mar 2011 13:14:24 GMT (envelope-from fabient@svn.freebsd.org) Message-Id: <201103311314.p2VDEOro007304@svn.freebsd.org> From: Fabien Thomas Date: Thu, 31 Mar 2011 13:14:24 +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: r220194 - head/sys/netipsec 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, 31 Mar 2011 13:14:24 -0000 Author: fabient Date: Thu Mar 31 13:14:24 2011 New Revision: 220194 URL: http://svn.freebsd.org/changeset/base/220194 Log: Fix two SA refcount: - AH does not release the SA like in ESP/IPCOMP when handling EAGAIN - ipsec_process_done incorrectly release the SA. Reviewed by: vanhu MFC after: 1 week Modified: head/sys/netipsec/ipsec_output.c head/sys/netipsec/xform_ah.c Modified: head/sys/netipsec/ipsec_output.c ============================================================================== --- head/sys/netipsec/ipsec_output.c Thu Mar 31 13:06:51 2011 (r220193) +++ head/sys/netipsec/ipsec_output.c Thu Mar 31 13:14:24 2011 (r220194) @@ -247,7 +247,6 @@ ipsec_process_done(struct mbuf *m, struc panic("ipsec_process_done"); bad: m_freem(m); - KEY_FREESAV(&sav); return (error); } Modified: head/sys/netipsec/xform_ah.c ============================================================================== --- head/sys/netipsec/xform_ah.c Thu Mar 31 13:06:51 2011 (r220193) +++ head/sys/netipsec/xform_ah.c Thu Mar 31 13:14:24 2011 (r220194) @@ -785,6 +785,7 @@ ah_input_cb(struct cryptop *crp) sav->tdb_cryptoid = crp->crp_sid; if (crp->crp_etype == EAGAIN) { + KEY_FREESAV(&sav); error = crypto_dispatch(crp); return error; } From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 13:22: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 0ABC81065674; Thu, 31 Mar 2011 13:22:13 +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 ED9F08FC16; Thu, 31 Mar 2011 13:22:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VDMCKE007519; Thu, 31 Mar 2011 13:22:12 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VDMCG4007514; Thu, 31 Mar 2011 13:22:12 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201103311322.p2VDMCG4007514@svn.freebsd.org> From: John Baldwin Date: Thu, 31 Mar 2011 13:22: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: r220195 - 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: Thu, 31 Mar 2011 13:22:13 -0000 Author: jhb Date: Thu Mar 31 13:22:12 2011 New Revision: 220195 URL: http://svn.freebsd.org/changeset/base/220195 Log: Explicitly track the state of all known BARs for each PCI device. The PCI bus driver will now remember the size of a BAR obtained during the initial bus scan and use that size when doing lazy resource allocation rather than resizing the BAR. The bus driver will now also report unallocated BARs to userland for display by 'pciconf -lb'. Psuedo-resources that are not BARs (such as the implicit I/O port resources for master/slave ATA controllers) will no longer be listed as BARs in 'pciconf -lb'. During resume, BARs are restored from their new saved state instead of having the raw registers saved and restored across resume. This also fixes restoring BARs at unusual loactions if said BAR has been allocated by a driver. Add a constant for the offset of the ROM BIOS BAR in PCI-PCI bridges and properly handle ROM BIOS BARs in PCI-PCI bridges. The PCI bus now also properly handles the lack of a ROM BIOS BAR in a PCI-Cardbus bridge. Tested by: jkim Modified: head/sys/dev/pci/pci.c head/sys/dev/pci/pci_user.c head/sys/dev/pci/pcireg.h head/sys/dev/pci/pcivar.h Modified: head/sys/dev/pci/pci.c ============================================================================== --- head/sys/dev/pci/pci.c Thu Mar 31 13:14:24 2011 (r220194) +++ head/sys/dev/pci/pci.c Thu Mar 31 13:22:12 2011 (r220195) @@ -69,6 +69,11 @@ __FBSDID("$FreeBSD$"); #include "pcib_if.h" #include "pci_if.h" +#define PCIR_IS_BIOS(cfg, reg) \ + (((cfg)->hdrtype == PCIM_HDRTYPE_NORMAL && reg == PCIR_BIOS) || \ + ((cfg)->hdrtype == PCIM_HDRTYPE_BRIDGE && reg == PCIR_BIOS_1)) + + static pci_addr_t pci_mapbase(uint64_t mapreg); static const char *pci_maptype(uint64_t mapreg); static int pci_mapsize(uint64_t testval); @@ -531,6 +536,7 @@ pci_read_device(device_t pcib, int d, in cfg->mfdev = (cfg->hdrtype & PCIM_MFDEV) != 0; cfg->hdrtype &= ~PCIM_MFDEV; + STAILQ_INIT(&cfg->maps); pci_fixancient(cfg); pci_hdrtypedata(pcib, b, s, f, cfg); @@ -2106,6 +2112,7 @@ int pci_freecfg(struct pci_devinfo *dinfo) { struct devlist *devlist_head; + struct pci_map *pm, *next; int i; devlist_head = &pci_devq; @@ -2119,6 +2126,9 @@ pci_freecfg(struct pci_devinfo *dinfo) free(dinfo->cfg.vpd.vpd_w[i].value, M_DEVBUF); free(dinfo->cfg.vpd.vpd_w, M_DEVBUF); } + STAILQ_FOREACH_SAFE(pm, &dinfo->cfg.maps, pm_link, next) { + free(pm, M_DEVBUF); + } STAILQ_REMOVE(devlist_head, dinfo, pci_devinfo, pci_links); free(dinfo, M_DEVBUF); @@ -2393,6 +2403,7 @@ pci_memen(device_t dev) static void pci_read_bar(device_t dev, int reg, pci_addr_t *mapp, pci_addr_t *testvalp) { + struct pci_devinfo *dinfo; pci_addr_t map, testval; int ln2range; uint16_t cmd; @@ -2402,7 +2413,8 @@ pci_read_bar(device_t dev, int reg, pci_ * memory BAR. Bit 0 is special and should not be set when * sizing the BAR. */ - if (reg == PCIR_BIOS) { + dinfo = device_get_ivars(dev); + if (PCIR_IS_BIOS(&dinfo->cfg, reg)) { map = pci_read_config(dev, reg, 4); pci_write_config(dev, reg, 0xfffffffe, 4); testval = pci_read_config(dev, reg, 4); @@ -2453,20 +2465,99 @@ pci_read_bar(device_t dev, int reg, pci_ } static void -pci_write_bar(device_t dev, int reg, pci_addr_t base) +pci_write_bar(device_t dev, struct pci_map *pm, pci_addr_t base) { - pci_addr_t map; + struct pci_devinfo *dinfo; int ln2range; - map = pci_read_config(dev, reg, 4); - - /* The device ROM BAR is always 32-bits. */ - if (reg == PCIR_BIOS) - return; - ln2range = pci_maprange(map); - pci_write_config(dev, reg, base, 4); + /* The device ROM BAR is always a 32-bit memory BAR. */ + dinfo = device_get_ivars(dev); + if (PCIR_IS_BIOS(&dinfo->cfg, pm->pm_reg)) + ln2range = 32; + else + ln2range = pci_maprange(pm->pm_value); + pci_write_config(dev, pm->pm_reg, base, 4); + if (ln2range == 64) + pci_write_config(dev, pm->pm_reg + 4, base >> 32, 4); + pm->pm_value = pci_read_config(dev, pm->pm_reg, 4); if (ln2range == 64) - pci_write_config(dev, reg + 4, base >> 32, 4); + pm->pm_value |= (pci_addr_t)pci_read_config(dev, pm->pm_reg + 4, 4) << 32; +} + +struct pci_map * +pci_find_bar(device_t dev, int reg) +{ + struct pci_devinfo *dinfo; + struct pci_map *pm; + + dinfo = device_get_ivars(dev); + STAILQ_FOREACH(pm, &dinfo->cfg.maps, pm_link) { + if (pm->pm_reg == reg) + return (pm); + } + return (NULL); +} + +int +pci_bar_enabled(device_t dev, struct pci_map *pm) +{ + struct pci_devinfo *dinfo; + uint16_t cmd; + + dinfo = device_get_ivars(dev); + if (PCIR_IS_BIOS(&dinfo->cfg, pm->pm_reg) && + !(pm->pm_value & PCIM_BIOS_ENABLE)) + return (0); + cmd = pci_read_config(dev, PCIR_COMMAND, 2); + if (PCIR_IS_BIOS(&dinfo->cfg, pm->pm_reg) || PCI_BAR_MEM(pm->pm_value)) + return ((cmd & PCIM_CMD_MEMEN) != 0); + else + return ((cmd & PCIM_CMD_PORTEN) != 0); +} + +static struct pci_map * +pci_add_bar(device_t dev, int reg, pci_addr_t value, pci_addr_t size) +{ + struct pci_devinfo *dinfo; + struct pci_map *pm, *prev; + + dinfo = device_get_ivars(dev); + pm = malloc(sizeof(*pm), M_DEVBUF, M_WAITOK | M_ZERO); + pm->pm_reg = reg; + pm->pm_value = value; + pm->pm_size = size; + STAILQ_FOREACH(prev, &dinfo->cfg.maps, pm_link) { + KASSERT(prev->pm_reg != pm->pm_reg, ("duplicate map %02x", + reg)); + if (STAILQ_NEXT(prev, pm_link) == NULL || + STAILQ_NEXT(prev, pm_link)->pm_reg > pm->pm_reg) + break; + } + if (prev != NULL) + STAILQ_INSERT_AFTER(&dinfo->cfg.maps, prev, pm, pm_link); + else + STAILQ_INSERT_TAIL(&dinfo->cfg.maps, pm, pm_link); + return (pm); +} + +static void +pci_restore_bars(device_t dev) +{ + struct pci_devinfo *dinfo; + struct pci_map *pm; + int ln2range; + + dinfo = device_get_ivars(dev); + STAILQ_FOREACH(pm, &dinfo->cfg.maps, pm_link) { + if (PCIR_IS_BIOS(&dinfo->cfg, pm->pm_reg)) + ln2range = 32; + else + ln2range = pci_maprange(pm->pm_value); + pci_write_config(dev, pm->pm_reg, pm->pm_value, 4); + if (ln2range == 64) + pci_write_config(dev, pm->pm_reg + 4, + pm->pm_value >> 32, 4); + } } /* @@ -2477,6 +2568,7 @@ static int pci_add_map(device_t bus, device_t dev, int reg, struct resource_list *rl, int force, int prefetch) { + struct pci_map *pm; pci_addr_t base, map, testval; pci_addr_t start, end, count; int barlen, basezero, maprange, mapsize, type; @@ -2513,6 +2605,8 @@ pci_add_map(device_t bus, device_t dev, (type == SYS_RES_IOPORT && mapsize < 2)) return (barlen); + /* Save a record of this BAR. */ + pm = pci_add_bar(dev, reg, map, mapsize); if (bootverbose) { printf("\tmap[%02x]: type %s, range %2d, base %#jx, size %2d", reg, pci_maptype(map), maprange, (uintmax_t)base, mapsize); @@ -2600,7 +2694,7 @@ pci_add_map(device_t bus, device_t dev, start = 0; } else start = rman_get_start(res); - pci_write_bar(dev, reg, start); + pci_write_bar(dev, pm, start); return (barlen); } @@ -3735,31 +3829,41 @@ pci_reserve_map(device_t dev, device_t c struct resource_list *rl = &dinfo->resources; struct resource_list_entry *rle; struct resource *res; + struct pci_map *pm; pci_addr_t map, testval; int mapsize; - /* - * Weed out the bogons, and figure out how large the BAR/map - * is. Bars that read back 0 here are bogus and unimplemented. - * Note: atapci in legacy mode are special and handled elsewhere - * in the code. If you have a atapci device in legacy mode and - * it fails here, that other code is broken. - */ res = NULL; - pci_read_bar(child, *rid, &map, &testval); + pm = pci_find_bar(child, *rid); + if (pm != NULL) { + /* This is a BAR that we failed to allocate earlier. */ + mapsize = pm->pm_size; + map = pm->pm_value; + } else { + /* + * Weed out the bogons, and figure out how large the + * BAR/map is. BARs that read back 0 here are bogus + * and unimplemented. Note: atapci in legacy mode are + * special and handled elsewhere in the code. If you + * have a atapci device in legacy mode and it fails + * here, that other code is broken. + */ + pci_read_bar(child, *rid, &map, &testval); - /* - * Determine the size of the BAR and ignore BARs with a size - * of 0. Device ROM BARs use a different mask value. - */ - if (*rid == PCIR_BIOS) - mapsize = pci_romsize(testval); - else - mapsize = pci_mapsize(testval); - if (mapsize == 0) - goto out; + /* + * Determine the size of the BAR and ignore BARs with a size + * of 0. Device ROM BARs use a different mask value. + */ + if (PCIR_IS_BIOS(&dinfo->cfg, *rid)) + mapsize = pci_romsize(testval); + else + mapsize = pci_mapsize(testval); + if (mapsize == 0) + goto out; + pm = pci_add_bar(child, *rid, map, mapsize); + } - if (PCI_BAR_MEM(testval) || *rid == PCIR_BIOS) { + if (PCI_BAR_MEM(map) || PCIR_IS_BIOS(&dinfo->cfg, *rid)) { if (type != SYS_RES_MEMORY) { if (bootverbose) device_printf(dev, @@ -3789,12 +3893,12 @@ pci_reserve_map(device_t dev, device_t c count = (pci_addr_t)1 << mapsize; if (RF_ALIGNMENT(flags) < mapsize) flags = (flags & ~RF_ALIGNMENT_MASK) | RF_ALIGNMENT_LOG2(mapsize); - if (PCI_BAR_MEM(testval) && (testval & PCIM_BAR_MEM_PREFETCH)) + if (PCI_BAR_MEM(map) && (map & PCIM_BAR_MEM_PREFETCH)) flags |= RF_PREFETCHABLE; /* * Allocate enough resource, and then write back the - * appropriate bar for that resource. + * appropriate BAR for that resource. */ res = BUS_ALLOC_RESOURCE(device_get_parent(dev), child, type, rid, start, end, count, flags & ~RF_ACTIVE); @@ -3818,7 +3922,7 @@ pci_reserve_map(device_t dev, device_t c "Lazy allocation of %#lx bytes rid %#x type %d at %#lx\n", count, *rid, type, rman_get_start(res)); map = rman_get_start(res); - pci_write_bar(child, *rid, map); + pci_write_bar(child, pm, map); out:; return (res); } @@ -3879,6 +3983,7 @@ int pci_activate_resource(device_t dev, device_t child, int type, int rid, struct resource *r) { + struct pci_devinfo *dinfo; int error; error = bus_generic_activate_resource(dev, child, type, rid, r); @@ -3888,9 +3993,10 @@ pci_activate_resource(device_t dev, devi /* Enable decoding in the command register when activating BARs. */ if (device_get_parent(child) == dev) { /* Device ROMs need their decoding explicitly enabled. */ - if (rid == PCIR_BIOS) - pci_write_config(child, rid, rman_get_start(r) | - PCIM_BIOS_ENABLE, 4); + dinfo = device_get_ivars(child); + if (PCIR_IS_BIOS(&dinfo->cfg, rid)) + pci_write_bar(child, pci_find_bar(child, rid), + rman_get_start(r) | PCIM_BIOS_ENABLE); switch (type) { case SYS_RES_IOPORT: case SYS_RES_MEMORY: @@ -3905,15 +4011,20 @@ int pci_deactivate_resource(device_t dev, device_t child, int type, int rid, struct resource *r) { + struct pci_devinfo *dinfo; int error; error = bus_generic_deactivate_resource(dev, child, type, rid, r); if (error) return (error); - /* Disable decoding for device ROMs. */ - if (rid == PCIR_BIOS) - pci_write_config(child, rid, rman_get_start(r), 4); + /* Disable decoding for device ROMs. */ + if (device_get_parent(child) == dev) { + dinfo = device_get_ivars(child); + if (PCIR_IS_BIOS(&dinfo->cfg, rid)) + pci_write_bar(child, pci_find_bar(child, rid), + rman_get_start(r)); + } return (0); } @@ -3991,7 +4102,7 @@ pci_delete_resource(device_t dev, device switch (type) { case SYS_RES_IOPORT: case SYS_RES_MEMORY: - pci_write_bar(child, rid, 0); + pci_write_bar(child, pci_find_bar(child, rid), 0); break; } #endif @@ -4090,7 +4201,6 @@ pci_modevent(module_t mod, int what, voi void pci_cfg_restore(device_t dev, struct pci_devinfo *dinfo) { - int i; /* * Only do header type 0 devices. Type 1 devices are bridges, @@ -4112,9 +4222,7 @@ pci_cfg_restore(device_t dev, struct pci */ if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) pci_set_powerstate(dev, PCI_POWERSTATE_D0); - for (i = 0; i < dinfo->cfg.nummaps; i++) - pci_write_config(dev, PCIR_BAR(i), dinfo->cfg.bar[i], 4); - pci_write_config(dev, PCIR_BIOS, dinfo->cfg.bios, 4); + pci_restore_bars(dev); pci_write_config(dev, PCIR_COMMAND, dinfo->cfg.cmdreg, 2); pci_write_config(dev, PCIR_INTLINE, dinfo->cfg.intline, 1); pci_write_config(dev, PCIR_INTPIN, dinfo->cfg.intpin, 1); @@ -4135,7 +4243,6 @@ pci_cfg_restore(device_t dev, struct pci void pci_cfg_save(device_t dev, struct pci_devinfo *dinfo, int setstate) { - int i; uint32_t cls; int ps; @@ -4148,9 +4255,6 @@ pci_cfg_save(device_t dev, struct pci_de */ if ((dinfo->cfg.hdrtype & PCIM_HDRTYPE) != PCIM_HDRTYPE_NORMAL) return; - for (i = 0; i < dinfo->cfg.nummaps; i++) - dinfo->cfg.bar[i] = pci_read_config(dev, PCIR_BAR(i), 4); - dinfo->cfg.bios = pci_read_config(dev, PCIR_BIOS, 4); /* * Some drivers apparently write to these registers w/o updating our Modified: head/sys/dev/pci/pci_user.c ============================================================================== --- head/sys/dev/pci/pci_user.c Thu Mar 31 13:14:24 2011 (r220194) +++ head/sys/dev/pci/pci_user.c Thu Mar 31 13:22:12 2011 (r220195) @@ -309,8 +309,7 @@ pci_ioctl(struct cdev *dev, u_long cmd, struct pci_io *io; struct pci_bar_io *bio; struct pci_match_conf *pattern_buf; - struct resource_list_entry *rle; - uint32_t value; + struct pci_map *pm; size_t confsz, iolen, pbufsz; int error, ionum, i, num_patterns; #ifdef PRE7_COMPAT @@ -685,54 +684,14 @@ getconfexit: error = ENODEV; break; } - dinfo = device_get_ivars(pcidev); - - /* - * Look for a resource list entry matching the requested BAR. - * - * XXX: This will not find BARs that are not initialized, but - * maybe that is ok? - */ - rle = resource_list_find(&dinfo->resources, SYS_RES_MEMORY, - bio->pbi_reg); - if (rle == NULL) - rle = resource_list_find(&dinfo->resources, - SYS_RES_IOPORT, bio->pbi_reg); - if (rle == NULL || rle->res == NULL) { + pm = pci_find_bar(pcidev, bio->pbi_reg); + if (pm == NULL) { error = EINVAL; break; } - - /* - * Ok, we have a resource for this BAR. Read the lower - * 32 bits to get any flags. - */ - value = pci_read_config(pcidev, bio->pbi_reg, 4); - if (PCI_BAR_MEM(value)) { - if (rle->type != SYS_RES_MEMORY) { - error = EINVAL; - break; - } - value &= ~PCIM_BAR_MEM_BASE; - } else { - if (rle->type != SYS_RES_IOPORT) { - error = EINVAL; - break; - } - value &= ~PCIM_BAR_IO_BASE; - } - bio->pbi_base = rman_get_start(rle->res) | value; - bio->pbi_length = rman_get_size(rle->res); - - /* - * Check the command register to determine if this BAR - * is enabled. - */ - value = pci_read_config(pcidev, PCIR_COMMAND, 2); - if (rle->type == SYS_RES_MEMORY) - bio->pbi_enabled = (value & PCIM_CMD_MEMEN) != 0; - else - bio->pbi_enabled = (value & PCIM_CMD_PORTEN) != 0; + bio->pbi_base = pm->pm_value; + bio->pbi_length = (pci_addr_t)1 << pm->pm_size; + bio->pbi_enabled = pci_bar_enabled(pcidev, pm); error = 0; break; case PCIOCATTACHED: Modified: head/sys/dev/pci/pcireg.h ============================================================================== --- head/sys/dev/pci/pcireg.h Thu Mar 31 13:14:24 2011 (r220194) +++ head/sys/dev/pci/pcireg.h Thu Mar 31 13:22:12 2011 (r220195) @@ -212,6 +212,7 @@ #define PCIM_BRPM_64 0x1 #define PCIM_BRPM_MASK 0xf +#define PCIR_BIOS_1 0x38 #define PCIR_BRIDGECTL_1 0x3e /* config registers for header type 2 (CardBus) devices */ Modified: head/sys/dev/pci/pcivar.h ============================================================================== --- head/sys/dev/pci/pcivar.h Thu Mar 31 13:14:24 2011 (r220194) +++ head/sys/dev/pci/pcivar.h Thu Mar 31 13:22:12 2011 (r220195) @@ -46,7 +46,14 @@ struct pcicfg_pp { uint8_t pp_bse; /* conf. space addr. of PM BSE reg */ uint8_t pp_data; /* conf. space addr. of PM data reg */ }; - + +struct pci_map { + pci_addr_t pm_value; /* Raw BAR value */ + pci_addr_t pm_size; + uint8_t pm_reg; + STAILQ_ENTRY(pci_map) pm_link; +}; + struct vpd_readonly { char keyword[2]; char *value; @@ -120,8 +127,7 @@ struct pcicfg_ht { typedef struct pcicfg { struct device *dev; /* device which owns this */ - uint32_t bar[PCI_MAXMAPS_0]; /* BARs */ - uint32_t bios; /* BIOS mapping */ + STAILQ_HEAD(, pci_map) maps; /* BARs */ uint16_t subvendor; /* card vendor ID */ uint16_t subdevice; /* card device ID, assigned by card vendor */ @@ -477,4 +483,7 @@ STAILQ_HEAD(devlist, pci_devinfo); extern struct devlist pci_devq; extern uint32_t pci_generation; +struct pci_map *pci_find_bar(device_t dev, int reg); +int pci_bar_enabled(device_t dev, struct pci_map *pm); + #endif /* _PCIVAR_H_ */ From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 13:59: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 4A5D2106566B; Thu, 31 Mar 2011 13:59:48 +0000 (UTC) (envelope-from fabient@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3AC1D8FC16; Thu, 31 Mar 2011 13:59:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VDxm7P008486; Thu, 31 Mar 2011 13:59:48 GMT (envelope-from fabient@svn.freebsd.org) Received: (from fabient@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VDxmOI008483; Thu, 31 Mar 2011 13:59:48 GMT (envelope-from fabient@svn.freebsd.org) Message-Id: <201103311359.p2VDxmOI008483@svn.freebsd.org> From: Fabien Thomas Date: Thu, 31 Mar 2011 13:59: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: r220198 - 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: Thu, 31 Mar 2011 13:59:48 -0000 Author: fabient Date: Thu Mar 31 13:59:47 2011 New Revision: 220198 URL: http://svn.freebsd.org/changeset/base/220198 Log: Clearing the flag when preempting will let the preempted thread run too much time. This can finish in a scheduler deadlock with ping-pong between two threads. One sample of this is: - device lapic (to have a preemption point on critical_exit()) - options DEVICE_POLLING with HZ>1499 (to have lapic freq = hardclock freq) - running a cpu intensive task (that does not enter the kernel) - only one CPU on SMP or no SMP. As requested by jhb@ 4BSD have received the same type of fix instead of propagating the flag to the new thread. Reviewed by: jhb, jeff MFC after: 1 month Modified: head/sys/kern/sched_4bsd.c head/sys/kern/sched_ule.c Modified: head/sys/kern/sched_4bsd.c ============================================================================== --- head/sys/kern/sched_4bsd.c Thu Mar 31 13:36:31 2011 (r220197) +++ head/sys/kern/sched_4bsd.c Thu Mar 31 13:59:47 2011 (r220198) @@ -940,13 +940,9 @@ sched_switch(struct thread *td, struct t if ((td->td_flags & TDF_NOLOAD) == 0) sched_load_rem(); - if (newtd) { - MPASS(newtd->td_lock == &sched_lock); - newtd->td_flags |= (td->td_flags & TDF_NEEDRESCHED); - } - td->td_lastcpu = td->td_oncpu; - td->td_flags &= ~TDF_NEEDRESCHED; + if (!(flags & SW_PREEMPT)) + td->td_flags &= ~TDF_NEEDRESCHED; td->td_owepreempt = 0; td->td_oncpu = NOCPU; Modified: head/sys/kern/sched_ule.c ============================================================================== --- head/sys/kern/sched_ule.c Thu Mar 31 13:36:31 2011 (r220197) +++ head/sys/kern/sched_ule.c Thu Mar 31 13:59:47 2011 (r220198) @@ -1783,7 +1783,8 @@ sched_switch(struct thread *td, struct t ts->ts_rltick = ticks; td->td_lastcpu = td->td_oncpu; td->td_oncpu = NOCPU; - td->td_flags &= ~TDF_NEEDRESCHED; + if (!(flags & SW_PREEMPT)) + td->td_flags &= ~TDF_NEEDRESCHED; td->td_owepreempt = 0; tdq->tdq_switchcnt++; /* From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 14:33: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 CAA311065673; Thu, 31 Mar 2011 14:33:27 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BAEC68FC08; Thu, 31 Mar 2011 14:33:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VEXRZK009299; Thu, 31 Mar 2011 14:33:27 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VEXRHq009297; Thu, 31 Mar 2011 14:33:27 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201103311433.p2VEXRHq009297@svn.freebsd.org> From: Ed Maste Date: Thu, 31 Mar 2011 14:33: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: r220200 - head/usr.sbin/pkg_install 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, 31 Mar 2011 14:33:27 -0000 Author: emaste Date: Thu Mar 31 14:33:27 2011 New Revision: 220200 URL: http://svn.freebsd.org/changeset/base/220200 Log: Remove $Log$ keyword and associated history, which can cause annoyance in diffs in some cases. Revision control tools have a history command to obtain this information. Modified: head/usr.sbin/pkg_install/tkpkg Modified: head/usr.sbin/pkg_install/tkpkg ============================================================================== --- head/usr.sbin/pkg_install/tkpkg Thu Mar 31 14:16:56 2011 (r220199) +++ head/usr.sbin/pkg_install/tkpkg Thu Mar 31 14:33:27 2011 (r220200) @@ -1,31 +1,6 @@ #!/usr/local/bin/wish -f #$FreeBSD$ # -#$Log: tkpkg,v $ -#Revision 1.2 1994/12/06 00:51:21 jkh -#Many of John T. Kohl's patches from NetBSD. Thanks, John! -#Submitted by: jkohl -# -# Revision 1.1 1994/01/06 08:16:20 jkh -# Cleaning house. -# -# Revision 1.1 1993/09/04 17:06:09 jkh -# Added Rich's wish front-end. -# -# Revision 1.6 1993/09/03 23:37:22 rich -# warn user if no tar archives are found in the current directory. -# removed the revision string from the lower text frame. -# -# Revision 1.5 1993/09/03 15:48:04 rich -# glob for .tar.gz, .tar.z and .tar.Z looking for archives -# -# Revision 1.4 1993/08/28 15:53:59 rich -# added version and date info to lower text window. -# -# Revision 1.3 1993/08/28 15:47:12 rich -# filtered out ^Ls in pkg_* output. -# -# set pkgname "" wm title . "Package Installation" #-------------------------------------------------------------- From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 14:35: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 5D1411065670; Thu, 31 Mar 2011 14:35:33 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4D9EE8FC25; Thu, 31 Mar 2011 14:35:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VEZXx5009386; Thu, 31 Mar 2011 14:35:33 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VEZXmF009384; Thu, 31 Mar 2011 14:35:33 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201103311435.p2VEZXmF009384@svn.freebsd.org> From: Ed Maste Date: Thu, 31 Mar 2011 14: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: r220201 - head/usr.bin/compress/doc 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, 31 Mar 2011 14:35:33 -0000 Author: emaste Date: Thu Mar 31 14:35:33 2011 New Revision: 220201 URL: http://svn.freebsd.org/changeset/base/220201 Log: Remove $Log$ keyword, which can cause annoyance in diffs in some cases. Revision control tools have a history command to obtain this information. Modified: head/usr.bin/compress/doc/revision.log Modified: head/usr.bin/compress/doc/revision.log ============================================================================== --- head/usr.bin/compress/doc/revision.log Thu Mar 31 14:33:27 2011 (r220200) +++ head/usr.bin/compress/doc/revision.log Thu Mar 31 14:35:33 2011 (r220201) @@ -2,7 +2,7 @@ /* * $Header: compress.c,v 4.0 85/07/30 12:50:00 joe Release $ - * $Log: compress.c,v $ + * * Revision 4.0 85/07/30 12:50:00 joe * Removed ferror() calls in output routine on every output except first. * Prepared for release to the world. From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 15:10: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 E1684106566B; Thu, 31 Mar 2011 15:10:41 +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 D20888FC0A; Thu, 31 Mar 2011 15:10:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VFAfxp010177; Thu, 31 Mar 2011 15:10:41 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VFAfUj010175; Thu, 31 Mar 2011 15:10:41 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201103311510.p2VFAfUj010175@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Thu, 31 Mar 2011 15:10:41 +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: r220203 - head/sys/netinet/ipfw 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, 31 Mar 2011 15:10:42 -0000 Author: ae Date: Thu Mar 31 15:10:41 2011 New Revision: 220203 URL: http://svn.freebsd.org/changeset/base/220203 Log: Fix a memory leak. Memory that is allocated for schedulers hash table was not freed. PR: kern/156083 MFC after: 1 week Modified: head/sys/netinet/ipfw/ip_dummynet.c Modified: head/sys/netinet/ipfw/ip_dummynet.c ============================================================================== --- head/sys/netinet/ipfw/ip_dummynet.c Thu Mar 31 14:44:00 2011 (r220202) +++ head/sys/netinet/ipfw/ip_dummynet.c Thu Mar 31 15:10:41 2011 (r220203) @@ -748,9 +748,10 @@ schk_delete_cb(void *obj, void *arg) #endif fsk_detach_list(&s->fsk_list, arg ? DN_DESTROY : 0); /* no more flowset pointing to us now */ - if (s->sch.flags & DN_HAVE_MASK) + if (s->sch.flags & DN_HAVE_MASK) { dn_ht_scan(s->siht, si_destroy, NULL); - else if (s->siht) + dn_ht_free(s->siht, 0); + } else if (s->siht) si_destroy(s->siht, NULL); if (s->profile) { free(s->profile, M_DUMMYNET); From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 15:11: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 9C3721065781; Thu, 31 Mar 2011 15:11:12 +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 8CD998FC08; Thu, 31 Mar 2011 15:11:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VFBCFF010239; Thu, 31 Mar 2011 15:11:12 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VFBCDo010237; Thu, 31 Mar 2011 15:11:12 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201103311511.p2VFBCDo010237@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Thu, 31 Mar 2011 15:11: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: r220204 - head/sys/netinet/ipfw 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, 31 Mar 2011 15:11:12 -0000 Author: ae Date: Thu Mar 31 15:11:12 2011 New Revision: 220204 URL: http://svn.freebsd.org/changeset/base/220204 Log: Fix malloc types. MFC after: 1 week Modified: head/sys/netinet/ipfw/ip_dn_glue.c Modified: head/sys/netinet/ipfw/ip_dn_glue.c ============================================================================== --- head/sys/netinet/ipfw/ip_dn_glue.c Thu Mar 31 15:10:41 2011 (r220203) +++ head/sys/netinet/ipfw/ip_dn_glue.c Thu Mar 31 15:11:12 2011 (r220204) @@ -807,7 +807,7 @@ ip_dummynet_compat(struct sockopt *sopt) if (error) break; error = dn_compat_del(v); - free(v, M_DUMMYNET); + free(v, M_TEMP); break; case IP_DUMMYNET_CONFIGURE: @@ -816,7 +816,7 @@ ip_dummynet_compat(struct sockopt *sopt) if (error) break; error = dn_compat_configure(v); - free(v, M_DUMMYNET); + free(v, M_TEMP); break; case IP_DUMMYNET_GET: { From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 15:12: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 A1DFD106564A; Thu, 31 Mar 2011 15:12:40 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 923F88FC1C; Thu, 31 Mar 2011 15:12:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VFCedl010303; Thu, 31 Mar 2011 15:12:40 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VFCeEn010300; Thu, 31 Mar 2011 15:12:40 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201103311512.p2VFCeEn010300@svn.freebsd.org> From: Ed Maste Date: Thu, 31 Mar 2011 15:12: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: r220205 - head/share/examples/kld/firmware/fwimage 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, 31 Mar 2011 15:12:40 -0000 Author: emaste Date: Thu Mar 31 15:12:40 2011 New Revision: 220205 URL: http://svn.freebsd.org/changeset/base/220205 Log: Avoid having a binary file in our source tree and instead create it at build time, to avoid possible grief maintaining FreeBSD source in alternative version control tools. Added: head/share/examples/kld/firmware/fwimage/firmware.img.in - copied, changed from r220153, head/share/examples/kld/firmware/fwimage/firmware.img Deleted: head/share/examples/kld/firmware/fwimage/firmware.img Modified: head/share/examples/kld/firmware/fwimage/Makefile Modified: head/share/examples/kld/firmware/fwimage/Makefile ============================================================================== --- head/share/examples/kld/firmware/fwimage/Makefile Thu Mar 31 15:11:12 2011 (r220204) +++ head/share/examples/kld/firmware/fwimage/Makefile Thu Mar 31 15:12:40 2011 (r220205) @@ -3,4 +3,8 @@ KMOD= beastie FIRMWS= firmware.img:beastie +firmware.img: firmware.img.in + cp ${.ALLSRC} ${.TARGET} + printf '\0\0\0\0\0' >> ${.TARGET} + .include Copied and modified: head/share/examples/kld/firmware/fwimage/firmware.img.in (from r220153, head/share/examples/kld/firmware/fwimage/firmware.img) ============================================================================== Files head/share/examples/kld/firmware/fwimage/firmware.img Wed Mar 30 01:19:00 2011 (r220153, copy source) and head/share/examples/kld/firmware/fwimage/firmware.img.in Thu Mar 31 15:12:40 2011 (r220205) differ From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 15:23:32 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 76AB71065674; Thu, 31 Mar 2011 15:23:32 +0000 (UTC) (envelope-from fabient@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6633D8FC12; Thu, 31 Mar 2011 15:23:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VFNWPk010562; Thu, 31 Mar 2011 15:23:32 GMT (envelope-from fabient@svn.freebsd.org) Received: (from fabient@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VFNWNf010554; Thu, 31 Mar 2011 15:23:32 GMT (envelope-from fabient@svn.freebsd.org) Message-Id: <201103311523.p2VFNWNf010554@svn.freebsd.org> From: Fabien Thomas Date: Thu, 31 Mar 2011 15:23: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: r220206 - head/sys/netipsec 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, 31 Mar 2011 15:23:32 -0000 Author: fabient Date: Thu Mar 31 15:23:32 2011 New Revision: 220206 URL: http://svn.freebsd.org/changeset/base/220206 Log: Optimisation in IPSEC(4): - Remove contention on ISR during the crypto operation by using rwlock(9). - Remove a second lookup of the SA in the callback. Gain on 6 cores CPU with SHA1/AES128 can be up to 30%. Reviewed by: vanhu MFC after: 1 month Modified: head/sys/netipsec/ipsec.h head/sys/netipsec/key.c head/sys/netipsec/key.h head/sys/netipsec/xform.h head/sys/netipsec/xform_ah.c head/sys/netipsec/xform_esp.c head/sys/netipsec/xform_ipcomp.c Modified: head/sys/netipsec/ipsec.h ============================================================================== --- head/sys/netipsec/ipsec.h Thu Mar 31 15:12:40 2011 (r220205) +++ head/sys/netipsec/ipsec.h Thu Mar 31 15:23:32 2011 (r220206) @@ -123,7 +123,7 @@ struct ipsecrequest { struct secasvar *sav; /* place holder of SA for use */ struct secpolicy *sp; /* back pointer to SP */ - struct mtx lock; /* to interlock updates */ + struct rwlock lock; /* to interlock updates */ }; /* @@ -132,11 +132,15 @@ struct ipsecrequest { * hard it is to remove this... */ #define IPSECREQUEST_LOCK_INIT(_isr) \ - mtx_init(&(_isr)->lock, "ipsec request", NULL, MTX_DEF | MTX_RECURSE) -#define IPSECREQUEST_LOCK(_isr) mtx_lock(&(_isr)->lock) -#define IPSECREQUEST_UNLOCK(_isr) mtx_unlock(&(_isr)->lock) -#define IPSECREQUEST_LOCK_DESTROY(_isr) mtx_destroy(&(_isr)->lock) -#define IPSECREQUEST_LOCK_ASSERT(_isr) mtx_assert(&(_isr)->lock, MA_OWNED) + rw_init_flags(&(_isr)->lock, "ipsec request", RW_RECURSE) +#define IPSECREQUEST_LOCK(_isr) rw_rlock(&(_isr)->lock) +#define IPSECREQUEST_UNLOCK(_isr) rw_runlock(&(_isr)->lock) +#define IPSECREQUEST_WLOCK(_isr) rw_wlock(&(_isr)->lock) +#define IPSECREQUEST_WUNLOCK(_isr) rw_wunlock(&(_isr)->lock) +#define IPSECREQUEST_UPGRADE(_isr) rw_try_upgrade(&(_isr)->lock) +#define IPSECREQUEST_DOWNGRADE(_isr) rw_downgrade(&(_isr)->lock) +#define IPSECREQUEST_LOCK_DESTROY(_isr) rw_destroy(&(_isr)->lock) +#define IPSECREQUEST_LOCK_ASSERT(_isr) rw_assert(&(_isr)->lock, RA_LOCKED) /* security policy in PCB */ struct inpcbpolicy { Modified: head/sys/netipsec/key.c ============================================================================== --- head/sys/netipsec/key.c Thu Mar 31 15:12:40 2011 (r220205) +++ head/sys/netipsec/key.c Thu Mar 31 15:23:32 2011 (r220206) @@ -809,6 +809,7 @@ key_checkrequest(struct ipsecrequest *is { u_int level; int error; + struct secasvar *sav; IPSEC_ASSERT(isr != NULL, ("null isr")); IPSEC_ASSERT(saidx != NULL, ("null saidx")); @@ -826,45 +827,31 @@ key_checkrequest(struct ipsecrequest *is /* get current level */ level = ipsec_get_reqlevel(isr); -#if 0 - /* - * We do allocate new SA only if the state of SA in the holder is - * SADB_SASTATE_DEAD. The SA for outbound must be the oldest. - */ - if (isr->sav != NULL) { - if (isr->sav->sah == NULL) - panic("%s: sah is null.\n", __func__); - if (isr->sav == (struct secasvar *)LIST_FIRST( - &isr->sav->sah->savtree[SADB_SASTATE_DEAD])) { - KEY_FREESAV(&isr->sav); - isr->sav = NULL; - } - } -#else + /* - * we free any SA stashed in the IPsec request because a different + * We check new SA in the IPsec request because a different * SA may be involved each time this request is checked, either * because new SAs are being configured, or this request is * associated with an unconnected datagram socket, or this request * is associated with a system default policy. * - * The operation may have negative impact to performance. We may - * want to check cached SA carefully, rather than picking new SA - * every time. - */ - if (isr->sav != NULL) { - KEY_FREESAV(&isr->sav); - isr->sav = NULL; - } -#endif - - /* - * new SA allocation if no SA found. * key_allocsa_policy should allocate the oldest SA available. * See key_do_allocsa_policy(), and draft-jenkins-ipsec-rekeying-03.txt. */ - if (isr->sav == NULL) - isr->sav = key_allocsa_policy(saidx); + sav = key_allocsa_policy(saidx); + if (sav != isr->sav) { + /* SA need to be updated. */ + if (!IPSECREQUEST_UPGRADE(isr)) { + /* Kick everyone off. */ + IPSECREQUEST_UNLOCK(isr); + IPSECREQUEST_WLOCK(isr); + } + if (isr->sav != NULL) + KEY_FREESAV(&isr->sav); + isr->sav = sav; + IPSECREQUEST_DOWNGRADE(isr); + } else if (sav != NULL) + KEY_FREESAV(&sav); /* When there is SA. */ if (isr->sav != NULL) { @@ -1240,6 +1227,16 @@ key_freesp_so(struct secpolicy **sp) KEY_FREESP(sp); } +void +key_addrefsa(struct secasvar *sav, const char* where, int tag) +{ + + IPSEC_ASSERT(sav != NULL, ("null sav")); + IPSEC_ASSERT(sav->refcnt > 0, ("refcount must exist")); + + sa_addref(sav); +} + /* * Must be called after calling key_allocsa(). * This function is called by key_freesp() to free some SA allocated Modified: head/sys/netipsec/key.h ============================================================================== --- head/sys/netipsec/key.h Thu Mar 31 15:12:40 2011 (r220205) +++ head/sys/netipsec/key.h Thu Mar 31 15:23:32 2011 (r220206) @@ -76,10 +76,13 @@ extern void _key_freesp(struct secpolicy extern struct secasvar *key_allocsa(union sockaddr_union *, u_int, u_int32_t, const char*, int); +extern void key_addrefsa(struct secasvar *, const char*, int); extern void key_freesav(struct secasvar **, const char*, int); #define KEY_ALLOCSA(dst, proto, spi) \ key_allocsa(dst, proto, spi, __FILE__, __LINE__) +#define KEY_ADDREFSA(sav) \ + key_addrefsa(sav, __FILE__, __LINE__) #define KEY_FREESAV(psav) \ key_freesav(psav, __FILE__, __LINE__) Modified: head/sys/netipsec/xform.h ============================================================================== --- head/sys/netipsec/xform.h Thu Mar 31 15:12:40 2011 (r220205) +++ head/sys/netipsec/xform.h Thu Mar 31 15:23:32 2011 (r220206) @@ -75,6 +75,7 @@ struct tdb_crypto { int tc_protoff; /* current protocol offset */ int tc_skip; /* data offset */ caddr_t tc_ptr; /* associated crypto data */ + struct secasvar *tc_sav; /* related SA */ }; struct secasvar; Modified: head/sys/netipsec/xform_ah.c ============================================================================== --- head/sys/netipsec/xform_ah.c Thu Mar 31 15:12:40 2011 (r220205) +++ head/sys/netipsec/xform_ah.c Thu Mar 31 15:23:32 2011 (r220206) @@ -715,6 +715,8 @@ ah_input(struct mbuf *m, struct secasvar tc->tc_protoff = protoff; tc->tc_skip = skip; tc->tc_ptr = (caddr_t) mtag; /* Save the mtag we've identified. */ + KEY_ADDREFSA(sav); + tc->tc_sav = sav; if (mtag == NULL) return crypto_dispatch(crp); @@ -764,13 +766,8 @@ ah_input_cb(struct cryptop *crp) mtag = (struct m_tag *) tc->tc_ptr; m = (struct mbuf *) crp->crp_buf; - sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi); - if (sav == NULL) { - V_ahstat.ahs_notdb++; - DPRINTF(("%s: SA expired while in crypto\n", __func__)); - error = ENOBUFS; /*XXX*/ - goto bad; - } + sav = tc->tc_sav; + IPSEC_ASSERT(sav != NULL, ("null SA!")); saidx = &sav->sah->saidx; IPSEC_ASSERT(saidx->dst.sa.sa_family == AF_INET || @@ -785,7 +782,6 @@ ah_input_cb(struct cryptop *crp) sav->tdb_cryptoid = crp->crp_sid; if (crp->crp_etype == EAGAIN) { - KEY_FREESAV(&sav); error = crypto_dispatch(crp); return error; } @@ -1111,6 +1107,8 @@ ah_output( /* These are passed as-is to the callback. */ tc->tc_isr = isr; + KEY_ADDREFSA(sav); + tc->tc_sav = sav; tc->tc_spi = sav->spi; tc->tc_dst = sav->sah->saidx.dst; tc->tc_proto = sav->sah->saidx.proto; @@ -1147,14 +1145,14 @@ ah_output_cb(struct cryptop *crp) isr = tc->tc_isr; IPSECREQUEST_LOCK(isr); - sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi); - if (sav == NULL) { + sav = tc->tc_sav; + /* With the isr lock released SA pointer can be updated. */ + if (sav != isr->sav) { V_ahstat.ahs_notdb++; DPRINTF(("%s: SA expired while in crypto\n", __func__)); error = ENOBUFS; /*XXX*/ goto bad; } - IPSEC_ASSERT(isr->sav == sav, ("SA changed\n")); /* Check for crypto errors. */ if (crp->crp_etype) { @@ -1162,7 +1160,6 @@ ah_output_cb(struct cryptop *crp) sav->tdb_cryptoid = crp->crp_sid; if (crp->crp_etype == EAGAIN) { - KEY_FREESAV(&sav); IPSECREQUEST_UNLOCK(isr); error = crypto_dispatch(crp); return error; Modified: head/sys/netipsec/xform_esp.c ============================================================================== --- head/sys/netipsec/xform_esp.c Thu Mar 31 15:12:40 2011 (r220205) +++ head/sys/netipsec/xform_esp.c Thu Mar 31 15:23:32 2011 (r220206) @@ -429,6 +429,8 @@ esp_input(struct mbuf *m, struct secasva tc->tc_proto = sav->sah->saidx.proto; tc->tc_protoff = protoff; tc->tc_skip = skip; + KEY_ADDREFSA(sav); + tc->tc_sav = sav; /* Decryption descriptor */ if (espx) { @@ -490,15 +492,8 @@ esp_input_cb(struct cryptop *crp) mtag = (struct m_tag *) tc->tc_ptr; m = (struct mbuf *) crp->crp_buf; - sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi); - if (sav == NULL) { - V_espstat.esps_notdb++; - DPRINTF(("%s: SA gone during crypto (SA %s/%08lx proto %u)\n", - __func__, ipsec_address(&tc->tc_dst), - (u_long) ntohl(tc->tc_spi), tc->tc_proto)); - error = ENOBUFS; /*XXX*/ - goto bad; - } + sav = tc->tc_sav; + IPSEC_ASSERT(sav != NULL, ("null SA!")); saidx = &sav->sah->saidx; IPSEC_ASSERT(saidx->dst.sa.sa_family == AF_INET || @@ -515,7 +510,6 @@ esp_input_cb(struct cryptop *crp) sav->tdb_cryptoid = crp->crp_sid; if (crp->crp_etype == EAGAIN) { - KEY_FREESAV(&sav); error = crypto_dispatch(crp); return error; } @@ -883,6 +877,8 @@ esp_output( /* Callback parameters */ tc->tc_isr = isr; + KEY_ADDREFSA(sav); + tc->tc_sav = sav; tc->tc_spi = sav->spi; tc->tc_dst = saidx->dst; tc->tc_proto = saidx->proto; @@ -932,8 +928,9 @@ esp_output_cb(struct cryptop *crp) isr = tc->tc_isr; IPSECREQUEST_LOCK(isr); - sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi); - if (sav == NULL) { + sav = tc->tc_sav; + /* With the isr lock released SA pointer can be updated. */ + if (sav != isr->sav) { V_espstat.esps_notdb++; DPRINTF(("%s: SA gone during crypto (SA %s/%08lx proto %u)\n", __func__, ipsec_address(&tc->tc_dst), @@ -941,8 +938,6 @@ esp_output_cb(struct cryptop *crp) error = ENOBUFS; /*XXX*/ goto bad; } - IPSEC_ASSERT(isr->sav == sav, - ("SA changed was %p now %p\n", isr->sav, sav)); /* Check for crypto errors. */ if (crp->crp_etype) { @@ -951,7 +946,6 @@ esp_output_cb(struct cryptop *crp) sav->tdb_cryptoid = crp->crp_sid; if (crp->crp_etype == EAGAIN) { - KEY_FREESAV(&sav); IPSECREQUEST_UNLOCK(isr); error = crypto_dispatch(crp); return error; Modified: head/sys/netipsec/xform_ipcomp.c ============================================================================== --- head/sys/netipsec/xform_ipcomp.c Thu Mar 31 15:12:40 2011 (r220205) +++ head/sys/netipsec/xform_ipcomp.c Thu Mar 31 15:23:32 2011 (r220206) @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -185,6 +186,8 @@ ipcomp_input(struct mbuf *m, struct seca tc->tc_proto = sav->sah->saidx.proto; tc->tc_protoff = protoff; tc->tc_skip = skip; + KEY_ADDREFSA(sav); + tc->tc_sav = sav; return crypto_dispatch(crp); } @@ -228,13 +231,8 @@ ipcomp_input_cb(struct cryptop *crp) mtag = (struct mtag *) tc->tc_ptr; m = (struct mbuf *) crp->crp_buf; - sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi); - if (sav == NULL) { - V_ipcompstat.ipcomps_notdb++; - DPRINTF(("%s: SA expired while in crypto\n", __func__)); - error = ENOBUFS; /*XXX*/ - goto bad; - } + sav = tc->tc_sav; + IPSEC_ASSERT(sav != NULL, ("null SA!")); saidx = &sav->sah->saidx; IPSEC_ASSERT(saidx->dst.sa.sa_family == AF_INET || @@ -248,7 +246,6 @@ ipcomp_input_cb(struct cryptop *crp) sav->tdb_cryptoid = crp->crp_sid; if (crp->crp_etype == EAGAIN) { - KEY_FREESAV(&sav); return crypto_dispatch(crp); } V_ipcompstat.ipcomps_noxform++; @@ -431,6 +428,8 @@ ipcomp_output( } tc->tc_isr = isr; + KEY_ADDREFSA(sav); + tc->tc_sav = sav; tc->tc_spi = sav->spi; tc->tc_dst = sav->sah->saidx.dst; tc->tc_proto = sav->sah->saidx.proto; @@ -471,14 +470,14 @@ ipcomp_output_cb(struct cryptop *crp) isr = tc->tc_isr; IPSECREQUEST_LOCK(isr); - sav = KEY_ALLOCSA(&tc->tc_dst, tc->tc_proto, tc->tc_spi); - if (sav == NULL) { + sav = tc->tc_sav; + /* With the isr lock released SA pointer can be updated. */ + if (sav != isr->sav) { V_ipcompstat.ipcomps_notdb++; DPRINTF(("%s: SA expired while in crypto\n", __func__)); error = ENOBUFS; /*XXX*/ goto bad; } - IPSEC_ASSERT(isr->sav == sav, ("SA changed\n")); /* Check for crypto errors */ if (crp->crp_etype) { @@ -487,7 +486,6 @@ ipcomp_output_cb(struct cryptop *crp) sav->tdb_cryptoid = crp->crp_sid; if (crp->crp_etype == EAGAIN) { - KEY_FREESAV(&sav); IPSECREQUEST_UNLOCK(isr); return crypto_dispatch(crp); } From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 15:40: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 06A88106566B; Thu, 31 Mar 2011 15:40:14 +0000 (UTC) (envelope-from rrs@lakerest.net) Received: from lakerest.net (unknown [IPv6:2001:240:585:2:213:d4ff:fef3:2d8d]) by mx1.freebsd.org (Postfix) with ESMTP id 8A7A48FC13; Thu, 31 Mar 2011 15:40:13 +0000 (UTC) Received: from dhcp-54bc.meeting.ietf.org (dhcp-54bc.meeting.ietf.org [130.129.84.188]) (authenticated bits=0) by lakerest.net (8.14.4/8.14.3) with ESMTP id p2VFe9FU061476 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Thu, 31 Mar 2011 11:40:11 -0400 (EDT) (envelope-from rrs@lakerest.net) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Randall Stewart In-Reply-To: <201103291401.03565.jhb@freebsd.org> Date: Thu, 31 Mar 2011 11:40:08 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: <2BE17525-83AA-4255-B191-3429B5FF6F5E@lakerest.net> References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> <201103291401.03565.jhb@freebsd.org> To: John Baldwin X-Mailer: Apple Mail (2.1084) Cc: svn-src-head@FreeBSD.org, Daniel Eischen , svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r217592 - 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, 31 Mar 2011 15:40:14 -0000 John: So I caught up with Dave Thaler here at the IETF... He said that NO UDP socket that has NOT joined a multicast group should ever receive a packet sent to a multicast address. He also said this was part of the POSIX API and the way all Unix machines worked.=20 So.. no it is a bug and the fix is correct. R On Mar 29, 2011, at 2:01 PM, John Baldwin wrote: > On Wednesday, January 19, 2011 2:07:16 pm Randall Stewart wrote: >> Author: rrs >> Date: Wed Jan 19 19:07:16 2011 >> New Revision: 217592 >> URL: http://svn.freebsd.org/changeset/base/217592 >>=20 >> Log: >> Fix a bug where Multicast packets sent from a >> udp endpoint may end up echoing back to the sender >> even with OUT joining the multi-cast group. >>=20 >> Reviewed by: gnn, bms, bz? >> Obtained from: deischen (with help from) >>=20 >> Modified: >> head/sys/netinet/udp_usrreq.c >>=20 >> Modified: head/sys/netinet/udp_usrreq.c >>=20 > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/netinet/udp_usrreq.c Wed Jan 19 18:20:11 2011 = (r217591) >> +++ head/sys/netinet/udp_usrreq.c Wed Jan 19 19:07:16 2011 = (r217592) >> @@ -479,11 +479,13 @@ udp_input(struct mbuf *m, int off) >> * and source-specific multicast. [RFC3678] >> */ >> imo =3D inp->inp_moptions; >> - if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && >> - imo !=3D NULL) { >> + if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { >> struct sockaddr_in group; >> int blocked; >> - >> + if(imo =3D=3D NULL) { >> + INP_RUNLOCK(inp); >> + continue; >> + } >> bzero(&group, sizeof(struct = sockaddr_in)); >> group.sin_len =3D sizeof(struct = sockaddr_in); >> group.sin_family =3D AF_INET; >=20 > So it turns out that this is a feature, not a bug, and is how = multicast has=20 > always worked. Specifically, if you bind a UDP socket with a wildcard=20= > address, it should receive all traffic for the bound port, unicast or=20= > multicast. When you join a group, you have switched the socket into a = mode=20 > where it now has a whitelist of acceptable multicast groups, but if a = socket=20 > has no joined groups, it should receive all multicast traffic, not = none. This=20 > change breaks that. >=20 > I did not find this behavior intuitive at first, but it does seem to = be=20 > required. Note the description of IP_ADD_MEMBERSHIP from RFC 3678 for=20= > example: >=20 > 3. Overview of APIs >=20 > There are a number of different APIs described in this document that > are appropriate for a number of different application types and IP > versions. Before providing detailed descriptions, this section > provides a "taxonomy" with a brief description of each. >=20 > There are two categories of source-filter APIs, both of which are > designed to allow multicast receiver applications to designate the > unicast address(es) of sender(s) along with the multicast group > (destination address) to receive. >=20 > o Basic (Delta-based): Some applications desire the simplicity = of > a delta-based API in which each function call specifies a > single source address which should be added to or removed from > the existing filter for a given multicast group address on > which to listen. Such applications typically fall into either > of two categories: >=20 > + Any-Source Multicast: By default, all sources are accepted. > Individual sources may be turned off and back on as needed > over time. This is also known as "exclude" mode, since the > source filter contains a list of excluded sources. >=20 > + Source-Specific Multicast: Only sources in a given list are > allowed. The list may change over time. This is also = known > as "include" mode, since the source filter contains a list > of included sources. >=20 > This API would be used, for example, by "single-source" > applications such as audio/video broadcasting. It would > also be used for logical multi-source sessions where each > source independently allocates its own Source-Specific > Multicast group address. >=20 >=20 > ..... >=20 > 4.1.1. IPv4 Any-Source Multicast API >=20 > The following socket options are defined in for > applications in the Any-Source Multicast category: >=20 > Socket option Argument type > IP_ADD_MEMBERSHIP struct ip_mreq > IP_BLOCK_SOURCE struct ip_mreq_source > IP_UNBLOCK_SOURCE struct ip_mreq_source > IP_DROP_MEMBERSHIP struct ip_mreq >=20 > IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP are already implemented on > most operating systems, and are used to join and leave an any-source > group. >=20 > IP_BLOCK_SOURCE can be used to block data from a given source to a > given group (e.g., if the user "mutes" that source), and > IP_UNBLOCK_SOURCE can be used to undo this (e.g., if the user then > "unmutes" the source). >=20 > As to why the packets loop back to the receiver, I believe that is a = separate=20 > issue on the output side, not the receive side. >=20 > --=20 > John Baldwin >=20 ------------------------------ Randall Stewart 803-317-4952 (cell) From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 15:45: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 62419106564A; Thu, 31 Mar 2011 15:45:23 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 1E3A88FC12; Thu, 31 Mar 2011 15:45:22 +0000 (UTC) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.4/8.14.4/NETPLEX) with ESMTP id p2VFjMTh012910; Thu, 31 Mar 2011 11:45:22 -0400 X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.2.6 (mail.netplex.net [204.213.176.10]); Thu, 31 Mar 2011 11:45:22 -0400 (EDT) Date: Thu, 31 Mar 2011 11:45:22 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Randall Stewart In-Reply-To: <2BE17525-83AA-4255-B191-3429B5FF6F5E@lakerest.net> Message-ID: References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> <201103291401.03565.jhb@freebsd.org> <2BE17525-83AA-4255-B191-3429B5FF6F5E@lakerest.net> 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, John Baldwin Subject: Re: svn commit: r217592 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen 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, 31 Mar 2011 15:45:23 -0000 On Thu, 31 Mar 2011, Randall Stewart wrote: > John: > > So I caught up with Dave Thaler here at the IETF... > > He said that NO UDP socket that has NOT joined a multicast > group should ever receive a packet sent to a multicast address. > He also said this was part of the POSIX API and the way > all Unix machines worked. > > So.. no it is a bug and the fix is correct. Randall, thank you for following this up. If we ever meet, I owe you a beer (or drink of your choice) :-) -- DE From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 16:14:35 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 BB5EE106564A; Thu, 31 Mar 2011 16:14:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A0EBF8FC08; Thu, 31 Mar 2011 16:14:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VGEZbQ011874; Thu, 31 Mar 2011 16:14:35 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VGEZZb011867; Thu, 31 Mar 2011 16:14:35 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201103311614.p2VGEZZb011867@svn.freebsd.org> From: Alexander Motin Date: Thu, 31 Mar 2011 16:14:35 +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: r220209 - head/sys/geom/raid 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, 31 Mar 2011 16:14:35 -0000 Author: mav Date: Thu Mar 31 16:14:35 2011 New Revision: 220209 URL: http://svn.freebsd.org/changeset/base/220209 Log: Bunch of small bugfixes and cleanups. Found with: Coverity Prevent(tm) CID: 9656, 9658, 9693, 9705, 9706, 9707, 9808, 9809, 9810, 9711, 9712, 9713, 9714 Modified: head/sys/geom/raid/md_intel.c head/sys/geom/raid/md_jmicron.c head/sys/geom/raid/md_nvidia.c head/sys/geom/raid/md_promise.c head/sys/geom/raid/md_sii.c head/sys/geom/raid/tr_raid1.c Modified: head/sys/geom/raid/md_intel.c ============================================================================== --- head/sys/geom/raid/md_intel.c Thu Mar 31 15:52:12 2011 (r220208) +++ head/sys/geom/raid/md_intel.c Thu Mar 31 16:14:35 2011 (r220209) @@ -541,9 +541,9 @@ intel_meta_write_spare(struct g_consumer /* Fill anchor and single disk. */ meta = malloc(INTEL_MAX_MD_SIZE(1), M_MD_INTEL, M_WAITOK | M_ZERO); - memcpy(&meta->intel_id[0], INTEL_MAGIC, sizeof(INTEL_MAGIC)); + memcpy(&meta->intel_id[0], INTEL_MAGIC, sizeof(INTEL_MAGIC) - 1); memcpy(&meta->version[0], INTEL_VERSION_1000, - sizeof(INTEL_VERSION_1000)); + sizeof(INTEL_VERSION_1000) - 1); meta->config_size = INTEL_MAX_MD_SIZE(1); meta->config_id = arc4random(); meta->generation = 1; @@ -1881,10 +1881,8 @@ g_raid_md_ctl_intel(struct g_raid_md_obj /* If disk was assigned, just update statuses. */ if (pd->pd_disk_pos >= 0) { g_raid_change_disk_state(disk, G_RAID_DISK_S_OFFLINE); - if (disk->d_consumer) { - g_raid_kill_consumer(sc, disk->d_consumer); - disk->d_consumer = NULL; - } + g_raid_kill_consumer(sc, disk->d_consumer); + disk->d_consumer = NULL; TAILQ_FOREACH(sd, &disk->d_subdisks, sd_next) { g_raid_change_subdisk_state(sd, G_RAID_SUBDISK_S_NONE); @@ -2049,7 +2047,7 @@ g_raid_md_write_intel(struct g_raid_md_o /* Fill anchor and disks. */ meta = malloc(INTEL_MAX_MD_SIZE(numdisks), M_MD_INTEL, M_WAITOK | M_ZERO); - memcpy(&meta->intel_id[0], INTEL_MAGIC, sizeof(INTEL_MAGIC)); + memcpy(&meta->intel_id[0], INTEL_MAGIC, sizeof(INTEL_MAGIC) - 1); meta->config_size = INTEL_MAX_MD_SIZE(numdisks); meta->config_id = mdi->mdio_config_id; meta->generation = mdi->mdio_generation; @@ -2214,7 +2212,7 @@ g_raid_md_write_intel(struct g_raid_md_o meta->total_volumes = vi; if (strcmp(version, INTEL_VERSION_1300) != 0) meta->attributes &= INTEL_ATTR_CHECKSUM; - memcpy(&meta->version[0], version, sizeof(INTEL_VERSION_1000)); + memcpy(&meta->version[0], version, sizeof(INTEL_VERSION_1000) - 1); /* We are done. Print meta data and store them to disks. */ g_raid_md_intel_print(meta); Modified: head/sys/geom/raid/md_jmicron.c ============================================================================== --- head/sys/geom/raid/md_jmicron.c Thu Mar 31 15:52:12 2011 (r220208) +++ head/sys/geom/raid/md_jmicron.c Thu Mar 31 16:14:35 2011 (r220209) @@ -431,7 +431,10 @@ g_raid_md_jmicron_start_disk(struct g_ra olddisk = NULL; /* Find disk position in metadata by it's serial. */ - disk_pos = jmicron_meta_find_disk(meta, pd->pd_disk_id); + if (pd->pd_meta != NULL) + disk_pos = jmicron_meta_find_disk(meta, pd->pd_disk_id); + else + disk_pos = -1; if (disk_pos < 0) { G_RAID_DEBUG1(1, sc, "Unknown, probably new or stale disk"); /* If we are in the start process, that's all for now. */ @@ -522,7 +525,7 @@ nofit: * Different disks may have different sizes/offsets, * especially in concat mode. Update. */ - if (pd->pd_meta != NULL && !resurrection) { + if (!resurrection) { sd->sd_offset = (off_t)pd->pd_meta->offset * 16 * 512; //ZZZ sd->sd_size = @@ -1300,10 +1303,8 @@ g_raid_md_ctl_jmicron(struct g_raid_md_o /* If disk was assigned, just update statuses. */ if (pd->pd_disk_pos >= 0) { g_raid_change_disk_state(disk, G_RAID_DISK_S_OFFLINE); - if (disk->d_consumer) { - g_raid_kill_consumer(sc, disk->d_consumer); - disk->d_consumer = NULL; - } + g_raid_kill_consumer(sc, disk->d_consumer); + disk->d_consumer = NULL; TAILQ_FOREACH(sd, &disk->d_subdisks, sd_next) { g_raid_change_subdisk_state(sd, G_RAID_SUBDISK_S_NONE); Modified: head/sys/geom/raid/md_nvidia.c ============================================================================== --- head/sys/geom/raid/md_nvidia.c Thu Mar 31 15:52:12 2011 (r220208) +++ head/sys/geom/raid/md_nvidia.c Thu Mar 31 16:14:35 2011 (r220209) @@ -1311,10 +1311,8 @@ g_raid_md_ctl_nvidia(struct g_raid_md_ob /* If disk was assigned, just update statuses. */ if (pd->pd_disk_pos >= 0) { g_raid_change_disk_state(disk, G_RAID_DISK_S_OFFLINE); - if (disk->d_consumer) { - g_raid_kill_consumer(sc, disk->d_consumer); - disk->d_consumer = NULL; - } + g_raid_kill_consumer(sc, disk->d_consumer); + disk->d_consumer = NULL; TAILQ_FOREACH(sd, &disk->d_subdisks, sd_next) { g_raid_change_subdisk_state(sd, G_RAID_SUBDISK_S_NONE); @@ -1435,7 +1433,7 @@ g_raid_md_write_nvidia(struct g_raid_md_ meta = malloc(sizeof(*meta), M_MD_NVIDIA, M_WAITOK | M_ZERO); if (mdi->mdio_meta) memcpy(meta, mdi->mdio_meta, sizeof(*meta)); - memcpy(meta->nvidia_id, NVIDIA_MAGIC, sizeof(NVIDIA_MAGIC)); + memcpy(meta->nvidia_id, NVIDIA_MAGIC, sizeof(NVIDIA_MAGIC) - 1); meta->config_size = 30; meta->version = 0x0064; meta->total_sectors = vol->v_mediasize / vol->v_sectorsize; Modified: head/sys/geom/raid/md_promise.c ============================================================================== --- head/sys/geom/raid/md_promise.c Thu Mar 31 15:52:12 2011 (r220208) +++ head/sys/geom/raid/md_promise.c Thu Mar 31 16:14:35 2011 (r220209) @@ -398,7 +398,8 @@ next: &off, &size)) { /* Optionally add record for unused space. */ meta = (struct promise_raid_conf *)buf; - memcpy(&meta->promise_id[0], PROMISE_MAGIC, sizeof(PROMISE_MAGIC)); + memcpy(&meta->promise_id[0], PROMISE_MAGIC, + sizeof(PROMISE_MAGIC) - 1); meta->dummy_0 = 0x00020000; meta->integrity = PROMISE_I_VALID; meta->disk.flags = PROMISE_F_ONLINE | PROMISE_F_VALID; @@ -462,7 +463,7 @@ promise_meta_write_spare(struct g_consum int error; meta = malloc(sizeof(*meta), M_MD_PROMISE, M_WAITOK | M_ZERO); - memcpy(&meta->promise_id[0], PROMISE_MAGIC, sizeof(PROMISE_MAGIC)); + memcpy(&meta->promise_id[0], PROMISE_MAGIC, sizeof(PROMISE_MAGIC) - 1); meta->dummy_0 = 0x00020000; meta->integrity = PROMISE_I_VALID; meta->disk.flags = PROMISE_F_SPARE | PROMISE_F_ONLINE | PROMISE_F_VALID; @@ -818,10 +819,10 @@ restart: } else update = 0; if (update) { + updated = 1; g_raid_md_write_promise(md, vol, NULL, disk); break; } - updated += update; } } if (updated) @@ -1684,7 +1685,8 @@ g_raid_md_write_promise(struct g_raid_md meta = malloc(sizeof(*meta), M_MD_PROMISE, M_WAITOK | M_ZERO); if (pv->pv_meta != NULL) memcpy(meta, pv->pv_meta, sizeof(*meta)); - memcpy(meta->promise_id, PROMISE_MAGIC, sizeof(PROMISE_MAGIC)); + memcpy(meta->promise_id, PROMISE_MAGIC, + sizeof(PROMISE_MAGIC) - 1); meta->dummy_0 = 0x00020000; meta->integrity = PROMISE_I_VALID; Modified: head/sys/geom/raid/md_sii.c ============================================================================== --- head/sys/geom/raid/md_sii.c Thu Mar 31 15:52:12 2011 (r220208) +++ head/sys/geom/raid/md_sii.c Thu Mar 31 16:14:35 2011 (r220209) @@ -1389,10 +1389,8 @@ g_raid_md_ctl_sii(struct g_raid_md_objec /* If disk was assigned, just update statuses. */ if (pd->pd_disk_pos >= 0) { g_raid_change_disk_state(disk, G_RAID_DISK_S_OFFLINE); - if (disk->d_consumer) { - g_raid_kill_consumer(sc, disk->d_consumer); - disk->d_consumer = NULL; - } + g_raid_kill_consumer(sc, disk->d_consumer); + disk->d_consumer = NULL; TAILQ_FOREACH(sd, &disk->d_subdisks, sd_next) { g_raid_change_subdisk_state(sd, G_RAID_SUBDISK_S_NONE); Modified: head/sys/geom/raid/tr_raid1.c ============================================================================== --- head/sys/geom/raid/tr_raid1.c Thu Mar 31 15:52:12 2011 (r220208) +++ head/sys/geom/raid/tr_raid1.c Thu Mar 31 16:14:35 2011 (r220209) @@ -720,8 +720,6 @@ g_raid_tr_iodone_raid1(struct g_raid_tr_ bp->bio_error); bp->bio_cmd = BIO_WRITE; bp->bio_cflags = G_RAID_BIO_FLAG_SYNC; - bp->bio_offset = bp->bio_offset; - bp->bio_length = bp->bio_length; G_RAID_LOGREQ(4, bp, "Queueing rebuild write."); g_raid_subdisk_iostart(trs->trso_failed_sd, bp); } else { From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 16:19: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 A79B71065672; Thu, 31 Mar 2011 16:19:53 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 96B728FC16; Thu, 31 Mar 2011 16:19:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VGJrkh012048; Thu, 31 Mar 2011 16:19:53 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VGJrqN012039; Thu, 31 Mar 2011 16:19:53 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201103311619.p2VGJrqN012039@svn.freebsd.org> From: Alexander Motin Date: Thu, 31 Mar 2011 16:19: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: r220210 - head/sys/geom/raid 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, 31 Mar 2011 16:19:53 -0000 Author: mav Date: Thu Mar 31 16:19:53 2011 New Revision: 220210 URL: http://svn.freebsd.org/changeset/base/220210 Log: Bunch of small bugfixes and cleanups. Found with: Clang Static Analyzer Modified: head/sys/geom/raid/g_raid.c head/sys/geom/raid/md_intel.c head/sys/geom/raid/md_jmicron.c head/sys/geom/raid/md_nvidia.c head/sys/geom/raid/md_promise.c head/sys/geom/raid/md_sii.c head/sys/geom/raid/tr_raid1.c head/sys/geom/raid/tr_raid1e.c Modified: head/sys/geom/raid/g_raid.c ============================================================================== --- head/sys/geom/raid/g_raid.c Thu Mar 31 16:14:35 2011 (r220209) +++ head/sys/geom/raid/g_raid.c Thu Mar 31 16:19:53 2011 (r220210) @@ -1608,7 +1608,7 @@ g_raid_access(struct g_provider *pp, int { struct g_raid_volume *vol; struct g_raid_softc *sc; - int dcr, dcw, dce, opens, error = 0; + int dcw, opens, error = 0; g_topology_assert(); sc = pp->geom->softc; @@ -1618,10 +1618,7 @@ g_raid_access(struct g_provider *pp, int G_RAID_DEBUG1(2, sc, "Access request for %s: r%dw%de%d.", pp->name, acr, acw, ace); - - dcr = pp->acr + acr; dcw = pp->acw + acw; - dce = pp->ace + ace; g_topology_unlock(); sx_xlock(&sc->sc_lock); Modified: head/sys/geom/raid/md_intel.c ============================================================================== --- head/sys/geom/raid/md_intel.c Thu Mar 31 16:14:35 2011 (r220209) +++ head/sys/geom/raid/md_intel.c Thu Mar 31 16:19:53 2011 (r220210) @@ -1153,7 +1153,6 @@ g_raid_md_taste_intel(struct g_raid_md_o /* Read metadata from device. */ meta = NULL; - spare = 0; vendor = 0xffff; disk_pos = 0; if (g_access(cp, 1, 0, 0) != 0) @@ -1431,7 +1430,7 @@ g_raid_md_ctl_intel(struct g_raid_md_obj gctl_error(req, "Can't open disk '%s'.", diskname); g_topology_unlock(); - error = -4; + error = -7; break; } pp = cp->provider; @@ -1481,6 +1480,11 @@ g_raid_md_ctl_intel(struct g_raid_md_obj if (error != 0) return (error); + if (sectorsize <= 0) { + gctl_error(req, "Can't get sector size."); + return (-8); + } + /* Reserve some space for metadata. */ size -= ((4096 + sectorsize - 1) / sectorsize) * sectorsize; @@ -1953,7 +1957,6 @@ g_raid_md_ctl_intel(struct g_raid_md_obj disk = g_raid_create_disk(sc); disk->d_consumer = cp; - disk->d_consumer->private = disk; disk->d_md_data = (void *)pd; cp->private = disk; Modified: head/sys/geom/raid/md_jmicron.c ============================================================================== --- head/sys/geom/raid/md_jmicron.c Thu Mar 31 16:14:35 2011 (r220209) +++ head/sys/geom/raid/md_jmicron.c Thu Mar 31 16:19:53 2011 (r220210) @@ -579,14 +579,12 @@ g_raid_md_jmicron_refill(struct g_raid_s { struct g_raid_md_object *md; struct g_raid_md_jmicron_object *mdi; - struct jmicron_raid_conf *meta; struct g_raid_disk *disk; struct task *task; int update, na; md = sc->sc_md; mdi = (struct g_raid_md_jmicron_object *)md; - meta = mdi->mdio_meta; update = 0; do { /* Make sure we miss anything. */ @@ -620,10 +618,8 @@ g_raid_md_jmicron_refill(struct g_raid_s } while (disk != NULL); /* Write new metadata if we changed something. */ - if (update) { + if (update) g_raid_md_write_jmicron(md, NULL, NULL, NULL); - meta = mdi->mdio_meta; - } /* Update status of our need for spare. */ mdi->mdio_incomplete = (g_raid_ndisks(sc, G_RAID_DISK_S_ACTIVE) < @@ -835,9 +831,7 @@ g_raid_md_taste_jmicron(struct g_raid_md /* Read metadata from device. */ meta = NULL; - spare = 0; vendor = 0xffff; - disk_pos = 0; if (g_access(cp, 1, 0, 0) != 0) return (G_RAID_MD_TASTE_FAIL); g_topology_unlock(); @@ -1133,6 +1127,11 @@ g_raid_md_ctl_jmicron(struct g_raid_md_o if (error != 0) return (error); + if (sectorsize <= 0) { + gctl_error(req, "Can't get sector size."); + return (-8); + } + /* Reserve space for metadata. */ size -= sectorsize; @@ -1364,7 +1363,6 @@ g_raid_md_ctl_jmicron(struct g_raid_md_o disk = g_raid_create_disk(sc); disk->d_consumer = cp; - disk->d_consumer->private = disk; disk->d_md_data = (void *)pd; cp->private = disk; g_topology_unlock(); @@ -1470,7 +1468,6 @@ g_raid_md_write_jmicron(struct g_raid_md if (mdi->mdio_meta != NULL) free(mdi->mdio_meta, M_MD_JMICRON); mdi->mdio_meta = meta; - i = 0; TAILQ_FOREACH(disk, &sc->sc_disks, d_next) { pd = (struct g_raid_md_jmicron_perdisk *)disk->d_md_data; if (disk->d_state != G_RAID_DISK_S_ACTIVE && @@ -1507,12 +1504,10 @@ g_raid_md_fail_disk_jmicron(struct g_rai struct g_raid_subdisk *tsd, struct g_raid_disk *tdisk) { struct g_raid_softc *sc; - struct g_raid_md_jmicron_object *mdi; struct g_raid_md_jmicron_perdisk *pd; struct g_raid_subdisk *sd; sc = md->mdo_softc; - mdi = (struct g_raid_md_jmicron_object *)md; pd = (struct g_raid_md_jmicron_perdisk *)tdisk->d_md_data; /* We can't fail disk that is not a part of array now. */ Modified: head/sys/geom/raid/md_nvidia.c ============================================================================== --- head/sys/geom/raid/md_nvidia.c Thu Mar 31 16:14:35 2011 (r220209) +++ head/sys/geom/raid/md_nvidia.c Thu Mar 31 16:19:53 2011 (r220210) @@ -584,14 +584,12 @@ g_raid_md_nvidia_refill(struct g_raid_so { struct g_raid_md_object *md; struct g_raid_md_nvidia_object *mdi; - struct nvidia_raid_conf *meta; struct g_raid_disk *disk; struct task *task; int update, na; md = sc->sc_md; mdi = (struct g_raid_md_nvidia_object *)md; - meta = mdi->mdio_meta; update = 0; do { /* Make sure we miss anything. */ @@ -625,10 +623,8 @@ g_raid_md_nvidia_refill(struct g_raid_so } while (disk != NULL); /* Write new metadata if we changed something. */ - if (update) { + if (update) g_raid_md_write_nvidia(md, NULL, NULL, NULL); - meta = mdi->mdio_meta; - } /* Update status of our need for spare. */ mdi->mdio_incomplete = (g_raid_ndisks(sc, G_RAID_DISK_S_ACTIVE) < @@ -828,7 +824,7 @@ g_raid_md_taste_nvidia(struct g_raid_md_ struct nvidia_raid_conf *meta; struct g_raid_md_nvidia_perdisk *pd; struct g_geom *geom; - int error, disk_pos, result, spare, len; + int error, result, spare, len; char name[32]; uint16_t vendor; @@ -838,9 +834,7 @@ g_raid_md_taste_nvidia(struct g_raid_md_ /* Read metadata from device. */ meta = NULL; - spare = 0; vendor = 0xffff; - disk_pos = 0; if (g_access(cp, 1, 0, 0) != 0) return (G_RAID_MD_TASTE_FAIL); g_topology_unlock(); @@ -866,16 +860,9 @@ g_raid_md_taste_nvidia(struct g_raid_md_ return (G_RAID_MD_TASTE_FAIL); } - /* Check this disk position in obtained metadata. */ - disk_pos = meta->disk_number; - if (disk_pos == -1) { - G_RAID_DEBUG(1, "NVIDIA disk position not found"); - goto fail1; - } - /* Metadata valid. Print it. */ g_raid_md_nvidia_print(meta); - G_RAID_DEBUG(1, "NVIDIA disk position %d", disk_pos); + G_RAID_DEBUG(1, "NVIDIA disk position %d", meta->disk_number); spare = 0;//(meta->type == NVIDIA_T_SPARE) ? 1 : 0; search: @@ -1141,6 +1128,11 @@ g_raid_md_ctl_nvidia(struct g_raid_md_ob if (error != 0) return (error); + if (sectorsize <= 0) { + gctl_error(req, "Can't get sector size."); + return (-8); + } + /* Reserve space for metadata. */ size -= 2 * sectorsize; @@ -1371,7 +1363,6 @@ g_raid_md_ctl_nvidia(struct g_raid_md_ob disk = g_raid_create_disk(sc); disk->d_consumer = cp; - disk->d_consumer->private = disk; disk->d_md_data = (void *)pd; cp->private = disk; g_topology_unlock(); @@ -1528,12 +1519,10 @@ g_raid_md_fail_disk_nvidia(struct g_raid struct g_raid_subdisk *tsd, struct g_raid_disk *tdisk) { struct g_raid_softc *sc; - struct g_raid_md_nvidia_object *mdi; struct g_raid_md_nvidia_perdisk *pd; struct g_raid_subdisk *sd; sc = md->mdo_softc; - mdi = (struct g_raid_md_nvidia_object *)md; pd = (struct g_raid_md_nvidia_perdisk *)tdisk->d_md_data; /* We can't fail disk that is not a part of array now. */ Modified: head/sys/geom/raid/md_promise.c ============================================================================== --- head/sys/geom/raid/md_promise.c Thu Mar 31 16:14:35 2011 (r220209) +++ head/sys/geom/raid/md_promise.c Thu Mar 31 16:19:53 2011 (r220210) @@ -1154,12 +1154,10 @@ g_raid_md_event_promise(struct g_raid_md struct g_raid_disk *disk, u_int event) { struct g_raid_softc *sc; - struct g_raid_md_promise_perdisk *pd; sc = md->mdo_softc; if (disk == NULL) return (-1); - pd = (struct g_raid_md_promise_perdisk *)disk->d_md_data; switch (event) { case G_RAID_DISK_E_DISCONNECTED: /* Delete disk. */ @@ -1184,10 +1182,8 @@ static int g_raid_md_volume_event_promise(struct g_raid_md_object *md, struct g_raid_volume *vol, u_int event) { - struct g_raid_softc *sc; struct g_raid_md_promise_pervolume *pv; - sc = md->mdo_softc; pv = (struct g_raid_md_promise_pervolume *)vol->v_md_data; switch (event) { case G_RAID_VOLUME_E_STARTMD: @@ -1345,6 +1341,11 @@ g_raid_md_ctl_promise(struct g_raid_md_o return (error); } + if (sectorsize <= 0) { + gctl_error(req, "Can't get sector size."); + return (-8); + } + /* Handle size argument. */ len = sizeof(*sizearg); sizearg = gctl_get_param(req, "size", &len); @@ -1567,8 +1568,6 @@ g_raid_md_ctl_promise(struct g_raid_md_o continue; } - pd = (struct g_raid_md_promise_perdisk *)disk->d_md_data; - /* Erase metadata on deleting disk and destroy it. */ promise_meta_erase(disk->d_consumer); g_raid_destroy_disk(disk); @@ -1610,14 +1609,12 @@ g_raid_md_ctl_promise(struct g_raid_md_o error = -4; break; } - pp = cp->provider; g_topology_unlock(); pd = malloc(sizeof(*pd), M_MD_PROMISE, M_WAITOK | M_ZERO); disk = g_raid_create_disk(sc); disk->d_consumer = cp; - disk->d_consumer->private = disk; disk->d_md_data = (void *)pd; cp->private = disk; Modified: head/sys/geom/raid/md_sii.c ============================================================================== --- head/sys/geom/raid/md_sii.c Thu Mar 31 16:14:35 2011 (r220209) +++ head/sys/geom/raid/md_sii.c Thu Mar 31 16:19:53 2011 (r220210) @@ -641,14 +641,12 @@ g_raid_md_sii_refill(struct g_raid_softc { struct g_raid_md_object *md; struct g_raid_md_sii_object *mdi; - struct sii_raid_conf *meta; struct g_raid_disk *disk; struct task *task; int update, na; md = sc->sc_md; mdi = (struct g_raid_md_sii_object *)md; - meta = mdi->mdio_meta; update = 0; do { /* Make sure we miss anything. */ @@ -682,10 +680,8 @@ g_raid_md_sii_refill(struct g_raid_softc } while (disk != NULL); /* Write new metadata if we changed something. */ - if (update) { + if (update) g_raid_md_write_sii(md, NULL, NULL, NULL); - meta = mdi->mdio_meta; - } /* Update status of our need for spare. */ mdi->mdio_incomplete = (g_raid_ndisks(sc, G_RAID_DISK_S_ACTIVE) < @@ -921,9 +917,7 @@ g_raid_md_taste_sii(struct g_raid_md_obj /* Read metadata from device. */ meta = NULL; - spare = 0; vendor = 0xffff; - disk_pos = 0; if (g_access(cp, 1, 0, 0) != 0) return (G_RAID_MD_TASTE_FAIL); g_topology_unlock(); @@ -1219,6 +1213,11 @@ g_raid_md_ctl_sii(struct g_raid_md_objec if (error != 0) return (error); + if (sectorsize <= 0) { + gctl_error(req, "Can't get sector size."); + return (-8); + } + /* Reserve space for metadata. */ size -= 0x800 * sectorsize; @@ -1449,7 +1448,6 @@ g_raid_md_ctl_sii(struct g_raid_md_objec disk = g_raid_create_disk(sc); disk->d_consumer = cp; - disk->d_consumer->private = disk; disk->d_md_data = (void *)pd; cp->private = disk; g_topology_unlock(); @@ -1559,7 +1557,6 @@ g_raid_md_write_sii(struct g_raid_md_obj if (mdi->mdio_meta != NULL) free(mdi->mdio_meta, M_MD_SII); mdi->mdio_meta = meta; - i = 0; TAILQ_FOREACH(disk, &sc->sc_disks, d_next) { pd = (struct g_raid_md_sii_perdisk *)disk->d_md_data; if (disk->d_state != G_RAID_DISK_S_ACTIVE) @@ -1605,12 +1602,10 @@ g_raid_md_fail_disk_sii(struct g_raid_md struct g_raid_subdisk *tsd, struct g_raid_disk *tdisk) { struct g_raid_softc *sc; - struct g_raid_md_sii_object *mdi; struct g_raid_md_sii_perdisk *pd; struct g_raid_subdisk *sd; sc = md->mdo_softc; - mdi = (struct g_raid_md_sii_object *)md; pd = (struct g_raid_md_sii_perdisk *)tdisk->d_md_data; /* We can't fail disk that is not a part of array now. */ Modified: head/sys/geom/raid/tr_raid1.c ============================================================================== --- head/sys/geom/raid/tr_raid1.c Thu Mar 31 16:14:35 2011 (r220209) +++ head/sys/geom/raid/tr_raid1.c Thu Mar 31 16:19:53 2011 (r220210) @@ -549,7 +549,6 @@ g_raid_tr_iostart_raid1_read(struct g_ra static void g_raid_tr_iostart_raid1_write(struct g_raid_tr_object *tr, struct bio *bp) { - struct g_raid_softc *sc; struct g_raid_volume *vol; struct g_raid_subdisk *sd; struct bio_queue_head queue; @@ -557,7 +556,6 @@ g_raid_tr_iostart_raid1_write(struct g_r int i; vol = tr->tro_volume; - sc = vol->v_softc; /* * Allocate all bios before sending any request, so we can return Modified: head/sys/geom/raid/tr_raid1e.c ============================================================================== --- head/sys/geom/raid/tr_raid1e.c Thu Mar 31 16:14:35 2011 (r220209) +++ head/sys/geom/raid/tr_raid1e.c Thu Mar 31 16:19:53 2011 (r220210) @@ -196,13 +196,11 @@ g_raid_tr_taste_raid1e(struct g_raid_tr_ static int g_raid_tr_update_state_raid1e_even(struct g_raid_volume *vol) { - struct g_raid_tr_raid1e_object *trs; struct g_raid_softc *sc; struct g_raid_subdisk *sd, *bestsd, *worstsd; int i, j, state, sstate; sc = vol->v_softc; - trs = (struct g_raid_tr_raid1e_object *)vol->v_tr; state = G_RAID_VOLUME_S_OPTIMAL; for (i = 0; i < vol->v_disks_count / N; i++) { bestsd = &vol->v_subdisks[i * N]; @@ -251,13 +249,11 @@ g_raid_tr_update_state_raid1e_even(struc static int g_raid_tr_update_state_raid1e_odd(struct g_raid_volume *vol) { - struct g_raid_tr_raid1e_object *trs; struct g_raid_softc *sc; struct g_raid_subdisk *sd, *bestsd, *worstsd; int i, j, state, sstate; sc = vol->v_softc; - trs = (struct g_raid_tr_raid1e_object *)vol->v_tr; if (g_raid_nsubdisks(vol, G_RAID_SUBDISK_S_ACTIVE) == vol->v_disks_count) return (G_RAID_VOLUME_S_OPTIMAL); From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 16:30: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 27C731065670; Thu, 31 Mar 2011 16:30:15 +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 180638FC0C; Thu, 31 Mar 2011 16:30:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VGUEos012293; Thu, 31 Mar 2011 16:30:14 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VGUEGn012291; Thu, 31 Mar 2011 16:30:14 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201103311630.p2VGUEGn012291@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Thu, 31 Mar 2011 16:30: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: r220211 - head/sys/netinet/ipfw 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, 31 Mar 2011 16:30:15 -0000 Author: ae Date: Thu Mar 31 16:30:14 2011 New Revision: 220211 URL: http://svn.freebsd.org/changeset/base/220211 Log: Fill up src_port and dst_port variables for SCTP over IPv4. PR: kern/153415 MFC after: 1 week Modified: head/sys/netinet/ipfw/ip_fw2.c Modified: head/sys/netinet/ipfw/ip_fw2.c ============================================================================== --- head/sys/netinet/ipfw/ip_fw2.c Thu Mar 31 16:19:53 2011 (r220210) +++ head/sys/netinet/ipfw/ip_fw2.c Thu Mar 31 16:30:14 2011 (r220211) @@ -1123,6 +1123,12 @@ do { \ args->f_id._flags = TCP(ulp)->th_flags; break; + case IPPROTO_SCTP: + PULLUP_TO(hlen, ulp, struct sctphdr); + src_port = SCTP(ulp)->src_port; + dst_port = SCTP(ulp)->dest_port; + break; + case IPPROTO_UDP: PULLUP_TO(hlen, ulp, struct udphdr); dst_port = UDP(ulp)->uh_dport; From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 18:12: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 E34181065670; Thu, 31 Mar 2011 18:12:04 +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 D293A8FC0C; Thu, 31 Mar 2011 18:12:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VIC40J014445; Thu, 31 Mar 2011 18:12:04 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VIC4V5014443; Thu, 31 Mar 2011 18:12:04 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103311812.p2VIC4V5014443@svn.freebsd.org> From: Edward Tomasz Napierala Date: Thu, 31 Mar 2011 18:12: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: r220212 - 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: Thu, 31 Mar 2011 18:12:05 -0000 Author: trasz Date: Thu Mar 31 18:12:04 2011 New Revision: 220212 URL: http://svn.freebsd.org/changeset/base/220212 Log: Notify racct when process credentials change. Sponsored by: The FreeBSD Foundation Reviewed by: kib (earlier version) Modified: head/sys/kern/kern_prot.c Modified: head/sys/kern/kern_prot.c ============================================================================== --- head/sys/kern/kern_prot.c Thu Mar 31 16:30:14 2011 (r220211) +++ head/sys/kern/kern_prot.c Thu Mar 31 18:12:04 2011 (r220212) @@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -584,6 +585,9 @@ setuid(struct thread *td, struct setuid_ } p->p_ucred = newcred; PROC_UNLOCK(p); +#ifdef RACCT + racct_proc_ucred_changed(p, oldcred, newcred); +#endif uifree(uip); crfree(oldcred); return (0); @@ -922,6 +926,9 @@ setreuid(register struct thread *td, str } p->p_ucred = newcred; PROC_UNLOCK(p); +#ifdef RACCT + racct_proc_ucred_changed(p, oldcred, newcred); +#endif uifree(ruip); uifree(euip); crfree(oldcred); @@ -1060,6 +1067,9 @@ setresuid(register struct thread *td, st } p->p_ucred = newcred; PROC_UNLOCK(p); +#ifdef RACCT + racct_proc_ucred_changed(p, oldcred, newcred); +#endif uifree(ruip); uifree(euip); crfree(oldcred); From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 18: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 E8DFD10656DE; Thu, 31 Mar 2011 18:18:33 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id BC8C08FC27; Thu, 31 Mar 2011 18:18:33 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 34BFA46B1A; Thu, 31 Mar 2011 14:18:33 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 94B358A027; Thu, 31 Mar 2011 14:18:32 -0400 (EDT) From: John Baldwin To: Randall Stewart Date: Thu, 31 Mar 2011 14:17:27 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <201101191907.p0JJ7GMp086060@svn.freebsd.org> <201103291401.03565.jhb@freebsd.org> <2BE17525-83AA-4255-B191-3429B5FF6F5E@lakerest.net> In-Reply-To: <2BE17525-83AA-4255-B191-3429B5FF6F5E@lakerest.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201103311417.27360.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Thu, 31 Mar 2011 14:18:32 -0400 (EDT) Cc: svn-src-head@freebsd.org, Daniel Eischen , svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r217592 - 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, 31 Mar 2011 18:18:34 -0000 On Thursday, March 31, 2011 11:40:08 am Randall Stewart wrote: > John: > > So I caught up with Dave Thaler here at the IETF... > > He said that NO UDP socket that has NOT joined a multicast > group should ever receive a packet sent to a multicast address. > He also said this was part of the POSIX API and the way > all Unix machines worked. > > So.. no it is a bug and the fix is correct. That works for me. Can you please merge this fix to 7 and 8? > R > On Mar 29, 2011, at 2:01 PM, John Baldwin wrote: > > > On Wednesday, January 19, 2011 2:07:16 pm Randall Stewart wrote: > >> Author: rrs > >> Date: Wed Jan 19 19:07:16 2011 > >> New Revision: 217592 > >> URL: http://svn.freebsd.org/changeset/base/217592 > >> > >> Log: > >> Fix a bug where Multicast packets sent from a > >> udp endpoint may end up echoing back to the sender > >> even with OUT joining the multi-cast group. > >> > >> Reviewed by: gnn, bms, bz? > >> Obtained from: deischen (with help from) > >> > >> Modified: > >> head/sys/netinet/udp_usrreq.c > >> > >> Modified: head/sys/netinet/udp_usrreq.c > >> > > ============================================================================== > >> --- head/sys/netinet/udp_usrreq.c Wed Jan 19 18:20:11 2011 (r217591) > >> +++ head/sys/netinet/udp_usrreq.c Wed Jan 19 19:07:16 2011 (r217592) > >> @@ -479,11 +479,13 @@ udp_input(struct mbuf *m, int off) > >> * and source-specific multicast. [RFC3678] > >> */ > >> imo = inp->inp_moptions; > >> - if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && > >> - imo != NULL) { > >> + if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { > >> struct sockaddr_in group; > >> int blocked; > >> - > >> + if(imo == NULL) { > >> + INP_RUNLOCK(inp); > >> + continue; > >> + } > >> bzero(&group, sizeof(struct sockaddr_in)); > >> group.sin_len = sizeof(struct sockaddr_in); > >> group.sin_family = AF_INET; > > > > So it turns out that this is a feature, not a bug, and is how multicast has > > always worked. Specifically, if you bind a UDP socket with a wildcard > > address, it should receive all traffic for the bound port, unicast or > > multicast. When you join a group, you have switched the socket into a mode > > where it now has a whitelist of acceptable multicast groups, but if a socket > > has no joined groups, it should receive all multicast traffic, not none. This > > change breaks that. > > > > I did not find this behavior intuitive at first, but it does seem to be > > required. Note the description of IP_ADD_MEMBERSHIP from RFC 3678 for > > example: > > > > 3. Overview of APIs > > > > There are a number of different APIs described in this document that > > are appropriate for a number of different application types and IP > > versions. Before providing detailed descriptions, this section > > provides a "taxonomy" with a brief description of each. > > > > There are two categories of source-filter APIs, both of which are > > designed to allow multicast receiver applications to designate the > > unicast address(es) of sender(s) along with the multicast group > > (destination address) to receive. > > > > o Basic (Delta-based): Some applications desire the simplicity of > > a delta-based API in which each function call specifies a > > single source address which should be added to or removed from > > the existing filter for a given multicast group address on > > which to listen. Such applications typically fall into either > > of two categories: > > > > + Any-Source Multicast: By default, all sources are accepted. > > Individual sources may be turned off and back on as needed > > over time. This is also known as "exclude" mode, since the > > source filter contains a list of excluded sources. > > > > + Source-Specific Multicast: Only sources in a given list are > > allowed. The list may change over time. This is also known > > as "include" mode, since the source filter contains a list > > of included sources. > > > > This API would be used, for example, by "single-source" > > applications such as audio/video broadcasting. It would > > also be used for logical multi-source sessions where each > > source independently allocates its own Source-Specific > > Multicast group address. > > > > > > ..... > > > > 4.1.1. IPv4 Any-Source Multicast API > > > > The following socket options are defined in for > > applications in the Any-Source Multicast category: > > > > Socket option Argument type > > IP_ADD_MEMBERSHIP struct ip_mreq > > IP_BLOCK_SOURCE struct ip_mreq_source > > IP_UNBLOCK_SOURCE struct ip_mreq_source > > IP_DROP_MEMBERSHIP struct ip_mreq > > > > IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP are already implemented on > > most operating systems, and are used to join and leave an any-source > > group. > > > > IP_BLOCK_SOURCE can be used to block data from a given source to a > > given group (e.g., if the user "mutes" that source), and > > IP_UNBLOCK_SOURCE can be used to undo this (e.g., if the user then > > "unmutes" the source). > > > > As to why the packets loop back to the receiver, I believe that is a separate > > issue on the output side, not the receive side. > > > > -- > > John Baldwin > > > > ------------------------------ > Randall Stewart > 803-317-4952 (cell) > > -- John Baldwin From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 19:22: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 C8EC1106566C; Thu, 31 Mar 2011 19:22:11 +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 B59818FC15; Thu, 31 Mar 2011 19:22:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VJMBBd016500; Thu, 31 Mar 2011 19:22:11 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VJMBVM016495; Thu, 31 Mar 2011 19:22:11 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201103311922.p2VJMBVM016495@svn.freebsd.org> From: Edward Tomasz Napierala Date: Thu, 31 Mar 2011 19:22:11 +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: r220222 - 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: Thu, 31 Mar 2011 19:22:11 -0000 Author: trasz Date: Thu Mar 31 19:22:11 2011 New Revision: 220222 URL: http://svn.freebsd.org/changeset/base/220222 Log: Enable accounting for RACCT_NPROC and RACCT_NTHR. Sponsored by: The FreeBSD Foundation Reviewed by: kib (earlier version) Modified: head/sys/kern/init_main.c head/sys/kern/kern_exit.c head/sys/kern/kern_fork.c head/sys/kern/kern_thr.c Modified: head/sys/kern/init_main.c ============================================================================== --- head/sys/kern/init_main.c Thu Mar 31 18:35:44 2011 (r220221) +++ head/sys/kern/init_main.c Thu Mar 31 19:22:11 2011 (r220222) @@ -557,6 +557,9 @@ proc0_init(void *dummy __unused) * Charge root for one process. */ (void)chgproccnt(p->p_ucred->cr_ruidinfo, 1, 0); + PROC_LOCK(p); + racct_add_force(p, RACCT_NPROC, 1); + PROC_UNLOCK(p); } SYSINIT(p0init, SI_SUB_INTRINSIC, SI_ORDER_FIRST, proc0_init, NULL); Modified: head/sys/kern/kern_exit.c ============================================================================== --- head/sys/kern/kern_exit.c Thu Mar 31 18:35:44 2011 (r220221) +++ head/sys/kern/kern_exit.c Thu Mar 31 19:22:11 2011 (r220222) @@ -177,6 +177,7 @@ exit1(struct thread *td, int rv) } KASSERT(p->p_numthreads == 1, ("exit1: proc %p exiting with %d threads", p, p->p_numthreads)); + racct_sub(p, RACCT_NTHR, 1); /* * Wakeup anyone in procfs' PIOCWAIT. They should have a hold * on our vmspace, so we should block below until they have @@ -745,6 +746,9 @@ proc_reap(struct thread *td, struct proc * Destroy resource accounting information associated with the process. */ racct_proc_exit(p); + PROC_LOCK(p->p_pptr); + racct_sub(p->p_pptr, RACCT_NPROC, 1); + PROC_UNLOCK(p->p_pptr); /* * Free credentials, arguments, and sigacts. @@ -905,7 +909,11 @@ proc_reparent(struct proc *child, struct if (child->p_pptr == parent) return; + PROC_LOCK(parent); + racct_add_force(parent, RACCT_NPROC, 1); + PROC_UNLOCK(parent); PROC_LOCK(child->p_pptr); + racct_sub(child->p_pptr, RACCT_NPROC, 1); sigqueue_take(child->p_ksi); PROC_UNLOCK(child->p_pptr); LIST_REMOVE(child, p_sibling); Modified: head/sys/kern/kern_fork.c ============================================================================== --- head/sys/kern/kern_fork.c Thu Mar 31 18:35:44 2011 (r220221) +++ head/sys/kern/kern_fork.c Thu Mar 31 19:22:11 2011 (r220222) @@ -734,6 +734,12 @@ fork1(struct thread *td, int flags, int return (fork_norfproc(td, flags)); } + PROC_LOCK(p1); + error = racct_add(p1, RACCT_NPROC, 1); + PROC_UNLOCK(p1); + if (error != 0) + return (EAGAIN); + mem_charged = 0; vm2 = NULL; if (pages == 0) @@ -817,6 +823,17 @@ fork1(struct thread *td, int flags, int } /* + * After fork, there is exactly one thread running. + */ + PROC_LOCK(newproc); + error = racct_set(newproc, RACCT_NTHR, 1); + PROC_UNLOCK(newproc); + if (error != 0) { + error = EAGAIN; + goto fail; + } + + /* * Increment the count of procs running with this uid. Don't allow * a nonprivileged user to exceed their current limit. * @@ -857,6 +874,9 @@ fail1: vmspace_free(vm2); uma_zfree(proc_zone, newproc); pause("fork", hz / 2); + PROC_LOCK(p1); + racct_sub(p1, RACCT_NPROC, 1); + PROC_UNLOCK(p1); return (error); } Modified: head/sys/kern/kern_thr.c ============================================================================== --- head/sys/kern/kern_thr.c Thu Mar 31 18:35:44 2011 (r220221) +++ head/sys/kern/kern_thr.c Thu Mar 31 19:22:11 2011 (r220222) @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -184,10 +185,18 @@ create_thread(struct thread *td, mcontex } } + PROC_LOCK(td->td_proc); + error = racct_add(p, RACCT_NTHR, 1); + PROC_UNLOCK(td->td_proc); + if (error != 0) + return (EPROCLIM); + /* Initialize our td */ newtd = thread_alloc(0); - if (newtd == NULL) - return (ENOMEM); + if (newtd == NULL) { + error = ENOMEM; + goto fail; + } /* * Try the copyout as soon as we allocate the td so we don't @@ -203,7 +212,8 @@ create_thread(struct thread *td, mcontex (parent_tid != NULL && suword_lwpid(parent_tid, newtd->td_tid))) { thread_free(newtd); - return (EFAULT); + error = EFAULT; + goto fail; } bzero(&newtd->td_startzero, @@ -220,7 +230,7 @@ create_thread(struct thread *td, mcontex if (error != 0) { thread_free(newtd); crfree(td->td_ucred); - return (error); + goto fail; } } else { /* Set up our machine context. */ @@ -233,7 +243,7 @@ create_thread(struct thread *td, mcontex if (error != 0) { thread_free(newtd); crfree(td->td_ucred); - return (error); + goto fail; } } @@ -265,6 +275,12 @@ create_thread(struct thread *td, mcontex thread_unlock(newtd); return (0); + +fail: + PROC_LOCK(p); + racct_sub(p, RACCT_NTHR, 1); + PROC_UNLOCK(p); + return (error); } int @@ -294,7 +310,10 @@ thr_exit(struct thread *td, struct thr_e } rw_wlock(&tidhash_lock); + PROC_LOCK(p); + racct_sub(p, RACCT_NTHR, 1); + /* * Shutting down last thread in the proc. This will actually * call exit() in the trampoline when it returns. From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 19:34: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 02BA11065670; Thu, 31 Mar 2011 19:34:38 +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 AD2B18FC18; Thu, 31 Mar 2011 19:34:37 +0000 (UTC) Received: from [10.30.101.54] ([209.117.142.2]) (authenticated bits=0) by harmony.bsdimp.com (8.14.4/8.14.3) with ESMTP id p2VJTHQp010763 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Thu, 31 Mar 2011 13:29:19 -0600 (MDT) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <201103310740.20265.jhb@freebsd.org> Date: Thu, 31 Mar 2011 13:29:11 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <73CB36BD-1C9E-4992-A3C7-B540ABB7F11E@bsdimp.com> References: <201103310807.p2V87DHV096049@svn.freebsd.org> <201103310740.20265.jhb@freebsd.org> To: John Baldwin X-Mailer: Apple Mail (2.1082) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (harmony.bsdimp.com [10.0.0.6]); Thu, 31 Mar 2011 13:29:19 -0600 (MDT) Cc: svn-src-head@FreeBSD.org, Adrian Chadd , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org Subject: Re: svn commit: r220185 - in head/sys: amd64/conf arm/conf conf dev/ath i386/conf mips/conf modules modules/ath modules/ath_ahb modules/ath_pci pc98/conf sparc64/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: Thu, 31 Mar 2011 19:34:38 -0000 On Mar 31, 2011, at 5:40 AM, John Baldwin wrote: > On Thursday, March 31, 2011 4:07:13 am Adrian Chadd wrote: >> Author: adrian >> Date: Thu Mar 31 08:07:13 2011 >> New Revision: 220185 >> URL: http://svn.freebsd.org/changeset/base/220185 >>=20 >> Log: >> Break out the ath PCI logic into a separate device/module. >>=20 >> Introduce the AHB glue for Atheros embedded systems. Right now it's >> hard-coded for the AR9130 chip whose support isn't yet in this HAL; >> it'll be added in a subsequent commit. >>=20 >> Kernel configuration files now need both 'ath' and 'ath_pci' = devices; both >> modules need to be loaded for the ath device to work. >=20 > Err, there's no need to break the kernel config. Just have the kernel = DTRT if=20 > both ath and pci are enabled using something like: >=20 > sys/dev/ath/if_ath_pci.c ath pci >=20 > in sys/conf/files. >=20 > You can still have an if_ath_pci.ko module with this arrangement. = This is=20 > what almost all other drivers due that have multiple bus backends. Well, most drivers with multiple back ends compile all the relevant ones = for the platform in. There's very few that call out individual ones = (ata and its kin being the big exception). Personally, I'd not bother having a if_ath_pci.ko, and instead bundle it = in with if_ath.ko and omitting if_ath_ahb.c from the x86 builds, but I = understand why this might be important in the embedded builds. Warner= From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 19:58: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 4B87F1065674; Thu, 31 Mar 2011 19:58:52 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 1BA148FC1D; Thu, 31 Mar 2011 19:58:52 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id AFE3346B09; Thu, 31 Mar 2011 15:58:51 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 3F6928A01B; Thu, 31 Mar 2011 15:58:51 -0400 (EDT) From: John Baldwin To: Warner Losh Date: Thu, 31 Mar 2011 15:58:50 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <201103310807.p2V87DHV096049@svn.freebsd.org> <201103310740.20265.jhb@freebsd.org> <73CB36BD-1C9E-4992-A3C7-B540ABB7F11E@bsdimp.com> In-Reply-To: <73CB36BD-1C9E-4992-A3C7-B540ABB7F11E@bsdimp.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201103311558.50709.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Thu, 31 Mar 2011 15:58:51 -0400 (EDT) Cc: svn-src-head@freebsd.org, Adrian Chadd , src-committers@freebsd.org, svn-src-all@freebsd.org Subject: Re: svn commit: r220185 - in head/sys: amd64/conf arm/conf conf dev/ath i386/conf mips/conf modules modules/ath modules/ath_ahb modules/ath_pci pc98/conf sparc64/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: Thu, 31 Mar 2011 19:58:52 -0000 On Thursday, March 31, 2011 3:29:11 pm Warner Losh wrote: > > On Mar 31, 2011, at 5:40 AM, John Baldwin wrote: > > > On Thursday, March 31, 2011 4:07:13 am Adrian Chadd wrote: > >> Author: adrian > >> Date: Thu Mar 31 08:07:13 2011 > >> New Revision: 220185 > >> URL: http://svn.freebsd.org/changeset/base/220185 > >> > >> Log: > >> Break out the ath PCI logic into a separate device/module. > >> > >> Introduce the AHB glue for Atheros embedded systems. Right now it's > >> hard-coded for the AR9130 chip whose support isn't yet in this HAL; > >> it'll be added in a subsequent commit. > >> > >> Kernel configuration files now need both 'ath' and 'ath_pci' devices; both > >> modules need to be loaded for the ath device to work. > > > > Err, there's no need to break the kernel config. Just have the kernel DTRT if > > both ath and pci are enabled using something like: > > > > sys/dev/ath/if_ath_pci.c ath pci > > > > in sys/conf/files. > > > > You can still have an if_ath_pci.ko module with this arrangement. This is > > what almost all other drivers due that have multiple bus backends. > > Well, most drivers with multiple back ends compile all the relevant ones for the platform in. There's very few that call out individual ones (ata and its kin being the big exception). Yes, that is true for modules, and I agree that the module build for if_ath.ko should just include all the relevant bus attachments for each platform. There's certainly no reason to not use the method above for sys/conf/files and remove 'device ath_pci', etc. -- John Baldwin From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 20:16: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 93F3B106564A; Thu, 31 Mar 2011 20:16:12 +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 2CC3C8FC13; Thu, 31 Mar 2011 20:16:12 +0000 (UTC) Received: from [10.30.101.54] ([209.117.142.2]) (authenticated bits=0) by harmony.bsdimp.com (8.14.4/8.14.3) with ESMTP id p2VKCxMe011231 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Thu, 31 Mar 2011 14:13:01 -0600 (MDT) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <201103311558.50709.jhb@freebsd.org> Date: Thu, 31 Mar 2011 14:12:54 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <4DEF8A5E-6ADE-4B27-8E1C-82188DB1244D@bsdimp.com> References: <201103310807.p2V87DHV096049@svn.freebsd.org> <201103310740.20265.jhb@freebsd.org> <73CB36BD-1C9E-4992-A3C7-B540ABB7F11E@bsdimp.com> <201103311558.50709.jhb@freebsd.org> To: John Baldwin X-Mailer: Apple Mail (2.1082) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (harmony.bsdimp.com [10.0.0.6]); Thu, 31 Mar 2011 14:13:02 -0600 (MDT) Cc: svn-src-head@FreeBSD.org, Adrian Chadd , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org Subject: Re: svn commit: r220185 - in head/sys: amd64/conf arm/conf conf dev/ath i386/conf mips/conf modules modules/ath modules/ath_ahb modules/ath_pci pc98/conf sparc64/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: Thu, 31 Mar 2011 20:16:12 -0000 On Mar 31, 2011, at 1:58 PM, John Baldwin wrote: > On Thursday, March 31, 2011 3:29:11 pm Warner Losh wrote: >>=20 >> On Mar 31, 2011, at 5:40 AM, John Baldwin wrote: >>=20 >>> On Thursday, March 31, 2011 4:07:13 am Adrian Chadd wrote: >>>> Author: adrian >>>> Date: Thu Mar 31 08:07:13 2011 >>>> New Revision: 220185 >>>> URL: http://svn.freebsd.org/changeset/base/220185 >>>>=20 >>>> Log: >>>> Break out the ath PCI logic into a separate device/module. >>>>=20 >>>> Introduce the AHB glue for Atheros embedded systems. Right now it's >>>> hard-coded for the AR9130 chip whose support isn't yet in this HAL; >>>> it'll be added in a subsequent commit. >>>>=20 >>>> Kernel configuration files now need both 'ath' and 'ath_pci' = devices; both >>>> modules need to be loaded for the ath device to work. >>>=20 >>> Err, there's no need to break the kernel config. Just have the = kernel DTRT if=20 >>> both ath and pci are enabled using something like: >>>=20 >>> sys/dev/ath/if_ath_pci.c ath pci >>>=20 >>> in sys/conf/files. >>>=20 >>> You can still have an if_ath_pci.ko module with this arrangement. = This is=20 >>> what almost all other drivers due that have multiple bus backends. >>=20 >> Well, most drivers with multiple back ends compile all the relevant = ones for the platform in. There's very few that call out individual = ones (ata=20 > and its kin being the big exception). >=20 > Yes, that is true for modules, and I agree that the module build for = if_ath.ko > should just include all the relevant bus attachments for each = platform. >=20 > There's certainly no reason to not use the method above for = sys/conf/files > and remove 'device ath_pci', etc. Agreed. Wasn't trying to disagree with you there. Warner= From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 20: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 310E81065674; Thu, 31 Mar 2011 20:46:51 +0000 (UTC) (envelope-from davidch@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1C6AA8FC15; Thu, 31 Mar 2011 20:46:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VKkpOU022043; Thu, 31 Mar 2011 20:46:51 GMT (envelope-from davidch@svn.freebsd.org) Received: (from davidch@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VKkoMJ022040; Thu, 31 Mar 2011 20:46:50 GMT (envelope-from davidch@svn.freebsd.org) Message-Id: <201103312046.p2VKkoMJ022040@svn.freebsd.org> From: David Christensen Date: Thu, 31 Mar 2011 20:46: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: r220223 - head/sys/dev/bxe 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, 31 Mar 2011 20:46:51 -0000 Author: davidch Date: Thu Mar 31 20:46:50 2011 New Revision: 220223 URL: http://svn.freebsd.org/changeset/base/220223 Log: - Fixed a problem where the stack passed a TSO frame larger than the 64K size allowed by the DMA descriptor for TSO frames. MFC after: One week Modified: head/sys/dev/bxe/if_bxe.c head/sys/dev/bxe/if_bxe.h Modified: head/sys/dev/bxe/if_bxe.c ============================================================================== --- head/sys/dev/bxe/if_bxe.c Thu Mar 31 19:22:11 2011 (r220222) +++ head/sys/dev/bxe/if_bxe.c Thu Mar 31 20:46:50 2011 (r220223) @@ -68,7 +68,7 @@ __FBSDID("$FreeBSD$"); /* BXE Debug Options */ #ifdef BXE_DEBUG - uint32_t bxe_debug = BXE_WARN; + uint32_t bxe_debug = BXE_INFO; /* 0 = Never */ /* 1 = 1 in 2,147,483,648 */ @@ -382,7 +382,7 @@ static void bxe_breakpoint(struct bxe_so #endif -#define BXE_DRIVER_VERSION "1.5.52_preliminary" +#define BXE_DRIVER_VERSION "1.5.52" static void bxe_init_e1_firmware(struct bxe_softc *sc); static void bxe_init_e1h_firmware(struct bxe_softc *sc); @@ -13042,10 +13042,20 @@ bxe_dma_alloc(device_t dev) * address of the block. */ - if (bus_dma_tag_create(sc->parent_tag, BCM_PAGE_SIZE, - BXE_DMA_BOUNDARY, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, - NULL, NULL, BXE_STATUS_BLK_SZ, 1, BXE_STATUS_BLK_SZ, - 0, NULL, NULL, &fp->status_block_tag)) { + if (bus_dma_tag_create(sc->parent_tag, + BCM_PAGE_SIZE, /* alignment for segs */ + BXE_DMA_BOUNDARY, /* cannot cross */ + BUS_SPACE_MAXADDR, /* restricted low */ + BUS_SPACE_MAXADDR, /* restricted hi */ + NULL, /* filter f() */ + NULL, /* filter f() arg */ + BXE_STATUS_BLK_SZ, /* max map for this tag */ + 1, /* # of discontinuities */ + BXE_STATUS_BLK_SZ, /* max seg size */ + 0, /* flags */ + NULL, /* lock f() */ + NULL, /* lock f() arg */ + &fp->status_block_tag)) { BXE_PRINTF("%s(%d): Could not allocate fp[%d] " "status block DMA tag!\n", __FILE__, __LINE__, i); rc = ENOMEM; @@ -13086,10 +13096,20 @@ bxe_dma_alloc(device_t dev) * allocate and clear the memory, and fetch the * physical address of the block. */ - if (bus_dma_tag_create(sc->parent_tag, BCM_PAGE_SIZE, - BXE_DMA_BOUNDARY, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, - NULL, NULL, BXE_TX_CHAIN_PAGE_SZ, 1, BXE_TX_CHAIN_PAGE_SZ, - 0, NULL, NULL, &fp->tx_bd_chain_tag)) { + if (bus_dma_tag_create(sc->parent_tag, + BCM_PAGE_SIZE, /* alignment for segs */ + BXE_DMA_BOUNDARY, /* cannot cross */ + BUS_SPACE_MAXADDR, /* restricted low */ + BUS_SPACE_MAXADDR, /* restricted hi */ + NULL, /* filter f() */ + NULL, /* filter f() arg */ + BXE_TX_CHAIN_PAGE_SZ,/* max map for this tag */ + 1, /* # of discontinuities */ + BXE_TX_CHAIN_PAGE_SZ,/* max seg size */ + 0, /* flags */ + NULL, /* lock f() */ + NULL, /* lock f() arg */ + &fp->tx_bd_chain_tag)) { BXE_PRINTF( "%s(%d): Could not allocate fp[%d] TX descriptor " "chain DMA tag!\n", __FILE__, __LINE__, i); @@ -13132,23 +13152,33 @@ bxe_dma_alloc(device_t dev) } /* - * Check the required size before mapping to conserve resources. + * Check required size before mapping to conserve resources. */ if (bxe_tso_enable) { - max_size = BXE_TSO_MAX_SIZE; - max_segments = 32; /* BXE_MAX_SEGMENTS; */ + max_size = BXE_TSO_MAX_SIZE; + max_segments = BXE_TSO_MAX_SEGMENTS; max_seg_size = BXE_TSO_MAX_SEG_SIZE; } else { - max_size = MCLBYTES * BXE_MAX_SEGMENTS; + max_size = MCLBYTES * BXE_MAX_SEGMENTS; max_segments = BXE_MAX_SEGMENTS; max_seg_size = MCLBYTES; } /* Create a DMA tag for TX mbufs. */ - if (bus_dma_tag_create(sc->parent_tag, 1, BXE_DMA_BOUNDARY, - BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, - max_size, max_segments, max_seg_size, - 0, NULL, NULL, &fp->tx_mbuf_tag)) { + if (bus_dma_tag_create(sc->parent_tag, + 1, /* alignment for segs */ + BXE_DMA_BOUNDARY, /* cannot cross */ + BUS_SPACE_MAXADDR, /* restricted low */ + BUS_SPACE_MAXADDR, /* restricted hi */ + NULL, /* filter f() */ + NULL, /* filter f() arg */ + max_size, /* max map for this tag */ + max_segments, /* # of discontinuities */ + max_seg_size, /* max seg size */ + 0, /* flags */ + NULL, /* lock f() */ + NULL, /* lock f() arg */ + &fp->tx_mbuf_tag)) { BXE_PRINTF( "%s(%d): Could not allocate fp[%d] TX mbuf DMA tag!\n", __FILE__, __LINE__, i); @@ -13174,12 +13204,22 @@ bxe_dma_alloc(device_t dev) * the memory, and fetch the physical * address of the blocks. */ - if (bus_dma_tag_create(sc->parent_tag, BCM_PAGE_SIZE, - BXE_DMA_BOUNDARY, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, - NULL, NULL, BXE_RX_CHAIN_PAGE_SZ, 1, BXE_RX_CHAIN_PAGE_SZ, - 0, NULL, NULL, &fp->rx_bd_chain_tag)) { - BXE_PRINTF( - "%s(%d): Could not allocate fp[%d] RX BD chain DMA tag!\n", + if (bus_dma_tag_create(sc->parent_tag, + BCM_PAGE_SIZE, /* alignment for segs */ + BXE_DMA_BOUNDARY, /* cannot cross */ + BUS_SPACE_MAXADDR, /* restricted low */ + BUS_SPACE_MAXADDR, /* restricted hi */ + NULL, /* filter f() */ + NULL, /* filter f() arg */ + BXE_RX_CHAIN_PAGE_SZ,/* max map for this tag */ + 1, /* # of discontinuities */ + BXE_RX_CHAIN_PAGE_SZ,/* max seg size */ + 0, /* flags */ + NULL, /* lock f() */ + NULL, /* lock f() arg */ + &fp->rx_bd_chain_tag)) { + BXE_PRINTF("%s(%d): Could not allocate fp[%d] " + "RX BD chain DMA tag!\n", __FILE__, __LINE__, i); rc = ENOMEM; goto bxe_dma_alloc_exit; @@ -13222,9 +13262,19 @@ bxe_dma_alloc(device_t dev) /* * Create a DMA tag for RX mbufs. */ - if (bus_dma_tag_create(sc->parent_tag, 1, BXE_DMA_BOUNDARY, - BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, - MJUM9BYTES, 1, MJUM9BYTES, 0, NULL, NULL, + if (bus_dma_tag_create(sc->parent_tag, + 1, /* alignment for segs */ + BXE_DMA_BOUNDARY, /* cannot cross */ + BUS_SPACE_MAXADDR, /* restricted low */ + BUS_SPACE_MAXADDR, /* restricted hi */ + NULL, /* filter f() */ + NULL, /* filter f() arg */ + MJUM9BYTES, /* max map for this tag */ + 1, /* # of discontinuities */ + MJUM9BYTES, /* max seg size */ + 0, /* flags */ + NULL, /* lock f() */ + NULL, /* lock f() arg */ &fp->rx_mbuf_tag)) { BXE_PRINTF( "%s(%d): Could not allocate fp[%d] RX mbuf DMA tag!\n", @@ -13251,10 +13301,20 @@ bxe_dma_alloc(device_t dev) * map the memory into DMA space, and fetch * the physical address of the block. */ - if (bus_dma_tag_create(sc->parent_tag, BCM_PAGE_SIZE, - BXE_DMA_BOUNDARY, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, - NULL, NULL, BXE_RX_CHAIN_PAGE_SZ, 1, BXE_RX_CHAIN_PAGE_SZ, - 0, NULL, NULL, &fp->rx_comp_chain_tag)) { + if (bus_dma_tag_create(sc->parent_tag, + BCM_PAGE_SIZE, /* alignment for segs */ + BXE_DMA_BOUNDARY, /* cannot cross */ + BUS_SPACE_MAXADDR, /* restricted low */ + BUS_SPACE_MAXADDR, /* restricted hi */ + NULL, /* filter f() */ + NULL, /* filter f() arg */ + BXE_RX_CHAIN_PAGE_SZ,/* max map for this tag */ + 1, /* # of discontinuities */ + BXE_RX_CHAIN_PAGE_SZ,/* max seg size */ + 0, /* flags */ + NULL, /* lock f() */ + NULL, /* lock f() arg */ + &fp->rx_comp_chain_tag)) { BXE_PRINTF( "%s(%d): Could not allocate fp[%d] RX Completion Queue DMA tag!\n", __FILE__, __LINE__, i); @@ -13311,10 +13371,19 @@ bxe_dma_alloc(device_t dev) * memory into DMA space, and fetch the * physical address of the block. */ - if (bus_dma_tag_create(sc->parent_tag, BCM_PAGE_SIZE, - BXE_DMA_BOUNDARY, BUS_SPACE_MAXADDR, - BUS_SPACE_MAXADDR, NULL, NULL, BXE_RX_CHAIN_PAGE_SZ, - 1, BXE_RX_CHAIN_PAGE_SZ, 0, NULL, NULL, + if (bus_dma_tag_create(sc->parent_tag, + BCM_PAGE_SIZE, /* alignment for segs */ + BXE_DMA_BOUNDARY, /* cannot cross */ + BUS_SPACE_MAXADDR, /* restricted low */ + BUS_SPACE_MAXADDR, /* restricted hi */ + NULL, /* filter f() */ + NULL, /* filter f() arg */ + BXE_RX_CHAIN_PAGE_SZ,/* max map for this tag */ + 1, /* # of discontinuities */ + BXE_RX_CHAIN_PAGE_SZ,/* max seg size */ + 0, /* flags */ + NULL, /* lock f() */ + NULL, /* lock f() arg */ &fp->rx_sge_chain_tag)) { BXE_PRINTF( "%s(%d): Could not allocate fp[%d] RX SGE descriptor chain DMA tag!\n", Modified: head/sys/dev/bxe/if_bxe.h ============================================================================== --- head/sys/dev/bxe/if_bxe.h Thu Mar 31 19:22:11 2011 (r220222) +++ head/sys/dev/bxe/if_bxe.h Thu Mar 31 20:46:50 2011 (r220223) @@ -388,8 +388,9 @@ struct bxe_type { /* Reduce from 13 to leave room for the parsing buffer. */ #define BXE_MAX_SEGMENTS 12 -#define BXE_TSO_MAX_SIZE 65536 -#define BXE_TSO_MAX_SEG_SIZE 4096 +#define BXE_TSO_MAX_SEGMENTS 32 +#define BXE_TSO_MAX_SIZE (65535 + sizeof(struct ether_vlan_header)) +#define BXE_TSO_MAX_SEG_SIZE 4096 /* * Hardware Support For IP and TCP checksum. From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 21:01: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 A6B1E10656DA; Thu, 31 Mar 2011 21:01:10 +0000 (UTC) (envelope-from davidch@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 92CC08FC2A; Thu, 31 Mar 2011 21:01:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VL1ADI022619; Thu, 31 Mar 2011 21:01:10 GMT (envelope-from davidch@svn.freebsd.org) Received: (from davidch@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VL1AJN022616; Thu, 31 Mar 2011 21:01:10 GMT (envelope-from davidch@svn.freebsd.org) Message-Id: <201103312101.p2VL1AJN022616@svn.freebsd.org> From: David Christensen Date: Thu, 31 Mar 2011 21:01: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: r220224 - head/sys/dev/bxe 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, 31 Mar 2011 21:01:10 -0000 Author: davidch Date: Thu Mar 31 21:01:10 2011 New Revision: 220224 URL: http://svn.freebsd.org/changeset/base/220224 Log: - Print number of queues when RSS is enabled. - Improve reporting of media type (not always 10GBase-CX4). MFC after: One week Modified: head/sys/dev/bxe/if_bxe.c head/sys/dev/bxe/if_bxe.h Modified: head/sys/dev/bxe/if_bxe.c ============================================================================== --- head/sys/dev/bxe/if_bxe.c Thu Mar 31 20:46:50 2011 (r220223) +++ head/sys/dev/bxe/if_bxe.c Thu Mar 31 21:01:10 2011 (r220224) @@ -1036,7 +1036,7 @@ bxe_print_adapter_info(struct bxe_softc printf("None"); break; case ETH_RSS_MODE_REGULAR: - printf("RSS"); + printf("RSS:%d", sc->num_queues); break; default: printf("Unknown"); @@ -1717,14 +1717,6 @@ bxe_attach(device_t dev) /* Prepare the tick routine. */ callout_init(&sc->bxe_tick_callout, CALLOUT_MPSAFE); - ifmedia_init(&sc->bxe_ifmedia, IFM_IMASK, bxe_ifmedia_upd, - bxe_ifmedia_status); - ifmedia_add(&sc->bxe_ifmedia, IFM_ETHER | IFM_10G_CX4, 0, NULL); - ifmedia_add(&sc->bxe_ifmedia, IFM_ETHER | IFM_10G_CX4 | IFM_FDX, 0, - NULL); - ifmedia_add(&sc->bxe_ifmedia, IFM_ETHER | IFM_AUTO, 0, NULL); - ifmedia_set(&sc->bxe_ifmedia, IFM_ETHER | IFM_AUTO); - sc->bxe_ifmedia.ifm_media = sc->bxe_ifmedia.ifm_cur->ifm_media; /* Enable bus master capability */ pci_enable_busmaster(dev); @@ -1778,12 +1770,62 @@ bxe_attach(device_t dev) /* Get hardware info from shared memory and validate data. */ if (bxe_get_function_hwinfo(sc)) { - DBPRINT(sc, BXE_WARN, "%s(): Failed to get hardware info!\n", - __FUNCTION__); + DBPRINT(sc, BXE_WARN, + "%s(): Failed to get hardware info!\n", __FUNCTION__); rc = ENODEV; goto bxe_attach_fail; } + /* Identify supported media based on the PHY type. */ + switch (XGXS_EXT_PHY_TYPE(sc->link_params.ext_phy_config)) { + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT: + DBPRINT(sc, BXE_INFO_LOAD, + "%s(): Found 10GBase-CX4 media.\n", __FUNCTION__); + sc->media = IFM_10G_CX4; + break; +#if 0 + /* ToDo: Configure correct media types for these PHYs. */ + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8071 + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8072 + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073 + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705 + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706 + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8726 +#endif + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727: + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727_NOC: + DBPRINT(sc, BXE_INFO_LOAD, + "%s(): Found 10GBase-SR media.\n", __FUNCTION__); + sc->media = IFM_10G_SR; + break; + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481: + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101: + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823: + DBPRINT(sc, BXE_INFO_LOAD, + "%s(): Found 10GBase-T media.\n", __FUNCTION__); + sc->media = IFM_10G_T; + break; + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE: + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN: + default: + BXE_PRINTF("%s(%d): PHY not supported by driver!\n", + __FILE__, __LINE__); + sc->media = 0; + rc = ENODEV; + goto bxe_attach_fail; + } + + /* Setup supported media options. */ + ifmedia_init(&sc->bxe_ifmedia, + IFM_IMASK, bxe_ifmedia_upd, bxe_ifmedia_status); + ifmedia_add(&sc->bxe_ifmedia, + IFM_ETHER | sc->media | IFM_FDX, 0, NULL); + ifmedia_add(&sc->bxe_ifmedia, + IFM_ETHER | IFM_AUTO, 0, NULL); + ifmedia_set(&sc->bxe_ifmedia, + IFM_ETHER | IFM_AUTO); + sc->bxe_ifmedia.ifm_media = sc->bxe_ifmedia.ifm_cur->ifm_media; + /* Set init arrays */ rc = bxe_init_firmware(sc); if (rc) { @@ -14153,6 +14195,18 @@ bxe_ifmedia_upd(struct ifnet *ifp) DBPRINT(sc, BXE_VERBOSE_PHY, "%s(): Media set to IFM_10G_CX4, forced mode.\n", __FUNCTION__); break; + case IFM_10G_SR: + DBPRINT(sc, BXE_VERBOSE_PHY, + "%s(): Media set to IFM_10G_SR, forced mode.\n", __FUNCTION__); + break; + case IFM_10G_T: + DBPRINT(sc, BXE_VERBOSE_PHY, + "%s(): Media set to IFM_10G_T, forced mode.\n", __FUNCTION__); + break; + case IFM_10G_TWINAX: + DBPRINT(sc, BXE_VERBOSE_PHY, + "%s(): Media set to IFM_10G_TWINAX, forced mode.\n", __FUNCTION__); + break; default: DBPRINT(sc, BXE_WARN, "%s(): Invalid media type!\n", __FUNCTION__); @@ -14198,7 +14252,7 @@ bxe_ifmedia_status(struct ifnet *ifp, st goto bxe_ifmedia_status_exit; } - ifmr->ifm_active |= IFM_10G_CX4; + ifmr->ifm_active |= sc->media; if (sc->link_vars.duplex == MEDIUM_FULL_DUPLEX) ifmr->ifm_active |= IFM_FDX; Modified: head/sys/dev/bxe/if_bxe.h ============================================================================== --- head/sys/dev/bxe/if_bxe.h Thu Mar 31 20:46:50 2011 (r220223) +++ head/sys/dev/bxe/if_bxe.h Thu Mar 31 21:01:10 2011 (r220224) @@ -1119,6 +1119,7 @@ struct bxe_softc { * MUST start with ifnet pointer (see definition of miibus_statchg()). */ struct ifnet *bxe_ifp; + int media; /* Parent device handle. */ device_t bxe_dev; From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 21:30:00 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 8A06B1065670; Thu, 31 Mar 2011 21:30:00 +0000 (UTC) (envelope-from davidch@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7237B8FC12; Thu, 31 Mar 2011 21:30:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VLU0ii023274; Thu, 31 Mar 2011 21:30:00 GMT (envelope-from davidch@svn.freebsd.org) Received: (from davidch@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VLU0fG023271; Thu, 31 Mar 2011 21:30:00 GMT (envelope-from davidch@svn.freebsd.org) Message-Id: <201103312130.p2VLU0fG023271@svn.freebsd.org> From: David Christensen Date: Thu, 31 Mar 2011 21:30:00 +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: r220226 - head/sys/dev/bxe 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, 31 Mar 2011 21:30:00 -0000 Author: davidch Date: Thu Mar 31 21:30:00 2011 New Revision: 220226 URL: http://svn.freebsd.org/changeset/base/220226 Log: - Added debug support to monitor mbuf defrag attempts/failures. MFC after: One week. Modified: head/sys/dev/bxe/if_bxe.c head/sys/dev/bxe/if_bxe.h Modified: head/sys/dev/bxe/if_bxe.c ============================================================================== --- head/sys/dev/bxe/if_bxe.c Thu Mar 31 21:21:07 2011 (r220225) +++ head/sys/dev/bxe/if_bxe.c Thu Mar 31 21:30:00 2011 (r220226) @@ -352,7 +352,7 @@ static int bxe_sysctl_reg_read(SYSCTL_HA static int bxe_sysctl_breakpoint(SYSCTL_HANDLER_ARGS); static void bxe_validate_rx_packet(struct bxe_fastpath *, uint16_t, union eth_rx_cqe *, struct mbuf *); -static void bxe_dump_grc(struct bxe_softc *, int); +static void bxe_grcdump(struct bxe_softc *, int); static void bxe_dump_enet(struct bxe_softc *,struct mbuf *); static void bxe_dump_mbuf (struct bxe_softc *, struct mbuf *); static void bxe_dump_tx_mbuf_chain(struct bxe_softc *, int, int); @@ -8585,16 +8585,22 @@ bxe_tx_encap(struct bxe_fastpath *fp, st error = bus_dmamap_load_mbuf_sg(fp->tx_mbuf_tag, map, m0, segs, &nsegs, BUS_DMA_NOWAIT); do{ - /* Handle any mapping errors. */ + /* Handle any mapping errors. */ if(__predict_false(error)){ if (error == ENOMEM) { + /* Temporary OS resource issue. */ rc = ENOMEM; }else if (error == EFBIG) { + /* Possibly recoverable. */ + DBRUN(fp->mbuf_defrag_attempts++); m0 = m_defrag(*m_head, M_DONTWAIT); if (m0 == NULL) { + BXE_PRINTF("%s(%d): Can't defrag TX frame!\n", + __FILE__, __LINE__); rc = ENOBUFS; } else { /* Defrag was successful, try mapping again.*/ + DBRUN(fp->mbuf_defrag_successes++); *m_head = m0; error = bus_dmamap_load_mbuf_sg( @@ -8602,10 +8608,15 @@ bxe_tx_encap(struct bxe_fastpath *fp, st segs, &nsegs, BUS_DMA_NOWAIT); } }else { + /* Unrecoverable. */ + BXE_PRINTF("%s(%d): Unknown TX mapping error! " + "rc = %d.\n", __FILE__, __LINE__, error); + DBRUN(bxe_dump_mbuf(sc, m0)); rc = error; } break; } + /* * Now that we know how many buffer descriptors are required to * send the frame, check whether we have enough transmit BD's @@ -8615,29 +8626,39 @@ bxe_tx_encap(struct bxe_fastpath *fp, st if (__predict_false((nsegs + 2) > (USABLE_TX_BD - fp->used_tx_bd))) { bus_dmamap_unload(fp->tx_mbuf_tag, map); + BXE_PRINTF("%s(%d): Insufficient TX queue space!\n", + __FILE__, __LINE__); + /* DRC - Should we drop a frame with this error? */ rc = ENOBUFS; break; } + /* Now make sure it fits in the pkt window */ - if (nsegs > 12) { - /* The mbuf has more segments than the controller can handle. - * Try to defrag the mbuf if there are too many - * segments. If it can't be defragged then - * drop the frame, log an error, and exit. - * An alternative would be to use a bounce buffer. - */ + if (__predict_false(nsegs > 12)) { + /* The mbuf has more segments than the controller can + * handle. Try to defrag the mbuf if there are too many + * segments. If it can't be defragged then + * drop the frame, log an error, and exit. + * An alternative would be to use a bounce buffer. + */ if(m0->m_pkthdr.csum_flags & CSUM_TSO){ if (! bxe_chktso_window(sc,nsegs,segs,m0)) /* Send it */ break; } + /* Defrag for non tso and if tso needs it */ + DBRUN(fp->mbuf_defrag_attempts++); m0 = m_defrag(*m_head, M_DONTWAIT); if (m0 == NULL) { + BXE_PRINTF("%s(%d): Can't defrag TX frame!\n", + __FILE__, __LINE__); rc = ENOBUFS; break; } + /* Defrag was successful, try mapping again. */ + DBRUN(fp->mbuf_defrag_successes++); *m_head = m0; error = bus_dmamap_load_mbuf_sg( @@ -8654,6 +8675,8 @@ bxe_tx_encap(struct bxe_fastpath *fp, st /* The frame can't be defragged, * drop it. */ + BXE_PRINTF("%s(%d): Can't map TX frame!\n", + __FILE__, __LINE__); rc = error; } break; @@ -8663,6 +8686,8 @@ bxe_tx_encap(struct bxe_fastpath *fp, st if (bxe_chktso_window(sc,nsegs,segs,m0)) rc = ENOBUFS; } else if (nsegs > 12 ){ + BXE_PRINTF("%s(%d): Too many fragments for a TSO " + "frame!\n", __FILE__, __LINE__); rc = ENOBUFS; } } @@ -8672,15 +8697,13 @@ bxe_tx_encap(struct bxe_fastpath *fp, st if (rc){ if(rc == ENOMEM){ /* Recoverable try again later */ - BXE_PRINTF("%s(%d): Error mapping mbuf into TX chain" - "returning pkt to queue\n",__FILE__, __LINE__); + BXE_PRINTF("%s(%d): Error mapping mbuf into TX chain, " + "returning pkt to queue!\n",__FILE__, __LINE__); }else{ fp->soft_tx_errors++; DBRUN(fp->tx_mbuf_alloc--); m_freem(*m_head); *m_head = NULL; - BXE_PRINTF("%s(%d): Error mapping mbuf into TX chain" - "Frame dropped \n",__FILE__, __LINE__); } return (rc); } @@ -14838,7 +14861,7 @@ bxe_rxeof(struct bxe_fastpath *fp) /* * The high level logic used here is to - * immediatley replace each receive buffer + * immediatley replace each receive buffer * as it is used so that the receive chain * is full at all times. First we try to * allocate a new receive buffer, but if @@ -15497,7 +15520,7 @@ bxe_sysctl_reg_read(SYSCTL_HANDLER_ARGS) * 0 for success, positive value for failure. */ static int -bxe_sysctl_dump_grc(SYSCTL_HANDLER_ARGS) +bxe_sysctl_grcdump(SYSCTL_HANDLER_ARGS) { struct bxe_softc *sc; int error, result; @@ -15510,10 +15533,10 @@ bxe_sysctl_dump_grc(SYSCTL_HANDLER_ARGS) if (result == 1) { /* Generate a grcdump and log the contents.*/ - bxe_dump_grc(sc, 1); + bxe_grcdump(sc, 1); } else { /* Generate a grcdump and don't log the contents. */ - bxe_dump_grc(sc, 0); + bxe_grcdump(sc, 0); } return (error); @@ -15555,13 +15578,18 @@ bxe_sysctl_breakpoint(SYSCTL_HANDLER_ARG static void bxe_add_sysctls(struct bxe_softc *sc) { - struct sysctl_ctx_list *ctx; - struct sysctl_oid_list *children; - struct bxe_eth_stats *estats; + struct sysctl_ctx_list *ctx = + device_get_sysctl_ctx(sc->bxe_dev); + struct sysctl_oid_list *children = + SYSCTL_CHILDREN(device_get_sysctl_tree(sc->bxe_dev)); + struct bxe_eth_stats *estats = &sc->eth_stats; + + struct sysctl_oid *queue_node; + struct sysctl_oid_list *queue_list; + +#define QUEUE_NAME_LEN 32 + char namebuf[QUEUE_NAME_LEN]; - estats = &sc->eth_stats; - ctx = device_get_sysctl_ctx(sc->bxe_dev); - children = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->bxe_dev)); SYSCTL_ADD_UINT(ctx, children, OID_AUTO, "estats_total_bytes_received_hi", @@ -15676,36 +15704,60 @@ bxe_add_sysctls(struct bxe_softc *sc) CTLFLAG_RD, &sc->mbuf_alloc_failed, 0, "mbuf cluster allocation failures"); + for (int i = 0; i < sc->num_queues; i++) { + struct bxe_fastpath *fp = &sc->fp[i]; + snprintf(namebuf, QUEUE_NAME_LEN, "fp[%02d]", i); + + queue_node = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, + namebuf, CTLFLAG_RD, NULL, "Queue Name"); + queue_list = SYSCTL_CHILDREN(queue_node); + + SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, + "mbuf_alloc_failed", + CTLFLAG_RD, &fp->mbuf_alloc_failed, + "Mbuf allocation failures"); + + SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, + "mbuf_defrag_attempts", + CTLFLAG_RD, &fp->mbuf_defrag_attempts, + "Mbuf defrag attempts"); + + SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, + "mbuf_defrag_successes", + CTLFLAG_RD, &fp->mbuf_defrag_successes, + "Mbuf defrag successes"); + } + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "driver_state", - CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, bxe_sysctl_driver_state, - "I", "Drive state information"); + CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, + bxe_sysctl_driver_state, "I", "Drive state information"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "hw_state", - CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, bxe_sysctl_hw_state, - "I", "Hardware state information"); + CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, + bxe_sysctl_hw_state, "I", "Hardware state information"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "dump_fw", - CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, bxe_sysctl_dump_fw, - "I", "Dump MCP firmware"); + CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, + bxe_sysctl_dump_fw, "I", "Dump MCP firmware"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "dump_rx_chain", - CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, bxe_sysctl_dump_rx_chain, - "I", "Dump rx_bd chain"); + CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, + bxe_sysctl_dump_rx_chain, "I", "Dump rx_bd chain"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "dump_cqe_chain", - CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, bxe_sysctl_dump_cqe_chain, - "I", "Dump cqe chain"); + CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, + bxe_sysctl_dump_cqe_chain, "I", "Dump cqe chain"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "dump_tx_chain", - CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, bxe_sysctl_dump_tx_chain, - "I", "Dump tx_bd chain"); + CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, + bxe_sysctl_dump_tx_chain, "I", "Dump tx_bd chain"); /* * Generates a GRCdump (run sysctl dev.bxe.0.grcdump=0 - * before access buffer below). + * before accessing buffer below). */ SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "grcdump", - CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, bxe_sysctl_dump_grc, + CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, bxe_sysctl_grcdump, "I", "Initiate a grcdump operation"); /* @@ -15713,16 +15765,17 @@ bxe_add_sysctls(struct bxe_softc *sc) * Use "sysctl -b dev.bxe.0.grcdump_buffer > buf.bin". */ SYSCTL_ADD_OPAQUE(ctx, children, OID_AUTO, "grcdump_buffer", - CTLFLAG_RD | CTLFLAG_SKIP, sc->grcdump_buffer, BXE_GRCDUMP_BUF_SIZE, - "IU", "Grcdump buffer"); + CTLFLAG_RD | CTLFLAG_SKIP, sc->grcdump_buffer, + BXE_GRCDUMP_BUF_SIZE, "IU", "Access grcdump buffer"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "breakpoint", - CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, bxe_sysctl_breakpoint, - "I", "Driver breakpoint"); + CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, + bxe_sysctl_breakpoint, "I", "Driver breakpoint"); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "reg_read", - CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, bxe_sysctl_reg_read, - "I", "Register read"); + CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, + bxe_sysctl_reg_read, "I", "Register read"); + #endif /* BXE_DEBUG */ } @@ -15886,7 +15939,7 @@ bxe_dump_debug_reg_wread(struct bxe_soft * None. */ static void -bxe_dump_grc(struct bxe_softc *sc, int log) +bxe_grcdump(struct bxe_softc *sc, int log) { uint32_t *buf, i, index; Modified: head/sys/dev/bxe/if_bxe.h ============================================================================== --- head/sys/dev/bxe/if_bxe.h Thu Mar 31 21:21:07 2011 (r220225) +++ head/sys/dev/bxe/if_bxe.h Thu Mar 31 21:30:00 2011 (r220226) @@ -1084,6 +1084,8 @@ struct bxe_fastpath { /* Memory buffer allocation failure counter. */ unsigned long mbuf_alloc_failed; + unsigned long mbuf_defrag_attempts; + unsigned long mbuf_defrag_successes; /* Track the number of enqueued mbufs. */ int tx_mbuf_alloc; From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 21:33: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 EA4F4106566B; Thu, 31 Mar 2011 21:33:33 +0000 (UTC) (envelope-from rstone@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D758E8FC17; Thu, 31 Mar 2011 21:33:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VLXXv0023396; Thu, 31 Mar 2011 21:33:33 GMT (envelope-from rstone@svn.freebsd.org) Received: (from rstone@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VLXXLA023394; Thu, 31 Mar 2011 21:33:33 GMT (envelope-from rstone@svn.freebsd.org) Message-Id: <201103312133.p2VLXXLA023394@svn.freebsd.org> From: Ryan Stone Date: Thu, 31 Mar 2011 21:33: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: r220227 - head/sys/tools 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, 31 Mar 2011 21:33:34 -0000 Author: rstone Date: Thu Mar 31 21:33:33 2011 New Revision: 220227 URL: http://svn.freebsd.org/changeset/base/220227 Log: GNU awk does not output escaped newlines in multi-line printc statements. This leads to compile errors when trying to compile firmware(9) stubs created with gawk, as multiple #include statements end up on the same line. Replace the multi-line printc statement that outputs all of the #includes with one printc per #include. This allows modules compatible with firmware(9) to be cross-built from a Linux machine without requiring the one true awk to be installed. I've intentionally done the minimal set of changes necessary to make gawk produce valid (but not pretty) C code, to reduce the churn and keep fw_stubs.awk as readable as possible. Approved by: emaste (mentor) MFC after: 2 weeks Modified: head/sys/tools/fw_stub.awk Modified: head/sys/tools/fw_stub.awk ============================================================================== --- head/sys/tools/fw_stub.awk Thu Mar 31 21:30:00 2011 (r220226) +++ head/sys/tools/fw_stub.awk Thu Mar 31 21:33:33 2011 (r220227) @@ -124,14 +124,14 @@ gsub(/[-\.]/, "_", modname); printc("/*\ * Automatically generated by:\ * $FreeBSD$\ - */\ -#include \ -#include \ -#include \ -#include \ -#include \ -#include \ -#include \n"); + */"); +printc("#include "); +printc("#include "); +printc("#include "); +printc("#include "); +printc("#include "); +printc("#include "); +printc("#include \n"); if (opt_l) { printc("static long " opt_l "_license_ack = 0;"); From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 22:04: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 42C8F106566B; Thu, 31 Mar 2011 22:04:01 +0000 (UTC) (envelope-from davidch@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2F06F8FC08; Thu, 31 Mar 2011 22:04:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VM41gW024056; Thu, 31 Mar 2011 22:04:01 GMT (envelope-from davidch@svn.freebsd.org) Received: (from davidch@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VM41fm024054; Thu, 31 Mar 2011 22:04:01 GMT (envelope-from davidch@svn.freebsd.org) Message-Id: <201103312204.p2VM41fm024054@svn.freebsd.org> From: David Christensen Date: Thu, 31 Mar 2011 22:04:01 +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: r220228 - head/sys/dev/bxe 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, 31 Mar 2011 22:04:01 -0000 Author: davidch Date: Thu Mar 31 22:04:00 2011 New Revision: 220228 URL: http://svn.freebsd.org/changeset/base/220228 Log: - Fixed DMA engine errors by increasing timeouts to 200ms for reads/writes. - Improved some error reporting calls to include file name/line number. - Various style(9) fixes. MFC after: One week. Modified: head/sys/dev/bxe/if_bxe.c Modified: head/sys/dev/bxe/if_bxe.c ============================================================================== --- head/sys/dev/bxe/if_bxe.c Thu Mar 31 21:33:33 2011 (r220227) +++ head/sys/dev/bxe/if_bxe.c Thu Mar 31 22:04:00 2011 (r220228) @@ -458,9 +458,7 @@ SYSCTL_UINT(_hw_bxe, OID_AUTO, tpa_enabl /* * Specifies the number of queues that will be used when a multi-queue - * RSS mode is selected using bxe_multi_mode below. Some RSS modes - * require additional queue configuration which may conflict with this - * setting. In that case this value will be overriden. + * RSS mode is selected using bxe_multi_mode below. * * Allowable values are 0 (Auto) or 1 to MAX_CONTEXT (fixed queue number). */ @@ -1145,7 +1143,7 @@ bxe_interrupt_allocate(struct bxe_softc break; } } else { - /* User has forced INTx mode. */ + /* User has forced INTx mode. */ sc->multi_mode = ETH_RSS_MODE_DISABLED; sc->num_queues = 1; } @@ -1451,7 +1449,7 @@ bxe_interrupt_attach(struct bxe_softc *s "%s(): Enabling slowpath MSI[0] vector.\n", __FUNCTION__); /* - * Setup the interrupt handler. Note that we pass the driver + * Setup the interrupt handler. Note that we pass the driver * instance to the interrupt handler for the slowpath. */ rc = bus_setup_intr(sc->bxe_dev,sc->bxe_msi_res[0], @@ -1477,7 +1475,7 @@ bxe_interrupt_attach(struct bxe_softc *s "%s(): Enabling MSI[%d] vector.\n", __FUNCTION__, i + 1); /* - * Setup the interrupt handler. Note that we pass the + * Setup the interrupt handler. Note that we pass the * fastpath context to the interrupt handler in this * case. */ @@ -1762,7 +1760,7 @@ bxe_attach(device_t dev) /* Put indirect address registers into a sane state. */ pci_write_config(sc->bxe_dev, PCICFG_GRC_ADDRESS, - PCICFG_VENDOR_ID_OFFSET, 4); + PCICFG_VENDOR_ID_OFFSET, 4); REG_WR(sc, PXP2_REG_PGL_ADDR_88_F0 + BP_PORT(sc) * 16, 0); REG_WR(sc, PXP2_REG_PGL_ADDR_8C_F0 + BP_PORT(sc) * 16, 0); REG_WR(sc, PXP2_REG_PGL_ADDR_90_F0 + BP_PORT(sc) * 16, 0); @@ -1829,7 +1827,8 @@ bxe_attach(device_t dev) /* Set init arrays */ rc = bxe_init_firmware(sc); if (rc) { - BXE_PRINTF("Error loading firmware\n"); + BXE_PRINTF("%s(%d): Error loading firmware\n", + __FILE__, __LINE__); goto bxe_attach_fail; } @@ -1846,8 +1845,8 @@ bxe_attach(device_t dev) /* Check that NVRAM contents are valid.*/ if (bxe_nvram_test(sc)) { - DBPRINT(sc, BXE_WARN, "%s(): Failed NVRAM test!\n", - __FUNCTION__); + BXE_PRINTF("%s(%d): Failed NVRAM test!\n", + __FILE__, __LINE__); rc = ENODEV; goto bxe_attach_fail; } @@ -1855,7 +1854,7 @@ bxe_attach(device_t dev) /* Allocate the appropriate interrupts.*/ if (bxe_interrupt_allocate(sc)) { BXE_PRINTF("%s(%d): Interrupt allocation failed!\n", - __FILE__, __LINE__); + __FILE__, __LINE__); rc = ENODEV; goto bxe_attach_fail; } @@ -1902,10 +1901,13 @@ bxe_attach(device_t dev) /* Disable WoL. */ sc->wol = 0; + /* Assume a standard 1500 byte MTU size for mbuf allocations. */ + sc->mbuf_alloc_size = MCLBYTES; + /* Allocate DMA memory resources. */ if (bxe_dma_alloc(sc->bxe_dev)) { BXE_PRINTF("%s(%d): DMA allocation failed!\n", - __FILE__, __LINE__); + __FILE__, __LINE__); rc = ENOMEM; goto bxe_attach_fail; } @@ -1914,7 +1916,7 @@ bxe_attach(device_t dev) ifp = sc->bxe_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { BXE_PRINTF("%s(%d): Interface allocation failed!\n", - __FILE__, __LINE__); + __FILE__, __LINE__); rc = ENXIO; goto bxe_attach_fail; } @@ -1935,8 +1937,6 @@ bxe_attach(device_t dev) ifp->if_capenable = ifp->if_capabilities; ifp->if_baudrate = IF_Gbps(10UL); - /* Assume a standard 1500 byte MTU size for mbuf allocations. */ - sc->mbuf_alloc_size = MCLBYTES; ifp->if_snd.ifq_drv_maxlen = sc->tx_ring_size; IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen); @@ -1947,8 +1947,8 @@ bxe_attach(device_t dev) /* Attach the interrupts to the interrupt handlers. */ if (bxe_interrupt_attach(sc)) { - BXE_PRINTF("%s(%d): Interrupt allocation failed!\n", __FILE__, - __LINE__); + BXE_PRINTF("%s(%d): Interrupt allocation failed!\n", + __FILE__, __LINE__); goto bxe_attach_fail; } @@ -2901,6 +2901,9 @@ bxe_setup_leading(struct bxe_softc *sc) DBENTER(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET | BXE_VERBOSE_RAMROD); + DBPRINT(sc, BXE_INFO_LOAD, "%s(): Setup leading connection " + "on fp[00].\n", __FUNCTION__); + /* Reset IGU state for the leading connection. */ bxe_ack_sb(sc, sc->fp[0].sb_id, CSTORM_ID, 0, IGU_INT_ENABLE, 0); @@ -2929,6 +2932,9 @@ bxe_stop_leading(struct bxe_softc *sc) DBENTER(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET | BXE_VERBOSE_RAMROD); + DBPRINT(sc, BXE_INFO_LOAD, "%s(): Stop client connection " + "on fp[00].\n", __FUNCTION__); + /* Send the ETH_HALT ramrod. */ sc->fp[0].state = BXE_FP_STATE_HALTING; bxe_sp_post(sc,RAMROD_CMD_ID_ETH_HALT, 0, 0, sc->fp[0].cl_id, 0); @@ -2987,6 +2993,9 @@ bxe_setup_multi(struct bxe_softc *sc, in DBENTER(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET | BXE_VERBOSE_RAMROD); + DBPRINT(sc, BXE_INFO_LOAD, "%s(): Setup client connection " + "on fp[%02d].\n", __FUNCTION__, index); + fp = &sc->fp[index]; /* Reset IGU state. */ bxe_ack_sb(sc, fp->sb_id, CSTORM_ID, 0, IGU_INT_ENABLE, 0); @@ -3019,7 +3028,11 @@ bxe_stop_multi(struct bxe_softc *sc, int DBENTER(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET | BXE_VERBOSE_RAMROD); + DBPRINT(sc, BXE_INFO_LOAD, "%s(): Stop client connection " + "on fp[%02d].\n", __FUNCTION__, index); + fp = &sc->fp[index]; + /* Halt the client connection. */ fp->state = BXE_FP_STATE_HALTING; bxe_sp_post(sc, RAMROD_CMD_ID_ETH_HALT, index, 0, fp->cl_id, 0); @@ -4398,7 +4411,7 @@ bxe_write_dmae(struct bxe_softc *sc, bus bxe_post_dmae(sc, &dmae, INIT_DMAE_C(sc)); - DELAY(5); + DELAY(50); timeout = 4000; while (*wb_comp != BXE_WB_COMP_VAL) { @@ -4409,7 +4422,7 @@ bxe_write_dmae(struct bxe_softc *sc, bus break; } timeout--; - DELAY(5); + DELAY(50); } BXE_DMAE_UNLOCK(sc); @@ -4485,9 +4498,9 @@ bxe_read_dmae(struct bxe_softc *sc, uint bxe_post_dmae(sc, &dmae, INIT_DMAE_C(sc)); - DELAY(5); + DELAY(50); - timeout = 200; + timeout = 4000; while (*wb_comp != BXE_WB_COMP_VAL) { if (!timeout) { DBPRINT(sc, 1, @@ -4496,7 +4509,7 @@ bxe_read_dmae(struct bxe_softc *sc, uint break; } timeout--; - DELAY(5); + DELAY(50); } BXE_DMAE_UNLOCK(sc); @@ -8527,8 +8540,7 @@ bxe_chktso_window(struct bxe_softc* sc, } /* - * bxe_tx_encap() - * Encapsultes an mbuf cluster into the bxe tx_bd chain structure and + * Encapsultes an mbuf cluster into the tx_bd chain structure and * makes the memory visible to the controller. * * If an mbuf is submitted to this routine and cannot be given to the @@ -10769,6 +10781,7 @@ bxe_init_context(struct bxe_softc *sc) U64_HI(fp->rx_bd_chain_paddr[0]); context->ustorm_st_context.common.bd_page_base_lo = U64_LO(fp->rx_bd_chain_paddr[0]); + if (TPA_ENABLED(sc) && !(fp->disable_tpa)) { /* Enable TPA and SGE chain support. */ context->ustorm_st_context.common.flags |= @@ -11333,7 +11346,7 @@ bxe_init_nic(struct bxe_softc *sc, uint3 fp->sb_id = fp->cl_id; DBPRINT(sc, (BXE_INFO_LOAD | BXE_INFO_RESET), - "%s(): fp[%d]: cl_id = %d, sb_id = %d,\n", + "%s(): fp[%d]: cl_id = %d, sb_id = %d\n", __FUNCTION__, fp->index, fp->cl_id, fp->sb_id); /* Initialize the fastpath status block. */ @@ -14761,7 +14774,8 @@ bxe_rxeof(struct bxe_fastpath *fp) __FUNCTION__)); /* Check the CQE type for slowpath or fastpath completion. */ - if (__predict_false(CQE_TYPE(cqe_fp_flags) == 1)) { + if (__predict_false(CQE_TYPE(cqe_fp_flags) == + RX_ETH_CQE_TYPE_ETH_RAMROD)) { /* This is a slowpath completion. */ bxe_sp_event(fp, cqe); goto bxe_rxeof_next_cqe; @@ -14891,6 +14905,7 @@ bxe_rxeof(struct bxe_fastpath *fp) DBRUN(bxe_breakpoint(sc)); + /* ToDo: Find alterntive to panic(). */ panic( "bxe%d: Double mbuf allocation failure!\n", sc->bxe_unit); @@ -15352,6 +15367,7 @@ bxe_sysctl_driver_state(SYSCTL_HANDLER_A fp = &sc->fp[i]; bxe_dump_fp_state(fp); } + bxe_dump_status_block(sc); } return (error); From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 22:40:44 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 8E4B5106566B; Thu, 31 Mar 2011 22:40:44 +0000 (UTC) (envelope-from davidch@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7B0388FC0A; Thu, 31 Mar 2011 22:40:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VMeic2024874; Thu, 31 Mar 2011 22:40:44 GMT (envelope-from davidch@svn.freebsd.org) Received: (from davidch@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VMeiEb024871; Thu, 31 Mar 2011 22:40:44 GMT (envelope-from davidch@svn.freebsd.org) Message-Id: <201103312240.p2VMeiEb024871@svn.freebsd.org> From: David Christensen Date: Thu, 31 Mar 2011 22:40: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: r220229 - head/sys/dev/bxe 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, 31 Mar 2011 22:40:44 -0000 Author: davidch Date: Thu Mar 31 22:40:44 2011 New Revision: 220229 URL: http://svn.freebsd.org/changeset/base/220229 Log: - Freshened debug support code. - Renamed several RX variable for more consistent usage. - Fixed a potential problem when masking RX CQ producer value. MFC after: One week. Modified: head/sys/dev/bxe/if_bxe.c head/sys/dev/bxe/if_bxe.h Modified: head/sys/dev/bxe/if_bxe.c ============================================================================== --- head/sys/dev/bxe/if_bxe.c Thu Mar 31 22:04:00 2011 (r220228) +++ head/sys/dev/bxe/if_bxe.c Thu Mar 31 22:40:44 2011 (r220229) @@ -68,7 +68,8 @@ __FBSDID("$FreeBSD$"); /* BXE Debug Options */ #ifdef BXE_DEBUG - uint32_t bxe_debug = BXE_INFO; +uint32_t bxe_debug = BXE_INFO; + /* 0 = Never */ /* 1 = 1 in 2,147,483,648 */ @@ -345,8 +346,8 @@ int bxe_set_gpio_int(struct bxe_softc * static int bxe_sysctl_driver_state(SYSCTL_HANDLER_ARGS); static int bxe_sysctl_hw_state(SYSCTL_HANDLER_ARGS); static int bxe_sysctl_dump_fw(SYSCTL_HANDLER_ARGS); -static int bxe_sysctl_dump_cqe_chain(SYSCTL_HANDLER_ARGS); -static int bxe_sysctl_dump_rx_chain(SYSCTL_HANDLER_ARGS); +static int bxe_sysctl_dump_rx_cq_chain(SYSCTL_HANDLER_ARGS); +static int bxe_sysctl_dump_rx_bd_chain(SYSCTL_HANDLER_ARGS); static int bxe_sysctl_dump_tx_chain(SYSCTL_HANDLER_ARGS); static int bxe_sysctl_reg_read(SYSCTL_HANDLER_ARGS); static int bxe_sysctl_breakpoint(SYSCTL_HANDLER_ARGS); @@ -357,16 +358,16 @@ static void bxe_dump_enet(struct bxe_sof static void bxe_dump_mbuf (struct bxe_softc *, struct mbuf *); static void bxe_dump_tx_mbuf_chain(struct bxe_softc *, int, int); static void bxe_dump_rx_mbuf_chain(struct bxe_softc *, int, int); -static void bxe_dump_pbd_locked(struct bxe_softc *,int, +static void bxe_dump_tx_parsing_bd(struct bxe_fastpath *,int, struct eth_tx_parse_bd *); -static void bxe_dump_txbd_locked(struct bxe_fastpath *, int, - struct eth_tx_bd *); -static void bxe_dump_rxbd_locked(struct bxe_fastpath *, int, +static void bxe_dump_txbd(struct bxe_fastpath *, int, + union eth_tx_bd_types *); +static void bxe_dump_rxbd(struct bxe_fastpath *, int, struct eth_rx_bd *); -static void bxe_dump_cqe_locked(struct bxe_fastpath *, int, union eth_rx_cqe *); +static void bxe_dump_cqe(struct bxe_fastpath *, int, union eth_rx_cqe *); static void bxe_dump_tx_chain(struct bxe_fastpath *, int, int); -static void bxe_dump_cqe_chain(struct bxe_fastpath *, int, int); -static void bxe_dump_rx_chain(struct bxe_fastpath *, int, int); +static void bxe_dump_rx_cq_chain(struct bxe_fastpath *, int, int); +static void bxe_dump_rx_bd_chain(struct bxe_fastpath *, int, int); static void bxe_dump_status_block(struct bxe_softc *); static void bxe_dump_stats_block(struct bxe_softc *); static void bxe_dump_fp_state(struct bxe_fastpath *); @@ -404,6 +405,7 @@ static device_method_t bxe_methods[] = { KOBJMETHOD_END }; + static driver_t bxe_driver = { "bxe", bxe_methods, @@ -1725,11 +1727,11 @@ bxe_attach(device_t dev) * processor memory. */ rid = PCIR_BAR(0); - sc->bxe_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &rid, RF_ACTIVE); + sc->bxe_res = bus_alloc_resource_any(dev, + SYS_RES_MEMORY, &rid, RF_ACTIVE); if (sc->bxe_res == NULL) { BXE_PRINTF("%s(%d):PCI BAR0 memory allocation failed\n", - __FILE__, __LINE__); + __FILE__, __LINE__); rc = ENXIO; goto bxe_attach_fail; } @@ -1744,11 +1746,11 @@ bxe_attach(device_t dev) * Doorbell (DB) memory. */ rid = PCIR_BAR(2); - sc->bxe_db_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &rid, RF_ACTIVE); + sc->bxe_db_res = bus_alloc_resource_any(dev, + SYS_RES_MEMORY, &rid, RF_ACTIVE); if (sc->bxe_db_res == NULL) { BXE_PRINTF("%s(%d): PCI BAR2 memory allocation failed\n", - __FILE__, __LINE__); + __FILE__, __LINE__); rc = ENXIO; goto bxe_attach_fail; } @@ -1834,7 +1836,6 @@ bxe_attach(device_t dev) #ifdef BXE_DEBUG - /* Allocate a memory buffer for grcdump output.*/ sc->grcdump_buffer = malloc(BXE_GRCDUMP_BUF_SIZE, M_TEMP, M_NOWAIT); if (sc->grcdump_buffer == NULL) { @@ -3738,8 +3739,8 @@ bxe_init_locked(struct bxe_softc *sc, in callout_reset(&sc->bxe_tick_callout, hz, bxe_tick, sc); /* Everything went OK, go ahead and exit. */ goto bxe_init_locked_exit; + /* Try and gracefully shutdown the device because of a failure. */ -/* Try and gracefully shutdown the device because of a failure. */ bxe_init_locked_failed4: for (i = 1; i < sc->num_queues; i++) @@ -4413,6 +4414,7 @@ bxe_write_dmae(struct bxe_softc *sc, bus DELAY(50); + /* Wait up to 200ms. */ timeout = 4000; while (*wb_comp != BXE_WB_COMP_VAL) { if (!timeout) { @@ -4433,18 +4435,18 @@ bxe_write_dmae_exit: /* -* Perform a DMAE read from to device memory. -* + * Perform a DMAE read from to device memory. + * * Some of the registers on the 577XX controller are 128bits wide. It is * required that when accessing those registers that they be read * atomically and that no intervening bus acceses to the device occur. * This could be handled by a lock held across all driver instances for * the device or it can be handled by performing a DMA operation when * reading from the device. This code implements the latter. -* -* Returns: -* None. -*/ + * + * Returns: + * None. + */ void bxe_read_dmae(struct bxe_softc *sc, uint32_t src_addr, uint32_t len32) @@ -7244,7 +7246,8 @@ bxe_stats_init(struct bxe_softc *sc) sizeof(struct ustorm_per_client_stats)); memset(&fp->old_xclient, 0, sizeof(struct xstorm_per_client_stats)); - memset(&fp->eth_q_stats, 0, sizeof(struct bxe_q_stats)); + memset(&fp->eth_q_stats, 0, + sizeof(struct bxe_q_stats)); } sc->stats_state = STATS_STATE_DISABLED; @@ -8539,6 +8542,7 @@ bxe_chktso_window(struct bxe_softc* sc, return (defrag); } + /* * Encapsultes an mbuf cluster into the tx_bd chain structure and * makes the memory visible to the controller. @@ -8557,7 +8561,7 @@ bxe_tx_encap(struct bxe_fastpath *fp, st bus_dma_segment_t segs[32]; bus_dmamap_t map; struct mbuf *m0; - struct eth_tx_parse_bd *pbd; + struct eth_tx_parse_bd *tx_parse_bd; struct eth_tx_bd *tx_data_bd; struct eth_tx_bd *tx_total_pkt_size_bd; struct eth_tx_start_bd *tx_start_bd; @@ -8580,7 +8584,7 @@ bxe_tx_encap(struct bxe_fastpath *fp, st tx_total_pkt_size_bd = NULL; tx_start_bd = NULL; tx_data_bd = NULL; - pbd = NULL; + tx_parse_bd = NULL; pkt_prod = fp->tx_pkt_prod; bd_prod = TX_BD(fp->tx_bd_prod); @@ -8693,6 +8697,7 @@ bxe_tx_encap(struct bxe_fastpath *fp, st } break; } + /* Last try */ if (m0->m_pkthdr.csum_flags & CSUM_TSO){ if (bxe_chktso_window(sc,nsegs,segs,m0)) @@ -8765,11 +8770,11 @@ bxe_tx_encap(struct bxe_fastpath *fp, st * however, it is only used for tso & chksum. */ bd_prod = TX_BD(NEXT_TX_BD(bd_prod)); - pbd = (struct eth_tx_parse_bd *) + tx_parse_bd = (struct eth_tx_parse_bd *) &fp->tx_bd_chain[TX_PAGE(bd_prod)][TX_IDX(bd_prod)].parse_bd; - memset(pbd, 0, sizeof(struct eth_tx_parse_bd)); + memset(tx_parse_bd, 0, sizeof(struct eth_tx_parse_bd)); - /* Gather all info about the packet and add to pbd */ + /* Gather all info about the packet and add to tx_parse_bd */ if (m0->m_pkthdr.csum_flags) { struct ether_vlan_header *eh; struct ip *ip = NULL; @@ -8790,8 +8795,9 @@ bxe_tx_encap(struct bxe_fastpath *fp, st } /* Set the Ethernet header length in 16 bit words. */ - pbd->global_data = (e_hlen + ovlan) >> 1; - pbd->global_data |= ((m0->m_flags & M_VLANTAG) << ETH_TX_PARSE_BD_LLC_SNAP_EN_SHIFT); + tx_parse_bd->global_data = (e_hlen + ovlan) >> 1; + tx_parse_bd->global_data |= ((m0->m_flags & M_VLANTAG) << + ETH_TX_PARSE_BD_LLC_SNAP_EN_SHIFT); switch (etype) { case ETHERTYPE_IP:{ @@ -8802,10 +8808,10 @@ bxe_tx_encap(struct bxe_fastpath *fp, st ip = (struct ip *)(m0->m_data + e_hlen); /* Calculate IP header length (16 bit words). */ - pbd->ip_hlen = (ip->ip_hl << 1); + tx_parse_bd->ip_hlen = (ip->ip_hl << 1); /* Calculate enet + IP header length (16 bit words). */ - pbd->total_hlen = pbd->ip_hlen + (e_hlen >> 1); + tx_parse_bd->total_hlen = tx_parse_bd->ip_hlen + (e_hlen >> 1); if (m0->m_pkthdr.csum_flags & CSUM_IP) { DBPRINT(sc, BXE_EXTREME_SEND, "%s(): IP checksum " @@ -8816,7 +8822,7 @@ bxe_tx_encap(struct bxe_fastpath *fp, st /* Handle any checksums requested by the stack. */ if ((m0->m_pkthdr.csum_flags & CSUM_TCP)|| - (m0->m_pkthdr.csum_flags & CSUM_TSO)){ + (m0->m_pkthdr.csum_flags & CSUM_TSO)){ /* Perform TCP checksum offload. */ DBPRINT(sc, BXE_EXTREME_SEND, "%s(): TCP checksum " @@ -8830,10 +8836,10 @@ bxe_tx_encap(struct bxe_fastpath *fp, st DBRUN(sc->debug_tcp_csum_offload_frames++); /* Update the enet + IP + TCP header length. */ - pbd->total_hlen += (uint16_t)(th->th_off << 1); + tx_parse_bd->total_hlen += (uint16_t)(th->th_off << 1); /* Get the pseudo header checksum. */ - pbd->tcp_pseudo_csum = ntohs(th->th_sum); + tx_parse_bd->tcp_pseudo_csum = ntohs(th->th_sum); } else if (m0->m_pkthdr.csum_flags & CSUM_UDP) { /* * The hardware doesn't actually support UDP checksum @@ -8861,7 +8867,7 @@ bxe_tx_encap(struct bxe_fastpath *fp, st /* Add the TCP checksum offload flag for UDP frames too. */ flags |= ETH_TX_BD_FLAGS_L4_CSUM; DBRUN(sc->debug_udp_csum_offload_frames++); - pbd->global_data |= ETH_TX_PARSE_BD_UDP_CS_FLG; + tx_parse_bd->global_data |= ETH_TX_PARSE_BD_UDP_CS_FLG; /* Get a pointer to the UDP header. */ uh = (struct udphdr *)((caddr_t)ip + (ip->ip_hl << 2)); @@ -8878,8 +8884,8 @@ bxe_tx_encap(struct bxe_fastpath *fp, st ntohl((*(tmp_uh + 2)) & 0x0000FFFF)); /* Update the enet + IP + UDP header length. */ - pbd->total_hlen += (sizeof(struct udphdr) >> 1); - pbd->tcp_pseudo_csum = ~in_addword(uh->uh_sum, ~tmp_csum); + tx_parse_bd->total_hlen += (sizeof(struct udphdr) >> 1); + tx_parse_bd->tcp_pseudo_csum = ~in_addword(uh->uh_sum, ~tmp_csum); } /* Update the flags settings for VLAN/Offload. */ @@ -8900,9 +8906,10 @@ bxe_tx_encap(struct bxe_fastpath *fp, st /* Setup the Parsing BD with TSO specific info */ if (m0->m_pkthdr.csum_flags & CSUM_TSO) { - uint16_t hdr_len = pbd->total_hlen << 1; + uint16_t hdr_len = tx_parse_bd->total_hlen << 1; - DBPRINT(sc, BXE_EXTREME_SEND, "%s(): TSO is enabled.\n",__FUNCTION__); + DBPRINT(sc, BXE_EXTREME_SEND, "%s(): TSO is enabled.\n", + __FUNCTION__); tx_start_bd->bd_flags.as_bitfield |= ETH_TX_BD_FLAGS_SW_LSO; @@ -8918,9 +8925,9 @@ bxe_tx_encap(struct bxe_fastpath *fp, st __FUNCTION__, tx_start_bd->nbytes, tx_start_bd->addr_hi, tx_start_bd->addr_lo, nbds); - bd_prod = TX_BD(NEXT_TX_BD(bd_prod)); + bd_prod = TX_BD(NEXT_TX_BD(bd_prod)); - /* Get a new transmit BD (after the pbd) and fill it. */ + /* Get a new transmit BD (after the tx_parse_bd) and fill it. */ tx_data_bd = &fp->tx_bd_chain[TX_PAGE(bd_prod)][TX_IDX(bd_prod)].reg_bd; tx_data_bd->addr_hi = htole32(U64_HI(segs[0].ds_addr + hdr_len)); tx_data_bd->addr_lo = htole32(U64_LO(segs[0].ds_addr + hdr_len)); @@ -8934,23 +8941,26 @@ bxe_tx_encap(struct bxe_fastpath *fp, st */ DBPRINT(sc, BXE_EXTREME_SEND, "%s(): TSO split data " - "size is %d (%x:%x)\n", __FUNCTION__, - tx_data_bd->nbytes, tx_data_bd->addr_hi, tx_data_bd->addr_lo); + "size is %d (%x:%x)\n", __FUNCTION__, + tx_data_bd->nbytes, tx_data_bd->addr_hi, + tx_data_bd->addr_lo); } /* * For TSO the controller needs the following info: * MSS, tcp_send_seq, ip_id, and tcp_pseudo_csum. */ - pbd->lso_mss = htole16(m0->m_pkthdr.tso_segsz); - pbd->tcp_send_seq = ntohl(th->th_seq); - pbd->tcp_flags = th->th_flags; - pbd->ip_id = ntohs(ip->ip_id); + tx_parse_bd->lso_mss = htole16(m0->m_pkthdr.tso_segsz); + tx_parse_bd->tcp_send_seq = ntohl(th->th_seq); + tx_parse_bd->tcp_flags = th->th_flags; + tx_parse_bd->ip_id = ntohs(ip->ip_id); + + tx_parse_bd->tcp_pseudo_csum = + ntohs(in_pseudo(ip->ip_src.s_addr, + ip->ip_dst.s_addr, htons(IPPROTO_TCP))); - pbd->tcp_pseudo_csum = ntohs(in_pseudo(ip->ip_src.s_addr, - ip->ip_dst.s_addr, htons(IPPROTO_TCP))); - - pbd->global_data |= ETH_TX_PARSE_BD_PSEUDO_CS_WITHOUT_LEN; + tx_parse_bd->global_data |= + ETH_TX_PARSE_BD_PSEUDO_CS_WITHOUT_LEN; } } @@ -8971,17 +8981,6 @@ bxe_tx_encap(struct bxe_fastpath *fp, st /* Update bd producer index value for next tx */ bd_prod = TX_BD(NEXT_TX_BD(bd_prod)); -/* -BXE_PRINTF("tx_start_bd: addrlo:0x%x, addrhi:0x%x, nbytes:0x%x, bitfield:0x%x, gendata:0x%x, nbd:0x%x\n", -tx_start_bd->addr_lo, -tx_start_bd->addr_hi, -tx_start_bd->nbytes, -tx_start_bd->bd_flags.as_bitfield, -tx_start_bd->general_data, -tx_start_bd->nbd ); - -bxe_dump_mbuf(sc, m0); -*/ DBRUNMSG(BXE_EXTREME_SEND, bxe_dump_tx_chain(fp, debug_prod, nbds)); /* @@ -9391,12 +9390,12 @@ bxe_ioctl(struct ifnet *ifp, u_long comm * The adjusted value of *fp->rx_cons_sb. */ static __inline uint16_t -bxe_rx_comp_cons(struct bxe_fastpath *fp) +bxe_rx_cq_cons(struct bxe_fastpath *fp) { volatile uint16_t rx_cons_sb = 0; rmb(); - rx_cons_sb = (volatile uint16_t)le16toh(*fp->rx_cons_sb); + rx_cons_sb = (volatile uint16_t) le16toh(*fp->rx_cons_sb); /* * It is valid for the hardware's copy of the completion @@ -9405,8 +9404,8 @@ bxe_rx_comp_cons(struct bxe_fastpath *fp * that it is pointing at the next available CQE so we * need to adjust the value accordingly. */ - if ((rx_cons_sb & TOTAL_RCQ_ENTRIES_PER_PAGE) == - TOTAL_RCQ_ENTRIES_PER_PAGE) + if ((rx_cons_sb & USABLE_RCQ_ENTRIES_PER_PAGE) == + USABLE_RCQ_ENTRIES_PER_PAGE) rx_cons_sb++; return (rx_cons_sb); @@ -9434,7 +9433,7 @@ bxe_has_rx_work(struct bxe_fastpath *fp) { rmb(); - return (bxe_rx_comp_cons(fp) != fp->rx_comp_cons); + return (bxe_rx_cq_cons(fp) != fp->rx_cq_cons); } /* @@ -10306,7 +10305,7 @@ bxe_init_rx_chains(struct bxe_softc *sc) struct eth_rx_bd *rx_bd; struct eth_rx_cqe_next_page *nextpg; uint16_t ring_prod, cqe_ring_prod; - int func, i, j, max_agg_queues; + int func, i, j, rcq_idx, rx_idx, rx_sge_idx, max_agg_queues; DBENTER(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET); @@ -10374,16 +10373,19 @@ bxe_init_rx_chains(struct bxe_softc *sc) /* Link the SGE Ring Pages to form SGE chain */ for (j = 0; j < NUM_RX_SGE_PAGES; j++) { - DBPRINT(sc, - (BXE_INSANE_LOAD | BXE_INSANE_RESET), - "%s(): Linking fp[%d] SGE ring[%d].\n", - __FUNCTION__, i, j); - + rx_sge_idx = ((j + 1) % NUM_RX_SGE_PAGES); sge = &fp->rx_sge_chain[j][MAX_RX_SGE_CNT]; + + DBPRINT(sc, (BXE_EXTREME_LOAD | BXE_EXTREME_RESET), + "%s(): fp[%02d].rx_sge_chain[%02d][0x%04X]=0x%jX\n", + __FUNCTION__, i, j, + (uint16_t) MAX_RX_SGE_CNT, + (uintmax_t) fp->rx_sge_chain_paddr[rx_sge_idx]); + sge->addr_hi = - htole32(U64_HI(fp->rx_sge_chain_paddr[(j + 1) % NUM_RX_SGE_PAGES])); + htole32(U64_HI(fp->rx_sge_chain_paddr[rx_sge_idx])); sge->addr_lo = - htole32(U64_LO(fp->rx_sge_chain_paddr[(j + 1) % NUM_RX_SGE_PAGES])); + htole32(U64_LO(fp->rx_sge_chain_paddr[rx_sge_idx])); } bxe_init_sge_ring_bit_mask(fp); @@ -10394,16 +10396,19 @@ bxe_init_rx_chains(struct bxe_softc *sc) /* Link the pages to form the RX BD Chain. */ for (j = 0; j < NUM_RX_PAGES; j++) { + rx_idx = ((j + 1) % NUM_RX_PAGES); rx_bd = &fp->rx_bd_chain[j][USABLE_RX_BD_PER_PAGE]; - DBPRINT(sc, (BXE_INSANE_LOAD | BXE_INSANE_RESET), - "%s(): Linking fp[%d] RX BD chain page[%d].\n", - __FUNCTION__, i, j); + DBPRINT(sc, (BXE_INFO_LOAD), + "%s(): fp[%02d].rx_bd_chain[%02d][0x%04X]=0x%jX\n", + __FUNCTION__, i, j, + (uint16_t) USABLE_RX_BD_PER_PAGE, + (uintmax_t) fp->rx_bd_chain_paddr[rx_idx]); rx_bd->addr_hi = - htole32(U64_HI(fp->rx_bd_chain_paddr[(j + 1) % NUM_RX_PAGES])); + htole32(U64_HI(fp->rx_bd_chain_paddr[rx_idx])); rx_bd->addr_lo = - htole32(U64_LO(fp->rx_bd_chain_paddr[(j + 1) % NUM_RX_PAGES])); + htole32(U64_LO(fp->rx_bd_chain_paddr[rx_idx])); } DBPRINT(sc, (BXE_INSANE_LOAD | BXE_INSANE_RESET), @@ -10412,17 +10417,20 @@ bxe_init_rx_chains(struct bxe_softc *sc) /* Link the pages to form the RX Completion Queue.*/ for (j = 0; j < NUM_RCQ_PAGES; j++) { + rcq_idx = ((j + 1) % NUM_RCQ_PAGES); nextpg = (struct eth_rx_cqe_next_page *) - &fp->rx_comp_chain[j][USABLE_RCQ_ENTRIES_PER_PAGE]; + &fp->rx_cq_chain[j][USABLE_RCQ_ENTRIES_PER_PAGE]; - DBPRINT(sc, (BXE_INSANE_LOAD | BXE_INSANE_RESET), - "%s(): Linking fp[%d] RX completion chain page[%d].\n", - __FUNCTION__, i, j); + DBPRINT(sc, (BXE_INFO_LOAD), + "%s(): fp[%02d].rx_cq_chain[%02d][0x%04X]=0x%jX\n", + __FUNCTION__, i, j, + (uint16_t) USABLE_RCQ_ENTRIES_PER_PAGE, + (uintmax_t) fp->rx_cq_chain_paddr[rcq_idx]); nextpg->addr_hi = - htole32(U64_HI(fp->rx_comp_chain_paddr[(j + 1) % NUM_RCQ_PAGES])); + htole32(U64_HI(fp->rx_cq_chain_paddr[rcq_idx])); nextpg->addr_lo = - htole32(U64_LO(fp->rx_comp_chain_paddr[(j + 1) % NUM_RCQ_PAGES])); + htole32(U64_LO(fp->rx_cq_chain_paddr[rcq_idx])); } if (TPA_ENABLED(sc)) { @@ -10432,7 +10440,8 @@ bxe_init_rx_chains(struct bxe_softc *sc) while (ring_prod < sc->rx_ring_size) { if (bxe_alloc_rx_sge(sc, fp, ring_prod) != 0) { BXE_PRINTF( - "%s(%d): Memory allocation failure! Disabling TPA for fp[%d].\n", + "%s(%d): Memory allocation failure! " + "Disabling TPA for fp[%d].\n", __FILE__, __LINE__, i); /* Cleanup already allocated elements */ @@ -10452,7 +10461,7 @@ bxe_init_rx_chains(struct bxe_softc *sc) * Allocate buffers for all the RX BDs in RX BD Chain. * Add completion queue entries at the same time. */ - fp->rx_comp_cons = ring_prod = cqe_ring_prod = 0; + fp->rx_cq_cons = ring_prod = cqe_ring_prod = 0; DBRUN(fp->free_rx_bd = USABLE_RX_BD); while (ring_prod < sc->rx_ring_size) { @@ -10469,9 +10478,9 @@ bxe_init_rx_chains(struct bxe_softc *sc) /* Update the driver's copy of the producer indices. */ fp->rx_bd_prod = ring_prod; - fp->rx_comp_prod = cqe_ring_prod; + fp->rx_cq_prod = cqe_ring_prod; /* - * fp->rx_comp_prod = + * fp->rx_cq_prod = * (uint16_t)min(NUM_RCQ_PAGES*TOTAL_RCQ_ENTRIES_PER_PAGE, * cqe_ring_prod); */ @@ -10485,8 +10494,8 @@ bxe_init_rx_chains(struct bxe_softc *sc) BUS_DMASYNC_PREWRITE); for (j = 0; j < NUM_RCQ_PAGES; j++) - bus_dmamap_sync(fp->rx_comp_chain_tag, - fp->rx_comp_chain_map[j], BUS_DMASYNC_PREREAD | + bus_dmamap_sync(fp->rx_cq_chain_tag, + fp->rx_cq_chain_map[j], BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); /* @@ -10494,7 +10503,7 @@ bxe_init_rx_chains(struct bxe_softc *sc) * Warning! this will generate an interrupt (to the TSTORM). * This must only be done when the controller is initialized. */ - bxe_update_rx_prod(sc, fp, ring_prod, fp->rx_comp_prod, + bxe_update_rx_prod(sc, fp, ring_prod, fp->rx_cq_prod, fp->rx_sge_prod); if (i != 0) @@ -10502,10 +10511,10 @@ bxe_init_rx_chains(struct bxe_softc *sc) REG_WR(sc, BAR_USTORM_INTMEM + USTORM_MEM_WORKAROUND_ADDRESS_OFFSET(func), - U64_LO(fp->rx_comp_chain_paddr[0])); + U64_LO(fp->rx_cq_chain_paddr[0])); REG_WR(sc, BAR_USTORM_INTMEM + USTORM_MEM_WORKAROUND_ADDRESS_OFFSET(func) + 4, - U64_HI(fp->rx_comp_chain_paddr[0])); + U64_HI(fp->rx_cq_chain_paddr[0])); } DBEXIT(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET); @@ -10521,7 +10530,7 @@ static void bxe_init_tx_chains(struct bxe_softc *sc) { struct bxe_fastpath *fp; - struct eth_tx_next_bd *tx_bd; + struct eth_tx_next_bd *tx_n_bd; int i, j; DBENTER(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET); @@ -10532,17 +10541,17 @@ bxe_init_tx_chains(struct bxe_softc *sc) "%s(): Linking fp[%d] TX chain pages.\n", __FUNCTION__, i); for (j = 0; j < NUM_TX_PAGES; j++) { - tx_bd = + tx_n_bd = &fp->tx_bd_chain[j][USABLE_TX_BD_PER_PAGE].next_bd; DBPRINT(sc, (BXE_INSANE_LOAD | BXE_INSANE_RESET), "%s(): Linking fp[%d] TX BD chain page[%d].\n", __FUNCTION__, i, j); - tx_bd->addr_hi = + tx_n_bd->addr_hi = htole32(U64_HI(fp->tx_bd_chain_paddr[(j + 1) % NUM_TX_PAGES])); - tx_bd->addr_lo = + tx_n_bd->addr_lo = htole32(U64_LO(fp->tx_bd_chain_paddr[(j + 1) % NUM_TX_PAGES])); } @@ -10609,8 +10618,8 @@ bxe_free_rx_chains(struct bxe_softc *sc) /* Clear each RX completion queue page. */ for (j = 0; j < NUM_RCQ_PAGES; j++) { - if (fp->rx_comp_chain[j] != NULL) - bzero((char *)fp->rx_comp_chain[j], + if (fp->rx_cq_chain[j] != NULL) + bzero((char *)fp->rx_cq_chain[j], BXE_RX_CHAIN_PAGE_SZ); } @@ -11190,14 +11199,14 @@ bxe_init_internal_func(struct bxe_softc for (i = 0; i < sc->num_queues; i++) { fp = &sc->fp[i]; nextpg = (struct eth_rx_cqe_next_page *) - &fp->rx_comp_chain[i][USABLE_RCQ_ENTRIES_PER_PAGE]; + &fp->rx_cq_chain[i][USABLE_RCQ_ENTRIES_PER_PAGE]; /* Program the completion queue address. */ REG_WR(sc, BAR_USTORM_INTMEM + USTORM_CQE_PAGE_BASE_OFFSET(port, fp->cl_id), - U64_LO(fp->rx_comp_chain_paddr[0])); + U64_LO(fp->rx_cq_chain_paddr[0])); REG_WR(sc, BAR_USTORM_INTMEM + USTORM_CQE_PAGE_BASE_OFFSET(port, fp->cl_id) + 4, - U64_HI(fp->rx_comp_chain_paddr[0])); + U64_HI(fp->rx_cq_chain_paddr[0])); /* Next page */ REG_WR(sc, BAR_USTORM_INTMEM + USTORM_CQE_PAGE_NEXT_OFFSET(port, @@ -12806,22 +12815,22 @@ bxe_dma_free(struct bxe_softc *sc) * Free, unmap and destroy all RX CQ * chain pages. */ - if (fp->rx_comp_chain_tag != NULL) { + if (fp->rx_cq_chain_tag != NULL) { for (j = 0; j < NUM_RCQ_PAGES; j++ ) { - if (fp->rx_comp_chain_map[j] != NULL) { - if (fp->rx_comp_chain[j] != NULL) - bus_dmamem_free(fp->rx_comp_chain_tag, - fp->rx_comp_chain[j], - fp->rx_comp_chain_map[j]); - - bus_dmamap_unload(fp->rx_comp_chain_tag, - fp->rx_comp_chain_map[j]); - bus_dmamap_destroy(fp->rx_comp_chain_tag, - fp->rx_comp_chain_map[j]); + if (fp->rx_cq_chain_map[j] != NULL) { + if (fp->rx_cq_chain[j] != NULL) + bus_dmamem_free(fp->rx_cq_chain_tag, + fp->rx_cq_chain[j], + fp->rx_cq_chain_map[j]); + + bus_dmamap_unload(fp->rx_cq_chain_tag, + fp->rx_cq_chain_map[j]); + bus_dmamap_destroy(fp->rx_cq_chain_tag, + fp->rx_cq_chain_map[j]); } } - bus_dma_tag_destroy(fp->rx_comp_chain_tag); + bus_dma_tag_destroy(fp->rx_cq_chain_tag); } /* Unload and destroy the TX mbuf maps. */ @@ -13093,7 +13102,7 @@ bxe_dma_alloc(device_t dev) NULL, /* filter f() */ NULL, /* filter f() arg */ MAXBSIZE, /* max map for this tag */ - BUS_SPACE_UNRESTRICTED, /* #of discontinuities */ + BUS_SPACE_UNRESTRICTED, /* # of discontinuities */ BUS_SPACE_MAXSIZE_32BIT, /* max seg size */ 0, /* flags */ NULL, /* lock f() */ @@ -13115,9 +13124,9 @@ bxe_dma_alloc(device_t dev) (long unsigned int)sizeof(struct bxe_fastpath)); /* - * Create a DMA tag for the status block, allocate and clear the - * memory, map the memory into DMA space, and fetch the physical - * address of the block. + * Create a DMA tag for the status block, allocate and + * clear the memory, map the memory into DMA space, and + * fetch the physical address of the block. */ if (bus_dma_tag_create(sc->parent_tag, @@ -13266,10 +13275,11 @@ bxe_dma_alloc(device_t dev) /* Create DMA maps for each the TX mbuf cluster(ext buf). */ for (j = 0; j < TOTAL_TX_BD; j++) { - if (bus_dmamap_create(fp->tx_mbuf_tag, BUS_DMA_NOWAIT, + if (bus_dmamap_create(fp->tx_mbuf_tag, + BUS_DMA_NOWAIT, &(fp->tx_mbuf_map[j]))) { - BXE_PRINTF( - "%s(%d): Unable to create fp[%d] TX mbuf DMA map!\n", + BXE_PRINTF("%s(%d): Unable to create fp[%d] " + "TX mbuf DMA map!\n", __FILE__, __LINE__, i); rc = ENOMEM; goto bxe_dma_alloc_exit; @@ -13363,8 +13373,8 @@ bxe_dma_alloc(device_t dev) /* Create DMA maps for the RX mbuf clusters. */ for (j = 0; j < TOTAL_RX_BD; j++) { - if (bus_dmamap_create(fp->rx_mbuf_tag, BUS_DMA_NOWAIT, - &(fp->rx_mbuf_map[j]))) { + if (bus_dmamap_create(fp->rx_mbuf_tag, + BUS_DMA_NOWAIT, &(fp->rx_mbuf_map[j]))) { BXE_PRINTF( "%s(%d): Unable to create fp[%d] RX mbuf DMA map!\n", __FILE__, __LINE__, i); @@ -13392,7 +13402,7 @@ bxe_dma_alloc(device_t dev) 0, /* flags */ NULL, /* lock f() */ NULL, /* lock f() arg */ - &fp->rx_comp_chain_tag)) { + &fp->rx_cq_chain_tag)) { BXE_PRINTF( "%s(%d): Could not allocate fp[%d] RX Completion Queue DMA tag!\n", __FILE__, __LINE__, i); @@ -13401,9 +13411,9 @@ bxe_dma_alloc(device_t dev) } for (j = 0; j < NUM_RCQ_PAGES; j++) { - if (bus_dmamem_alloc(fp->rx_comp_chain_tag, - (void **)&fp->rx_comp_chain[j], BUS_DMA_NOWAIT, - &fp->rx_comp_chain_map[j])) { + if (bus_dmamem_alloc(fp->rx_cq_chain_tag, + (void **)&fp->rx_cq_chain[j], BUS_DMA_NOWAIT, + &fp->rx_cq_chain_map[j])) { BXE_PRINTF( "%s(%d): Could not allocate fp[%d] RX Completion Queue DMA memory!\n", __FILE__, __LINE__, i); @@ -13411,11 +13421,11 @@ bxe_dma_alloc(device_t dev) goto bxe_dma_alloc_exit; } - bzero((char *)fp->rx_comp_chain[j], + bzero((char *)fp->rx_cq_chain[j], BXE_RX_CHAIN_PAGE_SZ); - error = bus_dmamap_load(fp->rx_comp_chain_tag, - fp->rx_comp_chain_map[j], fp->rx_comp_chain[j], + error = bus_dmamap_load(fp->rx_cq_chain_tag, + fp->rx_cq_chain_map[j], fp->rx_cq_chain[j], BXE_RX_CHAIN_PAGE_SZ, bxe_dma_map_addr, &busaddr, BUS_DMA_NOWAIT); @@ -13431,17 +13441,17 @@ bxe_dma_alloc(device_t dev) * Physical address of each page in the RX * Completion Chain. */ - fp->rx_comp_chain_paddr[j] = busaddr; + fp->rx_cq_chain_paddr[j] = busaddr; DBPRINT(sc, (BXE_EXTREME_LOAD | BXE_EXTREME_RESET), - "%s(): fp[%d]->rx_comp_chain_paddr[%d] = 0x%jX\n", + "%s(): fp[%d]->rx_cq_chain_paddr[%d] = 0x%jX\n", __FUNCTION__, i, j, (uintmax_t)busaddr); } if (TPA_ENABLED(sc)) { int tpa_pool_max = CHIP_IS_E1H(sc) ? - ETH_MAX_AGGREGATION_QUEUES_E1H : - ETH_MAX_AGGREGATION_QUEUES_E1; + ETH_MAX_AGGREGATION_QUEUES_E1H : + ETH_MAX_AGGREGATION_QUEUES_E1; /* * Create a DMA tag for the RX SGE Ring, @@ -14213,6 +14223,7 @@ bxe_ifmedia_upd(struct ifnet *ifp) ifm = &sc->bxe_ifmedia; rc = 0; + /* This is an Ethernet controller. */ if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER) { rc = EINVAL; @@ -14672,27 +14683,27 @@ bxe_tpa_stop_exit: */ static __inline void bxe_update_rx_prod(struct bxe_softc *sc, struct bxe_fastpath *fp, - uint16_t bd_prod, uint16_t rx_comp_prod, uint16_t rx_sge_prod) + uint16_t bd_prod, uint16_t rx_cq_prod, uint16_t sge_prod) { volatile struct ustorm_eth_rx_producers rx_prods = {0}; int i; /* Update producers. */ - rx_prods.bd_prod = bd_prod;/* htole16(bd_prod);*/ - rx_prods.cqe_prod = rx_comp_prod;/*htole16(rx_comp_prod);*/ - rx_prods.sge_prod = rx_sge_prod;/*htole16(rx_sge_prod);*/ + rx_prods.bd_prod = bd_prod; + rx_prods.cqe_prod = rx_cq_prod; + rx_prods.sge_prod = sge_prod; wmb(); for (i = 0; i < sizeof(struct ustorm_eth_rx_producers) / 4; i++){ REG_WR(sc, BAR_USTORM_INTMEM + USTORM_RX_PRODS_OFFSET(BP_PORT(sc), fp->cl_id) + i * 4, - ((volatile uint32_t *)&rx_prods)[i]); + ((volatile uint32_t *) &rx_prods)[i]); } - DBPRINT(sc, BXE_EXTREME_RECV, "%s(): Wrote fp[%d] bd_prod = 0x%04X, " - "cqe_prod = 0x%04X, sge_prod = 0x%04X\n", __FUNCTION__, fp->index, - bd_prod, rx_comp_prod, rx_sge_prod); + DBPRINT(sc, BXE_EXTREME_RECV, "%s(%d): Wrote fp[%02d] bd_prod = 0x%04X, " + "rx_cq_prod = 0x%04X, sge_prod = 0x%04X\n", __FUNCTION__, curcpu, + fp->index, bd_prod, rx_cq_prod, sge_prod); } /* @@ -14706,32 +14717,38 @@ bxe_rxeof(struct bxe_fastpath *fp) { struct bxe_softc *sc; struct ifnet *ifp; - uint16_t bd_cons, bd_prod, bd_prod_fw; - uint16_t hw_comp_cons_idx, sw_comp_cons_idx, sw_comp_prod; - uint16_t comp_ring_cons; + uint16_t rx_bd_cons, rx_bd_cons_idx; + uint16_t rx_bd_prod, rx_bd_prod_idx; + uint16_t rx_cq_cons, rx_cq_cons_idx; + uint16_t rx_cq_prod, rx_cq_cons_sb; #ifdef BXE_DEBUG unsigned long rx_pkts = 0; #endif + sc = fp->sc; ifp = sc->bxe_ifp; DBENTER(BXE_EXTREME_RECV); - /* Get the sb's view of the RX completion consumer index. */ - hw_comp_cons_idx = le16toh(*fp->rx_cons_sb); - if ((hw_comp_cons_idx & USABLE_RCQ_ENTRIES_PER_PAGE) == - USABLE_RCQ_ENTRIES_PER_PAGE) - hw_comp_cons_idx++; - /* Get working copies of the driver's view of the RX indices. */ - bd_cons = fp->rx_bd_cons; - bd_prod = bd_prod_fw = fp->rx_bd_prod; - sw_comp_cons_idx = fp->rx_comp_cons; - sw_comp_prod = fp->rx_comp_prod; + + /* Get the status block's view of the RX completion consumer index. */ + rx_cq_cons_sb = bxe_rx_cq_cons(fp); + + /* + * Get working copies of the driver's view of the + * RX indices. These are 16 bit values that are + * expected to increment from from 0 to 65535 + * and then wrap-around to 0 again. + */ + rx_bd_cons = fp->rx_bd_cons; + rx_bd_prod = fp->rx_bd_prod; + rx_cq_cons = fp->rx_cq_cons; + rx_cq_prod = fp->rx_cq_prod; DBPRINT(sc, (BXE_EXTREME_RECV), - "%s(): fp[%d], bd_cons = 0x%04X, bd_prod = 0x%04X, " - "sw_comp_cons = 0x%04X, sw_comp_prod = 0x%04X\n", __FUNCTION__, - fp->index, bd_cons, bd_prod, sw_comp_cons_idx, sw_comp_prod); + "%s(%d): BEFORE: fp[%d], rx_bd_cons = 0x%04X, rx_bd_prod = 0x%04X, " + "rx_cq_cons_sw = 0x%04X, rx_cq_prod_sw = 0x%04X\n", __FUNCTION__, + curcpu, fp->index, rx_bd_cons, rx_bd_prod, rx_cq_cons, rx_cq_prod); /* * Memory barrier to prevent speculative reads of the RX buffer @@ -14743,20 +14760,25 @@ bxe_rxeof(struct bxe_fastpath *fp) * Scan through the receive chain as long * as there is work to do. */ - while (sw_comp_cons_idx != hw_comp_cons_idx) { + while (rx_cq_cons != rx_cq_cons_sb) { struct mbuf *m; union eth_rx_cqe *cqe; uint8_t cqe_fp_flags; uint16_t len, pad; - /* Convert the indices to an actual rx_bd index. */ - comp_ring_cons = RCQ_ENTRY(sw_comp_cons_idx); - bd_prod = RX_BD(bd_prod); - bd_cons = RX_BD(bd_cons); + /* + * Convert the 16 bit indices used by hardware + * into values that map to the arrays used by + * the driver (i.e. an index). + */ + rx_cq_cons_idx = RCQ_ENTRY(rx_cq_cons); + rx_bd_prod_idx = RX_BD(rx_bd_prod); + rx_bd_cons_idx = RX_BD(rx_bd_cons); wmb(); + /* Fetch the cookie. */ - cqe = (union eth_rx_cqe*) - &fp->rx_comp_chain[RCQ_PAGE(comp_ring_cons)][RCQ_IDX(comp_ring_cons)]; + cqe = (union eth_rx_cqe *) + &fp->rx_cq_chain[RCQ_PAGE(rx_cq_cons_idx)][RCQ_IDX(rx_cq_cons_idx)]; cqe_fp_flags = cqe->fast_path_cqe.type_error_flags; #ifdef BXE_DEBUG @@ -14769,9 +14791,10 @@ bxe_rxeof(struct bxe_fastpath *fp) } #endif - DBRUNIF((cqe_fp_flags == 0), BXE_PRINTF( - "%s(): CQE received with null type/error flags!\n", - __FUNCTION__)); + DBRUNIF((cqe_fp_flags == 0), + BXE_PRINTF("%s(): CQE received with null " + "type/error flags!\n", __FUNCTION__); + bxe_dump_cqe(fp, rx_cq_cons_idx, cqe)); /* Check the CQE type for slowpath or fastpath completion. */ if (__predict_false(CQE_TYPE(cqe_fp_flags) == @@ -14803,8 +14826,8 @@ bxe_rxeof(struct bxe_fastpath *fp) * Check if a TPA aggregation has been started. */ if (TPA_TYPE(cqe_fp_flags) == TPA_TYPE_START) { - bxe_tpa_start(fp, queue, bd_cons, - bd_prod); + bxe_tpa_start(fp, queue, + rx_bd_cons_idx, rx_bd_prod_idx); goto bxe_rxeof_next_rx; } @@ -14826,7 +14849,7 @@ bxe_rxeof(struct bxe_fastpath *fp) * the frame up. */ bxe_tpa_stop(sc, fp, queue, pad, len, - cqe, comp_ring_cons); + cqe, rx_cq_cons_idx); bxe_update_sge_prod(fp, &cqe->fast_path_cqe); goto bxe_rxeof_next_cqe; @@ -14834,8 +14857,8 @@ bxe_rxeof(struct bxe_fastpath *fp) } /* Remove the mbuf from the RX chain. */ - m = fp->rx_mbuf_ptr[bd_cons]; - fp->rx_mbuf_ptr[bd_cons] = NULL; + m = fp->rx_mbuf_ptr[rx_bd_cons_idx]; + fp->rx_mbuf_ptr[rx_bd_cons_idx] = NULL; DBRUN(fp->free_rx_bd++); DBRUNIF((fp->free_rx_bd > USABLE_RX_BD), @@ -14845,9 +14868,10 @@ bxe_rxeof(struct bxe_fastpath *fp) /* Unmap the mbuf from DMA space. */ bus_dmamap_sync(fp->rx_mbuf_tag, - fp->rx_mbuf_map[bd_cons], BUS_DMASYNC_POSTREAD); + fp->rx_mbuf_map[rx_bd_cons_idx], + BUS_DMASYNC_POSTREAD); bus_dmamap_unload(fp->rx_mbuf_tag, - fp->rx_mbuf_map[bd_cons]); + fp->rx_mbuf_map[rx_bd_cons_idx]); /* Check if the received frame has any errors. */ if (__predict_false(cqe_fp_flags & @@ -14860,11 +14884,13 @@ bxe_rxeof(struct bxe_fastpath *fp) fp->soft_rx_errors++; /* Reuse the mbuf for a new frame. */ - if (bxe_get_buf(fp, m, bd_prod)) { + if (bxe_get_buf(fp, m, rx_bd_prod_idx)) { DBPRINT(sc, BXE_FATAL, "%s(): Can't reuse RX mbuf!\n", __FUNCTION__); DBRUN(bxe_breakpoint(sc)); + + /* ToDo: Find alterntive to panic(). */ panic("bxe%d: Can't reuse RX mbuf!\n", sc->bxe_unit); } @@ -14885,7 +14911,8 @@ bxe_rxeof(struct bxe_fastpath *fp) */ /* Allocate a new mbuf for the receive chain. */ - if (__predict_false(bxe_get_buf(fp, NULL, bd_prod))) { + if (__predict_false(bxe_get_buf(fp, + NULL, rx_bd_prod_idx))) { /* * Drop the current frame if we can't get * a new mbuf. @@ -14897,12 +14924,11 @@ bxe_rxeof(struct bxe_fastpath *fp) * receive chain. */ if (__predict_false(bxe_get_buf(fp, m, - bd_prod))) { + rx_bd_prod_idx))) { /* This is really bad! */ DBPRINT(sc, BXE_FATAL, "%s(): Can't reuse RX mbuf!\n", __FUNCTION__); - DBRUN(bxe_breakpoint(sc)); /* ToDo: Find alterntive to panic(). */ @@ -14980,12 +15006,12 @@ bxe_rxeof(struct bxe_fastpath *fp) } /* Last chance to check for problems. */ - DBRUN(bxe_validate_rx_packet(fp, comp_ring_cons, cqe, - m)); + DBRUN(bxe_validate_rx_packet(fp, rx_cq_cons, cqe, m)); /* Pass the mbuf off to the upper layers. */ ifp->if_ipackets++; + /* ToDo: Any potential locking issues here? */ /* Pass the frame to the stack. */ (*ifp->if_input)(ifp, m); @@ -14993,14 +15019,13 @@ bxe_rxeof(struct bxe_fastpath *fp) } bxe_rxeof_next_rx: - bd_prod = NEXT_RX_BD(bd_prod); - bd_prod_fw = NEXT_RX_BD(bd_prod_fw); - bd_cons = NEXT_RX_BD(bd_cons); + rx_bd_prod = NEXT_RX_BD(rx_bd_prod); + rx_bd_cons = NEXT_RX_BD(rx_bd_cons); DBRUN(rx_pkts++); bxe_rxeof_next_cqe: - sw_comp_prod = NEXT_RCQ_IDX(sw_comp_prod); - sw_comp_cons_idx = NEXT_RCQ_IDX(sw_comp_cons_idx); + rx_cq_prod = NEXT_RCQ_IDX(rx_cq_prod); + rx_cq_cons = NEXT_RCQ_IDX(rx_cq_cons); /* * Memory barrier to prevent speculative reads of the RX buffer @@ -15010,18 +15035,19 @@ bxe_rxeof_next_cqe: } /* Update the driver copy of the fastpath indices. */ - fp->rx_bd_cons = bd_cons; - fp->rx_bd_prod = bd_prod_fw; - fp->rx_comp_cons = sw_comp_cons_idx; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 22:50: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 3655E106566B; Thu, 31 Mar 2011 22:50:56 +0000 (UTC) (envelope-from davidch@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 09E518FC0A; Thu, 31 Mar 2011 22:50:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VMotXr025178; Thu, 31 Mar 2011 22:50:55 GMT (envelope-from davidch@svn.freebsd.org) Received: (from davidch@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VMotq8025176; Thu, 31 Mar 2011 22:50:55 GMT (envelope-from davidch@svn.freebsd.org) Message-Id: <201103312250.p2VMotq8025176@svn.freebsd.org> From: David Christensen Date: Thu, 31 Mar 2011 22:50: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: r220230 - head/sys/dev/bxe 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, 31 Mar 2011 22:50:56 -0000 Author: davidch Date: Thu Mar 31 22:50:55 2011 New Revision: 220230 URL: http://svn.freebsd.org/changeset/base/220230 Log: - Fixed build problem when not useing BXE_DEBUG. MFC after: One week. Modified: head/sys/dev/bxe/if_bxe.c Modified: head/sys/dev/bxe/if_bxe.c ============================================================================== --- head/sys/dev/bxe/if_bxe.c Thu Mar 31 22:40:44 2011 (r220229) +++ head/sys/dev/bxe/if_bxe.c Thu Mar 31 22:50:55 2011 (r220230) @@ -15627,13 +15627,6 @@ bxe_add_sysctls(struct bxe_softc *sc) SYSCTL_CHILDREN(device_get_sysctl_tree(sc->bxe_dev)); struct bxe_eth_stats *estats = &sc->eth_stats; - struct sysctl_oid *queue_node; - struct sysctl_oid_list *queue_list; - -#define QUEUE_NAME_LEN 32 - char namebuf[QUEUE_NAME_LEN]; - - SYSCTL_ADD_UINT(ctx, children, OID_AUTO, "estats_total_bytes_received_hi", CTLFLAG_RD, &estats->total_bytes_received_hi, @@ -15747,28 +15740,36 @@ bxe_add_sysctls(struct bxe_softc *sc) CTLFLAG_RD, &sc->mbuf_alloc_failed, 0, "mbuf cluster allocation failures"); - for (int i = 0; i < sc->num_queues; i++) { - struct bxe_fastpath *fp = &sc->fp[i]; - snprintf(namebuf, QUEUE_NAME_LEN, "fp[%02d]", i); - - queue_node = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, - namebuf, CTLFLAG_RD, NULL, "Queue Name"); - queue_list = SYSCTL_CHILDREN(queue_node); - - SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, - "mbuf_alloc_failed", - CTLFLAG_RD, &fp->mbuf_alloc_failed, - "Mbuf allocation failures"); - - SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, - "mbuf_defrag_attempts", - CTLFLAG_RD, &fp->mbuf_defrag_attempts, - "Mbuf defrag attempts"); - - SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, - "mbuf_defrag_successes", - CTLFLAG_RD, &fp->mbuf_defrag_successes, - "Mbuf defrag successes"); + do() { +#define QUEUE_NAME_LEN 32 + char namebuf[QUEUE_NAME_LEN]; + struct sysctl_oid *queue_node; + struct sysctl_oid_list *queue_list; + + for (int i = 0; i < sc->num_queues; i++) { + struct bxe_fastpath *fp = &sc->fp[i]; + snprintf(namebuf, QUEUE_NAME_LEN, "fp[%02d]", i); + + queue_node = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, + namebuf, CTLFLAG_RD, NULL, "Queue Name"); + queue_list = SYSCTL_CHILDREN(queue_node); + + SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, + "mbuf_alloc_failed", + CTLFLAG_RD, &fp->mbuf_alloc_failed, + "Mbuf allocation failures"); + + SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, + "mbuf_defrag_attempts", + CTLFLAG_RD, &fp->mbuf_defrag_attempts, + "Mbuf defrag attempts"); + + SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, + "mbuf_defrag_successes", + CTLFLAG_RD, &fp->mbuf_defrag_successes, + "Mbuf defrag successes"); + } + } SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "driver_state", From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 00:25:32 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 BEC95106566B; Fri, 1 Apr 2011 00:25:32 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AE9D68FC13; Fri, 1 Apr 2011 00:25:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p310PWHq027053; Fri, 1 Apr 2011 00:25:32 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p310PWmC027051; Fri, 1 Apr 2011 00:25:32 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201104010025.p310PWmC027051@svn.freebsd.org> From: Navdeep Parhar Date: Fri, 1 Apr 2011 00:25: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: r220231 - in head/sys/modules/cxgbe: . if_cxgbe 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, 01 Apr 2011 00:25:32 -0000 Author: np Date: Fri Apr 1 00:25:32 2011 New Revision: 220231 URL: http://svn.freebsd.org/changeset/base/220231 Log: Allow multiple modules within sys/modules/cxgbe. The first one is if_cxgbe. MFC after: 3 days Added: head/sys/modules/cxgbe/if_cxgbe/ head/sys/modules/cxgbe/if_cxgbe/Makefile - copied, changed from r220221, head/sys/modules/cxgbe/Makefile Replaced: head/sys/modules/cxgbe/Makefile (contents, props changed) Added: head/sys/modules/cxgbe/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/modules/cxgbe/Makefile Fri Apr 1 00:25:32 2011 (r220231) @@ -0,0 +1,7 @@ +# +# $FreeBSD$ +# + +SUBDIR = if_cxgbe + +.include Copied and modified: head/sys/modules/cxgbe/if_cxgbe/Makefile (from r220221, head/sys/modules/cxgbe/Makefile) ============================================================================== --- head/sys/modules/cxgbe/Makefile Thu Mar 31 18:35:44 2011 (r220221, copy source) +++ head/sys/modules/cxgbe/if_cxgbe/Makefile Fri Apr 1 00:25:32 2011 (r220231) @@ -2,7 +2,7 @@ # $FreeBSD$ # -CXGBE = ${.CURDIR}/../../dev/cxgbe +CXGBE = ${.CURDIR}/../../../dev/cxgbe .PATH: ${CXGBE} ${CXGBE}/common KMOD = if_cxgbe @@ -11,6 +11,6 @@ SRCS+= t4_hw.c SRCS+= device_if.h bus_if.h pci_if.h SRCS+= opt_inet.h -CFLAGS+= -g -I${CXGBE} +CFLAGS+= -I${CXGBE} .include From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 00:40: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 32759106564A; Fri, 1 Apr 2011 00:40:25 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 22D348FC0A; Fri, 1 Apr 2011 00:40:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p310ePb7027409; Fri, 1 Apr 2011 00:40:25 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p310ePWM027405; Fri, 1 Apr 2011 00:40:25 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201104010040.p310ePWM027405@svn.freebsd.org> From: Navdeep Parhar Date: Fri, 1 Apr 2011 00:40:24 +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: r220232 - in head/sys/dev/cxgbe: . common 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, 01 Apr 2011 00:40:25 -0000 Author: np Date: Fri Apr 1 00:40:24 2011 New Revision: 220232 URL: http://svn.freebsd.org/changeset/base/220232 Log: Update header and related code for firmware 1.3.8 MFC after: 3 days Modified: head/sys/dev/cxgbe/common/common.h head/sys/dev/cxgbe/common/t4fw_interface.h head/sys/dev/cxgbe/t4_main.c Modified: head/sys/dev/cxgbe/common/common.h ============================================================================== --- head/sys/dev/cxgbe/common/common.h Fri Apr 1 00:25:32 2011 (r220231) +++ head/sys/dev/cxgbe/common/common.h Fri Apr 1 00:40:24 2011 (r220232) @@ -54,7 +54,7 @@ enum { #define FW_VERSION_MAJOR 1 #define FW_VERSION_MINOR 3 -#define FW_VERSION_MICRO 0 +#define FW_VERSION_MICRO 8 struct port_stats { u64 tx_octets; /* total # of octets in good frames */ Modified: head/sys/dev/cxgbe/common/t4fw_interface.h ============================================================================== --- head/sys/dev/cxgbe/common/t4fw_interface.h Fri Apr 1 00:25:32 2011 (r220231) +++ head/sys/dev/cxgbe/common/t4fw_interface.h Fri Apr 1 00:40:24 2011 (r220232) @@ -47,7 +47,7 @@ enum fw_retval { FW_ENOSYS = 38, /* functionality not implemented */ FW_EPROTO = 71, /* protocol error */ FW_ETIMEDOUT = 110, /* timeout */ - FW_TIMEDOUT = 110, /* timeout */ + FW_EINPROGRESS = 115, /* fw internal */ FW_SCSI_ABORT_REQUESTED = 128, /* */ FW_SCSI_ABORT_TIMEDOUT = 129, /* */ FW_SCSI_ABORTED = 130, /* */ @@ -3934,13 +3934,11 @@ enum fw_port_cap { FW_PORT_CAP_FC_RX = 0x0040, FW_PORT_CAP_FC_TX = 0x0080, FW_PORT_CAP_ANEG = 0x0100, - FW_PORT_CAP_MDI_0 = 0x0200, - FW_PORT_CAP_MDI_1 = 0x0400, - FW_PORT_CAP_BEAN = 0x0800, - FW_PORT_CAP_PMA_LPBK = 0x1000, - FW_PORT_CAP_PCS_LPBK = 0x2000, - FW_PORT_CAP_PHYXS_LPBK = 0x4000, - FW_PORT_CAP_FAR_END_LPBK = 0x8000, + FW_PORT_CAP_MDIX = 0x0200, + FW_PORT_CAP_MDIAUTO = 0x0400, + FW_PORT_CAP_FEC = 0x0800, + FW_PORT_CAP_TECHKR = 0x1000, + FW_PORT_CAP_TECHKX4 = 0x2000, }; #define S_FW_PORT_CAP_SPEED 0 @@ -3955,6 +3953,12 @@ enum fw_port_cap { #define G_FW_PORT_CAP_FC(x) \ (((x) >> S_FW_PORT_CAP_FC) & M_FW_PORT_CAP_FC) +#define S_FW_PORT_CAP_ANEG 8 +#define M_FW_PORT_CAP_ANEG 0x1 +#define V_FW_PORT_CAP_ANEG(x) ((x) << S_FW_PORT_CAP_ANEG) +#define G_FW_PORT_CAP_ANEG(x) \ + (((x) >> S_FW_PORT_CAP_ANEG) & M_FW_PORT_CAP_ANEG) + enum fw_port_mdi { FW_PORT_CAP_MDI_UNCHANGED, FW_PORT_CAP_MDI_AUTO, @@ -4253,16 +4257,16 @@ enum fw_port_type { /* These are read from module's EEPROM and determined once the module is inserted. */ enum fw_port_module_type { - FW_PORT_MOD_TYPE_NA, - FW_PORT_MOD_TYPE_LR = 0x1, - FW_PORT_MOD_TYPE_SR = 0x2, - FW_PORT_MOD_TYPE_ER = 0x3, - FW_PORT_MOD_TYPE_TWINAX_PASSIVE = 0x4, - FW_PORT_MOD_TYPE_TWINAX_ACTIVE = 0x5, - - FW_PORT_MOD_TYPE_LRM = 0x6, - - FW_PORT_MOD_TYPE_NONE = M_FW_PORT_CMD_MODTYPE + FW_PORT_MOD_TYPE_NA = 0x0, + FW_PORT_MOD_TYPE_LR = 0x1, + FW_PORT_MOD_TYPE_SR = 0x2, + FW_PORT_MOD_TYPE_ER = 0x3, + FW_PORT_MOD_TYPE_TWINAX_PASSIVE = 0x4, + FW_PORT_MOD_TYPE_TWINAX_ACTIVE = 0x5, + FW_PORT_MOD_TYPE_LRM = 0x6, + FW_PORT_MOD_TYPE_UNKNOWN = M_FW_PORT_CMD_MODTYPE - 2, + FW_PORT_MOD_TYPE_NOTSUPPORTED = M_FW_PORT_CMD_MODTYPE - 1, + FW_PORT_MOD_TYPE_NONE = M_FW_PORT_CMD_MODTYPE }; /* used by FW and tools may use this to generate VPD */ Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Fri Apr 1 00:25:32 2011 (r220231) +++ head/sys/dev/cxgbe/t4_main.c Fri Apr 1 00:40:24 2011 (r220232) @@ -2748,11 +2748,15 @@ t4_os_portmod_changed(const struct adapt { struct port_info *pi = sc->port[idx]; static const char *mod_str[] = { - NULL, "LR", "SR", "ER", "TWINAX", "active TWINAX" + NULL, "LR", "SR", "ER", "TWINAX", "active TWINAX", "LRM" }; if (pi->mod_type == FW_PORT_MOD_TYPE_NONE) if_printf(pi->ifp, "transceiver unplugged.\n"); + else if (pi->mod_type == FW_PORT_MOD_TYPE_UNKNOWN) + if_printf(pi->ifp, "unknown transceiver inserted.\n"); + else if (pi->mod_type == FW_PORT_MOD_TYPE_NOTSUPPORTED) + if_printf(pi->ifp, "unsupported transceiver inserted.\n"); else if (pi->mod_type > 0 && pi->mod_type < ARRAY_SIZE(mod_str)) { if_printf(pi->ifp, "%s transceiver inserted.\n", mod_str[pi->mod_type]); From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 01:13: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 9A80A106564A; Fri, 1 Apr 2011 01:13:30 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8C1FC8FC0C; Fri, 1 Apr 2011 01:13:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p311DULS028117; Fri, 1 Apr 2011 01:13:30 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p311DUBx028115; Fri, 1 Apr 2011 01:13:30 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201104010113.p311DUBx028115@svn.freebsd.org> From: Ed Maste Date: Fri, 1 Apr 2011 01:13:30 +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: r220233 - head/share/examples 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, 01 Apr 2011 01:13:30 -0000 Author: emaste Date: Fri Apr 1 01:13:30 2011 New Revision: 220233 URL: http://svn.freebsd.org/changeset/base/220233 Log: Unbreak installworld after r220205. Noticed by: np Pointy hat to: emaste Modified: head/share/examples/Makefile Modified: head/share/examples/Makefile ============================================================================== --- head/share/examples/Makefile Fri Apr 1 00:40:24 2011 (r220232) +++ head/share/examples/Makefile Fri Apr 1 01:13:30 2011 (r220233) @@ -99,7 +99,7 @@ XFILES= BSD_daemon/FreeBSD.pfa \ kld/firmware/fwconsumer/Makefile \ kld/firmware/fwconsumer/fw_consumer.c \ kld/firmware/fwimage/Makefile \ - kld/firmware/fwimage/firmware.img \ + kld/firmware/fwimage/firmware.img.in \ kld/khelp/Makefile \ kld/khelp/README \ kld/khelp/h_example.c \ From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 01:30: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 86A1C106564A; Fri, 1 Apr 2011 01:30:21 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 78CB08FC0A; Fri, 1 Apr 2011 01:30:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p311UL3Z028468; Fri, 1 Apr 2011 01:30:21 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p311ULsE028466; Fri, 1 Apr 2011 01:30:21 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201104010130.p311ULsE028466@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 1 Apr 2011 01:30:21 +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: r220234 - head/sys/dev/bxe 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, 01 Apr 2011 01:30:21 -0000 Author: yongari Date: Fri Apr 1 01:30:21 2011 New Revision: 220234 URL: http://svn.freebsd.org/changeset/base/220234 Log: Make bxe(4) build with BXE_DEBUG. Modified: head/sys/dev/bxe/if_bxe.c Modified: head/sys/dev/bxe/if_bxe.c ============================================================================== --- head/sys/dev/bxe/if_bxe.c Fri Apr 1 01:13:30 2011 (r220233) +++ head/sys/dev/bxe/if_bxe.c Fri Apr 1 01:30:21 2011 (r220234) @@ -15740,7 +15740,7 @@ bxe_add_sysctls(struct bxe_softc *sc) CTLFLAG_RD, &sc->mbuf_alloc_failed, 0, "mbuf cluster allocation failures"); - do() { + do { #define QUEUE_NAME_LEN 32 char namebuf[QUEUE_NAME_LEN]; struct sysctl_oid *queue_node; @@ -15770,7 +15770,7 @@ bxe_add_sysctls(struct bxe_softc *sc) "Mbuf defrag successes"); } - } + } while (0); SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "driver_state", CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 03:27: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 73CB91065673; Fri, 1 Apr 2011 03:27:55 +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 6481E8FC08; Fri, 1 Apr 2011 03:27:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p313RtFE031140; Fri, 1 Apr 2011 03:27:55 GMT (envelope-from kevlo@svn.freebsd.org) Received: (from kevlo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p313Rtqg031138; Fri, 1 Apr 2011 03:27:55 GMT (envelope-from kevlo@svn.freebsd.org) Message-Id: <201104010327.p313Rtqg031138@svn.freebsd.org> From: Kevin Lo Date: Fri, 1 Apr 2011 03:27: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: r220235 - head/sys/dev/usb/wlan 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, 01 Apr 2011 03:27:55 -0000 Author: kevlo Date: Fri Apr 1 03:27:55 2011 New Revision: 220235 URL: http://svn.freebsd.org/changeset/base/220235 Log: - Minor style(9) cleanup - Make functions static Modified: head/sys/dev/usb/wlan/if_run.c Modified: head/sys/dev/usb/wlan/if_run.c ============================================================================== --- head/sys/dev/usb/wlan/if_run.c Fri Apr 1 01:30:21 2011 (r220234) +++ head/sys/dev/usb/wlan/if_run.c Fri Apr 1 03:27:55 2011 (r220235) @@ -71,8 +71,8 @@ __FBSDID("$FreeBSD$"); #define USB_DEBUG_VAR run_debug #include -#include "if_runreg.h" -#include "if_runvar.h" +#include +#include #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) @@ -523,7 +523,7 @@ static const struct usb_config run_confi } }; -int +static int run_match(device_t self) { struct usb_attach_arg *uaa = device_get_ivars(self); @@ -604,7 +604,7 @@ run_attach(device_t self) RUN_UNLOCK(sc); ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211); - if(ifp == NULL){ + if (ifp == NULL) { device_printf(sc->sc_dev, "can not if_alloc()\n"); goto detach; } @@ -958,7 +958,7 @@ run_unsetup_tx_list(struct run_softc *sc } } -int +static int run_load_microcode(struct run_softc *sc) { usb_device_request_t req; @@ -1018,7 +1018,8 @@ run_load_microcode(struct run_softc *sc) USETW(req.wValue, 8); USETW(req.wIndex, 0); USETW(req.wLength, 0); - if ((error = usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, NULL)) != 0) { + if ((error = usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, NULL)) + != 0) { device_printf(sc->sc_dev, "firmware reset failed\n"); goto fail; } From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 03:41: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 E091D106568A; Fri, 1 Apr 2011 03:41:41 +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 D0D358FC2F; Fri, 1 Apr 2011 03:41:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p313ff8w031490; Fri, 1 Apr 2011 03:41:41 GMT (envelope-from kevlo@svn.freebsd.org) Received: (from kevlo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p313ffVC031488; Fri, 1 Apr 2011 03:41:41 GMT (envelope-from kevlo@svn.freebsd.org) Message-Id: <201104010341.p313ffVC031488@svn.freebsd.org> From: Kevin Lo Date: Fri, 1 Apr 2011 03:41:41 +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: r220236 - head/sys/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: Fri, 01 Apr 2011 03:41:42 -0000 Author: kevlo Date: Fri Apr 1 03:41:41 2011 New Revision: 220236 URL: http://svn.freebsd.org/changeset/base/220236 Log: Add 'mos' interface to NOTES Modified: head/sys/conf/NOTES Modified: head/sys/conf/NOTES ============================================================================== --- head/sys/conf/NOTES Fri Apr 1 03:27:55 2011 (r220235) +++ head/sys/conf/NOTES Fri Apr 1 03:41:41 2011 (r220236) @@ -2711,6 +2711,9 @@ device rue # Davicom DM9601E USB to fast ethernet. Supports the Corega FEther USB-TXC. device udav # +# Moschip MCS7730/MCS7840 USB to fast ethernet. Supports the Sitecom LN030. +device mos +# # HSxPA devices from Option N.V device uhso From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 06:28: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 9BC431065677; Fri, 1 Apr 2011 06:28:21 +0000 (UTC) (envelope-from lstewart@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 88D598FC1C; Fri, 1 Apr 2011 06:28:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p316SLfX034953; Fri, 1 Apr 2011 06:28:21 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p316SLEp034951; Fri, 1 Apr 2011 06:28:21 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <201104010628.p316SLEp034951@svn.freebsd.org> From: Lawrence Stewart Date: Fri, 1 Apr 2011 06:28:21 +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: r220237 - head/share/man/man4 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, 01 Apr 2011 06:28:21 -0000 Author: lstewart Date: Fri Apr 1 06:28:21 2011 New Revision: 220237 URL: http://svn.freebsd.org/changeset/base/220237 Log: Add a missing .El macro. Modified: head/share/man/man4/cc_chd.4 Modified: head/share/man/man4/cc_chd.4 ============================================================================== --- head/share/man/man4/cc_chd.4 Fri Apr 1 03:41:41 2011 (r220236) +++ head/share/man/man4/cc_chd.4 Fri Apr 1 06:28:21 2011 (r220237) @@ -58,6 +58,7 @@ do not cause cwnd to be reduced. .It CHD uses a shadow window to help regain lost transmission opportunities when competing with loss-based TCP flows. +.El .Sh MIB Variables The algorithm exposes the following tunable variables in the .Va net.inet.tcp.cc.chd From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 10:19: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 4EC41106566B; Fri, 1 Apr 2011 10:19:07 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 2E1288FC08; Fri, 1 Apr 2011 10:19:05 +0000 (UTC) Received: from odyssey.starpoint.kiev.ua (alpha-e.starpoint.kiev.ua [212.40.38.101]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id NAA22892; Fri, 01 Apr 2011 13:19:04 +0300 (EEST) (envelope-from avg@FreeBSD.org) Message-ID: <4D95A697.3050009@FreeBSD.org> Date: Fri, 01 Apr 2011 13:19:03 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.15) Gecko/20110309 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: Subject: svn commit r220401- in head: lib/libc/gen sys/kern 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: Fri, 01 Apr 2011 10:19:07 -0000 Author: avg Date: Fri Apr 1 07:28:21 2011 New Revision: 220401 URL: http://svn.freebsd.org/changeset/base/220401 Log: errno: add a new error code EDAVE This error code should be used when a system, having a superior knowledge of its state and environment, has to deny a user action. Introduce the first usage of the new error code in vfs unmount to deny unmounting of root filesystem. Inspired by: 2001: The Space Odyssey Inspired by: GDB 7 Inspired by: EDOOFUS MFC after: Apr 1 2012 Modified: lib/libc/gen/errlst.c sys/kern/vfs_mount.c sys/sys/errno.h Modified: lib/libc/gen/errlst.c =================================================================== --- lib/libc/gen/errlst.c (revision 220181) +++ lib/libc/gen/errlst.c (working copy) @@ -152,5 +152,6 @@ const char *const sys_errlist[] = { "Protocol error", /* 92 - EPROTO */ "Capabilities insufficient", /* 93 - ENOTCAPABLE */ "Not permitted in capability mode", /* 94 - ECAPMODE */ + "I'm sorry Dave, I'm afraid I can't do that", /* 95 - EDAVE */ }; const int sys_nerr = sizeof(sys_errlist) / sizeof(sys_errlist[0]); Modified: sys/kern/vfs_mount.c =================================================================== --- sys/kern/vfs_mount.c (revision 220181) +++ sys/kern/vfs_mount.c (working copy) @@ -1206,7 +1206,7 @@ unmount(td, uap) */ if (mp->mnt_flag & MNT_ROOTFS) { mtx_unlock(&Giant); - return (EINVAL); + return (EDAVE); } error = dounmount(mp, uap->flags, td); mtx_unlock(&Giant); Modified: sys/sys/errno.h =================================================================== --- sys/sys/errno.h (revision 220181) +++ sys/sys/errno.h (working copy) @@ -175,13 +175,17 @@ __END_DECLS #ifndef _POSIX_SOURCE #define ENOTCAPABLE 93 /* Capabilities insufficient */ -#define ECAPMODE 94 /* Not permitted in capability mode */ +#define ECAPMODE 94 /* Not permitted in capability mode */ #endif /* _POSIX_SOURCE */ #ifndef _POSIX_SOURCE -#define ELAST 94 /* Must be equal largest errno */ +#define EDAVE 95 /* I'm sorry Dave, I'm afraid I can't do that. */ #endif /* _POSIX_SOURCE */ +#ifndef _POSIX_SOURCE +#define ELAST 95 /* Must be equal largest errno */ +#endif /* _POSIX_SOURCE */ + #ifdef _KERNEL /* pseudo-errors returned inside kernel to modify return to process */ #define ERESTART (-1) /* restart syscall */ From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 10:29:43 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 DE9EB106566B; Fri, 1 Apr 2011 10:29:43 +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 909968FC08; Fri, 1 Apr 2011 10:29:43 +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 p31ARp4V027916 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Fri, 1 Apr 2011 04:27:51 -0600 (MDT) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <4D95A697.3050009@FreeBSD.org> Date: Fri, 1 Apr 2011 04:27:50 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <789C49A1-A444-4594-9BD7-AC5E70752BB7@bsdimp.com> References: <4D95A697.3050009@FreeBSD.org> To: Andriy Gapon X-Mailer: Apple Mail (2.1082) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (harmony.bsdimp.com [10.0.0.6]); Fri, 01 Apr 2011 04:27:51 -0600 (MDT) Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit r220401- in head: lib/libc/gen sys/kern 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: Fri, 01 Apr 2011 10:29:44 -0000 Great commit. Just one nit. See below... On Apr 1, 2011, at 4:19 AM, Andriy Gapon wrote: > --- sys/sys/errno.h (revision 220181) > +++ sys/sys/errno.h (working copy) > @@ -175,13 +175,17 @@ __END_DECLS >=20 > #ifndef _POSIX_SOURCE > #define ENOTCAPABLE 93 /* Capabilities = insufficient */ > -#define ECAPMODE 94 /* Not permitted = in capability mode */ > +#define ECAPMODE 94 /* Not permitted in = capability mode */ > #endif /* _POSIX_SOURCE */ You really shouldn't mix functional changes with white-space changes = like this. Warner From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 10:36: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 CA4851065672; Fri, 1 Apr 2011 10:36:23 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id AC0498FC08; Fri, 1 Apr 2011 10:36:22 +0000 (UTC) Received: from odyssey.starpoint.kiev.ua (alpha-e.starpoint.kiev.ua [212.40.38.101]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id NAA23187; Fri, 01 Apr 2011 13:36:16 +0300 (EEST) (envelope-from avg@FreeBSD.org) Message-ID: <4D95AAA0.6010904@FreeBSD.org> Date: Fri, 01 Apr 2011 13:36:16 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.15) Gecko/20110309 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: Warner Losh References: <4D95A697.3050009@FreeBSD.org> <789C49A1-A444-4594-9BD7-AC5E70752BB7@bsdimp.com> In-Reply-To: <789C49A1-A444-4594-9BD7-AC5E70752BB7@bsdimp.com> X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit r220401- in head: lib/libc/gen sys/kern 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: Fri, 01 Apr 2011 10:36:23 -0000 on 01/04/2011 13:27 Warner Losh said the following: > Great commit. Just one nit. See below... > > > On Apr 1, 2011, at 4:19 AM, Andriy Gapon wrote: >> --- sys/sys/errno.h (revision 220181) >> +++ sys/sys/errno.h (working copy) >> @@ -175,13 +175,17 @@ __END_DECLS >> >> #ifndef _POSIX_SOURCE >> #define ENOTCAPABLE 93 /* Capabilities insufficient */ >> -#define ECAPMODE 94 /* Not permitted in capability mode */ >> +#define ECAPMODE 94 /* Not permitted in capability mode */ >> #endif /* _POSIX_SOURCE */ > > You really shouldn't mix functional changes with white-space changes like this. Oops, sorry, that was meant to be a separate commit. -- Andriy Gapon From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 11: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 2D5371065670; Fri, 1 Apr 2011 11:16:30 +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 1B9198FC08; Fri, 1 Apr 2011 11:16:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31BGUcp042331; Fri, 1 Apr 2011 11:16:30 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31BGTx4042314; Fri, 1 Apr 2011 11:16:29 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104011116.p31BGTx4042314@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Apr 2011 11:16: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: r220238 - in head/sys: amd64/ia32 compat/freebsd32 compat/ia32 ia64/ia32 kern modules 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: Fri, 01 Apr 2011 11:16:31 -0000 Author: kib Date: Fri Apr 1 11:16:29 2011 New Revision: 220238 URL: http://svn.freebsd.org/changeset/base/220238 Log: Add support for executing the FreeBSD 1/i386 a.out binaries on amd64. In particular: - implement compat shims for old stat(2) variants and ogetdirentries(2); - implement delivery of signals with ancient stack frame layout and corresponding sigreturn(2); - implement old getpagesize(2); - provide a user-mode trampoline and LDT call gate for lcall $7,$0; - port a.out image activator and connect it to the build as a module on amd64. The changes are hidden under COMPAT_43. MFC after: 1 month Modified: head/sys/amd64/ia32/ia32_misc.c head/sys/amd64/ia32/ia32_signal.c head/sys/amd64/ia32/ia32_sigtramp.S head/sys/amd64/ia32/ia32_syscall.c head/sys/compat/freebsd32/freebsd32_misc.c head/sys/compat/freebsd32/syscalls.master head/sys/compat/ia32/ia32_genassym.c head/sys/compat/ia32/ia32_signal.h head/sys/compat/ia32/ia32_sysvec.c head/sys/compat/ia32/ia32_util.h head/sys/ia64/ia32/ia32_misc.c head/sys/ia64/ia32/ia32_signal.c head/sys/kern/imgact_aout.c head/sys/kern/vfs_syscalls.c head/sys/modules/Makefile head/sys/sys/syscallsubr.h Modified: head/sys/amd64/ia32/ia32_misc.c ============================================================================== --- head/sys/amd64/ia32/ia32_misc.c Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/amd64/ia32/ia32_misc.c Fri Apr 1 11:16:29 2011 (r220238) @@ -69,3 +69,14 @@ freebsd32_sysarch(struct thread *td, str return (sysarch(td, &uap1)); } } + +#ifdef COMPAT_43 +int +ofreebsd32_getpagesize(struct thread *td, + struct ofreebsd32_getpagesize_args *uap) +{ + + td->td_retval[0] = IA32_PAGE_SIZE; + return (0); +} +#endif Modified: head/sys/amd64/ia32/ia32_signal.c ============================================================================== --- head/sys/amd64/ia32/ia32_signal.c Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/amd64/ia32/ia32_signal.c Fri Apr 1 11:16:29 2011 (r220238) @@ -300,6 +300,109 @@ freebsd32_swapcontext(struct thread *td, * frame pointer, it returns to the user * specified pc, psl. */ + +#ifdef COMPAT_43 +static void +ia32_osendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) +{ + struct ia32_sigframe3 sf, *fp; + struct proc *p; + struct thread *td; + struct sigacts *psp; + struct trapframe *regs; + int sig; + int oonstack; + + td = curthread; + p = td->td_proc; + PROC_LOCK_ASSERT(p, MA_OWNED); + sig = ksi->ksi_signo; + psp = p->p_sigacts; + mtx_assert(&psp->ps_mtx, MA_OWNED); + regs = td->td_frame; + oonstack = sigonstack(regs->tf_rsp); + + /* Allocate space for the signal handler context. */ + if ((td->td_pflags & TDP_ALTSTACK) && !oonstack && + SIGISMEMBER(psp->ps_sigonstack, sig)) { + fp = (struct ia32_sigframe3 *)(td->td_sigstk.ss_sp + + td->td_sigstk.ss_size - sizeof(sf)); + td->td_sigstk.ss_flags |= SS_ONSTACK; + } else + fp = (struct ia32_sigframe3 *)regs->tf_rsp - 1; + + /* Translate the signal if appropriate. */ + if (p->p_sysent->sv_sigtbl && sig <= p->p_sysent->sv_sigsize) + sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; + + /* Build the argument list for the signal handler. */ + sf.sf_signum = sig; + sf.sf_scp = (register_t)&fp->sf_siginfo.si_sc; + if (SIGISMEMBER(psp->ps_siginfo, sig)) { + /* Signal handler installed with SA_SIGINFO. */ + sf.sf_arg2 = (register_t)&fp->sf_siginfo; + sf.sf_siginfo.si_signo = sig; + sf.sf_siginfo.si_code = ksi->ksi_code; + sf.sf_ah = (uintptr_t)catcher; + } else { + /* Old FreeBSD-style arguments. */ + sf.sf_arg2 = ksi->ksi_code; + sf.sf_addr = (register_t)ksi->ksi_addr; + sf.sf_ah = (uintptr_t)catcher; + } + mtx_unlock(&psp->ps_mtx); + PROC_UNLOCK(p); + + /* Save most if not all of trap frame. */ + sf.sf_siginfo.si_sc.sc_eax = regs->tf_rax; + sf.sf_siginfo.si_sc.sc_ebx = regs->tf_rbx; + sf.sf_siginfo.si_sc.sc_ecx = regs->tf_rcx; + sf.sf_siginfo.si_sc.sc_edx = regs->tf_rdx; + sf.sf_siginfo.si_sc.sc_esi = regs->tf_rsi; + sf.sf_siginfo.si_sc.sc_edi = regs->tf_rdi; + sf.sf_siginfo.si_sc.sc_cs = regs->tf_cs; + sf.sf_siginfo.si_sc.sc_ds = regs->tf_ds; + sf.sf_siginfo.si_sc.sc_ss = regs->tf_ss; + sf.sf_siginfo.si_sc.sc_es = regs->tf_es; + sf.sf_siginfo.si_sc.sc_fs = regs->tf_fs; + sf.sf_siginfo.si_sc.sc_gs = regs->tf_gs; + sf.sf_siginfo.si_sc.sc_isp = regs->tf_rsp; + + /* Build the signal context to be used by osigreturn(). */ + sf.sf_siginfo.si_sc.sc_onstack = (oonstack) ? 1 : 0; + SIG2OSIG(*mask, sf.sf_siginfo.si_sc.sc_mask); + sf.sf_siginfo.si_sc.sc_esp = regs->tf_rsp; + sf.sf_siginfo.si_sc.sc_ebp = regs->tf_rbp; + sf.sf_siginfo.si_sc.sc_eip = regs->tf_rip; + sf.sf_siginfo.si_sc.sc_eflags = regs->tf_rflags; + sf.sf_siginfo.si_sc.sc_trapno = regs->tf_trapno; + sf.sf_siginfo.si_sc.sc_err = regs->tf_err; + + /* + * Copy the sigframe out to the user's stack. + */ + if (copyout(&sf, fp, sizeof(*fp)) != 0) { +#ifdef DEBUG + printf("process %ld has trashed its stack\n", (long)p->p_pid); +#endif + PROC_LOCK(p); + sigexit(td, SIGILL); + } + + regs->tf_rsp = (uintptr_t)fp; + regs->tf_rip = p->p_sysent->sv_psstrings - sz_ia32_osigcode; + regs->tf_rflags &= ~(PSL_T | PSL_D); + regs->tf_cs = _ucode32sel; + regs->tf_ds = _udatasel; + regs->tf_es = _udatasel; + regs->tf_fs = _udatasel; + regs->tf_ss = _udatasel; + set_pcb_flags(td->td_pcb, PCB_FULL_IRET); + PROC_LOCK(p); + mtx_lock(&psp->ps_mtx); +} +#endif + #ifdef COMPAT_FREEBSD4 static void freebsd4_ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) @@ -441,6 +544,12 @@ ia32_sendsig(sig_t catcher, ksiginfo_t * return; } #endif +#ifdef COMPAT_43 + if (SIGISMEMBER(psp->ps_osigset, sig)) { + ia32_osendsig(catcher, ksi, mask); + return; + } +#endif mtx_assert(&psp->ps_mtx, MA_OWNED); regs = td->td_frame; oonstack = sigonstack(regs->tf_rsp); @@ -547,6 +656,64 @@ ia32_sendsig(sig_t catcher, ksiginfo_t * * make sure that the user has not modified the * state to gain improper privileges. */ + +#ifdef COMPAT_43 +int +ofreebsd32_sigreturn(struct thread *td, struct ofreebsd32_sigreturn_args *uap) +{ + struct ia32_sigcontext3 sc, *scp; + struct trapframe *regs; + int eflags, error; + ksiginfo_t ksi; + + regs = td->td_frame; + error = copyin(uap->sigcntxp, &sc, sizeof(sc)); + if (error != 0) + return (error); + scp = ≻ + eflags = scp->sc_eflags; + if (!EFL_SECURE(eflags & ~PSL_RF, regs->tf_rflags & ~PSL_RF)) { + return (EINVAL); + } + if (!CS_SECURE(scp->sc_cs)) { + ksiginfo_init_trap(&ksi); + ksi.ksi_signo = SIGBUS; + ksi.ksi_code = BUS_OBJERR; + ksi.ksi_trapno = T_PROTFLT; + ksi.ksi_addr = (void *)regs->tf_rip; + trapsignal(td, &ksi); + return (EINVAL); + } + regs->tf_ds = scp->sc_ds; + regs->tf_es = scp->sc_es; + regs->tf_fs = scp->sc_fs; + regs->tf_gs = scp->sc_gs; + + regs->tf_rax = scp->sc_eax; + regs->tf_rbx = scp->sc_ebx; + regs->tf_rcx = scp->sc_ecx; + regs->tf_rdx = scp->sc_edx; + regs->tf_rsi = scp->sc_esi; + regs->tf_rdi = scp->sc_edi; + regs->tf_cs = scp->sc_cs; + regs->tf_ss = scp->sc_ss; + regs->tf_rbp = scp->sc_ebp; + regs->tf_rsp = scp->sc_esp; + regs->tf_rip = scp->sc_eip; + regs->tf_rflags = eflags; + + if (scp->sc_onstack & 1) + td->td_sigstk.ss_flags |= SS_ONSTACK; + else + td->td_sigstk.ss_flags &= ~SS_ONSTACK; + + kern_sigprocmask(td, SIG_SETMASK, (sigset_t *)&scp->sc_mask, NULL, + SIGPROCMASK_OLD); + set_pcb_flags(td->td_pcb, PCB_FULL_IRET); + return (EJUSTRETURN); +} +#endif + #ifdef COMPAT_FREEBSD4 /* * MPSAFE @@ -734,6 +901,9 @@ ia32_setregs(struct thread *td, struct i user_ldt_free(td); else mtx_unlock(&dt_lock); +#ifdef COMPAT_43 + setup_lcall_gate(); +#endif pcb->pcb_fsbase = 0; pcb->pcb_gsbase = 0; Modified: head/sys/amd64/ia32/ia32_sigtramp.S ============================================================================== --- head/sys/amd64/ia32/ia32_sigtramp.S Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/amd64/ia32/ia32_sigtramp.S Fri Apr 1 11:16:29 2011 (r220238) @@ -66,6 +66,35 @@ freebsd4_ia32_sigcode: jmp 1b #endif +#ifdef COMPAT_43 + ALIGN_TEXT +ia32_osigcode: + calll *IA32_SIGF_HANDLER(%esp)/* call signal handler */ + leal IA32_SIGF_SC(%esp),%eax /* get sigcontext */ + pushl %eax + movl $103,%eax /* 3.x SYS_sigreturn */ + pushl %eax /* junk to fake return addr. */ + int $0x80 /* enter kernel with args */ +1: + jmp 1b + + + ALIGN_TEXT +lcall_tramp: + pushl %ebp + movl %esp,%ebp + pushl 0x24(%ebp) /* arg 6 */ + pushl 0x20(%ebp) + pushl 0x1c(%ebp) + pushl 0x18(%ebp) + pushl 0x14(%ebp) + pushl 0x10(%ebp) /* arg 1 */ + pushl 0xc(%ebp) /* gap */ + int $0x80 + leave + lretl +#endif + ALIGN_TEXT esigcode: @@ -78,3 +107,11 @@ sz_ia32_sigcode: sz_freebsd4_ia32_sigcode: .long esigcode-freebsd4_ia32_sigcode #endif +#ifdef COMPAT_43 + .globl sz_ia32_osigcode +sz_ia32_osigcode: + .long esigcode-ia32_osigcode + .globl sz_lcall_tramp +sz_lcall_tramp: + .long esigcode-lcall_tramp +#endif Modified: head/sys/amd64/ia32/ia32_syscall.c ============================================================================== --- head/sys/amd64/ia32/ia32_syscall.c Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/amd64/ia32/ia32_syscall.c Fri Apr 1 11:16:29 2011 (r220238) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); */ #include "opt_clock.h" +#include "opt_compat.h" #include "opt_cpu.h" #include "opt_isa.h" @@ -78,7 +79,17 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #define IDTVEC(name) __CONCAT(X,name) @@ -198,3 +209,45 @@ ia32_syscall_disable(void *dummy) SYSINIT(ia32_syscall, SI_SUB_EXEC, SI_ORDER_ANY, ia32_syscall_enable, NULL); SYSUNINIT(ia32_syscall, SI_SUB_EXEC, SI_ORDER_ANY, ia32_syscall_disable, NULL); + +#ifdef COMPAT_43 +int +setup_lcall_gate(void) +{ + struct i386_ldt_args uap; + struct user_segment_descriptor descs[2]; + struct gate_descriptor *ssd; + uint32_t lcall_addr; + int error; + + bzero(&uap, sizeof(uap)); + uap.start = 0; + uap.num = 2; + + /* + * This is the easiest way to cut the space for system + * descriptor in ldt. Manually adjust the descriptor type to + * the call gate later. + */ + bzero(&descs[0], sizeof(descs)); + descs[0].sd_type = SDT_SYSNULL; + descs[1].sd_type = SDT_SYSNULL; + error = amd64_set_ldt(curthread, &uap, descs); + if (error != 0) + return (error); + + lcall_addr = curproc->p_sysent->sv_psstrings - sz_lcall_tramp; + mtx_lock(&dt_lock); + ssd = (struct gate_descriptor *)(curproc->p_md.md_ldt->ldt_base); + bzero(ssd, sizeof(*ssd)); + ssd->gd_looffset = lcall_addr; + ssd->gd_hioffset = lcall_addr >> 16; + ssd->gd_selector = _ucode32sel; + ssd->gd_type = SDT_SYSCGT; + ssd->gd_dpl = SEL_UPL; + ssd->gd_p = 1; + mtx_unlock(&dt_lock); + + return (0); +} +#endif Modified: head/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_misc.c Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/compat/freebsd32/freebsd32_misc.c Fri Apr 1 11:16:29 2011 (r220238) @@ -1454,6 +1454,29 @@ freebsd32_ftruncate(struct thread *td, s return (ftruncate(td, &ap)); } +#ifdef COMPAT_43 +int +ofreebsd32_getdirentries(struct thread *td, + struct ofreebsd32_getdirentries_args *uap) +{ + struct ogetdirentries_args ap; + int error; + long loff; + int32_t loff_cut; + + ap.fd = uap->fd; + ap.buf = uap->buf; + ap.count = uap->count; + ap.basep = NULL; + error = kern_ogetdirentries(td, &ap, &loff); + if (error == 0) { + loff_cut = loff; + error = copyout(&loff_cut, uap->basep, sizeof(int32_t)); + } + return (error); +} +#endif + int freebsd32_getdirentries(struct thread *td, struct freebsd32_getdirentries_args *uap) @@ -1638,6 +1661,29 @@ copy_stat(struct stat *in, struct stat32 TS_CP(*in, *out, st_birthtim); } +#ifdef COMPAT_43 +static void +copy_ostat(struct stat *in, struct ostat32 *out) +{ + + CP(*in, *out, st_dev); + CP(*in, *out, st_ino); + CP(*in, *out, st_mode); + CP(*in, *out, st_nlink); + CP(*in, *out, st_uid); + CP(*in, *out, st_gid); + CP(*in, *out, st_rdev); + CP(*in, *out, st_size); + TS_CP(*in, *out, st_atim); + TS_CP(*in, *out, st_mtim); + TS_CP(*in, *out, st_ctim); + CP(*in, *out, st_blksize); + CP(*in, *out, st_blocks); + CP(*in, *out, st_flags); + CP(*in, *out, st_gen); +} +#endif + int freebsd32_stat(struct thread *td, struct freebsd32_stat_args *uap) { @@ -1653,6 +1699,23 @@ freebsd32_stat(struct thread *td, struct return (error); } +#ifdef COMPAT_43 +int +ofreebsd32_stat(struct thread *td, struct ofreebsd32_stat_args *uap) +{ + struct stat sb; + struct ostat32 sb32; + int error; + + error = kern_stat(td, uap->path, UIO_USERSPACE, &sb); + if (error) + return (error); + copy_ostat(&sb, &sb32); + error = copyout(&sb32, uap->ub, sizeof (sb32)); + return (error); +} +#endif + int freebsd32_fstat(struct thread *td, struct freebsd32_fstat_args *uap) { @@ -1668,6 +1731,23 @@ freebsd32_fstat(struct thread *td, struc return (error); } +#ifdef COMPAT_43 +int +ofreebsd32_fstat(struct thread *td, struct ofreebsd32_fstat_args *uap) +{ + struct stat ub; + struct ostat32 ub32; + int error; + + error = kern_fstat(td, uap->fd, &ub); + if (error) + return (error); + copy_ostat(&ub, &ub32); + error = copyout(&ub32, uap->ub, sizeof(ub32)); + return (error); +} +#endif + int freebsd32_fstatat(struct thread *td, struct freebsd32_fstatat_args *uap) { @@ -1698,9 +1778,23 @@ freebsd32_lstat(struct thread *td, struc return (error); } -/* - * MPSAFE - */ +#ifdef COMPAT_43 +int +ofreebsd32_lstat(struct thread *td, struct ofreebsd32_lstat_args *uap) +{ + struct stat sb; + struct ostat32 sb32; + int error; + + error = kern_lstat(td, uap->path, UIO_USERSPACE, &sb); + if (error) + return (error); + copy_ostat(&sb, &sb32); + error = copyout(&sb32, uap->ub, sizeof (sb32)); + return (error); +} +#endif + int freebsd32_sysctl(struct thread *td, struct freebsd32_sysctl_args *uap) { Modified: head/sys/compat/freebsd32/syscalls.master ============================================================================== --- head/sys/compat/freebsd32/syscalls.master Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/compat/freebsd32/syscalls.master Fri Apr 1 11:16:29 2011 (r220238) @@ -117,9 +117,11 @@ 35 AUE_FCHFLAGS NOPROTO { int fchflags(int fd, int flags); } 36 AUE_SYNC NOPROTO { int sync(void); } 37 AUE_KILL NOPROTO { int kill(int pid, int signum); } -38 AUE_STAT UNIMPL ostat +38 AUE_STAT COMPAT { int freebsd32_stat(char *path, \ + struct ostat32 *ub); } 39 AUE_GETPPID NOPROTO { pid_t getppid(void); } -40 AUE_LSTAT UNIMPL olstat +40 AUE_LSTAT COMPAT { int freebsd32_lstat(char *path, \ + struct ostat *ub); } 41 AUE_DUP NOPROTO { int dup(u_int fd); } 42 AUE_PIPE NOPROTO { int pipe(void); } 43 AUE_GETEGID NOPROTO { gid_t getegid(void); } @@ -153,9 +155,11 @@ 60 AUE_UMASK NOPROTO { int umask(int newmask); } umask \ umask_args int 61 AUE_CHROOT NOPROTO { int chroot(char *path); } -62 AUE_FSTAT OBSOL ofstat +62 AUE_FSTAT COMPAT { int freebsd32_fstat(int fd, \ + struct ostat32 *ub); } 63 AUE_NULL OBSOL ogetkerninfo -64 AUE_NULL OBSOL ogetpagesize +64 AUE_NULL COMPAT { int freebsd32_getpagesize( \ + int32_t dummy); } 65 AUE_MSYNC NOPROTO { int msync(void *addr, size_t len, \ int flags); } 66 AUE_VFORK NOPROTO { int vfork(void); } @@ -210,7 +214,8 @@ 100 AUE_GETPRIORITY NOPROTO { int getpriority(int which, int who); } 101 AUE_NULL OBSOL osend 102 AUE_NULL OBSOL orecv -103 AUE_NULL OBSOL osigreturn +103 AUE_NULL COMPAT { int freebsd32_sigreturn( \ + struct ia32_sigcontext3 *sigcntxp); } 104 AUE_BIND NOPROTO { int bind(int s, caddr_t name, \ int namelen); } 105 AUE_SETSOCKOPT NOPROTO { int setsockopt(int s, int level, \ @@ -292,7 +297,8 @@ ; 155 is initialized by the NFS code, if present. ; XXX this is a problem!!! 155 AUE_NFS_SVC UNIMPL nfssvc -156 AUE_GETDIRENTRIES OBSOL ogetdirentries +156 AUE_GETDIRENTRIES COMPAT { int freebsd32_getdirentries(int fd, \ + char *buf, u_int count, uint32_t *basep); } 157 AUE_STATFS COMPAT4 { int freebsd32_statfs(char *path, \ struct statfs32 *buf); } 158 AUE_FSTATFS COMPAT4 { int freebsd32_fstatfs(int fd, \ Modified: head/sys/compat/ia32/ia32_genassym.c ============================================================================== --- head/sys/compat/ia32/ia32_genassym.c Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/compat/ia32/ia32_genassym.c Fri Apr 1 11:16:29 2011 (r220238) @@ -13,6 +13,9 @@ __FBSDID("$FreeBSD$"); ASSYM(IA32_SIGF_HANDLER, offsetof(struct ia32_sigframe, sf_ah)); ASSYM(IA32_SIGF_UC, offsetof(struct ia32_sigframe, sf_uc)); +#ifdef COMPAT_43 +ASSYM(IA32_SIGF_SC, offsetof(struct ia32_sigframe3, sf_siginfo.si_sc)); +#endif ASSYM(IA32_UC_GS, offsetof(struct ia32_ucontext, uc_mcontext.mc_gs)); ASSYM(IA32_UC_FS, offsetof(struct ia32_ucontext, uc_mcontext.mc_fs)); ASSYM(IA32_UC_ES, offsetof(struct ia32_ucontext, uc_mcontext.mc_es)); Modified: head/sys/compat/ia32/ia32_signal.h ============================================================================== --- head/sys/compat/ia32/ia32_signal.h Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/compat/ia32/ia32_signal.h Fri Apr 1 11:16:29 2011 (r220238) @@ -112,7 +112,7 @@ struct ia32_ucontext4 { }; #endif -#ifdef COMPAT_FREEBSD3 +#ifdef COMPAT_43 struct ia32_sigcontext3 { u_int32_t sc_onstack; u_int32_t sc_mask; @@ -165,7 +165,7 @@ struct ia32_sigframe { struct siginfo32 sf_si; /* = *sf_siginfo (SA_SIGINFO case) */ }; -#ifdef COMPAT_FREEBSD3 +#ifdef COMPAT_43 struct ia32_siginfo3 { struct ia32_sigcontext3 si_sc; int si_signo; @@ -186,10 +186,15 @@ struct ksiginfo; struct image_params; extern char ia32_sigcode[]; extern char freebsd4_ia32_sigcode[]; +extern char ia32_osigcode[]; +extern char lcall_tramp; extern int sz_ia32_sigcode; extern int sz_freebsd4_ia32_sigcode; -extern void ia32_sendsig(sig_t, struct ksiginfo *, sigset_t *); -extern void ia32_setregs(struct thread *td, struct image_params *imgp, +extern int sz_ia32_osigcode; +extern int sz_lcall_tramp; +void ia32_sendsig(sig_t, struct ksiginfo *, sigset_t *); +void ia32_setregs(struct thread *td, struct image_params *imgp, u_long stack); +int setup_lcall_gate(void); #endif Modified: head/sys/compat/ia32/ia32_sysvec.c ============================================================================== --- head/sys/compat/ia32/ia32_sysvec.c Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/compat/ia32/ia32_sysvec.c Fri Apr 1 11:16:29 2011 (r220238) @@ -95,14 +95,12 @@ CTASSERT(sizeof(struct ia32_sigframe4) = extern const char *freebsd32_syscallnames[]; -static void ia32_fixlimit(struct rlimit *rl, int which); - SYSCTL_NODE(_compat, OID_AUTO, ia32, CTLFLAG_RW, 0, "ia32 mode"); static u_long ia32_maxdsiz = IA32_MAXDSIZ; SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxdsiz, CTLFLAG_RW, &ia32_maxdsiz, 0, ""); TUNABLE_ULONG("compat.ia32.maxdsiz", &ia32_maxdsiz); -static u_long ia32_maxssiz = IA32_MAXSSIZ; +u_long ia32_maxssiz = IA32_MAXSSIZ; SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxssiz, CTLFLAG_RW, &ia32_maxssiz, 0, ""); TUNABLE_ULONG("compat.ia32.maxssiz", &ia32_maxssiz); static u_long ia32_maxvmem = IA32_MAXVMEM; @@ -206,7 +204,7 @@ elf32_dump_thread(struct thread *td __un { } -static void +void ia32_fixlimit(struct rlimit *rl, int which) { Modified: head/sys/compat/ia32/ia32_util.h ============================================================================== --- head/sys/compat/ia32/ia32_util.h Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/compat/ia32/ia32_util.h Fri Apr 1 11:16:29 2011 (r220238) @@ -58,5 +58,6 @@ struct syscall_args; int ia32_fetch_syscall_args(struct thread *td, struct syscall_args *sa); void ia32_set_syscall_retval(struct thread *, int); +void ia32_fixlimit(struct rlimit *rl, int which); #endif Modified: head/sys/ia64/ia32/ia32_misc.c ============================================================================== --- head/sys/ia64/ia32/ia32_misc.c Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/ia64/ia32/ia32_misc.c Fri Apr 1 11:16:29 2011 (r220238) @@ -48,3 +48,14 @@ freebsd32_sysarch(struct thread *td, str return (EOPNOTSUPP); } + +#ifdef COMPAT_43 +int +ofreebsd32_getpagesize(struct thread *td, + struct ofreebsd32_getpagesize_args *uap) +{ + + td->td_retval[0] = IA32_PAGE_SIZE; + return (0); +} +#endif Modified: head/sys/ia64/ia32/ia32_signal.c ============================================================================== --- head/sys/ia64/ia32/ia32_signal.c Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/ia64/ia32/ia32_signal.c Fri Apr 1 11:16:29 2011 (r220238) @@ -92,6 +92,15 @@ x) */ }; int sz_ia32_sigcode = sizeof(ia32_sigcode); +#ifdef COMPAT_43 +int +ofreebsd32_sigreturn(struct thread *td, struct ofreebsd32_sigreturn_args *uap) +{ + + return (EOPNOTSUPP); +} +#endif + /* * Signal sending has not been implemented on ia64. This causes * the sigtramp code to not understand the arguments and the application Modified: head/sys/kern/imgact_aout.c ============================================================================== --- head/sys/kern/imgact_aout.c Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/kern/imgact_aout.c Fri Apr 1 11:16:29 2011 (r220238) @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -52,9 +53,18 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef __amd64__ +#include +#include +#include +#include +#include +#endif + static int exec_aout_imgact(struct image_params *imgp); static int aout_fixup(register_t **stack_base, struct image_params *imgp); +#if defined(__i386__) struct sysentvec aout_sysvec = { .sv_size = SYS_MAXSYSCALL, .sv_table = sysent, @@ -83,31 +93,69 @@ struct sysentvec aout_sysvec = { .sv_setregs = exec_setregs, .sv_fixlimit = NULL, .sv_maxssiz = NULL, - .sv_flags = SV_ABI_FREEBSD | SV_AOUT | -#if defined(__i386__) - SV_IA32 | SV_ILP32 -#else -#error Choose SV_XXX flags for the platform -#endif - , + .sv_flags = SV_ABI_FREEBSD | SV_AOUT | SV_IA32 | SV_ILP32, .sv_set_syscall_retval = cpu_set_syscall_retval, .sv_fetch_syscall_args = cpu_fetch_syscall_args, .sv_syscallnames = syscallnames, .sv_schedtail = NULL, }; +#elif defined(__amd64__) + +#define AOUT32_USRSTACK 0xbfc0000 +#define AOUT32_PS_STRINGS \ + (AOUT32_USRSTACK - sizeof(struct freebsd32_ps_strings)) + +extern const char *freebsd32_syscallnames[]; +extern u_long ia32_maxssiz; + +struct sysentvec aout_sysvec = { + .sv_size = FREEBSD32_SYS_MAXSYSCALL, + .sv_table = freebsd32_sysent, + .sv_mask = 0, + .sv_sigsize = 0, + .sv_sigtbl = NULL, + .sv_errsize = 0, + .sv_errtbl = NULL, + .sv_transtrap = NULL, + .sv_fixup = aout_fixup, + .sv_sendsig = ia32_sendsig, + .sv_sigcode = ia32_sigcode, + .sv_szsigcode = &sz_ia32_sigcode, + .sv_prepsyscall = NULL, + .sv_name = "FreeBSD a.out", + .sv_coredump = NULL, + .sv_imgact_try = NULL, + .sv_minsigstksz = MINSIGSTKSZ, + .sv_pagesize = IA32_PAGE_SIZE, + .sv_minuser = 0, + .sv_maxuser = AOUT32_USRSTACK, + .sv_usrstack = AOUT32_USRSTACK, + .sv_psstrings = AOUT32_PS_STRINGS, + .sv_stackprot = VM_PROT_ALL, + .sv_copyout_strings = freebsd32_copyout_strings, + .sv_setregs = ia32_setregs, + .sv_fixlimit = ia32_fixlimit, + .sv_maxssiz = &ia32_maxssiz, + .sv_flags = SV_ABI_FREEBSD | SV_AOUT | SV_IA32 | SV_ILP32, + .sv_set_syscall_retval = ia32_set_syscall_retval, + .sv_fetch_syscall_args = ia32_fetch_syscall_args, + .sv_syscallnames = freebsd32_syscallnames, +}; +#else +#error "Port me" +#endif + static int -aout_fixup(stack_base, imgp) - register_t **stack_base; - struct image_params *imgp; +aout_fixup(register_t **stack_base, struct image_params *imgp) { - return (suword(--(*stack_base), imgp->args->argc)); + *(char **)stack_base -= sizeof(uint32_t); + return (suword(*stack_base, imgp->args->argc)); } static int -exec_aout_imgact(imgp) - struct image_params *imgp; +exec_aout_imgact(struct image_params *imgp) { const struct exec *a_out = (const struct exec *) imgp->image_header; struct vmspace *vmspace; @@ -175,7 +223,14 @@ exec_aout_imgact(imgp) a_out->a_entry >= virtual_offset + a_out->a_text || /* text and data size must each be page rounded */ - a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK) + a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK + +#ifdef __amd64__ + || + /* overflows */ + virtual_offset + a_out->a_text + a_out->a_data + bss_size > UINT_MAX +#endif + ) return (-1); /* text + data can't exceed file size */ Modified: head/sys/kern/vfs_syscalls.c ============================================================================== --- head/sys/kern/vfs_syscalls.c Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/kern/vfs_syscalls.c Fri Apr 1 11:16:29 2011 (r220238) @@ -3898,14 +3898,20 @@ struct ogetdirentries_args { }; #endif int -ogetdirentries(td, uap) - struct thread *td; - register struct ogetdirentries_args /* { - int fd; - char *buf; - u_int count; - long *basep; - } */ *uap; +ogetdirentries(struct thread *td, struct ogetdirentries_args *uap) +{ + long loff; + int error; + + error = kern_ogetdirentries(td, uap, &loff); + if (error == 0) + error = copyout(&loff, uap->basep, sizeof(long)); + return (error); +} + +int +kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap, + long *ploff) { struct vnode *vp; struct file *fp; @@ -4024,9 +4030,10 @@ unionread: } VOP_UNLOCK(vp, 0); VFS_UNLOCK_GIANT(vfslocked); - error = copyout(&loff, uap->basep, sizeof(long)); fdrop(fp, td); td->td_retval[0] = uap->count - auio.uio_resid; + if (error == 0) + *ploff = loff; return (error); } #endif /* COMPAT_43 */ Modified: head/sys/modules/Makefile ============================================================================== --- head/sys/modules/Makefile Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/modules/Makefile Fri Apr 1 11:16:29 2011 (r220238) @@ -518,6 +518,7 @@ _snc= snc .if ${MACHINE_CPUARCH} == "amd64" _aac= aac +_aout= aout _acpi= acpi .if ${MK_CRYPT} != "no" || defined(ALL_MODULES) _aesni= aesni Modified: head/sys/sys/syscallsubr.h ============================================================================== --- head/sys/sys/syscallsubr.h Fri Apr 1 06:28:21 2011 (r220237) +++ head/sys/sys/syscallsubr.h Fri Apr 1 11:16:29 2011 (r220238) @@ -52,6 +52,7 @@ struct kld_file_stat; struct ksiginfo; struct sendfile_args; struct thr_param; +struct ogetdirentries_args; int kern___getcwd(struct thread *td, u_char *buf, enum uio_seg bufseg, u_int buflen); @@ -143,6 +144,8 @@ int kern_msgsnd(struct thread *, int, co int kern_msgrcv(struct thread *, int, void *, size_t, long, int, long *); int kern_nanosleep(struct thread *td, struct timespec *rqt, struct timespec *rmt); +int kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap, + long *ploff); int kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags, int mode); int kern_openat(struct thread *td, int fd, char *path, From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 11: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 638BE1065673; Fri, 1 Apr 2011 11:16:53 +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 531868FC17; Fri, 1 Apr 2011 11:16:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31BGrJc042379; Fri, 1 Apr 2011 11:16:53 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31BGrCL042374; Fri, 1 Apr 2011 11:16:53 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104011116.p31BGrCL042374@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Apr 2011 11: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: r220239 - head/sys/compat/freebsd32 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, 01 Apr 2011 11:16:53 -0000 Author: kib Date: Fri Apr 1 11:16:53 2011 New Revision: 220239 URL: http://svn.freebsd.org/changeset/base/220239 Log: Regen Modified: head/sys/compat/freebsd32/freebsd32_proto.h head/sys/compat/freebsd32/freebsd32_syscall.h head/sys/compat/freebsd32/freebsd32_syscalls.c head/sys/compat/freebsd32/freebsd32_sysent.c Modified: head/sys/compat/freebsd32/freebsd32_proto.h ============================================================================== --- head/sys/compat/freebsd32/freebsd32_proto.h Fri Apr 1 11:16:29 2011 (r220238) +++ head/sys/compat/freebsd32/freebsd32_proto.h Fri Apr 1 11:16:53 2011 (r220239) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220163 2011-03-30 17:48:15Z trasz + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220238 2011-04-01 11:16:29Z kib */ #ifndef _FREEBSD32_SYSPROTO_H_ @@ -682,6 +682,14 @@ int freebsd32_pselect(struct thread *, s #if !defined(PAD64_REQUIRED) && defined(__powerpc__) #define PAD64_REQUIRED #endif +struct ofreebsd32_stat_args { + char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)]; + char ub_l_[PADL_(struct ostat32 *)]; struct ostat32 * ub; char ub_r_[PADR_(struct ostat32 *)]; +}; +struct ofreebsd32_lstat_args { + char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)]; + char ub_l_[PADL_(struct ostat *)]; struct ostat * ub; char ub_r_[PADR_(struct ostat *)]; +}; struct ofreebsd32_sigaction_args { char signum_l_[PADL_(int)]; int signum; char signum_r_[PADR_(int)]; char nsa_l_[PADL_(struct osigaction32 *)]; struct osigaction32 * nsa; char nsa_r_[PADR_(struct osigaction32 *)]; @@ -691,6 +699,16 @@ struct ofreebsd32_sigprocmask_args { char how_l_[PADL_(int)]; int how; char how_r_[PADR_(int)]; char mask_l_[PADL_(osigset_t)]; osigset_t mask; char mask_r_[PADR_(osigset_t)]; }; +struct ofreebsd32_fstat_args { + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; + char ub_l_[PADL_(struct ostat32 *)]; struct ostat32 * ub; char ub_r_[PADR_(struct ostat32 *)]; +}; +struct ofreebsd32_getpagesize_args { + char dummy_l_[PADL_(int32_t)]; int32_t dummy; char dummy_r_[PADR_(int32_t)]; +}; +struct ofreebsd32_sigreturn_args { + char sigcntxp_l_[PADL_(struct ia32_sigcontext3 *)]; struct ia32_sigcontext3 * sigcntxp; char sigcntxp_r_[PADR_(struct ia32_sigcontext3 *)]; +}; struct ofreebsd32_sigvec_args { char signum_l_[PADL_(int)]; int signum; char signum_r_[PADR_(int)]; char nsv_l_[PADL_(struct sigvec32 *)]; struct sigvec32 * nsv; char nsv_r_[PADR_(struct sigvec32 *)]; @@ -709,20 +727,32 @@ struct ofreebsd32_sigstack_args { char nss_l_[PADL_(struct sigstack32 *)]; struct sigstack32 * nss; char nss_r_[PADR_(struct sigstack32 *)]; char oss_l_[PADL_(struct sigstack32 *)]; struct sigstack32 * oss; char oss_r_[PADR_(struct sigstack32 *)]; }; +struct ofreebsd32_getdirentries_args { + char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; + char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)]; + char count_l_[PADL_(u_int)]; u_int count; char count_r_[PADR_(u_int)]; + char basep_l_[PADL_(uint32_t *)]; uint32_t * basep; char basep_r_[PADR_(uint32_t *)]; +}; #ifdef PAD64_REQUIRED #else #endif #ifdef PAD64_REQUIRED #else #endif +int ofreebsd32_stat(struct thread *, struct ofreebsd32_stat_args *); +int ofreebsd32_lstat(struct thread *, struct ofreebsd32_lstat_args *); int ofreebsd32_sigaction(struct thread *, struct ofreebsd32_sigaction_args *); int ofreebsd32_sigprocmask(struct thread *, struct ofreebsd32_sigprocmask_args *); int ofreebsd32_sigpending(struct thread *, struct ofreebsd32_sigpending_args *); +int ofreebsd32_fstat(struct thread *, struct ofreebsd32_fstat_args *); +int ofreebsd32_getpagesize(struct thread *, struct ofreebsd32_getpagesize_args *); +int ofreebsd32_sigreturn(struct thread *, struct ofreebsd32_sigreturn_args *); int ofreebsd32_sigvec(struct thread *, struct ofreebsd32_sigvec_args *); int ofreebsd32_sigblock(struct thread *, struct ofreebsd32_sigblock_args *); int ofreebsd32_sigsetmask(struct thread *, struct ofreebsd32_sigsetmask_args *); int ofreebsd32_sigsuspend(struct thread *, struct ofreebsd32_sigsuspend_args *); int ofreebsd32_sigstack(struct thread *, struct ofreebsd32_sigstack_args *); +int ofreebsd32_getdirentries(struct thread *, struct ofreebsd32_getdirentries_args *); #endif /* COMPAT_43 */ @@ -888,15 +918,20 @@ int freebsd7_freebsd32_shmctl(struct thr #define FREEBSD32_SYS_AUE_freebsd32_recvmsg AUE_RECVMSG #define FREEBSD32_SYS_AUE_freebsd32_sendmsg AUE_SENDMSG #define FREEBSD32_SYS_AUE_freebsd32_recvfrom AUE_RECVFROM +#define FREEBSD32_SYS_AUE_ofreebsd32_stat AUE_STAT +#define FREEBSD32_SYS_AUE_ofreebsd32_lstat AUE_LSTAT #define FREEBSD32_SYS_AUE_ofreebsd32_sigaction AUE_SIGACTION #define FREEBSD32_SYS_AUE_ofreebsd32_sigprocmask AUE_SIGPROCMASK #define FREEBSD32_SYS_AUE_ofreebsd32_sigpending AUE_SIGPENDING #define FREEBSD32_SYS_AUE_freebsd32_sigaltstack AUE_SIGALTSTACK #define FREEBSD32_SYS_AUE_freebsd32_ioctl AUE_NULL #define FREEBSD32_SYS_AUE_freebsd32_execve AUE_EXECVE +#define FREEBSD32_SYS_AUE_ofreebsd32_fstat AUE_FSTAT +#define FREEBSD32_SYS_AUE_ofreebsd32_getpagesize AUE_NULL #define FREEBSD32_SYS_AUE_freebsd32_setitimer AUE_SETITIMER #define FREEBSD32_SYS_AUE_freebsd32_getitimer AUE_GETITIMER #define FREEBSD32_SYS_AUE_freebsd32_select AUE_SELECT +#define FREEBSD32_SYS_AUE_ofreebsd32_sigreturn AUE_NULL #define FREEBSD32_SYS_AUE_ofreebsd32_sigvec AUE_O_SIGVEC #define FREEBSD32_SYS_AUE_ofreebsd32_sigblock AUE_O_SIGBLOCK #define FREEBSD32_SYS_AUE_ofreebsd32_sigsetmask AUE_O_SIGSETMASK @@ -909,6 +944,7 @@ int freebsd7_freebsd32_shmctl(struct thr #define FREEBSD32_SYS_AUE_freebsd32_settimeofday AUE_SETTIMEOFDAY #define FREEBSD32_SYS_AUE_freebsd32_utimes AUE_UTIMES #define FREEBSD32_SYS_AUE_freebsd32_adjtime AUE_ADJTIME +#define FREEBSD32_SYS_AUE_ofreebsd32_getdirentries AUE_GETDIRENTRIES #define FREEBSD32_SYS_AUE_freebsd4_freebsd32_statfs AUE_STATFS #define FREEBSD32_SYS_AUE_freebsd4_freebsd32_fstatfs AUE_FSTATFS #define FREEBSD32_SYS_AUE_freebsd32_sysarch AUE_SYSARCH Modified: head/sys/compat/freebsd32/freebsd32_syscall.h ============================================================================== --- head/sys/compat/freebsd32/freebsd32_syscall.h Fri Apr 1 11:16:29 2011 (r220238) +++ head/sys/compat/freebsd32/freebsd32_syscall.h Fri Apr 1 11:16:53 2011 (r220239) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220163 2011-03-30 17:48:15Z trasz + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220238 2011-04-01 11:16:29Z kib */ #define FREEBSD32_SYS_syscall 0 @@ -44,7 +44,9 @@ #define FREEBSD32_SYS_fchflags 35 #define FREEBSD32_SYS_sync 36 #define FREEBSD32_SYS_kill 37 + /* 38 is old freebsd32_stat */ #define FREEBSD32_SYS_getppid 39 + /* 40 is old freebsd32_lstat */ #define FREEBSD32_SYS_dup 41 #define FREEBSD32_SYS_pipe 42 #define FREEBSD32_SYS_getegid 43 @@ -66,9 +68,9 @@ #define FREEBSD32_SYS_freebsd32_execve 59 #define FREEBSD32_SYS_umask 60 #define FREEBSD32_SYS_chroot 61 - /* 62 is obsolete ofstat */ + /* 62 is old freebsd32_fstat */ /* 63 is obsolete ogetkerninfo */ - /* 64 is obsolete ogetpagesize */ + /* 64 is old freebsd32_getpagesize */ #define FREEBSD32_SYS_msync 65 #define FREEBSD32_SYS_vfork 66 /* 67 is obsolete vread */ @@ -105,7 +107,7 @@ #define FREEBSD32_SYS_getpriority 100 /* 101 is obsolete osend */ /* 102 is obsolete orecv */ - /* 103 is obsolete osigreturn */ + /* 103 is old freebsd32_sigreturn */ #define FREEBSD32_SYS_bind 104 #define FREEBSD32_SYS_setsockopt 105 #define FREEBSD32_SYS_listen 106 @@ -152,7 +154,7 @@ #define FREEBSD32_SYS_quotactl 148 /* 149 is obsolete oquota */ /* 150 is obsolete ogetsockname */ - /* 156 is obsolete ogetdirentries */ + /* 156 is old freebsd32_getdirentries */ #define FREEBSD32_SYS_freebsd4_freebsd32_statfs 157 #define FREEBSD32_SYS_freebsd4_freebsd32_fstatfs 158 #define FREEBSD32_SYS_getfh 161 Modified: head/sys/compat/freebsd32/freebsd32_syscalls.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_syscalls.c Fri Apr 1 11:16:29 2011 (r220238) +++ head/sys/compat/freebsd32/freebsd32_syscalls.c Fri Apr 1 11:16:53 2011 (r220239) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220163 2011-03-30 17:48:15Z trasz + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220238 2011-04-01 11:16:29Z kib */ const char *freebsd32_syscallnames[] = { @@ -48,9 +48,9 @@ const char *freebsd32_syscallnames[] = { "fchflags", /* 35 = fchflags */ "sync", /* 36 = sync */ "kill", /* 37 = kill */ - "#38", /* 38 = ostat */ + "compat.freebsd32_stat", /* 38 = old freebsd32_stat */ "getppid", /* 39 = getppid */ - "#40", /* 40 = olstat */ + "compat.freebsd32_lstat", /* 40 = old freebsd32_lstat */ "dup", /* 41 = dup */ "pipe", /* 42 = pipe */ "getegid", /* 43 = getegid */ @@ -72,9 +72,9 @@ const char *freebsd32_syscallnames[] = { "freebsd32_execve", /* 59 = freebsd32_execve */ "umask", /* 60 = umask */ "chroot", /* 61 = chroot */ - "obs_ofstat", /* 62 = obsolete ofstat */ + "compat.freebsd32_fstat", /* 62 = old freebsd32_fstat */ "obs_ogetkerninfo", /* 63 = obsolete ogetkerninfo */ - "obs_ogetpagesize", /* 64 = obsolete ogetpagesize */ + "compat.freebsd32_getpagesize", /* 64 = old freebsd32_getpagesize */ "msync", /* 65 = msync */ "vfork", /* 66 = vfork */ "obs_vread", /* 67 = obsolete vread */ @@ -113,7 +113,7 @@ const char *freebsd32_syscallnames[] = { "getpriority", /* 100 = getpriority */ "obs_osend", /* 101 = obsolete osend */ "obs_orecv", /* 102 = obsolete orecv */ - "obs_osigreturn", /* 103 = obsolete osigreturn */ + "compat.freebsd32_sigreturn", /* 103 = old freebsd32_sigreturn */ "bind", /* 104 = bind */ "setsockopt", /* 105 = setsockopt */ "listen", /* 106 = listen */ @@ -166,7 +166,7 @@ const char *freebsd32_syscallnames[] = { "#153", /* 153 = asyncdaemon */ "#154", /* 154 = nlm_syscall */ "#155", /* 155 = nfssvc */ - "obs_ogetdirentries", /* 156 = obsolete ogetdirentries */ + "compat.freebsd32_getdirentries", /* 156 = old freebsd32_getdirentries */ "compat4.freebsd32_statfs", /* 157 = freebsd4 freebsd32_statfs */ "compat4.freebsd32_fstatfs", /* 158 = freebsd4 freebsd32_fstatfs */ "#159", /* 159 = nosys */ Modified: head/sys/compat/freebsd32/freebsd32_sysent.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_sysent.c Fri Apr 1 11:16:29 2011 (r220238) +++ head/sys/compat/freebsd32/freebsd32_sysent.c Fri Apr 1 11:16:53 2011 (r220239) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220163 2011-03-30 17:48:15Z trasz + * created from FreeBSD: head/sys/compat/freebsd32/syscalls.master 220238 2011-04-01 11:16:29Z kib */ #include "opt_compat.h" @@ -85,9 +85,9 @@ struct sysent freebsd32_sysent[] = { { AS(fchflags_args), (sy_call_t *)fchflags, AUE_FCHFLAGS, NULL, 0, 0, 0, SY_THR_STATIC }, /* 35 = fchflags */ { 0, (sy_call_t *)sync, AUE_SYNC, NULL, 0, 0, 0, SY_THR_STATIC }, /* 36 = sync */ { AS(kill_args), (sy_call_t *)kill, AUE_KILL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 37 = kill */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 38 = ostat */ + { compat(AS(ofreebsd32_stat_args),freebsd32_stat), AUE_STAT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 38 = old freebsd32_stat */ { 0, (sy_call_t *)getppid, AUE_GETPPID, NULL, 0, 0, 0, SY_THR_STATIC }, /* 39 = getppid */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 40 = olstat */ + { compat(AS(ofreebsd32_lstat_args),freebsd32_lstat), AUE_LSTAT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 40 = old freebsd32_lstat */ { AS(dup_args), (sy_call_t *)dup, AUE_DUP, NULL, 0, 0, 0, SY_THR_STATIC }, /* 41 = dup */ { 0, (sy_call_t *)pipe, AUE_PIPE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 42 = pipe */ { 0, (sy_call_t *)getegid, AUE_GETEGID, NULL, 0, 0, 0, SY_THR_STATIC }, /* 43 = getegid */ @@ -109,9 +109,9 @@ struct sysent freebsd32_sysent[] = { { AS(freebsd32_execve_args), (sy_call_t *)freebsd32_execve, AUE_EXECVE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 59 = freebsd32_execve */ { AS(umask_args), (sy_call_t *)umask, AUE_UMASK, NULL, 0, 0, 0, SY_THR_STATIC }, /* 60 = umask */ { AS(chroot_args), (sy_call_t *)chroot, AUE_CHROOT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 61 = chroot */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 62 = obsolete ofstat */ + { compat(AS(ofreebsd32_fstat_args),freebsd32_fstat), AUE_FSTAT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 62 = old freebsd32_fstat */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 63 = obsolete ogetkerninfo */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 64 = obsolete ogetpagesize */ + { compat(AS(ofreebsd32_getpagesize_args),freebsd32_getpagesize), AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 64 = old freebsd32_getpagesize */ { AS(msync_args), (sy_call_t *)msync, AUE_MSYNC, NULL, 0, 0, 0, SY_THR_STATIC }, /* 65 = msync */ { 0, (sy_call_t *)vfork, AUE_VFORK, NULL, 0, 0, 0, SY_THR_STATIC }, /* 66 = vfork */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 67 = obsolete vread */ @@ -150,7 +150,7 @@ struct sysent freebsd32_sysent[] = { { AS(getpriority_args), (sy_call_t *)getpriority, AUE_GETPRIORITY, NULL, 0, 0, 0, SY_THR_STATIC }, /* 100 = getpriority */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 101 = obsolete osend */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 102 = obsolete orecv */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 103 = obsolete osigreturn */ + { compat(AS(ofreebsd32_sigreturn_args),freebsd32_sigreturn), AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 103 = old freebsd32_sigreturn */ { AS(bind_args), (sy_call_t *)bind, AUE_BIND, NULL, 0, 0, 0, SY_THR_STATIC }, /* 104 = bind */ { AS(setsockopt_args), (sy_call_t *)setsockopt, AUE_SETSOCKOPT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 105 = setsockopt */ { AS(listen_args), (sy_call_t *)listen, AUE_LISTEN, NULL, 0, 0, 0, SY_THR_STATIC }, /* 106 = listen */ @@ -203,7 +203,7 @@ struct sysent freebsd32_sysent[] = { { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 153 = asyncdaemon */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 154 = nlm_syscall */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 155 = nfssvc */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 156 = obsolete ogetdirentries */ + { compat(AS(ofreebsd32_getdirentries_args),freebsd32_getdirentries), AUE_GETDIRENTRIES, NULL, 0, 0, 0, SY_THR_STATIC }, /* 156 = old freebsd32_getdirentries */ { compat4(AS(freebsd4_freebsd32_statfs_args),freebsd32_statfs), AUE_STATFS, NULL, 0, 0, 0, SY_THR_STATIC }, /* 157 = freebsd4 freebsd32_statfs */ { compat4(AS(freebsd4_freebsd32_fstatfs_args),freebsd32_fstatfs), AUE_FSTATFS, NULL, 0, 0, 0, SY_THR_STATIC }, /* 158 = freebsd4 freebsd32_fstatfs */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 159 = nosys */ From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 11:39: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 02BE0106566C; Fri, 1 Apr 2011 11:39:14 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E759C8FC1E; Fri, 1 Apr 2011 11:39:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31BdDdu043094; Fri, 1 Apr 2011 11:39:13 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31BdDk0043092; Fri, 1 Apr 2011 11:39:13 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201104011139.p31BdDk0043092@svn.freebsd.org> From: Warner Losh Date: Fri, 1 Apr 2011 11:39: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: r220240 - head/share/man/man4/man4.i386 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, 01 Apr 2011 11:39:14 -0000 Author: imp Date: Fri Apr 1 11:39:13 2011 New Revision: 220240 URL: http://svn.freebsd.org/changeset/base/220240 Log: Minor tweaks to the man page: o Remove bogus ordering info o 3C1 actually works, so remove that o Add warning about making sure BIOS is configured properly for PnP configured 3c509 cards. Modified: head/share/man/man4/man4.i386/ep.4 Modified: head/share/man/man4/man4.i386/ep.4 ============================================================================== --- head/share/man/man4/man4.i386/ep.4 Fri Apr 1 11:16:53 2011 (r220239) +++ head/share/man/man4/man4.i386/ep.4 Fri Apr 1 11:39:13 2011 (r220240) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 1, 2008 +.Dd April 1, 2011 .Dt EP 4 i386 .Os .Sh NAME @@ -81,9 +81,6 @@ Use the BNC port. .It 10baseT/UTP Use the UTP port. .El -.Pp -If there are multiple cards in the computer, they are searched for -in the following order: bus, slot, then Ethernet address. .Sh HARDWARE The .Nm @@ -128,13 +125,14 @@ scan operation at IO address 0x110. Beware! Avoid placing other cards at that address! .Pp -Furthermore, -the 3c509 should only -be configured in EISA mode +Furthermore, the 3c509 should only be configured in EISA mode when installed in a computer that has actual EISA slots (and an EISA-aware BIOS). -The normal driver auto-detection support -is sufficient for non-EISA systems. +The normal driver auto-detection support is sufficient for non-EISA systems. +.Pp +Cards in PnP mode may conflict with other resources in the system. +Ensure your BIOS is configured correctly to exclude resources used by +the 3c509, especially IRQs, to avoid unpredictable behavior. .Pp Many different companies sold the 3Com PC Cards under their own private label. @@ -212,5 +210,3 @@ This should never happen. .Sh STANDARDS are great. There is so many to choose from. -.Sh BUGS -Support for the 3Com 3C1 CompactFlash is not working. From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 11:44:59 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 1233) id E7A45106566C; Fri, 1 Apr 2011 11:44:59 +0000 (UTC) Date: Fri, 1 Apr 2011 11:44:59 +0000 From: Alexander Best To: Konstantin Belousov Message-ID: <20110401114459.GA13612@freebsd.org> References: <201104011116.p31BGTx4042314@svn.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201104011116.p31BGTx4042314@svn.freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r220238 - in head/sys: amd64/ia32 compat/freebsd32 compat/ia32 ia64/ia32 kern modules 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: Fri, 01 Apr 2011 11:45:00 -0000 On Fri Apr 1 11, Konstantin Belousov wrote: > Author: kib > Date: Fri Apr 1 11:16:29 2011 > New Revision: 220238 > URL: http://svn.freebsd.org/changeset/base/220238 > > Log: > Add support for executing the FreeBSD 1/i386 a.out binaries on amd64. > > In particular: > - implement compat shims for old stat(2) variants and ogetdirentries(2); > - implement delivery of signals with ancient stack frame layout and > corresponding sigreturn(2); > - implement old getpagesize(2); > - provide a user-mode trampoline and LDT call gate for lcall $7,$0; > - port a.out image activator and connect it to the build as a module > on amd64. > > The changes are hidden under COMPAT_43. hmm...for i386 there's # Enable i386 a.out binary support options COMPAT_AOUT why not make this feature dependant upon the same option and not COMPAT_43? ...also i noticed sys/amd/conf/NOTES says: # Enable 32-bit Linux ABI emulation (requires COMPAT_43 and COMPAT_FREEBSD32) options COMPAT_LINUX32 ...i don't think COMPAT_43 is actually necessary to use COMPAT_FREEBSD32, is it? cheers. alex > > MFC after: 1 month > > Modified: > head/sys/amd64/ia32/ia32_misc.c > head/sys/amd64/ia32/ia32_signal.c > head/sys/amd64/ia32/ia32_sigtramp.S > head/sys/amd64/ia32/ia32_syscall.c > head/sys/compat/freebsd32/freebsd32_misc.c > head/sys/compat/freebsd32/syscalls.master > head/sys/compat/ia32/ia32_genassym.c > head/sys/compat/ia32/ia32_signal.h > head/sys/compat/ia32/ia32_sysvec.c > head/sys/compat/ia32/ia32_util.h > head/sys/ia64/ia32/ia32_misc.c > head/sys/ia64/ia32/ia32_signal.c > head/sys/kern/imgact_aout.c > head/sys/kern/vfs_syscalls.c > head/sys/modules/Makefile > head/sys/sys/syscallsubr.h > > Modified: head/sys/amd64/ia32/ia32_misc.c > ============================================================================== > --- head/sys/amd64/ia32/ia32_misc.c Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/amd64/ia32/ia32_misc.c Fri Apr 1 11:16:29 2011 (r220238) > @@ -69,3 +69,14 @@ freebsd32_sysarch(struct thread *td, str > return (sysarch(td, &uap1)); > } > } > + > +#ifdef COMPAT_43 > +int > +ofreebsd32_getpagesize(struct thread *td, > + struct ofreebsd32_getpagesize_args *uap) > +{ > + > + td->td_retval[0] = IA32_PAGE_SIZE; > + return (0); > +} > +#endif > > Modified: head/sys/amd64/ia32/ia32_signal.c > ============================================================================== > --- head/sys/amd64/ia32/ia32_signal.c Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/amd64/ia32/ia32_signal.c Fri Apr 1 11:16:29 2011 (r220238) > @@ -300,6 +300,109 @@ freebsd32_swapcontext(struct thread *td, > * frame pointer, it returns to the user > * specified pc, psl. > */ > + > +#ifdef COMPAT_43 > +static void > +ia32_osendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) > +{ > + struct ia32_sigframe3 sf, *fp; > + struct proc *p; > + struct thread *td; > + struct sigacts *psp; > + struct trapframe *regs; > + int sig; > + int oonstack; > + > + td = curthread; > + p = td->td_proc; > + PROC_LOCK_ASSERT(p, MA_OWNED); > + sig = ksi->ksi_signo; > + psp = p->p_sigacts; > + mtx_assert(&psp->ps_mtx, MA_OWNED); > + regs = td->td_frame; > + oonstack = sigonstack(regs->tf_rsp); > + > + /* Allocate space for the signal handler context. */ > + if ((td->td_pflags & TDP_ALTSTACK) && !oonstack && > + SIGISMEMBER(psp->ps_sigonstack, sig)) { > + fp = (struct ia32_sigframe3 *)(td->td_sigstk.ss_sp + > + td->td_sigstk.ss_size - sizeof(sf)); > + td->td_sigstk.ss_flags |= SS_ONSTACK; > + } else > + fp = (struct ia32_sigframe3 *)regs->tf_rsp - 1; > + > + /* Translate the signal if appropriate. */ > + if (p->p_sysent->sv_sigtbl && sig <= p->p_sysent->sv_sigsize) > + sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; > + > + /* Build the argument list for the signal handler. */ > + sf.sf_signum = sig; > + sf.sf_scp = (register_t)&fp->sf_siginfo.si_sc; > + if (SIGISMEMBER(psp->ps_siginfo, sig)) { > + /* Signal handler installed with SA_SIGINFO. */ > + sf.sf_arg2 = (register_t)&fp->sf_siginfo; > + sf.sf_siginfo.si_signo = sig; > + sf.sf_siginfo.si_code = ksi->ksi_code; > + sf.sf_ah = (uintptr_t)catcher; > + } else { > + /* Old FreeBSD-style arguments. */ > + sf.sf_arg2 = ksi->ksi_code; > + sf.sf_addr = (register_t)ksi->ksi_addr; > + sf.sf_ah = (uintptr_t)catcher; > + } > + mtx_unlock(&psp->ps_mtx); > + PROC_UNLOCK(p); > + > + /* Save most if not all of trap frame. */ > + sf.sf_siginfo.si_sc.sc_eax = regs->tf_rax; > + sf.sf_siginfo.si_sc.sc_ebx = regs->tf_rbx; > + sf.sf_siginfo.si_sc.sc_ecx = regs->tf_rcx; > + sf.sf_siginfo.si_sc.sc_edx = regs->tf_rdx; > + sf.sf_siginfo.si_sc.sc_esi = regs->tf_rsi; > + sf.sf_siginfo.si_sc.sc_edi = regs->tf_rdi; > + sf.sf_siginfo.si_sc.sc_cs = regs->tf_cs; > + sf.sf_siginfo.si_sc.sc_ds = regs->tf_ds; > + sf.sf_siginfo.si_sc.sc_ss = regs->tf_ss; > + sf.sf_siginfo.si_sc.sc_es = regs->tf_es; > + sf.sf_siginfo.si_sc.sc_fs = regs->tf_fs; > + sf.sf_siginfo.si_sc.sc_gs = regs->tf_gs; > + sf.sf_siginfo.si_sc.sc_isp = regs->tf_rsp; > + > + /* Build the signal context to be used by osigreturn(). */ > + sf.sf_siginfo.si_sc.sc_onstack = (oonstack) ? 1 : 0; > + SIG2OSIG(*mask, sf.sf_siginfo.si_sc.sc_mask); > + sf.sf_siginfo.si_sc.sc_esp = regs->tf_rsp; > + sf.sf_siginfo.si_sc.sc_ebp = regs->tf_rbp; > + sf.sf_siginfo.si_sc.sc_eip = regs->tf_rip; > + sf.sf_siginfo.si_sc.sc_eflags = regs->tf_rflags; > + sf.sf_siginfo.si_sc.sc_trapno = regs->tf_trapno; > + sf.sf_siginfo.si_sc.sc_err = regs->tf_err; > + > + /* > + * Copy the sigframe out to the user's stack. > + */ > + if (copyout(&sf, fp, sizeof(*fp)) != 0) { > +#ifdef DEBUG > + printf("process %ld has trashed its stack\n", (long)p->p_pid); > +#endif > + PROC_LOCK(p); > + sigexit(td, SIGILL); > + } > + > + regs->tf_rsp = (uintptr_t)fp; > + regs->tf_rip = p->p_sysent->sv_psstrings - sz_ia32_osigcode; > + regs->tf_rflags &= ~(PSL_T | PSL_D); > + regs->tf_cs = _ucode32sel; > + regs->tf_ds = _udatasel; > + regs->tf_es = _udatasel; > + regs->tf_fs = _udatasel; > + regs->tf_ss = _udatasel; > + set_pcb_flags(td->td_pcb, PCB_FULL_IRET); > + PROC_LOCK(p); > + mtx_lock(&psp->ps_mtx); > +} > +#endif > + > #ifdef COMPAT_FREEBSD4 > static void > freebsd4_ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) > @@ -441,6 +544,12 @@ ia32_sendsig(sig_t catcher, ksiginfo_t * > return; > } > #endif > +#ifdef COMPAT_43 > + if (SIGISMEMBER(psp->ps_osigset, sig)) { > + ia32_osendsig(catcher, ksi, mask); > + return; > + } > +#endif > mtx_assert(&psp->ps_mtx, MA_OWNED); > regs = td->td_frame; > oonstack = sigonstack(regs->tf_rsp); > @@ -547,6 +656,64 @@ ia32_sendsig(sig_t catcher, ksiginfo_t * > * make sure that the user has not modified the > * state to gain improper privileges. > */ > + > +#ifdef COMPAT_43 > +int > +ofreebsd32_sigreturn(struct thread *td, struct ofreebsd32_sigreturn_args *uap) > +{ > + struct ia32_sigcontext3 sc, *scp; > + struct trapframe *regs; > + int eflags, error; > + ksiginfo_t ksi; > + > + regs = td->td_frame; > + error = copyin(uap->sigcntxp, &sc, sizeof(sc)); > + if (error != 0) > + return (error); > + scp = ≻ > + eflags = scp->sc_eflags; > + if (!EFL_SECURE(eflags & ~PSL_RF, regs->tf_rflags & ~PSL_RF)) { > + return (EINVAL); > + } > + if (!CS_SECURE(scp->sc_cs)) { > + ksiginfo_init_trap(&ksi); > + ksi.ksi_signo = SIGBUS; > + ksi.ksi_code = BUS_OBJERR; > + ksi.ksi_trapno = T_PROTFLT; > + ksi.ksi_addr = (void *)regs->tf_rip; > + trapsignal(td, &ksi); > + return (EINVAL); > + } > + regs->tf_ds = scp->sc_ds; > + regs->tf_es = scp->sc_es; > + regs->tf_fs = scp->sc_fs; > + regs->tf_gs = scp->sc_gs; > + > + regs->tf_rax = scp->sc_eax; > + regs->tf_rbx = scp->sc_ebx; > + regs->tf_rcx = scp->sc_ecx; > + regs->tf_rdx = scp->sc_edx; > + regs->tf_rsi = scp->sc_esi; > + regs->tf_rdi = scp->sc_edi; > + regs->tf_cs = scp->sc_cs; > + regs->tf_ss = scp->sc_ss; > + regs->tf_rbp = scp->sc_ebp; > + regs->tf_rsp = scp->sc_esp; > + regs->tf_rip = scp->sc_eip; > + regs->tf_rflags = eflags; > + > + if (scp->sc_onstack & 1) > + td->td_sigstk.ss_flags |= SS_ONSTACK; > + else > + td->td_sigstk.ss_flags &= ~SS_ONSTACK; > + > + kern_sigprocmask(td, SIG_SETMASK, (sigset_t *)&scp->sc_mask, NULL, > + SIGPROCMASK_OLD); > + set_pcb_flags(td->td_pcb, PCB_FULL_IRET); > + return (EJUSTRETURN); > +} > +#endif > + > #ifdef COMPAT_FREEBSD4 > /* > * MPSAFE > @@ -734,6 +901,9 @@ ia32_setregs(struct thread *td, struct i > user_ldt_free(td); > else > mtx_unlock(&dt_lock); > +#ifdef COMPAT_43 > + setup_lcall_gate(); > +#endif > > pcb->pcb_fsbase = 0; > pcb->pcb_gsbase = 0; > > Modified: head/sys/amd64/ia32/ia32_sigtramp.S > ============================================================================== > --- head/sys/amd64/ia32/ia32_sigtramp.S Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/amd64/ia32/ia32_sigtramp.S Fri Apr 1 11:16:29 2011 (r220238) > @@ -66,6 +66,35 @@ freebsd4_ia32_sigcode: > jmp 1b > #endif > > +#ifdef COMPAT_43 > + ALIGN_TEXT > +ia32_osigcode: > + calll *IA32_SIGF_HANDLER(%esp)/* call signal handler */ > + leal IA32_SIGF_SC(%esp),%eax /* get sigcontext */ > + pushl %eax > + movl $103,%eax /* 3.x SYS_sigreturn */ > + pushl %eax /* junk to fake return addr. */ > + int $0x80 /* enter kernel with args */ > +1: > + jmp 1b > + > + > + ALIGN_TEXT > +lcall_tramp: > + pushl %ebp > + movl %esp,%ebp > + pushl 0x24(%ebp) /* arg 6 */ > + pushl 0x20(%ebp) > + pushl 0x1c(%ebp) > + pushl 0x18(%ebp) > + pushl 0x14(%ebp) > + pushl 0x10(%ebp) /* arg 1 */ > + pushl 0xc(%ebp) /* gap */ > + int $0x80 > + leave > + lretl > +#endif > + > ALIGN_TEXT > esigcode: > > @@ -78,3 +107,11 @@ sz_ia32_sigcode: > sz_freebsd4_ia32_sigcode: > .long esigcode-freebsd4_ia32_sigcode > #endif > +#ifdef COMPAT_43 > + .globl sz_ia32_osigcode > +sz_ia32_osigcode: > + .long esigcode-ia32_osigcode > + .globl sz_lcall_tramp > +sz_lcall_tramp: > + .long esigcode-lcall_tramp > +#endif > > Modified: head/sys/amd64/ia32/ia32_syscall.c > ============================================================================== > --- head/sys/amd64/ia32/ia32_syscall.c Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/amd64/ia32/ia32_syscall.c Fri Apr 1 11:16:29 2011 (r220238) > @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); > */ > > #include "opt_clock.h" > +#include "opt_compat.h" > #include "opt_cpu.h" > #include "opt_isa.h" > > @@ -78,7 +79,17 @@ __FBSDID("$FreeBSD$"); > #include > #include > > +#include > #include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > > #define IDTVEC(name) __CONCAT(X,name) > > @@ -198,3 +209,45 @@ ia32_syscall_disable(void *dummy) > > SYSINIT(ia32_syscall, SI_SUB_EXEC, SI_ORDER_ANY, ia32_syscall_enable, NULL); > SYSUNINIT(ia32_syscall, SI_SUB_EXEC, SI_ORDER_ANY, ia32_syscall_disable, NULL); > + > +#ifdef COMPAT_43 > +int > +setup_lcall_gate(void) > +{ > + struct i386_ldt_args uap; > + struct user_segment_descriptor descs[2]; > + struct gate_descriptor *ssd; > + uint32_t lcall_addr; > + int error; > + > + bzero(&uap, sizeof(uap)); > + uap.start = 0; > + uap.num = 2; > + > + /* > + * This is the easiest way to cut the space for system > + * descriptor in ldt. Manually adjust the descriptor type to > + * the call gate later. > + */ > + bzero(&descs[0], sizeof(descs)); > + descs[0].sd_type = SDT_SYSNULL; > + descs[1].sd_type = SDT_SYSNULL; > + error = amd64_set_ldt(curthread, &uap, descs); > + if (error != 0) > + return (error); > + > + lcall_addr = curproc->p_sysent->sv_psstrings - sz_lcall_tramp; > + mtx_lock(&dt_lock); > + ssd = (struct gate_descriptor *)(curproc->p_md.md_ldt->ldt_base); > + bzero(ssd, sizeof(*ssd)); > + ssd->gd_looffset = lcall_addr; > + ssd->gd_hioffset = lcall_addr >> 16; > + ssd->gd_selector = _ucode32sel; > + ssd->gd_type = SDT_SYSCGT; > + ssd->gd_dpl = SEL_UPL; > + ssd->gd_p = 1; > + mtx_unlock(&dt_lock); > + > + return (0); > +} > +#endif > > Modified: head/sys/compat/freebsd32/freebsd32_misc.c > ============================================================================== > --- head/sys/compat/freebsd32/freebsd32_misc.c Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/compat/freebsd32/freebsd32_misc.c Fri Apr 1 11:16:29 2011 (r220238) > @@ -1454,6 +1454,29 @@ freebsd32_ftruncate(struct thread *td, s > return (ftruncate(td, &ap)); > } > > +#ifdef COMPAT_43 > +int > +ofreebsd32_getdirentries(struct thread *td, > + struct ofreebsd32_getdirentries_args *uap) > +{ > + struct ogetdirentries_args ap; > + int error; > + long loff; > + int32_t loff_cut; > + > + ap.fd = uap->fd; > + ap.buf = uap->buf; > + ap.count = uap->count; > + ap.basep = NULL; > + error = kern_ogetdirentries(td, &ap, &loff); > + if (error == 0) { > + loff_cut = loff; > + error = copyout(&loff_cut, uap->basep, sizeof(int32_t)); > + } > + return (error); > +} > +#endif > + > int > freebsd32_getdirentries(struct thread *td, > struct freebsd32_getdirentries_args *uap) > @@ -1638,6 +1661,29 @@ copy_stat(struct stat *in, struct stat32 > TS_CP(*in, *out, st_birthtim); > } > > +#ifdef COMPAT_43 > +static void > +copy_ostat(struct stat *in, struct ostat32 *out) > +{ > + > + CP(*in, *out, st_dev); > + CP(*in, *out, st_ino); > + CP(*in, *out, st_mode); > + CP(*in, *out, st_nlink); > + CP(*in, *out, st_uid); > + CP(*in, *out, st_gid); > + CP(*in, *out, st_rdev); > + CP(*in, *out, st_size); > + TS_CP(*in, *out, st_atim); > + TS_CP(*in, *out, st_mtim); > + TS_CP(*in, *out, st_ctim); > + CP(*in, *out, st_blksize); > + CP(*in, *out, st_blocks); > + CP(*in, *out, st_flags); > + CP(*in, *out, st_gen); > +} > +#endif > + > int > freebsd32_stat(struct thread *td, struct freebsd32_stat_args *uap) > { > @@ -1653,6 +1699,23 @@ freebsd32_stat(struct thread *td, struct > return (error); > } > > +#ifdef COMPAT_43 > +int > +ofreebsd32_stat(struct thread *td, struct ofreebsd32_stat_args *uap) > +{ > + struct stat sb; > + struct ostat32 sb32; > + int error; > + > + error = kern_stat(td, uap->path, UIO_USERSPACE, &sb); > + if (error) > + return (error); > + copy_ostat(&sb, &sb32); > + error = copyout(&sb32, uap->ub, sizeof (sb32)); > + return (error); > +} > +#endif > + > int > freebsd32_fstat(struct thread *td, struct freebsd32_fstat_args *uap) > { > @@ -1668,6 +1731,23 @@ freebsd32_fstat(struct thread *td, struc > return (error); > } > > +#ifdef COMPAT_43 > +int > +ofreebsd32_fstat(struct thread *td, struct ofreebsd32_fstat_args *uap) > +{ > + struct stat ub; > + struct ostat32 ub32; > + int error; > + > + error = kern_fstat(td, uap->fd, &ub); > + if (error) > + return (error); > + copy_ostat(&ub, &ub32); > + error = copyout(&ub32, uap->ub, sizeof(ub32)); > + return (error); > +} > +#endif > + > int > freebsd32_fstatat(struct thread *td, struct freebsd32_fstatat_args *uap) > { > @@ -1698,9 +1778,23 @@ freebsd32_lstat(struct thread *td, struc > return (error); > } > > -/* > - * MPSAFE > - */ > +#ifdef COMPAT_43 > +int > +ofreebsd32_lstat(struct thread *td, struct ofreebsd32_lstat_args *uap) > +{ > + struct stat sb; > + struct ostat32 sb32; > + int error; > + > + error = kern_lstat(td, uap->path, UIO_USERSPACE, &sb); > + if (error) > + return (error); > + copy_ostat(&sb, &sb32); > + error = copyout(&sb32, uap->ub, sizeof (sb32)); > + return (error); > +} > +#endif > + > int > freebsd32_sysctl(struct thread *td, struct freebsd32_sysctl_args *uap) > { > > Modified: head/sys/compat/freebsd32/syscalls.master > ============================================================================== > --- head/sys/compat/freebsd32/syscalls.master Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/compat/freebsd32/syscalls.master Fri Apr 1 11:16:29 2011 (r220238) > @@ -117,9 +117,11 @@ > 35 AUE_FCHFLAGS NOPROTO { int fchflags(int fd, int flags); } > 36 AUE_SYNC NOPROTO { int sync(void); } > 37 AUE_KILL NOPROTO { int kill(int pid, int signum); } > -38 AUE_STAT UNIMPL ostat > +38 AUE_STAT COMPAT { int freebsd32_stat(char *path, \ > + struct ostat32 *ub); } > 39 AUE_GETPPID NOPROTO { pid_t getppid(void); } > -40 AUE_LSTAT UNIMPL olstat > +40 AUE_LSTAT COMPAT { int freebsd32_lstat(char *path, \ > + struct ostat *ub); } > 41 AUE_DUP NOPROTO { int dup(u_int fd); } > 42 AUE_PIPE NOPROTO { int pipe(void); } > 43 AUE_GETEGID NOPROTO { gid_t getegid(void); } > @@ -153,9 +155,11 @@ > 60 AUE_UMASK NOPROTO { int umask(int newmask); } umask \ > umask_args int > 61 AUE_CHROOT NOPROTO { int chroot(char *path); } > -62 AUE_FSTAT OBSOL ofstat > +62 AUE_FSTAT COMPAT { int freebsd32_fstat(int fd, \ > + struct ostat32 *ub); } > 63 AUE_NULL OBSOL ogetkerninfo > -64 AUE_NULL OBSOL ogetpagesize > +64 AUE_NULL COMPAT { int freebsd32_getpagesize( \ > + int32_t dummy); } > 65 AUE_MSYNC NOPROTO { int msync(void *addr, size_t len, \ > int flags); } > 66 AUE_VFORK NOPROTO { int vfork(void); } > @@ -210,7 +214,8 @@ > 100 AUE_GETPRIORITY NOPROTO { int getpriority(int which, int who); } > 101 AUE_NULL OBSOL osend > 102 AUE_NULL OBSOL orecv > -103 AUE_NULL OBSOL osigreturn > +103 AUE_NULL COMPAT { int freebsd32_sigreturn( \ > + struct ia32_sigcontext3 *sigcntxp); } > 104 AUE_BIND NOPROTO { int bind(int s, caddr_t name, \ > int namelen); } > 105 AUE_SETSOCKOPT NOPROTO { int setsockopt(int s, int level, \ > @@ -292,7 +297,8 @@ > ; 155 is initialized by the NFS code, if present. > ; XXX this is a problem!!! > 155 AUE_NFS_SVC UNIMPL nfssvc > -156 AUE_GETDIRENTRIES OBSOL ogetdirentries > +156 AUE_GETDIRENTRIES COMPAT { int freebsd32_getdirentries(int fd, \ > + char *buf, u_int count, uint32_t *basep); } > 157 AUE_STATFS COMPAT4 { int freebsd32_statfs(char *path, \ > struct statfs32 *buf); } > 158 AUE_FSTATFS COMPAT4 { int freebsd32_fstatfs(int fd, \ > > Modified: head/sys/compat/ia32/ia32_genassym.c > ============================================================================== > --- head/sys/compat/ia32/ia32_genassym.c Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/compat/ia32/ia32_genassym.c Fri Apr 1 11:16:29 2011 (r220238) > @@ -13,6 +13,9 @@ __FBSDID("$FreeBSD$"); > > ASSYM(IA32_SIGF_HANDLER, offsetof(struct ia32_sigframe, sf_ah)); > ASSYM(IA32_SIGF_UC, offsetof(struct ia32_sigframe, sf_uc)); > +#ifdef COMPAT_43 > +ASSYM(IA32_SIGF_SC, offsetof(struct ia32_sigframe3, sf_siginfo.si_sc)); > +#endif > ASSYM(IA32_UC_GS, offsetof(struct ia32_ucontext, uc_mcontext.mc_gs)); > ASSYM(IA32_UC_FS, offsetof(struct ia32_ucontext, uc_mcontext.mc_fs)); > ASSYM(IA32_UC_ES, offsetof(struct ia32_ucontext, uc_mcontext.mc_es)); > > Modified: head/sys/compat/ia32/ia32_signal.h > ============================================================================== > --- head/sys/compat/ia32/ia32_signal.h Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/compat/ia32/ia32_signal.h Fri Apr 1 11:16:29 2011 (r220238) > @@ -112,7 +112,7 @@ struct ia32_ucontext4 { > }; > #endif > > -#ifdef COMPAT_FREEBSD3 > +#ifdef COMPAT_43 > struct ia32_sigcontext3 { > u_int32_t sc_onstack; > u_int32_t sc_mask; > @@ -165,7 +165,7 @@ struct ia32_sigframe { > struct siginfo32 sf_si; /* = *sf_siginfo (SA_SIGINFO case) */ > }; > > -#ifdef COMPAT_FREEBSD3 > +#ifdef COMPAT_43 > struct ia32_siginfo3 { > struct ia32_sigcontext3 si_sc; > int si_signo; > @@ -186,10 +186,15 @@ struct ksiginfo; > struct image_params; > extern char ia32_sigcode[]; > extern char freebsd4_ia32_sigcode[]; > +extern char ia32_osigcode[]; > +extern char lcall_tramp; > extern int sz_ia32_sigcode; > extern int sz_freebsd4_ia32_sigcode; > -extern void ia32_sendsig(sig_t, struct ksiginfo *, sigset_t *); > -extern void ia32_setregs(struct thread *td, struct image_params *imgp, > +extern int sz_ia32_osigcode; > +extern int sz_lcall_tramp; > +void ia32_sendsig(sig_t, struct ksiginfo *, sigset_t *); > +void ia32_setregs(struct thread *td, struct image_params *imgp, > u_long stack); > +int setup_lcall_gate(void); > > #endif > > Modified: head/sys/compat/ia32/ia32_sysvec.c > ============================================================================== > --- head/sys/compat/ia32/ia32_sysvec.c Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/compat/ia32/ia32_sysvec.c Fri Apr 1 11:16:29 2011 (r220238) > @@ -95,14 +95,12 @@ CTASSERT(sizeof(struct ia32_sigframe4) = > > extern const char *freebsd32_syscallnames[]; > > -static void ia32_fixlimit(struct rlimit *rl, int which); > - > SYSCTL_NODE(_compat, OID_AUTO, ia32, CTLFLAG_RW, 0, "ia32 mode"); > > static u_long ia32_maxdsiz = IA32_MAXDSIZ; > SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxdsiz, CTLFLAG_RW, &ia32_maxdsiz, 0, ""); > TUNABLE_ULONG("compat.ia32.maxdsiz", &ia32_maxdsiz); > -static u_long ia32_maxssiz = IA32_MAXSSIZ; > +u_long ia32_maxssiz = IA32_MAXSSIZ; > SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxssiz, CTLFLAG_RW, &ia32_maxssiz, 0, ""); > TUNABLE_ULONG("compat.ia32.maxssiz", &ia32_maxssiz); > static u_long ia32_maxvmem = IA32_MAXVMEM; > @@ -206,7 +204,7 @@ elf32_dump_thread(struct thread *td __un > { > } > > -static void > +void > ia32_fixlimit(struct rlimit *rl, int which) > { > > > Modified: head/sys/compat/ia32/ia32_util.h > ============================================================================== > --- head/sys/compat/ia32/ia32_util.h Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/compat/ia32/ia32_util.h Fri Apr 1 11:16:29 2011 (r220238) > @@ -58,5 +58,6 @@ > struct syscall_args; > int ia32_fetch_syscall_args(struct thread *td, struct syscall_args *sa); > void ia32_set_syscall_retval(struct thread *, int); > +void ia32_fixlimit(struct rlimit *rl, int which); > > #endif > > Modified: head/sys/ia64/ia32/ia32_misc.c > ============================================================================== > --- head/sys/ia64/ia32/ia32_misc.c Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/ia64/ia32/ia32_misc.c Fri Apr 1 11:16:29 2011 (r220238) > @@ -48,3 +48,14 @@ freebsd32_sysarch(struct thread *td, str > > return (EOPNOTSUPP); > } > + > +#ifdef COMPAT_43 > +int > +ofreebsd32_getpagesize(struct thread *td, > + struct ofreebsd32_getpagesize_args *uap) > +{ > + > + td->td_retval[0] = IA32_PAGE_SIZE; > + return (0); > +} > +#endif > > Modified: head/sys/ia64/ia32/ia32_signal.c > ============================================================================== > --- head/sys/ia64/ia32/ia32_signal.c Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/ia64/ia32/ia32_signal.c Fri Apr 1 11:16:29 2011 (r220238) > @@ -92,6 +92,15 @@ x) */ > }; > int sz_ia32_sigcode = sizeof(ia32_sigcode); > > +#ifdef COMPAT_43 > +int > +ofreebsd32_sigreturn(struct thread *td, struct ofreebsd32_sigreturn_args *uap) > +{ > + > + return (EOPNOTSUPP); > +} > +#endif > + > /* > * Signal sending has not been implemented on ia64. This causes > * the sigtramp code to not understand the arguments and the application > > Modified: head/sys/kern/imgact_aout.c > ============================================================================== > --- head/sys/kern/imgact_aout.c Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/kern/imgact_aout.c Fri Apr 1 11:16:29 2011 (r220238) > @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > #include > #include > #include > @@ -52,9 +53,18 @@ __FBSDID("$FreeBSD$"); > #include > #include > > +#ifdef __amd64__ > +#include > +#include > +#include > +#include > +#include > +#endif > + > static int exec_aout_imgact(struct image_params *imgp); > static int aout_fixup(register_t **stack_base, struct image_params *imgp); > > +#if defined(__i386__) > struct sysentvec aout_sysvec = { > .sv_size = SYS_MAXSYSCALL, > .sv_table = sysent, > @@ -83,31 +93,69 @@ struct sysentvec aout_sysvec = { > .sv_setregs = exec_setregs, > .sv_fixlimit = NULL, > .sv_maxssiz = NULL, > - .sv_flags = SV_ABI_FREEBSD | SV_AOUT | > -#if defined(__i386__) > - SV_IA32 | SV_ILP32 > -#else > -#error Choose SV_XXX flags for the platform > -#endif > - , > + .sv_flags = SV_ABI_FREEBSD | SV_AOUT | SV_IA32 | SV_ILP32, > .sv_set_syscall_retval = cpu_set_syscall_retval, > .sv_fetch_syscall_args = cpu_fetch_syscall_args, > .sv_syscallnames = syscallnames, > .sv_schedtail = NULL, > }; > > +#elif defined(__amd64__) > + > +#define AOUT32_USRSTACK 0xbfc0000 > +#define AOUT32_PS_STRINGS \ > + (AOUT32_USRSTACK - sizeof(struct freebsd32_ps_strings)) > + > +extern const char *freebsd32_syscallnames[]; > +extern u_long ia32_maxssiz; > + > +struct sysentvec aout_sysvec = { > + .sv_size = FREEBSD32_SYS_MAXSYSCALL, > + .sv_table = freebsd32_sysent, > + .sv_mask = 0, > + .sv_sigsize = 0, > + .sv_sigtbl = NULL, > + .sv_errsize = 0, > + .sv_errtbl = NULL, > + .sv_transtrap = NULL, > + .sv_fixup = aout_fixup, > + .sv_sendsig = ia32_sendsig, > + .sv_sigcode = ia32_sigcode, > + .sv_szsigcode = &sz_ia32_sigcode, > + .sv_prepsyscall = NULL, > + .sv_name = "FreeBSD a.out", > + .sv_coredump = NULL, > + .sv_imgact_try = NULL, > + .sv_minsigstksz = MINSIGSTKSZ, > + .sv_pagesize = IA32_PAGE_SIZE, > + .sv_minuser = 0, > + .sv_maxuser = AOUT32_USRSTACK, > + .sv_usrstack = AOUT32_USRSTACK, > + .sv_psstrings = AOUT32_PS_STRINGS, > + .sv_stackprot = VM_PROT_ALL, > + .sv_copyout_strings = freebsd32_copyout_strings, > + .sv_setregs = ia32_setregs, > + .sv_fixlimit = ia32_fixlimit, > + .sv_maxssiz = &ia32_maxssiz, > + .sv_flags = SV_ABI_FREEBSD | SV_AOUT | SV_IA32 | SV_ILP32, > + .sv_set_syscall_retval = ia32_set_syscall_retval, > + .sv_fetch_syscall_args = ia32_fetch_syscall_args, > + .sv_syscallnames = freebsd32_syscallnames, > +}; > +#else > +#error "Port me" > +#endif > + > static int > -aout_fixup(stack_base, imgp) > - register_t **stack_base; > - struct image_params *imgp; > +aout_fixup(register_t **stack_base, struct image_params *imgp) > { > > - return (suword(--(*stack_base), imgp->args->argc)); > + *(char **)stack_base -= sizeof(uint32_t); > + return (suword(*stack_base, imgp->args->argc)); > } > > static int > -exec_aout_imgact(imgp) > - struct image_params *imgp; > +exec_aout_imgact(struct image_params *imgp) > { > const struct exec *a_out = (const struct exec *) imgp->image_header; > struct vmspace *vmspace; > @@ -175,7 +223,14 @@ exec_aout_imgact(imgp) > a_out->a_entry >= virtual_offset + a_out->a_text || > > /* text and data size must each be page rounded */ > - a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK) > + a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK > + > +#ifdef __amd64__ > + || > + /* overflows */ > + virtual_offset + a_out->a_text + a_out->a_data + bss_size > UINT_MAX > +#endif > + ) > return (-1); > > /* text + data can't exceed file size */ > > Modified: head/sys/kern/vfs_syscalls.c > ============================================================================== > --- head/sys/kern/vfs_syscalls.c Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/kern/vfs_syscalls.c Fri Apr 1 11:16:29 2011 (r220238) > @@ -3898,14 +3898,20 @@ struct ogetdirentries_args { > }; > #endif > int > -ogetdirentries(td, uap) > - struct thread *td; > - register struct ogetdirentries_args /* { > - int fd; > - char *buf; > - u_int count; > - long *basep; > - } */ *uap; > +ogetdirentries(struct thread *td, struct ogetdirentries_args *uap) > +{ > + long loff; > + int error; > + > + error = kern_ogetdirentries(td, uap, &loff); > + if (error == 0) > + error = copyout(&loff, uap->basep, sizeof(long)); > + return (error); > +} > + > +int > +kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap, > + long *ploff) > { > struct vnode *vp; > struct file *fp; > @@ -4024,9 +4030,10 @@ unionread: > } > VOP_UNLOCK(vp, 0); > VFS_UNLOCK_GIANT(vfslocked); > - error = copyout(&loff, uap->basep, sizeof(long)); > fdrop(fp, td); > td->td_retval[0] = uap->count - auio.uio_resid; > + if (error == 0) > + *ploff = loff; > return (error); > } > #endif /* COMPAT_43 */ > > Modified: head/sys/modules/Makefile > ============================================================================== > --- head/sys/modules/Makefile Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/modules/Makefile Fri Apr 1 11:16:29 2011 (r220238) > @@ -518,6 +518,7 @@ _snc= snc > > .if ${MACHINE_CPUARCH} == "amd64" > _aac= aac > +_aout= aout > _acpi= acpi > .if ${MK_CRYPT} != "no" || defined(ALL_MODULES) > _aesni= aesni > > Modified: head/sys/sys/syscallsubr.h > ============================================================================== > --- head/sys/sys/syscallsubr.h Fri Apr 1 06:28:21 2011 (r220237) > +++ head/sys/sys/syscallsubr.h Fri Apr 1 11:16:29 2011 (r220238) > @@ -52,6 +52,7 @@ struct kld_file_stat; > struct ksiginfo; > struct sendfile_args; > struct thr_param; > +struct ogetdirentries_args; > > int kern___getcwd(struct thread *td, u_char *buf, enum uio_seg bufseg, > u_int buflen); > @@ -143,6 +144,8 @@ int kern_msgsnd(struct thread *, int, co > int kern_msgrcv(struct thread *, int, void *, size_t, long, int, long *); > int kern_nanosleep(struct thread *td, struct timespec *rqt, > struct timespec *rmt); > +int kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap, > + long *ploff); > int kern_open(struct thread *td, char *path, enum uio_seg pathseg, > int flags, int mode); > int kern_openat(struct thread *td, int fd, char *path, -- a13x From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 13:28:35 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 66FC1106566B; Fri, 1 Apr 2011 13:28:35 +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 556B08FC15; Fri, 1 Apr 2011 13:28:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31DSZ4P046808; Fri, 1 Apr 2011 13:28:35 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31DSZud046795; Fri, 1 Apr 2011 13:28:35 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104011328.p31DSZud046795@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Apr 2011 13:28:35 +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: r220245 - in head/sys: dev/streams kern opencrypto 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: Fri, 01 Apr 2011 13:28:35 -0000 Author: kib Date: Fri Apr 1 13:28:34 2011 New Revision: 220245 URL: http://svn.freebsd.org/changeset/base/220245 Log: After the r219999 is merged to stable/8, rename fallocf(9) to falloc(9) and remove the falloc() version that lacks flag argument. This is done to reduce the KPI bloat. Requested by: jhb X-MFC-note: do not Modified: head/sys/dev/streams/streams.c head/sys/kern/kern_descrip.c head/sys/kern/kern_event.c head/sys/kern/sys_pipe.c head/sys/kern/tty_pts.c head/sys/kern/uipc_mqueue.c head/sys/kern/uipc_sem.c head/sys/kern/uipc_shm.c head/sys/kern/uipc_syscalls.c head/sys/kern/vfs_syscalls.c head/sys/opencrypto/cryptodev.c head/sys/sys/filedesc.h Modified: head/sys/dev/streams/streams.c ============================================================================== --- head/sys/dev/streams/streams.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/dev/streams/streams.c Fri Apr 1 13:28:34 2011 (r220245) @@ -241,7 +241,7 @@ streamsopen(struct cdev *dev, int oflags } fdp = td->td_proc->p_fd; - if ((error = falloc(td, &fp, &fd)) != 0) + if ((error = falloc(td, &fp, &fd, 0)) != 0) return error; /* An extra reference on `fp' has been held for us by falloc(). */ Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/kern/kern_descrip.c Fri Apr 1 13:28:34 2011 (r220245) @@ -1516,7 +1516,7 @@ fdavail(struct thread *td, int n) * release the FILEDESC lock. */ int -fallocf(struct thread *td, struct file **resultfp, int *resultfd, int flags) +falloc(struct thread *td, struct file **resultfp, int *resultfd, int flags) { struct proc *p = td->td_proc; struct file *fp; @@ -1569,13 +1569,6 @@ fallocf(struct thread *td, struct file * return (0); } -int -falloc(struct thread *td, struct file **resultfp, int *resultfd) -{ - - return (fallocf(td, resultfp, resultfd, 0)); -} - /* * Build a new filedesc structure from another. * Copy the current, root, and jail root vnode references. Modified: head/sys/kern/kern_event.c ============================================================================== --- head/sys/kern/kern_event.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/kern/kern_event.c Fri Apr 1 13:28:34 2011 (r220245) @@ -684,7 +684,7 @@ kqueue(struct thread *td, struct kqueue_ int fd, error; fdp = td->td_proc->p_fd; - error = falloc(td, &fp, &fd); + error = falloc(td, &fp, &fd, 0); if (error) goto done2; Modified: head/sys/kern/sys_pipe.c ============================================================================== --- head/sys/kern/sys_pipe.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/kern/sys_pipe.c Fri Apr 1 13:28:34 2011 (r220245) @@ -348,7 +348,7 @@ kern_pipe(struct thread *td, int fildes[ rpipe->pipe_state |= PIPE_DIRECTOK; wpipe->pipe_state |= PIPE_DIRECTOK; - error = falloc(td, &rf, &fd); + error = falloc(td, &rf, &fd, 0); if (error) { pipeclose(rpipe); pipeclose(wpipe); @@ -364,7 +364,7 @@ kern_pipe(struct thread *td, int fildes[ * side while we are blocked trying to allocate the write side. */ finit(rf, FREAD | FWRITE, DTYPE_PIPE, rpipe, &pipeops); - error = falloc(td, &wf, &fd); + error = falloc(td, &wf, &fd, 0); if (error) { fdclose(fdp, rf, fildes[0], td); fdrop(rf, td); Modified: head/sys/kern/tty_pts.c ============================================================================== --- head/sys/kern/tty_pts.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/kern/tty_pts.c Fri Apr 1 13:28:34 2011 (r220245) @@ -805,7 +805,7 @@ posix_openpt(struct thread *td, struct p if (uap->flags & ~(O_RDWR|O_NOCTTY)) return (EINVAL); - error = falloc(td, &fp, &fd); + error = falloc(td, &fp, &fd, 0); if (error) return (error); Modified: head/sys/kern/uipc_mqueue.c ============================================================================== --- head/sys/kern/uipc_mqueue.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/kern/uipc_mqueue.c Fri Apr 1 13:28:34 2011 (r220245) @@ -1974,7 +1974,7 @@ kern_kmq_open(struct thread *td, const c if (len < 2 || path[0] != '/' || index(path + 1, '/') != NULL) return (EINVAL); - error = falloc(td, &fp, &fd); + error = falloc(td, &fp, &fd, 0); if (error) return (error); Modified: head/sys/kern/uipc_sem.c ============================================================================== --- head/sys/kern/uipc_sem.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/kern/uipc_sem.c Fri Apr 1 13:28:34 2011 (r220245) @@ -422,7 +422,7 @@ ksem_create(struct thread *td, const cha fdp = td->td_proc->p_fd; mode = (mode & ~fdp->fd_cmask) & ACCESSPERMS; - error = falloc(td, &fp, &fd); + error = falloc(td, &fp, &fd, 0); if (error) { if (name == NULL) error = ENOSPC; Modified: head/sys/kern/uipc_shm.c ============================================================================== --- head/sys/kern/uipc_shm.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/kern/uipc_shm.c Fri Apr 1 13:28:34 2011 (r220245) @@ -496,7 +496,7 @@ shm_open(struct thread *td, struct shm_o fdp = td->td_proc->p_fd; cmode = (uap->mode & ~fdp->fd_cmask) & ACCESSPERMS; - error = falloc(td, &fp, &fd); + error = falloc(td, &fp, &fd, 0); if (error) return (error); Modified: head/sys/kern/uipc_syscalls.c ============================================================================== --- head/sys/kern/uipc_syscalls.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/kern/uipc_syscalls.c Fri Apr 1 13:28:34 2011 (r220245) @@ -176,7 +176,7 @@ socket(td, uap) return (error); #endif fdp = td->td_proc->p_fd; - error = falloc(td, &fp, &fd); + error = falloc(td, &fp, &fd, 0); if (error) return (error); /* An extra reference on `fp' has been held for us by falloc(). */ @@ -358,7 +358,7 @@ kern_accept(struct thread *td, int s, st if (error != 0) goto done; #endif - error = falloc(td, &nfp, &fd); + error = falloc(td, &nfp, &fd, 0); if (error) goto done; ACCEPT_LOCK(); @@ -606,12 +606,12 @@ kern_socketpair(struct thread *td, int d if (error) goto free1; /* On success extra reference to `fp1' and 'fp2' is set by falloc. */ - error = falloc(td, &fp1, &fd); + error = falloc(td, &fp1, &fd, 0); if (error) goto free2; rsv[0] = fd; fp1->f_data = so1; /* so1 already has ref count */ - error = falloc(td, &fp2, &fd); + error = falloc(td, &fp2, &fd, 0); if (error) goto free3; fp2->f_data = so2; /* so2 already has ref count */ @@ -2299,7 +2299,7 @@ sctp_peeloff(td, uap) * but that is ok. */ - error = falloc(td, &nfp, &fd); + error = falloc(td, &nfp, &fd, 0); if (error) goto done; td->td_retval[0] = fd; Modified: head/sys/kern/vfs_syscalls.c ============================================================================== --- head/sys/kern/vfs_syscalls.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/kern/vfs_syscalls.c Fri Apr 1 13:28:34 2011 (r220245) @@ -1069,7 +1069,7 @@ kern_openat(struct thread *td, int fd, c else flags = FFLAGS(flags); - error = fallocf(td, &nfp, &indx, flags); + error = falloc(td, &nfp, &indx, flags); if (error) return (error); /* An extra reference on `nfp' has been held for us by falloc(). */ @@ -4495,7 +4495,7 @@ fhopen(td, uap) * end of vn_open code */ - if ((error = fallocf(td, &nfp, &indx, fmode)) != 0) { + if ((error = falloc(td, &nfp, &indx, fmode)) != 0) { if (fmode & FWRITE) vp->v_writecount--; goto bad; Modified: head/sys/opencrypto/cryptodev.c ============================================================================== --- head/sys/opencrypto/cryptodev.c Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/opencrypto/cryptodev.c Fri Apr 1 13:28:34 2011 (r220245) @@ -1109,7 +1109,7 @@ cryptoioctl(struct cdev *dev, u_long cmd TAILQ_INIT(&fcr->csessions); fcr->sesn = 0; - error = falloc(td, &f, &fd); + error = falloc(td, &f, &fd, 0); if (error) { free(fcr, M_XDATA); Modified: head/sys/sys/filedesc.h ============================================================================== --- head/sys/sys/filedesc.h Fri Apr 1 13:23:53 2011 (r220244) +++ head/sys/sys/filedesc.h Fri Apr 1 13:28:34 2011 (r220245) @@ -111,8 +111,7 @@ struct thread; int closef(struct file *fp, struct thread *td); int dupfdopen(struct thread *td, struct filedesc *fdp, int indx, int dfd, int mode, int error); -int falloc(struct thread *td, struct file **resultfp, int *resultfd); -int fallocf(struct thread *td, struct file **resultfp, int *resultfd, +int falloc(struct thread *td, struct file **resultfp, int *resultfd, int flags); int fdalloc(struct thread *td, int minfd, int *result); int fdavail(struct thread *td, int n); From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 14:13: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 54C841065672; Fri, 1 Apr 2011 14:13:50 +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 4446B8FC0C; Fri, 1 Apr 2011 14:13:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31EDogV048061; Fri, 1 Apr 2011 14:13:50 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31EDowO048059; Fri, 1 Apr 2011 14:13:50 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201104011413.p31EDowO048059@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Fri, 1 Apr 2011 14:13: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: r220247 - head/sys/netipsec 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, 01 Apr 2011 14:13:50 -0000 Author: bz Date: Fri Apr 1 14:13:49 2011 New Revision: 220247 URL: http://svn.freebsd.org/changeset/base/220247 Log: Do not allow recursive RFC3173 IPComp payload. Reviewed by: Tavis Ormandy (taviso cmpxchg8b.com) MFC after: 5 days Security: CVE-2011-1547 Modified: head/sys/netipsec/xform_ipcomp.c Modified: head/sys/netipsec/xform_ipcomp.c ============================================================================== --- head/sys/netipsec/xform_ipcomp.c Fri Apr 1 14:04:36 2011 (r220246) +++ head/sys/netipsec/xform_ipcomp.c Fri Apr 1 14:13:49 2011 (r220247) @@ -142,8 +142,29 @@ ipcomp_input(struct mbuf *m, struct seca struct tdb_crypto *tc; struct cryptodesc *crdc; struct cryptop *crp; + struct ipcomp *ipcomp; + caddr_t addr; int hlen = IPCOMP_HLENGTH; + /* + * Check that the next header of the IPComp is not IPComp again, before + * doing any real work. Given it is not possible to do double + * compression it means someone is playing tricks on us. + */ + if (m->m_len < skip + hlen && (m = m_pullup(m, skip + hlen)) == NULL) { + V_ipcompstat.ipcomps_hdrops++; /*XXX*/ + DPRINTF(("%s: m_pullup failed\n", __func__)); + return (ENOBUFS); + } + addr = (caddr_t) mtod(m, struct ip *) + skip; + ipcomp = (struct ipcomp *)addr; + if (ipcomp->comp_nxt == IPPROTO_IPCOMP) { + m_freem(m); + V_ipcompstat.ipcomps_pdrops++; /* XXX have our own stats? */ + DPRINTF(("%s: recursive compression detected\n", __func__)); + return (EINVAL); + } + /* Get crypto descriptors */ crp = crypto_getreq(1); if (crp == NULL) { From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 16:45: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 737C81065670; Fri, 1 Apr 2011 16:45:26 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 61CEE8FC16; Fri, 1 Apr 2011 16:45:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31GjQOi052325; Fri, 1 Apr 2011 16:45:26 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31GjQk5052323; Fri, 1 Apr 2011 16:45:26 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201104011645.p31GjQk5052323@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 1 Apr 2011 16:45: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: r220249 - head/sys/dev/age 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, 01 Apr 2011 16:45:26 -0000 Author: yongari Date: Fri Apr 1 16:45:26 2011 New Revision: 220249 URL: http://svn.freebsd.org/changeset/base/220249 Log: 64bit DMA caused data corruption. Unfortunately there is no known workaround to use 64bit DMA. Disable 64bit DMA on Attansic L1 controller. Tested by: Yamagi Burmeister (lists <> yamagi dot org) MFC after: 1 week Modified: head/sys/dev/age/if_age.c Modified: head/sys/dev/age/if_age.c ============================================================================== --- head/sys/dev/age/if_age.c Fri Apr 1 16:06:19 2011 (r220248) +++ head/sys/dev/age/if_age.c Fri Apr 1 16:45:26 2011 (r220249) @@ -1092,11 +1092,14 @@ again: * Create Tx/Rx buffer parent tag. * L1 supports full 64bit DMA addressing in Tx/Rx buffers * so it needs separate parent DMA tag. + * XXX + * It seems enabling 64bit DMA causes data corruption. Limit + * DMA address space to 32bit. */ error = bus_dma_tag_create( bus_get_dma_tag(sc->age_dev), /* parent */ 1, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR, /* lowaddr */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ BUS_SPACE_MAXSIZE_32BIT, /* maxsize */ From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 18: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 8A0EF1065670; Fri, 1 Apr 2011 18:48:31 +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 770278FC16; Fri, 1 Apr 2011 18:48:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31ImVPP055811; Fri, 1 Apr 2011 18:48:31 GMT (envelope-from jfv@svn.freebsd.org) Received: (from jfv@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31ImVLd055808; Fri, 1 Apr 2011 18:48:31 GMT (envelope-from jfv@svn.freebsd.org) Message-Id: <201104011848.p31ImVLd055808@svn.freebsd.org> From: Jack F Vogel Date: Fri, 1 Apr 2011 18: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: r220251 - 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: Fri, 01 Apr 2011 18:48:31 -0000 Author: jfv Date: Fri Apr 1 18:48:31 2011 New Revision: 220251 URL: http://svn.freebsd.org/changeset/base/220251 Log: Change the refresh_mbuf logic slightly, add an inline to calculate the outstanding descriptors that need to be refreshed at any time, and use THAT in rxeof to determine if refreshing needs to be done. Also change the local_timer to simply fire off the appropriate interrupt rather than schedule a tasklet, its simpler. MFC in two weeks Modified: head/sys/dev/e1000/if_em.c head/sys/dev/e1000/if_em.h Modified: head/sys/dev/e1000/if_em.c ============================================================================== --- head/sys/dev/e1000/if_em.c Fri Apr 1 18:23:44 2011 (r220250) +++ head/sys/dev/e1000/if_em.c Fri Apr 1 18:48:31 2011 (r220251) @@ -1,6 +1,6 @@ /****************************************************************************** - Copyright (c) 2001-2010, Intel Corporation + Copyright (c) 2001-2011, Intel Corporation All rights reserved. Redistribution and use in source and binary forms, with or without @@ -93,7 +93,7 @@ int em_display_debug_stats = 0; /********************************************************************* * Driver version: *********************************************************************/ -char em_driver_version[] = "7.2.2"; +char em_driver_version[] = "7.2.3"; /********************************************************************* * PCI Device ID Table @@ -2182,6 +2182,7 @@ em_local_timer(void *arg) struct ifnet *ifp = adapter->ifp; struct tx_ring *txr = adapter->tx_rings; struct rx_ring *rxr = adapter->rx_rings; + u32 trigger; EM_CORE_LOCK_ASSERT(adapter); @@ -2193,12 +2194,11 @@ em_local_timer(void *arg) e1000_get_laa_state_82571(&adapter->hw)) e1000_rar_set(&adapter->hw, adapter->hw.mac.addr, 0); - /* trigger tq to refill rx ring queue if it is empty */ - for (int i = 0; i < adapter->num_queues; i++, rxr++) { - if (rxr->next_to_check == rxr->next_to_refresh) { - taskqueue_enqueue(rxr->tq, &rxr->rx_task); - } - } + /* Mask to use in the irq trigger */ + if (adapter->msix_mem) + trigger = rxr->ims; /* RX for 82574 */ + else + trigger = E1000_ICS_RXDMT0; /* ** Don't do TX watchdog check if we've been paused @@ -2217,6 +2217,10 @@ em_local_timer(void *arg) goto hung; out: callout_reset(&adapter->timer, hz, em_local_timer, adapter); +#ifndef DEVICE_POLLING + /* Trigger an RX interrupt to guarantee mbuf refresh */ + E1000_WRITE_REG(&adapter->hw, E1000_ICS, trigger); +#endif return; hung: /* Looks like we're hung */ @@ -4327,7 +4331,7 @@ next_desc: } /* Catch any remaining refresh work */ - if (processed != 0 || i == rxr->next_to_refresh) + if (e1000_rx_unrefreshed(rxr)) em_refresh_mbufs(rxr, i); rxr->next_to_check = i; Modified: head/sys/dev/e1000/if_em.h ============================================================================== --- head/sys/dev/e1000/if_em.h Fri Apr 1 18:23:44 2011 (r220250) +++ head/sys/dev/e1000/if_em.h Fri Apr 1 18:48:31 2011 (r220251) @@ -1,6 +1,6 @@ /****************************************************************************** - Copyright (c) 2001-2010, Intel Corporation + Copyright (c) 2001-2011, Intel Corporation All rights reserved. Redistribution and use in source and binary forms, with or without @@ -463,6 +463,22 @@ struct em_buffer { bus_dmamap_t map; /* bus_dma map for packet */ }; + +/* +** Find the number of unrefreshed RX descriptors +*/ +static inline u16 +e1000_rx_unrefreshed(struct rx_ring *rxr) +{ + struct adapter *adapter = rxr->adapter; + + if (rxr->next_to_check > rxr->next_to_refresh) + return (rxr->next_to_check - rxr->next_to_refresh - 1); + else + return ((adapter->num_rx_desc + rxr->next_to_check) - + rxr->next_to_refresh - 1); +} + #define EM_CORE_LOCK_INIT(_sc, _name) \ mtx_init(&(_sc)->core_mtx, _name, "EM Core Lock", MTX_DEF) #define EM_TX_LOCK_INIT(_sc, _name) \ From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 18:53: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 C24CD106566C; Fri, 1 Apr 2011 18:53:41 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AEF9F8FC15; Fri, 1 Apr 2011 18:53:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31Irfr8055958; Fri, 1 Apr 2011 18:53:41 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31Irfx5055956; Fri, 1 Apr 2011 18:53:41 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201104011853.p31Irfx5055956@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 1 Apr 2011 18:53:41 +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: r220252 - head/sys/dev/age 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, 01 Apr 2011 18:53:41 -0000 Author: yongari Date: Fri Apr 1 18:53:41 2011 New Revision: 220252 URL: http://svn.freebsd.org/changeset/base/220252 Log: Partially revert r184106. RX buffer ring also needs bus_dmamap_sync(). Tested by: Yamagi Burmeister (lists <> yamagi dot org) MFC after: 1 week Modified: head/sys/dev/age/if_age.c Modified: head/sys/dev/age/if_age.c ============================================================================== --- head/sys/dev/age/if_age.c Fri Apr 1 18:48:31 2011 (r220251) +++ head/sys/dev/age/if_age.c Fri Apr 1 18:53:41 2011 (r220252) @@ -2424,6 +2424,8 @@ age_rxintr(struct age_softc *sc, int rr_ bus_dmamap_sync(sc->age_cdata.age_rr_ring_tag, sc->age_cdata.age_rr_ring_map, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); + bus_dmamap_sync(sc->age_cdata.age_rx_ring_tag, + sc->age_cdata.age_rx_ring_map, BUS_DMASYNC_POSTWRITE); for (prog = 0; rr_cons != rr_prod; prog++) { if (count <= 0) @@ -2455,6 +2457,8 @@ age_rxintr(struct age_softc *sc, int rr_ /* Update the consumer index. */ sc->age_cdata.age_rr_cons = rr_cons; + bus_dmamap_sync(sc->age_cdata.age_rx_ring_tag, + sc->age_cdata.age_rx_ring_map, BUS_DMASYNC_PREWRITE); /* Sync descriptors. */ bus_dmamap_sync(sc->age_cdata.age_rr_ring_tag, sc->age_cdata.age_rr_ring_map, @@ -2981,8 +2985,7 @@ age_init_rx_ring(struct age_softc *sc) } bus_dmamap_sync(sc->age_cdata.age_rx_ring_tag, - sc->age_cdata.age_rx_ring_map, - BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + sc->age_cdata.age_rx_ring_map, BUS_DMASYNC_PREWRITE); return (0); } From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 19:57: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 95F26106564A; Fri, 1 Apr 2011 19:57:27 +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 846228FC17; Fri, 1 Apr 2011 19:57:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31JvRxI057509; Fri, 1 Apr 2011 19:57:27 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31JvRcj057507; Fri, 1 Apr 2011 19:57:27 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104011957.p31JvRcj057507@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Apr 2011 19:57: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: r220253 - head/lib/libc/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: Fri, 01 Apr 2011 19:57:27 -0000 Author: kib Date: Fri Apr 1 19:57:27 2011 New Revision: 220253 URL: http://svn.freebsd.org/changeset/base/220253 Log: Fix mdoc errors. Submitted by: ru MFC after: 3 days Modified: head/lib/libc/sys/open.2 Modified: head/lib/libc/sys/open.2 ============================================================================== --- head/lib/libc/sys/open.2 Fri Apr 1 18:53:41 2011 (r220252) +++ head/lib/libc/sys/open.2 Fri Apr 1 19:57:27 2011 (r220253) @@ -248,8 +248,7 @@ When a new file is created it is given t which contains it. .Pp Unless -.Dv -O_CLOEXEC +.Dv O_CLOEXEC flag was specified, the new descriptor is set to remain open across .Xr execve 2 @@ -416,7 +415,7 @@ of .Dv O_WRONLY , .Dv O_RDWR and -.Dv O_EXEC. +.Dv O_EXEC . .It Bq Eq EBADF The .Fa path From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 20:24: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 423181065670; Fri, 1 Apr 2011 20:24:52 +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 1730E8FC12; Fri, 1 Apr 2011 20:24:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31KOpur058133; Fri, 1 Apr 2011 20:24:51 GMT (envelope-from jfv@svn.freebsd.org) Received: (from jfv@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31KOpvX058131; Fri, 1 Apr 2011 20:24:51 GMT (envelope-from jfv@svn.freebsd.org) Message-Id: <201104012024.p31KOpvX058131@svn.freebsd.org> From: Jack F Vogel Date: Fri, 1 Apr 2011 20:24: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: r220254 - 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: Fri, 01 Apr 2011 20:24:52 -0000 Author: jfv Date: Fri Apr 1 20:24:51 2011 New Revision: 220254 URL: http://svn.freebsd.org/changeset/base/220254 Log: Fix to an error condition case, when an mbuf chain get's defragged due to a mapping failure the header pointers will be invalidated and can result in a TSO or other failure down the line. So, when the remapping occurs force a retry thru the offload calculation code. Thanks to Andrew Boyer for discovering this and cooking up the fix!! Modified: head/sys/dev/e1000/if_em.c Modified: head/sys/dev/e1000/if_em.c ============================================================================== --- head/sys/dev/e1000/if_em.c Fri Apr 1 19:57:27 2011 (r220253) +++ head/sys/dev/e1000/if_em.c Fri Apr 1 20:24:51 2011 (r220254) @@ -1761,8 +1761,9 @@ em_xmit(struct tx_ring *txr, struct mbuf u32 txd_upper, txd_lower, txd_used, txd_saved; int ip_off, poff; int nsegs, i, j, first, last = 0; - int error, do_tso, tso_desc = 0; + int error, do_tso, tso_desc = 0, remap = 1; +retry: m_head = *m_headp; txd_upper = txd_lower = txd_used = txd_saved = 0; do_tso = ((m_head->m_pkthdr.csum_flags & CSUM_TSO) != 0); @@ -1900,7 +1901,7 @@ em_xmit(struct tx_ring *txr, struct mbuf * All other errors, in particular EINVAL, are fatal and prevent the * mbuf chain from ever going through. Drop it and report error. */ - if (error == EFBIG) { + if (error == EFBIG && remap) { struct mbuf *m; m = m_defrag(*m_headp, M_DONTWAIT); @@ -1912,20 +1913,9 @@ em_xmit(struct tx_ring *txr, struct mbuf } *m_headp = m; - /* Try it again */ - error = bus_dmamap_load_mbuf_sg(txr->txtag, map, - *m_headp, segs, &nsegs, BUS_DMA_NOWAIT); - - if (error == ENOMEM) { - adapter->no_tx_dma_setup++; - return (error); - } else if (error != 0) { - adapter->no_tx_dma_setup++; - m_freem(*m_headp); - *m_headp = NULL; - return (error); - } - + /* Try it again, but only once */ + remap = 0; + goto retry; } else if (error == ENOMEM) { adapter->no_tx_dma_setup++; return (error); From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 20:59: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 4B55B1065677; Fri, 1 Apr 2011 20:59:24 +0000 (UTC) (envelope-from uqs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3BE088FC1A; Fri, 1 Apr 2011 20:59:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31KxO6c058933; Fri, 1 Apr 2011 20:59:24 GMT (envelope-from uqs@svn.freebsd.org) Received: (from uqs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31KxOA0058931; Fri, 1 Apr 2011 20:59:24 GMT (envelope-from uqs@svn.freebsd.org) Message-Id: <201104012059.p31KxOA0058931@svn.freebsd.org> From: Ulrich Spoerlein Date: Fri, 1 Apr 2011 20:59:24 +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: r220255 - 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: Fri, 01 Apr 2011 20:59:24 -0000 Author: uqs Date: Fri Apr 1 20:59:23 2011 New Revision: 220255 URL: http://svn.freebsd.org/changeset/base/220255 Log: Fix the delete-old/check-old targets to work with arbitrarily long OLD_FILES/OLD_DIRS/OLD_LIBS lists. If you specify enough WITHOUT_FOO flags, the argument list passed to the shell will be too long. Using .for/.endfor make(1) "loop" will make the parser of the Makefile explode. Hack around this with good old pipes. No objections: netchild Reported by: b.f. Modified: head/Makefile.inc1 Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Fri Apr 1 20:24:51 2011 (r220254) +++ head/Makefile.inc1 Fri Apr 1 20:59:23 2011 (r220255) @@ -1355,10 +1355,16 @@ delete-old-files: @echo ">>> Removing old files (only deletes safe to delete libs)" # Ask for every old file if the user really wants to remove it. # It's annoying, but better safe than sorry. - @for file in ${OLD_FILES} ${OLD_FILES:Musr/share/*.gz:R}; do \ +# NB: We cannot pass the list of OLD_FILES as a parameter because the +# argument list will get too long. Using .for/.endfor make "loops" will make +# the Makefile parser segfault. + @exec 3<&0; \ + ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ + -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \ + while read file; do \ if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \ - rm ${RM_I} "${DESTDIR}/$${file}"; \ + rm ${RM_I} "${DESTDIR}/$${file}" <&3; \ fi; \ done # Remove catpages without corresponding manpages. @@ -1368,14 +1374,16 @@ delete-old-files: while read catpage; do \ read manpage; \ if [ ! -e "$${manpage}" ]; then \ - rm ${RM_I} $${catpage} <&3 ; \ + rm ${RM_I} $${catpage} <&3; \ fi; \ done @echo ">>> Old files removed" check-old-files: @echo ">>> Checking for old files" - @for file in ${OLD_FILES} ${OLD_FILES:Musr/share/*.gz:R}; do \ + @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ + -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \ + while read file; do \ if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ echo "${DESTDIR}/$${file}"; \ fi; \ @@ -1386,24 +1394,29 @@ check-old-files: while read catpage; do \ read manpage; \ if [ ! -e "$${manpage}" ]; then \ - echo $${catpage} ; \ + echo $${catpage}; \ fi; \ done delete-old-libs: @echo ">>> Removing old libraries" @echo "${OLD_LIBS_MESSAGE}" | fmt - @for file in ${OLD_LIBS}; do \ + @exec 3<&0; \ + ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ + -V OLD_LIBS | xargs -n1 | \ + while read file; do \ if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \ - rm ${RM_I} "${DESTDIR}/$${file}"; \ + rm ${RM_I} "${DESTDIR}/$${file}" <&3; \ fi; \ done @echo ">>> Old libraries removed" check-old-libs: @echo ">>> Checking for old libraries" - @for file in ${OLD_LIBS}; do \ + @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ + -V OLD_LIBS | xargs -n1 | \ + while read file; do \ if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ echo "${DESTDIR}/$${file}"; \ fi; \ @@ -1411,7 +1424,9 @@ check-old-libs: delete-old-dirs: @echo ">>> Removing old directories" - @for dir in ${OLD_DIRS}; do \ + @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ + -V OLD_DIRS | xargs -n1 | \ + while read dir; do \ if [ -d "${DESTDIR}/$${dir}" ]; then \ rmdir -v "${DESTDIR}/$${dir}" || true; \ elif [ -L "${DESTDIR}/$${dir}" ]; then \ @@ -1422,7 +1437,9 @@ delete-old-dirs: check-old-dirs: @echo ">>> Checking for old directories" - @for dir in ${OLD_DIRS}; do \ + @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ + -V OLD_DIRS | xargs -n1 | \ + while read dir; do \ if [ -d "${DESTDIR}/$${dir}" ]; then \ echo "${DESTDIR}/$${dir}"; \ elif [ -L "${DESTDIR}/$${dir}" ]; then \ From owner-svn-src-head@FreeBSD.ORG Fri Apr 1 23:47: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 0419E106566C; Fri, 1 Apr 2011 23:47:11 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CFC188FC18; Fri, 1 Apr 2011 23:47:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31NlAcl062587; Fri, 1 Apr 2011 23:47:10 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31NlADA062583; Fri, 1 Apr 2011 23:47:10 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201104012347.p31NlADA062583@svn.freebsd.org> From: Ed Maste Date: Fri, 1 Apr 2011 23:47: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: r220256 - in head/share/examples: . kld/firmware/fwimage 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, 01 Apr 2011 23:47:11 -0000 Author: emaste Date: Fri Apr 1 23:47:10 2011 New Revision: 220256 URL: http://svn.freebsd.org/changeset/base/220256 Log: Uuencode the sample "binary" firmware image file (instead of explicitly adding \0 bytes). This is a technique that would be used in an actual driver and is more suitable as an example. Reviewed by: mlaier Added: head/share/examples/kld/firmware/fwimage/firmware.img.uu (contents, props changed) Deleted: head/share/examples/kld/firmware/fwimage/firmware.img.in Modified: head/share/examples/Makefile head/share/examples/kld/firmware/fwimage/Makefile Modified: head/share/examples/Makefile ============================================================================== --- head/share/examples/Makefile Fri Apr 1 20:59:23 2011 (r220255) +++ head/share/examples/Makefile Fri Apr 1 23:47:10 2011 (r220256) @@ -99,7 +99,7 @@ XFILES= BSD_daemon/FreeBSD.pfa \ kld/firmware/fwconsumer/Makefile \ kld/firmware/fwconsumer/fw_consumer.c \ kld/firmware/fwimage/Makefile \ - kld/firmware/fwimage/firmware.img.in \ + kld/firmware/fwimage/firmware.img.uu \ kld/khelp/Makefile \ kld/khelp/README \ kld/khelp/h_example.c \ Modified: head/share/examples/kld/firmware/fwimage/Makefile ============================================================================== --- head/share/examples/kld/firmware/fwimage/Makefile Fri Apr 1 20:59:23 2011 (r220255) +++ head/share/examples/kld/firmware/fwimage/Makefile Fri Apr 1 23:47:10 2011 (r220256) @@ -3,8 +3,9 @@ KMOD= beastie FIRMWS= firmware.img:beastie -firmware.img: firmware.img.in - cp ${.ALLSRC} ${.TARGET} - printf '\0\0\0\0\0' >> ${.TARGET} +CLEANFILES= firmware.img + +firmware.img: firmware.img.uu + uudecode -p ${.ALLSRC} > ${.TARGET} .include Added: head/share/examples/kld/firmware/fwimage/firmware.img.uu ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/examples/kld/firmware/fwimage/firmware.img.uu Fri Apr 1 23:47:10 2011 (r220256) @@ -0,0 +1,16 @@ +$FreeBSD$ +begin 644 firmware.img +M("`@("`@("`@("`@("`L("`@("`@("`L"B`@("`@("`@("`@("`O*"`@("`@ +M("`@*0H@("`@("`@("`@("`@7"!<7U]?("`@+R!\"B`@("`@("`@("`@("`O +M+2!?("`M+R`@)PH@("`@("`@("`@("`H+UPO(%P@7"`@("]<"B`@("`@("`@ +M("`@("\@+R`@('P@("`@(%P*("`@("`@("`@("`@3R!/("`@*2`O("`@('P* +M("`@("`@("`@("`@+5XM+2<\("`@("`G"B`@("`@("`@("`@*%\N*2`@7R`@ +M*2`@("\*("`@("`@("`@("`@+E]?7R\@("`@+PH@("`@("`@("`@("`@("TM +M+2TM)R`O"B`\+2TM+2X@("`@(%]?("\@7U\@("!<"B`\+2TM+7P]/3T]3RDI +M*3T]*2!<*2`O/3T]/0H@/"TM+2TG("`@("TM)R`N7U\L)R!<"B`@("`@("`@ +M("`@("`@?"`@("`@("`@?`H@("`@("`@("`@("`@("!<("`@("`@("\@("`@ +M("`@+UP*("`@("`@("`@(%]?7U]?7R@@*%\@("\@7%]?7U]?7R\*("`@("`@ +M("`L)R`@+"TM+2TM)R`@('P*("`@("`@("`M+7M?7U]?7U]?7U]?*2`@0V]P +@>7)I9VAT("AC*2`R,#`S(%-C;W1T($QO;F<*```````` +` +end From owner-svn-src-head@FreeBSD.ORG Sat Apr 2 00:08:32 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 5F586106566B; Sat, 2 Apr 2011 00:08:32 +0000 (UTC) (envelope-from art@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 519988FC08; Sat, 2 Apr 2011 00:08:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3208W7s064410; Sat, 2 Apr 2011 00:08:32 GMT (envelope-from art@svn.freebsd.org) Received: (from art@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3208W6e064408; Sat, 2 Apr 2011 00:08:32 GMT (envelope-from art@svn.freebsd.org) Message-Id: <201104020008.p3208W6e064408@svn.freebsd.org> From: Artem Belevich Date: Sat, 2 Apr 2011 00:08: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: r220257 - head/share/misc 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, 02 Apr 2011 00:08:32 -0000 Author: art Date: Sat Apr 2 00:08:32 2011 New Revision: 220257 URL: http://svn.freebsd.org/changeset/base/220257 Log: Added myself as src committer. Approved by: avg (mentor) Modified: head/share/misc/committers-src.dot Modified: head/share/misc/committers-src.dot ============================================================================== --- head/share/misc/committers-src.dot Fri Apr 1 23:47:10 2011 (r220256) +++ head/share/misc/committers-src.dot Sat Apr 2 00:08:32 2011 (r220257) @@ -98,6 +98,7 @@ andreast [label="Andreas Tobler\nandreas andrew [label="Andrew Turner\nandrew@FreeBSD.org\n2010/07/19"] antoine [label="Antoine Brodin\nantoine@FreeBSD.org\n2008/02/03"] ariff [label="Ariff Abdullah\nariff@FreeBSD.org\n2005/11/14"] +art [label="Artem Belevich\nart@FreeBSD.org\n2011/03/29"] avg [label="Andriy Gapon\navg@FreeBSD.org\n2009/02/18"] benno [label="Benno Rice\nbenno@FreeBSD.org\n2000/11/02"] bms [label="Bruce M Simpson\nbms@FreeBSD.org\n2003/08/06"] @@ -270,6 +271,7 @@ andre -> qingli anholt -> jkim +avg -> art avg -> pluknet benno -> grehan @@ -440,6 +442,7 @@ kib -> trociny kmacy -> lstewart +marcel -> art marcel -> arun marcel -> marius marcel -> nwhitehorn From owner-svn-src-head@FreeBSD.ORG Sat Apr 2 00:24: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 542E21065670; Sat, 2 Apr 2011 00:24:14 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 45C978FC0C; Sat, 2 Apr 2011 00:24:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p320OElQ064957; Sat, 2 Apr 2011 00:24:14 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p320OEcX064955; Sat, 2 Apr 2011 00:24:14 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201104020024.p320OEcX064955@svn.freebsd.org> From: Adrian Chadd Date: Sat, 2 Apr 2011 00:24: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: r220258 - head/sys/dev/ath/ath_hal/ar5416 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, 02 Apr 2011 00:24:14 -0000 Author: adrian Date: Sat Apr 2 00:24:13 2011 New Revision: 220258 URL: http://svn.freebsd.org/changeset/base/220258 Log: Add some more debugging Modified: head/sys/dev/ath/ath_hal/ar5416/ar2133.c Modified: head/sys/dev/ath/ath_hal/ar5416/ar2133.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar2133.c Sat Apr 2 00:08:32 2011 (r220257) +++ head/sys/dev/ath/ath_hal/ar5416/ar2133.c Sat Apr 2 00:24:13 2011 (r220258) @@ -251,11 +251,19 @@ ar2133SetRfRegs(struct ath_hal *ah, cons /* Only the 5 or 2 GHz OB/DB need to be set for a mode */ if (IEEE80211_IS_CHAN_2GHZ(chan)) { + HALDEBUG(ah, HAL_DEBUG_EEPROM, "%s: 2ghz: OB_2:%d, DB_2:%d\n", + __func__, + ath_hal_eepromGet(ah, AR_EEP_OB_2, AH_NULL), + ath_hal_eepromGet(ah, AR_EEP_DB_2, AH_NULL)); ar5416ModifyRfBuffer(priv->Bank6Data, ath_hal_eepromGet(ah, AR_EEP_OB_2, AH_NULL), 3, 197, 0); ar5416ModifyRfBuffer(priv->Bank6Data, ath_hal_eepromGet(ah, AR_EEP_DB_2, AH_NULL), 3, 194, 0); } else { + HALDEBUG(ah, HAL_DEBUG_EEPROM, "%s: 5ghz: OB_5:%d, DB_5:%d\n", + __func__, + ath_hal_eepromGet(ah, AR_EEP_OB_5, AH_NULL), + ath_hal_eepromGet(ah, AR_EEP_DB_5, AH_NULL)); ar5416ModifyRfBuffer(priv->Bank6Data, ath_hal_eepromGet(ah, AR_EEP_OB_5, AH_NULL), 3, 203, 0); ar5416ModifyRfBuffer(priv->Bank6Data, From owner-svn-src-head@FreeBSD.ORG Sat Apr 2 00:27:22 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 72A39106566C; Sat, 2 Apr 2011 00:27:22 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 642398FC1A; Sat, 2 Apr 2011 00:27:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p320RMXb065110; Sat, 2 Apr 2011 00:27:22 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p320RMa2065108; Sat, 2 Apr 2011 00:27:22 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201104020027.p320RMa2065108@svn.freebsd.org> From: Adrian Chadd Date: Sat, 2 Apr 2011 00:27:22 +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: r220259 - head/sys/dev/ath/ath_hal/ar5416 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, 02 Apr 2011 00:27:22 -0000 Author: adrian Date: Sat Apr 2 00:27:22 2011 New Revision: 220259 URL: http://svn.freebsd.org/changeset/base/220259 Log: From ath9k - clear the RX descriptor status before recycling it. Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c Sat Apr 2 00:24:13 2011 (r220258) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416_recv.c Sat Apr 2 00:27:22 2011 (r220259) @@ -67,6 +67,7 @@ ar5416SetupRxDesc(struct ath_hal *ah, st uint32_t size, u_int flags) { struct ar5416_desc *ads = AR5416DESC(ds); + HAL_CAPABILITIES *pCap = &AH_PRIVATE(ah)->ah_caps; HALASSERT((size &~ AR_BufLen) == 0); @@ -77,6 +78,10 @@ ar5416SetupRxDesc(struct ath_hal *ah, st /* this should be enough */ ads->ds_rxstatus8 &= ~AR_RxDone; + /* clear the rest of the status fields */ + if (! pCap->halAutoSleepSupport) + OS_MEMZERO(&(ads->u), sizeof(ads->u)); + return AH_TRUE; } From owner-svn-src-head@FreeBSD.ORG Sat Apr 2 03:48: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 6C5A0106564A; Sat, 2 Apr 2011 03:48:15 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5CBDA8FC12; Sat, 2 Apr 2011 03:48:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p323mFFB069367; Sat, 2 Apr 2011 03:48:15 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p323mFeb069365; Sat, 2 Apr 2011 03:48:15 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201104020348.p323mFeb069365@svn.freebsd.org> From: Adrian Chadd Date: Sat, 2 Apr 2011 03:48: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: r220260 - head/sys/mips/atheros 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, 02 Apr 2011 03:48:15 -0000 Author: adrian Date: Sat Apr 2 03:48:15 2011 New Revision: 220260 URL: http://svn.freebsd.org/changeset/base/220260 Log: A handful of the openwrt devices use a MAC address that's at a hard-coded offset in the flash. Some devices (eg the TPLink WR-1043ND) don't have a flash environment partition which can be queried for the current board settings. This particular workaround allows for image creators to use a hint to set the base MAC address. For example: hint.arge.0.eeprommac=0x1f01fc00 Modified: head/sys/mips/atheros/if_arge.c Modified: head/sys/mips/atheros/if_arge.c ============================================================================== --- head/sys/mips/atheros/if_arge.c Sat Apr 2 00:27:22 2011 (r220259) +++ head/sys/mips/atheros/if_arge.c Sat Apr 2 03:48:15 2011 (r220260) @@ -227,11 +227,32 @@ arge_attach(device_t dev) uint32_t reg, rnd; int is_base_mac_empty, i, phys_total; uint32_t hint; + long eeprom_mac_addr = 0; sc = device_get_softc(dev); sc->arge_dev = dev; sc->arge_mac_unit = device_get_unit(dev); + /* + * Some units (eg the TP-Link WR-1043ND) do not have a convenient + * EEPROM location to read the ethernet MAC address from. + * OpenWRT simply snaffles it from a fixed location. + * + * Since multiple units seem to use this feature, include + * a method of setting the MAC address based on an flash location + * in CPU address space. + */ + if (sc->arge_mac_unit == 0 && + resource_long_value(device_get_name(dev), device_get_unit(dev), + "eeprommac", &eeprom_mac_addr) == 0) { + int i; + const char *mac = (const char *) MIPS_PHYS_TO_KSEG1(eeprom_mac_addr); + device_printf(dev, "Overriding MAC from EEPROM\n"); + for (i = 0; i < 6; i++) { + ar711_base_mac[i] = mac[i]; + } + } + KASSERT(((sc->arge_mac_unit == 0) || (sc->arge_mac_unit == 1)), ("if_arge: Only MAC0 and MAC1 supported")); From owner-svn-src-head@FreeBSD.ORG Sat Apr 2 04:05:32 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 7A67B1065673; Sat, 2 Apr 2011 04:05:32 +0000 (UTC) (envelope-from juli@clockworksquid.com) Received: from mail-gw0-f54.google.com (mail-gw0-f54.google.com [74.125.83.54]) by mx1.freebsd.org (Postfix) with ESMTP id 079FC8FC0C; Sat, 2 Apr 2011 04:05:31 +0000 (UTC) Received: by gwb15 with SMTP id 15so1933717gwb.13 for ; Fri, 01 Apr 2011 21:05:31 -0700 (PDT) Received: by 10.151.158.18 with SMTP id k18mr4692694ybo.299.1301717131106; Fri, 01 Apr 2011 21:05:31 -0700 (PDT) MIME-Version: 1.0 Sender: juli@clockworksquid.com Received: by 10.151.13.12 with HTTP; Fri, 1 Apr 2011 21:05:11 -0700 (PDT) In-Reply-To: <201104020348.p323mFeb069365@svn.freebsd.org> References: <201104020348.p323mFeb069365@svn.freebsd.org> From: Juli Mallett Date: Fri, 1 Apr 2011 21:05:11 -0700 X-Google-Sender-Auth: U9GqEbsG4SOf1sBRUnoHmdRrE9s Message-ID: To: Adrian Chadd 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: r220260 - head/sys/mips/atheros 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, 02 Apr 2011 04:05:32 -0000 On Fri, Apr 1, 2011 at 20:48, Adrian Chadd wrote: > Author: adrian > Date: Sat Apr =A02 03:48:15 2011 > New Revision: 220260 > URL: http://svn.freebsd.org/changeset/base/220260 > > Log: > =A0A handful of the openwrt devices use a MAC address that's at a hard-co= ded > =A0offset in the flash. > > =A0Some devices (eg the TPLink WR-1043ND) don't have a flash environment > =A0partition which can be queried for the current board settings. > > =A0This particular workaround allows for image creators to use a hint > =A0to set the base MAC address. For example: > > =A0hint.arge.0.eeprommac=3D0x1f01fc00 It isn't obvious from the wording here that it's the address of the MAC in flash, it sounds like it's the base MAC-address. Might be useful to add "phys" or "pa" or something to suggest that it's a physical address in RAM. From owner-svn-src-head@FreeBSD.ORG Sat Apr 2 05:01: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 3C7DD1065672; Sat, 2 Apr 2011 05:01:10 +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 2D97F8FC08; Sat, 2 Apr 2011 05:01:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3251Aog070948; Sat, 2 Apr 2011 05:01:10 GMT (envelope-from gordon@svn.freebsd.org) Received: (from gordon@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3251AEL070946; Sat, 2 Apr 2011 05:01:10 GMT (envelope-from gordon@svn.freebsd.org) Message-Id: <201104020501.p3251AEL070946@svn.freebsd.org> From: Gordon Tetlow Date: Sat, 2 Apr 2011 05:01: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: r220261 - head/usr.bin/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: Sat, 02 Apr 2011 05:01:10 -0000 Author: gordon Date: Sat Apr 2 05:01:09 2011 New Revision: 220261 URL: http://svn.freebsd.org/changeset/base/220261 Log: Overhaul locale handling. Use locale(1) to determine the locale instead of trying to hand roll it. Correctly construct groff call based on charset and locale independently, not the mix between the two. Submitted by: uqs@ Modified: head/usr.bin/man/man.sh Modified: head/usr.bin/man/man.sh ============================================================================== --- head/usr.bin/man/man.sh Sat Apr 2 03:48:15 2011 (r220260) +++ head/usr.bin/man/man.sh Sat Apr 2 05:01:09 2011 (r220261) @@ -312,11 +312,10 @@ man_display_page() { # device flag (-T) we have to pass to eqn(1) and groff(1). Then, # setup the pipeline of commands based on the user's request. - # Apparently the locale flags are switched on where the manpage is - # found not just the locale env variables. - nroff_dev="ascii" - case "X${use_locale}X${manpage}" in - XyesX*/${man_lang}*${man_charset}/*) + # If the manpage is from a particular charset, we need to setup nroff + # to properly output for the correct device. + case "${manpage}" in + *.${man_charset}/*) # I don't pretend to know this; I'm just copying from the # previous version of man(1). case "$man_charset" in @@ -327,9 +326,20 @@ man_display_page() { *) nroff_dev="ascii" ;; esac - NROFF="$NROFF -T$nroff_dev -dlocale=$man_lang.$man_charset" + NROFF="$NROFF -T$nroff_dev" EQN="$EQN -T$nroff_dev" + # Iff the manpage is from the locale and not just the charset, + # then we need to define the locale string. + case "${manpage}" in + */${man_lang}_${man_country}.${man_charset}/*) + NROFF="$NROFF -dlocale=$man_lang.$man_charset" + ;; + */${man_lang}.${man_charset}/*) + NROFF="$NROFF -dlocale=$man_lang.$man_charset" + ;; + esac + # Allow language specific calls to override the default # set of utilities. l=$(echo $man_lang | tr [:lower:] [:upper:]) @@ -557,28 +567,38 @@ man_setup() { # Usage: man_setup_locale # Setup necessary locale variables. man_setup_locale() { + local lang_cc + + locpaths='.' + man_charset='US-ASCII' + # Setup locale information. if [ -n "$oflag" ]; then - decho "Using non-localized manpages" - unset use_locale - elif [ -n "$LC_ALL" ]; then - parse_locale "$LC_ALL" - elif [ -n "$LC_CTYPE" ]; then - parse_locale "$LC_CTYPE" - elif [ -n "$LANG" ]; then - parse_locale "$LANG" - fi - - if [ -n "$use_locale" ]; then - locpaths="${man_lang}_${man_country}.${man_charset}" - locpaths="$locpaths:$man_lang.$man_charset" - if [ "$man_lang" != "en" ]; then - locpaths="$locpaths:en.$man_charset" - fi - locpaths="$locpaths:." + decho 'Using non-localized manpages' else - locpaths="." + # Use the locale tool to give us the proper LC_CTYPE + eval $( $LOCALE ) + + case "$LC_CTYPE" in + C) ;; + POSIX) ;; + [a-z][a-z]_[A-Z][A-Z]\.*) + lang_cc="${LC_CTYPE%.*}" + man_lang="${LC_CTYPE%_*}" + man_country="${lang_cc#*_}" + man_charset="${LC_CTYPE#*.}" + locpaths="$LC_CTYPE" + locpaths="$locpaths:$man_lang.$man_charset" + if [ "$man_lang" != "en" ]; then + locpaths="$locpaths:en.$man_charset" + fi + locpaths="$locpaths:." + ;; + *) echo 'Unknown locale, assuming C' >&2 + ;; + esac fi + decho "Using locale paths: $locpaths" } @@ -660,28 +680,6 @@ parse_file() { done < "$file" } -# Usage: parse_locale localestring -# Setup locale variables for proper parsing. -parse_locale() { - local lang_cc - - case "$1" in - C) ;; - POSIX) ;; - [a-z][a-z]_[A-Z][A-Z]\.*) lang_cc="${1%.*}" - man_lang="${1%_*}" - man_country="${lang_cc#*_}" - man_charset="${1#*.}" - use_locale=yes - return 0 - ;; - *) echo 'Unknown locale, assuming C' >&2 - ;; - esac - - unset use_locale -} - # Usage: search_path # Traverse $PATH looking for manpaths. search_path() { @@ -893,6 +891,7 @@ do_whatis() { EQN=/usr/bin/eqn COL=/usr/bin/col +LOCALE=/usr/bin/locale NROFF='/usr/bin/groff -S -Wall -mtty-char -man' PIC=/usr/bin/pic SYSCTL=/sbin/sysctl From owner-svn-src-head@FreeBSD.ORG Sat Apr 2 06:56: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 85A6E106566C; Sat, 2 Apr 2011 06:56:07 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5D4128FC13; Sat, 2 Apr 2011 06:56:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p326u77e073509; Sat, 2 Apr 2011 06:56:07 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p326u7GW073507; Sat, 2 Apr 2011 06:56:07 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201104020656.p326u7GW073507@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sat, 2 Apr 2011 06:56: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: r220264 - head/sys/geom/gate 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, 02 Apr 2011 06:56:07 -0000 Author: pjd Date: Sat Apr 2 06:56:06 2011 New Revision: 220264 URL: http://svn.freebsd.org/changeset/base/220264 Log: GEOM has an internal mechanism to deal with ENOMEM errors returned via g_io_deliver(). In such case it increases 'pace' counter on each ENOMEM and reschedules the request. The 'pace' counter is decreased for each request going down, but until 'pace' is greater than zero, GEOM will handle at most 10 requests per second. For GEOM GATE users that are proxy to local GEOM providers (like ggatel(8) and HAST) we can end up with almost permanent slow down of GEOM down queue. This is because once we reach GEOM GATE queue limit, we return ENOMEM to the GEOM. This means that we have, eg. 1024 I/O requests in the GEOM GATE queue. To make room in the queue and stop returning ENOMEM we need to proceed the requests of course, but those requests are handled by userland daemons that handle them by reading/writing also from/to local GEOM providers. For example with HAST, a new requests comes to /dev/hast/data, which is GEOM GATE provider. GEOM GATE passes the request to hastd(8) and hastd(8) reads/writes from/to /dev/da0. Once we reach GEOM GATE queue limit, to free up a slot in GEOM GATE queue, hastd(8) has to read/write from/to /dev/da0, but this request will also be very slow, because GEOM now slows down all the requests. We end up with full queue that we can unload at the speed of 10 requests per second. This simply looks like a deadlock. Fix it by allowing userland daemons that work with both GEOM GATE and local GEOM providers to specify unlimited queue size, so GEOM GATE will never return ENOMEM to the GEOM. MFC after: 1 week Modified: head/sys/geom/gate/g_gate.c Modified: head/sys/geom/gate/g_gate.c ============================================================================== --- head/sys/geom/gate/g_gate.c Sat Apr 2 06:25:13 2011 (r220263) +++ head/sys/geom/gate/g_gate.c Sat Apr 2 06:56:06 2011 (r220264) @@ -194,7 +194,7 @@ g_gate_start(struct bio *bp) } mtx_lock(&sc->sc_queue_mtx); - if (sc->sc_queue_count > sc->sc_queue_size) { + if (sc->sc_queue_size > 0 && sc->sc_queue_count > sc->sc_queue_size) { mtx_unlock(&sc->sc_queue_mtx); G_GATE_LOGREQ(1, bp, "Queue full, request canceled."); g_io_deliver(bp, ENOMEM); From owner-svn-src-head@FreeBSD.ORG Sat Apr 2 06:59: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 B1A30106566C; Sat, 2 Apr 2011 06:59:05 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 893568FC12; Sat, 2 Apr 2011 06:59:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p326x5RS073608; Sat, 2 Apr 2011 06:59:05 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p326x5W4073605; Sat, 2 Apr 2011 06:59:05 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201104020659.p326x5W4073605@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sat, 2 Apr 2011 06:59:05 +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: r220265 - head/sbin/ggate/ggatel 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, 02 Apr 2011 06:59:05 -0000 Author: pjd Date: Sat Apr 2 06:59:05 2011 New Revision: 220265 URL: http://svn.freebsd.org/changeset/base/220265 Log: Because ggatel(8) operates on local GEOM providers, use unlimited queue size in GEOM GATE to fix the issue described in r220264. This also means that we no longer need -q option, remove it. Don't bother to leaving it as a no-op, as ggatel(8) is just an example utility. Modified: head/sbin/ggate/ggatel/ggatel.8 head/sbin/ggate/ggatel/ggatel.c Modified: head/sbin/ggate/ggatel/ggatel.8 ============================================================================== --- head/sbin/ggate/ggatel/ggatel.8 Sat Apr 2 06:56:06 2011 (r220264) +++ head/sbin/ggate/ggatel/ggatel.8 Sat Apr 2 06:59:05 2011 (r220265) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 26, 2004 +.Dd April 2, 2011 .Dt GGATEL 8 .Os .Sh NAME @@ -35,7 +35,6 @@ .Cm create .Op Fl v .Op Fl o Cm ro | wo | rw -.Op Fl q Ar queue_size .Op Fl s Ar sectorsize .Op Fl t Ar timeout .Op Fl u Ar unit @@ -100,10 +99,6 @@ or read-write .Pq Cm rw . Default is .Cm rw . -.It Fl q Ar queue_size -Number of pending I/O requests that can be queued before they will -start to be canceled. -Default is 1024. .It Fl s Ar sectorsize Sector size for .Nm ggate Modified: head/sbin/ggate/ggatel/ggatel.c ============================================================================== --- head/sbin/ggate/ggatel/ggatel.c Sat Apr 2 06:56:06 2011 (r220264) +++ head/sbin/ggate/ggatel/ggatel.c Sat Apr 2 06:59:05 2011 (r220265) @@ -53,7 +53,6 @@ static const char *path = NULL; static int unit = G_GATE_UNIT_AUTO; static unsigned flags = 0; static int force = 0; -static unsigned queue_size = G_GATE_QUEUE_SIZE; static unsigned sectorsize = 0; static unsigned timeout = G_GATE_TIMEOUT; @@ -61,7 +60,7 @@ static void usage(void) { - fprintf(stderr, "usage: %s create [-v] [-o ] [-q queue_size] " + fprintf(stderr, "usage: %s create [-v] [-o ] " "[-s sectorsize] [-t timeout] [-u unit] \n", getprogname()); fprintf(stderr, " %s rescue [-v] [-o ] <-u unit> " "\n", getprogname()); @@ -182,7 +181,7 @@ g_gatel_create(void) ggioc.gctl_sectorsize = sectorsize; ggioc.gctl_timeout = timeout; ggioc.gctl_flags = flags; - ggioc.gctl_maxcount = queue_size; + ggioc.gctl_maxcount = 0; strlcpy(ggioc.gctl_info, path, sizeof(ggioc.gctl_info)); g_gate_ioctl(G_GATE_CMD_CREATE, &ggioc); if (unit == -1) @@ -230,7 +229,7 @@ main(int argc, char *argv[]) for (;;) { int ch; - ch = getopt(argc, argv, "fo:q:s:t:u:v"); + ch = getopt(argc, argv, "fo:s:t:u:v"); if (ch == -1) break; switch (ch) { @@ -253,14 +252,6 @@ main(int argc, char *argv[]) "Invalid argument for '-o' option."); } break; - case 'q': - if (action != CREATE) - usage(); - errno = 0; - queue_size = strtoul(optarg, NULL, 10); - if (queue_size == 0 && errno != 0) - errx(EXIT_FAILURE, "Invalid queue_size."); - break; case 's': if (action != CREATE) usage(); From owner-svn-src-head@FreeBSD.ORG Sat Apr 2 07:01: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 54127106566B; Sat, 2 Apr 2011 07:01:10 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 469A38FC0C; Sat, 2 Apr 2011 07:01:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3271AsY073708; Sat, 2 Apr 2011 07:01:10 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3271AUt073706; Sat, 2 Apr 2011 07:01:10 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201104020701.p3271AUt073706@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sat, 2 Apr 2011 07:01: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: r220266 - 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: Sat, 02 Apr 2011 07:01:10 -0000 Author: pjd Date: Sat Apr 2 07:01:09 2011 New Revision: 220266 URL: http://svn.freebsd.org/changeset/base/220266 Log: Handle the problem described in r220264 by using GEOM GATE queue of unlimited length. This should fix deadlocks reported by HAST users. MFC after: 1 week Modified: head/sbin/hastd/primary.c Modified: head/sbin/hastd/primary.c ============================================================================== --- head/sbin/hastd/primary.c Sat Apr 2 06:59:05 2011 (r220265) +++ head/sbin/hastd/primary.c Sat Apr 2 07:01:09 2011 (r220266) @@ -761,7 +761,7 @@ init_ggate(struct hast_resource *res) ggiocreate.gctl_mediasize = res->hr_datasize; ggiocreate.gctl_sectorsize = res->hr_local_sectorsize; ggiocreate.gctl_flags = 0; - ggiocreate.gctl_maxcount = G_GATE_MAX_QUEUE_SIZE; + ggiocreate.gctl_maxcount = 0; ggiocreate.gctl_timeout = 0; ggiocreate.gctl_unit = G_GATE_NAME_GIVEN; snprintf(ggiocreate.gctl_name, sizeof(ggiocreate.gctl_name), "hast/%s", From owner-svn-src-head@FreeBSD.ORG Sat Apr 2 09:22: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 E786B106564A; Sat, 2 Apr 2011 09:22:06 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DF6E88FC13; Sat, 2 Apr 2011 09:22:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p329M66t076874; Sat, 2 Apr 2011 09:22:06 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p329M6hF076872; Sat, 2 Apr 2011 09:22:06 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201104020922.p329M6hF076872@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sat, 2 Apr 2011 09:22: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: r220270 - 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: Sat, 02 Apr 2011 09:22:07 -0000 Author: pjd Date: Sat Apr 2 09:22:06 2011 New Revision: 220270 URL: http://svn.freebsd.org/changeset/base/220270 Log: Allow to disable sends or receives on a socket using shutdown(2) by interpreting NULL 'data' argument passed to proto_common_send() or proto_common_recv() as a will to do so. MFC after: 1 month Modified: head/sbin/hastd/proto_common.c Modified: head/sbin/hastd/proto_common.c ============================================================================== --- head/sbin/hastd/proto_common.c Sat Apr 2 08:45:13 2011 (r220269) +++ head/sbin/hastd/proto_common.c Sat Apr 2 09:22:06 2011 (r220270) @@ -82,6 +82,17 @@ proto_common_send(int sock, const unsign size_t sendsize; PJDLOG_ASSERT(sock >= 0); + + if (data == NULL) { + /* The caller is just trying to decide about direction. */ + + PJDLOG_ASSERT(size == 0); + + if (shutdown(sock, SHUT_RD) == -1) + return (errno); + return (0); + } + PJDLOG_ASSERT(data != NULL); PJDLOG_ASSERT(size > 0); @@ -141,6 +152,17 @@ proto_common_recv(int sock, unsigned cha ssize_t done; PJDLOG_ASSERT(sock >= 0); + + if (data == NULL) { + /* The caller is just trying to decide about direction. */ + + PJDLOG_ASSERT(size == 0); + + if (shutdown(sock, SHUT_WR) == -1) + return (errno); + return (0); + } + PJDLOG_ASSERT(data != NULL); PJDLOG_ASSERT(size > 0); From owner-svn-src-head@FreeBSD.ORG Sat Apr 2 09:25: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 03CA91065689; Sat, 2 Apr 2011 09:25:14 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8EC938FC14; Sat, 2 Apr 2011 09:25:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p329PDWW076970; Sat, 2 Apr 2011 09:25:13 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p329PDX3076967; Sat, 2 Apr 2011 09:25:13 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201104020925.p329PDX3076967@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sat, 2 Apr 2011 09:25: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: r220271 - 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: Sat, 02 Apr 2011 09:25:14 -0000 Author: pjd Date: Sat Apr 2 09:25:13 2011 New Revision: 220271 URL: http://svn.freebsd.org/changeset/base/220271 Log: Declare directions for sockets between primary and secondary. In HAST we use two sockets - one for only sending the data and one for only receiving the data. MFC after: 1 month Modified: head/sbin/hastd/primary.c head/sbin/hastd/secondary.c Modified: head/sbin/hastd/primary.c ============================================================================== --- head/sbin/hastd/primary.c Sat Apr 2 09:22:06 2011 (r220270) +++ head/sbin/hastd/primary.c Sat Apr 2 09:25:13 2011 (r220271) @@ -701,6 +701,11 @@ init_remote(struct hast_resource *res, s (void)hast_activemap_flush(res); } nv_free(nvin); + /* Setup directions. */ + if (proto_send(out, NULL, 0) == -1) + pjdlog_errno(LOG_WARNING, "Unable to set connection direction"); + if (proto_recv(in, NULL, 0) == -1) + pjdlog_errno(LOG_WARNING, "Unable to set connection direction"); pjdlog_info("Connected to %s.", res->hr_remoteaddr); if (inp != NULL && outp != NULL) { *inp = in; Modified: head/sbin/hastd/secondary.c ============================================================================== --- head/sbin/hastd/secondary.c Sat Apr 2 09:22:06 2011 (r220270) +++ head/sbin/hastd/secondary.c Sat Apr 2 09:25:13 2011 (r220271) @@ -183,6 +183,10 @@ init_remote(struct hast_resource *res, s unsigned char *map; size_t mapsize; + /* Setup direction. */ + if (proto_send(res->hr_remoteout, NULL, 0) == -1) + pjdlog_errno(LOG_WARNING, "Unable to set connection direction"); + map = NULL; mapsize = 0; nvout = nv_alloc(); @@ -346,6 +350,9 @@ init_remote(struct hast_resource *res, s if (map != NULL) free(map); nv_free(nvout); + /* Setup direction. */ + if (proto_recv(res->hr_remotein, NULL, 0) == -1) + pjdlog_errno(LOG_WARNING, "Unable to set connection direction"); if (res->hr_secondary_localcnt > res->hr_primary_remotecnt && res->hr_primary_localcnt > res->hr_secondary_remotecnt) { /* Exit on split-brain. */ From owner-svn-src-head@FreeBSD.ORG Sat Apr 2 09:29: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 DC386106564A; Sat, 2 Apr 2011 09:29:53 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B9E878FC0A; Sat, 2 Apr 2011 09:29:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p329Trc6077086; Sat, 2 Apr 2011 09:29:53 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p329TrRC077084; Sat, 2 Apr 2011 09:29:53 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201104020929.p329TrRC077084@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sat, 2 Apr 2011 09:29: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: r220272 - 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: Sat, 02 Apr 2011 09:29:54 -0000 Author: pjd Date: Sat Apr 2 09:29:53 2011 New Revision: 220272 URL: http://svn.freebsd.org/changeset/base/220272 Log: When we are operating on blocking socket and get EAGAIN on send(2) or recv(2) this means that request timed out. Translate the meaningless EAGAIN to ETIMEDOUT to give administrator a hint that he might need to increase timeout in configuration file. MFC after: 1 month Modified: head/sbin/hastd/proto_common.c Modified: head/sbin/hastd/proto_common.c ============================================================================== --- head/sbin/hastd/proto_common.c Sat Apr 2 09:25:13 2011 (r220271) +++ head/sbin/hastd/proto_common.c Sat Apr 2 09:29:53 2011 (r220272) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2009-2010 The FreeBSD Foundation + * Copyright (c) 2011 Pawel Jakub Dawidek * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from @@ -34,8 +35,11 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include #include #include +#include #include "pjdlog.h" #include "proto_impl.h" @@ -45,6 +49,16 @@ __FBSDID("$FreeBSD$"); #define MAX_SEND_SIZE 32768 #endif +static bool +blocking_socket(int sock) +{ + int flags; + + flags = fcntl(sock, F_GETFL); + PJDLOG_ASSERT(flags >= 0); + return ((flags & O_NONBLOCK) == 0); +} + static int proto_descriptor_send(int sock, int fd) { @@ -99,11 +113,19 @@ proto_common_send(int sock, const unsign do { sendsize = size < MAX_SEND_SIZE ? size : MAX_SEND_SIZE; done = send(sock, data, sendsize, MSG_NOSIGNAL); - if (done == 0) + if (done == 0) { return (ENOTCONN); - else if (done < 0) { + } else if (done < 0) { if (errno == EINTR) continue; + /* + * If this is blocking socket and we got EAGAIN, this + * means the request timed out. Translate errno to + * ETIMEDOUT, to give administrator a hint to + * eventually increase timeout. + */ + if (errno == EAGAIN && blocking_socket(sock)) + errno = ETIMEDOUT; return (errno); } data += done; @@ -169,10 +191,19 @@ proto_common_recv(int sock, unsigned cha do { done = recv(sock, data, size, MSG_WAITALL); } while (done == -1 && errno == EINTR); - if (done == 0) + if (done == 0) { return (ENOTCONN); - else if (done < 0) + } else if (done < 0) { + /* + * If this is blocking socket and we got EAGAIN, this + * means the request timed out. Translate errno to + * ETIMEDOUT, to give administrator a hint to + * eventually increase timeout. + */ + if (errno == EAGAIN && blocking_socket(sock)) + errno = ETIMEDOUT; return (errno); + } if (fdp == NULL) return (0); return (proto_descriptor_recv(sock, fdp)); From owner-svn-src-head@FreeBSD.ORG Sat Apr 2 09:31: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 A033C106566B; Sat, 2 Apr 2011 09:31:02 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 989418FC15; Sat, 2 Apr 2011 09:31:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p329V2Ve077156; Sat, 2 Apr 2011 09:31:02 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p329V2s8077154; Sat, 2 Apr 2011 09:31:02 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201104020931.p329V2s8077154@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sat, 2 Apr 2011 09:31: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: r220273 - 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: Sat, 02 Apr 2011 09:31:02 -0000 Author: pjd Date: Sat Apr 2 09:31:02 2011 New Revision: 220273 URL: http://svn.freebsd.org/changeset/base/220273 Log: Handle ENOBUFS on send(2) by retrying for a while and logging the problem. MFC after: 1 week Modified: head/sbin/hastd/proto_common.c Modified: head/sbin/hastd/proto_common.c ============================================================================== --- head/sbin/hastd/proto_common.c Sat Apr 2 09:29:53 2011 (r220272) +++ head/sbin/hastd/proto_common.c Sat Apr 2 09:31:02 2011 (r220273) @@ -94,6 +94,7 @@ proto_common_send(int sock, const unsign { ssize_t done; size_t sendsize; + int errcount = 0; PJDLOG_ASSERT(sock >= 0); @@ -118,6 +119,23 @@ proto_common_send(int sock, const unsign } else if (done < 0) { if (errno == EINTR) continue; + if (errno == ENOBUFS) { + /* + * If there are no buffers we retry. + * After each try we increase delay before the + * next one and we give up after fifteen times. + * This gives 11s of total wait time. + */ + if (errcount == 15) { + pjdlog_warning("Getting ENOBUFS errors for 11s on send(), giving up."); + } else { + if (errcount == 0) + pjdlog_warning("Got ENOBUFS error on send(), retrying for a bit."); + errcount++; + usleep(100000 * errcount); + continue; + } + } /* * If this is blocking socket and we got EAGAIN, this * means the request timed out. Translate errno to @@ -131,6 +149,10 @@ proto_common_send(int sock, const unsign data += done; size -= done; } while (size > 0); + if (errcount > 0) { + pjdlog_info("Data sent successfully after %d ENOBUFS error%s.", + errcount, errcount == 1 ? "" : "s"); + } if (fd == -1) return (0); From owner-svn-src-head@FreeBSD.ORG Sat Apr 2 09:31: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 2505B106566B; Sat, 2 Apr 2011 09:31:58 +0000 (UTC) (envelope-from pawel@dawidek.net) Received: from mail.garage.freebsd.pl (60.wheelsystems.com [83.12.187.60]) by mx1.freebsd.org (Postfix) with ESMTP id C8BEB8FC22; Sat, 2 Apr 2011 09:31:57 +0000 (UTC) Received: by mail.garage.freebsd.pl (Postfix, from userid 65534) id 2C65645F60; Sat, 2 Apr 2011 11:31:56 +0200 (CEST) Received: from localhost (89-73-195-149.dynamic.chello.pl [89.73.195.149]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.garage.freebsd.pl (Postfix) with ESMTP id 5326B45C98; Sat, 2 Apr 2011 11:31:50 +0200 (CEST) Date: Sat, 2 Apr 2011 11:31:46 +0200 From: Pawel Jakub Dawidek To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-ID: <20110402093146.GC1849@garage.freebsd.pl> References: <201104020922.p329M6hF076872@svn.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="kVXhAStRUZ/+rrGn" Content-Disposition: inline In-Reply-To: <201104020922.p329M6hF076872@svn.freebsd.org> X-OS: FreeBSD 9.0-CURRENT amd64 User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on mail.garage.freebsd.pl X-Spam-Level: X-Spam-Status: No, score=-0.6 required=4.5 tests=BAYES_00,RCVD_IN_SORBS_DUL autolearn=no version=3.0.4 Cc: Subject: Re: svn commit: r220270 - 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: Sat, 02 Apr 2011 09:31:58 -0000 --kVXhAStRUZ/+rrGn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Apr 02, 2011 at 09:22:06AM +0000, Pawel Jakub Dawidek wrote: > Author: pjd > Date: Sat Apr 2 09:22:06 2011 > New Revision: 220270 > URL: http://svn.freebsd.org/changeset/base/220270 >=20 > Log: > Allow to disable sends or receives on a socket using shutdown(2) by > interpreting NULL 'data' argument passed to proto_common_send() or > proto_common_recv() as a will to do so. > =20 > MFC after: 1 month This should've been 1 week here in the next two commits. --=20 Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com --kVXhAStRUZ/+rrGn Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAk2W7QIACgkQForvXbEpPzRFRwCaA6JyroJPktKMsOVYsCaOfAEK dEMAnA1M64Kb9I5yAbc2PQBJmgfpeSYy =bMbT -----END PGP SIGNATURE----- --kVXhAStRUZ/+rrGn-- From owner-svn-src-head@FreeBSD.ORG Sat Apr 2 09:34: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 C617A106564A; Sat, 2 Apr 2011 09:34:33 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BE80D8FC1D; Sat, 2 Apr 2011 09:34:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p329YXHu077274; Sat, 2 Apr 2011 09:34:33 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p329YXcg077271; Sat, 2 Apr 2011 09:34:33 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201104020934.p329YXcg077271@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sat, 2 Apr 2011 09:34: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: r220274 - 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: Sat, 02 Apr 2011 09:34:33 -0000 Author: pjd Date: Sat Apr 2 09:34:33 2011 New Revision: 220274 URL: http://svn.freebsd.org/changeset/base/220274 Log: Increase default timeout from 5 seconds to 20 seconds. 5 seconds is definitely to short under heavy load and I was experiencing those timeouts in my recent tests. MFC after: 1 week Modified: head/sbin/hastd/hast.conf.5 head/sbin/hastd/hast.h Modified: head/sbin/hastd/hast.conf.5 ============================================================================== --- head/sbin/hastd/hast.conf.5 Sat Apr 2 09:31:02 2011 (r220273) +++ head/sbin/hastd/hast.conf.5 Sat Apr 2 09:34:33 2011 (r220274) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 20, 2011 +.Dd April 2, 2011 .Dt HAST.CONF 5 .Os .Sh NAME @@ -241,7 +241,7 @@ LZF is very fast, general purpose compre .Pp Connection timeout in seconds. The default value is -.Va 5 . +.Va 20 . .It Ic exec Aq path .Pp Execute the given program on various HAST events. Modified: head/sbin/hastd/hast.h ============================================================================== --- head/sbin/hastd/hast.h Sat Apr 2 09:31:02 2011 (r220273) +++ head/sbin/hastd/hast.h Sat Apr 2 09:34:33 2011 (r220274) @@ -83,7 +83,7 @@ #define HIO_KEEPALIVE 5 #define HAST_USER "hast" -#define HAST_TIMEOUT 5 +#define HAST_TIMEOUT 20 #define HAST_CONFIG "/etc/hast.conf" #define HAST_CONTROL "/var/run/hastctl" #define HASTD_LISTEN "tcp4://0.0.0.0:8457" From owner-svn-src-head@FreeBSD.ORG Sat Apr 2 09:46: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 3DFDF106566B; Sat, 2 Apr 2011 09:46:10 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 358CF8FC12; Sat, 2 Apr 2011 09:46:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p329kAnN077563; Sat, 2 Apr 2011 09:46:10 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p329kAlp077561; Sat, 2 Apr 2011 09:46:10 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201104020946.p329kAlp077561@svn.freebsd.org> From: Adrian Chadd Date: Sat, 2 Apr 2011 09:46: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: r220275 - head/sys/modules/ath_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, 02 Apr 2011 09:46:10 -0000 Author: adrian Date: Sat Apr 2 09:46:09 2011 New Revision: 220275 URL: http://svn.freebsd.org/changeset/base/220275 Log: Add missing include. Reported by: Ulrich Sporlein Modified: head/sys/modules/ath_pci/Makefile Modified: head/sys/modules/ath_pci/Makefile ============================================================================== --- head/sys/modules/ath_pci/Makefile Sat Apr 2 09:34:33 2011 (r220274) +++ head/sys/modules/ath_pci/Makefile Sat Apr 2 09:46:09 2011 (r220275) @@ -34,7 +34,7 @@ KMOD= if_ath_pci SRCS= if_ath_pci.c -SRCS+= device_if.h bus_if.h pci_if.h +SRCS+= device_if.h bus_if.h pci_if.h opt_ah.h CFLAGS+= -I. -I${.CURDIR}/../../dev/ath -I${.CURDIR}/../../dev/ath/ath_hal From owner-svn-src-head@FreeBSD.ORG Sat Apr 2 15:02:43 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 5CAAE106566B; Sat, 2 Apr 2011 15:02:43 +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 32F648FC18; Sat, 2 Apr 2011 15:02:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p32F2htK085659; Sat, 2 Apr 2011 15:02:43 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p32F2h3n085657; Sat, 2 Apr 2011 15:02:43 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201104021502.p32F2h3n085657@svn.freebsd.org> From: Edward Tomasz Napierala Date: Sat, 2 Apr 2011 15:02:43 +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: r220279 - 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: Sat, 02 Apr 2011 15:02:43 -0000 Author: trasz Date: Sat Apr 2 15:02:42 2011 New Revision: 220279 URL: http://svn.freebsd.org/changeset/base/220279 Log: Add accounting for RACCT_NPTS. Modified: head/sys/kern/tty_pts.c Modified: head/sys/kern/tty_pts.c ============================================================================== --- head/sys/kern/tty_pts.c Sat Apr 2 11:10:36 2011 (r220278) +++ head/sys/kern/tty_pts.c Sat Apr 2 15:02:42 2011 (r220279) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -682,6 +683,7 @@ ptsdrv_free(void *softc) free_unr(pts_pool, psc->pts_unit); chgptscnt(psc->pts_cred->cr_ruidinfo, -1, 0); + racct_sub_cred(psc->pts_cred, RACCT_NPTS, 1); crfree(psc->pts_cred); knlist_destroy(&psc->pts_inpoll.si_note); @@ -712,7 +714,7 @@ static int pts_alloc(int fflags, struct thread *td, struct file *fp) { - int unit, ok; + int unit, ok, error; struct tty *tp; struct pts_softc *psc; struct proc *p = td->td_proc; @@ -720,14 +722,23 @@ pts_alloc(int fflags, struct thread *td, /* Resource limiting. */ PROC_LOCK(p); + error = racct_add(p, RACCT_NPTS, 1); + if (error != 0) { + PROC_UNLOCK(p); + return (EAGAIN); + } ok = chgptscnt(cred->cr_ruidinfo, 1, lim_cur(p, RLIMIT_NPTS)); - PROC_UNLOCK(p); - if (!ok) + if (!ok) { + racct_sub(p, RACCT_NPTS, 1); + PROC_UNLOCK(p); return (EAGAIN); + } + PROC_UNLOCK(p); /* Try to allocate a new pts unit number. */ unit = alloc_unr(pts_pool); if (unit < 0) { + racct_sub(p, RACCT_NPTS, 1); chgptscnt(cred->cr_ruidinfo, -1, 0); return (EAGAIN); } @@ -757,7 +768,7 @@ int pts_alloc_external(int fflags, struct thread *td, struct file *fp, struct cdev *dev, const char *name) { - int ok; + int ok, error; struct tty *tp; struct pts_softc *psc; struct proc *p = td->td_proc; @@ -765,10 +776,18 @@ pts_alloc_external(int fflags, struct th /* Resource limiting. */ PROC_LOCK(p); + error = racct_add(p, RACCT_NPTS, 1); + if (error != 0) { + PROC_UNLOCK(p); + return (EAGAIN); + } ok = chgptscnt(cred->cr_ruidinfo, 1, lim_cur(p, RLIMIT_NPTS)); - PROC_UNLOCK(p); - if (!ok) + if (!ok) { + racct_sub(p, RACCT_NPTS, 1); + PROC_UNLOCK(p); return (EAGAIN); + } + PROC_UNLOCK(p); /* Allocate TTY and softc. */ psc = malloc(sizeof(struct pts_softc), M_PTS, M_WAITOK|M_ZERO); From owner-svn-src-head@FreeBSD.ORG Sat Apr 2 15:47: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 B430D1065673; Sat, 2 Apr 2011 15:47:23 +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 A47AF8FC13; Sat, 2 Apr 2011 15:47:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p32FlNdk086598; Sat, 2 Apr 2011 15:47:23 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p32FlNG1086595; Sat, 2 Apr 2011 15:47:23 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104021547.p32FlNG1086595@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 2 Apr 2011 15:47: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: r220280 - head/sys/compat/freebsd32 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, 02 Apr 2011 15:47:23 -0000 Author: kib Date: Sat Apr 2 15:47:23 2011 New Revision: 220280 URL: http://svn.freebsd.org/changeset/base/220280 Log: Provide the structures and ioctl number definition for handling PCIOCGETCONF compat32. Submitted by: John Wehle MFC after: 2 weeks Modified: head/sys/compat/freebsd32/freebsd32_ioctl.c head/sys/compat/freebsd32/freebsd32_ioctl.h Modified: head/sys/compat/freebsd32/freebsd32_ioctl.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_ioctl.c Sat Apr 2 15:02:42 2011 (r220279) +++ head/sys/compat/freebsd32/freebsd32_ioctl.c Sat Apr 2 15:47:23 2011 (r220280) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -58,6 +59,9 @@ CTASSERT((sizeof(struct md_ioctl32)+4) = CTASSERT(sizeof(struct ioc_read_toc_entry32) == 8); CTASSERT(sizeof(struct ioc_toc_header32) == 4); CTASSERT(sizeof(struct mem_range_op32) == 12); +CTASSERT(sizeof(struct pci_conf_io32) == 36); +CTASSERT(sizeof(struct pci_match_conf32) == 44); +CTASSERT(sizeof(struct pci_conf32) == 44); static int Modified: head/sys/compat/freebsd32/freebsd32_ioctl.h ============================================================================== --- head/sys/compat/freebsd32/freebsd32_ioctl.h Sat Apr 2 15:02:42 2011 (r220279) +++ head/sys/compat/freebsd32/freebsd32_ioctl.h Sat Apr 2 15:47:23 2011 (r220280) @@ -73,6 +73,45 @@ struct mem_range_op32 int mo_arg[2]; }; +struct pci_conf32 { + struct pcisel pc_sel; /* domain+bus+slot+function */ + u_int8_t pc_hdr; /* PCI header type */ + u_int16_t pc_subvendor; /* card vendor ID */ + u_int16_t pc_subdevice; /* card device ID, assigned by + card vendor */ + u_int16_t pc_vendor; /* chip vendor ID */ + u_int16_t pc_device; /* chip device ID, assigned by + chip vendor */ + u_int8_t pc_class; /* chip PCI class */ + u_int8_t pc_subclass; /* chip PCI subclass */ + u_int8_t pc_progif; /* chip PCI programming interface */ + u_int8_t pc_revid; /* chip revision ID */ + char pd_name[PCI_MAXNAMELEN + 1]; /* device name */ + u_int32_t pd_unit; /* device unit number */ +}; + +struct pci_match_conf32 { + struct pcisel pc_sel; /* domain+bus+slot+function */ + char pd_name[PCI_MAXNAMELEN + 1]; /* device name */ + u_int32_t pd_unit; /* Unit number */ + u_int16_t pc_vendor; /* PCI Vendor ID */ + u_int16_t pc_device; /* PCI Device ID */ + u_int8_t pc_class; /* PCI class */ + u_int32_t flags; /* Matching expression */ +}; + +struct pci_conf_io32 { + u_int32_t pat_buf_len; /* pattern buffer length */ + u_int32_t num_patterns; /* number of patterns */ + caddr_t32 patterns; /* struct pci_match_conf ptr */ + u_int32_t match_buf_len; /* match buffer length */ + u_int32_t num_matches; /* number of matches returned */ + caddr_t32 matches; /* struct pci_conf ptr */ + u_int32_t offset; /* offset into device list */ + u_int32_t generation; /* device list generation */ + u_int32_t status; /* request status */ +}; + #define CDIOREADTOCENTRYS_32 _IOWR('c', 5, struct ioc_read_toc_entry32) #define CDIOREADTOCHEADER_32 _IOR('c', 4, struct ioc_toc_header32) #define MDIOCATTACH_32 _IOC(IOC_INOUT, 'm', 0, sizeof(struct md_ioctl32) + 4) @@ -82,5 +121,6 @@ struct mem_range_op32 #define FIODGNAME_32 _IOW('f', 120, struct fiodgname_arg32) #define MEMRANGE_GET32 _IOWR('m', 50, struct mem_range_op32) #define MEMRANGE_SET32 _IOW('m', 51, struct mem_range_op32) +#define PCIOCGETCONF_32 _IOWR('p', 5, struct pci_conf_io32) #endif /* _COMPAT_FREEBSD32_IOCTL_H_ */ From owner-svn-src-head@FreeBSD.ORG Sat Apr 2 16:02: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 87BAE1065674; Sat, 2 Apr 2011 16:02:25 +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 778258FC15; Sat, 2 Apr 2011 16:02:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p32G2P6Z086946; Sat, 2 Apr 2011 16:02:25 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p32G2Pqc086944; Sat, 2 Apr 2011 16:02:25 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104021602.p32G2Pqc086944@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 2 Apr 2011 16:02: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: r220281 - head/sys/compat/freebsd32 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, 02 Apr 2011 16:02:25 -0000 Author: kib Date: Sat Apr 2 16:02:25 2011 New Revision: 220281 URL: http://svn.freebsd.org/changeset/base/220281 Log: Implement compat32 shims for PCIOCGETCONF. There is a generic problem with the shims for ioctls that receive pointers to the usermode data areas in the data argument. We either have to modify the handler to accept UIO_USERSPACE/UIO_SYSSPACE indicator, or allocate and fill a usermode memory for data buffer in the host format. The change goes the second route, in particular because we do not need to modify the handler. Submitted by: John Wehle MFC after: 2 weeks Modified: head/sys/compat/freebsd32/freebsd32_ioctl.c Modified: head/sys/compat/freebsd32/freebsd32_ioctl.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_ioctl.c Sat Apr 2 15:47:23 2011 (r220280) +++ head/sys/compat/freebsd32/freebsd32_ioctl.c Sat Apr 2 16:02:25 2011 (r220281) @@ -241,6 +241,108 @@ freebsd32_ioctl_memrange(struct thread * return (error); } +static int +freebsd32_ioctl_pciocgetconf(struct thread *td, + struct freebsd32_ioctl_args *uap, struct file *fp) +{ + struct pci_conf_io pci; + struct pci_conf_io32 pci32; + struct pci_match_conf32 pmc32; + struct pci_match_conf32 *pmc32p; + struct pci_match_conf pmc; + struct pci_match_conf *pmcp; + struct pci_conf32 pc32; + struct pci_conf32 *pc32p; + struct pci_conf pc; + struct pci_conf *pcp; + u_int32_t i; + u_int32_t npat_to_convert; + u_int32_t nmatch_to_convert; + vm_offset_t addr; + int error; + + if ((error = copyin(uap->data, &pci32, sizeof(pci32))) != 0) + return (error); + + CP(pci32, pci, num_patterns); + CP(pci32, pci, offset); + CP(pci32, pci, generation); + + npat_to_convert = pci32.pat_buf_len / sizeof(struct pci_match_conf32); + pci.pat_buf_len = npat_to_convert * sizeof(struct pci_match_conf); + pci.patterns = NULL; + nmatch_to_convert = pci32.match_buf_len / sizeof(struct pci_conf32); + pci.match_buf_len = nmatch_to_convert * sizeof(struct pci_conf); + pci.matches = NULL; + + if ((error = copyout_map(td, &addr, pci.pat_buf_len)) != 0) + goto cleanup; + pci.patterns = (struct pci_match_conf *)addr; + if ((error = copyout_map(td, &addr, pci.match_buf_len)) != 0) + goto cleanup; + pci.matches = (struct pci_conf *)addr; + + npat_to_convert = min(npat_to_convert, pci.num_patterns); + + for (i = 0, pmc32p = (struct pci_match_conf32 *)PTRIN(pci32.patterns), + pmcp = pci.patterns; + i < npat_to_convert; i++, pmc32p++, pmcp++) { + if ((error = copyin(pmc32p, &pmc32, sizeof(pmc32))) != 0) + goto cleanup; + CP(pmc32,pmc,pc_sel); + strlcpy(pmc.pd_name, pmc32.pd_name, sizeof(pmc.pd_name)); + CP(pmc32,pmc,pd_unit); + CP(pmc32,pmc,pc_vendor); + CP(pmc32,pmc,pc_device); + CP(pmc32,pmc,pc_class); + CP(pmc32,pmc,flags); + if ((error = copyout(&pmc, pmcp, sizeof(pmc))) != 0) + goto cleanup; + } + + if ((error = fo_ioctl(fp, PCIOCGETCONF, (caddr_t)&pci, + td->td_ucred, td)) != 0) + goto cleanup; + + nmatch_to_convert = min(nmatch_to_convert, pci.num_matches); + + for (i = 0, pcp = pci.matches, + pc32p = (struct pci_conf32 *)PTRIN(pci32.matches); + i < nmatch_to_convert; i++, pcp++, pc32p++) { + if ((error = copyin(pcp, &pc, sizeof(pc))) != 0) + goto cleanup; + CP(pc,pc32,pc_sel); + CP(pc,pc32,pc_hdr); + CP(pc,pc32,pc_subvendor); + CP(pc,pc32,pc_subdevice); + CP(pc,pc32,pc_vendor); + CP(pc,pc32,pc_device); + CP(pc,pc32,pc_class); + CP(pc,pc32,pc_subclass); + CP(pc,pc32,pc_progif); + CP(pc,pc32,pc_revid); + strlcpy(pc32.pd_name, pc.pd_name, sizeof(pc32.pd_name)); + CP(pc,pc32,pd_unit); + if ((error = copyout(&pc32, pc32p, sizeof(pc32))) != 0) + goto cleanup; + } + + CP(pci, pci32, num_matches); + CP(pci, pci32, offset); + CP(pci, pci32, generation); + CP(pci, pci32, status); + + error = copyout(&pci32, uap->data, sizeof(pci32)); + +cleanup: + if (pci.patterns) + copyout_unmap(td, (vm_offset_t)pci.patterns, pci.pat_buf_len); + if (pci.matches) + copyout_unmap(td, (vm_offset_t)pci.matches, pci.match_buf_len); + + return (error); +} + int freebsd32_ioctl(struct thread *td, struct freebsd32_ioctl_args *uap) { @@ -284,6 +386,10 @@ freebsd32_ioctl(struct thread *td, struc error = freebsd32_ioctl_memrange(td, uap, fp); break; + case PCIOCGETCONF_32: + error = freebsd32_ioctl_pciocgetconf(td, uap, fp); + break; + default: fdrop(fp, td); ap.fd = uap->fd; From owner-svn-src-head@FreeBSD.ORG Sat Apr 2 21:52: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 06700106564A; Sat, 2 Apr 2011 21:52:59 +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 E7A628FC0C; Sat, 2 Apr 2011 21:52:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p32Lqwn6094161; Sat, 2 Apr 2011 21:52:58 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p32Lqw9s094159; Sat, 2 Apr 2011 21:52:58 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201104022152.p32Lqw9s094159@svn.freebsd.org> From: Jeff Roberson Date: Sat, 2 Apr 2011 21:52: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: r220282 - 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, 02 Apr 2011 21:52:59 -0000 Author: jeff Date: Sat Apr 2 21:52:58 2011 New Revision: 220282 URL: http://svn.freebsd.org/changeset/base/220282 Log: Fix problems that manifested from filesystem full conditions: - In softdep_revert_mkdir() find the dotaddref before we attempt to cancel the jaddref so we can make assumptions about where the dotaddref is on the list. cancel_jaddref() does not always remove items from the list anymore. - Always set GOINGAWAY on an inode in softdep_freefile() if DEPCOMPLETE was never set. This ensures that dependencies will continue to be processed on the inowait/bufwait list and is more an artifact of the structure of the code than a pure ordering problem. - Always set DEPCOMPLETE on canceled jaddrefs so that they can be freed appropriately. This normally occurs when the refs are added to the journal but if they are canceled before this point the state would never be set and the dependency could never be freed. Reported by: pho Tested 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 Sat Apr 2 16:02:25 2011 (r220281) +++ head/sys/ufs/ffs/ffs_softdep.c Sat Apr 2 21:52:58 2011 (r220282) @@ -3501,10 +3501,14 @@ cancel_jaddref(jaddref, inodedep, wkhd) * us so that it is consistent with the in-memory reference. This * ensures that inode nlink rollbacks always have the correct link. */ - if (needsj == 0) + if (needsj == 0) { for (inoref = TAILQ_NEXT(&jaddref->ja_ref, if_deps); inoref; - inoref = TAILQ_NEXT(inoref, if_deps)) + inoref = TAILQ_NEXT(inoref, if_deps)) { + if (inoref->if_state & GOINGAWAY) + break; inoref->if_nlink--; + } + } jsegdep = inoref_jseg(&jaddref->ja_ref); if (jaddref->ja_state & NEWBLOCK) move_newblock_dep(jaddref, inodedep); @@ -3522,6 +3526,7 @@ cancel_jaddref(jaddref, inodedep, wkhd) if (jaddref->ja_state & DEPCOMPLETE) remove_from_journal(&jaddref->ja_list); } + jaddref->ja_state |= (GOINGAWAY | DEPCOMPLETE); /* * Leave NEWBLOCK jaddrefs on the inodedep so handle_workitem_remove * can arrange for them to be freed with the bitmap. Otherwise we @@ -3535,7 +3540,6 @@ cancel_jaddref(jaddref, inodedep, wkhd) free_jaddref(jaddref); return (needsj); } - jaddref->ja_state |= GOINGAWAY; /* * Leave the head of the list for jsegdeps for fast merging. */ @@ -4071,6 +4075,7 @@ softdep_revert_mkdir(dp, ip) { struct inodedep *inodedep; struct jaddref *jaddref; + struct jaddref *dotaddref; struct vnode *dvp; dvp = ITOV(dp); @@ -4090,12 +4095,12 @@ softdep_revert_mkdir(dp, ip) inoreflst); KASSERT(jaddref->ja_parent == dp->i_number, ("softdep_revert_mkdir: addref parent mismatch")); + dotaddref = (struct jaddref *)TAILQ_PREV(&jaddref->ja_ref, + inoreflst, if_deps); cancel_jaddref(jaddref, inodedep, &inodedep->id_inowait); - jaddref = (struct jaddref *)TAILQ_LAST(&inodedep->id_inoreflst, - inoreflst); - KASSERT(jaddref->ja_parent == ip->i_number, + KASSERT(dotaddref->ja_parent == ip->i_number, ("softdep_revert_mkdir: dot addref parent mismatch")); - cancel_jaddref(jaddref, inodedep, &inodedep->id_inowait); + cancel_jaddref(dotaddref, inodedep, &inodedep->id_inowait); } FREE_LOCK(&lk); } @@ -5734,14 +5739,14 @@ softdep_freefile(pvp, ino, mode) clear_unlinked_inodedep(inodedep); /* Re-acquire inodedep as we've dropped lk. */ inodedep_lookup(pvp->v_mount, ino, 0, &inodedep); - if (inodedep && (inodedep->id_state & DEPCOMPLETE) == 0) - inodedep->id_state |= GOINGAWAY; } if (inodedep == NULL || check_inode_unwritten(inodedep)) { FREE_LOCK(&lk); handle_workitem_freefile(freefile); return; } + if (inodedep && (inodedep->id_state & DEPCOMPLETE) == 0) + inodedep->id_state |= GOINGAWAY; WORKLIST_INSERT(&inodedep->id_inowait, &freefile->fx_list); FREE_LOCK(&lk); if (ip->i_number == ino)