summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorbz <bz@FreeBSD.org>2011-05-31 00:25:52 +0000
committerbz <bz@FreeBSD.org>2011-05-31 00:25:52 +0000
commit3de43df666fc0c65ef09fad8946fa68943f2f93b (patch)
treedaaf64b3c055004246c6fb2636cf669eb2e90cbd /etc
parent8cee41e82ddb57f6395ba6dd9748b90bb439b1a8 (diff)
downloadFreeBSD-src-3de43df666fc0c65ef09fad8946fa68943f2f93b.zip
FreeBSD-src-3de43df666fc0c65ef09fad8946fa68943f2f93b.tar.gz
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
Diffstat (limited to 'etc')
-rw-r--r--etc/defaults/rc.conf2
-rw-r--r--etc/network.subr28
2 files changed, 21 insertions, 9 deletions
diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf
index 21007d6..0fa9004 100644
--- a/etc/defaults/rc.conf
+++ b/etc/defaults/rc.conf
@@ -210,7 +210,7 @@ icmp_log_redirect="NO" # Set to YES to log ICMP REDIRECT packets
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
diff --git a/etc/network.subr b/etc/network.subr
index 8185c5a..64fb0fe 100644
--- a/etc/network.subr
+++ b/etc/network.subr
@@ -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
OpenPOWER on IntegriCloud