From owner-freebsd-rc@FreeBSD.ORG Tue May 31 21:14:51 2011 Return-Path: Delivered-To: freebsd-rc@FreeBSD.org Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2001:4f8:fff6::35]) by hub.freebsd.org (Postfix) with ESMTP id 38FF6106564A; Tue, 31 May 2011 21:14:51 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from 65-241-43-5.globalsuite.net (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx2.freebsd.org (Postfix) with ESMTP id 28ECE14DE1C; Tue, 31 May 2011 21:14:49 +0000 (UTC) Message-ID: <4DE55A48.8090508@FreeBSD.org> Date: Tue, 31 May 2011 14:14:48 -0700 From: Doug Barton Organization: http://SupersetSolutions.com/ User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.17) Gecko/20110429 Thunderbird/3.1.10 MIME-Version: 1.0 To: freebsd-rc@FreeBSD.org, "Bjoern A. Zeeb" , Hiroki Sato X-Enigmail-Version: 1.1.2 OpenPGP: id=1A1ABC84 Content-Type: multipart/mixed; boundary="------------050207070004000803050409" Cc: Subject: afexists() X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 May 2011 21:14:51 -0000 This is a multi-part message in MIME format. --------------050207070004000803050409 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit I don't have any specific objections to this change, although adding more calls to afexists() highlights an issue I addressed previously in looking at network.subr. On my system (with IPv6) it's called over 25 times at each boot, which given that it's a moderately expensive test indicates an opportunity for optimization. Attached is a patch which caches a positive result for support for a given address family. I don't think caching negative results is a good idea since that could change as the boot progresses. I plan to commit this on Friday if there are no objections. Doug -------- Original Message -------- Subject: svn commit: r222515 - in head/etc: . defaults Date: Tue, 31 May 2011 00:25:52 +0000 (UTC) From: Bjoern A. Zeeb To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Author: bz Date: Tue May 31 00:25:52 2011 New Revision: 222515 URL: http://svn.freebsd.org/changeset/base/222515 Log: No logner set an IPv4 loopback address by default in defaults/rc.conf. If not specified, network.subr will add it automatically if we have INET support (1). In network.subr only call the address family up/down functions if the respective AF is available. Switch to new kern.features variables for inet and inet6 as the inet sysctl tree is also available for IPv6-only kernels leading to unexpected results. Suggested by: hrs (1) Reviewed by: hrs Sponsored by: The FreeBSD Foundation Sponsored by: iXsystems MFC after: 20 days Modified: head/etc/defaults/rc.conf head/etc/network.subr --------------050207070004000803050409 Content-Type: text/plain; name="network-subr.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="network-subr.diff" Index: network.subr =================================================================== --- network.subr (revision 222515) +++ network.subr (working copy) @@ -351,22 +351,35 @@ # 1 otherwise. afexists() { - local _af - _af=$1 - - case ${_af} in + case "$1" in inet) - ${SYSCTL_N} kern.features.inet > /dev/null 2>&1 + [ -n "$afexists_inet" ] && return 0 + if ${SYSCTL_N} kern.features.inet > /dev/null 2>&1; then + afexists_inet=afexists_inet + return 0 + fi ;; inet6) - ${SYSCTL_N} kern.features.inet6 > /dev/null 2>&1 + [ -n "$afexists_inet6" ] && return 0 + if ${SYSCTL_N} kern.features.inet6 > /dev/null 2>&1; then + afexists_inet6=afexists_inet6 + return 0 + fi ;; ipx) - ${SYSCTL_N} net.ipx > /dev/null 2>&1 + [ -n "$afexists_ipx" ] && return 0 + if ${SYSCTL_N} net.ipx > /dev/null 2>&1; then + afexists_ipx=afexists_ipx + return 0 + fi ;; atm) + [ -n "$afexists_atm" ] && return 0 if [ -x /sbin/atmconfig ]; then - /sbin/atmconfig diag list > /dev/null 2>&1 + if /sbin/atmconfig diag list > /dev/null 2>&1; then + afexists_atm=afexists_atm + return 0 + fi else return 1 fi --------------050207070004000803050409--