afexists()
Doug Barton
dougb at FreeBSD.org
Tue May 31 21:14:51 UTC 2011
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 at FreeBSD.org>
To: src-committers at freebsd.org, svn-src-all at freebsd.org,
svn-src-head at 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
-------------- next part --------------
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
More information about the freebsd-rc
mailing list