Date: Tue, 31 May 2011 14:14:48 -0700 From: Doug Barton <dougb@FreeBSD.org> To: freebsd-rc@FreeBSD.org, "Bjoern A. Zeeb" <bzeeb-lists@lists.zabbadoz.net>, Hiroki Sato <hrs@freebsd.org> Subject: afexists() Message-ID: <4DE55A48.8090508@FreeBSD.org>
next in thread | raw e-mail | index | archive | help
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 <bz@FreeBSD.org> 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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4DE55A48.8090508>