svn commit: r222515 - in head/etc: . defaults

Bjoern A. Zeeb bz at FreeBSD.org
Tue May 31 00:25:52 UTC 2011


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

Modified: head/etc/defaults/rc.conf
==============================================================================
--- head/etc/defaults/rc.conf	Mon May 30 23:27:42 2011	(r222514)
+++ head/etc/defaults/rc.conf	Tue May 31 00:25:52 2011	(r222515)
@@ -210,7 +210,7 @@ icmp_log_redirect="NO"		# Set to YES to 
 network_interfaces="auto"	# List of network interfaces (or "auto").
 cloned_interfaces=""		# List of cloned network interfaces to create.
 #cloned_interfaces="gif0 gif1 gif2 gif3" # Pre-cloning GENERIC config.
-ifconfig_lo0="inet 127.0.0.1"	# default loopback device configuration.
+#ifconfig_lo0="inet 127.0.0.1"	# default loopback device configuration.
 #ifconfig_lo0_alias0="inet 127.0.0.254 netmask 0xffffffff" # Sample alias entry.
 #ifconfig_ed0_ipx="ipx 0x00010010"	# Sample IPX address family entry.
 #ifconfig_ed0_ipv6="inet6 2001:db8:1::1 prefixlen 64" # Sample IPv6 addr entry

Modified: head/etc/network.subr
==============================================================================
--- head/etc/network.subr	Mon May 30 23:27:42 2011	(r222514)
+++ head/etc/network.subr	Tue May 31 00:25:52 2011	(r222515)
@@ -44,9 +44,9 @@ ifn_start()
 
 	ifscript_up ${ifn} && cfg=0
 	ifconfig_up ${ifn} && cfg=0
-	ipv4_up ${ifn} && cfg=0
-	ipv6_up ${ifn} && cfg=0
-	ipx_up ${ifn} && cfg=0
+	afexists inet && ipv4_up ${ifn} && cfg=0
+	afexists inet6 && ipv6_up ${ifn} && cfg=0
+	afexists ipx && ipx_up ${ifn} && cfg=0
 	childif_create ${ifn} && cfg=0
 
 	return $cfg
@@ -64,9 +64,9 @@ ifn_stop()
 
 	[ -z "$ifn" ] && err 1 "ifn_stop called without an interface"
 
-	ipx_down ${ifn} && cfg=0
-	ipv6_down ${ifn} && cfg=0
-	ipv4_down ${ifn} && cfg=0
+	afexists ipx && ipx_down ${ifn} && cfg=0
+	afexists inet6 && ipv6_down ${ifn} && cfg=0
+	afexists inet && ipv4_down ${ifn} && cfg=0
 	ifconfig_down ${ifn} && cfg=0
 	ifscript_down ${ifn} && cfg=0
 	childif_destroy ${ifn} && cfg=0
@@ -86,6 +86,11 @@ ifconfig_up()
 	local _cfg _ipv6_opts ifconfig_args
 	_cfg=1
 
+	# Make sure lo0 always comes up.
+	if [ "$1" = "lo0" ]; then
+		_cfg=0
+	fi
+
 	# ifconfig_IF
 	ifconfig_args=`ifconfig_getargs $1`
 	if [ -n "${ifconfig_args}" ]; then
@@ -351,10 +356,10 @@ afexists()
 
 	case ${_af} in
 	inet)
-		${SYSCTL_N} net.inet > /dev/null 2>&1
+		${SYSCTL_N} kern.features.inet > /dev/null 2>&1
 		;;
 	inet6)
-		${SYSCTL_N} net.inet6 > /dev/null 2>&1
+		${SYSCTL_N} kern.features.inet6 > /dev/null 2>&1
 		;;
 	ipx)
 		${SYSCTL_N} net.ipx > /dev/null 2>&1
@@ -512,6 +517,13 @@ ipv4_up()
 	_if=$1
 	_ret=1
 
+	# Add 127.0.0.1/8 to lo0 unless otherwise specified.
+	if [ "${_if}" = "lo0" ]; then
+		ifconfig_args=`ifconfig_getargs ${_if}`
+		if [ -z "${ifconfig_args}" ]; then
+			ifconfig ${_if} inet 127.0.0.1/8 alias
+		fi
+	fi
 	ifalias_up ${_if} inet && _ret=0
 	ipv4_addrs_common ${_if} alias && _ret=0
 


More information about the svn-src-head mailing list