From owner-svn-src-stable@FreeBSD.ORG Mon Jan 10 04:48:18 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 942811065673; Mon, 10 Jan 2011 04:48:18 +0000 (UTC) (envelope-from deischen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 67D0F8FC19; Mon, 10 Jan 2011 04:48: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 p0A4mIvC067533; Mon, 10 Jan 2011 04:48:18 GMT (envelope-from deischen@svn.freebsd.org) Received: (from deischen@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0A4mIHo067531; Mon, 10 Jan 2011 04:48:18 GMT (envelope-from deischen@svn.freebsd.org) Message-Id: <201101100448.p0A4mIHo067531@svn.freebsd.org> From: Daniel Eischen Date: Mon, 10 Jan 2011 04:48:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217219 - stable/8/sys/netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Jan 2011 04:48:18 -0000 Author: deischen Date: Mon Jan 10 04:48:18 2011 New Revision: 217219 URL: http://svn.freebsd.org/changeset/base/217219 Log: MFC: 217169 Make sure to always do source address selection on an unbound socket, regardless of any multicast options. If an address is specified via a multicast option, then let it override normal the source address selection. This fixes a bug where source address selection was not being performed when multicast options were present but without an interface being specified. Modified: stable/8/sys/netinet/in_pcb.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/netinet/in_pcb.c ============================================================================== --- stable/8/sys/netinet/in_pcb.c Mon Jan 10 03:59:04 2011 (r217218) +++ stable/8/sys/netinet/in_pcb.c Mon Jan 10 04:48:18 2011 (r217219) @@ -833,9 +833,10 @@ in_pcbconnect_setup(struct inpcb *inp, s } } if (laddr.s_addr == INADDR_ANY) { + error = in_pcbladdr(inp, &faddr, &laddr, cred); /* * If the destination address is multicast and an outgoing - * interface has been set as a multicast option, use the + * interface has been set as a multicast option, prefer the * address of that interface as our source address. */ if (IN_MULTICAST(ntohl(faddr.s_addr)) && @@ -852,16 +853,16 @@ in_pcbconnect_setup(struct inpcb *inp, s break; if (ia == NULL) { IN_IFADDR_RUNLOCK(); - return (EADDRNOTAVAIL); + error = EADDRNOTAVAIL; + } else { + laddr = ia->ia_addr.sin_addr; + IN_IFADDR_RUNLOCK(); + error = 0; } - laddr = ia->ia_addr.sin_addr; - IN_IFADDR_RUNLOCK(); } - } else { - error = in_pcbladdr(inp, &faddr, &laddr, cred); - if (error) - return (error); } + if (error) + return (error); } oinp = in_pcblookup_hash(inp->inp_pcbinfo, faddr, fport, laddr, lport, 0, NULL); From owner-svn-src-stable@FreeBSD.ORG Mon Jan 10 19:43:16 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B24CA106566C; Mon, 10 Jan 2011 19:43:16 +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 8600B8FC19; Mon, 10 Jan 2011 19:43:16 +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 p0AJhG5r091017; Mon, 10 Jan 2011 19:43:16 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0AJhGkW091015; Mon, 10 Jan 2011 19:43:16 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201101101943.p0AJhGkW091015@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 10 Jan 2011 19:43:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217230 - stable/8/sys/dev/bge X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Jan 2011 19:43:16 -0000 Author: yongari Date: Mon Jan 10 19:43:16 2011 New Revision: 217230 URL: http://svn.freebsd.org/changeset/base/217230 Log: MFC r217226: Apply DMA address space restriction to controllers that have 4GB DMA boundary bug and runs with PCI-X mode. watchdog timeout was observed on BCM5704 which lives behind certain PCI-X bridge(e.g. AMD 8131 PCI-X bridge). It's still not clear whether the root cause came from that PCI-X bridge or not. The watchdog timeout indicates the issue is in TX path. If the bridge reorders TX mailbox write accesses it would generate all kinds of problems but I'm not sure. This should be revisited. Early MFC requested by re@ for inclusion in 8.2-RC2/7.4-RC2. Tested by: Michael L. Squires (mikes <> siralan dot org) Modified: stable/8/sys/dev/bge/if_bge.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/bge/if_bge.c ============================================================================== --- stable/8/sys/dev/bge/if_bge.c Mon Jan 10 19:11:25 2011 (r217229) +++ stable/8/sys/dev/bge/if_bge.c Mon Jan 10 19:43:16 2011 (r217230) @@ -2473,8 +2473,18 @@ bge_dma_alloc(struct bge_softc *sc) /* Create parent tag for buffers. */ boundary = 0; - if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0) + if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0) { boundary = BGE_DMA_BNDRY; + /* + * XXX + * watchdog timeout issue was observed on BCM5704 which + * lives behind PCI-X bridge(e.g AMD 8131 PCI-X bridge). + * Limiting DMA address space to 32bits seems to address + * it. + */ + if (sc->bge_flags & BGE_FLAG_PCIX) + lowaddr = BUS_SPACE_MAXADDR_32BIT; + } error = bus_dma_tag_create(bus_get_dma_tag(sc->bge_dev), 1, boundary, lowaddr, BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, 0, BUS_SPACE_MAXSIZE_32BIT, From owner-svn-src-stable@FreeBSD.ORG Mon Jan 10 19:48:25 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5D7A81065672; Mon, 10 Jan 2011 19:48:25 +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 314D68FC23; Mon, 10 Jan 2011 19:48: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 p0AJmPpC091176; Mon, 10 Jan 2011 19:48:25 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0AJmP9e091174; Mon, 10 Jan 2011 19:48:25 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201101101948.p0AJmP9e091174@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 10 Jan 2011 19:48:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217231 - stable/7/sys/dev/bge X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Jan 2011 19:48:25 -0000 Author: yongari Date: Mon Jan 10 19:48:24 2011 New Revision: 217231 URL: http://svn.freebsd.org/changeset/base/217231 Log: MFC r217226: Apply DMA address space restriction to controllers that have 4GB DMA boundary bug and runs with PCI-X mode. watchdog timeout was observed on BCM5704 which lives behind certain PCI-X bridge(e.g. AMD 8131 PCI-X bridge). It's still not clear whether the root cause came from that PCI-X bridge or not. The watchdog timeout indicates the issue is in TX path. If the bridge reorders TX mailbox write accesses it would generate all kinds of problems but I'm not sure. This should be revisited. Early MFC requested by re@ for inclusion in 8.2-RC2/7.4-RC2. Tested by: Michael L. Squires (mikes <> siralan dot org) Modified: stable/7/sys/dev/bge/if_bge.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/bge/if_bge.c ============================================================================== --- stable/7/sys/dev/bge/if_bge.c Mon Jan 10 19:43:16 2011 (r217230) +++ stable/7/sys/dev/bge/if_bge.c Mon Jan 10 19:48:24 2011 (r217231) @@ -2473,8 +2473,18 @@ bge_dma_alloc(struct bge_softc *sc) /* Create parent tag for buffers. */ boundary = 0; - if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0) + if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0) { boundary = BGE_DMA_BNDRY; + /* + * XXX + * watchdog timeout issue was observed on BCM5704 which + * lives behind PCI-X bridge(e.g AMD 8131 PCI-X bridge). + * Limiting DMA address space to 32bits seems to address + * it. + */ + if (sc->bge_flags & BGE_FLAG_PCIX) + lowaddr = BUS_SPACE_MAXADDR_32BIT; + } error = bus_dma_tag_create(bus_get_dma_tag(sc->bge_dev), 1, boundary, lowaddr, BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, 0, BUS_SPACE_MAXSIZE_32BIT, From owner-svn-src-stable@FreeBSD.ORG Mon Jan 10 22:58:12 2011 Return-Path: Delivered-To: svn-src-stable@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 37A5A106566B; Mon, 10 Jan 2011 22:58:12 +0000 (UTC) (envelope-from lstewart@freebsd.org) Received: from lauren.room52.net (lauren.room52.net [210.50.193.198]) by mx1.freebsd.org (Postfix) with ESMTP id A6D218FC19; Mon, 10 Jan 2011 22:58:11 +0000 (UTC) Received: from lawrence1.loshell.room52.net (ppp59-167-184-191.static.internode.on.net [59.167.184.191]) by lauren.room52.net (Postfix) with ESMTPSA id 747017E8D6; Tue, 11 Jan 2011 09:58:09 +1100 (EST) Message-ID: <4D2B8EFD.5030500@freebsd.org> Date: Tue, 11 Jan 2011 09:58:05 +1100 From: Lawrence Stewart User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-AU; rv:1.9.2.13) Gecko/20101214 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: Lawrence Stewart References: <201101051852.p05IqUjK087769@svn.freebsd.org> <4D26A165.3070001@freebsd.org> <20110107091418.H14966@maildrop.int.zabbadoz.net> <4D27A605.6090002@freebsd.org> In-Reply-To: <4D27A605.6090002@freebsd.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on lauren.room52.net Cc: src-committers@FreeBSD.org, svn-src-stable@FreeBSD.org, svn-src-all@FreeBSD.org, "George V. Neville-Neil" , "Bjoern A. Zeeb" , svn-src-stable-8@FreeBSD.org, "Robert N. M. Watson" Subject: Re: svn commit: r217018 - stable/8/sys/netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Jan 2011 22:58:12 -0000 On 01/08/11 10:47, Lawrence Stewart wrote: > On 01/07/11 20:36, Bjoern A. Zeeb wrote: >> On Fri, 7 Jan 2011, Lawrence Stewart wrote: >> >>> Hi George, >>> >>> On 01/06/11 05:52, George V. Neville-Neil wrote: >>>> Author: gnn >>>> Date: Wed Jan 5 18:52:30 2011 >>>> New Revision: 217018 >>>> URL: http://svn.freebsd.org/changeset/base/217018 >>>> >>>> Log: >>>> Fix binary compatability for netstats across the -x/-T changes >>>> that have been previously MFC'd. >>>> >>>> Reviewed by: rwatson, bz >>>> >>>> Modified: >>>> stable/8/sys/netinet/tcp_var.h >>>> >> ... >>> >>> On my stable/8 machine after updating world but not kernel I see "struct >>> xtcpcb size mismatch" messages which indicates the ABI has been futzed >>> with. >> >> Be sure that it's not local changes. > > Definitely not the issue - this box runs stock stable/8 directly from > svn.freebsd.org without any local changes. > >>> Looking at the above diff I think this commit does indeed change the ABI >>> and therefore needs to be tweaked in order to maintain our current ABI >>> preservation policy for stable branches (unless I'm missing something?). >>> If the change to the ABI is intentional, a note in UPDATING would >>> probably be warranted. >> >> I think you are missing that that was the "repair" commit. Are you >> sure you didn't pickup the wrong versions? There was about a 1 day >> timeframe, where things were hosed but I believe George fixed them >> all. > > Looking at my kernel.old rev, I updated from stable/8 kernel/world @ > r216035 to stable/8 @ r217084. According to my commit mail log, George > made the initial change in r216968 and the repair commit was r217018, so > I don't think that I should have seen any issues if r217018 didn't mess > with the ABI as I hadn't updated in the cross over period. > >> Hmm looking at the diff committed more closely I see that the two >> uint64_t are not were they should be. Are you by any chance on i386 >> or another 32bit platform? > > No: > > lstewart@lstewart3:~> uname -a > > > FreeBSD lstewart3 8.2-PRERELEASE FreeBSD 8.2-PRERELEASE #16 r217084: Fri > Jan 7 16:17:03 EST 2011 root@lstewart3:/usr/obj/usr/src/sys/GENERIC > amd64 For the record, the fact I was seeing issues on amd64 was a bit of a red herring, even though the ABI issues were real and are now fixed thanks to Bjoern. I can't reproduce the error I saw with the revisions noted above, and did some digging to figure out why. I was still running the old r216035 kernel but had updated my src tree a couple of times in between and I think I built and installed world in the window between George's commits. I then rebuilt world at r217084 post George's r217018 with a "-DNO_CLEAN" and I suspect somehow it left me with a sockstat built against the ABI compromised struct tcpcb. Not quite sure how that happened but it's my best guess. Cheers, Lawrence From owner-svn-src-stable@FreeBSD.ORG Tue Jan 11 00:58:49 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5769B1065697; Tue, 11 Jan 2011 00:58:49 +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 465908FC24; Tue, 11 Jan 2011 00:58: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 p0B0wnvt001158; Tue, 11 Jan 2011 00:58:49 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0B0wn9l001156; Tue, 11 Jan 2011 00:58:49 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201101110058.p0B0wn9l001156@svn.freebsd.org> From: Ed Maste Date: Tue, 11 Jan 2011 00:58:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217249 - stable/8/libexec/ftpd X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jan 2011 00:58:49 -0000 Author: emaste Date: Tue Jan 11 00:58:49 2011 New Revision: 217249 URL: http://svn.freebsd.org/changeset/base/217249 Log: MFC 216943, 216945: Handle failure from ftpd_popen in statfilecmd(). Make format string a string literal. (Discovered by clang.) Modified: stable/8/libexec/ftpd/ftpd.c Directory Properties: stable/8/libexec/ftpd/ (props changed) Modified: stable/8/libexec/ftpd/ftpd.c ============================================================================== --- stable/8/libexec/ftpd/ftpd.c Tue Jan 11 00:29:17 2011 (r217248) +++ stable/8/libexec/ftpd/ftpd.c Tue Jan 11 00:58:49 2011 (r217249) @@ -2133,7 +2133,7 @@ send_data(FILE *instr, FILE *outstr, siz } } ENDXFER; - reply(226, msg); + reply(226, "%s", msg); return (0); } @@ -2330,6 +2330,10 @@ statfilecmd(char *filename) code = lstat(filename, &st) == 0 && S_ISDIR(st.st_mode) ? 212 : 213; (void)snprintf(line, sizeof(line), _PATH_LS " -lgA %s", filename); fin = ftpd_popen(line, "r"); + if (fin == NULL) { + perror_reply(551, filename); + return; + } lreply(code, "Status of %s:", filename); atstart = 1; while ((c = getc(fin)) != EOF) { From owner-svn-src-stable@FreeBSD.ORG Tue Jan 11 01:12:51 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1DA78106566C; Tue, 11 Jan 2011 01:12:51 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0BFB88FC12; Tue, 11 Jan 2011 01:12: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 p0B1CoPi001569; Tue, 11 Jan 2011 01:12:50 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0B1Cop7001566; Tue, 11 Jan 2011 01:12:50 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201101110112.p0B1Cop7001566@svn.freebsd.org> From: Rick Macklem Date: Tue, 11 Jan 2011 01:12:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217251 - in stable/8/sys/fs: nfs nfsserver X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jan 2011 01:12:51 -0000 Author: rmacklem Date: Tue Jan 11 01:12:50 2011 New Revision: 217251 URL: http://svn.freebsd.org/changeset/base/217251 Log: MFC: r216784 Delete the nfsvno_localconflict() function in the experimental NFS server since it is no longer used and is broken. Modified: stable/8/sys/fs/nfs/nfs_var.h stable/8/sys/fs/nfsserver/nfs_nfsdport.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/fs/nfs/nfs_var.h ============================================================================== --- stable/8/sys/fs/nfs/nfs_var.h Tue Jan 11 01:11:07 2011 (r217250) +++ stable/8/sys/fs/nfs/nfs_var.h Tue Jan 11 01:12:50 2011 (r217251) @@ -571,8 +571,6 @@ int nfsvno_fhtovp(mount_t, fhandle_t *, int nfsvno_pathconf(vnode_t, int, register_t *, struct ucred *, NFSPROC_T *); vnode_t nfsvno_getvp(fhandle_t *); -int nfsvno_localconflict(vnode_t, int, u_int64_t, u_int64_t, - struct nfslockconflict *, NFSPROC_T *); int nfsvno_advlock(vnode_t, int, u_int64_t, u_int64_t, NFSPROC_T *); void nfsvno_unlockvfs(mount_t); int nfsvno_lockvfs(mount_t); Modified: stable/8/sys/fs/nfsserver/nfs_nfsdport.c ============================================================================== --- stable/8/sys/fs/nfsserver/nfs_nfsdport.c Tue Jan 11 01:11:07 2011 (r217250) +++ stable/8/sys/fs/nfsserver/nfs_nfsdport.c Tue Jan 11 01:12:50 2011 (r217251) @@ -2781,66 +2781,6 @@ nfsvno_getvp(fhandle_t *fhp) } /* - * Check to see it a byte range lock held by a process running - * locally on the server conflicts with the new lock. - */ -int -nfsvno_localconflict(struct vnode *vp, int ftype, u_int64_t first, - u_int64_t end, struct nfslockconflict *cfp, struct thread *td) -{ - int error; - struct flock fl; - - if (!nfsrv_dolocallocks) - return (0); - fl.l_whence = SEEK_SET; - fl.l_type = ftype; - fl.l_start = (off_t)first; - if (end == NFS64BITSSET) - fl.l_len = 0; - else - fl.l_len = (off_t)(end - first); - /* - * For FreeBSD8, the l_pid and l_sysid must be set to the same - * values for all calls, so that all locks will be held by the - * nfsd server. (The nfsd server handles conflicts between the - * various clients.) - * Since an NFSv4 lockowner is a ClientID plus an array of up to 1024 - * bytes, so it can't be put in l_sysid. - */ - if (nfsv4_sysid == 0) - nfsv4_sysid = nlm_acquire_next_sysid(); - fl.l_pid = (pid_t)0; - fl.l_sysid = (int)nfsv4_sysid; - - NFSVOPUNLOCK(vp, 0, td); - error = VOP_ADVLOCK(vp, (caddr_t)td->td_proc, F_GETLK, &fl, - (F_POSIX | F_REMOTE)); - NFSVOPLOCK(vp, LK_EXCLUSIVE | LK_RETRY, td); - if (error) - return (error); - if (fl.l_type == F_UNLCK) - return (0); - if (cfp != NULL) { - cfp->cl_clientid.lval[0] = cfp->cl_clientid.lval[1] = 0; - cfp->cl_first = (u_int64_t)fl.l_start; - if (fl.l_len == 0) - cfp->cl_end = NFS64BITSSET; - else - cfp->cl_end = (u_int64_t) - (fl.l_start + fl.l_len); - if (fl.l_type == F_WRLCK) - cfp->cl_flags = NFSLCK_WRITE; - else - cfp->cl_flags = NFSLCK_READ; - sprintf(cfp->cl_owner, "LOCALID%d", fl.l_pid); - cfp->cl_ownerlen = strlen(cfp->cl_owner); - return (NFSERR_DENIED); - } - return (NFSERR_INVAL); -} - -/* * Do a local VOP_ADVLOCK(). */ int From owner-svn-src-stable@FreeBSD.ORG Tue Jan 11 17:16:50 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6878E106564A; Tue, 11 Jan 2011 17:16:50 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5763C8FC08; Tue, 11 Jan 2011 17:16: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 p0BHGoRc027266; Tue, 11 Jan 2011 17:16:50 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0BHGoZ5027264; Tue, 11 Jan 2011 17:16:50 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201101111716.p0BHGoZ5027264@svn.freebsd.org> From: Matthew D Fleming Date: Tue, 11 Jan 2011 17:16:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217268 - stable/8/sys/geom/part X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jan 2011 17:16:50 -0000 Author: mdf Date: Tue Jan 11 17:16:50 2011 New Revision: 217268 URL: http://svn.freebsd.org/changeset/base/217268 Log: MFC r217109: Fix a memory overflow where the input length to g_gpt_utf8_to_utf16() was specified incorrectly, causing the bzero to run past the end of a malloc(9)'d object. Submitted by: Eric Youngblut < eyoungblut AT isilon DOT com > Modified: stable/8/sys/geom/part/g_part_gpt.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/geom/part/g_part_gpt.c ============================================================================== --- stable/8/sys/geom/part/g_part_gpt.c Tue Jan 11 17:02:24 2011 (r217267) +++ stable/8/sys/geom/part/g_part_gpt.c Tue Jan 11 17:16:50 2011 (r217268) @@ -425,7 +425,8 @@ g_part_gpt_add(struct g_part_table *base } if (gpp->gpp_parms & G_PART_PARM_LABEL) g_gpt_utf8_to_utf16(gpp->gpp_label, entry->ent.ent_name, - sizeof(entry->ent.ent_name)); + sizeof(entry->ent.ent_name) / + sizeof(entry->ent.ent_name[0])); return (0); } @@ -588,7 +589,8 @@ g_part_gpt_modify(struct g_part_table *b } if (gpp->gpp_parms & G_PART_PARM_LABEL) g_gpt_utf8_to_utf16(gpp->gpp_label, entry->ent.ent_name, - sizeof(entry->ent.ent_name)); + sizeof(entry->ent.ent_name) / + sizeof(entry->ent.ent_name[0])); return (0); } From owner-svn-src-stable@FreeBSD.ORG Tue Jan 11 17:26:37 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4F2281065672; Tue, 11 Jan 2011 17:26:37 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3D8368FC0C; Tue, 11 Jan 2011 17:26:37 +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 p0BHQbCB027535; Tue, 11 Jan 2011 17:26:37 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0BHQbwq027532; Tue, 11 Jan 2011 17:26:37 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201101111726.p0BHQbwq027532@svn.freebsd.org> From: Matthew D Fleming Date: Tue, 11 Jan 2011 17:26:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217269 - in stable/8/sys: kern sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jan 2011 17:26:37 -0000 Author: mdf Date: Tue Jan 11 17:26:36 2011 New Revision: 217269 URL: http://svn.freebsd.org/changeset/base/217269 Log: Move the fail_point_entry definition from fail.h to kern_fail.c, which allows putting the enumeration constants of fail point types with the text string that matches them. Modified: stable/8/sys/kern/kern_fail.c stable/8/sys/sys/fail.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/kern/kern_fail.c ============================================================================== --- stable/8/sys/kern/kern_fail.c Tue Jan 11 17:16:50 2011 (r217268) +++ stable/8/sys/kern/kern_fail.c Tue Jan 11 17:26:36 2011 (r217269) @@ -76,6 +76,43 @@ MTX_SYSINIT(g_fp_mtx, &g_fp_mtx, "fail p #define FP_LOCK() mtx_lock(&g_fp_mtx) #define FP_UNLOCK() mtx_unlock(&g_fp_mtx) +/** + * Failpoint types. + * Don't change these without changing fail_type_strings in fail.c. + * @ingroup failpoint_private + */ +enum fail_point_t { + FAIL_POINT_OFF, /**< don't fail */ + FAIL_POINT_PANIC, /**< panic */ + FAIL_POINT_RETURN, /**< return an errorcode */ + FAIL_POINT_BREAK, /**< break into the debugger */ + FAIL_POINT_PRINT, /**< print a message */ + FAIL_POINT_SLEEP, /**< sleep for some msecs */ + FAIL_POINT_INVALID, /**< placeholder */ +}; + +static const char *fail_type_strings[] = { + "off", + "panic", + "return", + "break", + "print", + "sleep", +}; + +/** + * Internal structure tracking a single term of a complete failpoint. + * @ingroup failpoint_private + */ +struct fail_point_entry { + enum fail_point_t fe_type; /**< type of entry */ + int fe_arg; /**< argument to type (e.g. return value) */ + int fe_prob; /**< likelihood of firing in millionths */ + int fe_count; /**< number of times to fire, 0 means always */ + + TAILQ_ENTRY(fail_point_entry) fe_entries; /**< next entry in fail point */ +}; + static inline void fail_point_sleep(struct fail_point *fp, struct fail_point_entry *ent, int msecs, enum fail_point_return_code *pret) @@ -102,15 +139,6 @@ enum { PROB_DIGITS = 6, /* number of zero's in above number */ }; -static const char *fail_type_strings[] = { - "off", - "panic", - "return", - "break", - "print", - "sleep", -}; - static char *parse_fail_point(struct fail_point_entries *, char *); static char *parse_term(struct fail_point_entries *, char *); static char *parse_number(int *out_units, int *out_decimal, char *); Modified: stable/8/sys/sys/fail.h ============================================================================== --- stable/8/sys/sys/fail.h Tue Jan 11 17:16:50 2011 (r217268) +++ stable/8/sys/sys/fail.h Tue Jan 11 17:26:36 2011 (r217269) @@ -39,22 +39,6 @@ #include #include - -/** - * Failpoint types. - * Don't change these without changing fail_type_strings in fail.c. - * @ingroup failpoint_private - */ -enum fail_point_t { - FAIL_POINT_OFF, /**< don't fail */ - FAIL_POINT_PANIC, /**< panic */ - FAIL_POINT_RETURN, /**< return an errorcode */ - FAIL_POINT_BREAK, /**< break into the debugger */ - FAIL_POINT_PRINT, /**< print a message */ - FAIL_POINT_SLEEP, /**< sleep for some msecs */ - FAIL_POINT_INVALID, /**< placeholder */ -}; - /** * Failpoint return codes, used internally. * @ingroup failpoint_private @@ -65,6 +49,7 @@ enum fail_point_return_code { FAIL_POINT_RC_QUEUED, /**< sleep_fn will be called */ }; +struct fail_point_entry; TAILQ_HEAD(fail_point_entries, fail_point_entry); /** * Internal failpoint structure, tracking all the current details of the @@ -84,18 +69,7 @@ struct fail_point { #define FAIL_POINT_DYNAMIC_NAME 0x01 /**< Must free name on destroy */ -/** - * Internal structure tracking a single term of a complete failpoint. - * @ingroup failpoint_private - */ -struct fail_point_entry { - enum fail_point_t fe_type; /**< type of entry */ - int fe_arg; /**< argument to type (e.g. return value) */ - int fe_prob; /**< likelihood of firing in millionths */ - int fe_count; /**< number of times to fire, 0 means always */ - - TAILQ_ENTRY(fail_point_entry) fe_entries; /**< next entry in fail point */ -}; +__BEGIN_DECLS /* Private failpoint eval function -- use fail_point_eval() instead. */ enum fail_point_return_code fail_point_eval_nontrivial(struct fail_point *, @@ -152,6 +126,8 @@ fail_point_eval(struct fail_point *fp, i return (fail_point_eval_nontrivial(fp, ret)); } +__END_DECLS + /* Declare a fail_point and its sysctl in a function. */ #define _FAIL_POINT_NAME(name) _fail_point_##name #define _STRINGIFY_HELPER(x) #x @@ -233,7 +209,7 @@ fail_point_eval(struct fail_point *fp, i NULL, NULL, \ }; \ SYSCTL_OID(parent, OID_AUTO, name, \ - CTLTYPE_STRING | CTLFLAG_RW, \ + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, \ &_FAIL_POINT_NAME(name), 0, fail_point_sysctl, \ "A", ""); \ \ @@ -254,7 +230,7 @@ int fail_point_sysctl(SYSCTL_HANDLER_ARG /* The fail point sysctl tree. */ SYSCTL_DECL(_debug_fail_point); +#define DEBUG_FP _debug_fail_point #endif -#define DEBUG_FP _debug_fail_point #endif /* _SYS_FAIL_H_ */ From owner-svn-src-stable@FreeBSD.ORG Tue Jan 11 17:29:34 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B09FB106564A; Tue, 11 Jan 2011 17:29:34 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9EFD68FC14; Tue, 11 Jan 2011 17:29:34 +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 p0BHTY7q027646; Tue, 11 Jan 2011 17:29:34 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0BHTYmH027643; Tue, 11 Jan 2011 17:29:34 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201101111729.p0BHTYmH027643@svn.freebsd.org> From: Matthew D Fleming Date: Tue, 11 Jan 2011 17:29:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217270 - in stable/8/sys: kern sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jan 2011 17:29:34 -0000 Author: mdf Date: Tue Jan 11 17:29:34 2011 New Revision: 217270 URL: http://svn.freebsd.org/changeset/base/217270 Log: (Note the previous commit was a MFC of r216616). MFC r216620: Initialize fp_location for explicitly managed fail points, and push the parentheses around the location for simple fail points into the location string. This makes the print on fail point set more consistent between the two versions. Also fix up fail.h a little for style(9): only use one of sys/param.h and sys/types.h, and use the existing __XSTRING() macro instead of rolling our own. Also fix up a few tabs on changed and nearby lines. Lastly, since KFAIL_POINT_{BEGIN,END} are not meant for use outside this file, just eliminate the macros entirely. Modified: stable/8/sys/kern/kern_fail.c stable/8/sys/sys/fail.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/kern/kern_fail.c ============================================================================== --- stable/8/sys/kern/kern_fail.c Tue Jan 11 17:26:36 2011 (r217269) +++ stable/8/sys/kern/kern_fail.c Tue Jan 11 17:29:34 2011 (r217270) @@ -177,6 +177,7 @@ fail_point_init(struct fail_point *fp, c va_end(ap); } fp->fp_name = name; + fp->fp_location = ""; fp->fp_flags |= FAIL_POINT_DYNAMIC_NAME; fp->fp_sleep_fn = NULL; fp->fp_sleep_arg = NULL; @@ -372,10 +373,10 @@ fail_point_set(struct fail_point *fp, ch end: #ifdef IWARNING if (error) - IWARNING("Failed to set %s (%s) to %s", + IWARNING("Failed to set %s %s to %s", fp->fp_name, fp->fp_location, buf); else - INOTICE("Set %s (%s) to %s", + INOTICE("Set %s %s to %s", fp->fp_name, fp->fp_location, buf); #endif /* IWARNING */ Modified: stable/8/sys/sys/fail.h ============================================================================== --- stable/8/sys/sys/fail.h Tue Jan 11 17:26:36 2011 (r217269) +++ stable/8/sys/sys/fail.h Tue Jan 11 17:29:34 2011 (r217270) @@ -32,10 +32,9 @@ #ifndef _SYS_FAIL_H_ #define _SYS_FAIL_H_ -#include - -#include #include +#include +#include #include #include @@ -129,10 +128,8 @@ fail_point_eval(struct fail_point *fp, i __END_DECLS /* Declare a fail_point and its sysctl in a function. */ -#define _FAIL_POINT_NAME(name) _fail_point_##name -#define _STRINGIFY_HELPER(x) #x -#define _STRINGIFY(x) _STRINGIFY_HELPER(x) -#define _FAIL_POINT_LOCATION() __FILE__ ":" _STRINGIFY(__LINE__) +#define _FAIL_POINT_NAME(name) _fail_point_##name +#define _FAIL_POINT_LOCATION() "(" __FILE__ ":" __XSTRING(__LINE__) ")" /** * Instantiate a failpoint which returns "value" from the function when triggered. @@ -178,53 +175,43 @@ __END_DECLS /** * Instantiate a failpoint which runs arbitrary code when triggered. * @param parent The parent sysctl under which to locate the sysctl - * @param name The name of the failpoint in the sysctl tree (and printouts) + * @param name The name of the failpoint in the sysctl tree + * (and printouts) * @param code The arbitrary code to run when triggered. Can reference - * "RETURN_VALUE" if desired to extract the specified user - * return-value when triggered + * "RETURN_VALUE" if desired to extract the specified + * user return-value when triggered. Note that this is + * implemented with a do-while loop so be careful of + * break and continue statements. */ #define KFAIL_POINT_CODE(parent, name, code) \ - KFAIL_POINT_START(parent, name) { \ +do { \ + int RETURN_VALUE; \ + static struct fail_point _FAIL_POINT_NAME(name) = { \ + #name, \ + _FAIL_POINT_LOCATION(), \ + TAILQ_HEAD_INITIALIZER(_FAIL_POINT_NAME(name).fp_entries), \ + 0, \ + NULL, NULL, \ + }; \ + SYSCTL_OID(parent, OID_AUTO, name, \ + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, \ + &_FAIL_POINT_NAME(name), 0, fail_point_sysctl, \ + "A", ""); \ + \ + if (__predict_false( \ + fail_point_eval(&_FAIL_POINT_NAME(name), &RETURN_VALUE))) { \ + \ code; \ - } FAIL_POINT_END + \ + } \ +} while (0) + /** * @} * (end group failpoint) */ -/** - * Internal macro to implement above #defines -- should not be used directly. - * @ingroup failpoint_private - */ -#define KFAIL_POINT_START(parent, name) \ - do { \ - int RETURN_VALUE; \ - static struct fail_point _FAIL_POINT_NAME(name) = { \ - #name, \ - _FAIL_POINT_LOCATION(), \ - TAILQ_HEAD_INITIALIZER( \ - _FAIL_POINT_NAME(name).fp_entries), \ - 0, \ - NULL, NULL, \ - }; \ - SYSCTL_OID(parent, OID_AUTO, name, \ - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, \ - &_FAIL_POINT_NAME(name), 0, fail_point_sysctl, \ - "A", ""); \ - \ - if (__predict_false( \ - fail_point_eval(&_FAIL_POINT_NAME(name), \ - &RETURN_VALUE))) { - -/** - * Internal macro to implement above #defines -- should not be used directly. - * @ingroup failpoint_private - */ -#define FAIL_POINT_END \ - } \ - } while (0) - #ifdef _KERNEL int fail_point_sysctl(SYSCTL_HANDLER_ARGS); From owner-svn-src-stable@FreeBSD.ORG Tue Jan 11 17:31:59 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6D5D0106564A; Tue, 11 Jan 2011 17:31:59 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5C7668FC12; Tue, 11 Jan 2011 17:31:59 +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 p0BHVxJl027763; Tue, 11 Jan 2011 17:31:59 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0BHVxBL027761; Tue, 11 Jan 2011 17:31:59 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201101111731.p0BHVxBL027761@svn.freebsd.org> From: Matthew D Fleming Date: Tue, 11 Jan 2011 17:31:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217271 - stable/8/sys/kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jan 2011 17:31:59 -0000 Author: mdf Date: Tue Jan 11 17:31:59 2011 New Revision: 217271 URL: http://svn.freebsd.org/changeset/base/217271 Log: MFC r216058 and r216059: r216058: Use the SYSCTL_CHILDREN macro in kern_sysctl.c to help de-obfuscate the code. r216059: Slightly modify the logic in sysctl_find_oid to reduce the indentation. There should be no functional change. Modified: stable/8/sys/kern/kern_sysctl.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/kern/kern_sysctl.c ============================================================================== --- stable/8/sys/kern/kern_sysctl.c Tue Jan 11 17:29:34 2011 (r217270) +++ stable/8/sys/kern/kern_sysctl.c Tue Jan 11 17:31:59 2011 (r217271) @@ -675,7 +675,7 @@ sysctl_sysctl_name(SYSCTL_HANDLER_ARGS) if (oid->oid_handler) break; - lsp2 = (struct sysctl_oid_list *)oid->oid_arg1; + lsp2 = SYSCTL_CHILDREN(oid); break; } lsp = lsp2; @@ -706,7 +706,7 @@ sysctl_sysctl_next_ls(struct sysctl_oid_ if (oidp->oid_handler) /* We really should call the handler here...*/ return (0); - lsp = (struct sysctl_oid_list *)oidp->oid_arg1; + lsp = SYSCTL_CHILDREN(oidp); if (!sysctl_sysctl_next_ls(lsp, 0, 0, next+1, len, level+1, oidpp)) return (0); @@ -721,7 +721,7 @@ sysctl_sysctl_next_ls(struct sysctl_oid_ return (0); if (oidp->oid_handler) return (0); - lsp = (struct sysctl_oid_list *)oidp->oid_arg1; + lsp = SYSCTL_CHILDREN(oidp); if (!sysctl_sysctl_next_ls(lsp, name+1, namelen-1, next+1, len, level+1, oidpp)) return (0); @@ -733,7 +733,7 @@ sysctl_sysctl_next_ls(struct sysctl_oid_ if (oidp->oid_handler) continue; - lsp = (struct sysctl_oid_list *)oidp->oid_arg1; + lsp = SYSCTL_CHILDREN(oidp); if (!sysctl_sysctl_next_ls(lsp, name+1, namelen-1, next+1, len, level+1, oidpp)) return (0); @@ -811,7 +811,7 @@ name2oid(char *name, int *oid, int *len, if (oidp->oid_handler) break; - lsp = (struct sysctl_oid_list *)oidp->oid_arg1; + lsp = SYSCTL_CHILDREN(oidp); oidp = SLIST_FIRST(lsp); name = p+1; for (p = name; *p && *p != '.'; p++) @@ -1302,37 +1302,39 @@ int sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid, int *nindx, struct sysctl_req *req) { + struct sysctl_oid_list *lsp; struct sysctl_oid *oid; int indx; SYSCTL_ASSERT_LOCKED(); - oid = SLIST_FIRST(&sysctl__children); + lsp = &sysctl__children; indx = 0; - while (oid && indx < CTL_MAXNAME) { - if (oid->oid_number == name[indx]) { - indx++; - if (oid->oid_kind & CTLFLAG_NOLOCK) - req->lock = REQ_UNLOCKED; - if ((oid->oid_kind & CTLTYPE) == CTLTYPE_NODE) { - if (oid->oid_handler != NULL || - indx == namelen) { - *noid = oid; - if (nindx != NULL) - *nindx = indx; - return (0); - } - oid = SLIST_FIRST( - (struct sysctl_oid_list *)oid->oid_arg1); - } else if (indx == namelen) { + while (indx < CTL_MAXNAME) { + SLIST_FOREACH(oid, lsp, oid_link) { + if (oid->oid_number == name[indx]) + break; + } + if (oid == NULL) + return (ENOENT); + + indx++; + if (oid->oid_kind & CTLFLAG_NOLOCK) + req->lock = REQ_UNLOCKED; + if ((oid->oid_kind & CTLTYPE) == CTLTYPE_NODE) { + if (oid->oid_handler != NULL || indx == namelen) { *noid = oid; if (nindx != NULL) *nindx = indx; return (0); - } else { - return (ENOTDIR); } + lsp = SYSCTL_CHILDREN(oid); + } else if (indx == namelen) { + *noid = oid; + if (nindx != NULL) + *nindx = indx; + return (0); } else { - oid = SLIST_NEXT(oid, oid_link); + return (ENOTDIR); } } return (ENOENT); From owner-svn-src-stable@FreeBSD.ORG Tue Jan 11 17:33:30 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 33E1E106564A; Tue, 11 Jan 2011 17:33:30 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 232718FC0C; Tue, 11 Jan 2011 17:33: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 p0BHXU49027859; Tue, 11 Jan 2011 17:33:30 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0BHXUc5027857; Tue, 11 Jan 2011 17:33:30 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201101111733.p0BHXUc5027857@svn.freebsd.org> From: Matthew D Fleming Date: Tue, 11 Jan 2011 17:33:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217272 - stable/8/sys/kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jan 2011 17:33:30 -0000 Author: mdf Date: Tue Jan 11 17:33:29 2011 New Revision: 217272 URL: http://svn.freebsd.org/changeset/base/217272 Log: MFC r216463: One of the compat32 functions was copying in a raw timespec, instead of a 32-bit one. This can cause weird timeout issues, as the copying reads garbage from the user. Modified: stable/8/sys/kern/kern_umtx.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/kern/kern_umtx.c ============================================================================== --- stable/8/sys/kern/kern_umtx.c Tue Jan 11 17:31:59 2011 (r217271) +++ stable/8/sys/kern/kern_umtx.c Tue Jan 11 17:33:29 2011 (r217272) @@ -3230,8 +3230,7 @@ __umtx_op_rw_rdlock_compat32(struct thre if (uap->uaddr2 == NULL) { error = do_rw_rdlock(td, uap->obj, uap->val, 0); } else { - error = copyin(uap->uaddr2, &timeout, - sizeof(timeout)); + error = copyin_timeout32(uap->uaddr2, &timeout); if (error != 0) return (error); if (timeout.tv_nsec >= 1000000000 || From owner-svn-src-stable@FreeBSD.ORG Tue Jan 11 18:01:55 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7DD261065672; Tue, 11 Jan 2011 18:01:55 +0000 (UTC) (envelope-from mdf356@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 348D28FC19; Tue, 11 Jan 2011 18:01:54 +0000 (UTC) Received: by iyb26 with SMTP id 26so19760404iyb.13 for ; Tue, 11 Jan 2011 10:01:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:content-type:content-transfer-encoding; bh=3UiSuzecPfwLpj2LGWB2MbL/DyspOx4K51+9wIVb8mI=; b=piuKhXA7QGn4+s5/pW0nGZuwxErKo/7lChBDjKdQPv0W9KFMgubLUBGjNHwgpVBH3A rY7zlDpG3xv/v14QIY02QPa8XT8baKciQWei+bQynRZ0DmBP101o8rdpWpuB8Iljdw/4 jlZ4vjOThWmXHhO+IWxC3dvR7YZi6hiR5JfkU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=Rj627ctAG2HYauP2OXQLL7M6KVAa56HEwaiZ94g7u9qTfZlyYJma7sGgPd5EynAVDD Qqbx/T2dCvoBu4Lc6PCi2hBLcvr8XUdpPnfeGsn+w9+bITpeFXUIRzmRUgEp6vX9lgp7 wrAEugitzQ9jngAyudSZFWCnkmaXIoqtIh+ms= MIME-Version: 1.0 Received: by 10.231.161.15 with SMTP id p15mr30641506ibx.104.1294766866084; Tue, 11 Jan 2011 09:27:46 -0800 (PST) Sender: mdf356@gmail.com Received: by 10.231.160.147 with HTTP; Tue, 11 Jan 2011 09:27:45 -0800 (PST) In-Reply-To: <201101111726.p0BHQbwq027532@svn.freebsd.org> References: <201101111726.p0BHQbwq027532@svn.freebsd.org> Date: Tue, 11 Jan 2011 09:27:45 -0800 X-Google-Sender-Auth: 9SF-3ogzFZAtlkH_3WxMhZLz7HE Message-ID: From: mdf@FreeBSD.org To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Subject: Re: svn commit: r217269 - in stable/8/sys: kern sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jan 2011 18:01:55 -0000 Gah! Forgot to mention this is a MFC of r216616. On Tue, Jan 11, 2011 at 9:26 AM, Matthew D Fleming wrote: > Author: mdf > Date: Tue Jan 11 17:26:36 2011 > New Revision: 217269 > URL: http://svn.freebsd.org/changeset/base/217269 > > Log: > =A0Move the fail_point_entry definition from fail.h to kern_fail.c, which > =A0allows putting the enumeration constants of fail point types with the > =A0text string that matches them. > > Modified: > =A0stable/8/sys/kern/kern_fail.c > =A0stable/8/sys/sys/fail.h > Directory Properties: > =A0stable/8/sys/ =A0 (props changed) > =A0stable/8/sys/amd64/include/xen/ =A0 (props changed) > =A0stable/8/sys/cddl/contrib/opensolaris/ =A0 (props changed) > =A0stable/8/sys/contrib/dev/acpica/ =A0 (props changed) > =A0stable/8/sys/contrib/pf/ =A0 (props changed) > > Modified: stable/8/sys/kern/kern_fail.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 > --- stable/8/sys/kern/kern_fail.c =A0 =A0 =A0 Tue Jan 11 17:16:50 2011 = =A0 =A0 =A0 =A0(r217268) > +++ stable/8/sys/kern/kern_fail.c =A0 =A0 =A0 Tue Jan 11 17:26:36 2011 = =A0 =A0 =A0 =A0(r217269) > @@ -76,6 +76,43 @@ MTX_SYSINIT(g_fp_mtx, &g_fp_mtx, "fail p > =A0#define FP_LOCK() =A0 =A0 =A0mtx_lock(&g_fp_mtx) > =A0#define FP_UNLOCK() =A0 =A0mtx_unlock(&g_fp_mtx) > > +/** > + * Failpoint types. > + * Don't change these without changing fail_type_strings in fail.c. > + * @ingroup failpoint_private > + */ > +enum fail_point_t { > + =A0 =A0 =A0 FAIL_POINT_OFF, =A0 =A0 =A0 =A0 /**< don't fail */ > + =A0 =A0 =A0 FAIL_POINT_PANIC, =A0 =A0 =A0 /**< panic */ > + =A0 =A0 =A0 FAIL_POINT_RETURN, =A0 =A0 =A0/**< return an errorcode */ > + =A0 =A0 =A0 FAIL_POINT_BREAK, =A0 =A0 =A0 /**< break into the debugger = */ > + =A0 =A0 =A0 FAIL_POINT_PRINT, =A0 =A0 =A0 /**< print a message */ > + =A0 =A0 =A0 FAIL_POINT_SLEEP, =A0 =A0 =A0 /**< sleep for some msecs */ > + =A0 =A0 =A0 FAIL_POINT_INVALID, =A0 =A0 /**< placeholder */ > +}; > + > +static const char *fail_type_strings[] =3D { > + =A0 =A0 =A0 "off", > + =A0 =A0 =A0 "panic", > + =A0 =A0 =A0 "return", > + =A0 =A0 =A0 "break", > + =A0 =A0 =A0 "print", > + =A0 =A0 =A0 "sleep", > +}; > + > +/** > + * Internal structure tracking a single term of a complete failpoint. > + * @ingroup failpoint_private > + */ > +struct fail_point_entry { > + =A0 =A0 =A0 enum fail_point_t fe_type; =A0 =A0 =A0/**< type of entry */ > + =A0 =A0 =A0 int =A0 =A0 =A0 =A0 =A0 =A0 fe_arg; =A0 =A0 =A0 =A0 /**< ar= gument to type (e.g. return value) */ > + =A0 =A0 =A0 int =A0 =A0 =A0 =A0 =A0 =A0 fe_prob; =A0 =A0 =A0 =A0/**< li= kelihood of firing in millionths */ > + =A0 =A0 =A0 int =A0 =A0 =A0 =A0 =A0 =A0 fe_count; =A0 =A0 =A0 /**< numb= er of times to fire, 0 means always */ > + > + =A0 =A0 =A0 TAILQ_ENTRY(fail_point_entry) fe_entries; /**< next entry i= n fail point */ > +}; > + > =A0static inline void > =A0fail_point_sleep(struct fail_point *fp, struct fail_point_entry *ent, > =A0 =A0 int msecs, enum fail_point_return_code *pret) > @@ -102,15 +139,6 @@ enum { > =A0 =A0 =A0 =A0PROB_DIGITS =3D 6, =A0 =A0 =A0 =A0/* number of zero's in a= bove number */ > =A0}; > > -static const char *fail_type_strings[] =3D { > - =A0 =A0 =A0 "off", > - =A0 =A0 =A0 "panic", > - =A0 =A0 =A0 "return", > - =A0 =A0 =A0 "break", > - =A0 =A0 =A0 "print", > - =A0 =A0 =A0 "sleep", > -}; > - > =A0static char *parse_fail_point(struct fail_point_entries *, char *); > =A0static char *parse_term(struct fail_point_entries *, char *); > =A0static char *parse_number(int *out_units, int *out_decimal, char *); > > Modified: stable/8/sys/sys/fail.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- stable/8/sys/sys/fail.h =A0 =A0 Tue Jan 11 17:16:50 2011 =A0 =A0 =A0 = =A0(r217268) > +++ stable/8/sys/sys/fail.h =A0 =A0 Tue Jan 11 17:26:36 2011 =A0 =A0 =A0 = =A0(r217269) > @@ -39,22 +39,6 @@ > =A0#include > =A0#include > > - > -/** > - * Failpoint types. > - * Don't change these without changing fail_type_strings in fail.c. > - * @ingroup failpoint_private > - */ > -enum fail_point_t { > - =A0 =A0 =A0 FAIL_POINT_OFF, =A0 =A0 =A0 =A0 /**< don't fail */ > - =A0 =A0 =A0 FAIL_POINT_PANIC, =A0 =A0 =A0 /**< panic */ > - =A0 =A0 =A0 FAIL_POINT_RETURN, =A0 =A0 =A0/**< return an errorcode */ > - =A0 =A0 =A0 FAIL_POINT_BREAK, =A0 =A0 =A0 /**< break into the debugger = */ > - =A0 =A0 =A0 FAIL_POINT_PRINT, =A0 =A0 =A0 /**< print a message */ > - =A0 =A0 =A0 FAIL_POINT_SLEEP, =A0 =A0 =A0 /**< sleep for some msecs */ > - =A0 =A0 =A0 FAIL_POINT_INVALID, =A0 =A0 /**< placeholder */ > -}; > - > =A0/** > =A0* Failpoint return codes, used internally. > =A0* @ingroup failpoint_private > @@ -65,6 +49,7 @@ enum fail_point_return_code { > =A0 =A0 =A0 =A0FAIL_POINT_RC_QUEUED, =A0 =A0 =A0 =A0 =A0 /**< sleep_fn wi= ll be called */ > =A0}; > > +struct fail_point_entry; > =A0TAILQ_HEAD(fail_point_entries, fail_point_entry); > =A0/** > =A0* Internal failpoint structure, tracking all the current details of th= e > @@ -84,18 +69,7 @@ struct fail_point { > > =A0#define =A0 =A0 =A0 =A0FAIL_POINT_DYNAMIC_NAME 0x01 =A0 =A0/**< Must f= ree name on destroy */ > > -/** > - * Internal structure tracking a single term of a complete failpoint. > - * @ingroup failpoint_private > - */ > -struct fail_point_entry { > - =A0 =A0 =A0 enum fail_point_t fe_type; =A0 =A0 =A0/**< type of entry */ > - =A0 =A0 =A0 int =A0 =A0 =A0 =A0 =A0 =A0 fe_arg; =A0 =A0 =A0 =A0 /**< ar= gument to type (e.g. return value) */ > - =A0 =A0 =A0 int =A0 =A0 =A0 =A0 =A0 =A0 fe_prob; =A0 =A0 =A0 =A0/**< li= kelihood of firing in millionths */ > - =A0 =A0 =A0 int =A0 =A0 =A0 =A0 =A0 =A0 fe_count; =A0 =A0 =A0 /**< numb= er of times to fire, 0 means always */ > - > - =A0 =A0 =A0 TAILQ_ENTRY(fail_point_entry) fe_entries; /**< next entry i= n fail point */ > -}; > +__BEGIN_DECLS > > =A0/* Private failpoint eval function -- use fail_point_eval() instead. *= / > =A0enum fail_point_return_code fail_point_eval_nontrivial(struct fail_poi= nt *, > @@ -152,6 +126,8 @@ fail_point_eval(struct fail_point *fp, i > =A0 =A0 =A0 =A0return (fail_point_eval_nontrivial(fp, ret)); > =A0} > > +__END_DECLS > + > =A0/* Declare a fail_point and its sysctl in a function. */ > =A0#define _FAIL_POINT_NAME(name) _fail_point_##name > =A0#define _STRINGIFY_HELPER(x) #x > @@ -233,7 +209,7 @@ fail_point_eval(struct fail_point *fp, i > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0NULL, NULL, =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0SYSCTL_OID(parent, OID_AUTO, name, =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\ > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 CTLTYPE_STRING | CTLFLAG_RW= , =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 CTLTYPE_STRING | CTLFLAG_RW= | CTLFLAG_MPSAFE, =A0 \ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&_FAIL_POINT_NAME(name), 0= , fail_point_sysctl, =A0\ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"A", ""); =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\ > @@ -254,7 +230,7 @@ int fail_point_sysctl(SYSCTL_HANDLER_ARG > > =A0/* The fail point sysctl tree. */ > =A0SYSCTL_DECL(_debug_fail_point); > +#define =A0 =A0 =A0 =A0DEBUG_FP =A0 =A0 =A0 =A0_debug_fail_point > =A0#endif > -#define DEBUG_FP _debug_fail_point > > =A0#endif /* _SYS_FAIL_H_ */ > From owner-svn-src-stable@FreeBSD.ORG Tue Jan 11 19:13:29 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9F6081065679; Tue, 11 Jan 2011 19:13:29 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8E7E28FC2E; Tue, 11 Jan 2011 19:13: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 p0BJDTD6031883; Tue, 11 Jan 2011 19:13:29 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0BJDTJ3031881; Tue, 11 Jan 2011 19:13:29 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201101111913.p0BJDTJ3031881@svn.freebsd.org> From: Dimitry Andric Date: Tue, 11 Jan 2011 19:13:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217276 - stable/8/sys/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jan 2011 19:13:29 -0000 Author: dim Date: Tue Jan 11 19:13:29 2011 New Revision: 217276 URL: http://svn.freebsd.org/changeset/base/217276 Log: MFC r215212: Similar to r212647, remove the workaround in sys/net/vnet.h for an ld bug (incorrect placement of __start_SECNAME in some cases) that was fixed in r210245. There is already an UPDATING entry about needing a recent ld. Modified: stable/8/sys/net/vnet.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/net/vnet.h ============================================================================== --- stable/8/sys/net/vnet.h Tue Jan 11 19:07:34 2011 (r217275) +++ stable/8/sys/net/vnet.h Tue Jan 11 19:13:29 2011 (r217276) @@ -191,15 +191,6 @@ extern struct sx vnet_sxlock; * Virtual network stack memory allocator, which allows global variables to * be automatically instantiated for each network stack instance. */ -__asm__( -#if defined(__arm__) - ".section " VNET_SETNAME ", \"aw\", %progbits\n" -#else - ".section " VNET_SETNAME ", \"aw\", @progbits\n" -#endif - "\t.p2align " __XSTRING(CACHE_LINE_SHIFT) "\n" - "\t.previous"); - #define VNET_NAME(n) vnet_entry_##n #define VNET_DECLARE(t, n) extern t VNET_NAME(n) #define VNET_DEFINE(t, n) t VNET_NAME(n) __section(VNET_SETNAME) __used From owner-svn-src-stable@FreeBSD.ORG Tue Jan 11 19:17:13 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C45D0106566B; Tue, 11 Jan 2011 19:17:13 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B33A18FC14; Tue, 11 Jan 2011 19:17: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 p0BJHDIQ032000; Tue, 11 Jan 2011 19:17:13 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0BJHDR3031998; Tue, 11 Jan 2011 19:17:13 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201101111917.p0BJHDR3031998@svn.freebsd.org> From: Dimitry Andric Date: Tue, 11 Jan 2011 19:17:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217277 - stable/8/sys/amd64/amd64 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jan 2011 19:17:13 -0000 Author: dim Date: Tue Jan 11 19:17:13 2011 New Revision: 217277 URL: http://svn.freebsd.org/changeset/base/217277 Log: MFC r215801: Change ambiguous (or invalid, depending on how strict you want to be :) assembly instruction "movw %rcx,2(%rax)" to "movw %cx,2(%rax)", since the intent was to move 16 bits of data, in this case. Found by: clang Reviewed by: kib Modified: stable/8/sys/amd64/amd64/cpu_switch.S Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/amd64/amd64/cpu_switch.S ============================================================================== --- stable/8/sys/amd64/amd64/cpu_switch.S Tue Jan 11 19:13:29 2011 (r217276) +++ stable/8/sys/amd64/amd64/cpu_switch.S Tue Jan 11 19:17:13 2011 (r217277) @@ -276,7 +276,7 @@ load_dr: do_tss: movq %rdx,PCPU(TSSP) movq %rdx,%rcx movq PCPU(TSS),%rax - movw %rcx,2(%rax) + movw %cx,2(%rax) shrq $16,%rcx movb %cl,4(%rax) shrq $8,%rcx From owner-svn-src-stable@FreeBSD.ORG Tue Jan 11 20:04:38 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5D6A7106564A; Tue, 11 Jan 2011 20:04:38 +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 3151F8FC12; Tue, 11 Jan 2011 20:04:38 +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 p0BK4cgu033631; Tue, 11 Jan 2011 20:04:38 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0BK4cP4033628; Tue, 11 Jan 2011 20:04:38 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201101112004.p0BK4cP4033628@svn.freebsd.org> From: Doug Barton Date: Tue, 11 Jan 2011 20:04:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217281 - stable/8/usr.bin/stat X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jan 2011 20:04:38 -0000 Author: dougb Date: Tue Jan 11 20:04:37 2011 New Revision: 217281 URL: http://svn.freebsd.org/changeset/base/217281 Log: MFC r203971: The NetBSD Foundation has granted permission to remove clause 3 and 4 from their software. Obtained from: NetBSD Modified: stable/8/usr.bin/stat/stat.1 stable/8/usr.bin/stat/stat.c Directory Properties: stable/8/usr.bin/stat/ (props changed) Modified: stable/8/usr.bin/stat/stat.1 ============================================================================== --- stable/8/usr.bin/stat/stat.1 Tue Jan 11 19:43:35 2011 (r217280) +++ stable/8/usr.bin/stat/stat.1 Tue Jan 11 20:04:37 2011 (r217281) @@ -14,13 +14,6 @@ .\" 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the NetBSD -.\" Foundation, Inc. and its contributors. -.\" 4. Neither the name of The NetBSD Foundation nor the names of its -.\" contributors may be used to endorse or promote products derived -.\" from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED Modified: stable/8/usr.bin/stat/stat.c ============================================================================== --- stable/8/usr.bin/stat/stat.c Tue Jan 11 19:43:35 2011 (r217280) +++ stable/8/usr.bin/stat/stat.c Tue Jan 11 20:04:37 2011 (r217281) @@ -13,13 +13,6 @@ * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED From owner-svn-src-stable@FreeBSD.ORG Tue Jan 11 20:05:53 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 842F31065673; Tue, 11 Jan 2011 20:05:53 +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 587028FC13; Tue, 11 Jan 2011 20:05: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 p0BK5rlB033726; Tue, 11 Jan 2011 20:05:53 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0BK5rxo033723; Tue, 11 Jan 2011 20:05:53 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201101112005.p0BK5rxo033723@svn.freebsd.org> From: Doug Barton Date: Tue, 11 Jan 2011 20:05:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217282 - stable/7/usr.bin/stat X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jan 2011 20:05:53 -0000 Author: dougb Date: Tue Jan 11 20:05:53 2011 New Revision: 217282 URL: http://svn.freebsd.org/changeset/base/217282 Log: MFC r203971: The NetBSD Foundation has granted permission to remove clause 3 and 4 from their software. Obtained from: NetBSD Modified: stable/7/usr.bin/stat/stat.1 stable/7/usr.bin/stat/stat.c Directory Properties: stable/7/usr.bin/stat/ (props changed) Modified: stable/7/usr.bin/stat/stat.1 ============================================================================== --- stable/7/usr.bin/stat/stat.1 Tue Jan 11 20:04:37 2011 (r217281) +++ stable/7/usr.bin/stat/stat.1 Tue Jan 11 20:05:53 2011 (r217282) @@ -14,13 +14,6 @@ .\" 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the NetBSD -.\" Foundation, Inc. and its contributors. -.\" 4. Neither the name of The NetBSD Foundation nor the names of its -.\" contributors may be used to endorse or promote products derived -.\" from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED Modified: stable/7/usr.bin/stat/stat.c ============================================================================== --- stable/7/usr.bin/stat/stat.c Tue Jan 11 20:04:37 2011 (r217281) +++ stable/7/usr.bin/stat/stat.c Tue Jan 11 20:05:53 2011 (r217282) @@ -13,13 +13,6 @@ * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED From owner-svn-src-stable@FreeBSD.ORG Tue Jan 11 20:08:35 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 15BD9106566C; Tue, 11 Jan 2011 20:08:35 +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 028348FC24; Tue, 11 Jan 2011 20:08: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 p0BK8Yu8033834; Tue, 11 Jan 2011 20:08:35 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0BK8YYo033829; Tue, 11 Jan 2011 20:08:34 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201101112008.p0BK8YYo033829@svn.freebsd.org> From: Doug Barton Date: Tue, 11 Jan 2011 20:08:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217283 - stable/8/usr.bin/stat X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jan 2011 20:08:35 -0000 Author: dougb Date: Tue Jan 11 20:08:34 2011 New Revision: 217283 URL: http://svn.freebsd.org/changeset/base/217283 Log: For stat.c ========== MFC r216196: Bring in the change from NetBSD 1.18: "If using stat (the -L flag) and it fails, fall back to lstat(). It may be the case that we're examining a broken symlink, and anything is better than nothing." The changes in 1.14 through 1.17 were not relevant to us. Obtained from: atatat@NetBSD.org MFC r216202: Bring in the change from NetBSD 1.22: "Fix a trivial truncation case, and eliminate a corner case that might print a nul character." I am purposely bypassing the following versions: 1.19 A build infrastructure change that does not apply to us 1.20 A feature I am not interested in, but don't object if someone else wants to pick it up 1.21 A build infrastructure change that does not apply to us Obtained from: atatat@NetBSD.org MFC r216203: Bring in a new feature, adding a -f option to readlink to print the path of the target, similar to realpath(1). See the discussion at: http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=34662 This brings in the following changes: 1.24 "PR/34662: martijnb at atlas dot ipv6 dot stack dot nl: readlink doesn't grok -f, and there's no alternative (+fix) Patch applied with minor tweak (%y -> %R, as it was already taken) plus some nits from myself. Thanks!" Obtained from: elad@NetBSD.org 1.25 "Fix a segfault when doing 'stat -f %R' on the stdin file handle, instead fake the filename '(stdin)' like the %N format." Obtained from: mlelstv@NetBSD.org 1.27 "The ofmt variable is actually a bit mask (not the character that was in the format string) so that we can "or" it with the bits in the formats variable. This fixes the missing " -> " in front of the real path (when you use %SR). Also, the ?: needs another space." Obtained from: atatat@NetBSD.org I am purposely omitting the following changes: 1.23 A humanize_number(3) clone that should better be implemented by actually using humanize_number(3) 1.26 This is the removal of license clause 3 and 4, already handled by imp in r203971 MFC 216205: Bring in the update from NetBSD 1.28: "Fix WARNS=4 issues (-Wcast-qual -Wsign-compare)" Because of code differences I had to hand-apply parts of the patch, so responsibility for errors goes to me. Obtained from: lukem@NetBSD.org MFC 216206: [ Also applies to Makefile ] Fix an "unused variable" error that gets us all the way to WARNS=6 MFC 216207: Bring in the following changes from NetBSD. See the discussion at: http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=44128 1.29 "Don't printf time_t with %d; fixes PR 44128 from yamt. With this change it successfully prints mtimes after 2038." 1.30 "Improve previous with comments." Obtained from: dholland@NetBSD.org (both) MFC 216343: Bring in the change from OpenBSD's 1.14: "synchronize synopsis and usage; "-l", "-r", "-s" and "-x" are mutually exclusive; while here, slightly improve spacing in the source code so it fits on a 80-column display again. diff greatly improved by martynas@" Obtained from: sobrado@OpenBSD.org MFC 216512: Bring in the relevant changes from NetBSD's 1.31: "Use strlcpy, not strncpy, when the desired semantics are strlcpy's rather than strncpy's." Note: NetBSD's 1.32 is their adoption of our r216206 Obtained from: dholland@NetBSD.org For stat.1 ========== MFC 216197: Add my own documentation for the change in our r216196, aka NetBSD's 1.18 For -L if stat(2) fails, fall back to lstat(2). .Dd purposely not bumped because more changes are coming. MFC 216204: Bring in the update from NetBSD 1.19, the documentation of readlink -f "PR/34662: martijnb at atlas dot ipv6 dot stack dot nl: readlink doesn't grok -f, and there's no alternative (+fix) Patch applied with minor tweak (%y -> %R, as it was already taken) plus some nits from myself. Thanks!" Obtained from: elad@NetBSD.org MFC 216209: Bring in the change from NetBSD 1.12: "document default format." Obtained from: yamt@NetBSD.org MFC 216213: Bring in the changes from NetBSD 1.13 that we did not already have, with some differences. "Sort options. Use more mdoc macros. Some nit fixes. Bump date." Obtained from: wiz@NetBSD.org MFC 216215: Bring in the changes from NetBSD 1.16 that we did not already have. "Some fixes from jmc@openbsd." Obtained from: wiz@NetBSD.org MFC 216216: Bring in the change from NetBSD 1.20: "Make sentence easier to parse. From jsing@openbsd via jmc@openbsd." Obtained from: wiz@NetBSD.org MFC 216218: Bring in the following changes from NetBSD: 1.21 "Document the flags displayed by the default format, and mention their short names. From espie@openbsd via jmc@openbsd." 1.24 "Fix three variable names. From Todd T. Fries via Jason McIntyre." Obtained from: wiz@NetBSD.org (previous 2) 1.25 "Be consistent: document the birthtime field of struct stat for the "B" field specifier." Obtained from: reed@NetBSD.org 1.26 "Drop trailing space." Obtained from: wiz@NetBSD.org 1.27 "Since we have st_birthtime in struct stat, it is in default display." Obtained from: enami@NetBSD.org Purposely skipping the following revisions: 1.22 NetBSD-specific change 1.23 Removal of license clauses 3 and 4, already handled by imp in our r203971 MFC 216219: Bring in the change from NetBSD 1.28: "\\ -> \e" Obtained from: joerg@NetBSD.org Bump .Dd because we're now up to date with the latest NetBSD version Modified: stable/8/usr.bin/stat/Makefile stable/8/usr.bin/stat/stat.1 stable/8/usr.bin/stat/stat.c Directory Properties: stable/8/usr.bin/stat/ (props changed) Modified: stable/8/usr.bin/stat/Makefile ============================================================================== --- stable/8/usr.bin/stat/Makefile Tue Jan 11 20:05:53 2011 (r217282) +++ stable/8/usr.bin/stat/Makefile Tue Jan 11 20:08:34 2011 (r217283) @@ -1,7 +1,6 @@ # $FreeBSD$ PROG= stat -WARNS?= 2 LINKS= ${BINDIR}/stat ${BINDIR}/readlink MLINKS= stat.1 readlink.1 Modified: stable/8/usr.bin/stat/stat.1 ============================================================================== --- stable/8/usr.bin/stat/stat.1 Tue Jan 11 20:05:53 2011 (r217282) +++ stable/8/usr.bin/stat/stat.1 Tue Jan 11 20:08:34 2011 (r217283) @@ -1,4 +1,4 @@ -.\" $NetBSD: stat.1,v 1.11 2003/05/08 13:07:10 wiz Exp $ +.\" $NetBSD: stat.1,v 1.28 2010/04/05 21:25:01 joerg Exp $ .\" .\" Copyright (c) 2002 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 24, 2010 +.Dd December 5, 2010 .Dt STAT 1 .Os .Sh NAME @@ -43,15 +43,15 @@ .Op Fl t Ar timefmt .Op Ar .Nm readlink -.Op Fl n +.Op Fl fn .Op Ar .Sh DESCRIPTION The .Nm utility displays information about the file pointed to by .Ar file . -Read, write or execute permissions of the named file are not required, but -all directories listed in the path name leading to the file must be +Read, write, or execute permissions of the named file are not required, but +all directories listed in the pathname leading to the file must be searchable. If no argument is given, .Nm @@ -60,13 +60,42 @@ displays information about the file desc When invoked as .Nm readlink , only the target of the symbolic link is printed. -If the given argument is not a symbolic link, +If the given argument is not a symbolic link and the +.Fl f +option is not specified, .Nm readlink will print nothing and exit with an error. +If the +.Fl f +option is specified, the output is canonicalized by following every symlink +in every component of the given path recursively. +.Nm readlink +will resolve both absolute and relative paths, and return the absolute pathname +corresponding to +.Ar file . +In this case, the argument does not need to be a symbolic link. .Pp The information displayed is obtained by calling .Xr lstat 2 with the given argument and evaluating the returned structure. +The default format displays the +.Fa st_dev , +.Fa st_ino , +.Fa st_mode , +.Fa st_nlink , +.Fa st_uid , +.Fa st_gid , +.Fa st_rdev , +.Fa st_size , +.Fa st_atime , +.Fa st_mtime , +.Fa st_ctime , +.Fa st_birthtime , +.Fa st_blksize , +.Fa st_blocks , +and +.Fa st_flags +fields, in that order. .Pp The options are as follows: .Bl -tag -width indent @@ -107,6 +136,14 @@ will refer to the target of if file is a symbolic link, and not to .Ar file itself. +If the link is broken or the target does not exist, +fall back on +.Xr lstat 2 +and report information about the link. +.It Fl l +Display output in +.Ic ls Fl lT +format. .It Fl n Do not force a newline to appear at the end of each piece of output. .It Fl q @@ -136,7 +173,8 @@ display the raw, numerical value (for ex epoch, etc.). .It Fl s Display information in -.Dq "shell output" , +.Dq shell output +format, suitable for initializing variables. .It Fl x Display information in a more verbose way as known from some @@ -334,49 +372,62 @@ A required field specifier, being one of .It Cm d Device upon which .Ar file -resides. +resides +.Pq Fa st_dev . .It Cm i .Ar file Ns 's -inode number. +inode number +.Pq Fa st_ino . .It Cm p -File type and permissions. +File type and permissions +.Pq Fa st_mode . .It Cm l Number of hard links to -.Ar file . +.Ar file +.Pq Fa st_nlink . .It Cm u , g User ID and group ID of .Ar file Ns 's -owner. +owner +.Pq Fa st_uid , st_gid . .It Cm r -Device number for character and block device special files. +Device number for character and block device special files +.Pq Fa st_rdev . .It Cm a , m , c , B The time .Ar file -was last accessed or modified, of when the inode was last changed, or -the birth time of the inode. +was last accessed or modified, or when the inode was last changed, or +the birth time of the inode +.Pq Fa st_atime , st_mtime , st_ctime , st_birthtime . .It Cm z The size of .Ar file -in bytes. +in bytes +.Pq Fa st_size . .It Cm b Number of blocks allocated for -.Ar file . +.Ar file +.Pq Fa st_blocks . .It Cm k -Optimal file system I/O operation block size. +Optimal file system I/O operation block size +.Pq Fa st_blksize . .It Cm f User defined flags for .Ar file . .It Cm v -Inode generation number. +Inode generation number +.Pq Fa st_gen . .El .Pp -The following four field specifiers are not drawn directly from the +The following five field specifiers are not drawn directly from the data in .Vt "struct stat" , but are: .Bl -tag -width indent .It Cm N The name of the file. +.It Cm R +The absolute pathname corresponding to the file. .It Cm T The file type, either as in .Nm ls Fl F @@ -406,12 +457,12 @@ as an output form, with the exception of .Cm p which defaults to -.Cm O , +.Cm O ; .Cm a , m , and .Cm c which default to -.Cm D , +.Cm D ; and .Cm Y , T , and @@ -421,8 +472,15 @@ which default to .Sh EXIT STATUS .Ex -std stat readlink .Sh EXAMPLES +If no options are specified, the default format is +"%d %i %Sp %l %Su %Sg %r %z \e"%Sa\e" \e"%Sm\e" \e"%Sc\e" \e"%SB\e" %k %b %#Xf %N". +.Bd -literal -offset indent +\*[Gt] stat /tmp/bar +0 78852 -rw-r--r-- 1 root wheel 0 0 "Jul 8 10:26:03 2004" "Jul 8 10:26:03 2004" "Jul 8 10:28:13 2004" "Jan 1 09:00:00 1970" 16384 0 0 /tmp/bar +.Ed +.Pp Given a symbolic link -.Pa foo +.Dq foo that points from .Pa /tmp/foo to Modified: stable/8/usr.bin/stat/stat.c ============================================================================== --- stable/8/usr.bin/stat/stat.c Tue Jan 11 20:05:53 2011 (r217282) +++ stable/8/usr.bin/stat/stat.c Tue Jan 11 20:08:34 2011 (r217283) @@ -30,7 +30,8 @@ #include #if 0 #ifndef lint -__RCSID("$NetBSD: stat.c,v 1.13 2003/07/25 03:21:17 atatat Exp $"); +__RCSID("$NetBSD: stat.c,v 1.31 2010/12/16 05:30:16 dholland Exp $" +"$OpenBSD: stat.c,v 1.14 2009/06/24 09:44:25 sobrado Exp $"); #endif #endif @@ -52,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -152,6 +154,7 @@ __FBSDID("$FreeBSD$"); #define MIDDLE_PIECE 'M' #define LOW_PIECE 'L' +#define SHOW_realpath 'R' #define SHOW_st_dev 'd' #define SHOW_st_ino 'i' #define SHOW_st_mode 'p' @@ -175,7 +178,7 @@ __FBSDID("$FreeBSD$"); void usage(const char *); void output(const struct stat *, const char *, - const char *, int, int, int); + const char *, int, int); int format1(const struct stat *, /* stat info */ const char *, /* the file name */ const char *, int, /* the format string itself */ @@ -186,7 +189,7 @@ int format1(const struct stat *, /* stat char *xfflagstostr(unsigned long); #endif -char *timefmt; +const char *timefmt; int linkfail; #define addchar(s, c, nl) \ @@ -201,7 +204,7 @@ main(int argc, char *argv[]) struct stat st; int ch, rc, errs, am_readlink; int lsF, fmtchar, usestat, fn, nonl, quiet; - char *statfmt, *options, *synopsis; + const char *statfmt, *options, *synopsis; char dname[sizeof _PATH_DEV + SPECNAMELEN] = _PATH_DEV; const char *file; @@ -217,14 +220,15 @@ main(int argc, char *argv[]) if (strcmp(getprogname(), "readlink") == 0) { am_readlink = 1; - options = "n"; - synopsis = "[-n] [file ...]"; + options = "fn"; + synopsis = "[-fn] [file ...]"; statfmt = "%Y"; fmtchar = 'f'; quiet = 1; } else { options = "f:FlLnqrst:x"; - synopsis = "[-FlLnqrsx] [-f format] [-t timefmt] [file ...]"; + synopsis = "[-FLnq] [-f format | -l | -r | -s | -x] " + "[-t timefmt] [file ...]"; } while ((ch = getopt(argc, argv, options)) != -1) @@ -242,6 +246,10 @@ main(int argc, char *argv[]) quiet = 1; break; case 'f': + if (am_readlink) { + statfmt = "%R"; + break; + } statfmt = optarg; /* FALLTHROUGH */ case 'l': @@ -313,8 +321,17 @@ main(int argc, char *argv[]) rc = fstat(STDIN_FILENO, &st); } else { file = argv[0]; - if (usestat) - rc = stat(file, &st); + if (usestat) { + /* + * Try stat() and if it fails, fall back to + * lstat() just in case we're examining a + * broken symlink. + */ + if ((rc = stat(file, &st)) == -1 && + errno == ENOENT && + (rc = lstat(file, &st)) == -1) + errno = ENOENT; + } else rc = lstat(file, &st); } @@ -326,7 +343,7 @@ main(int argc, char *argv[]) warn("%s: stat", file); } else - output(&st, file, statfmt, fn, nonl, quiet); + output(&st, file, statfmt, fn, nonl); argv++; argc--; @@ -368,10 +385,10 @@ usage(const char *synopsis) */ void output(const struct stat *st, const char *file, - const char *statfmt, int fn, int nonl, int quiet) + const char *statfmt, int fn, int nonl) { int flags, size, prec, ofmt, hilo, what; - char buf[PATH_MAX]; + char buf[PATH_MAX + 4 + 1]; const char *subfmt; int nl, t, i; @@ -508,6 +525,7 @@ output(const struct stat *st, const char } switch (*statfmt) { + fmtcase(what, SHOW_realpath); fmtcase(what, SHOW_st_dev); fmtcase(what, SHOW_st_ino); fmtcase(what, SHOW_st_mode); @@ -540,7 +558,7 @@ output(const struct stat *st, const char buf, sizeof(buf), flags, size, prec, ofmt, hilo, what); - for (i = 0; i < t && i < sizeof(buf); i++) + for (i = 0; i < t && i < (int)(sizeof(buf) - 1); i++) addchar(stdout, buf[i], &nl); continue; @@ -567,7 +585,8 @@ format1(const struct stat *st, int hilo, int what) { u_int64_t data; - char *sdata, lfmt[24], tmp[20]; + char *stmp, lfmt[24], tmp[20]; + const char *sdata; char smode[12], sid[12], path[PATH_MAX + 4]; struct passwd *pw; struct group *gr; @@ -628,28 +647,29 @@ format1(const struct stat *st, small = (sizeof(st->st_mode) == 4); data = st->st_mode; strmode(st->st_mode, smode); - sdata = smode; - l = strlen(sdata); - if (sdata[l - 1] == ' ') - sdata[--l] = '\0'; + stmp = smode; + l = strlen(stmp); + if (stmp[l - 1] == ' ') + stmp[--l] = '\0'; if (hilo == HIGH_PIECE) { data >>= 12; - sdata += 1; - sdata[3] = '\0'; + stmp += 1; + stmp[3] = '\0'; hilo = 0; } else if (hilo == MIDDLE_PIECE) { data = (data >> 9) & 07; - sdata += 4; - sdata[3] = '\0'; + stmp += 4; + stmp[3] = '\0'; hilo = 0; } else if (hilo == LOW_PIECE) { data &= 0777; - sdata += 7; - sdata[3] = '\0'; + stmp += 7; + stmp[3] = '\0'; hilo = 0; } + sdata = stmp; formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX | FMTF_STRING; if (ofmt == 0) @@ -710,7 +730,6 @@ format1(const struct stat *st, ts = *tsp; /* copy so we can muck with it */ small = (sizeof(ts.tv_sec) == 4); data = ts.tv_sec; - small = 1; tm = localtime(&ts.tv_sec); (void)strftime(path, sizeof(path), timefmt, tm); sdata = path; @@ -766,6 +785,26 @@ format1(const struct stat *st, ofmt = FMTF_UNSIGNED; break; #endif /* HAVE_STRUCT_STAT_ST_GEN */ + case SHOW_realpath: + small = 0; + data = 0; + if (file == NULL) { + (void)strlcpy(path, "(stdin)", sizeof(path)); + sdata = path; + } else { + snprintf(path, sizeof(path), " -> "); + if (realpath(file, path + 4) == NULL) { + linkfail = 1; + l = 0; + path[0] = '\0'; + } + sdata = path + (ofmt == FMTF_STRING ? 0 : 4); + } + + formats = FMTF_STRING; + if (ofmt == 0) + ofmt = FMTF_STRING; + break; case SHOW_symlink: small = 0; data = 0; @@ -791,24 +830,23 @@ format1(const struct stat *st, case SHOW_filetype: small = 0; data = 0; - sdata = smode; - sdata[0] = '\0'; + sdata = ""; if (hilo == 0 || hilo == LOW_PIECE) { switch (st->st_mode & S_IFMT) { - case S_IFIFO: (void)strcat(sdata, "|"); break; - case S_IFDIR: (void)strcat(sdata, "/"); break; + case S_IFIFO: sdata = "|"; break; + case S_IFDIR: sdata = "/"; break; case S_IFREG: if (st->st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) - (void)strcat(sdata, "*"); + sdata = "*"; break; - case S_IFLNK: (void)strcat(sdata, "@"); break; - case S_IFSOCK: (void)strcat(sdata, "="); break; + case S_IFLNK: sdata = "@"; break; + case S_IFSOCK: sdata = "="; break; #ifdef S_IFWHT - case S_IFWHT: (void)strcat(sdata, "%"); break; + case S_IFWHT: sdata = "%"; break; #endif /* S_IFWHT */ #ifdef S_IFDOOR - case S_IFDOOR: (void)strcat(sdata, ">"); break; + case S_IFDOOR: sdata = ">"; break; #endif /* S_IFDOOR */ } hilo = 0; @@ -839,7 +877,7 @@ format1(const struct stat *st, case SHOW_filename: small = 0; data = 0; - (void)strncpy(path, file, sizeof(path)); + (void)strlcpy(path, file, sizeof(path)); sdata = path; formats = FMTF_STRING; if (ofmt == 0) @@ -914,8 +952,9 @@ format1(const struct stat *st, (void)snprintf(tmp, sizeof(tmp), "%d", size); (void)strcat(lfmt, tmp); } - (void)strcat(lfmt, "d"); - return (snprintf(buf, blen, lfmt, ts.tv_sec)); + (void)strcat(lfmt, "lld"); + return (snprintf(buf, blen, lfmt, + (long long)ts.tv_sec)); } /* @@ -938,7 +977,8 @@ format1(const struct stat *st, (void)snprintf(tmp, sizeof(tmp), "%d", size); (void)strcat(lfmt, tmp); } - (void)strcat(lfmt, "d"); + /* Seconds: time_t cast to long long. */ + (void)strcat(lfmt, "lld"); /* * The stuff after the decimal point always needs zero @@ -949,8 +989,10 @@ format1(const struct stat *st, /* * We can "print" at most nine digits of precision. The * rest we will pad on at the end. + * + * Nanoseconds: long. */ - (void)snprintf(tmp, sizeof(tmp), "%dd", prec > 9 ? 9 : prec); + (void)snprintf(tmp, sizeof(tmp), "%dld", prec > 9 ? 9 : prec); (void)strcat(lfmt, tmp); /* @@ -964,8 +1006,8 @@ format1(const struct stat *st, * Use the format, and then tack on any zeroes that * might be required to make up the requested precision. */ - l = snprintf(buf, blen, lfmt, ts.tv_sec, ts.tv_nsec); - for (; prec > 9 && l < blen; prec--, l++) + l = snprintf(buf, blen, lfmt, (long long)ts.tv_sec, ts.tv_nsec); + for (; prec > 9 && l < (int)blen; prec--, l++) (void)strcat(buf, "0"); return (l); } From owner-svn-src-stable@FreeBSD.ORG Wed Jan 12 05:37:13 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9D5E6106566C; Wed, 12 Jan 2011 05:37:13 +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 8BF2C8FC28; Wed, 12 Jan 2011 05:37: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 p0C5bDSG053443; Wed, 12 Jan 2011 05:37:13 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0C5bD7p053441; Wed, 12 Jan 2011 05:37:13 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201101120537.p0C5bD7p053441@svn.freebsd.org> From: Doug Barton Date: Wed, 12 Jan 2011 05:37:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217298 - stable/7/usr.bin/stat X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jan 2011 05:37:13 -0000 Author: dougb Date: Wed Jan 12 05:37:13 2011 New Revision: 217298 URL: http://svn.freebsd.org/changeset/base/217298 Log: MFC 178651: The referenced section name is 'Formats', not 'FORMATS'. Modified: stable/7/usr.bin/stat/stat.1 Directory Properties: stable/7/usr.bin/stat/ (props changed) Modified: stable/7/usr.bin/stat/stat.1 ============================================================================== --- stable/7/usr.bin/stat/stat.1 Wed Jan 12 04:59:29 2011 (r217297) +++ stable/7/usr.bin/stat/stat.1 Wed Jan 12 05:37:13 2011 (r217298) @@ -121,7 +121,7 @@ error messages are automatically suppres .It Fl f Ar format Display information using the specified format. See the -.Sx FORMATS +.Sx Formats section for a description of valid formats. .It Fl l Display output in From owner-svn-src-stable@FreeBSD.ORG Wed Jan 12 07:27:30 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9BF34106564A; Wed, 12 Jan 2011 07:27:30 +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 6FA0E8FC0A; Wed, 12 Jan 2011 07:27: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 p0C7RUsq058195; Wed, 12 Jan 2011 07:27:30 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0C7RUVT058193; Wed, 12 Jan 2011 07:27:30 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201101120727.p0C7RUVT058193@svn.freebsd.org> From: Doug Barton Date: Wed, 12 Jan 2011 07:27:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217299 - stable/7/usr.bin/stat X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jan 2011 07:27:30 -0000 Author: dougb Date: Wed Jan 12 07:27:30 2011 New Revision: 217299 URL: http://svn.freebsd.org/changeset/base/217299 Log: MFC r188498 (partial): "I've changed main() to set file properly, so output() is never called with file set to NULL." Obtained from: ed The other bits of that revision are related to using fdevname(3). This was never merged back to RELENG_7, however the cleanup of the code in this MFC is good both for general purposes, and diff reduction to HEAD (which in turn will make the following MFCs easier). Modified: stable/7/usr.bin/stat/stat.c Directory Properties: stable/7/usr.bin/stat/ (props changed) Modified: stable/7/usr.bin/stat/stat.c ============================================================================== --- stable/7/usr.bin/stat/stat.c Wed Jan 12 05:37:13 2011 (r217298) +++ stable/7/usr.bin/stat/stat.c Wed Jan 12 07:27:30 2011 (r217299) @@ -200,6 +200,7 @@ main(int argc, char *argv[]) int ch, rc, errs, am_readlink; int lsF, fmtchar, usestat, fn, nonl, quiet; char *statfmt, *options, *synopsis; + const char *file; am_readlink = 0; lsF = 0; @@ -300,22 +301,25 @@ main(int argc, char *argv[]) errs = 0; do { - if (argc == 0) + if (argc == 0) { + file = "(stdin)"; rc = fstat(STDIN_FILENO, &st); - else if (usestat) - rc = stat(argv[0], &st); - else - rc = lstat(argv[0], &st); + } else { + file = argv[0]; + if (usestat) + rc = stat(file, &st); + else + rc = lstat(file, &st); + } if (rc == -1) { errs = 1; linkfail = 1; if (!quiet) - warn("%s: stat", - argc == 0 ? "(stdin)" : argv[0]); + warn("%s: stat", file); } else - output(&st, argv[0], statfmt, fn, nonl, quiet); + output(&st, file, statfmt, fn, nonl, quiet); argv++; argc--; @@ -828,10 +832,7 @@ format1(const struct stat *st, case SHOW_filename: small = 0; data = 0; - if (file == NULL) - (void)strncpy(path, "(stdin)", sizeof(path)); - else - (void)strncpy(path, file, sizeof(path)); + (void)strncpy(path, file, sizeof(path)); sdata = path; formats = FMTF_STRING; if (ofmt == 0) From owner-svn-src-stable@FreeBSD.ORG Wed Jan 12 07:38:49 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1BCD51065672; Wed, 12 Jan 2011 07:38:49 +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 DAD788FC17; Wed, 12 Jan 2011 07:38: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 p0C7cmWZ059596; Wed, 12 Jan 2011 07:38:48 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0C7cmlH059592; Wed, 12 Jan 2011 07:38:48 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201101120738.p0C7cmlH059592@svn.freebsd.org> From: Doug Barton Date: Wed, 12 Jan 2011 07:38:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217300 - stable/7/usr.bin/stat X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jan 2011 07:38:49 -0000 Author: dougb Date: Wed Jan 12 07:38:48 2011 New Revision: 217300 URL: http://svn.freebsd.org/changeset/base/217300 Log: For stat.c ========== MFC r216196: Bring in the change from NetBSD 1.18: "If using stat (the -L flag) and it fails, fall back to lstat(). It may be the case that we're examining a broken symlink, and anything is better than nothing." The changes in 1.14 through 1.17 were not relevant to us. Obtained from: atatat@NetBSD.org MFC r216202: Bring in the change from NetBSD 1.22: "Fix a trivial truncation case, and eliminate a corner case that might print a nul character." I am purposely bypassing the following versions: 1.19 A build infrastructure change that does not apply to us 1.20 A feature I am not interested in, but don't object if someone else wants to pick it up 1.21 A build infrastructure change that does not apply to us Obtained from: atatat@NetBSD.org MFC r216203: Bring in a new feature, adding a -f option to readlink to print the path of the target, similar to realpath(1). See the discussion at: http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=34662 This brings in the following changes: 1.24 "PR/34662: martijnb at atlas dot ipv6 dot stack dot nl: readlink doesn't grok -f, and there's no alternative (+fix) Patch applied with minor tweak (%y -> %R, as it was already taken) plus some nits from myself. Thanks!" Obtained from: elad@NetBSD.org 1.25 "Fix a segfault when doing 'stat -f %R' on the stdin file handle, instead fake the filename '(stdin)' like the %N format." Obtained from: mlelstv@NetBSD.org 1.27 "The ofmt variable is actually a bit mask (not the character that was in the format string) so that we can "or" it with the bits in the formats variable. This fixes the missing " -> " in front of the real path (when you use %SR). Also, the ?: needs another space." Obtained from: atatat@NetBSD.org I am purposely omitting the following changes: 1.23 A humanize_number(3) clone that should better be implemented by actually using humanize_number(3) 1.26 This is the removal of license clause 3 and 4, already handled by imp in r203971 MFC 216205: Bring in the update from NetBSD 1.28: "Fix WARNS=4 issues (-Wcast-qual -Wsign-compare)" Because of code differences I had to hand-apply parts of the patch, so responsibility for errors goes to me. Obtained from: lukem@NetBSD.org MFC 216206: [ Also applies to Makefile ] Fix an "unused variable" error that gets us all the way to WARNS=6 MFC 216207: Bring in the following changes from NetBSD. See the discussion at: http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=44128 1.29 "Don't printf time_t with %d; fixes PR 44128 from yamt. With this change it successfully prints mtimes after 2038." 1.30 "Improve previous with comments." Obtained from: dholland@NetBSD.org (both) MFC 216343: Bring in the change from OpenBSD's 1.14: "synchronize synopsis and usage; "-l", "-r", "-s" and "-x" are mutually exclusive; while here, slightly improve spacing in the source code so it fits on a 80-column display again. diff greatly improved by martynas@" Obtained from: sobrado@OpenBSD.org MFC 216512: Bring in the relevant changes from NetBSD's 1.31: "Use strlcpy, not strncpy, when the desired semantics are strlcpy's rather than strncpy's." Note: NetBSD's 1.32 is their adoption of our r216206 Obtained from: dholland@NetBSD.org For stat.1 ========== MFC 216197: Add my own documentation for the change in our r216196, aka NetBSD's 1.18 For -L if stat(2) fails, fall back to lstat(2). .Dd purposely not bumped because more changes are coming. MFC 216204: Bring in the update from NetBSD 1.19, the documentation of readlink -f "PR/34662: martijnb at atlas dot ipv6 dot stack dot nl: readlink doesn't grok -f, and there's no alternative (+fix) Patch applied with minor tweak (%y -> %R, as it was already taken) plus some nits from myself. Thanks!" Obtained from: elad@NetBSD.org MFC 216209: Bring in the change from NetBSD 1.12: "document default format." Obtained from: yamt@NetBSD.org MFC 216213: Bring in the changes from NetBSD 1.13 that we did not already have, with some differences. "Sort options. Use more mdoc macros. Some nit fixes. Bump date." Obtained from: wiz@NetBSD.org MFC 216215: Bring in the changes from NetBSD 1.16 that we did not already have. "Some fixes from jmc@openbsd." Obtained from: wiz@NetBSD.org MFC 216216: Bring in the change from NetBSD 1.20: "Make sentence easier to parse. From jsing@openbsd via jmc@openbsd." Obtained from: wiz@NetBSD.org MFC 216218: Bring in the following changes from NetBSD: 1.21 "Document the flags displayed by the default format, and mention their short names. From espie@openbsd via jmc@openbsd." 1.24 "Fix three variable names. From Todd T. Fries via Jason McIntyre." Obtained from: wiz@NetBSD.org (previous 2) 1.25 "Be consistent: document the birthtime field of struct stat for the "B" field specifier." Obtained from: reed@NetBSD.org 1.26 "Drop trailing space." Obtained from: wiz@NetBSD.org 1.27 "Since we have st_birthtime in struct stat, it is in default display." Obtained from: enami@NetBSD.org Purposely skipping the following revisions: 1.22 NetBSD-specific change 1.23 Removal of license clauses 3 and 4, already handled by imp in our r203971 MFC 216219: Bring in the change from NetBSD 1.28: "\\ -> \e" Obtained from: joerg@NetBSD.org Bump .Dd because we're now up to date with the latest NetBSD version Modified: stable/7/usr.bin/stat/Makefile stable/7/usr.bin/stat/stat.1 stable/7/usr.bin/stat/stat.c Directory Properties: stable/7/usr.bin/stat/ (props changed) Modified: stable/7/usr.bin/stat/Makefile ============================================================================== --- stable/7/usr.bin/stat/Makefile Wed Jan 12 07:27:30 2011 (r217299) +++ stable/7/usr.bin/stat/Makefile Wed Jan 12 07:38:48 2011 (r217300) @@ -1,7 +1,7 @@ # $FreeBSD$ PROG= stat -WARNS?= 2 +WARNS?= 6 LINKS= ${BINDIR}/stat ${BINDIR}/readlink MLINKS= stat.1 readlink.1 Modified: stable/7/usr.bin/stat/stat.1 ============================================================================== --- stable/7/usr.bin/stat/stat.1 Wed Jan 12 07:27:30 2011 (r217299) +++ stable/7/usr.bin/stat/stat.1 Wed Jan 12 07:38:48 2011 (r217300) @@ -1,4 +1,4 @@ -.\" $NetBSD: stat.1,v 1.11 2003/05/08 13:07:10 wiz Exp $ +.\" $NetBSD: stat.1,v 1.28 2010/04/05 21:25:01 joerg Exp $ .\" .\" Copyright (c) 2002 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 24, 2010 +.Dd December 5, 2010 .Dt STAT 1 .Os .Sh NAME @@ -43,15 +43,15 @@ .Op Fl t Ar timefmt .Op Ar .Nm readlink -.Op Fl n +.Op Fl fn .Op Ar .Sh DESCRIPTION The .Nm utility displays information about the file pointed to by .Ar file . -Read, write or execute permissions of the named file are not required, but -all directories listed in the path name leading to the file must be +Read, write, or execute permissions of the named file are not required, but +all directories listed in the pathname leading to the file must be searchable. If no argument is given, .Nm @@ -60,13 +60,42 @@ displays information about the file desc When invoked as .Nm readlink , only the target of the symbolic link is printed. -If the given argument is not a symbolic link, +If the given argument is not a symbolic link and the +.Fl f +option is not specified, .Nm readlink will print nothing and exit with an error. +If the +.Fl f +option is specified, the output is canonicalized by following every symlink +in every component of the given path recursively. +.Nm readlink +will resolve both absolute and relative paths, and return the absolute pathname +corresponding to +.Ar file . +In this case, the argument does not need to be a symbolic link. .Pp The information displayed is obtained by calling .Xr lstat 2 with the given argument and evaluating the returned structure. +The default format displays the +.Fa st_dev , +.Fa st_ino , +.Fa st_mode , +.Fa st_nlink , +.Fa st_uid , +.Fa st_gid , +.Fa st_rdev , +.Fa st_size , +.Fa st_atime , +.Fa st_mtime , +.Fa st_ctime , +.Fa st_birthtime , +.Fa st_blksize , +.Fa st_blocks , +and +.Fa st_flags +fields, in that order. .Pp The options are as follows: .Bl -tag -width indent @@ -107,6 +136,14 @@ will refer to the target of if file is a symbolic link, and not to .Ar file itself. +If the link is broken or the target does not exist, +fall back on +.Xr lstat 2 +and report information about the link. +.It Fl l +Display output in +.Ic ls Fl lT +format. .It Fl n Do not force a newline to appear at the end of each piece of output. .It Fl q @@ -136,7 +173,8 @@ display the raw, numerical value (for ex epoch, etc.). .It Fl s Display information in -.Dq "shell output" , +.Dq shell output +format, suitable for initializing variables. .It Fl x Display information in a more verbose way as known from some @@ -334,49 +372,62 @@ A required field specifier, being one of .It Cm d Device upon which .Ar file -resides. +resides +.Pq Fa st_dev . .It Cm i .Ar file Ns 's -inode number. +inode number +.Pq Fa st_ino . .It Cm p -File type and permissions. +File type and permissions +.Pq Fa st_mode . .It Cm l Number of hard links to -.Ar file . +.Ar file +.Pq Fa st_nlink . .It Cm u , g User ID and group ID of .Ar file Ns 's -owner. +owner +.Pq Fa st_uid , st_gid . .It Cm r -Device number for character and block device special files. +Device number for character and block device special files +.Pq Fa st_rdev . .It Cm a , m , c , B The time .Ar file -was last accessed or modified, of when the inode was last changed, or -the birth time of the inode. +was last accessed or modified, or when the inode was last changed, or +the birth time of the inode +.Pq Fa st_atime , st_mtime , st_ctime , st_birthtime . .It Cm z The size of .Ar file -in bytes. +in bytes +.Pq Fa st_size . .It Cm b Number of blocks allocated for -.Ar file . +.Ar file +.Pq Fa st_blocks . .It Cm k -Optimal file system I/O operation block size. +Optimal file system I/O operation block size +.Pq Fa st_blksize . .It Cm f User defined flags for .Ar file . .It Cm v -Inode generation number. +Inode generation number +.Pq Fa st_gen . .El .Pp -The following four field specifiers are not drawn directly from the +The following five field specifiers are not drawn directly from the data in .Vt "struct stat" , but are: .Bl -tag -width indent .It Cm N The name of the file. +.It Cm R +The absolute pathname corresponding to the file. .It Cm T The file type, either as in .Nm ls Fl F @@ -406,12 +457,12 @@ as an output form, with the exception of .Cm p which defaults to -.Cm O , +.Cm O ; .Cm a , m , and .Cm c which default to -.Cm D , +.Cm D ; and .Cm Y , T , and @@ -421,8 +472,15 @@ which default to .Sh EXIT STATUS .Ex -std stat readlink .Sh EXAMPLES +If no options are specified, the default format is +"%d %i %Sp %l %Su %Sg %r %z \e"%Sa\e" \e"%Sm\e" \e"%Sc\e" \e"%SB\e" %k %b %#Xf %N". +.Bd -literal -offset indent +\*[Gt] stat /tmp/bar +0 78852 -rw-r--r-- 1 root wheel 0 0 "Jul 8 10:26:03 2004" "Jul 8 10:26:03 2004" "Jul 8 10:28:13 2004" "Jan 1 09:00:00 1970" 16384 0 0 /tmp/bar +.Ed +.Pp Given a symbolic link -.Pa foo +.Dq foo that points from .Pa /tmp/foo to Modified: stable/7/usr.bin/stat/stat.c ============================================================================== --- stable/7/usr.bin/stat/stat.c Wed Jan 12 07:27:30 2011 (r217299) +++ stable/7/usr.bin/stat/stat.c Wed Jan 12 07:38:48 2011 (r217300) @@ -30,7 +30,8 @@ #include #if 0 #ifndef lint -__RCSID("$NetBSD: stat.c,v 1.13 2003/07/25 03:21:17 atatat Exp $"); +__RCSID("$NetBSD: stat.c,v 1.31 2010/12/16 05:30:16 dholland Exp $" +"$OpenBSD: stat.c,v 1.14 2009/06/24 09:44:25 sobrado Exp $"); #endif #endif @@ -51,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -150,6 +152,7 @@ __FBSDID("$FreeBSD$"); #define MIDDLE_PIECE 'M' #define LOW_PIECE 'L' +#define SHOW_realpath 'R' #define SHOW_st_dev 'd' #define SHOW_st_ino 'i' #define SHOW_st_mode 'p' @@ -173,7 +176,7 @@ __FBSDID("$FreeBSD$"); void usage(const char *); void output(const struct stat *, const char *, - const char *, int, int, int); + const char *, int, int); int format1(const struct stat *, /* stat info */ const char *, /* the file name */ const char *, int, /* the format string itself */ @@ -184,7 +187,7 @@ int format1(const struct stat *, /* stat char *xfflagstostr(unsigned long); #endif -char *timefmt; +const char *timefmt; int linkfail; #define addchar(s, c, nl) \ @@ -199,7 +202,7 @@ main(int argc, char *argv[]) struct stat st; int ch, rc, errs, am_readlink; int lsF, fmtchar, usestat, fn, nonl, quiet; - char *statfmt, *options, *synopsis; + const char *statfmt, *options, *synopsis; const char *file; am_readlink = 0; @@ -214,14 +217,15 @@ main(int argc, char *argv[]) if (strcmp(getprogname(), "readlink") == 0) { am_readlink = 1; - options = "n"; - synopsis = "[-n] [file ...]"; + options = "fn"; + synopsis = "[-fn] [file ...]"; statfmt = "%Y"; fmtchar = 'f'; quiet = 1; } else { options = "f:FlLnqrst:x"; - synopsis = "[-FlLnqrsx] [-f format] [-t timefmt] [file ...]"; + synopsis = "[-FLnq] [-f format | -l | -r | -s | -x] " + "[-t timefmt] [file ...]"; } while ((ch = getopt(argc, argv, options)) != -1) @@ -239,6 +243,10 @@ main(int argc, char *argv[]) quiet = 1; break; case 'f': + if (am_readlink) { + statfmt = "%R"; + break; + } statfmt = optarg; /* FALLTHROUGH */ case 'l': @@ -306,8 +314,17 @@ main(int argc, char *argv[]) rc = fstat(STDIN_FILENO, &st); } else { file = argv[0]; - if (usestat) - rc = stat(file, &st); + if (usestat) { + /* + * Try stat() and if it fails, fall back to + * lstat() just in case we're examining a + * broken symlink. + */ + if ((rc = stat(file, &st)) == -1 && + errno == ENOENT && + (rc = lstat(file, &st)) == -1) + errno = ENOENT; + } else rc = lstat(file, &st); } @@ -319,7 +336,7 @@ main(int argc, char *argv[]) warn("%s: stat", file); } else - output(&st, file, statfmt, fn, nonl, quiet); + output(&st, file, statfmt, fn, nonl); argv++; argc--; @@ -361,10 +378,10 @@ usage(const char *synopsis) */ void output(const struct stat *st, const char *file, - const char *statfmt, int fn, int nonl, int quiet) + const char *statfmt, int fn, int nonl) { int flags, size, prec, ofmt, hilo, what; - char buf[PATH_MAX]; + char buf[PATH_MAX + 4 + 1]; const char *subfmt; int nl, t, i; @@ -501,6 +518,7 @@ output(const struct stat *st, const char } switch (*statfmt) { + fmtcase(what, SHOW_realpath); fmtcase(what, SHOW_st_dev); fmtcase(what, SHOW_st_ino); fmtcase(what, SHOW_st_mode); @@ -533,7 +551,7 @@ output(const struct stat *st, const char buf, sizeof(buf), flags, size, prec, ofmt, hilo, what); - for (i = 0; i < t && i < sizeof(buf); i++) + for (i = 0; i < t && i < (int)(sizeof(buf) - 1); i++) addchar(stdout, buf[i], &nl); continue; @@ -560,7 +578,8 @@ format1(const struct stat *st, int hilo, int what) { u_int64_t data; - char *sdata, lfmt[24], tmp[20]; + char *stmp, lfmt[24], tmp[20]; + const char *sdata; char smode[12], sid[12], path[PATH_MAX + 4]; struct passwd *pw; struct group *gr; @@ -621,28 +640,29 @@ format1(const struct stat *st, small = (sizeof(st->st_mode) == 4); data = st->st_mode; strmode(st->st_mode, smode); - sdata = smode; - l = strlen(sdata); - if (sdata[l - 1] == ' ') - sdata[--l] = '\0'; + stmp = smode; + l = strlen(stmp); + if (stmp[l - 1] == ' ') + stmp[--l] = '\0'; if (hilo == HIGH_PIECE) { data >>= 12; - sdata += 1; - sdata[3] = '\0'; + stmp += 1; + stmp[3] = '\0'; hilo = 0; } else if (hilo == MIDDLE_PIECE) { data = (data >> 9) & 07; - sdata += 4; - sdata[3] = '\0'; + stmp += 4; + stmp[3] = '\0'; hilo = 0; } else if (hilo == LOW_PIECE) { data &= 0777; - sdata += 7; - sdata[3] = '\0'; + stmp += 7; + stmp[3] = '\0'; hilo = 0; } + sdata = stmp; formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX | FMTF_STRING; if (ofmt == 0) @@ -703,7 +723,6 @@ format1(const struct stat *st, ts = *tsp; /* copy so we can muck with it */ small = (sizeof(ts.tv_sec) == 4); data = ts.tv_sec; - small = 1; tm = localtime(&ts.tv_sec); (void)strftime(path, sizeof(path), timefmt, tm); sdata = path; @@ -759,6 +778,26 @@ format1(const struct stat *st, ofmt = FMTF_UNSIGNED; break; #endif /* HAVE_STRUCT_STAT_ST_GEN */ + case SHOW_realpath: + small = 0; + data = 0; + if (file == NULL) { + (void)strlcpy(path, "(stdin)", sizeof(path)); + sdata = path; + } else { + snprintf(path, sizeof(path), " -> "); + if (realpath(file, path + 4) == NULL) { + linkfail = 1; + l = 0; + path[0] = '\0'; + } + sdata = path + (ofmt == FMTF_STRING ? 0 : 4); + } + + formats = FMTF_STRING; + if (ofmt == 0) + ofmt = FMTF_STRING; + break; case SHOW_symlink: small = 0; data = 0; @@ -784,24 +823,23 @@ format1(const struct stat *st, case SHOW_filetype: small = 0; data = 0; - sdata = smode; - sdata[0] = '\0'; + sdata = ""; if (hilo == 0 || hilo == LOW_PIECE) { switch (st->st_mode & S_IFMT) { - case S_IFIFO: (void)strcat(sdata, "|"); break; - case S_IFDIR: (void)strcat(sdata, "/"); break; + case S_IFIFO: sdata = "|"; break; + case S_IFDIR: sdata = "/"; break; case S_IFREG: if (st->st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) - (void)strcat(sdata, "*"); + sdata = "*"; break; - case S_IFLNK: (void)strcat(sdata, "@"); break; - case S_IFSOCK: (void)strcat(sdata, "="); break; + case S_IFLNK: sdata = "@"; break; + case S_IFSOCK: sdata = "="; break; #ifdef S_IFWHT - case S_IFWHT: (void)strcat(sdata, "%"); break; + case S_IFWHT: sdata = "%"; break; #endif /* S_IFWHT */ #ifdef S_IFDOOR - case S_IFDOOR: (void)strcat(sdata, ">"); break; + case S_IFDOOR: sdata = ">"; break; #endif /* S_IFDOOR */ } hilo = 0; @@ -832,7 +870,7 @@ format1(const struct stat *st, case SHOW_filename: small = 0; data = 0; - (void)strncpy(path, file, sizeof(path)); + (void)strlcpy(path, file, sizeof(path)); sdata = path; formats = FMTF_STRING; if (ofmt == 0) @@ -907,8 +945,9 @@ format1(const struct stat *st, (void)snprintf(tmp, sizeof(tmp), "%d", size); (void)strcat(lfmt, tmp); } - (void)strcat(lfmt, "d"); - return (snprintf(buf, blen, lfmt, ts.tv_sec)); + (void)strcat(lfmt, "lld"); + return (snprintf(buf, blen, lfmt, + (long long)ts.tv_sec)); } /* @@ -931,7 +970,8 @@ format1(const struct stat *st, (void)snprintf(tmp, sizeof(tmp), "%d", size); (void)strcat(lfmt, tmp); } - (void)strcat(lfmt, "d"); + /* Seconds: time_t cast to long long. */ + (void)strcat(lfmt, "lld"); /* * The stuff after the decimal point always needs zero @@ -942,8 +982,10 @@ format1(const struct stat *st, /* * We can "print" at most nine digits of precision. The * rest we will pad on at the end. + * + * Nanoseconds: long. */ - (void)snprintf(tmp, sizeof(tmp), "%dd", prec > 9 ? 9 : prec); + (void)snprintf(tmp, sizeof(tmp), "%dld", prec > 9 ? 9 : prec); (void)strcat(lfmt, tmp); /* @@ -957,8 +999,8 @@ format1(const struct stat *st, * Use the format, and then tack on any zeroes that * might be required to make up the requested precision. */ - l = snprintf(buf, blen, lfmt, ts.tv_sec, ts.tv_nsec); - for (; prec > 9 && l < blen; prec--, l++) + l = snprintf(buf, blen, lfmt, (long long)ts.tv_sec, ts.tv_nsec); + for (; prec > 9 && l < (int)blen; prec--, l++) (void)strcat(buf, "0"); return (l); } From owner-svn-src-stable@FreeBSD.ORG Wed Jan 12 10:12:32 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 97537106566B; Wed, 12 Jan 2011 10:12:32 +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 6CE4E8FC1A; Wed, 12 Jan 2011 10:12: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 p0CACWr5080260; Wed, 12 Jan 2011 10:12:32 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0CACWl6080258; Wed, 12 Jan 2011 10:12:32 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201101121012.p0CACWl6080258@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Wed, 12 Jan 2011 10:12:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217302 - stable/8/sys/kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jan 2011 10:12:32 -0000 Author: bz Date: Wed Jan 12 10:12:32 2011 New Revision: 217302 URL: http://svn.freebsd.org/changeset/base/217302 Log: MFC r216340,217195: Don't tie ct_debug to bootverbose. Provide a sysctl to turn it on or off. Switch the default to always off. Improve style and wording of comments and sysctl descriptions [1]. Move machdep.ct_debug to debug.clocktime as there was no reason to actually put it under machdep in r216340. Submitted by: bde [1] Modified: stable/8/sys/kern/subr_clock.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/kern/subr_clock.c ============================================================================== --- stable/8/sys/kern/subr_clock.c Wed Jan 12 08:09:29 2011 (r217301) +++ stable/8/sys/kern/subr_clock.c Wed Jan 12 10:12:32 2011 (r217302) @@ -49,20 +49,14 @@ __FBSDID("$FreeBSD$"); #include #include -#define ct_debug bootverbose -static int adjkerntz; /* local offset from UTC in seconds */ -static int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */ - int tz_minuteswest; int tz_dsttime; /* - * This have traditionally been in machdep, but should probably be moved to - * kern. + * The adjkerntz and wall_cmos_clock sysctls are in the "machdep" sysctl + * namespace because they were misplaced there originally. */ -SYSCTL_INT(_machdep, OID_AUTO, wall_cmos_clock, - CTLFLAG_RW, &wall_cmos_clock, 0, "CMOS clock keeps wall time"); - +static int adjkerntz; static int sysctl_machdep_adjkerntz(SYSCTL_HANDLER_ARGS) { @@ -72,11 +66,18 @@ sysctl_machdep_adjkerntz(SYSCTL_HANDLER_ resettodr(); return (error); } - SYSCTL_PROC(_machdep, OID_AUTO, adjkerntz, CTLTYPE_INT|CTLFLAG_RW, &adjkerntz, 0, sysctl_machdep_adjkerntz, "I", "Local offset from UTC in seconds"); +static int ct_debug; +SYSCTL_INT(_debug, OID_AUTO, clocktime, CTLFLAG_RW, + &ct_debug, 0, "Enable printing of clocktime debugging"); + +static int wall_cmos_clock; +SYSCTL_INT(_machdep, OID_AUTO, wall_cmos_clock, CTLFLAG_RW, + &wall_cmos_clock, 0, "Enables application of machdep.adjkerntz"); + /*--------------------------------------------------------------------* * Generic routines to convert between a POSIX date * (seconds since 1/1/1970) and yr/mo/day/hr/min/sec From owner-svn-src-stable@FreeBSD.ORG Wed Jan 12 14:13:50 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 90A4B106566B; Wed, 12 Jan 2011 14:13:50 +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 649388FC14; Wed, 12 Jan 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 p0CEDoK8091441; Wed, 12 Jan 2011 14:13:50 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0CEDort091438; Wed, 12 Jan 2011 14:13:50 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201101121413.p0CEDort091438@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Wed, 12 Jan 2011 14:13:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217306 - stable/8/sbin/hastd X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jan 2011 14:13:50 -0000 Author: pjd Date: Wed Jan 12 14:13:50 2011 New Revision: 217306 URL: http://svn.freebsd.org/changeset/base/217306 Log: svn merge -c215331,215332,215676 svn+ssh://svn.freebsd.org/base/head/sbin/hastd sbin/hastd MFC r215331,r215332,r215676: r215676 (by brucec): Don't generate input() since it's not used. r215332: Move timeout.tv_sec initialization outside the loop - sigtimedwait(2) won't modify it. Submitted by: Mikolaj Golub r215331: 1. Exit when we cannot create incoming connection. 2. Improve logging to inform which connection can't be created. Submitted by: [1] Mikolaj Golub Modified: stable/8/sbin/hastd/Makefile stable/8/sbin/hastd/primary.c Directory Properties: stable/8/sbin/hastd/ (props changed) Modified: stable/8/sbin/hastd/Makefile ============================================================================== --- stable/8/sbin/hastd/Makefile Wed Jan 12 13:55:01 2011 (r217305) +++ stable/8/sbin/hastd/Makefile Wed Jan 12 14:13:50 2011 (r217306) @@ -26,6 +26,7 @@ CFLAGS+=-DINET6 .endif # This is needed to have WARNS > 1. CFLAGS+=-DYY_NO_UNPUT +CFLAGS+=-DYY_NO_INPUT DPADD= ${LIBGEOM} ${LIBBSDXML} ${LIBSBUF} ${LIBL} ${LIBPTHREAD} ${LIBUTIL} LDADD= -lgeom -lbsdxml -lsbuf -ll -lpthread -lutil Modified: stable/8/sbin/hastd/primary.c ============================================================================== --- stable/8/sbin/hastd/primary.c Wed Jan 12 13:55:01 2011 (r217305) +++ stable/8/sbin/hastd/primary.c Wed Jan 12 14:13:50 2011 (r217306) @@ -511,7 +511,8 @@ init_remote(struct hast_resource *res, s /* Prepare outgoing connection with remote node. */ if (proto_client(res->hr_remoteaddr, &out) < 0) { - primary_exit(EX_TEMPFAIL, "Unable to create connection to %s", + primary_exit(EX_TEMPFAIL, + "Unable to create outgoing connection to %s", res->hr_remoteaddr); } /* Try to connect, but accept failure. */ @@ -577,7 +578,8 @@ init_remote(struct hast_resource *res, s * Setup incoming connection with remote node. */ if (proto_client(res->hr_remoteaddr, &in) < 0) { - pjdlog_errno(LOG_WARNING, "Unable to create connection to %s", + primary_exit(EX_TEMPFAIL, + "Unable to create incoming connection to %s", res->hr_remoteaddr); } /* Try to connect, but accept failure. */ @@ -2034,6 +2036,7 @@ guard_thread(void *arg) PJDLOG_VERIFY(sigaddset(&mask, SIGINT) == 0); PJDLOG_VERIFY(sigaddset(&mask, SIGTERM) == 0); + timeout.tv_sec = RETRY_SLEEP; timeout.tv_nsec = 0; signo = -1; @@ -2059,7 +2062,6 @@ guard_thread(void *arg) guard_one(res, ii); lastcheck = now; } - timeout.tv_sec = RETRY_SLEEP; signo = sigtimedwait(&mask, NULL, &timeout); } /* NOTREACHED */ From owner-svn-src-stable@FreeBSD.ORG Wed Jan 12 20:44:11 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EA7371065673; Wed, 12 Jan 2011 20:44:11 +0000 (UTC) (envelope-from gnn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D73968FC0A; Wed, 12 Jan 2011 20:44: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 p0CKiBpa009882; Wed, 12 Jan 2011 20:44:11 GMT (envelope-from gnn@svn.freebsd.org) Received: (from gnn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0CKiBWt009877; Wed, 12 Jan 2011 20:44:11 GMT (envelope-from gnn@svn.freebsd.org) Message-Id: <201101122044.p0CKiBWt009877@svn.freebsd.org> From: "George V. Neville-Neil" Date: Wed, 12 Jan 2011 20:44:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217329 - in stable/8: sys/net sys/netinet tools/regression/netinet/arphold X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jan 2011 20:44:12 -0000 Author: gnn Date: Wed Jan 12 20:44:11 2011 New Revision: 217329 URL: http://svn.freebsd.org/changeset/base/217329 Log: MFC: 215207 Add a queue to hold packets while we await an ARP reply. When a fast machine first brings up some non TCP networking program it is quite possible that we will drop packets due to the fact that only one packet can be held per ARP entry. This leads to packets being missed when a program starts or restarts if the ARP data is not currently in the ARP cache. This code adds a new sysctl, net.link.ether.inet.maxhold, which defines a system wide maximum number of packets to be held in each ARP entry. Up to maxhold packets are queued until an ARP reply is received or the ARP times out. The default setting is the old value of 1 which has been part of the BSD networking code since time immemorial. Expose the time we hold an incomplete ARP entry by adding the sysctl net.link.ether.inet.wait, which defaults to 20 seconds, the value used when the new ARP code was added.. Reviewed by: bz, rpaulo Added: stable/8/tools/regression/netinet/arphold/ - copied from r215207, head/tools/regression/netinet/arphold/ Modified: stable/8/sys/net/if_llatbl.c stable/8/sys/net/if_llatbl.h stable/8/sys/netinet/if_ether.c stable/8/sys/netinet/in.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/tools/regression/netinet/ (props changed) Modified: stable/8/sys/net/if_llatbl.c ============================================================================== --- stable/8/sys/net/if_llatbl.c Wed Jan 12 20:38:55 2011 (r217328) +++ stable/8/sys/net/if_llatbl.c Wed Jan 12 20:44:11 2011 (r217329) @@ -100,18 +100,34 @@ done: * This function is called by the timer functions * such as arptimer() and nd6_llinfo_timer(), and * the caller does the locking. + * + * Returns the number of held packets, if any, that were dropped. */ -void +size_t llentry_free(struct llentry *lle) { - + size_t pkts_dropped; + struct mbuf *next; + + pkts_dropped = 0; LLE_WLOCK_ASSERT(lle); LIST_REMOVE(lle, lle_next); - if (lle->la_hold != NULL) + while ((lle->la_numheld > 0) && (lle->la_hold != NULL)) { + next = lle->la_hold->m_nextpkt; m_freem(lle->la_hold); + lle->la_hold = next; + lle->la_numheld--; + pkts_dropped++; + } + + KASSERT(lle->la_numheld == 0, + ("%s: la_numheld %d > 0, pkts_droped %ld", __func__, + lle->la_numheld, pkts_dropped)); LLE_FREE_LOCKED(lle); + + return (pkts_dropped); } /* @@ -412,6 +428,7 @@ llatbl_lle_show(struct llentry_sa *la) db_printf(" lle_tbl=%p\n", lle->lle_tbl); db_printf(" lle_head=%p\n", lle->lle_head); db_printf(" la_hold=%p\n", lle->la_hold); + db_printf(" la_numheld=%d\n", lle->la_numheld); db_printf(" la_expire=%ju\n", (uintmax_t)lle->la_expire); db_printf(" la_flags=0x%04x\n", lle->la_flags); db_printf(" la_asked=%u\n", lle->la_asked); Modified: stable/8/sys/net/if_llatbl.h ============================================================================== --- stable/8/sys/net/if_llatbl.h Wed Jan 12 20:38:55 2011 (r217328) +++ stable/8/sys/net/if_llatbl.h Wed Jan 12 20:44:11 2011 (r217329) @@ -58,6 +58,7 @@ struct llentry { struct lltable *lle_tbl; struct llentries *lle_head; struct mbuf *la_hold; + int la_numheld; /* # of packets currently held */ time_t la_expire; uint16_t la_flags; uint16_t la_asked; @@ -184,7 +185,7 @@ void lltable_drain(int); #endif int lltable_sysctl_dumparp(int, struct sysctl_req *); -void llentry_free(struct llentry *); +size_t llentry_free(struct llentry *); int llentry_update(struct llentry **, struct lltable *, struct sockaddr_storage *, struct ifnet *); Modified: stable/8/sys/netinet/if_ether.c ============================================================================== --- stable/8/sys/netinet/if_ether.c Wed Jan 12 20:38:55 2011 (r217328) +++ stable/8/sys/netinet/if_ether.c Wed Jan 12 20:44:11 2011 (r217329) @@ -89,13 +89,16 @@ VNET_DEFINE(int, useloopback) = 1; /* us static VNET_DEFINE(int, arp_proxyall) = 0; static VNET_DEFINE(int, arpt_down) = 20; /* keep incomplete entries for * 20 seconds */ -static VNET_DEFINE(struct arpstat, arpstat); /* ARP statistics, see if_arp.h */ +VNET_DEFINE(struct arpstat, arpstat); /* ARP statistics, see if_arp.h */ + +static VNET_DEFINE(int, arp_maxhold) = 1; #define V_arpt_keep VNET(arpt_keep) #define V_arpt_down VNET(arpt_down) #define V_arp_maxtries VNET(arp_maxtries) #define V_arp_proxyall VNET(arp_proxyall) #define V_arpstat VNET(arpstat) +#define V_arp_maxhold VNET(arp_maxhold) SYSCTL_VNET_INT(_net_link_ether_inet, OID_AUTO, max_age, CTLFLAG_RW, &VNET_NAME(arpt_keep), 0, @@ -109,9 +112,15 @@ SYSCTL_VNET_INT(_net_link_ether_inet, OI SYSCTL_VNET_INT(_net_link_ether_inet, OID_AUTO, proxyall, CTLFLAG_RW, &VNET_NAME(arp_proxyall), 0, "Enable proxy ARP for all suitable requests"); +SYSCTL_VNET_INT(_net_link_ether_inet, OID_AUTO, wait, CTLFLAG_RW, + &VNET_NAME(arpt_down), 0, + "Incomplete ARP entry lifetime in seconds"); SYSCTL_VNET_STRUCT(_net_link_ether_arp, OID_AUTO, stats, CTLFLAG_RW, &VNET_NAME(arpstat), arpstat, "ARP statistics (struct arpstat, net/if_arp.h)"); +SYSCTL_VNET_INT(_net_link_ether_inet, OID_AUTO, maxhold, CTLFLAG_RW, + &VNET_NAME(arp_maxhold), 0, + "Number of packets to hold per ARP entry"); static void arp_init(void); void arprequest(struct ifnet *, @@ -160,6 +169,7 @@ arptimer(void *arg) { struct ifnet *ifp; struct llentry *lle; + int pkts_dropped; KASSERT(arg != NULL, ("%s: arg NULL", __func__)); lle = (struct llentry *)arg; @@ -174,7 +184,8 @@ arptimer(void *arg) callout_active(&lle->la_timer)) { callout_stop(&lle->la_timer); LLE_REMREF(lle); - (void) llentry_free(lle); + pkts_dropped = llentry_free(lle); + ARPSTAT_ADD(dropped, pkts_dropped); ARPSTAT_INC(timeouts); } #ifdef DIAGNOSTIC @@ -273,6 +284,8 @@ arpresolve(struct ifnet *ifp, struct rte { struct llentry *la = 0; u_int flags = 0; + struct mbuf *curr = NULL; + struct mbuf *next = NULL; int error, renew; *lle = NULL; @@ -348,15 +361,28 @@ retry: } /* * There is an arptab entry, but no ethernet address - * response yet. Replace the held mbuf with this - * latest one. + * response yet. Add the mbuf to the list, dropping + * the oldest packet if we have exceeded the system + * setting. */ if (m != NULL) { + if (la->la_numheld >= V_arp_maxhold) { + if (la->la_hold != NULL) { + next = la->la_hold->m_nextpkt; + m_freem(la->la_hold); + la->la_hold = next; + la->la_numheld--; + ARPSTAT_INC(dropped); + } + } if (la->la_hold != NULL) { - m_freem(la->la_hold); - ARPSTAT_INC(dropped); - } - la->la_hold = m; + curr = la->la_hold; + while (curr->m_nextpkt != NULL) + curr = curr->m_nextpkt; + curr->m_nextpkt = m; + } else + la->la_hold = m; + la->la_numheld++; if (renew == 0 && (flags & LLE_EXCLUSIVE)) { flags &= ~LLE_EXCLUSIVE; LLE_DOWNGRADE(la); @@ -483,7 +509,6 @@ in_arpinput(struct mbuf *m) struct rtentry *rt; struct ifaddr *ifa; struct in_ifaddr *ia; - struct mbuf *hold; struct sockaddr sa; struct in_addr isaddr, itaddr, myaddr; u_int8_t *enaddr = NULL; @@ -696,15 +721,29 @@ match: } la->la_asked = 0; la->la_preempt = V_arp_maxtries; - hold = la->la_hold; - if (hold != NULL) { + /* + * The packets are all freed within the call to the output + * routine. + * + * NB: The lock MUST be released before the call to the + * output routine. + */ + if (la->la_hold != NULL) { + struct mbuf *m_hold, *m_hold_next; + + m_hold = la->la_hold; la->la_hold = NULL; + la->la_numheld = 0; memcpy(&sa, L3_ADDR(la), sizeof(sa)); - } - LLE_WUNLOCK(la); - if (hold != NULL) - (*ifp->if_output)(ifp, hold, &sa, NULL); - } + LLE_WUNLOCK(la); + for (; m_hold != NULL; m_hold = m_hold_next) { + m_hold_next = m_hold->m_nextpkt; + m_hold->m_nextpkt = NULL; + (*ifp->if_output)(ifp, m_hold, &sa, NULL); + } + } else + LLE_WUNLOCK(la); + } /* end of FIB loop */ reply: if (op != ARPOP_REQUEST) goto drop; Modified: stable/8/sys/netinet/in.c ============================================================================== --- stable/8/sys/netinet/in.c Wed Jan 12 20:38:55 2011 (r217328) +++ stable/8/sys/netinet/in.c Wed Jan 12 20:44:11 2011 (r217329) @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -89,6 +90,9 @@ SYSCTL_VNET_INT(_net_inet_ip, OID_AUTO, VNET_DECLARE(struct inpcbinfo, ripcbinfo); #define V_ripcbinfo VNET(ripcbinfo) +VNET_DECLARE(struct arpstat, arpstat); /* ARP statistics, see if_arp.h */ +#define V_arpstat VNET(arpstat) + /* * Return 1 if an internet address is for a ``local'' host * (one to which we have a connection). If subnetsarelocal @@ -1363,6 +1367,7 @@ in_lltable_prefix_free(struct lltable *l const struct sockaddr_in *msk = (const struct sockaddr_in *)mask; struct llentry *lle, *next; register int i; + size_t pkts_dropped; for (i=0; i < LLTBL_HASHTBL_SIZE; i++) { LIST_FOREACH_SAFE(lle, &llt->lle_head[i], lle_next, next) { @@ -1375,7 +1380,8 @@ in_lltable_prefix_free(struct lltable *l LLE_WLOCK(lle); if (canceled) LLE_REMREF(lle); - llentry_free(lle); + pkts_dropped = llentry_free(lle); + ARPSTAT_ADD(dropped, pkts_dropped); } } } From owner-svn-src-stable@FreeBSD.ORG Thu Jan 13 08:19:10 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0C1CA106564A; Thu, 13 Jan 2011 08:19:10 +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 EF47E8FC16; Thu, 13 Jan 2011 08:19:09 +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 p0D8J9xC042997; Thu, 13 Jan 2011 08:19:09 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0D8J9RF042995; Thu, 13 Jan 2011 08:19:09 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201101130819.p0D8J9RF042995@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Thu, 13 Jan 2011 08:19:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217346 - stable/8/sys/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Jan 2011 08:19:10 -0000 Author: bz Date: Thu Jan 13 08:19:09 2011 New Revision: 217346 URL: http://svn.freebsd.org/changeset/base/217346 Log: MFC r215238 (originally by kib): Use 'z' modifier for size_t printing. Should have been merged with r215207 by gnn. Modified: stable/8/sys/net/if_llatbl.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/net/if_llatbl.c ============================================================================== --- stable/8/sys/net/if_llatbl.c Thu Jan 13 06:48:43 2011 (r217345) +++ stable/8/sys/net/if_llatbl.c Thu Jan 13 08:19:09 2011 (r217346) @@ -122,7 +122,7 @@ llentry_free(struct llentry *lle) } KASSERT(lle->la_numheld == 0, - ("%s: la_numheld %d > 0, pkts_droped %ld", __func__, + ("%s: la_numheld %d > 0, pkts_droped %zd", __func__, lle->la_numheld, pkts_dropped)); LLE_FREE_LOCKED(lle); From owner-svn-src-stable@FreeBSD.ORG Thu Jan 13 11:23:43 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 379B5106566B; Thu, 13 Jan 2011 11:23:43 +0000 (UTC) (envelope-from keramida@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 25F048FC0A; Thu, 13 Jan 2011 11:23: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 p0DBNh5x048686; Thu, 13 Jan 2011 11:23:43 GMT (envelope-from keramida@svn.freebsd.org) Received: (from keramida@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0DBNhqE048684; Thu, 13 Jan 2011 11:23:43 GMT (envelope-from keramida@svn.freebsd.org) Message-Id: <201101131123.p0DBNhqE048684@svn.freebsd.org> From: Giorgos Keramidas Date: Thu, 13 Jan 2011 11:23:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217347 - stable/8/tools/regression/bin/date X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Jan 2011 11:23:43 -0000 Author: keramida (doc committer) Date: Thu Jan 13 11:23:42 2011 New Revision: 217347 URL: http://svn.freebsd.org/changeset/base/217347 Log: MFC r217208 - regression/date: unset all LC_xxx vars and set LANG/LC_ALL When running with a custom locale setup, it's easy to confuse the date regression tests and cause them to fail, e.g. when LANG='C' but LC_ALL='el_GR.UTF-8'. Set LC_ALL to 'C', which overrides all other LC_xxx options, to avoid this sort of problem. Modified: stable/8/tools/regression/bin/date/regress.sh Directory Properties: stable/8/tools/regression/bin/date/ (props changed) Modified: stable/8/tools/regression/bin/date/regress.sh ============================================================================== --- stable/8/tools/regression/bin/date/regress.sh Thu Jan 13 08:19:09 2011 (r217346) +++ stable/8/tools/regression/bin/date/regress.sh Thu Jan 13 11:23:42 2011 (r217347) @@ -19,7 +19,7 @@ TEST1=3222243 # 1970-02-07 07:04:03 TEST2=1005600000 # 2001-11-12 21:11:12 -export LANG=C +export LC_ALL=C export TZ=UTC count=0 From owner-svn-src-stable@FreeBSD.ORG Thu Jan 13 12:26:39 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BD1E9106566B; Thu, 13 Jan 2011 12:26:39 +0000 (UTC) (envelope-from keramida@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AB83B8FC12; Thu, 13 Jan 2011 12:26: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 p0DCQdvj050280; Thu, 13 Jan 2011 12:26:39 GMT (envelope-from keramida@svn.freebsd.org) Received: (from keramida@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0DCQd9M050278; Thu, 13 Jan 2011 12:26:39 GMT (envelope-from keramida@svn.freebsd.org) Message-Id: <201101131226.p0DCQd9M050278@svn.freebsd.org> From: Giorgos Keramidas Date: Thu, 13 Jan 2011 12:26:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217348 - stable/7/tools/regression/bin/date X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Jan 2011 12:26:39 -0000 Author: keramida (doc committer) Date: Thu Jan 13 12:26:39 2011 New Revision: 217348 URL: http://svn.freebsd.org/changeset/base/217348 Log: MFC r217208 - regression/date: unset all LC_xxx vars and set LANG/LC_ALL When running with a custom locale setup, it's easy to confuse the date regression tests and cause them to fail, e.g. when LANG='C' but LC_ALL='el_GR.UTF-8'. Set LC_ALL to 'C', which overrides all other LC_xxx options, to avoid this sort of problem. Modified: stable/7/tools/regression/bin/date/regress.sh Directory Properties: stable/7/tools/regression/bin/date/ (props changed) Modified: stable/7/tools/regression/bin/date/regress.sh ============================================================================== --- stable/7/tools/regression/bin/date/regress.sh Thu Jan 13 11:23:42 2011 (r217347) +++ stable/7/tools/regression/bin/date/regress.sh Thu Jan 13 12:26:39 2011 (r217348) @@ -19,7 +19,7 @@ TEST1=3222243 # 1970-02-07 07:04:03 TEST2=1005600000 # 2001-11-12 21:11:12 -export LANG=C +export LC_ALL=C export TZ=UTC count=0 From owner-svn-src-stable@FreeBSD.ORG Fri Jan 14 00:57:14 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 49DAA106566B; Fri, 14 Jan 2011 00:57:14 +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 000618FC19; Fri, 14 Jan 2011 00:57: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 p0E0vDEK069482; Fri, 14 Jan 2011 00:57:13 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0E0vDBt069479; Fri, 14 Jan 2011 00:57:13 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <201101140057.p0E0vDBt069479@svn.freebsd.org> From: Lawrence Stewart Date: Fri, 14 Jan 2011 00:57:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217386 - stable/8/share/man/man9 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 00:57:14 -0000 Author: lstewart Date: Fri Jan 14 00:57:13 2011 New Revision: 217386 URL: http://svn.freebsd.org/changeset/base/217386 Log: MFC r216995,217043: Add a man page for the Object Specific Data (OSD) KPI. Although not directly related the FreeBSD Foundation funded "Five New TCP Congestion Control Algorithms for FreeBSD" project, the understanding and inspiration required to write this documentation was significantly bolstered by the Foundation's support. Reviewed by: pjd Added: stable/8/share/man/man9/osd.9 - copied, changed from r216995, head/share/man/man9/osd.9 Modified: stable/8/share/man/man9/Makefile Directory Properties: stable/8/share/man/ (props changed) stable/8/share/man/man1/ (props changed) stable/8/share/man/man3/ (props changed) stable/8/share/man/man4/ (props changed) stable/8/share/man/man5/ (props changed) stable/8/share/man/man7/ (props changed) stable/8/share/man/man8/ (props changed) stable/8/share/man/man9/ (props changed) Modified: stable/8/share/man/man9/Makefile ============================================================================== --- stable/8/share/man/man9/Makefile Thu Jan 13 23:15:09 2011 (r217385) +++ stable/8/share/man/man9/Makefile Fri Jan 14 00:57:13 2011 (r217386) @@ -173,6 +173,7 @@ MAN= accept_filter.9 \ mutex.9 \ namei.9 \ netisr.9 \ + osd.9 \ panic.9 \ pbuf.9 \ p_candebug.9 \ Copied and modified: stable/8/share/man/man9/osd.9 (from r216995, head/share/man/man9/osd.9) ============================================================================== --- head/share/man/man9/osd.9 Wed Jan 5 11:49:23 2011 (r216995, copy source) +++ stable/8/share/man/man9/osd.9 Fri Jan 14 00:57:13 2011 (r217386) @@ -34,7 +34,7 @@ .Nm osd_deregister , .Nm osd_set , .Nm osd_get , -.Nm osd_del, +.Nm osd_del , .Nm osd_call , .Nm osd_exit .Nd Object Specific Data From owner-svn-src-stable@FreeBSD.ORG Fri Jan 14 01:07:40 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 536F0106566C; Fri, 14 Jan 2011 01:07:40 +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 2704B8FC19; Fri, 14 Jan 2011 01:07: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 p0E17e1F069820; Fri, 14 Jan 2011 01:07:40 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0E17eNq069817; Fri, 14 Jan 2011 01:07:40 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <201101140107.p0E17eNq069817@svn.freebsd.org> From: Lawrence Stewart Date: Fri, 14 Jan 2011 01:07:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217387 - stable/7/share/man/man9 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 01:07:40 -0000 Author: lstewart Date: Fri Jan 14 01:07:39 2011 New Revision: 217387 URL: http://svn.freebsd.org/changeset/base/217387 Log: MFC r216995,217043: Add a man page for the Object Specific Data (OSD) KPI. Although not directly related the FreeBSD Foundation funded "Five New TCP Congestion Control Algorithms for FreeBSD" project, the understanding and inspiration required to write this documentation was significantly bolstered by the Foundation's support. Reviewed by: pjd Added: stable/7/share/man/man9/osd.9 - copied, changed from r216995, head/share/man/man9/osd.9 Modified: stable/7/share/man/man9/Makefile Directory Properties: stable/7/share/man/ (props changed) stable/7/share/man/man1/ (props changed) stable/7/share/man/man3/ (props changed) stable/7/share/man/man4/ (props changed) stable/7/share/man/man5/ (props changed) stable/7/share/man/man7/ (props changed) stable/7/share/man/man8/ (props changed) stable/7/share/man/man9/ (props changed) Modified: stable/7/share/man/man9/Makefile ============================================================================== --- stable/7/share/man/man9/Makefile Fri Jan 14 00:57:13 2011 (r217386) +++ stable/7/share/man/man9/Makefile Fri Jan 14 01:07:39 2011 (r217387) @@ -157,6 +157,7 @@ MAN= accept_filter.9 \ mtx_pool.9 \ mutex.9 \ namei.9 \ + osd.9 \ panic.9 \ pbuf.9 \ p_candebug.9 \ Copied and modified: stable/7/share/man/man9/osd.9 (from r216995, head/share/man/man9/osd.9) ============================================================================== --- head/share/man/man9/osd.9 Wed Jan 5 11:49:23 2011 (r216995, copy source) +++ stable/7/share/man/man9/osd.9 Fri Jan 14 01:07:39 2011 (r217387) @@ -34,7 +34,7 @@ .Nm osd_deregister , .Nm osd_set , .Nm osd_get , -.Nm osd_del, +.Nm osd_del , .Nm osd_call , .Nm osd_exit .Nd Object Specific Data @@ -378,7 +378,7 @@ terminates prematurely and returns the m .Sh HISTORY The Object Specific Data (OSD) facility first appeared in -.Fx 8.0 . +.Fx 7.3 . .Sh AUTHORS .An -nosplit The From owner-svn-src-stable@FreeBSD.ORG Fri Jan 14 11:12:56 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C296A106566C; Fri, 14 Jan 2011 11:12:56 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B17B88FC1A; Fri, 14 Jan 2011 11:12: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 p0EBCuVW085863; Fri, 14 Jan 2011 11:12:56 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0EBCuGl085861; Fri, 14 Jan 2011 11:12:56 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201101141112.p0EBCuGl085861@svn.freebsd.org> From: Jaakko Heinonen Date: Fri, 14 Jan 2011 11:12:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217392 - stable/8/sys/geom X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 11:12:56 -0000 Author: jh Date: Fri Jan 14 11:12:56 2011 New Revision: 217392 URL: http://svn.freebsd.org/changeset/base/217392 Log: MFC r214748: Extend the g_eventlock mutex coverage in one_event() to include setting of the EV_DONE flag and use the mutex to protect against losing wakeups in g_waitfor_event(). Modified: stable/8/sys/geom/geom_event.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/geom/geom_event.c ============================================================================== --- stable/8/sys/geom/geom_event.c Fri Jan 14 10:56:44 2011 (r217391) +++ stable/8/sys/geom/geom_event.c Fri Jan 14 11:12:56 2011 (r217392) @@ -212,11 +212,12 @@ one_event(void) g_topology_assert(); mtx_lock(&g_eventlock); TAILQ_REMOVE(&g_events, ep, events); - mtx_unlock(&g_eventlock); if (ep->flag & EV_WAKEUP) { ep->flag |= EV_DONE; + mtx_unlock(&g_eventlock); wakeup(ep); } else { + mtx_unlock(&g_eventlock); g_free(ep); } g_topology_unlock(); @@ -355,11 +356,14 @@ g_waitfor_event(g_event_t *func, void *a va_end(ap); if (error) return (error); - do - tsleep(ep, PRIBIO, "g_waitfor_event", hz); - while (!(ep->flag & EV_DONE)); + + mtx_lock(&g_eventlock); + while (!(ep->flag & EV_DONE)) + msleep(ep, &g_eventlock, PRIBIO, "g_waitfor_event", hz); if (ep->flag & EV_CANCELED) error = EAGAIN; + mtx_unlock(&g_eventlock); + g_free(ep); return (error); } From owner-svn-src-stable@FreeBSD.ORG Fri Jan 14 13:34:56 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6B11A1065672; Fri, 14 Jan 2011 13:34:56 +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 5A1248FC18; Fri, 14 Jan 2011 13:34: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 p0EDYu5V089469; Fri, 14 Jan 2011 13:34:56 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0EDYuPx089467; Fri, 14 Jan 2011 13:34:56 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201101141334.p0EDYuPx089467@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Fri, 14 Jan 2011 13:34:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217401 - stable/8/share/man/man4 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 13:34:56 -0000 Author: bz Date: Fri Jan 14 13:34:56 2011 New Revision: 217401 URL: http://svn.freebsd.org/changeset/base/217401 Log: MFC r217135: Clarify when we switch from keepidle to keepinvtl intervals if sending TCP keepalive probes is enabled. Modified: stable/8/share/man/man4/tcp.4 Directory Properties: stable/8/share/man/man4/ (props changed) Modified: stable/8/share/man/man4/tcp.4 ============================================================================== --- stable/8/share/man/man4/tcp.4 Fri Jan 14 11:36:44 2011 (r217400) +++ stable/8/share/man/man4/tcp.4 Fri Jan 14 13:34:56 2011 (r217401) @@ -32,7 +32,7 @@ .\" From: @(#)tcp.4 8.1 (Berkeley) 6/5/93 .\" $FreeBSD$ .\" -.Dd August 16, 2008 +.Dd January 8, 2011 .Dt TCP 4 .Os .Sh NAME @@ -289,7 +289,9 @@ Amount of time, in milliseconds, that th before keepalive probes (if enabled) are sent. .It Va keepintvl The interval, in milliseconds, between keepalive probes sent to remote -machines. +machines, when no response is received on a +.Va keepidle +probe. After .Dv TCPTV_KEEPCNT (default 8) probes are sent, with no response, the connection is dropped. From owner-svn-src-stable@FreeBSD.ORG Fri Jan 14 13:35:55 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6AE4E1065697; Fri, 14 Jan 2011 13:35:55 +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 59D4D8FC0C; Fri, 14 Jan 2011 13:35: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 p0EDZtXK089540; Fri, 14 Jan 2011 13:35:55 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0EDZtJ6089538; Fri, 14 Jan 2011 13:35:55 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201101141335.p0EDZtJ6089538@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Fri, 14 Jan 2011 13:35:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217402 - stable/7/share/man/man4 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 13:35:55 -0000 Author: bz Date: Fri Jan 14 13:35:55 2011 New Revision: 217402 URL: http://svn.freebsd.org/changeset/base/217402 Log: MFC r217135: Clarify when we switch from keepidle to keepinvtl intervals if sending TCP keepalive probes is enabled. Modified: stable/7/share/man/man4/tcp.4 Directory Properties: stable/7/share/man/man4/ (props changed) Modified: stable/7/share/man/man4/tcp.4 ============================================================================== --- stable/7/share/man/man4/tcp.4 Fri Jan 14 13:34:56 2011 (r217401) +++ stable/7/share/man/man4/tcp.4 Fri Jan 14 13:35:55 2011 (r217402) @@ -32,7 +32,7 @@ .\" From: @(#)tcp.4 8.1 (Berkeley) 6/5/93 .\" $FreeBSD$ .\" -.Dd February 28, 2007 +.Dd January 8, 2011 .Dt TCP 4 .Os .Sh NAME @@ -289,7 +289,9 @@ Amount of time, in milliseconds, that th before keepalive probes (if enabled) are sent. .It Va keepintvl The interval, in milliseconds, between keepalive probes sent to remote -machines. +machines, when no response is received on a +.Va keepidle +probe. After .Dv TCPTV_KEEPCNT (default 8) probes are sent, with no response, the connection is dropped. From owner-svn-src-stable@FreeBSD.ORG Fri Jan 14 14:20:55 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1F02D106566C; Fri, 14 Jan 2011 14:20:55 +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 0DF148FC13; Fri, 14 Jan 2011 14:20: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 p0EEKsOr090573; Fri, 14 Jan 2011 14:20:54 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0EEKsRv090571; Fri, 14 Jan 2011 14:20:54 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201101141420.p0EEKsRv090571@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Fri, 14 Jan 2011 14:20:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217403 - stable/8/sys/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 14:20:55 -0000 Author: bz Date: Fri Jan 14 14:20:54 2011 New Revision: 217403 URL: http://svn.freebsd.org/changeset/base/217403 Log: MFC r217203: MfP4 CH=185246 [1]: Add FEATURE() to announce optional VIMAGE. [1] for the moment put it in vnet.c. Modified: stable/8/sys/net/vnet.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/net/vnet.c ============================================================================== --- stable/8/sys/net/vnet.c Fri Jan 14 13:35:55 2011 (r217402) +++ stable/8/sys/net/vnet.c Fri Jan 14 14:20:54 2011 (r217403) @@ -80,6 +80,8 @@ __FBSDID("$FreeBSD$"); * stack instance. */ +FEATURE(vimage, "VIMAGE kernel virtualization"); + MALLOC_DEFINE(M_VNET, "vnet", "network stack control block"); /* From owner-svn-src-stable@FreeBSD.ORG Fri Jan 14 16:30:23 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3ED97106566C; Fri, 14 Jan 2011 16:30:23 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2D1788FC0C; Fri, 14 Jan 2011 16:30: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 p0EGUNmh093826; Fri, 14 Jan 2011 16:30:23 GMT (envelope-from cperciva@svn.freebsd.org) Received: (from cperciva@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0EGUNjn093824; Fri, 14 Jan 2011 16:30:23 GMT (envelope-from cperciva@svn.freebsd.org) Message-Id: <201101141630.p0EGUNjn093824@svn.freebsd.org> From: Colin Percival Date: Fri, 14 Jan 2011 16:30:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217408 - stable/8/sys/i386/i386 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 16:30:23 -0000 Author: cperciva Date: Fri Jan 14 16:30:22 2011 New Revision: 217408 URL: http://svn.freebsd.org/changeset/base/217408 Log: Don't use amdc1e on XEN && !XEN_PRIVILEGED. The Xen hypervisor gets justifiably annoyed when a guest OS tries to halt the CPU. This fixes a panic when booting FreeBSD/XEN on recent AMD CPUs. This is not an MFC; the problem was (accidentally?) fixed in HEAD four months ago via SVN r212541. Modified: stable/8/sys/i386/i386/machdep.c Modified: stable/8/sys/i386/i386/machdep.c ============================================================================== --- stable/8/sys/i386/i386/machdep.c Fri Jan 14 15:15:33 2011 (r217407) +++ stable/8/sys/i386/i386/machdep.c Fri Jan 14 16:30:22 2011 (r217408) @@ -1228,6 +1228,7 @@ cpu_idle_acpi(int busy) static int cpu_ident_amdc1e = 0; +#if !defined(XEN) || defined(XEN_PRIVILEGED) static int cpu_probe_amdc1e(void) { @@ -1254,6 +1255,7 @@ cpu_probe_amdc1e(void) #endif return (0); } +#endif /* * C1E renders the local APIC timer dead, so we disable it by @@ -2690,8 +2692,10 @@ init386(first) thread0.td_pcb->pcb_fsd = PCPU_GET(fsgs_gdt)[0]; thread0.td_pcb->pcb_gsd = PCPU_GET(fsgs_gdt)[1]; +#if defined(XEN_PRIVILEGED) if (cpu_probe_amdc1e()) cpu_idle_fn = cpu_idle_amdc1e; +#endif } #else From owner-svn-src-stable@FreeBSD.ORG Fri Jan 14 20:28:12 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 86E6F106566B; Fri, 14 Jan 2011 20:28:12 +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 3DA648FC0A; Fri, 14 Jan 2011 20:28: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 p0EKSC3W099785; Fri, 14 Jan 2011 20:28:12 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0EKSCHX099783; Fri, 14 Jan 2011 20:28:12 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201101142028.p0EKSCHX099783@svn.freebsd.org> From: Marius Strobl Date: Fri, 14 Jan 2011 20:28:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217418 - stable/8/sys/dev/mpt X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 20:28:12 -0000 Author: marius Date: Fri Jan 14 20:28:11 2011 New Revision: 217418 URL: http://svn.freebsd.org/changeset/base/217418 Log: MFC: r217009 Remove a redundant variable assignment found with the clang static analyzer. Modified: stable/8/sys/dev/mpt/mpt_cam.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/8/sys/dev/mpt/mpt_cam.c Fri Jan 14 20:26:59 2011 (r217417) +++ stable/8/sys/dev/mpt/mpt_cam.c Fri Jan 14 20:28:11 2011 (r217418) @@ -2971,7 +2971,7 @@ mpt_fc_els_reply_handler(struct mpt_soft } if (tgt_req) { mpt_tgt_state_t *tgt = MPT_TGT_STATE(mpt, tgt_req); - union ccb *ccb = tgt->ccb; + union ccb *ccb; uint32_t ct_id; /* From owner-svn-src-stable@FreeBSD.ORG Fri Jan 14 20:28:12 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8ABA4106566C; Fri, 14 Jan 2011 20:28:12 +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 517978FC0C; Fri, 14 Jan 2011 20:28: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 p0EKSCeG099789; Fri, 14 Jan 2011 20:28:12 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0EKSCN2099787; Fri, 14 Jan 2011 20:28:12 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201101142028.p0EKSCN2099787@svn.freebsd.org> From: Marius Strobl Date: Fri, 14 Jan 2011 20:28:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217419 - stable/7/sys/dev/mpt X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 20:28:12 -0000 Author: marius Date: Fri Jan 14 20:28:12 2011 New Revision: 217419 URL: http://svn.freebsd.org/changeset/base/217419 Log: MFC: r217009 Remove a redundant variable assignment found with the clang static analyzer. Modified: stable/7/sys/dev/mpt/mpt_cam.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/7/sys/dev/mpt/mpt_cam.c Fri Jan 14 20:28:11 2011 (r217418) +++ stable/7/sys/dev/mpt/mpt_cam.c Fri Jan 14 20:28:12 2011 (r217419) @@ -2965,7 +2965,7 @@ mpt_fc_els_reply_handler(struct mpt_soft } if (tgt_req) { mpt_tgt_state_t *tgt = MPT_TGT_STATE(mpt, tgt_req); - union ccb *ccb = tgt->ccb; + union ccb *ccb; uint32_t ct_id; /* From owner-svn-src-stable@FreeBSD.ORG Fri Jan 14 20:30:18 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4BFC7106566C; Fri, 14 Jan 2011 20:30:18 +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 39CBE8FC19; Fri, 14 Jan 2011 20:30: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 p0EKUIq3099948; Fri, 14 Jan 2011 20:30:18 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0EKUIOe099946; Fri, 14 Jan 2011 20:30:18 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201101142030.p0EKUIOe099946@svn.freebsd.org> From: Marius Strobl Date: Fri, 14 Jan 2011 20:30:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217420 - stable/7/sys/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 20:30:18 -0000 Author: marius Date: Fri Jan 14 20:30:17 2011 New Revision: 217420 URL: http://svn.freebsd.org/changeset/base/217420 Log: MFC: r217010 Fix whitespace. Modified: stable/7/sys/net/if_media.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/net/if_media.h ============================================================================== --- stable/7/sys/net/if_media.h Fri Jan 14 20:28:12 2011 (r217419) +++ stable/7/sys/net/if_media.h Fri Jan 14 20:30:17 2011 (r217420) @@ -36,7 +36,7 @@ */ #ifndef _NET_IF_MEDIA_H_ -#define _NET_IF_MEDIA_H_ +#define _NET_IF_MEDIA_H_ /* * Prototypes and definitions for BSD/OS-compatible network interface @@ -144,13 +144,12 @@ uint64_t ifmedia_baudrate(int); #define IFM_10G_LR 18 /* 10GBase-LR 1310nm Single-mode */ #define IFM_10G_SR 19 /* 10GBase-SR 850nm Multi-mode */ #define IFM_10G_CX4 20 /* 10GBase CX4 copper */ -#define IFM_2500_SX 21 /* 2500BaseSX - multi-mode fiber */ -#define IFM_10G_TWINAX 22 /* 10GBase Twinax copper */ -#define IFM_10G_TWINAX_LONG 23 /* 10GBase Twinax Long copper */ -#define IFM_10G_LRM 24 /* 10GBase-LRM 850nm Multi-mode */ -#define IFM_UNKNOWN 25 /* media types not defined yet */ -#define IFM_10G_T 26 /* 10GBase-T - RJ45 */ - +#define IFM_2500_SX 21 /* 2500BaseSX - multi-mode fiber */ +#define IFM_10G_TWINAX 22 /* 10GBase Twinax copper */ +#define IFM_10G_TWINAX_LONG 23 /* 10GBase Twinax Long copper */ +#define IFM_10G_LRM 24 /* 10GBase-LRM 850nm Multi-mode */ +#define IFM_UNKNOWN 25 /* media types not defined yet */ +#define IFM_10G_T 26 /* 10GBase-T - RJ45 */ /* note 31 is the max! */ @@ -231,20 +230,20 @@ uint64_t ifmedia_baudrate(int); /* * ATM */ -#define IFM_ATM 0x000000a0 -#define IFM_ATM_UNKNOWN 3 -#define IFM_ATM_UTP_25 4 -#define IFM_ATM_TAXI_100 5 -#define IFM_ATM_TAXI_140 6 -#define IFM_ATM_MM_155 7 -#define IFM_ATM_SM_155 8 -#define IFM_ATM_UTP_155 9 -#define IFM_ATM_MM_622 10 -#define IFM_ATM_SM_622 11 +#define IFM_ATM 0x000000a0 +#define IFM_ATM_UNKNOWN 3 +#define IFM_ATM_UTP_25 4 +#define IFM_ATM_TAXI_100 5 +#define IFM_ATM_TAXI_140 6 +#define IFM_ATM_MM_155 7 +#define IFM_ATM_SM_155 8 +#define IFM_ATM_UTP_155 9 +#define IFM_ATM_MM_622 10 +#define IFM_ATM_SM_622 11 #define IFM_ATM_VIRTUAL 12 -#define IFM_ATM_SDH 0x00000100 /* SDH instead of SONET */ -#define IFM_ATM_NOSCRAMB 0x00000200 /* no scrambling */ -#define IFM_ATM_UNASSIGNED 0x00000400 /* unassigned cells */ +#define IFM_ATM_SDH 0x00000100 /* SDH instead of SONET */ +#define IFM_ATM_NOSCRAMB 0x00000200 /* no scrambling */ +#define IFM_ATM_UNASSIGNED 0x00000400 /* unassigned cells */ /* * CARP Common Address Redundancy Protocol @@ -294,22 +293,22 @@ uint64_t ifmedia_baudrate(int); #define IFM_STATUS_VALID IFM_AVALID /* List of "status valid" bits, for ifconfig(8). */ -#define IFM_STATUS_VALID_LIST { \ - IFM_AVALID, \ - 0 \ +#define IFM_STATUS_VALID_LIST { \ + IFM_AVALID, \ + 0 \ } /* * Macros to extract various bits of information from the media word. */ -#define IFM_TYPE(x) ((x) & IFM_NMASK) -#define IFM_SUBTYPE(x) ((x) & IFM_TMASK) -#define IFM_TYPE_OPTIONS(x) ((x) & IFM_OMASK) -#define IFM_INST(x) (((x) & IFM_IMASK) >> IFM_ISHIFT) -#define IFM_OPTIONS(x) ((x) & (IFM_OMASK|IFM_GMASK)) -#define IFM_MODE(x) ((x) & IFM_MMASK) +#define IFM_TYPE(x) ((x) & IFM_NMASK) +#define IFM_SUBTYPE(x) ((x) & IFM_TMASK) +#define IFM_TYPE_OPTIONS(x) ((x) & IFM_OMASK) +#define IFM_INST(x) (((x) & IFM_IMASK) >> IFM_ISHIFT) +#define IFM_OPTIONS(x) ((x) & (IFM_OMASK | IFM_GMASK)) +#define IFM_MODE(x) ((x) & IFM_MMASK) -#define IFM_INST_MAX IFM_INST(IFM_IMASK) +#define IFM_INST_MAX IFM_INST(IFM_IMASK) /* * Macro to create a media word. @@ -537,7 +536,7 @@ struct ifmedia_description { { 0, NULL }, \ } -# define IFM_SUBTYPE_ATM_DESCRIPTIONS { \ +#define IFM_SUBTYPE_ATM_DESCRIPTIONS { \ { IFM_ATM_UNKNOWN, "Unknown" }, \ { IFM_ATM_UTP_25, "UTP/25.6MBit" }, \ { IFM_ATM_TAXI_100, "Taxi/100MBit" }, \ @@ -551,7 +550,7 @@ struct ifmedia_description { { 0, NULL }, \ } -# define IFM_SUBTYPE_ATM_ALIASES { \ +#define IFM_SUBTYPE_ATM_ALIASES { \ { IFM_ATM_UNKNOWN, "UNKNOWN" }, \ { IFM_ATM_UTP_25, "UTP-25" }, \ { IFM_ATM_TAXI_100, "TAXI-100" }, \ @@ -572,7 +571,6 @@ struct ifmedia_description { { 0, NULL }, \ } - #define IFM_SUBTYPE_SHARED_DESCRIPTIONS { \ { IFM_AUTO, "autoselect" }, \ { IFM_MANUAL, "manual" }, \ @@ -604,7 +602,7 @@ struct ifmedia_baudrate { uint64_t ifmb_baudrate; /* corresponding baudrate */ }; -#define IFM_BAUDRATE_DESCRIPTIONS { \ +#define IFM_BAUDRATE_DESCRIPTIONS { \ { IFM_ETHER | IFM_10_T, IF_Mbps(10) }, \ { IFM_ETHER | IFM_10_2, IF_Mbps(10) }, \ { IFM_ETHER | IFM_10_5, IF_Mbps(10) }, \ @@ -668,10 +666,10 @@ struct ifmedia_status_description { const char *ifms_string[2]; }; -#define IFM_STATUS_DESC(ifms, bit) \ +#define IFM_STATUS_DESC(ifms, bit) \ (ifms)->ifms_string[((ifms)->ifms_bit & (bit)) ? 1 : 0] -#define IFM_STATUS_DESCRIPTIONS { \ +#define IFM_STATUS_DESCRIPTIONS { \ { IFM_ETHER, IFM_AVALID, IFM_ACTIVE, \ { "no carrier", "active" } }, \ { IFM_FDDI, IFM_AVALID, IFM_ACTIVE, \ From owner-svn-src-stable@FreeBSD.ORG Fri Jan 14 20:30:18 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5CDE61065673; Fri, 14 Jan 2011 20:30:18 +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 4B15C8FC1A; Fri, 14 Jan 2011 20:30: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 p0EKUIXv099952; Fri, 14 Jan 2011 20:30:18 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0EKUIPt099950; Fri, 14 Jan 2011 20:30:18 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201101142030.p0EKUIPt099950@svn.freebsd.org> From: Marius Strobl Date: Fri, 14 Jan 2011 20:30:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217421 - stable/8/sys/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 20:30:18 -0000 Author: marius Date: Fri Jan 14 20:30:17 2011 New Revision: 217421 URL: http://svn.freebsd.org/changeset/base/217421 Log: MFC: r217010 Fix whitespace. Modified: stable/8/sys/net/if_media.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/net/if_media.h ============================================================================== --- stable/8/sys/net/if_media.h Fri Jan 14 20:30:17 2011 (r217420) +++ stable/8/sys/net/if_media.h Fri Jan 14 20:30:17 2011 (r217421) @@ -36,7 +36,7 @@ */ #ifndef _NET_IF_MEDIA_H_ -#define _NET_IF_MEDIA_H_ +#define _NET_IF_MEDIA_H_ /* * Prototypes and definitions for BSD/OS-compatible network interface @@ -144,13 +144,12 @@ uint64_t ifmedia_baudrate(int); #define IFM_10G_LR 18 /* 10GBase-LR 1310nm Single-mode */ #define IFM_10G_SR 19 /* 10GBase-SR 850nm Multi-mode */ #define IFM_10G_CX4 20 /* 10GBase CX4 copper */ -#define IFM_2500_SX 21 /* 2500BaseSX - multi-mode fiber */ -#define IFM_10G_TWINAX 22 /* 10GBase Twinax copper */ -#define IFM_10G_TWINAX_LONG 23 /* 10GBase Twinax Long copper */ -#define IFM_10G_LRM 24 /* 10GBase-LRM 850nm Multi-mode */ -#define IFM_UNKNOWN 25 /* media types not defined yet */ -#define IFM_10G_T 26 /* 10GBase-T - RJ45 */ - +#define IFM_2500_SX 21 /* 2500BaseSX - multi-mode fiber */ +#define IFM_10G_TWINAX 22 /* 10GBase Twinax copper */ +#define IFM_10G_TWINAX_LONG 23 /* 10GBase Twinax Long copper */ +#define IFM_10G_LRM 24 /* 10GBase-LRM 850nm Multi-mode */ +#define IFM_UNKNOWN 25 /* media types not defined yet */ +#define IFM_10G_T 26 /* 10GBase-T - RJ45 */ /* note 31 is the max! */ @@ -232,20 +231,20 @@ uint64_t ifmedia_baudrate(int); /* * ATM */ -#define IFM_ATM 0x000000a0 -#define IFM_ATM_UNKNOWN 3 -#define IFM_ATM_UTP_25 4 -#define IFM_ATM_TAXI_100 5 -#define IFM_ATM_TAXI_140 6 -#define IFM_ATM_MM_155 7 -#define IFM_ATM_SM_155 8 -#define IFM_ATM_UTP_155 9 -#define IFM_ATM_MM_622 10 -#define IFM_ATM_SM_622 11 +#define IFM_ATM 0x000000a0 +#define IFM_ATM_UNKNOWN 3 +#define IFM_ATM_UTP_25 4 +#define IFM_ATM_TAXI_100 5 +#define IFM_ATM_TAXI_140 6 +#define IFM_ATM_MM_155 7 +#define IFM_ATM_SM_155 8 +#define IFM_ATM_UTP_155 9 +#define IFM_ATM_MM_622 10 +#define IFM_ATM_SM_622 11 #define IFM_ATM_VIRTUAL 12 -#define IFM_ATM_SDH 0x00000100 /* SDH instead of SONET */ -#define IFM_ATM_NOSCRAMB 0x00000200 /* no scrambling */ -#define IFM_ATM_UNASSIGNED 0x00000400 /* unassigned cells */ +#define IFM_ATM_SDH 0x00000100 /* SDH instead of SONET */ +#define IFM_ATM_NOSCRAMB 0x00000200 /* no scrambling */ +#define IFM_ATM_UNASSIGNED 0x00000400 /* unassigned cells */ /* * CARP Common Address Redundancy Protocol @@ -295,22 +294,22 @@ uint64_t ifmedia_baudrate(int); #define IFM_STATUS_VALID IFM_AVALID /* List of "status valid" bits, for ifconfig(8). */ -#define IFM_STATUS_VALID_LIST { \ - IFM_AVALID, \ - 0 \ +#define IFM_STATUS_VALID_LIST { \ + IFM_AVALID, \ + 0 \ } /* * Macros to extract various bits of information from the media word. */ -#define IFM_TYPE(x) ((x) & IFM_NMASK) -#define IFM_SUBTYPE(x) ((x) & IFM_TMASK) -#define IFM_TYPE_OPTIONS(x) ((x) & IFM_OMASK) -#define IFM_INST(x) (((x) & IFM_IMASK) >> IFM_ISHIFT) -#define IFM_OPTIONS(x) ((x) & (IFM_OMASK|IFM_GMASK)) -#define IFM_MODE(x) ((x) & IFM_MMASK) +#define IFM_TYPE(x) ((x) & IFM_NMASK) +#define IFM_SUBTYPE(x) ((x) & IFM_TMASK) +#define IFM_TYPE_OPTIONS(x) ((x) & IFM_OMASK) +#define IFM_INST(x) (((x) & IFM_IMASK) >> IFM_ISHIFT) +#define IFM_OPTIONS(x) ((x) & (IFM_OMASK | IFM_GMASK)) +#define IFM_MODE(x) ((x) & IFM_MMASK) -#define IFM_INST_MAX IFM_INST(IFM_IMASK) +#define IFM_INST_MAX IFM_INST(IFM_IMASK) /* * Macro to create a media word. @@ -539,7 +538,7 @@ struct ifmedia_description { { 0, NULL }, \ } -# define IFM_SUBTYPE_ATM_DESCRIPTIONS { \ +#define IFM_SUBTYPE_ATM_DESCRIPTIONS { \ { IFM_ATM_UNKNOWN, "Unknown" }, \ { IFM_ATM_UTP_25, "UTP/25.6MBit" }, \ { IFM_ATM_TAXI_100, "Taxi/100MBit" }, \ @@ -553,7 +552,7 @@ struct ifmedia_description { { 0, NULL }, \ } -# define IFM_SUBTYPE_ATM_ALIASES { \ +#define IFM_SUBTYPE_ATM_ALIASES { \ { IFM_ATM_UNKNOWN, "UNKNOWN" }, \ { IFM_ATM_UTP_25, "UTP-25" }, \ { IFM_ATM_TAXI_100, "TAXI-100" }, \ @@ -574,7 +573,6 @@ struct ifmedia_description { { 0, NULL }, \ } - #define IFM_SUBTYPE_SHARED_DESCRIPTIONS { \ { IFM_AUTO, "autoselect" }, \ { IFM_MANUAL, "manual" }, \ @@ -606,7 +604,7 @@ struct ifmedia_baudrate { uint64_t ifmb_baudrate; /* corresponding baudrate */ }; -#define IFM_BAUDRATE_DESCRIPTIONS { \ +#define IFM_BAUDRATE_DESCRIPTIONS { \ { IFM_ETHER | IFM_10_T, IF_Mbps(10) }, \ { IFM_ETHER | IFM_10_2, IF_Mbps(10) }, \ { IFM_ETHER | IFM_10_5, IF_Mbps(10) }, \ @@ -670,10 +668,10 @@ struct ifmedia_status_description { const char *ifms_string[2]; }; -#define IFM_STATUS_DESC(ifms, bit) \ +#define IFM_STATUS_DESC(ifms, bit) \ (ifms)->ifms_string[((ifms)->ifms_bit & (bit)) ? 1 : 0] -#define IFM_STATUS_DESCRIPTIONS { \ +#define IFM_STATUS_DESCRIPTIONS { \ { IFM_ETHER, IFM_AVALID, IFM_ACTIVE, \ { "no carrier", "active" } }, \ { IFM_FDDI, IFM_AVALID, IFM_ACTIVE, \ From owner-svn-src-stable@FreeBSD.ORG Fri Jan 14 20:43:22 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 230C7106564A; Fri, 14 Jan 2011 20:43:22 +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 10D518FC18; Fri, 14 Jan 2011 20:43: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 p0EKhLXP000415; Fri, 14 Jan 2011 20:43:21 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0EKhLrR000412; Fri, 14 Jan 2011 20:43:21 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201101142043.p0EKhLrR000412@svn.freebsd.org> From: Marius Strobl Date: Fri, 14 Jan 2011 20:43:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217422 - in stable/8: sbin/ifconfig sys/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 20:43:22 -0000 Author: marius Date: Fri Jan 14 20:43:21 2011 New Revision: 217422 URL: http://svn.freebsd.org/changeset/base/217422 Log: MFC: r217013 Teach ifconfig(8) the handy shared option shortcut aliases the NetBSD counterpart also takes, i.e. "fdx" for "full-duplex", "flow" for "flowcontrol", "hdx" for "half-duplex" as well as "loop" and "loopback" for "hw-loopback". Modified: stable/8/sbin/ifconfig/ifmedia.c stable/8/sys/net/if_media.h Directory Properties: stable/8/sbin/ifconfig/ (props changed) stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sbin/ifconfig/ifmedia.c ============================================================================== --- stable/8/sbin/ifconfig/ifmedia.c Fri Jan 14 20:30:17 2011 (r217421) +++ stable/8/sbin/ifconfig/ifmedia.c Fri Jan 14 20:43:21 2011 (r217422) @@ -425,6 +425,9 @@ static struct ifmedia_description ifm_su static struct ifmedia_description ifm_shared_option_descriptions[] = IFM_SHARED_OPTION_DESCRIPTIONS; +static struct ifmedia_description ifm_shared_option_aliases[] = + IFM_SHARED_OPTION_ALIASES; + struct ifmedia_type_to_subtype { struct { struct ifmedia_description *desc; @@ -433,7 +436,7 @@ struct ifmedia_type_to_subtype { struct { struct ifmedia_description *desc; int alias; - } options[3]; + } options[4]; struct { struct ifmedia_description *desc; int alias; @@ -452,6 +455,7 @@ static struct ifmedia_type_to_subtype if }, { { &ifm_shared_option_descriptions[0], 0 }, + { &ifm_shared_option_aliases[0], 1 }, { &ifm_subtype_ethernet_option_descriptions[0], 0 }, { NULL, 0 }, }, @@ -469,6 +473,7 @@ static struct ifmedia_type_to_subtype if }, { { &ifm_shared_option_descriptions[0], 0 }, + { &ifm_shared_option_aliases[0], 1 }, { &ifm_subtype_tokenring_option_descriptions[0], 0 }, { NULL, 0 }, }, @@ -486,6 +491,7 @@ static struct ifmedia_type_to_subtype if }, { { &ifm_shared_option_descriptions[0], 0 }, + { &ifm_shared_option_aliases[0], 1 }, { &ifm_subtype_fddi_option_descriptions[0], 0 }, { NULL, 0 }, }, @@ -503,6 +509,7 @@ static struct ifmedia_type_to_subtype if }, { { &ifm_shared_option_descriptions[0], 0 }, + { &ifm_shared_option_aliases[0], 1 }, { &ifm_subtype_ieee80211_option_descriptions[0], 0 }, { NULL, 0 }, }, @@ -522,6 +529,7 @@ static struct ifmedia_type_to_subtype if }, { { &ifm_shared_option_descriptions[0], 0 }, + { &ifm_shared_option_aliases[0], 1 }, { &ifm_subtype_atm_option_descriptions[0], 0 }, { NULL, 0 }, }, Modified: stable/8/sys/net/if_media.h ============================================================================== --- stable/8/sys/net/if_media.h Fri Jan 14 20:30:17 2011 (r217421) +++ stable/8/sys/net/if_media.h Fri Jan 14 20:43:21 2011 (r217422) @@ -596,6 +596,15 @@ struct ifmedia_description { { 0, NULL }, \ } +#define IFM_SHARED_OPTION_ALIASES { \ + { IFM_FDX, "fdx" }, \ + { IFM_HDX, "hdx" }, \ + { IFM_FLOW, "flow" }, \ + { IFM_LOOP, "loop" }, \ + { IFM_LOOP, "loopback" }, \ + { 0, NULL }, \ +} + /* * Baudrate descriptions for the various media types. */ From owner-svn-src-stable@FreeBSD.ORG Fri Jan 14 20:43:25 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E32C41065694; Fri, 14 Jan 2011 20:43:24 +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 C66AD8FC08; Fri, 14 Jan 2011 20:43: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 p0EKhONZ000452; Fri, 14 Jan 2011 20:43:24 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0EKhOQb000449; Fri, 14 Jan 2011 20:43:24 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201101142043.p0EKhOQb000449@svn.freebsd.org> From: Marius Strobl Date: Fri, 14 Jan 2011 20:43:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217423 - in stable/7: sbin/ifconfig sys/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 20:43:25 -0000 Author: marius Date: Fri Jan 14 20:43:24 2011 New Revision: 217423 URL: http://svn.freebsd.org/changeset/base/217423 Log: MFC: r217013 Teach ifconfig(8) the handy shared option shortcut aliases the NetBSD counterpart also takes, i.e. "fdx" for "full-duplex", "flow" for "flowcontrol", "hdx" for "half-duplex" as well as "loop" and "loopback" for "hw-loopback". Modified: stable/7/sbin/ifconfig/ifmedia.c stable/7/sys/net/if_media.h Directory Properties: stable/7/sbin/ifconfig/ (props changed) stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sbin/ifconfig/ifmedia.c ============================================================================== --- stable/7/sbin/ifconfig/ifmedia.c Fri Jan 14 20:43:21 2011 (r217422) +++ stable/7/sbin/ifconfig/ifmedia.c Fri Jan 14 20:43:24 2011 (r217423) @@ -416,6 +416,9 @@ static struct ifmedia_description ifm_su static struct ifmedia_description ifm_shared_option_descriptions[] = IFM_SHARED_OPTION_DESCRIPTIONS; +static struct ifmedia_description ifm_shared_option_aliases[] = + IFM_SHARED_OPTION_ALIASES; + struct ifmedia_type_to_subtype { struct { struct ifmedia_description *desc; @@ -424,7 +427,7 @@ struct ifmedia_type_to_subtype { struct { struct ifmedia_description *desc; int alias; - } options[3]; + } options[4]; struct { struct ifmedia_description *desc; int alias; @@ -443,6 +446,7 @@ static struct ifmedia_type_to_subtype if }, { { &ifm_shared_option_descriptions[0], 0 }, + { &ifm_shared_option_aliases[0], 1 }, { &ifm_subtype_ethernet_option_descriptions[0], 0 }, { NULL, 0 }, }, @@ -460,6 +464,7 @@ static struct ifmedia_type_to_subtype if }, { { &ifm_shared_option_descriptions[0], 0 }, + { &ifm_shared_option_aliases[0], 1 }, { &ifm_subtype_tokenring_option_descriptions[0], 0 }, { NULL, 0 }, }, @@ -477,6 +482,7 @@ static struct ifmedia_type_to_subtype if }, { { &ifm_shared_option_descriptions[0], 0 }, + { &ifm_shared_option_aliases[0], 1 }, { &ifm_subtype_fddi_option_descriptions[0], 0 }, { NULL, 0 }, }, @@ -494,6 +500,7 @@ static struct ifmedia_type_to_subtype if }, { { &ifm_shared_option_descriptions[0], 0 }, + { &ifm_shared_option_aliases[0], 1 }, { &ifm_subtype_ieee80211_option_descriptions[0], 0 }, { NULL, 0 }, }, @@ -513,6 +520,7 @@ static struct ifmedia_type_to_subtype if }, { { &ifm_shared_option_descriptions[0], 0 }, + { &ifm_shared_option_aliases[0], 1 }, { &ifm_subtype_atm_option_descriptions[0], 0 }, { NULL, 0 }, }, Modified: stable/7/sys/net/if_media.h ============================================================================== --- stable/7/sys/net/if_media.h Fri Jan 14 20:43:21 2011 (r217422) +++ stable/7/sys/net/if_media.h Fri Jan 14 20:43:24 2011 (r217423) @@ -594,6 +594,15 @@ struct ifmedia_description { { 0, NULL }, \ } +#define IFM_SHARED_OPTION_ALIASES { \ + { IFM_FDX, "fdx" }, \ + { IFM_HDX, "hdx" }, \ + { IFM_FLOW, "flow" }, \ + { IFM_LOOP, "loop" }, \ + { IFM_LOOP, "loopback" }, \ + { 0, NULL }, \ +} + /* * Baudrate descriptions for the various media types. */ From owner-svn-src-stable@FreeBSD.ORG Fri Jan 14 22:29:46 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1BD3B106564A; Fri, 14 Jan 2011 22:29:46 +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 010B48FC1A; Fri, 14 Jan 2011 22:29:46 +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 p0EMTjuu004126; Fri, 14 Jan 2011 22:29:45 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0EMTjrK004124; Fri, 14 Jan 2011 22:29:45 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201101142229.p0EMTjrK004124@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 14 Jan 2011 22:29:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217426 - stable/8/sys/dev/usb/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 22:29:46 -0000 Author: yongari Date: Fri Jan 14 22:29:45 2011 New Revision: 217426 URL: http://svn.freebsd.org/changeset/base/217426 Log: MFC r215960,215962-215964,215966: r215960: Apply GPIO configuration for all CICADA PHYs. While I'm here show selected phymode to ease of debugging. r215962: Move axe_reset() to axe_init(). r215963: Do not reinitialize controller if it's already running. r215964: Make sure to change to currently selected media. r215966: Do full controller initialization in axe_reset() for controllers that require special configuration from EEPROM. This will put controllers into known sane state. Modified: stable/8/sys/dev/usb/net/if_axe.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/usb/net/if_axe.c ============================================================================== --- stable/8/sys/dev/usb/net/if_axe.c Fri Jan 14 21:30:27 2011 (r217425) +++ stable/8/sys/dev/usb/net/if_axe.c Fri Jan 14 22:29:45 2011 (r217426) @@ -536,8 +536,9 @@ axe_ax88178_init(struct axe_softc *sc) } if (bootverbose) - device_printf(sc->sc_ue.ue_dev, "EEPROM data : 0x%04x\n", - eeprom); + device_printf(sc->sc_ue.ue_dev, + "EEPROM data : 0x%04x, phymode : 0x%02x\n", eeprom, + phymode); /* Program GPIOs depending on PHY hardware. */ switch (phymode) { case AXE_PHY_MODE_MARVELL: @@ -554,6 +555,8 @@ axe_ax88178_init(struct axe_softc *sc) AXE_GPIO1_EN, hz / 32); break; case AXE_PHY_MODE_CICADA: + case AXE_PHY_MODE_CICADA_V2: + case AXE_PHY_MODE_CICADA_V2_ASIX: if (gpio0 == 1) AXE_GPIO_WRITE(AXE_GPIO_RELOAD_EEPROM | AXE_GPIO0 | AXE_GPIO0_EN, hz / 32); @@ -668,6 +671,12 @@ axe_reset(struct axe_softc *sc) /* Wait a little while for the chip to get its brains in order. */ uether_pause(&sc->sc_ue, hz / 100); + + /* Reinitialize controller to achieve full reset. */ + if (sc->sc_flags & AXE_FLAG_178) + axe_ax88178_init(sc); + else if (sc->sc_flags & AXE_FLAG_772) + axe_ax88772_init(sc); } static void @@ -1016,9 +1025,14 @@ axe_init(struct usb_ether *ue) AXE_LOCK_ASSERT(sc, MA_OWNED); + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + return; + /* Cancel pending I/O */ axe_stop(ue); + axe_reset(sc); + /* Set MAC address. */ if (sc->sc_flags & (AXE_FLAG_178 | AXE_FLAG_772)) axe_cmd(sc, AXE_178_CMD_WRITE_NODEID, 0, 0, IF_LLADDR(ifp)); @@ -1066,6 +1080,8 @@ axe_init(struct usb_ether *ue) usbd_xfer_set_stall(sc->sc_xfer[AXE_BULK_DT_WR]); ifp->if_drv_flags |= IFF_DRV_RUNNING; + /* Switch to selected media. */ + axe_ifmedia_upd(ifp); axe_start(ue); } @@ -1107,6 +1123,4 @@ axe_stop(struct usb_ether *ue) */ usbd_transfer_stop(sc->sc_xfer[AXE_BULK_DT_WR]); usbd_transfer_stop(sc->sc_xfer[AXE_BULK_DT_RD]); - - axe_reset(sc); } From owner-svn-src-stable@FreeBSD.ORG Fri Jan 14 22:31:27 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5870D106566B; Fri, 14 Jan 2011 22:31:27 +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 46FBC8FC1C; Fri, 14 Jan 2011 22:31: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 p0EMVRl6004220; Fri, 14 Jan 2011 22:31:27 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0EMVRWu004217; Fri, 14 Jan 2011 22:31:27 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201101142231.p0EMVRWu004217@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 14 Jan 2011 22:31:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217427 - stable/8/sys/dev/usb/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 22:31:27 -0000 Author: yongari Date: Fri Jan 14 22:31:26 2011 New Revision: 217427 URL: http://svn.freebsd.org/changeset/base/217427 Log: MFC r215968: Introduce new macro AXE_IS_178_FAMILY and AXE_IS_772. Include AX88772A and AX88772B for future extension. While here add TX buffer size for 178 family controllers. Modified: stable/8/sys/dev/usb/net/if_axe.c stable/8/sys/dev/usb/net/if_axereg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/usb/net/if_axe.c ============================================================================== --- stable/8/sys/dev/usb/net/if_axe.c Fri Jan 14 22:29:45 2011 (r217426) +++ stable/8/sys/dev/usb/net/if_axe.c Fri Jan 14 22:31:26 2011 (r217427) @@ -302,7 +302,7 @@ axe_miibus_readreg(device_t dev, int phy axe_cmd(sc, AXE_CMD_MII_OPMODE_HW, 0, 0, NULL); val = le16toh(val); - if ((sc->sc_flags & AXE_FLAG_772) != 0 && reg == MII_BMSR) { + if (AXE_IS_772(sc) && reg == MII_BMSR) { /* * BMSR of AX88772 indicates that it supports extended * capability but the extended status register is @@ -384,7 +384,7 @@ axe_miibus_statchg(device_t dev) val = 0; if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) val |= AXE_MEDIA_FULL_DUPLEX; - if (sc->sc_flags & (AXE_FLAG_178 | AXE_FLAG_772)) { + if (AXE_IS_178_FAMILY(sc)) { val |= AXE_178_MEDIA_RX_EN | AXE_178_MEDIA_MAGIC; if ((sc->sc_flags & AXE_FLAG_178) != 0) val |= AXE_178_MEDIA_ENCK; @@ -700,15 +700,18 @@ axe_attach_post(struct usb_ether *ue) sc->sc_phyno = 0; } - if (sc->sc_flags & AXE_FLAG_178) + if (sc->sc_flags & AXE_FLAG_178) { axe_ax88178_init(sc); - else if (sc->sc_flags & AXE_FLAG_772) + sc->sc_tx_bufsz = 16 * 1024; + } else if (sc->sc_flags & AXE_FLAG_772) { axe_ax88772_init(sc); + sc->sc_tx_bufsz = 8 * 1024; + } /* * Get station address. */ - if (sc->sc_flags & (AXE_FLAG_178 | AXE_FLAG_772)) + if (AXE_IS_178_FAMILY(sc)) axe_cmd(sc, AXE_178_CMD_READ_NODEID, 0, 0, ue->ue_eaddr); else axe_cmd(sc, AXE_172_CMD_READ_NODEID, 0, 0, ue->ue_eaddr); @@ -819,7 +822,7 @@ axe_bulk_read_callback(struct usb_xfer * err = 0; pc = usbd_xfer_get_frame(xfer, 0); - if (sc->sc_flags & (AXE_FLAG_772 | AXE_FLAG_178)) { + if (AXE_IS_178_FAMILY(sc)) { while (pos < actlen) { if ((pos + sizeof(hdr)) > actlen) { /* too little data */ @@ -916,7 +919,7 @@ tr_setup: if (m->m_pkthdr.len > MCLBYTES) { m->m_pkthdr.len = MCLBYTES; } - if (sc->sc_flags & (AXE_FLAG_772 | AXE_FLAG_178)) { + if (AXE_IS_178_FAMILY(sc)) { hdr.len = htole16(m->m_pkthdr.len); hdr.ilen = ~hdr.len; @@ -955,7 +958,7 @@ tr_setup: m_freem(m); - if (sc->sc_flags & (AXE_FLAG_772 | AXE_FLAG_178)) { + if (AXE_IS_178_FAMILY(sc)) { if (pos > (AXE_BULK_BUF_SIZE - MCLBYTES - sizeof(hdr))) { /* send out frame(s) */ break; @@ -1034,16 +1037,16 @@ axe_init(struct usb_ether *ue) axe_reset(sc); /* Set MAC address. */ - if (sc->sc_flags & (AXE_FLAG_178 | AXE_FLAG_772)) + if (AXE_IS_178_FAMILY(sc)) axe_cmd(sc, AXE_178_CMD_WRITE_NODEID, 0, 0, IF_LLADDR(ifp)); else axe_cmd(sc, AXE_172_CMD_WRITE_NODEID, 0, 0, IF_LLADDR(ifp)); /* Set transmitter IPG values */ - if (sc->sc_flags & (AXE_FLAG_178 | AXE_FLAG_772)) { + if (AXE_IS_178_FAMILY(sc)) axe_cmd(sc, AXE_178_CMD_WRITE_IPG012, sc->sc_ipgs[2], (sc->sc_ipgs[1] << 8) | (sc->sc_ipgs[0]), NULL); - } else { + else { axe_cmd(sc, AXE_172_CMD_WRITE_IPG0, 0, sc->sc_ipgs[0], NULL); axe_cmd(sc, AXE_172_CMD_WRITE_IPG1, 0, sc->sc_ipgs[1], NULL); axe_cmd(sc, AXE_172_CMD_WRITE_IPG2, 0, sc->sc_ipgs[2], NULL); @@ -1051,7 +1054,7 @@ axe_init(struct usb_ether *ue) /* Enable receiver, set RX mode */ rxmode = (AXE_RXCMD_MULTICAST | AXE_RXCMD_ENABLE); - if (sc->sc_flags & (AXE_FLAG_178 | AXE_FLAG_772)) { + if (AXE_IS_178_FAMILY(sc)) { #if 0 rxmode |= AXE_178_RXCMD_MFB_2048; /* chip default */ #else Modified: stable/8/sys/dev/usb/net/if_axereg.h ============================================================================== --- stable/8/sys/dev/usb/net/if_axereg.h Fri Jan 14 22:29:45 2011 (r217426) +++ stable/8/sys/dev/usb/net/if_axereg.h Fri Jan 14 22:31:26 2011 (r217427) @@ -203,12 +203,22 @@ struct axe_softc { int sc_flags; #define AXE_FLAG_LINK 0x0001 #define AXE_FLAG_772 0x1000 /* AX88772 */ -#define AXE_FLAG_178 0x2000 /* AX88178 */ +#define AXE_FLAG_772A 0x2000 /* AX88772A */ +#define AXE_FLAG_772B 0x4000 /* AX88772B */ +#define AXE_FLAG_178 0x8000 /* AX88178 */ uint8_t sc_ipgs[3]; uint8_t sc_phyaddrs[2]; + int sc_tx_bufsz; }; +#define AXE_IS_178_FAMILY(sc) \ + ((sc)->sc_flags & (AXE_FLAG_772 | AXE_FLAG_772A | AXE_FLAG_772B | \ + AXE_FLAG_178)) + +#define AXE_IS_772(sc) \ + ((sc)->sc_flags & (AXE_FLAG_772 | AXE_FLAG_772A | AXE_FLAG_772B)) + #define AXE_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) #define AXE_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) #define AXE_LOCK_ASSERT(_sc, t) mtx_assert(&(_sc)->sc_mtx, t) From owner-svn-src-stable@FreeBSD.ORG Fri Jan 14 22:33:12 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CF1BC106566B; Fri, 14 Jan 2011 22:33:12 +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 BD6C18FC19; Fri, 14 Jan 2011 22:33: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 p0EMXCN9004322; Fri, 14 Jan 2011 22:33:12 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0EMXCRJ004319; Fri, 14 Jan 2011 22:33:12 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201101142233.p0EMXCRJ004319@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 14 Jan 2011 22:33:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217428 - stable/8/sys/dev/usb/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 22:33:12 -0000 Author: yongari Date: Fri Jan 14 22:33:12 2011 New Revision: 217428 URL: http://svn.freebsd.org/changeset/base/217428 Log: MFC r215969: Add initial AX88772A support. H/W donated by: Derrick Brashear (shadow <> gmail dot com) Modified: stable/8/sys/dev/usb/net/if_axe.c stable/8/sys/dev/usb/net/if_axereg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/usb/net/if_axe.c ============================================================================== --- stable/8/sys/dev/usb/net/if_axe.c Fri Jan 14 22:31:26 2011 (r217427) +++ stable/8/sys/dev/usb/net/if_axe.c Fri Jan 14 22:33:12 2011 (r217428) @@ -142,11 +142,11 @@ static const struct usb_device_id axe_de AXE_DEV(ASIX, AX88172, 0), AXE_DEV(ASIX, AX88178, AXE_FLAG_178), AXE_DEV(ASIX, AX88772, AXE_FLAG_772), - AXE_DEV(ASIX, AX88772A, AXE_FLAG_772), + AXE_DEV(ASIX, AX88772A, AXE_FLAG_772A), AXE_DEV(ATEN, UC210T, 0), AXE_DEV(BELKIN, F5D5055, AXE_FLAG_178), AXE_DEV(BILLIONTON, USB2AR, 0), - AXE_DEV(CISCOLINKSYS, USB200MV2, AXE_FLAG_772), + AXE_DEV(CISCOLINKSYS, USB200MV2, AXE_FLAG_772A), AXE_DEV(COREGA, FETHER_USB2_TX, 0), AXE_DEV(DLINK, DUBE100, 0), AXE_DEV(DLINK, DUBE100B1, AXE_FLAG_772), @@ -191,6 +191,7 @@ static void axe_ifmedia_sts(struct ifnet static int axe_cmd(struct axe_softc *, int, int, int, void *); static void axe_ax88178_init(struct axe_softc *); static void axe_ax88772_init(struct axe_softc *); +static void axe_ax88772a_init(struct axe_softc *); static int axe_get_phyno(struct axe_softc *, int); static const struct usb_config axe_config[AXE_N_TRANSFER] = { @@ -613,7 +614,6 @@ axe_ax88178_init(struct axe_softc *sc) axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, 0, NULL); } -#undef AXE_GPIO_WRITE static void axe_ax88772_init(struct axe_softc *sc) @@ -657,6 +657,47 @@ axe_ax88772_init(struct axe_softc *sc) } static void +axe_ax88772a_init(struct axe_softc *sc) +{ + struct usb_ether *ue; + uint16_t eeprom; + + ue = &sc->sc_ue; + axe_cmd(sc, AXE_CMD_SROM_READ, 0, 0x0017, &eeprom); + eeprom = le16toh(eeprom); + /* Reload EEPROM. */ + AXE_GPIO_WRITE(AXE_GPIO_RELOAD_EEPROM, hz / 32); + if (sc->sc_phyno == AXE_772_PHY_NO_EPHY) { + /* Manually select internal(embedded) PHY - MAC mode. */ + axe_cmd(sc, AXE_CMD_SW_PHY_SELECT, 0, AXE_SW_PHY_SELECT_SS_ENB | + AXE_SW_PHY_SELECT_EMBEDDED | AXE_SW_PHY_SELECT_SS_MII, + NULL); + uether_pause(&sc->sc_ue, hz / 32); + } else { + /* + * Manually select external PHY - MAC mode. + * Reverse MII/RMII is for AX88772A PHY mode. + */ + axe_cmd(sc, AXE_CMD_SW_PHY_SELECT, 0, AXE_SW_PHY_SELECT_SS_ENB | + AXE_SW_PHY_SELECT_EXT | AXE_SW_PHY_SELECT_SS_MII, NULL); + uether_pause(&sc->sc_ue, hz / 32); + } + /* Take PHY out of power down. */ + axe_cmd(sc, AXE_CMD_SW_RESET_REG, 0, AXE_SW_RESET_IPPD | + AXE_SW_RESET_IPRL, NULL); + uether_pause(&sc->sc_ue, hz / 4); + axe_cmd(sc, AXE_CMD_SW_RESET_REG, 0, AXE_SW_RESET_IPRL, NULL); + uether_pause(&sc->sc_ue, hz); + axe_cmd(sc, AXE_CMD_SW_RESET_REG, 0, AXE_SW_RESET_CLEAR, NULL); + uether_pause(&sc->sc_ue, hz / 32); + axe_cmd(sc, AXE_CMD_SW_RESET_REG, 0, AXE_SW_RESET_IPRL, NULL); + uether_pause(&sc->sc_ue, hz / 32); + axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, 0, NULL); +} + +#undef AXE_GPIO_WRITE + +static void axe_reset(struct axe_softc *sc) { struct usb_config_descriptor *cd; @@ -677,6 +718,8 @@ axe_reset(struct axe_softc *sc) axe_ax88178_init(sc); else if (sc->sc_flags & AXE_FLAG_772) axe_ax88772_init(sc); + else if (sc->sc_flags & AXE_FLAG_772A) + axe_ax88772a_init(sc); } static void @@ -706,6 +749,9 @@ axe_attach_post(struct usb_ether *ue) } else if (sc->sc_flags & AXE_FLAG_772) { axe_ax88772_init(sc); sc->sc_tx_bufsz = 8 * 1024; + } else if (sc->sc_flags & AXE_FLAG_772A) { + axe_ax88772a_init(sc); + sc->sc_tx_bufsz = 8 * 1024; } /* @@ -719,7 +765,13 @@ axe_attach_post(struct usb_ether *ue) /* * Fetch IPG values. */ - axe_cmd(sc, AXE_CMD_READ_IPG012, 0, 0, sc->sc_ipgs); + if (sc->sc_flags & AXE_FLAG_772A) { + /* Set IPG values. */ + sc->sc_ipgs[0] = 0x15; + sc->sc_ipgs[1] = 0x16; + sc->sc_ipgs[2] = 0x1A; + } else + axe_cmd(sc, AXE_CMD_READ_IPG012, 0, 0, sc->sc_ipgs); } /* Modified: stable/8/sys/dev/usb/net/if_axereg.h ============================================================================== --- stable/8/sys/dev/usb/net/if_axereg.h Fri Jan 14 22:31:26 2011 (r217427) +++ stable/8/sys/dev/usb/net/if_axereg.h Fri Jan 14 22:33:12 2011 (r217428) @@ -92,6 +92,10 @@ #define AXE_CMD_SW_PHY_STATUS 0x0021 #define AXE_CMD_SW_PHY_SELECT 0x0122 +/* AX88772A and AX88772B only. */ +#define AXE_CMD_READ_VLAN_CTRL 0x4027 +#define AXE_CMD_WRITE_VLAN_CTRL 0x4028 + #define AXE_SW_RESET_CLEAR 0x00 #define AXE_SW_RESET_RR 0x01 #define AXE_SW_RESET_RT 0x02 @@ -172,6 +176,21 @@ #define AXE_PHY_MODE_REALTEK_8251CL 0x0E #define AXE_PHY_MODE_ATTANSIC 0x40 +/* AX88772A only. */ +#define AXE_SW_PHY_SELECT_EXT 0x0000 +#define AXE_SW_PHY_SELECT_EMBEDDED 0x0001 +#define AXE_SW_PHY_SELECT_AUTO 0x0002 +#define AXE_SW_PHY_SELECT_SS_MII 0x0004 +#define AXE_SW_PHY_SELECT_SS_RVRS_MII 0x0008 +#define AXE_SW_PHY_SELECT_SS_RVRS_RMII 0x000C +#define AXE_SW_PHY_SELECT_SS_ENB 0x0010 + +/* AX88772A/AX88772B VLAN control. */ +#define AXE_VLAN_CTRL_ENB 0x00001000 +#define AXE_VLAN_CTRL_STRIP 0x00002000 +#define AXE_VLAN_CTRL_VID1_MASK 0x00000FFF +#define AXE_VLAN_CTRL_VID2_MASK 0x0FFF0000 + #define AXE_BULK_BUF_SIZE 16384 /* bytes */ #define AXE_CTL_READ 0x01 From owner-svn-src-stable@FreeBSD.ORG Fri Jan 14 22:36:33 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A3EF11065738; Fri, 14 Jan 2011 22:36:33 +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 912C88FC1B; Fri, 14 Jan 2011 22:36: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 p0EMaXmg004446; Fri, 14 Jan 2011 22:36:33 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0EMaXqi004444; Fri, 14 Jan 2011 22:36:33 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201101142236.p0EMaXqi004444@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 14 Jan 2011 22:36:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217429 - stable/8/sys/dev/usb/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 22:36:33 -0000 Author: yongari Date: Fri Jan 14 22:36:33 2011 New Revision: 217429 URL: http://svn.freebsd.org/changeset/base/217429 Log: MFC r216284: r184610 changed the way how TX frames are handled on AX88178 and AX88772 controllers. ASIX added a new feature for AX88178/AX88772 controllers which allows combining multiple TX frames into a single big frame. This was to overcome one of USB limitation where it can't generate more than 8k interrupts/sec which in turn means USB ethernet controllers can not send more than 8k packets per second. Using ASIX's feature greatly enhanced TX performance(more than 3~4 times) compared to 7.x driver. However it seems r184610 removed boundary checking for buffered frames which in turn caused instability issues under certain conditions. In addition, using ASIX's feature triggered another issue which made USB controller hang under certain conditions. Restarting ethernet controller didn't help under this hang condition and unplugging and replugging the controller was the only solution. I believe there is a silicon bug in TX frame combining feature on AX88178/AX88772 controllers. To address these issues, reintroduce the boundary checking for both AX88178 and AX88772 after copying a frame to USB buffer and do not use ASIX's multiple frame combining feature. Instead, use USB controller's multi-frame transmit capability to enhance TX performance as suggested by Hans[1]. This should fix a long standing axe(4) instability issues reported on AX88772 and AX88178 controllers. While I'm here remove unnecessary TX frame length check since upper stack always guarantee the size of a frame to be less than MCLBYTES. Special thanks to Derrick Brashear who tried numerous patches during last 4 months and waited real fix with patience. Without this enthusiastic support, patience and H/W donation I couldn't fix it since I was not able to trigger the issue on my box. Suggested by: hselasky [1] Tested by: Derrick Brashear (shadow <> gmail dot com> H/W donated by: Derrick Brashear (shadow <> gmail dot com> PR: usb/140883 Modified: stable/8/sys/dev/usb/net/if_axe.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/usb/net/if_axe.c ============================================================================== --- stable/8/sys/dev/usb/net/if_axe.c Fri Jan 14 22:33:12 2011 (r217428) +++ stable/8/sys/dev/usb/net/if_axe.c Fri Jan 14 22:36:33 2011 (r217429) @@ -200,7 +200,8 @@ static const struct usb_config axe_confi .type = UE_BULK, .endpoint = UE_ADDR_ANY, .direction = UE_DIR_OUT, - .bufsize = AXE_BULK_BUF_SIZE, + .frames = 16, + .bufsize = 16 * MCLBYTES, .flags = {.pipe_bof = 1,.force_short_xfer = 1,}, .callback = axe_bulk_write_callback, .timeout = 10000, /* 10 seconds */ @@ -939,7 +940,7 @@ axe_bulk_write_callback(struct usb_xfer struct ifnet *ifp = uether_getifp(&sc->sc_ue); struct usb_page_cache *pc; struct mbuf *m; - int pos; + int nframes, pos; switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: @@ -956,40 +957,34 @@ tr_setup: */ return; } - pos = 0; - pc = usbd_xfer_get_frame(xfer, 0); - - while (1) { + for (nframes = 0; nframes < 16 && + !IFQ_DRV_IS_EMPTY(&ifp->if_snd); nframes++) { IFQ_DRV_DEQUEUE(&ifp->if_snd, m); - - if (m == NULL) { - if (pos > 0) - break; /* send out data */ - return; - } - if (m->m_pkthdr.len > MCLBYTES) { - m->m_pkthdr.len = MCLBYTES; - } + if (m == NULL) + break; + usbd_xfer_set_frame_offset(xfer, nframes * MCLBYTES, + nframes); + pos = 0; + pc = usbd_xfer_get_frame(xfer, nframes); if (AXE_IS_178_FAMILY(sc)) { - hdr.len = htole16(m->m_pkthdr.len); hdr.ilen = ~hdr.len; - usbd_copy_in(pc, pos, &hdr, sizeof(hdr)); - pos += sizeof(hdr); - - /* - * NOTE: Some drivers force a short packet - * by appending a dummy header with zero - * length at then end of the USB transfer. - * This driver uses the - * USB_FORCE_SHORT_XFER flag instead. - */ + usbd_m_copy_in(pc, pos, m, 0, m->m_pkthdr.len); + pos += m->m_pkthdr.len; + if ((pos % 512) == 0) { + hdr.len = 0; + hdr.ilen = 0xffff; + usbd_copy_in(pc, pos, &hdr, + sizeof(hdr)); + pos += sizeof(hdr); + } + } else { + usbd_m_copy_in(pc, pos, m, 0, m->m_pkthdr.len); + pos += m->m_pkthdr.len; } - usbd_m_copy_in(pc, pos, m, 0, m->m_pkthdr.len); - pos += m->m_pkthdr.len; /* * XXX @@ -1010,22 +1005,16 @@ tr_setup: m_freem(m); - if (AXE_IS_178_FAMILY(sc)) { - if (pos > (AXE_BULK_BUF_SIZE - MCLBYTES - sizeof(hdr))) { - /* send out frame(s) */ - break; - } - } else { - /* send out frame */ - break; - } + /* Set frame length. */ + usbd_xfer_set_frame_len(xfer, nframes, pos); + } + if (nframes != 0) { + usbd_xfer_set_frames(xfer, nframes); + usbd_transfer_submit(xfer); + ifp->if_drv_flags |= IFF_DRV_OACTIVE; } - - usbd_xfer_set_frame_len(xfer, 0, pos); - usbd_transfer_submit(xfer); - ifp->if_drv_flags |= IFF_DRV_OACTIVE; return; - + /* NOTREACHED */ default: /* Error */ DPRINTFN(11, "transfer error, %s\n", usbd_errstr(error)); From owner-svn-src-stable@FreeBSD.ORG Fri Jan 14 22:58:09 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 040721065673; Fri, 14 Jan 2011 22:58:09 +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 E71D38FC1B; Fri, 14 Jan 2011 22:58: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 p0EMw84B004955; Fri, 14 Jan 2011 22:58:08 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0EMw8Ym004953; Fri, 14 Jan 2011 22:58:08 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201101142258.p0EMw8Ym004953@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 14 Jan 2011 22:58:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217430 - stable/8/share/man/man4 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 22:58:09 -0000 Author: yongari Date: Fri Jan 14 22:58:08 2011 New Revision: 217430 URL: http://svn.freebsd.org/changeset/base/217430 Log: MFC r216131: Document loader tunable hw.re.prefer_iomap. Modified: stable/8/share/man/man4/re.4 Directory Properties: stable/8/share/man/man4/ (props changed) Modified: stable/8/share/man/man4/re.4 ============================================================================== --- stable/8/share/man/man4/re.4 Fri Jan 14 22:36:33 2011 (r217429) +++ stable/8/share/man/man4/re.4 Fri Jan 14 22:58:08 2011 (r217430) @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 27, 2010 +.Dd December 2, 2010 .Dt RE 4 .Os .Sh NAME @@ -178,6 +178,11 @@ prompt before booting the kernel or stor .It Va hw.re.msi_disable This tunable disables MSI support on the Ethernet hardware. The default value is 0. +.It Va hw.re.prefer_iomap +This tunable controls which register mapping should be used on the +specified device. +A non-zero value enables I/O space register mapping. +The default value is 0 to use memory space register mapping. .El .Sh DIAGNOSTICS .Bl -diag From owner-svn-src-stable@FreeBSD.ORG Fri Jan 14 22:58:41 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7572F1065675; Fri, 14 Jan 2011 22:58: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 646CD8FC14; Fri, 14 Jan 2011 22:58: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 p0EMwf1v005014; Fri, 14 Jan 2011 22:58:41 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0EMwfBm005012; Fri, 14 Jan 2011 22:58:41 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201101142258.p0EMwfBm005012@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 14 Jan 2011 22:58:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217431 - stable/7/share/man/man4 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 22:58:41 -0000 Author: yongari Date: Fri Jan 14 22:58:41 2011 New Revision: 217431 URL: http://svn.freebsd.org/changeset/base/217431 Log: MFC r216131: Document loader tunable hw.re.prefer_iomap. Modified: stable/7/share/man/man4/re.4 Directory Properties: stable/7/share/man/man4/ (props changed) Modified: stable/7/share/man/man4/re.4 ============================================================================== --- stable/7/share/man/man4/re.4 Fri Jan 14 22:58:08 2011 (r217430) +++ stable/7/share/man/man4/re.4 Fri Jan 14 22:58:41 2011 (r217431) @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 27, 2010 +.Dd December 2, 2010 .Dt RE 4 .Os .Sh NAME @@ -178,6 +178,11 @@ prompt before booting the kernel or stor .It Va hw.re.msi_disable This tunable disables MSI support on the Ethernet hardware. The default value is 0. +.It Va hw.re.prefer_iomap +This tunable controls which register mapping should be used on the +specified device. +A non-zero value enables I/O space register mapping. +The default value is 0 to use memory space register mapping. .El .Sh DIAGNOSTICS .Bl -diag From owner-svn-src-stable@FreeBSD.ORG Sat Jan 15 00:32:16 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 748A7106564A; Sat, 15 Jan 2011 00:32:16 +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 48FCC8FC12; Sat, 15 Jan 2011 00:32:16 +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 p0F0WGiP007360; Sat, 15 Jan 2011 00:32:16 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0F0WGtw007358; Sat, 15 Jan 2011 00:32:16 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201101150032.p0F0WGtw007358@svn.freebsd.org> From: Pyun YongHyeon Date: Sat, 15 Jan 2011 00:32:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217435 - stable/8/sys/dev/re X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2011 00:32:16 -0000 Author: yongari Date: Sat Jan 15 00:32:15 2011 New Revision: 217435 URL: http://svn.freebsd.org/changeset/base/217435 Log: MFC r217296: For re(4) controllers that uses new jumbo frame scheme(RTL8168C/D/E), limit maximum RX buffer size to RE_RX_DESC_BUFLEN instead of blindly configuring it to 16KB. Due to lack of documentation, re(4) didn't allow jumbo frame on these controllers. However it seems controller is confused with jumbo frame such that it can DMA the received frame to wrong address instead of splitting it into multiple RX buffers. Of course, this caused panic. Since re(4) does not support jumbo frames on these controllers, make controller drop frame that is longer than RE_RX_DESC_BUFLEN sized frame. Fortunately RTL810x controllers, which do not support jumbo frame, have no such issues but this change also limited maximum RX buffer size allowed to RTL810x controllers. Allowing 16KB RX buffer for controllers that have no such capability is meaningless. Modified: stable/8/sys/dev/re/if_re.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/re/if_re.c ============================================================================== --- stable/8/sys/dev/re/if_re.c Sat Jan 15 00:23:57 2011 (r217434) +++ stable/8/sys/dev/re/if_re.c Sat Jan 15 00:32:15 2011 (r217435) @@ -2779,8 +2779,13 @@ re_init_locked(struct rl_softc *sc) * For 8169 gigE NICs, set the max allowed RX packet * size so we can receive jumbo frames. */ - if (sc->rl_type == RL_8169) - CSR_WRITE_2(sc, RL_MAXRXPKTLEN, 16383); + if (sc->rl_type == RL_8169) { + if ((sc->rl_flags & (RL_FLAG_PCIE | RL_FLAG_NOJUMBO)) == + (RL_FLAG_PCIE | RL_FLAG_NOJUMBO)) + CSR_WRITE_2(sc, RL_MAXRXPKTLEN, RE_RX_DESC_BUFLEN); + else + CSR_WRITE_2(sc, RL_MAXRXPKTLEN, 16383); + } if (sc->rl_testmode) return; From owner-svn-src-stable@FreeBSD.ORG Sat Jan 15 00:34:51 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 219021065693; Sat, 15 Jan 2011 00:34:51 +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 D1C0A8FC18; Sat, 15 Jan 2011 00:34: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 p0F0Yoxx007468; Sat, 15 Jan 2011 00:34:50 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0F0YoxC007466; Sat, 15 Jan 2011 00:34:50 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201101150034.p0F0YoxC007466@svn.freebsd.org> From: Pyun YongHyeon Date: Sat, 15 Jan 2011 00:34:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217436 - stable/7/sys/dev/re X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2011 00:34:51 -0000 Author: yongari Date: Sat Jan 15 00:34:50 2011 New Revision: 217436 URL: http://svn.freebsd.org/changeset/base/217436 Log: MFC r217296: For re(4) controllers that uses new jumbo frame scheme(RTL8168C/D/E), limit maximum RX buffer size to RE_RX_DESC_BUFLEN instead of blindly configuring it to 16KB. Due to lack of documentation, re(4) didn't allow jumbo frame on these controllers. However it seems controller is confused with jumbo frame such that it can DMA the received frame to wrong address instead of splitting it into multiple RX buffers. Of course, this caused panic. Since re(4) does not support jumbo frames on these controllers, make controller drop frame that is longer than RE_RX_DESC_BUFLEN sized frame. Fortunately RTL810x controllers, which do not support jumbo frame, have no such issues but this change also limited maximum RX buffer size allowed to RTL810x controllers. Allowing 16KB RX buffer for controllers that have no such capability is meaningless. Modified: stable/7/sys/dev/re/if_re.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/re/if_re.c ============================================================================== --- stable/7/sys/dev/re/if_re.c Sat Jan 15 00:32:15 2011 (r217435) +++ stable/7/sys/dev/re/if_re.c Sat Jan 15 00:34:50 2011 (r217436) @@ -2773,8 +2773,13 @@ re_init_locked(struct rl_softc *sc) * For 8169 gigE NICs, set the max allowed RX packet * size so we can receive jumbo frames. */ - if (sc->rl_type == RL_8169) - CSR_WRITE_2(sc, RL_MAXRXPKTLEN, 16383); + if (sc->rl_type == RL_8169) { + if ((sc->rl_flags & (RL_FLAG_PCIE | RL_FLAG_NOJUMBO)) == + (RL_FLAG_PCIE | RL_FLAG_NOJUMBO)) + CSR_WRITE_2(sc, RL_MAXRXPKTLEN, RE_RX_DESC_BUFLEN); + else + CSR_WRITE_2(sc, RL_MAXRXPKTLEN, 16383); + } if (sc->rl_testmode) return; From owner-svn-src-stable@FreeBSD.ORG Sat Jan 15 01:03:27 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F2147106564A; Sat, 15 Jan 2011 01:03:26 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D5E818FC08; Sat, 15 Jan 2011 01:03: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 p0F13Qhm008373; Sat, 15 Jan 2011 01:03:26 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0F13QF3008370; Sat, 15 Jan 2011 01:03:26 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201101150103.p0F13QF3008370@svn.freebsd.org> From: Rick Macklem Date: Sat, 15 Jan 2011 01:03:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217437 - in stable/8/sys/fs: nfs nfsserver X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2011 01:03:27 -0000 Author: rmacklem Date: Sat Jan 15 01:03:26 2011 New Revision: 217437 URL: http://svn.freebsd.org/changeset/base/217437 Log: MFC: r216875 Add support for shared vnode locks for the Read operation in the experimental NFSv4 server. Modified: stable/8/sys/fs/nfs/nfs_commonsubs.c stable/8/sys/fs/nfsserver/nfs_nfsdstate.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/fs/nfs/nfs_commonsubs.c ============================================================================== --- stable/8/sys/fs/nfs/nfs_commonsubs.c Sat Jan 15 00:34:50 2011 (r217436) +++ stable/8/sys/fs/nfs/nfs_commonsubs.c Sat Jan 15 01:03:26 2011 (r217437) @@ -109,7 +109,7 @@ struct nfsv4_opflag nfsv4_opflag[NFSV4OP { 1, 0, 0, 0, LK_EXCLUSIVE }, /* PutFH */ { 1, 0, 0, 0, LK_EXCLUSIVE }, /* PutPubFH */ { 1, 0, 0, 0, LK_EXCLUSIVE }, /* PutRootFH */ - { 0, 1, 0, 0, LK_EXCLUSIVE }, /* Read */ + { 0, 1, 0, 0, LK_SHARED }, /* Read */ { 0, 1, 0, 0, LK_SHARED }, /* Readdir */ { 0, 1, 0, 0, LK_SHARED }, /* ReadLink */ { 0, 2, 1, 1, LK_EXCLUSIVE }, /* Remove */ Modified: stable/8/sys/fs/nfsserver/nfs_nfsdstate.c ============================================================================== --- stable/8/sys/fs/nfsserver/nfs_nfsdstate.c Sat Jan 15 00:34:50 2011 (r217436) +++ stable/8/sys/fs/nfsserver/nfs_nfsdstate.c Sat Jan 15 01:03:26 2011 (r217437) @@ -4217,7 +4217,7 @@ static int nfsrv_clientconflict(struct nfsclient *clp, int *haslockp, __unused vnode_t vp, NFSPROC_T *p) { - int gotlock; + int gotlock, lktype; /* * If lease hasn't expired, we can't fix it. @@ -4227,7 +4227,8 @@ nfsrv_clientconflict(struct nfsclient *c return (0); if (*haslockp == 0) { NFSUNLOCKSTATE(); - NFSVOPUNLOCK(vp, 0, p); + lktype = VOP_ISLOCKED(vp); + VOP_UNLOCK(vp, 0); NFSLOCKV4ROOTMUTEX(); nfsv4_relref(&nfsv4rootfs_lock); do { @@ -4236,7 +4237,7 @@ nfsrv_clientconflict(struct nfsclient *c } while (!gotlock); NFSUNLOCKV4ROOTMUTEX(); *haslockp = 1; - NFSVOPLOCK(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, lktype | LK_RETRY); return (1); } NFSUNLOCKSTATE(); @@ -4278,7 +4279,7 @@ nfsrv_delegconflict(struct nfsstate *stp vnode_t vp) { struct nfsclient *clp = stp->ls_clp; - int gotlock, error, retrycnt, zapped_clp; + int gotlock, error, lktype, retrycnt, zapped_clp; nfsv4stateid_t tstateid; fhandle_t tfh; @@ -4391,7 +4392,8 @@ nfsrv_delegconflict(struct nfsstate *stp */ if (*haslockp == 0) { NFSUNLOCKSTATE(); - NFSVOPUNLOCK(vp, 0, p); + lktype = VOP_ISLOCKED(vp); + VOP_UNLOCK(vp, 0); NFSLOCKV4ROOTMUTEX(); nfsv4_relref(&nfsv4rootfs_lock); do { @@ -4400,7 +4402,7 @@ nfsrv_delegconflict(struct nfsstate *stp } while (!gotlock); NFSUNLOCKV4ROOTMUTEX(); *haslockp = 1; - NFSVOPLOCK(vp, LK_EXCLUSIVE | LK_RETRY, p); + vn_lock(vp, lktype | LK_RETRY); return (-1); } From owner-svn-src-stable@FreeBSD.ORG Sat Jan 15 08:18:59 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 19655106566C; Sat, 15 Jan 2011 08:18:59 +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 E211B8FC0A; Sat, 15 Jan 2011 08:18: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 p0F8IwJX017941; Sat, 15 Jan 2011 08:18:58 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0F8IwAN017938; Sat, 15 Jan 2011 08:18:58 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201101150818.p0F8IwAN017938@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sat, 15 Jan 2011 08:18:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217439 - stable/8/sbin/hastd X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2011 08:18:59 -0000 Author: pjd Date: Sat Jan 15 08:18:58 2011 New Revision: 217439 URL: http://svn.freebsd.org/changeset/base/217439 Log: MFC r217307,r217308,r217312: r217307: Install default signal handlers before masking signals we want to handle. It is possible that the parent process ignores some of them and sigtimedwait() will never see them, eventhough they are masked. The most common situation for this to happen is boot process where init(8) ignores SIGHUP before starting to execute /etc/rc. This in turn caused hastd(8) to ignore SIGHUP. Reported by: trasz Obtained from: Wheel Systems Sp. z o.o. http://www.wheelsystems.com r217308: Add a note that when custom signal handler is installed for a signal, signal action is restored to default in child after fork(2). In this case there is no need to do anything with dummy SIGCHLD handler, because after fork(2) it will be automatically reverted to SIG_IGN. Obtained from: Wheel Systems Sp. z o.o. http://www.wheelsystems.com r217312: execve(2), not fork(2) resets signal handler to the default value (if it isn't ignored). Correct comment talking about that. Pointed out by: kib Modified: stable/8/sbin/hastd/hastd.c stable/8/sbin/hastd/hooks.c Directory Properties: stable/8/sbin/hastd/ (props changed) Modified: stable/8/sbin/hastd/hastd.c ============================================================================== --- stable/8/sbin/hastd/hastd.c Sat Jan 15 03:06:03 2011 (r217438) +++ stable/8/sbin/hastd/hastd.c Sat Jan 15 08:18:58 2011 (r217439) @@ -754,10 +754,18 @@ main(int argc, char *argv[]) assert(cfg != NULL); /* + * Restore default actions for interesting signals in case parent + * process (like init(8)) decided to ignore some of them (like SIGHUP). + */ + PJDLOG_VERIFY(signal(SIGHUP, SIG_DFL) != SIG_ERR); + PJDLOG_VERIFY(signal(SIGINT, SIG_DFL) != SIG_ERR); + PJDLOG_VERIFY(signal(SIGTERM, SIG_DFL) != SIG_ERR); + /* * Because SIGCHLD is ignored by default, setup dummy handler for it, * so we can mask it. */ PJDLOG_VERIFY(signal(SIGCHLD, dummy_sighandler) != SIG_ERR); + PJDLOG_VERIFY(sigemptyset(&mask) == 0); PJDLOG_VERIFY(sigaddset(&mask, SIGHUP) == 0); PJDLOG_VERIFY(sigaddset(&mask, SIGINT) == 0); Modified: stable/8/sbin/hastd/hooks.c ============================================================================== --- stable/8/sbin/hastd/hooks.c Sat Jan 15 03:06:03 2011 (r217438) +++ stable/8/sbin/hastd/hooks.c Sat Jan 15 08:18:58 2011 (r217439) @@ -372,6 +372,11 @@ hook_execv(const char *path, va_list ap) descriptors(); PJDLOG_VERIFY(sigemptyset(&mask) == 0); PJDLOG_VERIFY(sigprocmask(SIG_SETMASK, &mask, NULL) == 0); + /* + * Dummy handler set for SIGCHLD in the parent will be restored + * to SIG_IGN on execv(3) below, so there is no need to do + * anything with it. + */ execv(path, args); pjdlog_errno(LOG_ERR, "Unable to execute %s", path); exit(EX_SOFTWARE); From owner-svn-src-stable@FreeBSD.ORG Sat Jan 15 08:35:41 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ADF8E106566B; Sat, 15 Jan 2011 08:35:41 +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 9D3618FC18; Sat, 15 Jan 2011 08:35: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 p0F8ZfnJ018342; Sat, 15 Jan 2011 08:35:41 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0F8ZfmQ018340; Sat, 15 Jan 2011 08:35:41 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201101150835.p0F8ZfmQ018340@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 15 Jan 2011 08:35:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217440 - stable/8/lib/libc/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2011 08:35:41 -0000 Author: kib Date: Sat Jan 15 08:35:41 2011 New Revision: 217440 URL: http://svn.freebsd.org/changeset/base/217440 Log: MFC r217143: Fix struct FILE * leak on error (in disabled by default hesiod support code). PR: 153756 Modified: stable/8/lib/libc/net/hesiod.c Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/locale/ (props changed) stable/8/lib/libc/stdtime/ (props changed) stable/8/lib/libc/sys/ (props changed) Modified: stable/8/lib/libc/net/hesiod.c ============================================================================== --- stable/8/lib/libc/net/hesiod.c Sat Jan 15 08:18:58 2011 (r217439) +++ stable/8/lib/libc/net/hesiod.c Sat Jan 15 08:35:41 2011 (r217440) @@ -324,6 +324,7 @@ read_config_file(ctx, filename) ? &ctx->lhs : &ctx->rhs; *which = strdup(data); if (!*which) { + fclose(fp); errno = ENOMEM; return -1; } From owner-svn-src-stable@FreeBSD.ORG Sat Jan 15 08:37:34 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 50AD41065672; Sat, 15 Jan 2011 08:37:34 +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 3FBCF8FC0C; Sat, 15 Jan 2011 08:37:34 +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 p0F8bYAN018422; Sat, 15 Jan 2011 08:37:34 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0F8bYqN018420; Sat, 15 Jan 2011 08:37:34 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201101150837.p0F8bYqN018420@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 15 Jan 2011 08:37:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217441 - stable/8/lib/libc/stdlib X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2011 08:37:34 -0000 Author: kib Date: Sat Jan 15 08:37:33 2011 New Revision: 217441 URL: http://svn.freebsd.org/changeset/base/217441 Log: MFC r217144: Fix some style(9) issues. Do not use strlcpy() where simple assignment is enough. Modified: stable/8/lib/libc/stdlib/realpath.c Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/locale/ (props changed) stable/8/lib/libc/stdtime/ (props changed) stable/8/lib/libc/sys/ (props changed) Modified: stable/8/lib/libc/stdlib/realpath.c ============================================================================== --- stable/8/lib/libc/stdlib/realpath.c Sat Jan 15 08:35:41 2011 (r217440) +++ stable/8/lib/libc/stdlib/realpath.c Sat Jan 15 08:37:33 2011 (r217441) @@ -54,7 +54,7 @@ realpath(const char * __restrict path, c char *p, *q, *s; size_t left_len, resolved_len; unsigned symlinks; - int serrno, slen, m; + int m, serrno, slen; char left[PATH_MAX], next_token[PATH_MAX], symlink[PATH_MAX]; if (path == NULL) { @@ -73,7 +73,6 @@ realpath(const char * __restrict path, c m = 1; } else m = 0; - symlinks = 0; if (path[0] == '/') { resolved[0] = '/'; @@ -86,8 +85,10 @@ realpath(const char * __restrict path, c if (getcwd(resolved, PATH_MAX) == NULL) { if (m) free(resolved); - else - strlcpy(resolved, ".", PATH_MAX); + else { + resolved[0] = '.'; + resolved[1] = '\0'; + } return (NULL); } resolved_len = strlen(resolved); From owner-svn-src-stable@FreeBSD.ORG Sat Jan 15 09:25:19 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E9DAA106564A; Sat, 15 Jan 2011 09:25:19 +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 D8D7D8FC13; Sat, 15 Jan 2011 09:25: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 p0F9PJoa019570; Sat, 15 Jan 2011 09:25:19 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0F9PJsA019568; Sat, 15 Jan 2011 09:25:19 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201101150925.p0F9PJsA019568@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 15 Jan 2011 09:25:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217442 - stable/8/sys/kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2011 09:25:20 -0000 Author: kib Date: Sat Jan 15 09:25:19 2011 New Revision: 217442 URL: http://svn.freebsd.org/changeset/base/217442 Log: MFC r217150: Collect code to translate between vm_prot_t and p_flags into helper functions. Modified: stable/8/sys/kern/imgact_elf.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/kern/imgact_elf.c ============================================================================== --- stable/8/sys/kern/imgact_elf.c Sat Jan 15 08:37:33 2011 (r217441) +++ stable/8/sys/kern/imgact_elf.c Sat Jan 15 09:25:19 2011 (r217442) @@ -86,6 +86,8 @@ static boolean_t __elfN(freebsd_trans_os static boolean_t kfreebsd_trans_osrel(const Elf_Note *note, int32_t *osrel); static boolean_t __elfN(check_note)(struct image_params *imgp, Elf_Brandnote *checknote, int32_t *osrel); +static vm_prot_t __elfN(trans_prot)(Elf_Word); +static Elf_Word __elfN(untrans_prot)(vm_prot_t); SYSCTL_NODE(_kern, OID_AUTO, __CONCAT(elf, __ELF_WORD_SIZE), CTLFLAG_RW, 0, ""); @@ -632,14 +634,7 @@ __elfN(load_file)(struct proc *p, const for (i = 0, numsegs = 0; i < hdr->e_phnum; i++) { if (phdr[i].p_type == PT_LOAD && phdr[i].p_memsz != 0) { /* Loadable segment */ - prot = 0; - if (phdr[i].p_flags & PF_X) - prot |= VM_PROT_EXECUTE; - if (phdr[i].p_flags & PF_W) - prot |= VM_PROT_WRITE; - if (phdr[i].p_flags & PF_R) - prot |= VM_PROT_READ; - + prot = __elfN(trans_prot)(phdr[i].p_flags); if ((error = __elfN(load_section)(vmspace, imgp->object, phdr[i].p_offset, (caddr_t)(uintptr_t)phdr[i].p_vaddr + rbase, @@ -780,13 +775,7 @@ __CONCAT(exec_, __elfN(imgact))(struct i case PT_LOAD: /* Loadable segment */ if (phdr[i].p_memsz == 0) break; - prot = 0; - if (phdr[i].p_flags & PF_X) - prot |= VM_PROT_EXECUTE; - if (phdr[i].p_flags & PF_W) - prot |= VM_PROT_WRITE; - if (phdr[i].p_flags & PF_R) - prot |= VM_PROT_READ; + prot = __elfN(trans_prot)(phdr[i].p_flags); #if defined(__ia64__) && __ELF_WORD_SIZE == 32 && defined(IA32_ME_HARDER) /* @@ -1086,13 +1075,7 @@ cb_put_phdr(entry, closure) phdr->p_paddr = 0; phdr->p_filesz = phdr->p_memsz = entry->end - entry->start; phdr->p_align = PAGE_SIZE; - phdr->p_flags = 0; - if (entry->protection & VM_PROT_READ) - phdr->p_flags |= PF_R; - if (entry->protection & VM_PROT_WRITE) - phdr->p_flags |= PF_W; - if (entry->protection & VM_PROT_EXECUTE) - phdr->p_flags |= PF_X; + phdr->p_flags = __elfN(untrans_prot)(entry->protection); phc->offset += phdr->p_filesz; phc->phdr++; @@ -1483,3 +1466,33 @@ static struct execsw __elfN(execsw) = { __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) }; EXEC_SET(__CONCAT(elf, __ELF_WORD_SIZE), __elfN(execsw)); + +static vm_prot_t +__elfN(trans_prot)(Elf_Word flags) +{ + vm_prot_t prot; + + prot = 0; + if (flags & PF_X) + prot |= VM_PROT_EXECUTE; + if (flags & PF_W) + prot |= VM_PROT_WRITE; + if (flags & PF_R) + prot |= VM_PROT_READ; + return (prot); +} + +static Elf_Word +__elfN(untrans_prot)(vm_prot_t prot) +{ + Elf_Word flags; + + flags = 0; + if (prot & VM_PROT_EXECUTE) + flags |= PF_X; + if (prot & VM_PROT_READ) + flags |= PF_R; + if (prot & VM_PROT_WRITE) + flags |= PF_W; + return (flags); +} From owner-svn-src-stable@FreeBSD.ORG Sat Jan 15 09:36:31 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DA679106564A; Sat, 15 Jan 2011 09:36:31 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C9D648FC08; Sat, 15 Jan 2011 09:36: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 p0F9aVnx019843; Sat, 15 Jan 2011 09:36:31 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0F9aVGt019841; Sat, 15 Jan 2011 09:36:31 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201101150936.p0F9aVGt019841@svn.freebsd.org> From: Jaakko Heinonen Date: Sat, 15 Jan 2011 09:36:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217443 - stable/7/sys/geom X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2011 09:36:32 -0000 Author: jh Date: Sat Jan 15 09:36:31 2011 New Revision: 217443 URL: http://svn.freebsd.org/changeset/base/217443 Log: MFC r214748: Extend the g_eventlock mutex coverage in one_event() to include setting of the EV_DONE flag and use the mutex to protect against losing wakeups in g_waitfor_event(). Modified: stable/7/sys/geom/geom_event.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/geom/geom_event.c ============================================================================== --- stable/7/sys/geom/geom_event.c Sat Jan 15 09:25:19 2011 (r217442) +++ stable/7/sys/geom/geom_event.c Sat Jan 15 09:36:31 2011 (r217443) @@ -212,11 +212,12 @@ one_event(void) g_topology_assert(); mtx_lock(&g_eventlock); TAILQ_REMOVE(&g_events, ep, events); - mtx_unlock(&g_eventlock); if (ep->flag & EV_WAKEUP) { ep->flag |= EV_DONE; + mtx_unlock(&g_eventlock); wakeup(ep); } else { + mtx_unlock(&g_eventlock); g_free(ep); } g_topology_unlock(); @@ -355,11 +356,14 @@ g_waitfor_event(g_event_t *func, void *a va_end(ap); if (error) return (error); - do - tsleep(ep, PRIBIO, "g_waitfor_event", hz); - while (!(ep->flag & EV_DONE)); + + mtx_lock(&g_eventlock); + while (!(ep->flag & EV_DONE)) + msleep(ep, &g_eventlock, PRIBIO, "g_waitfor_event", hz); if (ep->flag & EV_CANCELED) error = EAGAIN; + mtx_unlock(&g_eventlock); + g_free(ep); return (error); } From owner-svn-src-stable@FreeBSD.ORG Sat Jan 15 18:41:42 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E75741065673; Sat, 15 Jan 2011 18:41:42 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D4B898FC12; Sat, 15 Jan 2011 18:41:42 +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 p0FIfgrW033242; Sat, 15 Jan 2011 18:41:42 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0FIfgTZ033239; Sat, 15 Jan 2011 18:41:42 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201101151841.p0FIfgTZ033239@svn.freebsd.org> From: Robert Watson Date: Sat, 15 Jan 2011 18:41:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217445 - stable/8/sys/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2011 18:41:43 -0000 Author: rwatson Date: Sat Jan 15 18:41:42 2011 New Revision: 217445 URL: http://svn.freebsd.org/changeset/base/217445 Log: Merge r204199 from head to stable/8: Export netisr configuration and statistics to userspace via sysctl(9). Sponsored by: Juniper Networks Modified: stable/8/sys/net/netisr.c stable/8/sys/net/netisr.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/net/netisr.c ============================================================================== --- stable/8/sys/net/netisr.c Sat Jan 15 09:43:25 2011 (r217444) +++ stable/8/sys/net/netisr.c Sat Jan 15 18:41:42 2011 (r217445) @@ -1,7 +1,11 @@ /*- * Copyright (c) 2007-2009 Robert N. M. Watson + * Copyright (c) 2010 Juniper Networks, Inc. * All rights reserved. * + * This software was developed by Robert N. M. Watson under contract + * to Juniper Networks, Inc. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -1118,6 +1122,170 @@ netisr_start(void *arg) } SYSINIT(netisr_start, SI_SUB_SMP, SI_ORDER_MIDDLE, netisr_start, NULL); +/* + * Sysctl monitoring for netisr: query a list of registered protocols. + */ +static int +sysctl_netisr_proto(SYSCTL_HANDLER_ARGS) +{ + struct rm_priotracker tracker; + struct sysctl_netisr_proto *snpp, *snp_array; + struct netisr_proto *npp; + u_int counter, proto; + int error; + + if (req->newptr != NULL) + return (EINVAL); + snp_array = malloc(sizeof(*snp_array) * NETISR_MAXPROT, M_TEMP, + M_ZERO | M_WAITOK); + counter = 0; + NETISR_RLOCK(&tracker); + for (proto = 0; proto < NETISR_MAXPROT; proto++) { + npp = &np[proto]; + if (npp->np_name == NULL) + continue; + snpp = &snp_array[counter]; + snpp->snp_version = sizeof(*snpp); + strlcpy(snpp->snp_name, npp->np_name, NETISR_NAMEMAXLEN); + snpp->snp_proto = proto; + snpp->snp_qlimit = npp->np_qlimit; + snpp->snp_policy = npp->np_policy; + if (npp->np_m2flow != NULL) + snpp->snp_flags |= NETISR_SNP_FLAGS_M2FLOW; + if (npp->np_m2cpuid != NULL) + snpp->snp_flags |= NETISR_SNP_FLAGS_M2CPUID; + if (npp->np_drainedcpu != NULL) + snpp->snp_flags |= NETISR_SNP_FLAGS_DRAINEDCPU; + counter++; + } + NETISR_RUNLOCK(&tracker); + KASSERT(counter < NETISR_MAXPROT, + ("sysctl_netisr_proto: counter too big (%d)", counter)); + error = SYSCTL_OUT(req, snp_array, sizeof(*snp_array) * counter); + free(snp_array, M_TEMP); + return (error); +} + +SYSCTL_PROC(_net_isr, OID_AUTO, proto, + CTLFLAG_RD|CTLTYPE_STRUCT|CTLFLAG_MPSAFE, 0, 0, sysctl_netisr_proto, + "S,sysctl_netisr_proto", + "Return list of protocols registered with netisr"); + +/* + * Sysctl monitoring for netisr: query a list of workstreams. + */ +static int +sysctl_netisr_workstream(SYSCTL_HANDLER_ARGS) +{ + struct rm_priotracker tracker; + struct sysctl_netisr_workstream *snwsp, *snws_array; + struct netisr_workstream *nwsp; + u_int counter, cpuid; + int error; + + if (req->newptr != NULL) + return (EINVAL); + snws_array = malloc(sizeof(*snws_array) * MAXCPU, M_TEMP, + M_ZERO | M_WAITOK); + counter = 0; + NETISR_RLOCK(&tracker); + for (cpuid = 0; cpuid < MAXCPU; cpuid++) { + if (CPU_ABSENT(cpuid)) + continue; + nwsp = DPCPU_ID_PTR(cpuid, nws); + if (nwsp->nws_intr_event == NULL) + continue; + NWS_LOCK(nwsp); + snwsp = &snws_array[counter]; + snwsp->snws_version = sizeof(*snwsp); + + /* + * For now, we equate workstream IDs and CPU IDs in the + * kernel, but expose them independently to userspace in case + * that assumption changes in the future. + */ + snwsp->snws_wsid = cpuid; + snwsp->snws_cpu = cpuid; + if (nwsp->nws_intr_event != NULL) + snwsp->snws_flags |= NETISR_SNWS_FLAGS_INTR; + NWS_UNLOCK(nwsp); + counter++; + } + NETISR_RUNLOCK(&tracker); + KASSERT(counter < MAXCPU, + ("sysctl_netisr_workstream: counter too big (%d)", counter)); + error = SYSCTL_OUT(req, snws_array, sizeof(*snws_array) * counter); + free(snws_array, M_TEMP); + return (error); +} + +SYSCTL_PROC(_net_isr, OID_AUTO, workstream, + CTLFLAG_RD|CTLTYPE_STRUCT|CTLFLAG_MPSAFE, 0, 0, sysctl_netisr_workstream, + "S,sysctl_netisr_workstream", + "Return list of workstreams implemented by netisr"); + +/* + * Sysctl monitoring for netisr: query per-protocol data across all + * workstreams. + */ +static int +sysctl_netisr_work(SYSCTL_HANDLER_ARGS) +{ + struct rm_priotracker tracker; + struct sysctl_netisr_work *snwp, *snw_array; + struct netisr_workstream *nwsp; + struct netisr_proto *npp; + struct netisr_work *nwp; + u_int counter, cpuid, proto; + int error; + + if (req->newptr != NULL) + return (EINVAL); + snw_array = malloc(sizeof(*snw_array) * MAXCPU * NETISR_MAXPROT, + M_TEMP, M_ZERO | M_WAITOK); + counter = 0; + NETISR_RLOCK(&tracker); + for (cpuid = 0; cpuid < MAXCPU; cpuid++) { + if (CPU_ABSENT(cpuid)) + continue; + nwsp = DPCPU_ID_PTR(cpuid, nws); + if (nwsp->nws_intr_event == NULL) + continue; + NWS_LOCK(nwsp); + for (proto = 0; proto < NETISR_MAXPROT; proto++) { + npp = &np[proto]; + if (npp->np_name == NULL) + continue; + nwp = &nwsp->nws_work[proto]; + snwp = &snw_array[counter]; + snwp->snw_version = sizeof(*snwp); + snwp->snw_wsid = cpuid; /* See comment above. */ + snwp->snw_proto = proto; + snwp->snw_len = nwp->nw_len; + snwp->snw_watermark = nwp->nw_watermark; + snwp->snw_dispatched = nwp->nw_dispatched; + snwp->snw_hybrid_dispatched = + nwp->nw_hybrid_dispatched; + snwp->snw_qdrops = nwp->nw_qdrops; + snwp->snw_queued = nwp->nw_queued; + snwp->snw_handled = nwp->nw_handled; + counter++; + } + NWS_UNLOCK(nwsp); + } + KASSERT(counter < MAXCPU * NETISR_MAXPROT, + ("sysctl_netisr_work: counter too big (%d)", counter)); + NETISR_RUNLOCK(&tracker); + error = SYSCTL_OUT(req, snw_array, sizeof(*snw_array) * counter); + free(snw_array, M_TEMP); + return (error); +} + +SYSCTL_PROC(_net_isr, OID_AUTO, work, + CTLFLAG_RD|CTLTYPE_STRUCT|CTLFLAG_MPSAFE, 0, 0, sysctl_netisr_work, + "S,sysctl_netisr_work", + "Return list of per-workstream, per-protocol work in netisr"); + #ifdef DDB DB_SHOW_COMMAND(netisr, db_show_netisr) { Modified: stable/8/sys/net/netisr.h ============================================================================== --- stable/8/sys/net/netisr.h Sat Jan 15 09:43:25 2011 (r217444) +++ stable/8/sys/net/netisr.h Sat Jan 15 18:41:42 2011 (r217445) @@ -1,7 +1,11 @@ /*- * Copyright (c) 2007-2009 Robert N. M. Watson + * Copyright (c) 2010 Juniper Networks, Inc. * All rights reserved. * + * This software was developed by Robert N. M. Watson under contract + * to Juniper Networks, Inc. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -28,7 +32,6 @@ #ifndef _NET_NETISR_H_ #define _NET_NETISR_H_ -#ifdef _KERNEL /* * The netisr (network interrupt service routine) provides a deferred @@ -39,6 +42,13 @@ * Historically, this was implemented by the BSD software ISR facility; it is * now implemented via a software ithread (SWI). */ + +/* + * Protocol numbers, which are encoded in monitoring applications and kernel + * modules. Internally, these are used in bit shift operations so must have + * a value 0 < proto < 32; we currently further limit at compile-time to 16 + * for array-sizing purposes. + */ #define NETISR_IP 1 #define NETISR_IGMP 2 /* IGMPv3 output queue */ #define NETISR_ROUTE 3 /* routing socket */ @@ -52,6 +62,78 @@ #define NETISR_NATM 11 #define NETISR_EPAIR 12 /* if_epair(4) */ +/* + * Protocol ordering and affinity policy constants. See the detailed + * discussion of policies later in the file. + */ +#define NETISR_POLICY_SOURCE 1 /* Maintain source ordering. */ +#define NETISR_POLICY_FLOW 2 /* Maintain flow ordering. */ +#define NETISR_POLICY_CPU 3 /* Protocol determines CPU placement. */ + +/* + * Monitoring data structures, exported by sysctl(2). + * + * Three sysctls are defined. First, a per-protocol structure exported by + * net.isr.proto. + */ +#define NETISR_NAMEMAXLEN 32 +struct sysctl_netisr_proto { + u_int snp_version; /* Length of struct. */ + char snp_name[NETISR_NAMEMAXLEN]; /* nh_name */ + u_int snp_proto; /* nh_proto */ + u_int snp_qlimit; /* nh_qlimit */ + u_int snp_policy; /* nh_policy */ + u_int snp_flags; /* Various flags. */ + u_int _snp_ispare[7]; +}; + +/* + * Flags for sysctl_netisr_proto.snp_flags. + */ +#define NETISR_SNP_FLAGS_M2FLOW 0x00000001 /* nh_m2flow */ +#define NETISR_SNP_FLAGS_M2CPUID 0x00000002 /* nh_m2cpuid */ +#define NETISR_SNP_FLAGS_DRAINEDCPU 0x00000003 /* nh_drainedcpu */ + +/* + * Next, a structure per-workstream, with per-protocol data, exported as + * net.isr.workstream. + */ +struct sysctl_netisr_workstream { + u_int snws_version; /* Length of struct. */ + u_int snws_flags; /* Various flags. */ + u_int snws_wsid; /* Workstream ID. */ + u_int snws_cpu; /* nws_cpu */ + u_int _snws_ispare[12]; +}; + +/* + * Flags for sysctl_netisr_workstream.snws_flags + */ +#define NETISR_SNWS_FLAGS_INTR 0x00000001 /* nws_intr_event */ + +/* + * Finally, a per-workstream-per-protocol structure, exported as + * net.isr.work. + */ +struct sysctl_netisr_work { + u_int snw_version; /* Length of struct. */ + u_int snw_wsid; /* Workstream ID. */ + u_int snw_proto; /* Protocol number. */ + u_int snw_len; /* nw_len */ + u_int snw_watermark; /* nw_watermark */ + u_int _snw_ispare[3]; + + uint64_t snw_dispatched; /* nw_dispatched */ + uint64_t snw_hybrid_dispatched; /* nw_hybrid_dispatched */ + uint64_t snw_qdrops; /* nw_qdrops */ + uint64_t snw_queued; /* nw_queued */ + uint64_t snw_handled; /* nw_handled */ + + uint64_t _snw_llspare[7]; +}; + +#ifdef _KERNEL + /*- * Protocols express ordering constraints and affinity preferences by * implementing one or neither of nh_m2flow and nh_m2cpuid, which are used by @@ -91,10 +173,6 @@ typedef struct mbuf *netisr_m2cpuid_t(st typedef struct mbuf *netisr_m2flow_t(struct mbuf *m, uintptr_t source); typedef void netisr_drainedcpu_t(u_int cpuid); -#define NETISR_POLICY_SOURCE 1 /* Maintain source ordering. */ -#define NETISR_POLICY_FLOW 2 /* Maintain flow ordering. */ -#define NETISR_POLICY_CPU 3 /* Protocol determines CPU placement. */ - /* * Data structure describing a protocol handler. */ From owner-svn-src-stable@FreeBSD.ORG Sat Jan 15 18:51:45 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 825B0106564A; Sat, 15 Jan 2011 18:51:45 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6EE578FC1B; Sat, 15 Jan 2011 18:51: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 p0FIpjdd033607; Sat, 15 Jan 2011 18:51:45 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0FIpjPU033601; Sat, 15 Jan 2011 18:51:45 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201101151851.p0FIpjPU033601@svn.freebsd.org> From: Robert Watson Date: Sat, 15 Jan 2011 18:51:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217446 - stable/8/usr.bin/netstat X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2011 18:51:45 -0000 Author: rwatson Date: Sat Jan 15 18:51:45 2011 New Revision: 217446 URL: http://svn.freebsd.org/changeset/base/217446 Log: Merge r204202 from head to stable/8: Teach netstat(1) to print out netisr statistics when given the -Q argument. Currently supports only reporting on live systems via sysctl, kmem support needs to be edded. Sponsored by: Juniper Networks Added: stable/8/usr.bin/netstat/netisr.c - copied unchanged from r204202, head/usr.bin/netstat/netisr.c Modified: stable/8/usr.bin/netstat/Makefile stable/8/usr.bin/netstat/main.c stable/8/usr.bin/netstat/netstat.1 stable/8/usr.bin/netstat/netstat.h Directory Properties: stable/8/usr.bin/netstat/ (props changed) Modified: stable/8/usr.bin/netstat/Makefile ============================================================================== --- stable/8/usr.bin/netstat/Makefile Sat Jan 15 18:41:42 2011 (r217445) +++ stable/8/usr.bin/netstat/Makefile Sat Jan 15 18:51:45 2011 (r217446) @@ -4,7 +4,7 @@ .include PROG= netstat -SRCS= if.c inet.c main.c mbuf.c mroute.c route.c \ +SRCS= if.c inet.c main.c mbuf.c mroute.c netisr.c route.c \ unix.c atalk.c mroute6.c ipsec.c bpf.c pfkey.c sctp.c WARNS?= 3 Modified: stable/8/usr.bin/netstat/main.c ============================================================================== --- stable/8/usr.bin/netstat/main.c Sat Jan 15 18:41:42 2011 (r217445) +++ stable/8/usr.bin/netstat/main.c Sat Jan 15 18:51:45 2011 (r217446) @@ -336,6 +336,7 @@ int noutputs = 0; /* how much outputs be int numeric_addr; /* show addresses numerically */ int numeric_port; /* show ports numerically */ static int pflag; /* show given protocol */ +int Qflag; /* show netisr information */ int rflag; /* show routing tables (or routing stats) */ int sflag; /* show protocol statistics */ int tflag; /* show i/f watchdog timers */ @@ -447,6 +448,9 @@ main(int argc, char *argv[]) } pflag = 1; break; + case 'Q': + Qflag = 1; + break; case 'q': noutputs = atoi(optarg); if (noutputs != 0) @@ -534,6 +538,12 @@ main(int argc, char *argv[]) mbpr(NULL, 0); exit(0); } + if (Qflag) { + if (!live) + usage(); + netisr_stats(); + exit(0); + } #if 0 /* * Keep file descriptors open to avoid overhead @@ -789,7 +799,7 @@ name2protox(const char *name) static void usage(void) { - (void)fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", + (void)fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", "usage: netstat [-AaLnSTWx] [-f protocol_family | -p protocol]\n" " [-M core] [-N system]", " netstat -i | -I interface [-abdhntW] [-f address_family]\n" @@ -804,6 +814,7 @@ usage(void) " netstat -r [-AanW] [-f address_family] [-M core] [-N system]", " netstat -rs [-s] [-M core] [-N system]", " netstat -g [-W] [-f address_family] [-M core] [-N system]", -" netstat -gs [-s] [-f address_family] [-M core] [-N system]"); +" netstat -gs [-s] [-f address_family] [-M core] [-N system]", +" netstat -Q"); exit(1); } Copied: stable/8/usr.bin/netstat/netisr.c (from r204202, head/usr.bin/netstat/netisr.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/usr.bin/netstat/netisr.c Sat Jan 15 18:51:45 2011 (r217446, copy of r204202, head/usr.bin/netstat/netisr.c) @@ -0,0 +1,268 @@ +/*- + * Copyright (c) 2010 Juniper Networks, Inc. + * All rights reserved. + * + * This software was developed by Robert N. M. Watson under contract + * to Juniper Networks, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +__FBSDID("$FreeBSD$"); + +#include +#include + +#include + +#include +#include +#include +#include + +#include "netstat.h" + +/* + * Print statistics for the kernel netisr subsystem. + */ +static u_int bindthreads; +static u_int maxthreads; +static u_int numthreads; + +static u_int defaultqlimit; +static u_int maxqlimit; + +static u_int direct; +static u_int direct_force; + +static struct sysctl_netisr_proto *proto_array; +static u_int proto_array_len; + +static struct sysctl_netisr_workstream *workstream_array; +static u_int workstream_array_len; + +static struct sysctl_netisr_work *work_array; +static u_int work_array_len; + +static void +netisr_load_sysctl_uint(const char *name, u_int *p) +{ + size_t retlen; + + retlen = sizeof(u_int); + if (sysctlbyname(name, p, &retlen, NULL, 0) < 0) + err(-1, "%s", name); + if (retlen != sizeof(u_int)) + errx(-1, "%s: invalid len %ju", name, (uintmax_t)retlen); +} + +static void +netisr_load_config(void) +{ + + netisr_load_sysctl_uint("net.isr.bindthreads", &bindthreads); + netisr_load_sysctl_uint("net.isr.maxthreads", &maxthreads); + netisr_load_sysctl_uint("net.isr.numthreads", &numthreads); + + netisr_load_sysctl_uint("net.isr.defaultqlimit", &defaultqlimit); + netisr_load_sysctl_uint("net.isr.maxqlimit", &maxqlimit); + + netisr_load_sysctl_uint("net.isr.direct", &direct); + netisr_load_sysctl_uint("net.isr.direct_force", &direct_force); +} + +static void +netisr_load_proto(void) +{ + size_t len; + + if (sysctlbyname("net.isr.proto", NULL, &len, NULL, 0) < 0) + err(-1, "net.isr.proto: query len"); + if (len % sizeof(*proto_array) != 0) + errx(-1, "net.isr.proto: invalid len"); + proto_array = malloc(len); + if (proto_array == NULL) + err(-1, "malloc"); + if (sysctlbyname("net.isr.proto", proto_array, &len, NULL, 0) < 0) + err(-1, "net.isr.proto: query data"); + if (len % sizeof(*proto_array) != 0) + errx(-1, "net.isr.proto: invalid len"); + proto_array_len = len / sizeof(*proto_array); + if (proto_array_len < 1) + errx(-1, "net.isr.proto: no data"); + if (proto_array[0].snp_version != sizeof(proto_array[0])) + errx(-1, "net.isr.proto: invalid version"); +} + +static void +netisr_load_workstream(void) +{ + size_t len; + + if (sysctlbyname("net.isr.workstream", NULL, &len, NULL, 0) < 0) + err(-1, "net.isr.workstream: query len"); + if (len % sizeof(*workstream_array) != 0) + errx(-1, "net.isr.workstream: invalid len"); + workstream_array = malloc(len); + if (workstream_array == NULL) + err(-1, "malloc"); + if (sysctlbyname("net.isr.workstream", workstream_array, &len, NULL, + 0) < 0) + err(-1, "net.isr.workstream: query data"); + if (len % sizeof(*workstream_array) != 0) + errx(-1, "net.isr.workstream: invalid len"); + workstream_array_len = len / sizeof(*workstream_array); + if (workstream_array_len < 1) + errx(-1, "net.isr.workstream: no data"); + if (workstream_array[0].snws_version != sizeof(workstream_array[0])) + errx(-1, "net.isr.workstream: invalid version"); +} + +static void +netisr_load_work(void) +{ + size_t len; + + if (sysctlbyname("net.isr.work", NULL, &len, NULL, 0) < 0) + err(-1, "net.isr.work: query len"); + if (len % sizeof(*work_array) != 0) + errx(-1, "net.isr.work: invalid len"); + work_array = malloc(len); + if (work_array == NULL) + err(-1, "malloc"); + if (sysctlbyname("net.isr.work", work_array, &len, NULL, 0) < 0) + err(-1, "net.isr.work: query data"); + if (len % sizeof(*work_array) != 0) + errx(-1, "net.isr.work: invalid len"); + work_array_len = len / sizeof(*work_array); + if (work_array_len < 1) + errx(-1, "net.isr.work: no data"); + if (work_array[0].snw_version != sizeof(work_array[0])) + errx(-1, "net.isr.work: invalid version"); +} + +static void +netisr_print_proto(struct sysctl_netisr_proto *snpp) +{ + + printf("%-6s", snpp->snp_name); + printf(" %5u", snpp->snp_proto); + printf(" %6u", snpp->snp_qlimit); + printf(" %6s", + (snpp->snp_policy == NETISR_POLICY_SOURCE) ? "source" : + (snpp->snp_policy == NETISR_POLICY_FLOW) ? "flow" : + (snpp->snp_policy == NETISR_POLICY_CPU) ? "cpu" : "-"); + printf(" %s%s%s\n", + (snpp->snp_flags & NETISR_SNP_FLAGS_M2CPUID) ? "C" : "-", + (snpp->snp_flags & NETISR_SNP_FLAGS_DRAINEDCPU) ? "D" : "-", + (snpp->snp_flags & NETISR_SNP_FLAGS_M2FLOW) ? "F" : "-"); +} + +static const char * +netisr_proto2name(u_int proto) +{ + u_int i; + + for (i = 0; i < proto_array_len; i++) { + if (proto_array[i].snp_proto == proto) + return (proto_array[i].snp_name); + } + return ("unknown"); +} + +static void +netisr_print_workstream(struct sysctl_netisr_workstream *snwsp) +{ + struct sysctl_netisr_work *snwp; + int first; + u_int i; + + first = 1; + for (i = 0; i < work_array_len; i++) { + snwp = &work_array[i]; + if (snwp->snw_wsid != snwsp->snws_wsid) + continue; + if (first) { + printf("%4u", snwsp->snws_wsid); + printf(" %3u", snwsp->snws_cpu); + first = 0; + } else + printf("%4s %3s", "", ""); + printf("%2s", ""); + printf("%-6s", netisr_proto2name(snwp->snw_proto)); + printf(" %5u", snwp->snw_len); + printf(" %5u", snwp->snw_watermark); + printf(" %8ju", snwp->snw_dispatched); + printf(" %8ju", snwp->snw_hybrid_dispatched); + printf(" %8ju", snwp->snw_qdrops); + printf(" %8ju", snwp->snw_queued); + printf(" %8ju", snwp->snw_handled); + printf("\n"); + } +} + +void +netisr_stats(void) +{ + struct sysctl_netisr_workstream *snwsp; + struct sysctl_netisr_proto *snpp; + u_int i; + + netisr_load_config(); + netisr_load_proto(); + netisr_load_workstream(); + netisr_load_work(); + + printf("Configuration:\n"); + printf("%-25s %12s %12s\n", "Setting", "Value", "Maximum"); + printf("%-25s %12u %12u\n", "Thread count", numthreads, maxthreads); + printf("%-25s %12u %12u\n", "Default queue limit", defaultqlimit, + maxqlimit); + printf("%-25s %12s %12s\n", "Direct dispatch", + direct ? "enabled" : "disabled", "n/a"); + printf("%-25s %12s %12s\n", "Forced direct dispatch", + direct_force ? "enabled" : "disabled", "n/a"); + printf("%-25s %12s %12s\n", "Threads bound to CPUs", + bindthreads ? "enabled" : "disabled", "n/a"); + printf("\n"); + + printf("Protocols:\n"); + printf("%-6s %5s %6s %-6s %-5s\n", "Name", "Proto", "QLimit", + "Policy", "Flags"); + for (i = 0; i < proto_array_len; i++) { + snpp = &proto_array[i]; + netisr_print_proto(snpp); + } + printf("\n"); + + printf("Workstreams:\n"); + printf("%4s %3s ", "WSID", "CPU"); + printf("%2s", ""); + printf("%-6s %5s %5s %8s %8s %8s %8s %8s\n", "Name", "Len", "WMark", + "Disp'd", "HDisp'd", "QDrops", "Queued", "Handled"); + for (i = 0; i < workstream_array_len; i++) { + snwsp = &workstream_array[i]; + netisr_print_workstream(snwsp); + } +} Modified: stable/8/usr.bin/netstat/netstat.1 ============================================================================== --- stable/8/usr.bin/netstat/netstat.1 Sat Jan 15 18:41:42 2011 (r217445) +++ stable/8/usr.bin/netstat/netstat.1 Sat Jan 15 18:51:45 2011 (r217446) @@ -299,6 +299,15 @@ Show multicast routing statistics. If .Fl s is repeated, counters with a value of zero are suppressed. +.It Xo +.Bk -words +.Nm +.Fl Q +.Ek +.Xc +Show +.Xr netisr 9 +statistics. .El .Pp Some options have the general meaning: Modified: stable/8/usr.bin/netstat/netstat.h ============================================================================== --- stable/8/usr.bin/netstat/netstat.h Sat Jan 15 18:41:42 2011 (r217445) +++ stable/8/usr.bin/netstat/netstat.h Sat Jan 15 18:51:45 2011 (r217446) @@ -69,6 +69,9 @@ const char *plural(uintmax_t); const char *plurales(uintmax_t); const char *pluralies(uintmax_t); +struct sockaddr; +struct socket; +struct xsocket; int sotoxsocket(struct socket *, struct xsocket *); void protopr(u_long, const char *, int, int); void tcp_stats(u_long, const char *, int, int); @@ -114,6 +117,8 @@ void pfkey_stats(u_long, const char *, i void mbpr(void *, u_long); +void netisr_stats(void); + void hostpr(u_long, u_long); void impstats(u_long, u_long); From owner-svn-src-stable@FreeBSD.ORG Sat Jan 15 18:56:51 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D0B91106566C; Sat, 15 Jan 2011 18:56:51 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BF0D48FC17; Sat, 15 Jan 2011 18:56: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 p0FIupKt033777; Sat, 15 Jan 2011 18:56:51 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0FIupcE033775; Sat, 15 Jan 2011 18:56:51 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201101151856.p0FIupcE033775@svn.freebsd.org> From: Robert Watson Date: Sat, 15 Jan 2011 18:56:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217447 - stable/8/share/man/man9 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2011 18:56:51 -0000 Author: rwatson Date: Sat Jan 15 18:56:51 2011 New Revision: 217447 URL: http://svn.freebsd.org/changeset/base/217447 Log: Merge r204206 from head to stable/8: Cross-reference netstat(1) from netisr(9) since you can now use it to monitor netisr status. Sponsored by: Juniper Networks Modified: stable/8/share/man/man9/netisr.9 Directory Properties: stable/8/share/man/man9/ (props changed) Modified: stable/8/share/man/man9/netisr.9 ============================================================================== --- stable/8/share/man/man9/netisr.9 Sat Jan 15 18:51:45 2011 (r217446) +++ stable/8/share/man/man9/netisr.9 Sat Jan 15 18:56:51 2011 (r217447) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 26, 2009 +.Dd February 22, 2010 .Dt NETISR 9 .Os .Sh NAME @@ -66,6 +66,8 @@ The .Nm kernel interface suite allows device drivers (and other packet sources) to direct packets to protocols for directly dispatched or deferred processing. +Protocol registration and work stream statistics may be monitored using +.Xr netstat 1 . .Ss Protocol registration Protocols register and unregister handlers using .Fn netisr_register @@ -209,6 +211,7 @@ IPv6 .It Dv NETISR_NATM ATM .It Dv NETISR_EPAIR +.Xr netstat 1 , .Xr epair 4 .El .Sh AUTHORS From owner-svn-src-stable@FreeBSD.ORG Sat Jan 15 19:00:23 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 64AFD106566B; Sat, 15 Jan 2011 19:00:23 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 38F5A8FC12; Sat, 15 Jan 2011 19:00: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 p0FJ0NDL033947; Sat, 15 Jan 2011 19:00:23 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0FJ0NO8033946; Sat, 15 Jan 2011 19:00:23 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201101151900.p0FJ0NO8033946@svn.freebsd.org> From: Robert Watson Date: Sat, 15 Jan 2011 19:00:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217448 - stable/8/usr.bin/netstat X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2011 19:00:23 -0000 Author: rwatson Date: Sat Jan 15 19:00:22 2011 New Revision: 217448 URL: http://svn.freebsd.org/changeset/base/217448 Log: Merge mergeinfo only for r204207 from head to stable/8; the edit itself was apparently merged as part of a separate change: Update date on netstat(1) for -Q. Suggested by: bz Modified: Directory Properties: stable/8/usr.bin/netstat/ (props changed) From owner-svn-src-stable@FreeBSD.ORG Sat Jan 15 19:02:09 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4EE9F106564A; Sat, 15 Jan 2011 19:02:09 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3DD408FC15; Sat, 15 Jan 2011 19:02:09 +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 p0FJ29D4034033; Sat, 15 Jan 2011 19:02:09 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0FJ29XM034031; Sat, 15 Jan 2011 19:02:09 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201101151902.p0FJ29XM034031@svn.freebsd.org> From: Robert Watson Date: Sat, 15 Jan 2011 19:02:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217449 - stable/8/sys/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2011 19:02:09 -0000 Author: rwatson Date: Sat Jan 15 19:02:08 2011 New Revision: 217449 URL: http://svn.freebsd.org/changeset/base/217449 Log: Merge r204208 from head to stable/8: Fix constant assignment for netisr protocol information sysctl. Spotted by: bz Modified: stable/8/sys/net/netisr.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/net/netisr.h ============================================================================== --- stable/8/sys/net/netisr.h Sat Jan 15 19:00:22 2011 (r217448) +++ stable/8/sys/net/netisr.h Sat Jan 15 19:02:08 2011 (r217449) @@ -92,7 +92,7 @@ struct sysctl_netisr_proto { */ #define NETISR_SNP_FLAGS_M2FLOW 0x00000001 /* nh_m2flow */ #define NETISR_SNP_FLAGS_M2CPUID 0x00000002 /* nh_m2cpuid */ -#define NETISR_SNP_FLAGS_DRAINEDCPU 0x00000003 /* nh_drainedcpu */ +#define NETISR_SNP_FLAGS_DRAINEDCPU 0x00000004 /* nh_drainedcpu */ /* * Next, a structure per-workstream, with per-protocol data, exported as From owner-svn-src-stable@FreeBSD.ORG Sat Jan 15 19:05:06 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DBD731065670; Sat, 15 Jan 2011 19:05:06 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AB9508FC1E; Sat, 15 Jan 2011 19:05: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 p0FJ56iV034149; Sat, 15 Jan 2011 19:05:06 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0FJ56AE034148; Sat, 15 Jan 2011 19:05:06 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201101151905.p0FJ56AE034148@svn.freebsd.org> From: Robert Watson Date: Sat, 15 Jan 2011 19:05:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217450 - stable/8/sys/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2011 19:05:07 -0000 Author: rwatson Date: Sat Jan 15 19:05:06 2011 New Revision: 217450 URL: http://svn.freebsd.org/changeset/base/217450 Log: Merge r204303 from head to stable/8: Fix edge cases in several KASSERTs: use <= rather than < when testing that counters have not gone about MAXCPU or NETISR_MAXPROT. These problems caused panics on UP kernels with INVARIANTS when using sysctl -a, but would also have caused problems for 32-core boxes or if the netisr protocol vector was fully populated. Reported by: nwhitehorn, Neel Natu Modified: stable/8/sys/net/netisr.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/net/netisr.c ============================================================================== --- stable/8/sys/net/netisr.c Sat Jan 15 19:02:08 2011 (r217449) +++ stable/8/sys/net/netisr.c Sat Jan 15 19:05:06 2011 (r217450) @@ -1159,7 +1159,7 @@ sysctl_netisr_proto(SYSCTL_HANDLER_ARGS) counter++; } NETISR_RUNLOCK(&tracker); - KASSERT(counter < NETISR_MAXPROT, + KASSERT(counter <= NETISR_MAXPROT, ("sysctl_netisr_proto: counter too big (%d)", counter)); error = SYSCTL_OUT(req, snp_array, sizeof(*snp_array) * counter); free(snp_array, M_TEMP); @@ -1212,7 +1212,7 @@ sysctl_netisr_workstream(SYSCTL_HANDLER_ counter++; } NETISR_RUNLOCK(&tracker); - KASSERT(counter < MAXCPU, + KASSERT(counter <= MAXCPU, ("sysctl_netisr_workstream: counter too big (%d)", counter)); error = SYSCTL_OUT(req, snws_array, sizeof(*snws_array) * counter); free(snws_array, M_TEMP); @@ -1273,7 +1273,7 @@ sysctl_netisr_work(SYSCTL_HANDLER_ARGS) } NWS_UNLOCK(nwsp); } - KASSERT(counter < MAXCPU * NETISR_MAXPROT, + KASSERT(counter <= MAXCPU * NETISR_MAXPROT, ("sysctl_netisr_work: counter too big (%d)", counter)); NETISR_RUNLOCK(&tracker); error = SYSCTL_OUT(req, snw_array, sizeof(*snw_array) * counter); From owner-svn-src-stable@FreeBSD.ORG Sat Jan 15 19:23:15 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 114B51065673; Sat, 15 Jan 2011 19:23:15 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F2AA28FC15; Sat, 15 Jan 2011 19:23: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 p0FJNEke034733; Sat, 15 Jan 2011 19:23:14 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0FJNElv034726; Sat, 15 Jan 2011 19:23:14 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201101151923.p0FJNElv034726@svn.freebsd.org> From: Robert Watson Date: Sat, 15 Jan 2011 19:23:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217454 - stable/8/lib/libkvm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2011 19:23:15 -0000 Author: rwatson Date: Sat Jan 15 19:23:14 2011 New Revision: 217454 URL: http://svn.freebsd.org/changeset/base/217454 Log: Merge r204494, r204511 from head to stable/8: A first cut at teaching libkvm how to deal with dynamic per-CPU storage (DPCPU): A new API, kvm_dpcpu_setcpu(3), selects the active CPU for the purposes of DPCPU. Calls to kvm_nlist(3) will automatically translate DPCPU symbols and return a pointer to the current CPU's version of the data. Consumers needing to read the same symbol on several CPUs will invoke a series of setcpu/nlist calls, one per CPU of interest. This addition makes it possible for tools like netstat(1) to query the values of DPCPU variables during crashdump analysis, and is based on similar code handling virtualized global variables. Sponsored by: Juniper Networks, Inc. Not all programs including kvm.h include the necessary headers to use u_int, so prefer unsigned int. Pointed out by: bz, kib, Mr Tinderbox Modified: stable/8/lib/libkvm/Makefile stable/8/lib/libkvm/kvm.c stable/8/lib/libkvm/kvm.h stable/8/lib/libkvm/kvm_getpcpu.3 stable/8/lib/libkvm/kvm_pcpu.c stable/8/lib/libkvm/kvm_private.h Directory Properties: stable/8/lib/libkvm/ (props changed) Modified: stable/8/lib/libkvm/Makefile ============================================================================== --- stable/8/lib/libkvm/Makefile Sat Jan 15 19:21:28 2011 (r217453) +++ stable/8/lib/libkvm/Makefile Sat Jan 15 19:23:14 2011 (r217454) @@ -21,6 +21,7 @@ MAN= kvm.3 kvm_getcptime.3 kvm_geterr.3 kvm_read.3 MLINKS+=kvm_getpcpu.3 kvm_getmaxcpu.3 +MLINKS+=kvm_getpcpu.3 kvm_dpcpu_setcpu.3 MLINKS+=kvm_getprocs.3 kvm_getargv.3 kvm_getprocs.3 kvm_getenvv.3 MLINKS+=kvm_open.3 kvm_close.3 kvm_open.3 kvm_openfiles.3 MLINKS+=kvm_read.3 kvm_write.3 Modified: stable/8/lib/libkvm/kvm.c ============================================================================== --- stable/8/lib/libkvm/kvm.c Sat Jan 15 19:21:28 2011 (r217453) +++ stable/8/lib/libkvm/kvm.c Sat Jan 15 19:23:14 2011 (r217454) @@ -416,6 +416,8 @@ _kvm_nlist(kvm_t *kd, struct nlist *nl, struct kld_sym_lookup lookup; int error; char *prefix = "", symname[1024]; /* XXX-BZ symbol name length limit? */ + int tried_vnet, tried_dpcpu; + /* * If we can't use the kld symbol lookup, revert to the * slow library call. @@ -429,6 +431,10 @@ _kvm_nlist(kvm_t *kd, struct nlist *nl, error = kvm_fdnlist_prefix(kd, nl, error, VNET_SYMPREFIX, _kvm_vnet_validaddr); + if (error > 0 && _kvm_dpcpu_initialized(kd, initialize)) + error = kvm_fdnlist_prefix(kd, nl, error, + "pcpu_entry_", _kvm_dpcpu_validaddr); + return (error); } @@ -437,6 +443,8 @@ _kvm_nlist(kvm_t *kd, struct nlist *nl, * and look it up with a kldsym(2) syscall. */ nvalid = 0; + tried_vnet = 0; + tried_dpcpu = 0; again: for (p = nl; p->n_name && p->n_name[0]; ++p) { if (p->n_type != N_UNDF) @@ -464,6 +472,10 @@ again: !strcmp(prefix, VNET_SYMPREFIX)) p->n_value = _kvm_vnet_validaddr(kd, lookup.symvalue); + else if (_kvm_dpcpu_initialized(kd, initialize) && + !strcmp(prefix, "pcpu_entry_")) + p->n_value = + _kvm_dpcpu_validaddr(kd, lookup.symvalue); else p->n_value = lookup.symvalue; ++nvalid; @@ -473,14 +485,19 @@ again: /* * Check the number of entries that weren't found. If they exist, - * try again with a prefix for virtualized symbol names. + * try again with a prefix for virtualized or DPCPU symbol names. */ error = ((p - nl) - nvalid); - if (error && _kvm_vnet_initialized(kd, initialize) && - strcmp(prefix, VNET_SYMPREFIX)) { + if (error && _kvm_vnet_initialized(kd, initialize) && !tried_vnet) { + tried_vnet = 1; prefix = VNET_SYMPREFIX; goto again; } + if (error && _kvm_dpcpu_initialized(kd, initialize) && !tried_dpcpu) { + tried_dpcpu = 1; + prefix = "pcpu_entry_"; + goto again; + } /* * Return the number of entries that weren't found. If they exist, Modified: stable/8/lib/libkvm/kvm.h ============================================================================== --- stable/8/lib/libkvm/kvm.h Sat Jan 15 19:21:28 2011 (r217453) +++ stable/8/lib/libkvm/kvm.h Sat Jan 15 19:23:14 2011 (r217454) @@ -69,6 +69,7 @@ struct kvm_swap { __BEGIN_DECLS int kvm_close(kvm_t *); +int kvm_dpcpu_setcpu(kvm_t *, unsigned int); char **kvm_getargv(kvm_t *, const struct kinfo_proc *, int); int kvm_getcptime(kvm_t *, long *); char **kvm_getenvv(kvm_t *, const struct kinfo_proc *, int); Modified: stable/8/lib/libkvm/kvm_getpcpu.3 ============================================================================== --- stable/8/lib/libkvm/kvm_getpcpu.3 Sat Jan 15 19:21:28 2011 (r217453) +++ stable/8/lib/libkvm/kvm_getpcpu.3 Sat Jan 15 19:23:14 2011 (r217454) @@ -28,10 +28,11 @@ .\" .\" $FreeBSD$ .\" -.Dd August 19, 2008 +.Dd February 28, 2010 .Dt KVM_GETPCPU 3 .Os .Sh NAME +.Nm kvm_dpcpu_setcpu .Nm kvm_getmaxcpu , .Nm kvm_getpcpu .Nd access per-CPU data @@ -43,20 +44,30 @@ .In sys/sysctl.h .In kvm.h .Ft int +.Fn kvm_dpcpu_setcpu "kvm_t *kd" "u_int cpu" +.Ft int .Fn kvm_getmaxcpu "kvm_t *kd" .Ft void * .Fn kvm_getpcpu "kvm_t *kd" "int cpu" .Sh DESCRIPTION The -.Fn kvm_getmaxcpu +.Fn kvm_dpcpu_setcpu , +.Fn kvm_getmaxcpu , and .Fn kvm_getpcpu functions are used to access the per-CPU data of active processors in the kernel indicated by .Fa kd . +Per-CPU storage comes in two flavours: data stored directly in a +.Vt "struct pcpu" +associated with each CPU, and dynamic per-CPU storage (DPCPU), in which a +single kernel symbol refers to different data depending on what CPU it is +accessed from. +.Pp The .Fn kvm_getmaxcpu function returns the maximum number of CPUs supported by the kernel. +.Pp The .Fn kvm_getpcpu function returns a buffer holding the per-CPU data for a single CPU. @@ -71,8 +82,22 @@ If is not active, then .Dv NULL is returned instead. +.Pp +Symbols for dynamic per-CPU data are accessed via +.Xr kvm_nlist 3 +as with other symbols. +.Nm libkvm +maintains a notion of the "current CPU", set by +.Xr kvm_dpcpu_setcpu , +which defaults to 0. +Once another CPU is selected, +.Xr kvm_nlist 3 +will return pointers to that data on the appropriate CPU. .Sh CACHING -These functions cache the nlist values for various kernel variables which are +.Fn kvm_getmaxcpu +and +.Vn kvm_getpcpu +cache the nlist values for various kernel variables which are reused in successive calls. You may call either function with .Fa kd @@ -93,7 +118,11 @@ function returns a pointer to an allocat If an error occurs, it returns -1 instead. .Pp -If either function encounters an error, +On success, the +.Fn kvm_dpcpu_setcpu +call returns 0; if an error occurs, it returns -1 instead. +.Pp +If any function encounters an error, then an error message may be retrieved via .Xr kvm_geterr 3. .Sh SEE ALSO Modified: stable/8/lib/libkvm/kvm_pcpu.c ============================================================================== --- stable/8/lib/libkvm/kvm_pcpu.c Sat Jan 15 19:21:28 2011 (r217453) +++ stable/8/lib/libkvm/kvm_pcpu.c Sat Jan 15 19:23:14 2011 (r217454) @@ -1,8 +1,15 @@ /*- + * Copyright (c) 2010 Juniper Networks, Inc. + * Copyright (c) 2009 Robert N. M. Watson + * Copyright (c) 2009 Bjoern A. Zeeb * Copyright (c) 2008 Yahoo!, Inc. * All rights reserved. + * * Written by: John Baldwin * + * This software was developed by Robert N. M. Watson under contract + * to Juniper Networks, Inc. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -49,6 +56,10 @@ static struct nlist kvm_pcpu_nl[] = { /* * Kernel per-CPU data state. We cache this stuff on the first * access. + * + * XXXRW: Possibly, this (and kvmpcpu_nl) should be per-kvm_t, in case the + * consumer has multiple handles in flight to differently configured + * kernels/crashdumps. */ static void **pcpu_data; static int maxcpu; @@ -150,3 +161,132 @@ kvm_getmaxcpu(kvm_t *kd) return (-1); return (maxcpu); } + +static int +_kvm_dpcpu_setcpu(kvm_t *kd, u_int cpu, int report_error) +{ + + if (!kd->dpcpu_initialized) { + if (report_error) + _kvm_err(kd, kd->program, "%s: not initialized", + __func__); + return (-1); + } + if (cpu >= kd->dpcpu_maxcpus) { + if (report_error) + _kvm_err(kd, kd->program, "%s: CPU %u too big", + __func__, cpu); + return (-1); + } + if (kd->dpcpu_off[cpu] == 0) { + if (report_error) + _kvm_err(kd, kd->program, "%s: CPU %u not found", + __func__, cpu); + return (-1); + } + kd->dpcpu_curcpu = cpu; + kd->dpcpu_curoff = kd->dpcpu_off[cpu]; + return (0); +} + +/* + * Set up libkvm to handle dynamic per-CPU memory. + */ +static int +_kvm_dpcpu_init(kvm_t *kd) +{ + struct nlist nl[] = { +#define NLIST_START_SET_PCPU 0 + { "___start_set_pcpu" }, +#define NLIST_STOP_SET_PCPU 1 + { "___stop_set_pcpu" }, +#define NLIST_DPCPU_OFF 2 + { "_dpcpu_off" }, +#define NLIST_MP_MAXCPUS 3 + { "_mp_maxcpus" }, + { NULL }, + }; + uintptr_t *dpcpu_off_buf; + size_t len; + u_int dpcpu_maxcpus; + + /* + * Locate and cache locations of important symbols using the internal + * version of _kvm_nlist, turning off initialization to avoid + * recursion in case of unresolveable symbols. + */ + if (_kvm_nlist(kd, nl, 0) != 0) + return (-1); + if (kvm_read(kd, nl[NLIST_MP_MAXCPUS].n_value, &dpcpu_maxcpus, + sizeof(dpcpu_maxcpus)) != sizeof(dpcpu_maxcpus)) + return (-1); + len = dpcpu_maxcpus * sizeof(*dpcpu_off_buf); + dpcpu_off_buf = malloc(len); + if (dpcpu_off_buf == NULL) + return (-1); + if (kvm_read(kd, nl[NLIST_DPCPU_OFF].n_value, dpcpu_off_buf, len) != + len) { + free(dpcpu_off_buf); + return (-1); + } + kd->dpcpu_start = nl[NLIST_START_SET_PCPU].n_value; + kd->dpcpu_stop = nl[NLIST_STOP_SET_PCPU].n_value; + kd->dpcpu_maxcpus = dpcpu_maxcpus; + kd->dpcpu_off = dpcpu_off_buf; + kd->dpcpu_initialized = 1; + (void)_kvm_dpcpu_setcpu(kd, 0, 0); + return (0); +} + +/* + * Check whether the dpcpu module has been initialized sucessfully or not, + * initialize it if permitted. + */ +int +_kvm_dpcpu_initialized(kvm_t *kd, int intialize) +{ + + if (kd->dpcpu_initialized || !intialize) + return (kd->dpcpu_initialized); + + (void)_kvm_dpcpu_init(kd); + + return (kd->dpcpu_initialized); +} + +/* + * Check whether the value is within the dpcpu symbol range and only if so + * adjust the offset relative to the current offset. + */ +uintptr_t +_kvm_dpcpu_validaddr(kvm_t *kd, uintptr_t value) +{ + + if (value == 0) + return (value); + + if (!kd->dpcpu_initialized) + return (value); + + if (value < kd->dpcpu_start || value >= kd->dpcpu_stop) + return (value); + + return (kd->dpcpu_curoff + value); +} + +int +kvm_dpcpu_setcpu(kvm_t *kd, u_int cpu) +{ + int ret; + + if (!kd->dpcpu_initialized) { + ret = _kvm_dpcpu_init(kd); + if (ret != 0) { + _kvm_err(kd, kd->program, "%s: init failed", + __func__); + return (ret); + } + } + + return (_kvm_dpcpu_setcpu(kd, cpu, 1)); +} Modified: stable/8/lib/libkvm/kvm_private.h ============================================================================== --- stable/8/lib/libkvm/kvm_private.h Sat Jan 15 19:21:28 2011 (r217453) +++ stable/8/lib/libkvm/kvm_private.h Sat Jan 15 19:23:14 2011 (r217454) @@ -68,6 +68,19 @@ struct __kvm { uintptr_t vnet_stop; /* stop of kernel's vnet region */ uintptr_t vnet_current; /* vnet we're working with */ uintptr_t vnet_base; /* vnet base of current vnet */ + + /* + * Dynamic per-CPU kernel memory. We translate symbols, on-demand, + * to the data associated with dpcpu_curcpu, set with + * kvm_dpcpu_setcpu(). + */ + int dpcpu_initialized; /* dpcpu fields set up */ + uintptr_t dpcpu_start; /* start of kernel's dpcpu region */ + uintptr_t dpcpu_stop; /* stop of kernel's dpcpu region */ + u_int dpcpu_maxcpus; /* size of base array */ + uintptr_t *dpcpu_off; /* base array, indexed by CPU ID */ + u_int dpcpu_curcpu; /* CPU we're currently working with */ + uintptr_t dpcpu_curoff; /* dpcpu base of current CPU */ }; /* @@ -88,6 +101,8 @@ int _kvm_uvatop(kvm_t *, const struct p int _kvm_vnet_selectpid(kvm_t *, pid_t); int _kvm_vnet_initialized(kvm_t *, int); uintptr_t _kvm_vnet_validaddr(kvm_t *, uintptr_t); +int _kvm_dpcpu_initialized(kvm_t *, int); +uintptr_t _kvm_dpcpu_validaddr(kvm_t *, uintptr_t); #if defined(__amd64__) || defined(__i386__) || defined(__arm__) void _kvm_minidump_freevtop(kvm_t *); From owner-svn-src-stable@FreeBSD.ORG Sat Jan 15 19:27:23 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5A9F61065672; Sat, 15 Jan 2011 19:27:23 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2EAEC8FC13; Sat, 15 Jan 2011 19:27: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 p0FJRN7e034892; Sat, 15 Jan 2011 19:27:23 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0FJRNtT034890; Sat, 15 Jan 2011 19:27:23 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201101151927.p0FJRNtT034890@svn.freebsd.org> From: Robert Watson Date: Sat, 15 Jan 2011 19:27:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217455 - stable/8/sys/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2011 19:27:23 -0000 Author: rwatson Date: Sat Jan 15 19:27:22 2011 New Revision: 217455 URL: http://svn.freebsd.org/changeset/base/217455 Log: Merge r203913 from head to stable/8 (original change by pjd): Mark various sysctls also as tunables. Reviewed by: rwatson Modified: stable/8/sys/net/netisr.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/net/netisr.c ============================================================================== --- stable/8/sys/net/netisr.c Sat Jan 15 19:23:14 2011 (r217454) +++ stable/8/sys/net/netisr.c Sat Jan 15 19:27:22 2011 (r217455) @@ -160,13 +160,13 @@ SYSCTL_INT(_net_isr, OID_AUTO, direct, C */ static int netisr_maxthreads = -1; /* Max number of threads. */ TUNABLE_INT("net.isr.maxthreads", &netisr_maxthreads); -SYSCTL_INT(_net_isr, OID_AUTO, maxthreads, CTLFLAG_RD, +SYSCTL_INT(_net_isr, OID_AUTO, maxthreads, CTLFLAG_RDTUN, &netisr_maxthreads, 0, "Use at most this many CPUs for netisr processing"); static int netisr_bindthreads = 0; /* Bind threads to CPUs. */ TUNABLE_INT("net.isr.bindthreads", &netisr_bindthreads); -SYSCTL_INT(_net_isr, OID_AUTO, bindthreads, CTLFLAG_RD, +SYSCTL_INT(_net_isr, OID_AUTO, bindthreads, CTLFLAG_RDTUN, &netisr_bindthreads, 0, "Bind netisr threads to CPUs."); /* @@ -176,7 +176,7 @@ SYSCTL_INT(_net_isr, OID_AUTO, bindthrea #define NETISR_DEFAULT_MAXQLIMIT 10240 static u_int netisr_maxqlimit = NETISR_DEFAULT_MAXQLIMIT; TUNABLE_INT("net.isr.maxqlimit", &netisr_maxqlimit); -SYSCTL_INT(_net_isr, OID_AUTO, maxqlimit, CTLFLAG_RD, +SYSCTL_INT(_net_isr, OID_AUTO, maxqlimit, CTLFLAG_RDTUN, &netisr_maxqlimit, 0, "Maximum netisr per-protocol, per-CPU queue depth."); @@ -188,7 +188,7 @@ SYSCTL_INT(_net_isr, OID_AUTO, maxqlimit #define NETISR_DEFAULT_DEFAULTQLIMIT 256 static u_int netisr_defaultqlimit = NETISR_DEFAULT_DEFAULTQLIMIT; TUNABLE_INT("net.isr.defaultqlimit", &netisr_defaultqlimit); -SYSCTL_INT(_net_isr, OID_AUTO, defaultqlimit, CTLFLAG_RD, +SYSCTL_INT(_net_isr, OID_AUTO, defaultqlimit, CTLFLAG_RDTUN, &netisr_defaultqlimit, 0, "Default netisr per-protocol, per-CPU queue limit if not set by protocol"); From owner-svn-src-stable@FreeBSD.ORG Sat Jan 15 19:36:48 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2FE64106564A; Sat, 15 Jan 2011 19:36:48 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1D7F68FC13; Sat, 15 Jan 2011 19:36: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 p0FJamG1035167; Sat, 15 Jan 2011 19:36:48 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0FJamxq035165; Sat, 15 Jan 2011 19:36:48 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201101151936.p0FJamxq035165@svn.freebsd.org> From: Robert Watson Date: Sat, 15 Jan 2011 19:36:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217456 - stable/8/sys/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2011 19:36:48 -0000 Author: rwatson Date: Sat Jan 15 19:36:47 2011 New Revision: 217456 URL: http://svn.freebsd.org/changeset/base/217456 Log: Merge from head to stable/8: Refine netisr.c comments a bit. Modified: stable/8/sys/net/netisr.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/net/netisr.c ============================================================================== --- stable/8/sys/net/netisr.c Sat Jan 15 19:27:22 2011 (r217455) +++ stable/8/sys/net/netisr.c Sat Jan 15 19:36:47 2011 (r217456) @@ -36,13 +36,13 @@ __FBSDID("$FreeBSD$"); * dispatched) and asynchronous (deferred dispatch) processing of packets by * registered protocol handlers. Callers pass a protocol identifier and * packet to netisr, along with a direct dispatch hint, and work will either - * be immediately processed with the registered handler, or passed to a - * kernel software interrupt (SWI) thread for deferred dispatch. Callers - * will generally select one or the other based on: + * be immediately processed by the registered handler, or passed to a + * software interrupt (SWI) thread for deferred dispatch. Callers will + * generally select one or the other based on: * - * - Might directly dispatching a netisr handler lead to code reentrance or + * - Whether directly dispatching a netisr handler lead to code reentrance or * lock recursion, such as entering the socket code from the socket code. - * - Might directly dispatching a netisr handler lead to recursive + * - Whether directly dispatching a netisr handler lead to recursive * processing, such as when decapsulating several wrapped layers of tunnel * information (IPSEC within IPSEC within ...). * @@ -58,9 +58,9 @@ __FBSDID("$FreeBSD$"); * more than one flow. * * netisr supports several policy variations, represented by the - * NETISR_POLICY_* constants, allowing protocols to play a varying role in + * NETISR_POLICY_* constants, allowing protocols to play various roles in * identifying flows, assigning work to CPUs, etc. These are described in - * detail in netisr.h. + * netisr.h. */ #include "opt_ddb.h" @@ -105,7 +105,7 @@ __FBSDID("$FreeBSD$"); * * Note: the NETISR_LOCKING define controls whether read locks are acquired * in packet processing paths requiring netisr registration stability. This - * is disabled by default as it can lead to a measurable performance + * is disabled by default as it can lead to measurable performance * degradation even with rmlocks (3%-6% for loopback ping-pong traffic), and * because netisr registration and unregistration is extremely rare at * runtime. If it becomes more common, this decision should be revisited. @@ -170,8 +170,9 @@ SYSCTL_INT(_net_isr, OID_AUTO, bindthrea &netisr_bindthreads, 0, "Bind netisr threads to CPUs."); /* - * Limit per-workstream queues to at most net.isr.maxqlimit, both for initial - * configuration and later modification using netisr_setqlimit(). + * Limit per-workstream mbuf queue limits s to at most net.isr.maxqlimit, + * both for initial configuration and later modification using + * netisr_setqlimit(). */ #define NETISR_DEFAULT_MAXQLIMIT 10240 static u_int netisr_maxqlimit = NETISR_DEFAULT_MAXQLIMIT; @@ -181,9 +182,9 @@ SYSCTL_INT(_net_isr, OID_AUTO, maxqlimit "Maximum netisr per-protocol, per-CPU queue depth."); /* - * The default per-workstream queue limit for protocols that don't initialize - * the nh_qlimit field of their struct netisr_handler. If this is set above - * netisr_maxqlimit, we truncate it to the maximum during boot. + * The default per-workstream mbuf queue limit for protocols that don't + * initialize the nh_qlimit field of their struct netisr_handler. If this is + * set above netisr_maxqlimit, we truncate it to the maximum during boot. */ #define NETISR_DEFAULT_DEFAULTQLIMIT 256 static u_int netisr_defaultqlimit = NETISR_DEFAULT_DEFAULTQLIMIT; @@ -241,12 +242,14 @@ struct netisr_work { }; /* - * Workstreams hold a set of ordered work across each protocol, and are + * Workstreams hold a queue of ordered work across each protocol, and are * described by netisr_workstream. Each workstream is associated with a * worker thread, which in turn is pinned to a CPU. Work associated with a * workstream can be processd in other threads during direct dispatch; * concurrent processing is prevented by the NWS_RUNNING flag, which - * indicates that a thread is already processing the work queue. + * indicates that a thread is already processing the work queue. It is + * important to prevent a directly dispatched packet from "skipping ahead" of + * work already in the workstream queue. */ struct netisr_workstream { struct intr_event *nws_intr_event; /* Handler for stream. */ @@ -321,7 +324,7 @@ netisr_get_cpuid(u_int cpunumber) } /* - * The default implementation of -> CPU ID mapping. + * The default implementation of flow -> CPU ID mapping. * * Non-static so that protocols can use it to map their own work to specific * CPUs in a manner consistent to netisr for affinity purposes. @@ -441,7 +444,7 @@ netisr_clearqdrops(const struct netisr_h } /* - * Query the current drop counters across all workstreams for a protocol. + * Query current drop counters across all workstreams for a protocol. */ void netisr_getqdrops(const struct netisr_handler *nhp, u_int64_t *qdropp) @@ -476,7 +479,7 @@ netisr_getqdrops(const struct netisr_han } /* - * Query the current queue limit for per-workstream queues for a protocol. + * Query current per-workstream queue limit for a protocol. */ void netisr_getqlimit(const struct netisr_handler *nhp, u_int *qlimitp) @@ -730,7 +733,7 @@ netisr_process_workstream_proto(struct n } /* - * SWI handler for netisr -- processes prackets in a set of workstreams that + * SWI handler for netisr -- processes packets in a set of workstreams that * it owns, woken up by calls to NWS_SIGNAL(). If this workstream is already * being direct dispatched, go back to sleep and wait for the dispatching * thread to wake us up again. @@ -798,6 +801,11 @@ netisr_queue_workstream(struct netisr_wo npwp->nw_len++; if (npwp->nw_len > npwp->nw_watermark) npwp->nw_watermark = npwp->nw_len; + + /* + * We must set the bit regardless of NWS_RUNNING, so that + * swi_net() keeps calling netisr_process_workstream_proto(). + */ nwsp->nws_pendingbits |= (1 << proto); if (!(nwsp->nws_flags & (NWS_RUNNING | NWS_DISPATCHING | NWS_SCHEDULED))) { @@ -878,7 +886,7 @@ netisr_queue(u_int proto, struct mbuf *m } /* - * Dispatch a packet for netisr processing, direct dispatch permitted by + * Dispatch a packet for netisr processing; direct dispatch is permitted by * calling context. */ int From owner-svn-src-stable@FreeBSD.ORG Sat Jan 15 19:46:36 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4742F106566B; Sat, 15 Jan 2011 19:46:36 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 344FA8FC13; Sat, 15 Jan 2011 19:46: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 p0FJkaai035458; Sat, 15 Jan 2011 19:46:36 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0FJkaia035455; Sat, 15 Jan 2011 19:46:36 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201101151946.p0FJkaia035455@svn.freebsd.org> From: Robert Watson Date: Sat, 15 Jan 2011 19:46:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217457 - stable/8/sys/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2011 19:46:36 -0000 Author: rwatson Date: Sat Jan 15 19:46:36 2011 New Revision: 217457 URL: http://svn.freebsd.org/changeset/base/217457 Log: Merge r204497, r204499 from head to stable/8: Changes to support crashdump analysis of netisr: - Rename the netisr protocol registration array, 'np' to 'netisr_proto', in order to reduce the chances of symbol name collisions. It remains statically defined, but it will be looked up by netstat(1). - Move certain internal structure definitions from netisr.c to netisr_internal.h so that netstat(1) can find them. They remain private, and should not be used for any other purpose (for example, they should not be used by kernel modules, which must instead use the public interfaces in netisr.h). - Store a kernel-compiled version of NETISR_MAXPROT in the global variable netisr_maxprot, and export via a sysctl, so that it is available for use by netstat(1). This is especially important for crashdump interpretation, where the size of the workstream structure is determined by the maximum number of protocols compiled into the kernel. Sponsored by: Juniper Networks Whitespace tweak. Added: stable/8/sys/net/netisr_internal.h - copied unchanged from r204497, head/sys/net/netisr_internal.h Modified: stable/8/sys/net/netisr.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/net/netisr.c ============================================================================== --- stable/8/sys/net/netisr.c Sat Jan 15 19:36:47 2011 (r217456) +++ stable/8/sys/net/netisr.c Sat Jan 15 19:46:36 2011 (r217457) @@ -87,9 +87,11 @@ __FBSDID("$FreeBSD$"); #include #endif +#define _WANT_NETISR_INTERNAL /* Enable definitions from netisr_internal.h */ #include #include #include +#include #include /*- @@ -99,7 +101,7 @@ __FBSDID("$FreeBSD$"); * * The following data structures and fields are protected by this lock: * - * - The np array, including all fields of struct netisr_proto. + * - The netisr_proto array, including all fields of struct netisr_proto. * - The nws array, including all fields of struct netisr_worker. * - The nws_array array. * @@ -194,79 +196,23 @@ SYSCTL_INT(_net_isr, OID_AUTO, defaultql "Default netisr per-protocol, per-CPU queue limit if not set by protocol"); /* - * Each protocol is described by a struct netisr_proto, which holds all - * global per-protocol information. This data structure is set up by - * netisr_register(), and derived from the public struct netisr_handler. + * Store and export the compile-time constant NETISR_MAXPROT limit on the + * number of protocols that can register with netisr at a time. This is + * required for crashdump analysis, as it sizes netisr_proto[]. */ -struct netisr_proto { - const char *np_name; /* Character string protocol name. */ - netisr_handler_t *np_handler; /* Protocol handler. */ - netisr_m2flow_t *np_m2flow; /* Query flow for untagged packet. */ - netisr_m2cpuid_t *np_m2cpuid; /* Query CPU to process packet on. */ - netisr_drainedcpu_t *np_drainedcpu; /* Callback when drained a queue. */ - u_int np_qlimit; /* Maximum per-CPU queue depth. */ - u_int np_policy; /* Work placement policy. */ -}; - -#define NETISR_MAXPROT 16 /* Compile-time limit. */ +static u_int netisr_maxprot = NETISR_MAXPROT; +SYSCTL_INT(_net_isr, OID_AUTO, maxprot, CTLFLAG_RD, + &netisr_maxprot, 0, + "Compile-time limit on the number of protocols supported by netisr."); /* - * The np array describes all registered protocols, indexed by protocol - * number. + * The netisr_proto array describes all registered protocols, indexed by + * protocol number. See netisr_internal.h for more details. */ -static struct netisr_proto np[NETISR_MAXPROT]; +static struct netisr_proto netisr_proto[NETISR_MAXPROT]; /* - * Protocol-specific work for each workstream is described by struct - * netisr_work. Each work descriptor consists of an mbuf queue and - * statistics. - */ -struct netisr_work { - /* - * Packet queue, linked by m_nextpkt. - */ - struct mbuf *nw_head; - struct mbuf *nw_tail; - u_int nw_len; - u_int nw_qlimit; - u_int nw_watermark; - - /* - * Statistics -- written unlocked, but mostly from curcpu. - */ - u_int64_t nw_dispatched; /* Number of direct dispatches. */ - u_int64_t nw_hybrid_dispatched; /* "" hybrid dispatches. */ - u_int64_t nw_qdrops; /* "" drops. */ - u_int64_t nw_queued; /* "" enqueues. */ - u_int64_t nw_handled; /* "" handled in worker. */ -}; - -/* - * Workstreams hold a queue of ordered work across each protocol, and are - * described by netisr_workstream. Each workstream is associated with a - * worker thread, which in turn is pinned to a CPU. Work associated with a - * workstream can be processd in other threads during direct dispatch; - * concurrent processing is prevented by the NWS_RUNNING flag, which - * indicates that a thread is already processing the work queue. It is - * important to prevent a directly dispatched packet from "skipping ahead" of - * work already in the workstream queue. - */ -struct netisr_workstream { - struct intr_event *nws_intr_event; /* Handler for stream. */ - void *nws_swi_cookie; /* swi(9) cookie for stream. */ - struct mtx nws_mtx; /* Synchronize work. */ - u_int nws_cpu; /* CPU pinning. */ - u_int nws_flags; /* Wakeup flags. */ - u_int nws_pendingbits; /* Scheduled protocols. */ - - /* - * Each protocol has per-workstream data. - */ - struct netisr_work nws_work[NETISR_MAXPROT]; -} __aligned(CACHE_LINE_SIZE); - -/* - * Per-CPU workstream data. + * Per-CPU workstream data. See netisr_internal.h for more details. */ DPCPU_DEFINE(struct netisr_workstream, nws); @@ -286,13 +232,6 @@ SYSCTL_INT(_net_isr, OID_AUTO, numthread &nws_count, 0, "Number of extant netisr threads."); /* - * Per-workstream flags. - */ -#define NWS_RUNNING 0x00000001 /* Currently running in a thread. */ -#define NWS_DISPATCHING 0x00000002 /* Currently being direct-dispatched. */ -#define NWS_SCHEDULED 0x00000004 /* Signal issued. */ - -/* * Synchronization for each workstream: a mutex protects all mutable fields * in each stream, including per-protocol state (mbuf queues). The SWI is * woken up if asynchronous dispatch is required. @@ -380,32 +319,32 @@ netisr_register(const struct netisr_hand * Test that no existing registration exists for this protocol. */ NETISR_WLOCK(); - KASSERT(np[proto].np_name == NULL, + KASSERT(netisr_proto[proto].np_name == NULL, ("%s(%u, %s): name present", __func__, proto, name)); - KASSERT(np[proto].np_handler == NULL, + KASSERT(netisr_proto[proto].np_handler == NULL, ("%s(%u, %s): handler present", __func__, proto, name)); - np[proto].np_name = name; - np[proto].np_handler = nhp->nh_handler; - np[proto].np_m2flow = nhp->nh_m2flow; - np[proto].np_m2cpuid = nhp->nh_m2cpuid; - np[proto].np_drainedcpu = nhp->nh_drainedcpu; + netisr_proto[proto].np_name = name; + netisr_proto[proto].np_handler = nhp->nh_handler; + netisr_proto[proto].np_m2flow = nhp->nh_m2flow; + netisr_proto[proto].np_m2cpuid = nhp->nh_m2cpuid; + netisr_proto[proto].np_drainedcpu = nhp->nh_drainedcpu; if (nhp->nh_qlimit == 0) - np[proto].np_qlimit = netisr_defaultqlimit; + netisr_proto[proto].np_qlimit = netisr_defaultqlimit; else if (nhp->nh_qlimit > netisr_maxqlimit) { printf("%s: %s requested queue limit %u capped to " "net.isr.maxqlimit %u\n", __func__, name, nhp->nh_qlimit, netisr_maxqlimit); - np[proto].np_qlimit = netisr_maxqlimit; + netisr_proto[proto].np_qlimit = netisr_maxqlimit; } else - np[proto].np_qlimit = nhp->nh_qlimit; - np[proto].np_policy = nhp->nh_policy; + netisr_proto[proto].np_qlimit = nhp->nh_qlimit; + netisr_proto[proto].np_policy = nhp->nh_policy; for (i = 0; i <= mp_maxid; i++) { if (CPU_ABSENT(i)) continue; npwp = &(DPCPU_ID_PTR(i, nws))->nws_work[proto]; bzero(npwp, sizeof(*npwp)); - npwp->nw_qlimit = np[proto].np_qlimit; + npwp->nw_qlimit = netisr_proto[proto].np_qlimit; } NETISR_WUNLOCK(); } @@ -430,7 +369,7 @@ netisr_clearqdrops(const struct netisr_h ("%s(%u): protocol too big for %s", __func__, proto, name)); NETISR_WLOCK(); - KASSERT(np[proto].np_handler != NULL, + KASSERT(netisr_proto[proto].np_handler != NULL, ("%s(%u): protocol not registered for %s", __func__, proto, name)); @@ -465,7 +404,7 @@ netisr_getqdrops(const struct netisr_han ("%s(%u): protocol too big for %s", __func__, proto, name)); NETISR_RLOCK(&tracker); - KASSERT(np[proto].np_handler != NULL, + KASSERT(netisr_proto[proto].np_handler != NULL, ("%s(%u): protocol not registered for %s", __func__, proto, name)); @@ -498,10 +437,10 @@ netisr_getqlimit(const struct netisr_han ("%s(%u): protocol too big for %s", __func__, proto, name)); NETISR_RLOCK(&tracker); - KASSERT(np[proto].np_handler != NULL, + KASSERT(netisr_proto[proto].np_handler != NULL, ("%s(%u): protocol not registered for %s", __func__, proto, name)); - *qlimitp = np[proto].np_qlimit; + *qlimitp = netisr_proto[proto].np_qlimit; NETISR_RUNLOCK(&tracker); } @@ -530,11 +469,11 @@ netisr_setqlimit(const struct netisr_han ("%s(%u): protocol too big for %s", __func__, proto, name)); NETISR_WLOCK(); - KASSERT(np[proto].np_handler != NULL, + KASSERT(netisr_proto[proto].np_handler != NULL, ("%s(%u): protocol not registered for %s", __func__, proto, name)); - np[proto].np_qlimit = qlimit; + netisr_proto[proto].np_qlimit = qlimit; for (i = 0; i <= mp_maxid; i++) { if (CPU_ABSENT(i)) continue; @@ -591,16 +530,16 @@ netisr_unregister(const struct netisr_ha ("%s(%u): protocol too big for %s", __func__, proto, name)); NETISR_WLOCK(); - KASSERT(np[proto].np_handler != NULL, + KASSERT(netisr_proto[proto].np_handler != NULL, ("%s(%u): protocol not registered for %s", __func__, proto, name)); - np[proto].np_name = NULL; - np[proto].np_handler = NULL; - np[proto].np_m2flow = NULL; - np[proto].np_m2cpuid = NULL; - np[proto].np_qlimit = 0; - np[proto].np_policy = 0; + netisr_proto[proto].np_name = NULL; + netisr_proto[proto].np_handler = NULL; + netisr_proto[proto].np_m2flow = NULL; + netisr_proto[proto].np_m2cpuid = NULL; + netisr_proto[proto].np_qlimit = 0; + netisr_proto[proto].np_policy = 0; for (i = 0; i <= mp_maxid; i++) { if (CPU_ABSENT(i)) continue; @@ -720,13 +659,13 @@ netisr_process_workstream_proto(struct n local_npw.nw_len--; VNET_ASSERT(m->m_pkthdr.rcvif != NULL); CURVNET_SET(m->m_pkthdr.rcvif->if_vnet); - np[proto].np_handler(m); + netisr_proto[proto].np_handler(m); CURVNET_RESTORE(); } KASSERT(local_npw.nw_len == 0, ("%s(%u): len %u", __func__, proto, local_npw.nw_len)); - if (np[proto].np_drainedcpu) - np[proto].np_drainedcpu(nwsp->nws_cpu); + if (netisr_proto[proto].np_drainedcpu) + netisr_proto[proto].np_drainedcpu(nwsp->nws_cpu); NWS_LOCK(nwsp); npwp->nw_handled += handled; return (handled); @@ -862,10 +801,10 @@ netisr_queue_src(u_int proto, uintptr_t #ifdef NETISR_LOCKING NETISR_RLOCK(&tracker); #endif - KASSERT(np[proto].np_handler != NULL, + KASSERT(netisr_proto[proto].np_handler != NULL, ("%s: invalid proto %u", __func__, proto)); - m = netisr_select_cpuid(&np[proto], source, m, &cpuid); + m = netisr_select_cpuid(&netisr_proto[proto], source, m, &cpuid); if (m != NULL) { KASSERT(!CPU_ABSENT(cpuid), ("%s: CPU %u absent", __func__, cpuid)); @@ -911,7 +850,7 @@ netisr_dispatch_src(u_int proto, uintptr #ifdef NETISR_LOCKING NETISR_RLOCK(&tracker); #endif - KASSERT(np[proto].np_handler != NULL, + KASSERT(netisr_proto[proto].np_handler != NULL, ("%s: invalid proto %u", __func__, proto)); /* @@ -926,7 +865,7 @@ netisr_dispatch_src(u_int proto, uintptr npwp = &nwsp->nws_work[proto]; npwp->nw_dispatched++; npwp->nw_handled++; - np[proto].np_handler(m); + netisr_proto[proto].np_handler(m); error = 0; goto out_unlock; } @@ -936,7 +875,7 @@ netisr_dispatch_src(u_int proto, uintptr * dispatch if we're on the right CPU and the netisr worker isn't * already running. */ - m = netisr_select_cpuid(&np[proto], source, m, &cpuid); + m = netisr_select_cpuid(&netisr_proto[proto], source, m, &cpuid); if (m == NULL) { error = ENOBUFS; goto out_unlock; @@ -973,7 +912,7 @@ netisr_dispatch_src(u_int proto, uintptr */ nwsp->nws_flags |= NWS_DISPATCHING; NWS_UNLOCK(nwsp); - np[proto].np_handler(m); + netisr_proto[proto].np_handler(m); NWS_LOCK(nwsp); nwsp->nws_flags &= ~NWS_DISPATCHING; npwp->nw_handled++; @@ -1149,7 +1088,7 @@ sysctl_netisr_proto(SYSCTL_HANDLER_ARGS) counter = 0; NETISR_RLOCK(&tracker); for (proto = 0; proto < NETISR_MAXPROT; proto++) { - npp = &np[proto]; + npp = &netisr_proto[proto]; if (npp->np_name == NULL) continue; snpp = &snp_array[counter]; @@ -1261,7 +1200,7 @@ sysctl_netisr_work(SYSCTL_HANDLER_ARGS) continue; NWS_LOCK(nwsp); for (proto = 0; proto < NETISR_MAXPROT; proto++) { - npp = &np[proto]; + npp = &netisr_proto[proto]; if (npp->np_name == NULL) continue; nwp = &nwsp->nws_work[proto]; @@ -1312,7 +1251,7 @@ DB_SHOW_COMMAND(netisr, db_show_netisr) continue; first = 1; for (proto = 0; proto < NETISR_MAXPROT; proto++) { - if (np[proto].np_handler == NULL) + if (netisr_proto[proto].np_handler == NULL) continue; nwp = &nwsp->nws_work[proto]; if (first) { @@ -1322,7 +1261,7 @@ DB_SHOW_COMMAND(netisr, db_show_netisr) db_printf("%3s ", ""); db_printf( "%6s %5d %5d %5d %8ju %8ju %8ju %8ju\n", - np[proto].np_name, nwp->nw_len, + netisr_proto[proto].np_name, nwp->nw_len, nwp->nw_watermark, nwp->nw_qlimit, nwp->nw_dispatched, nwp->nw_hybrid_dispatched, nwp->nw_qdrops, nwp->nw_queued); Copied: stable/8/sys/net/netisr_internal.h (from r204497, head/sys/net/netisr_internal.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/sys/net/netisr_internal.h Sat Jan 15 19:46:36 2011 (r217457, copy of r204497, head/sys/net/netisr_internal.h) @@ -0,0 +1,127 @@ +/*- + * Copyright (c) 2007-2009 Robert N. M. Watson + * Copyright (c) 2010 Juniper Networks, Inc. + * All rights reserved. + * + * This software was developed by Robert N. M. Watson under contract + * to Juniper Networks, Inc. + * + * 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$ + */ + +#ifndef _NET_NETISR_INTERNAL_H_ +#define _NET_NETISR_INTERNAL_H_ + +#ifndef _WANT_NETISR_INTERNAL +#error "no user-serviceable parts inside" +#endif + +/* + * These definitions are private to the netisr implementation, but provided + * here for use by post-mortem crashdump analysis tools. They should not be + * used in any other context as they can and will change. Public definitions + * may be found in netisr.h. + */ + +#ifndef _KERNEL +typedef void *netisr_handler_t; +typedef void *netisr_m2flow_t; +typedef void *netisr_m2cpuid_t; +typedef void *netisr_drainedcpu_t; +#endif + +/* + * Each protocol is described by a struct netisr_proto, which holds all + * global per-protocol information. This data structure is set up by + * netisr_register(), and derived from the public struct netisr_handler. + */ +struct netisr_proto { + const char *np_name; /* Character string protocol name. */ + netisr_handler_t *np_handler; /* Protocol handler. */ + netisr_m2flow_t *np_m2flow; /* Query flow for untagged packet. */ + netisr_m2cpuid_t *np_m2cpuid; /* Query CPU to process packet on. */ + netisr_drainedcpu_t *np_drainedcpu; /* Callback when drained a queue. */ + u_int np_qlimit; /* Maximum per-CPU queue depth. */ + u_int np_policy; /* Work placement policy. */ +}; + +#define NETISR_MAXPROT 16 /* Compile-time limit. */ + +/* + * Protocol-specific work for each workstream is described by struct + * netisr_work. Each work descriptor consists of an mbuf queue and + * statistics. + */ +struct netisr_work { + /* + * Packet queue, linked by m_nextpkt. + */ + struct mbuf *nw_head; + struct mbuf *nw_tail; + u_int nw_len; + u_int nw_qlimit; + u_int nw_watermark; + + /* + * Statistics -- written unlocked, but mostly from curcpu. + */ + u_int64_t nw_dispatched; /* Number of direct dispatches. */ + u_int64_t nw_hybrid_dispatched; /* "" hybrid dispatches. */ + u_int64_t nw_qdrops; /* "" drops. */ + u_int64_t nw_queued; /* "" enqueues. */ + u_int64_t nw_handled; /* "" handled in worker. */ +}; + +/* + * Workstreams hold a queue of ordered work across each protocol, and are + * described by netisr_workstream. Each workstream is associated with a + * worker thread, which in turn is pinned to a CPU. Work associated with a + * workstream can be processd in other threads during direct dispatch; + * concurrent processing is prevented by the NWS_RUNNING flag, which + * indicates that a thread is already processing the work queue. It is + * important to prevent a directly dispatched packet from "skipping ahead" of + * work already in the workstream queue. + */ +struct netisr_workstream { + struct intr_event *nws_intr_event; /* Handler for stream. */ + void *nws_swi_cookie; /* swi(9) cookie for stream. */ + struct mtx nws_mtx; /* Synchronize work. */ + u_int nws_cpu; /* CPU pinning. */ + u_int nws_flags; /* Wakeup flags. */ + u_int nws_pendingbits; /* Scheduled protocols. */ + + /* + * Each protocol has per-workstream data. + */ + struct netisr_work nws_work[NETISR_MAXPROT]; +} __aligned(CACHE_LINE_SIZE); + +/* + * Per-workstream flags. + */ +#define NWS_RUNNING 0x00000001 /* Currently running in a thread. */ +#define NWS_DISPATCHING 0x00000002 /* Currently being direct-dispatched. */ +#define NWS_SCHEDULED 0x00000004 /* Signal issued. */ + +#endif /* !_NET_NETISR_INTERNAL_H_ */ From owner-svn-src-stable@FreeBSD.ORG Sat Jan 15 19:49:08 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E5171106566B; Sat, 15 Jan 2011 19:49:08 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D22B08FC0A; Sat, 15 Jan 2011 19:49: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 p0FJn8tT035563; Sat, 15 Jan 2011 19:49:08 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0FJn8dq035559; Sat, 15 Jan 2011 19:49:08 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201101151949.p0FJn8dq035559@svn.freebsd.org> From: Robert Watson Date: Sat, 15 Jan 2011 19:49:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217458 - stable/8/usr.bin/netstat X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2011 19:49:09 -0000 Author: rwatson Date: Sat Jan 15 19:49:08 2011 New Revision: 217458 URL: http://svn.freebsd.org/changeset/base/217458 Log: Merge r204499, r204515 from head to stable/8: Teach netstat -Q to work with -N and -M by adding libkvm versions of data query routines. This code is necessarily more fragile in the presence of kernel changes than querying the kernel via sysctl (the default), but useful when investigating crashes or live kernel state via firewire. Sponsored by: Juniper Networks Prefer vocabulary of 'Current' and 'Limit' to 'Value' and 'Maximum' in netstat -Q. Sponsored by: Juniper Networks Modified: stable/8/usr.bin/netstat/main.c stable/8/usr.bin/netstat/netisr.c stable/8/usr.bin/netstat/netstat.h Directory Properties: stable/8/usr.bin/netstat/ (props changed) Modified: stable/8/usr.bin/netstat/main.c ============================================================================== --- stable/8/usr.bin/netstat/main.c Sat Jan 15 19:46:36 2011 (r217457) +++ stable/8/usr.bin/netstat/main.c Sat Jan 15 19:49:08 2011 (r217458) @@ -539,9 +539,11 @@ main(int argc, char *argv[]) exit(0); } if (Qflag) { - if (!live) - usage(); - netisr_stats(); + if (!live) { + if (kread(0, NULL, 0) == 0) + netisr_stats(kvmd); + } else + netisr_stats(NULL); exit(0); } #if 0 Modified: stable/8/usr.bin/netstat/netisr.c ============================================================================== --- stable/8/usr.bin/netstat/netisr.c Sat Jan 15 19:46:36 2011 (r217457) +++ stable/8/usr.bin/netstat/netisr.c Sat Jan 15 19:49:08 2011 (r217458) @@ -31,15 +31,22 @@ __FBSDID("$FreeBSD$"); -#include +#include #include +#include +#include + +#define _WANT_NETISR_INTERNAL #include +#include #include +#include #include #include #include +#include #include "netstat.h" @@ -65,6 +72,90 @@ static u_int workstream_array_len; static struct sysctl_netisr_work *work_array; static u_int work_array_len; +static u_int *nws_array; + +static u_int maxprot; + +static void +netisr_load_kvm_uint(kvm_t *kd, char *name, u_int *p) +{ + struct nlist nl[] = { + { .n_name = name }, + { .n_name = NULL }, + }; + int ret; + + ret = kvm_nlist(kd, nl); + if (ret < 0) + errx(-1, "%s: kvm_nlist(%s): %s", __func__, name, + kvm_geterr(kd)); + if (ret != 0) + errx(-1, "%s: kvm_nlist(%s): unresolved symbol", __func__, + name); + if (kvm_read(kd, nl[0].n_value, p, sizeof(*p)) != sizeof(*p)) + errx(-1, "%s: kvm_read(%s): %s", __func__, name, + kvm_geterr(kd)); +} + +/* + * Load a nul-terminated string from KVM up to 'limit', guarantee that the + * string in local memory is nul-terminated. + */ +static void +netisr_load_kvm_string(kvm_t *kd, uintptr_t addr, char *dest, u_int limit) +{ + u_int i; + + for (i = 0; i < limit; i++) { + if (kvm_read(kd, addr + i, &dest[i], sizeof(dest[i])) != + sizeof(dest[i])) + err(-1, "%s: kvm_read: %s", __func__, + kvm_geterr(kd)); + if (dest[i] == '\0') + break; + } + dest[limit - 1] = '\0'; +} + +static const char * +netisr_proto2name(u_int proto) +{ + u_int i; + + for (i = 0; i < proto_array_len; i++) { + if (proto_array[i].snp_proto == proto) + return (proto_array[i].snp_name); + } + return ("unknown"); +} + +static int +netisr_protoispresent(u_int proto) +{ + u_int i; + + for (i = 0; i < proto_array_len; i++) { + if (proto_array[i].snp_proto == proto) + return (1); + } + return (0); +} + +static void +netisr_load_kvm_config(kvm_t *kd) +{ + + netisr_load_kvm_uint(kd, "_netisr_bindthreads", &bindthreads); + netisr_load_kvm_uint(kd, "_netisr_maxthreads", &maxthreads); + netisr_load_kvm_uint(kd, "_nws_count", &numthreads); + + netisr_load_kvm_uint(kd, "_netisr_defaultqlimit", &defaultqlimit); + netisr_load_kvm_uint(kd, "_netisr_maxqlimit", &maxqlimit); + + netisr_load_kvm_uint(kd, "_netisr_direct", &direct); + netisr_load_kvm_uint(kd, "_netisr_direct_force", &direct_force); +} + static void netisr_load_sysctl_uint(const char *name, u_int *p) { @@ -78,7 +169,7 @@ netisr_load_sysctl_uint(const char *name } static void -netisr_load_config(void) +netisr_load_sysctl_config(void) { netisr_load_sysctl_uint("net.isr.bindthreads", &bindthreads); @@ -93,7 +184,80 @@ netisr_load_config(void) } static void -netisr_load_proto(void) +netisr_load_kvm_proto(kvm_t *kd) +{ + struct nlist nl[] = { +#define NLIST_NETISR_PROTO 0 + { .n_name = "_netisr_proto" }, + { .n_name = NULL }, + }; + struct netisr_proto *np_array, *npp; + u_int i, protocount; + struct sysctl_netisr_proto *snpp; + size_t len; + int ret; + + /* + * Kernel compile-time and user compile-time definitions of + * NETISR_MAXPROT must match, as we use that to size work arrays. + */ + netisr_load_kvm_uint(kd, "_netisr_maxprot", &maxprot); + if (maxprot != NETISR_MAXPROT) + errx(-1, "%s: NETISR_MAXPROT mismatch", __func__); + len = maxprot * sizeof(*np_array); + np_array = malloc(len); + if (np_array == NULL) + err(-1, "%s: malloc", __func__); + ret = kvm_nlist(kd, nl); + if (ret < 0) + errx(-1, "%s: kvm_nlist(_netisr_proto): %s", __func__, + kvm_geterr(kd)); + if (ret != 0) + errx(-1, "%s: kvm_nlist(_netisr_proto): unresolved symbol", + __func__); + if (kvm_read(kd, nl[NLIST_NETISR_PROTO].n_value, np_array, len) != + (ssize_t)len) + errx(-1, "%s: kvm_read(_netisr_proto): %s", __func__, + kvm_geterr(kd)); + + /* + * Size and allocate memory to hold only live protocols. + */ + protocount = 0; + for (i = 0; i < maxprot; i++) { + if (np_array[i].np_name == NULL) + continue; + protocount++; + } + proto_array = calloc(protocount, sizeof(*proto_array)); + if (proto_array == NULL) + err(-1, "malloc"); + protocount = 0; + for (i = 0; i < maxprot; i++) { + npp = &np_array[i]; + if (npp->np_name == NULL) + continue; + snpp = &proto_array[protocount]; + snpp->snp_version = sizeof(*snpp); + netisr_load_kvm_string(kd, (uintptr_t)npp->np_name, + snpp->snp_name, sizeof(snpp->snp_name)); + snpp->snp_proto = i; + snpp->snp_qlimit = npp->np_qlimit; + snpp->snp_policy = npp->np_policy; + if (npp->np_m2flow != NULL) + snpp->snp_flags |= NETISR_SNP_FLAGS_M2FLOW; + if (npp->np_m2cpuid != NULL) + snpp->snp_flags |= NETISR_SNP_FLAGS_M2CPUID; + if (npp->np_drainedcpu != NULL) + snpp->snp_flags |= NETISR_SNP_FLAGS_DRAINEDCPU; + protocount++; + } + proto_array_len = protocount; + free(np_array); +} + +static void +netisr_load_sysctl_proto(void) { size_t len; @@ -116,7 +280,96 @@ netisr_load_proto(void) } static void -netisr_load_workstream(void) +netisr_load_kvm_workstream(kvm_t *kd) +{ + struct nlist nl[] = { +#define NLIST_NWS_ARRAY 0 + { .n_name = "_nws_array" }, + { .n_name = NULL }, + }; + struct netisr_workstream nws; + struct sysctl_netisr_workstream *snwsp; + struct sysctl_netisr_work *snwp; + struct netisr_work *nwp; + struct nlist nl_nws[2]; + u_int counter, cpuid, proto, wsid; + size_t len; + int ret; + + len = numthreads * sizeof(*nws_array); + nws_array = malloc(len); + if (nws_array == NULL) + err(-1, "malloc"); + ret = kvm_nlist(kd, nl); + if (ret < 0) + errx(-1, "%s: kvm_nlist: %s", __func__, kvm_geterr(kd)); + if (ret != 0) + errx(-1, "%s: kvm_nlist: unresolved symbol", __func__); + if (kvm_read(kd, nl[NLIST_NWS_ARRAY].n_value, nws_array, len) != + (ssize_t)len) + errx(-1, "%s: kvm_read(_nws_array): %s", __func__, + kvm_geterr(kd)); + workstream_array = calloc(numthreads, sizeof(*workstream_array)); + if (workstream_array == NULL) + err(-1, "calloc"); + workstream_array_len = numthreads; + work_array = calloc(numthreads * proto_array_len, sizeof(*work_array)); + if (work_array == NULL) + err(-1, "calloc"); + counter = 0; + for (wsid = 0; wsid < numthreads; wsid++) { + cpuid = nws_array[wsid]; + if (kvm_dpcpu_setcpu(kd, cpuid) < 0) + errx(-1, "%s: kvm_dpcpu_setcpu(%u): %s", __func__, + cpuid, kvm_geterr(kd)); + bzero(nl_nws, sizeof(nl_nws)); + nl_nws[0].n_name = "_nws"; + ret = kvm_nlist(kd, nl_nws); + if (ret < 0) + errx(-1, "%s: kvm_nlist looking up nws on CPU %u: %s", + __func__, cpuid, kvm_geterr(kd)); + if (ret != 0) + errx(-1, "%s: kvm_nlist(nws): unresolved symbol on " + "CPU %u", __func__, cpuid); + if (kvm_read(kd, nl_nws[0].n_value, &nws, sizeof(nws)) != + sizeof(nws)) + errx(-1, "%s: kvm_read(nw): %s", __func__, + kvm_geterr(kd)); + snwsp = &workstream_array[wsid]; + snwsp->snws_version = sizeof(*snwsp); + snwsp->snws_wsid = cpuid; + snwsp->snws_cpu = cpuid; + if (nws.nws_intr_event != NULL) + snwsp->snws_flags |= NETISR_SNWS_FLAGS_INTR; + + /* + * Extract the CPU's per-protocol work information. + */ + printf("counting to maxprot: %u\n", maxprot); + for (proto = 0; proto < maxprot; proto++) { + if (!netisr_protoispresent(proto)) + continue; + nwp = &nws.nws_work[proto]; + snwp = &work_array[counter]; + snwp->snw_version = sizeof(*snwp); + snwp->snw_wsid = cpuid; + snwp->snw_proto = proto; + snwp->snw_len = nwp->nw_len; + snwp->snw_watermark = nwp->nw_watermark; + snwp->snw_dispatched = nwp->nw_dispatched; + snwp->snw_hybrid_dispatched = + nwp->nw_hybrid_dispatched; + snwp->snw_qdrops = nwp->nw_qdrops; + snwp->snw_queued = nwp->nw_queued; + snwp->snw_handled = nwp->nw_handled; + counter++; + } + } + work_array_len = counter; +} + +static void +netisr_load_sysctl_workstream(void) { size_t len; @@ -140,7 +393,7 @@ netisr_load_workstream(void) } static void -netisr_load_work(void) +netisr_load_sysctl_work(void) { size_t len; @@ -179,18 +432,6 @@ netisr_print_proto(struct sysctl_netisr_ (snpp->snp_flags & NETISR_SNP_FLAGS_M2FLOW) ? "F" : "-"); } -static const char * -netisr_proto2name(u_int proto) -{ - u_int i; - - for (i = 0; i < proto_array_len; i++) { - if (proto_array[i].snp_proto == proto) - return (proto_array[i].snp_name); - } - return ("unknown"); -} - static void netisr_print_workstream(struct sysctl_netisr_workstream *snwsp) { @@ -223,16 +464,25 @@ netisr_print_workstream(struct sysctl_ne } void -netisr_stats(void) +netisr_stats(void *kvmd) { struct sysctl_netisr_workstream *snwsp; struct sysctl_netisr_proto *snpp; + kvm_t *kd = kvmd; u_int i; - netisr_load_config(); - netisr_load_proto(); - netisr_load_workstream(); - netisr_load_work(); + if (live) { + netisr_load_sysctl_config(); + netisr_load_sysctl_proto(); + netisr_load_sysctl_workstream(); + netisr_load_sysctl_work(); + } else { + if (kd == NULL) + errx(-1, "netisr_stats: !live but !kd"); + netisr_load_kvm_config(kd); + netisr_load_kvm_proto(kd); + netisr_load_kvm_workstream(kd); /* Also does work. */ + } printf("Configuration:\n"); printf("%-25s %12s %12s\n", "Setting", "Value", "Maximum"); Modified: stable/8/usr.bin/netstat/netstat.h ============================================================================== --- stable/8/usr.bin/netstat/netstat.h Sat Jan 15 19:46:36 2011 (r217457) +++ stable/8/usr.bin/netstat/netstat.h Sat Jan 15 19:49:08 2011 (r217458) @@ -117,7 +117,7 @@ void pfkey_stats(u_long, const char *, i void mbpr(void *, u_long); -void netisr_stats(void); +void netisr_stats(void *); void hostpr(u_long, u_long); void impstats(u_long, u_long);