net-physical revision d62bc4badc1c1f1549c961cfb8b420e650e1272b
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj# CDDL HEADER START
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj# The contents of this file are subject to the terms of the
c25203fdca093d4504c51b4cd974ff60d5aa4fb1wrowe# Common Development and Distribution License (the "License").
c25203fdca093d4504c51b4cd974ff60d5aa4fb1wrowe# You may not use this file except in compliance with the License.
d89c116f82699294ca744125723651c554bc5925wrowe# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
8721697e2aece27b0e738519329f7976c72b27bfjerenkrantz# See the License for the specific language governing permissions
c25203fdca093d4504c51b4cd974ff60d5aa4fb1wrowe# and limitations under the License.
91cacb801f6c0215b38322f6d2fc58cbfedfecfbjerenkrantz# When distributing Covered Code, include this CDDL HEADER in each
df14f0d3a5191cdd7c4bb5b03acd135d43a6f51brbb# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
df14f0d3a5191cdd7c4bb5b03acd135d43a6f51brbb# If applicable, add the following below this CDDL HEADER, with the
ab71b233b3a36489e44a7b061c48293be0b17788jwoolley# fields enclosed by brackets "[]" replaced with your own identifying
571760de5e60c0b459cb11be45507b923cd023eejwoolley# information: Portions Copyright [yyyy] [name of copyright owner]
9180a5933673ffb1af633c255ceee029340f3b1erbb# CDDL HEADER END
2900ab946a2d76b73a14cebfe2985d253f01c967stoddard# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
a548c09e6a8ca1b059d0e93b5256c6ccb2b3c3cdrbb# Use is subject to license terms.
a548c09e6a8ca1b059d0e93b5256c6ccb2b3c3cdrbb# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
b876b7bcf0ce3d232da723246d709e8dbbfe8762rbb# All rights reserved.
6f6f4a4bca281779d196acbdd5c017bb90858305trawick# ident "%Z%%M% %I% %E% SMI"
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj# In a shared-IP zone we need this service to be up, but all of the work
af4c982a7cf4515f124935f99a329744035fc699slive# it tries to do is irrelevant (and will actually lead to the service
af4c982a7cf4515f124935f99a329744035fc699slive# failing if we try to do it), so just bail out.
af4c982a7cf4515f124935f99a329744035fc699slive# In the global zone and exclusive-IP zones we proceed.
af4c982a7cf4515f124935f99a329744035fc699slive# Print warnings to console
4b62424416882687387923b3130b96241503cbe0jerenkrantz echo "Failed to $1 interface(s): $2" >/dev/msglog
0d2f57cf389a981efa5e98d9b451c6baf0af12bfjerenkrantz# Make sure that the libraries essential to this stage of booting can be found.
0d2f57cf389a981efa5e98d9b451c6baf0af12bfjerenkrantz# Cause ifconfig to not automatically start in.mpathd when IPMP groups are
0d2f57cf389a981efa5e98d9b451c6baf0af12bfjerenkrantz# configured. This is not strictly necessary but makes it so that in.mpathd
0d2f57cf389a981efa5e98d9b451c6baf0af12bfjerenkrantz# will always be started explicitly from /etc/init.d/inetinit, when we're
a12b7938cf47a0017a70ba195bbce035aa040e38aaron# sure that /usr is mounted.
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz # Upgrade handling. The upgrade file consists of a series of dladm(1M)
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe # commands. Note that after we are done, we cannot rename the upgrade
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz # script file as the file system is still read-only at this point.
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz # Defer this to the manifest-import service.
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz upgrade_script=/var/svc/profile/upgrade_datalink
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz if [ -f "${upgrade_script}" ]; then
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz . "${upgrade_script}"
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz # Bring up link aggregations and initialize security objects.
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz # Note that link property initialization is deferred until after
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz # IP interfaces are plumbed to ensure that the links will not
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe # be unloaded (and the property settings lost).
1b3f48fd6b1ccb8745f908e40156c5a85ca3c347jerenkrantz# If the system was net booted by DHCP, hand DHCP management off to the
984a1ce6391060f0eea811dbbdbc993250399aa1stoddard# DHCP agent (ifconfig communicates to the DHCP agent through the
984a1ce6391060f0eea811dbbdbc993250399aa1stoddard# loopback interface).
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewroweif [ -n "$_INIT_NET_IF" -a "$_INIT_NET_STRATEGY" = "dhcp" ]; then
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe# The network initialization is done early to support diskless and
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe# dataless configurations. For IPv4 interfaces that were configured by
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe# the kernel (e.g. those on diskless machines) and not configured by
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe# DHCP, reset the netmask using the local "/etc/netmasks" file if one
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe# exists, and then reset the broadcast address based on the netmask.
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe# All the IPv4 and IPv6 interfaces are plumbed before doing any
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe# interface configuration. This prevents errors from plumb failures
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe# getting mixed in with the configured interface lists that the script
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe# Get the list of IPv4 interfaces to configure by breaking
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe# /etc/hostname.* into separate args by using "." as a shell separator
638a9edaf48cf003cd40ac25ee8c25f572107414stoddard# character.
638a9edaf48cf003cd40ac25ee8c25f572107414stoddardinterface_names="`echo /etc/hostname.*[0-9] 2>/dev/null`"
83d91d60d00dc345bfbcbc48ff206db4a6b23b2eaaronif [ "$interface_names" != "/etc/hostname.*[0-9]" ]; then
a12f07383f9c286519fe88f559187148d5bd1c16aaron# Get the list of IPv6 interfaces to configure by breaking
1ea5221b240a8b41a07c6fb04aab5a73adcddabfaaron# /etc/hostname6.* into separate args by using "." as a shell separator
1ea5221b240a8b41a07c6fb04aab5a73adcddabfaaron# character.
5d12baef135b5d3cb94745e007a1575398469724jerenkrantzinterface_names="`echo /etc/hostname6.*[0-9] 2>/dev/null`"
5d12baef135b5d3cb94745e007a1575398469724jerenkrantzif [ "$interface_names" != "/etc/hostname6.*[0-9]" ]; then
5d12baef135b5d3cb94745e007a1575398469724jerenkrantz if [ $# -gt 1 -a "$2" != "/etc/hostname6" ]; then
5d12baef135b5d3cb94745e007a1575398469724jerenkrantz while [ $# -gt 1 -a "$1" != "/etc/hostname6" ]; do
b865daaa4ef731a7066ee6d97e2aae36c7743939jerenkrantz# Step through the IPv4 interface list and try to plumb every interface.
b865daaa4ef731a7066ee6d97e2aae36c7743939jerenkrantz# Generate list of plumbed and failed IPv4 interfaces.
b865daaa4ef731a7066ee6d97e2aae36c7743939jerenkrantzif [ -n "$inet_list" ]; then
dc098c7ce5d36179c504d09fc722d190683d0262aaron [ -n "$inet_failed" ] && warn_failed_ifs "plumb IPv4" $inet_failed
0bcb1fe39dfaacf9745b6633f5cc9ebc8e2596caaaron# Run autoconf to connect to a WLAN if the interface is a wireless one
ff42f83cbf31893bcde9712332a8e5ee970f6a74trawick# Step through the IPv6 interface list and plumb every interface.
33f5961d34a8b5390cebad0543b3ebe67830e5d7jerenkrantz# Generate list of plumbed and failed IPv6 interfaces. Each plumbed
54e1babd5a5a56c576eeeace54110150769cc916coar# interface will be brought up later, after processing any contents of
54e1babd5a5a56c576eeeace54110150769cc916coar# the /etc/hostname6.* file.
54e1babd5a5a56c576eeeace54110150769cc916coarif [ -n "$inet6_list" ]; then
949aa7bba7f804faa8e6b08cad42a98fc0255d85jerenkrantz [ -n "$inet6_failed" ] && warn_failed_ifs "plumb IPv6" $inet6_failed
e0427bf8e52a8fb920cb8b6adb5cdb3b6535b7fecoar # Unfortunately, if a driver unloads and then is subsequently reloaded,
e0427bf8e52a8fb920cb8b6adb5cdb3b6535b7fecoar # no mechanism currently exists to restore the properties of its
07021d9f405849228b859d9fb4b877f20e4fbba3jerenkrantz # associated links. Hence, we wait until after interfaces have been
07021d9f405849228b859d9fb4b877f20e4fbba3jerenkrantz # plumbed (above) to initialize link properties.
f126ee03179eb54308118f1ec3de5a7b461685d8aaron# Process the /etc/hostname.* files of plumbed IPv4 interfaces. If an
f126ee03179eb54308118f1ec3de5a7b461685d8aaron# /etc/hostname file is not present or is empty, the ifconfig auto-dhcp
f126ee03179eb54308118f1ec3de5a7b461685d8aaron# / auto-revarp command will attempt to set the address, later.
f126ee03179eb54308118f1ec3de5a7b461685d8aaron# If /etc/hostname.lo0 exists the loop below will do additional
f126ee03179eb54308118f1ec3de5a7b461685d8aaron# configuration of lo0.
f126ee03179eb54308118f1ec3de5a7b461685d8aaronif [ -n "$inet_plumbed" ]; then
f126ee03179eb54308118f1ec3de5a7b461685d8aaron echo "configuring IPv4 interfaces:\c"
109faf633e12ab0bbdd602c7addc795cce59e8addreid echo " $1\c"
109faf633e12ab0bbdd602c7addc795cce59e8addreid [ -n "$i4s_fail" ] && warn_failed_ifs "configure IPv4" $i4s_fail
109faf633e12ab0bbdd602c7addc795cce59e8addreid# Process the /etc/hostname6.* files of plumbed IPv6 interfaces. After
109faf633e12ab0bbdd602c7addc795cce59e8addreid# processing the hostname6 file, bring the interface up. If
109faf633e12ab0bbdd602c7addc795cce59e8addreid# /etc/hostname6.lo0 exists the loop below will do additional
4ca13a5e126946272f02637e268a8e09193c553ecoar# configuration of lo0.
4ca13a5e126946272f02637e268a8e09193c553ecoarif [ -n "$inet6_plumbed" ]; then
4ca13a5e126946272f02637e268a8e09193c553ecoar echo "configuring IPv6 interfaces:\c"
48c0c81cd6fabac9d3386406d97633780365b839coar echo " $1\c"
b84f66c93f820824b1d5455181f55598b766319cwrowe [ -n "$i6_fail" ] && warn_failed_ifs "configure IPv6" $i6_fail
7fe18c15b669db9d191859695901dc4fcf3829dawrowe# Run DHCP if requested. Skip boot-configured interface.
b84f66c93f820824b1d5455181f55598b766319cwrowe # First find the primary interface. Default to the first
60d567a0c2aae815ee6fc20c0d65032bea52c92cwrowe # interface if not specified. First primary interface found
60d567a0c2aae815ee6fc20c0d65032bea52c92cwrowe # "wins". Use care not to "reconfigure" a net-booted interface
60d567a0c2aae815ee6fc20c0d65032bea52c92cwrowe # configured using DHCP. Run through the list of interfaces
d24a92b8a8315e9a266ba84cc2a996d49dd546c1stoddard # again, this time trying DHCP.
3913a3b7e7c72ea11d05da36275db39c2dc39b68jwoolley [ -n "$primary" ] && break
1c6fb1e726ce22694de0e9a957adb67b929e5d4fstoddard echo "starting DHCP on primary interface $primary"
d2f8b010487ffa990a9c268df5a25579e7291bcdrbb # Exit code 4 means ifconfig timed out waiting for dhcpagent
d2f8b010487ffa990a9c268df5a25579e7291bcdrbb [ $? != 0 ] && [ $? != 4 ] && i4d_fail="$i4d_fail $primary"
ff849e4163ed879288f0df15f78b6c9d278ec804fanf echo "starting DHCP on interface $1"
447c6ce3ff08073c44f6785d5256271fcb877512wrowe # Exit code can't be timeout when wait is 0
6758b07b4b79f898b0f56375016cea7da0bfb495wrowe [ -n "$i4d_fail" ] && warn_failed_ifs "configure IPv4 DHCP" $i4d_fail
dd4713dc5b186f4d1be7b88f86608fdb84cbe5d5gstein# In order to avoid bringing up the interfaces that have
48c0c81cd6fabac9d3386406d97633780365b839coar# intentionally been left down, perform RARP only if the system
48c0c81cd6fabac9d3386406d97633780365b839coar# has no configured hostname in /etc/nodename
48c0c81cd6fabac9d3386406d97633780365b839coarif [ "$_INIT_NET_STRATEGY" = "rarp" -o -z "$hostname" ]; then
db3ccce11afac4fc1d4f51a65424412f7480c46cgstein /sbin/ifconfig -adD4 auto-revarp netmask + broadcast + up
cf6bf6c34c936e6a6fe731dbce4a5c3c8bf8e9a3gstein# Process IPv4 and IPv6 interfaces that failed to plumb. Find an
cf6bf6c34c936e6a6fe731dbce4a5c3c8bf8e9a3gstein# alternative interface to host the addresses.
14cccaddba3a9263cf0d0ddc311e18f3e3dc9b0fgstein# If the /etc/defaultrouter file exists, process it now so that the next
14cccaddba3a9263cf0d0ddc311e18f3e3dc9b0fgstein# stage of booting will have access to NFS.
60d567a0c2aae815ee6fc20c0d65032bea52c92cwrowe# If we get here and were not asked to plumb any IPv4 interfaces, look
48c0c81cd6fabac9d3386406d97633780365b839coar# for boot properties that direct us.
60d567a0c2aae815ee6fc20c0d65032bea52c92cwrowe# - The "network-interface" property is required and indicates the
60d567a0c2aae815ee6fc20c0d65032bea52c92cwrowe# interface name.
60d567a0c2aae815ee6fc20c0d65032bea52c92cwrowe# - The "xpv-hcp" property, if present, is used by the hypervisor
60d567a0c2aae815ee6fc20c0d65032bea52c92cwrowe# tools to indicate how the specified interface should be configured.
60d567a0c2aae815ee6fc20c0d65032bea52c92cwrowe# Permitted values are "dhcp" and "off", where "off" indicates static
fdff4ace2701177219fe1c444f69242372423354aaron# IP configuration.
fdff4ace2701177219fe1c444f69242372423354aaron# In the case where "xpv-hcp" is set to "dhcp", no further properties
fdff4ace2701177219fe1c444f69242372423354aaron# are required or examined.
fdff4ace2701177219fe1c444f69242372423354aaron# In the case where "xpv-hcp" is not present or set to "off", the
fdff4ace2701177219fe1c444f69242372423354aaron# "host-ip" and "subnet-mask" properties are used to configure
fdff4ace2701177219fe1c444f69242372423354aaron# the specified interface. The "router-ip" property, if present,
27757f6699a924d4b493a1b6cceb27df27a43287dreid# is used to add a default route.
7169eebe7cef1a6bbd082f28b1906f91b6fc6621stoddardif smf_is_globalzone && [ -z "$inet_list" ] && [ -n "$nic" ]; then
48c0c81cd6fabac9d3386406d97633780365b839coar [ $? != 0 ] && [ $? != 4 ] && \
64ad864fa0f4493eebb181e393b40a8a90beccb9coar# We tell smf this service is online if any of the following is true:
64ad864fa0f4493eebb181e393b40a8a90beccb9coar# - no interfaces were configured for plumbing and no DHCP failures
48c0c81cd6fabac9d3386406d97633780365b839coar# - any non-loopback IPv4 interfaces are up and have a non-zero address
64ad864fa0f4493eebb181e393b40a8a90beccb9coar# - there are any DHCP interfaces started
64ad864fa0f4493eebb181e393b40a8a90beccb9coar# - any non-loopback IPv6 interfaces are up
48c0c81cd6fabac9d3386406d97633780365b839coar# If we weren't asked to configure any interfaces, exit
64ad864fa0f4493eebb181e393b40a8a90beccb9coar # Config error if DHCP was attempted without plumbed interfaces
64ad864fa0f4493eebb181e393b40a8a90beccb9coar# Any non-loopback IPv4 interfaces with usable addresses up?
48c0c81cd6fabac9d3386406d97633780365b839coar done && exit $SMF_EXIT_OK
64ad864fa0f4493eebb181e393b40a8a90beccb9coar# Any DHCP interfaces started?
48c0c81cd6fabac9d3386406d97633780365b839coar[ -n "`/sbin/ifconfig -a4 dhcp status 2>/dev/null`" ] && exit $SMF_EXIT_OK
64ad864fa0f4493eebb181e393b40a8a90beccb9coar# Any non-loopback IPv6 interfaces up?
64ad864fa0f4493eebb181e393b40a8a90beccb9coar [ $intf = inet6 ] && [ $addr != ::1/128 ] && exit $SMF_EXIT_OK
64ad864fa0f4493eebb181e393b40a8a90beccb9coar done && exit $SMF_EXIT_OK
64ad864fa0f4493eebb181e393b40a8a90beccb9coar# This service was supposed to configure something yet didn't. Exit
64ad864fa0f4493eebb181e393b40a8a90beccb9coar# with config error.