net-physical revision 6ba597c56d749c61b4f783157f63196d7b2445f0
6fe48fb46e53ffc37542853a1edb74cb481b7d94Automatic Updater# CDDL HEADER START
19558a04decde0e7261d489d92d04ad88104217bTinderbox User# The contents of this file are subject to the terms of the
827f8cccb5280f4da66c46186e792d1cb9d73503Mark Andrews# Common Development and Distribution License (the "License").
827f8cccb5280f4da66c46186e792d1cb9d73503Mark Andrews# You may not use this file except in compliance with the License.
03ebc228ee3725738b067b6bd7082a9a731822a1Tinderbox User# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
a2c370ca12bb0360ff7e969474ead3f788c65fffTinderbox User# See the License for the specific language governing permissions
8de3f14f1c300c3e1ed99084cc03485b42c92bf1Tinderbox User# and limitations under the License.
950d203b64f512b85fcc093ee1e9e3e531a1aea3Tinderbox User# When distributing Covered Code, include this CDDL HEADER in each
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
03ebc228ee3725738b067b6bd7082a9a731822a1Tinderbox User# If applicable, add the following below this CDDL HEADER, with the
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont# fields enclosed by brackets "[]" replaced with your own identifying
e676a596869d8a80a644c99a848afb53d1c5975eMark Andrews# information: Portions Copyright [yyyy] [name of copyright owner]
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont# CDDL HEADER END
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont# Use is subject to license terms.
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User# All rights reserved.
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews# In a shared-IP zone we need this service to be up, but all of the work
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews# it tries to do is irrelevant (and will actually lead to the service
30370d905e9be3be7d9b947fd432bacecbb13bb9Evan Hunt# failing if we try to do it), so just bail out.
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# In the global zone and exclusive-IP zones we proceed.
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews# Make sure that the libraries essential to this stage of booting can be found.
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt # Update PVID on interfaces configured with VLAN 1
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt # Upgrade handling. The upgrade file consists of a series of dladm(1M)
dc238a06bffa79de141ee7655765e2df91498a8aTinderbox User # commands. Note that after we are done, we cannot rename the upgrade
827f8cccb5280f4da66c46186e792d1cb9d73503Mark Andrews # script file as the file system is still read-only at this point.
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt # Defer this to the manifest-import service.
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater upgrade_script=/var/svc/profile/upgrade_datalink
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont if [ -f "${upgrade_script}" ]; then
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater . "${upgrade_script}"
30370d905e9be3be7d9b947fd432bacecbb13bb9Evan Hunt # Bring up simnets, link aggregations and initialize security objects.
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # Note that link property initialization is deferred until after
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # IP interfaces are plumbed to ensure that the links will not
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater # be unloaded (and the property settings lost). We should bring
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # up simnets prior to VLANs/Aggrs to enable creation of VLANs/Aggrs
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews # over simnets.
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews # Bring up VNICs
03ebc228ee3725738b067b6bd7082a9a731822a1Tinderbox User # Create flows via flowadm.
2ae159b376dac23870d8005563c585acf85a4b5aEvan Hunt# If the system was net booted by DHCP, hand DHCP management off to the
2ae159b376dac23870d8005563c585acf85a4b5aEvan Hunt# DHCP agent (ifconfig communicates to the DHCP agent through the
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews# loopback interface).
2ae159b376dac23870d8005563c585acf85a4b5aEvan Huntif [ -n "$_INIT_NET_IF" -a "$_INIT_NET_STRATEGY" = "dhcp" ]; then
549c517e2ecad52bb1d32f08920e29d4e8cda71eTinderbox User# The network initialization is done early to support diskless and
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# dataless configurations. For IPv4 interfaces that were configured by
549c517e2ecad52bb1d32f08920e29d4e8cda71eTinderbox User# the kernel (e.g. those on diskless machines) and not configured by
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# DHCP, reset the netmask using the local "/etc/netmasks" file if one
e40c4e4c17d4df338e2a7db0f84d8dbb3858964cTinderbox User# exists, and then reset the broadcast address based on the netmask.
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User /sbin/dladm show-iptun -P $intf > /dev/null 2>&1
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson if [ $? -eq 0 ]; then
30370d905e9be3be7d9b947fd432bacecbb13bb9Evan Hunt if [ $# -eq 2 -a \( "$1" = "ip" -o "$1" = "ip6" \) ]; then
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User # It looks like one, but another type of link might be
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson # using a name that looks like an implicit IP tunnel.
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User # If dladm show-link -P finds it, then it's not an IP
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews /sbin/dladm show-link -Pp $intf > /dev/null 2>&1
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User if [ $? -eq 0 ]; then
a450977e98155f6e828fe6f8d52cf24674231831Mark Andrews# All the IPv4 and IPv6 interfaces are plumbed before doing any
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews# interface configuration. This prevents errors from plumb failures
827f8cccb5280f4da66c46186e792d1cb9d73503Mark Andrews# getting mixed in with the configured interface lists that the script
e40c4e4c17d4df338e2a7db0f84d8dbb3858964cTinderbox User# Get the list of IPv4 interfaces to configure by breaking
827f8cccb5280f4da66c46186e792d1cb9d73503Mark Andrews# /etc/hostname.* into separate args by using "." as a shell separator
e40c4e4c17d4df338e2a7db0f84d8dbb3858964cTinderbox Userinterface_names="`echo /etc/hostname.*[0-9] 2>/dev/null`"
5747235bf35e7398984fd6b4632743396895ea7aTinderbox Userif [ "$interface_names" != "/etc/hostname.*[0-9]" ]; then
5747235bf35e7398984fd6b4632743396895ea7aTinderbox User while [ $# -gt 1 -a "$2" != "/etc/hostname" ]; do
827f8cccb5280f4da66c46186e792d1cb9d73503Mark Andrews # skip IP tunnel interfaces plumbed by net-iptun.
30370d905e9be3be7d9b947fd432bacecbb13bb9Evan Hunt# Get the list of IPv6 interfaces to configure by breaking
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# /etc/hostname6.* into separate args by using "." as a shell separator
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox Userinterface_names="`echo /etc/hostname6.*[0-9] 2>/dev/null`"
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrewsif [ "$interface_names" != "/etc/hostname6.*[0-9]" ]; then
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews while [ $# -gt 1 -a "$2" != "/etc/hostname6" ]; do
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # skip IP tunnel interfaces plumbed by net-iptun.
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User# Create all of the IPv4 IPMP interfaces.
30370d905e9be3be7d9b947fd432bacecbb13bb9Evan Huntif [ -n "$ipmp_list" ]; then
5affecff6e148a8e124d03f5dbac0da11e30dcc5Tinderbox User [ -n "$ipmp_failed" ] && warn_failed_ifs "create IPv4 IPMP" \
1fce11b1d3f2d461d261156b8cdc64ab864f06a9Tinderbox User# Step through the IPv4 interface list and try to plumb every interface.
f0c5e918974bf778af6cd1e25309ad13e30a79a6Tinderbox User# Generate list of plumbed and failed IPv4 interfaces.
7ca715ad1587a68a531ea1cdea07515d7232567eTinderbox Userif [ -n "$inet_list" ]; then
bac4435d473c9a0281507524f084480c34aa942aTinderbox User if /sbin/ifconfig $1 inet >/dev/null 2>&1; then
ac2e2800b4ac9cbe4cb756d967f4583c611eb75eMark Andrews [ -n "$inet_failed" ] && warn_failed_ifs "plumb IPv4" "$inet_failed"
f525041ae26958385b697cf82a30f108577024b6Tinderbox User# Run autoconf to connect to a WLAN if the interface is a wireless one
b02be031b9ff37b042adc8e68e36b8bbc1f672b7Tinderbox Userif [ -x /sbin/wificonfig -a -n "$inet_plumbed" ]; then
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater# Step through the IPv6 interface list and plumb every interface.
ecbc7ebb243a1f8a5dc6f28185ffe9e61d3b2102Mark Andrews# Generate list of plumbed and failed IPv6 interfaces. Each plumbed
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater# interface will be brought up later, after processing any contents of
39ae0eafed076ef769fef5c18b22a8051df5c93aTinderbox Userif [ -n "$inet6_list" ]; then
dc238a06bffa79de141ee7655765e2df91498a8aTinderbox User if /sbin/ifconfig $1 inet6 >/dev/null 2>&1; then
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews [ -n "$inet6_failed" ] && warn_failed_ifs "plumb IPv6" "$inet6_failed"
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater# Create all of the IPv6 IPMP interfaces.
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrewsif [ -n "$ipmp6_list" ]; then
5affecff6e148a8e124d03f5dbac0da11e30dcc5Tinderbox User [ -n "$ipmp6_failed" ] && warn_failed_ifs "create IPv6 IPMP" \
a2c370ca12bb0360ff7e969474ead3f788c65fffTinderbox User# Process the /etc/hostname[6].* files for IPMP interfaces. Processing these
a2c370ca12bb0360ff7e969474ead3f788c65fffTinderbox User# before non-IPMP interfaces avoids accidental implicit IPMP group creation.
757ff043760e4743dda1a10e7d58349275934902Tinderbox User[ -n "$ipmp_created" ] && if_configure inet "IPMP" $ipmp_created
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater[ -n "$ipmp6_created" ] && if_configure inet6 "IPMP" $ipmp6_created
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson# Process the /etc/hostname[6].* files for non-IPMP interfaces.
5affecff6e148a8e124d03f5dbac0da11e30dcc5Tinderbox User[ -n "$inet_plumbed" ] && if_configure inet "" $inet_plumbed
5affecff6e148a8e124d03f5dbac0da11e30dcc5Tinderbox User[ -n "$inet6_plumbed" ] && if_configure inet6 "" $inet6_plumbed
a2c370ca12bb0360ff7e969474ead3f788c65fffTinderbox User# For the IPv4 and IPv6 interfaces that failed to plumb, find (or create)
f520803b46dc189fdaf84adc87ef327d3587b435Mark Andrews# IPMP meta-interfaces to host their data addresses.
03ebc228ee3725738b067b6bd7082a9a731822a1Tinderbox User[ -n "$inet6_failed" ] && move_addresses inet6
e40c4e4c17d4df338e2a7db0f84d8dbb3858964cTinderbox User# Run DHCP if requested. Skip boot-configured interface.
e64202536ea72d8f371dd0df9fc763f8d70bf886Tinderbox Userinterface_names="`echo /etc/dhcp.*[0-9] 2>/dev/null`"
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrewsif [ "$interface_names" != '/etc/dhcp.*[0-9]' ]; then
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson # First find the primary interface. Default to the first
9ecb5d33470ebfb3719a1b8d56bcefdf4b27f7b2Tinderbox User # interface if not specified. First primary interface found
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews # "wins". Use care not to "reconfigure" a net-booted interface
30370d905e9be3be7d9b947fd432bacecbb13bb9Evan Hunt # configured using DHCP. Run through the list of interfaces
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews # again, this time trying DHCP.
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews [ -n "$primary" ] && break
30370d905e9be3be7d9b947fd432bacecbb13bb9Evan Hunt echo "starting DHCP on primary interface $primary"
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews /sbin/ifconfig $primary auto-dhcp primary $cmdline
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews # Exit code 4 means ifconfig timed out waiting for dhcpagent
e8fc8c884b44371784805e1e0d3100da403dd3f1Automatic Updater [ $? != 0 ] && [ $? != 4 ] && i4d_fail="$i4d_fail $primary"
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews echo "starting DHCP on interface $1"
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews # Exit code can't be timeout when wait is 0
827f8cccb5280f4da66c46186e792d1cb9d73503Mark Andrews [ -n "$i4d_fail" ] && warn_failed_ifs "configure IPv4 DHCP" "$i4d_fail"
03ebc228ee3725738b067b6bd7082a9a731822a1Tinderbox User# In order to avoid bringing up the interfaces that have
827f8cccb5280f4da66c46186e792d1cb9d73503Mark Andrews# intentionally been left down, perform RARP only if the system
827f8cccb5280f4da66c46186e792d1cb9d73503Mark Andrews# has no configured hostname in /etc/nodename
e64202536ea72d8f371dd0df9fc763f8d70bf886Tinderbox Userif [ "$_INIT_NET_STRATEGY" = "rarp" -o -z "$hostname" ]; then
015055b6e23f5c08f6a5b34726f90b62597e9e45Tinderbox User /sbin/ifconfig -adD4 auto-revarp netmask + broadcast + up
e40c4e4c17d4df338e2a7db0f84d8dbb3858964cTinderbox User# If the /etc/defaultrouter file exists, process it now so that the next
757ff043760e4743dda1a10e7d58349275934902Tinderbox User# stage of booting will have access to NFS.
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont *) /sbin/route -n add default -gateway $router ;;
30370d905e9be3be7d9b947fd432bacecbb13bb9Evan Hunt# If we get here and were not asked to plumb any IPv4 interfaces, look
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# for boot properties that direct us.
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews# - The "network-interface" property is required and indicates the
e813f036c8251b6d9d2a72fa84f80c2c9d2795afMark Andrews# interface name.
30370d905e9be3be7d9b947fd432bacecbb13bb9Evan Hunt# - The "xpv-hcp" property, if present, is used by the hypervisor
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# tools to indicate how the specified interface should be configured.
3a988722ad9e209ba4064604d482dc4efe0e19ebTinderbox User# Permitted values are "dhcp" and "off", where "off" indicates static
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# IP configuration.
a3ffa9ab0644ae2b52f2e13a00b5e85b879f612fTinderbox User# In the case where "xpv-hcp" is set to "dhcp", no further properties
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont# are required or examined.
1bf507ca635310b340aea42d6c3e567819974a99Tinderbox User# In the case where "xpv-hcp" is not present or set to "off", the
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# "host-ip" and "subnet-mask" properties are used to configure
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# the specified interface. The "router-ip" property, if present,
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# is used to add a default route.
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrewsif smf_is_globalzone && [ -z "$inet_list" ] && [ -n "$nic" ]; then
a5636b773fa05a272b6876afd99309c0b3090e2fMark Andrews [ -n "`/sbin/ifconfig $nic 2>/dev/null`" ] && (
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont # Given that this is the only IPv4 interface,
dedefc0bdbb4e6e39eeb98aa2fc6883efec2ddb0Mark Andrews echo "starting DHCP on primary interface $primary";
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington # Exit code 4 means ifconfig timed out waiting
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington [ $? != 0 ] && [ $? != 4 ] && \
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington /sbin/devprop host-ip subnet-mask router-ip | (
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington [ -n "`/sbin/ifconfig $nic 2>/dev/null`" ] && (
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# We tell smf this service is online if any of the following is true:
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# - no interfaces were configured for plumbing and no DHCP failures
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# - any non-loopback IPv4 interfaces are up and have a non-zero address
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# - there are any DHCP interfaces started
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# - any non-loopback IPv6 interfaces are up
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# If we weren't asked to configure any interfaces, exit
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellingtonif [ -z "$inet_list" ] && [ -z "$inet6_list" ]; then
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington # Config error if DHCP was attempted without plumbed interfaces
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington [ -n "$i4d_fail" ] && exit $SMF_EXIT_ERR_CONFIG
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# Any non-loopback IPv4 interfaces with usable addresses up?
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington /sbin/ifconfig -a4u | while read intf addr rest; do
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington [ $intf = inet ] && [ $addr != 127.0.0.1 ] &&
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews# Any DHCP interfaces started?
0eb371ca0dab50ae3462e98794a6126198c52f4bMark Andrews[ -n "`/sbin/ifconfig -a4 dhcp status 2>/dev/null`" ] && exit $SMF_EXIT_OK
30370d905e9be3be7d9b947fd432bacecbb13bb9Evan Hunt# Any non-loopback IPv6 interfaces up?
646fed0d28be4387e3e32fb0f5732a1f58b572baTinderbox User /sbin/ifconfig -au6 | while read intf addr rest; do
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updater [ $intf = inet6 ] && [ $addr != ::1/128 ] && exit $SMF_EXIT_OK
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updater# This service was supposed to configure something yet didn't. Exit
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updater# with config error.