net-physical revision 843e19887f64dde75055cf8842fc4db2171eff45
306763c67bb99228487345b32ab8c5c6cd41f23cChristian Maeder# CDDL HEADER START
306763c67bb99228487345b32ab8c5c6cd41f23cChristian Maeder# The contents of this file are subject to the terms of the
306763c67bb99228487345b32ab8c5c6cd41f23cChristian Maeder# Common Development and Distribution License (the "License").
306763c67bb99228487345b32ab8c5c6cd41f23cChristian Maeder# You may not use this file except in compliance with the License.
306763c67bb99228487345b32ab8c5c6cd41f23cChristian Maeder# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# or http://www.opensolaris.org/os/licensing.
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# See the License for the specific language governing permissions
679d3f541f7a9ede4079e045f7758873bb901872Till Mossakowski# and limitations under the License.
306763c67bb99228487345b32ab8c5c6cd41f23cChristian Maeder# When distributing Covered Code, include this CDDL HEADER in each
306763c67bb99228487345b32ab8c5c6cd41f23cChristian Maeder# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# If applicable, add the following below this CDDL HEADER, with the
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# fields enclosed by brackets "[]" replaced with your own identifying
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# information: Portions Copyright [yyyy] [name of copyright owner]
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# CDDL HEADER END
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# Use is subject to license terms.
b09c4ce9ee62d8b62f6c7bb12956a3dea4defd95Till Mossakowski# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# All rights reserved.
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# ident "%Z%%M% %I% %E% SMI"
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maeder# In a shared-IP zone we need this service to be up, but all of the work
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maeder# it tries to do is irrelevant (and will actually lead to the service
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maeder# failing if we try to do it), so just bail out.
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maeder# In the global zone and exclusive-IP zones we proceed.
95932c57191afb21b59187129e4fed66250500ecMaciek Makowski# Print warnings to console
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski echo "Failed to $1 interface(s): $2" >/dev/msglog
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski# Make sure that the libraries essential to this stage of booting can be found.
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian MaederLD_LIBRARY_PATH=/lib; export LD_LIBRARY_PATH
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# Cause ifconfig to not automatically start in.mpathd when IPMP groups are
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# configured. This is not strictly necessary but makes it so that in.mpathd
e73be37c05d01fc538553efbf77c1d330cf11542Till Mossakowski# will always be started explicitly from /etc/init.d/inetinit, when we're
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# sure that /usr is mounted.
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder # Bring up link aggregations and initialize security objects.
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder # Note that link property initialization is deferred until after
140a290e18b4a0a2d84127e2913b46ab779a8e86Klaus Luettich # IP interfaces are plumbed to ensure that the links will not
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder # be unloaded (and the property settings lost).
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# If the system was net booted by DHCP, hand DHCP management off to the
7bde7cbe86cb1fca9db8689939e5f57a3416643dJorina Freya Gerken# DHCP agent (ifconfig communicates to the DHCP agent through the
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# loopback interface).
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederif [ -n "$_INIT_NET_IF" -a "$_INIT_NET_STRATEGY" = "dhcp" ]; then
dac41c1d12ba1114c083e7b694ca7ae8a30d09dfTill Mossakowski# The network initialization is done early to support diskless and
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# dataless configurations. For IPv4 interfaces that were configured by
1aa2d970e253d650a50873d5b1213c26b04d90dcJorina Freya Gerken# the kernel (e.g. those on diskless machines) and not configured by
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# DHCP, reset the netmask using the local "/etc/netmasks" file if one
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# exists, and then reset the broadcast address based on the netmask.
1aa2d970e253d650a50873d5b1213c26b04d90dcJorina Freya Gerken# All the IPv4 and IPv6 interfaces are plumbed before doing any
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# interface configuration. This prevents errors from plumb failures
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# getting mixed in with the configured interface lists that the script
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# Get the list of IPv4 interfaces to configure by breaking
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder# /etc/hostname.* into separate args by using "." as a shell separator
b09c4ce9ee62d8b62f6c7bb12956a3dea4defd95Till Mossakowskiinterface_names="`echo /etc/hostname.*[0-9] 2>/dev/null`"
dac41c1d12ba1114c083e7b694ca7ae8a30d09dfTill Mossakowskiif [ "$interface_names" != "/etc/hostname.*[0-9]" ]; then
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder # For some unknown historical reason the xx0
e73be37c05d01fc538553efbf77c1d330cf11542Till Mossakowski # ifname is ignored.
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski if [ $# -gt 1 -a "$2" != "/etc/hostname" ]; then
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski while [ $# -gt 1 -a "$1" != "/etc/hostname" ]; do
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski# Get the list of IPv6 interfaces to configure by breaking
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski# /etc/hostname6.* into separate args by using "." as a shell separator
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederinterface_names="`echo /etc/hostname6.*[0-9] 2>/dev/null`"
95932c57191afb21b59187129e4fed66250500ecMaciek Makowskiif [ "$interface_names" != "/etc/hostname6.*[0-9]" ]; then
95932c57191afb21b59187129e4fed66250500ecMaciek Makowski if [ $# -gt 1 -a "$2" != "/etc/hostname6" ]; then
95932c57191afb21b59187129e4fed66250500ecMaciek Makowski while [ $# -gt 1 -a "$1" != "/etc/hostname6" ]; do
95932c57191afb21b59187129e4fed66250500ecMaciek Makowski# Step through the IPv4 interface list and try to plumb every interface.
503e836b34d3abed34520eb4a0a345b5e13f248dTill Mossakowski# Generate list of plumbed and failed IPv4 interfaces.
503e836b34d3abed34520eb4a0a345b5e13f248dTill Mossakowskiif [ -n "$inet_list" ]; then
503e836b34d3abed34520eb4a0a345b5e13f248dTill Mossakowski if /sbin/ifconfig $1 inet >/dev/null 2>&1; then
503e836b34d3abed34520eb4a0a345b5e13f248dTill Mossakowski [ -n "$inet_failed" ] && warn_failed_ifs "plumb IPv4" $inet_failed
503e836b34d3abed34520eb4a0a345b5e13f248dTill Mossakowski# Run autoconf to connect to a WLAN if the interface is a wireless one
503e836b34d3abed34520eb4a0a345b5e13f248dTill Mossakowskiif [ -x /sbin/wificonfig -a -n "$inet_plumbed" ]; then
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder /sbin/wificonfig -i $1 startconf >/dev/null
95932c57191afb21b59187129e4fed66250500ecMaciek Makowski# Step through the IPv6 interface list and plumb every interface.
95932c57191afb21b59187129e4fed66250500ecMaciek Makowski# Generate list of plumbed and failed IPv6 interfaces. Each plumbed
3468a2292bb3a53a252df0f916e4034e8e6f9dccMaciek Makowski# interface will be brought up later, after processing any contents of
95932c57191afb21b59187129e4fed66250500ecMaciek Makowskiif [ -n "$inet6_list" ]; then
95932c57191afb21b59187129e4fed66250500ecMaciek Makowski if /sbin/ifconfig $1 inet6 >/dev/null 2>&1; then
95932c57191afb21b59187129e4fed66250500ecMaciek Makowski [ -n "$inet6_failed" ] && warn_failed_ifs "plumb IPv6" $inet6_failed
3468a2292bb3a53a252df0f916e4034e8e6f9dccMaciek Makowski # Unfortunately, if a driver unloads and then is subsequently reloaded,
3468a2292bb3a53a252df0f916e4034e8e6f9dccMaciek Makowski # no mechanism currently exists to restore the properties of its
3468a2292bb3a53a252df0f916e4034e8e6f9dccMaciek Makowski # associated links. Hence, we wait until after interfaces have been
3468a2292bb3a53a252df0f916e4034e8e6f9dccMaciek Makowski # plumbed (above) to initialize link properties.
3468a2292bb3a53a252df0f916e4034e8e6f9dccMaciek Makowski# Process the /etc/hostname.* files of plumbed IPv4 interfaces. If an
3468a2292bb3a53a252df0f916e4034e8e6f9dccMaciek Makowski# /etc/hostname file is not present or is empty, the ifconfig auto-dhcp
3468a2292bb3a53a252df0f916e4034e8e6f9dccMaciek Makowski# / auto-revarp command will attempt to set the address, later.
3468a2292bb3a53a252df0f916e4034e8e6f9dccMaciek Makowski# If /etc/hostname.lo0 exists the loop below will do additional
3468a2292bb3a53a252df0f916e4034e8e6f9dccMaciek Makowski# configuration of lo0.
3468a2292bb3a53a252df0f916e4034e8e6f9dccMaciek Makowskiif [ -n "$inet_plumbed" ]; then
3468a2292bb3a53a252df0f916e4034e8e6f9dccMaciek Makowski echo "configuring IPv4 interfaces:\c"
95932c57191afb21b59187129e4fed66250500ecMaciek Makowski inet_process_hostname /sbin/ifconfig $1 inet \
95932c57191afb21b59187129e4fed66250500ecMaciek Makowski [ -n "$i4s_fail" ] && warn_failed_ifs "configure IPv4" $i4s_fail
3468a2292bb3a53a252df0f916e4034e8e6f9dccMaciek Makowski# Process the /etc/hostname6.* files of plumbed IPv6 interfaces. After
3468a2292bb3a53a252df0f916e4034e8e6f9dccMaciek Makowski# processing the hostname6 file, bring the interface up. If
3468a2292bb3a53a252df0f916e4034e8e6f9dccMaciek Makowski# /etc/hostname6.lo0 exists the loop below will do additional
3468a2292bb3a53a252df0f916e4034e8e6f9dccMaciek Makowski# configuration of lo0.
3468a2292bb3a53a252df0f916e4034e8e6f9dccMaciek Makowskiif [ -n "$inet6_plumbed" ]; then
3468a2292bb3a53a252df0f916e4034e8e6f9dccMaciek Makowski echo "configuring IPv6 interfaces:\c"
95932c57191afb21b59187129e4fed66250500ecMaciek Makowski inet6_process_hostname /sbin/ifconfig $1 inet6 \
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder [ -n "$i6_fail" ] && warn_failed_ifs "configure IPv6" $i6_fail
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski# Run DHCP if requested. Skip boot-configured interface.
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowskiinterface_names="`echo /etc/dhcp.*[0-9] 2>/dev/null`"
95932c57191afb21b59187129e4fed66250500ecMaciek Makowskiif [ "$interface_names" != '/etc/dhcp.*[0-9]' ]; then
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder # First find the primary interface. Default to the first
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder # interface if not specified. First primary interface found
c616e681da8c052b62e14247fea522da099ac0e4Christian Maeder # "wins". Use care not to "reconfigure" a net-booted interface
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder # configured using DHCP. Run through the list of interfaces
e73be37c05d01fc538553efbf77c1d330cf11542Till Mossakowski # again, this time trying DHCP.
47af295501ed5f407848f61b9943d58ccb43be29Till Mossakowski [ -n "$primary" ] && break
47af295501ed5f407848f61b9943d58ccb43be29Till Mossakowski echo "starting DHCP on primary interface $primary"
set -- $interface_names
unset ORIGIFS
# If the /etc/defaultrouter file exists, process it now so that the next
read ip;
read mask;
read router;
exit $SMF_EXIT_OK
done && exit $SMF_EXIT_OK
done && exit $SMF_EXIT_OK
exit $SMF_EXIT_ERR_CONFIG