net-physical revision d62bc4badc1c1f1549c961cfb8b420e650e1272b
48c0c81cd6fabac9d3386406d97633780365b839coar#!/sbin/sh
8c8497c39e75d88500a703511e8fba9dbe7596a7rbb#
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj# CDDL HEADER START
2a6c49cfaef5979a5a06098f3ce987cd76769409manoj#
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.
c25203fdca093d4504c51b4cd974ff60d5aa4fb1wrowe#
d89c116f82699294ca744125723651c554bc5925wrowe# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
4214e98fc9045e5010e66f9a967bd6d68f40d342aaron# or http://www.opensolaris.org/os/licensing.
8721697e2aece27b0e738519329f7976c72b27bfjerenkrantz# See the License for the specific language governing permissions
c25203fdca093d4504c51b4cd974ff60d5aa4fb1wrowe# and limitations under the License.
91cacb801f6c0215b38322f6d2fc58cbfedfecfbjerenkrantz#
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]
571760de5e60c0b459cb11be45507b923cd023eejwoolley#
9180a5933673ffb1af633c255ceee029340f3b1erbb# CDDL HEADER END
bcb6e1be6041dfeb549c8ea8d37f97ad4e90a0c3rbb#
9bd71e35f5d26d26d23fe3a677401828e842ed72wrowe#
2900ab946a2d76b73a14cebfe2985d253f01c967stoddard# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
a548c09e6a8ca1b059d0e93b5256c6ccb2b3c3cdrbb# Use is subject to license terms.
a548c09e6a8ca1b059d0e93b5256c6ccb2b3c3cdrbb#
a548c09e6a8ca1b059d0e93b5256c6ccb2b3c3cdrbb# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
b876b7bcf0ce3d232da723246d709e8dbbfe8762rbb# All rights reserved.
cf6bf6c34c936e6a6fe731dbce4a5c3c8bf8e9a3gstein#
35330e0d79ceb8027223bbb8330a381b1f989d6etrawick#
6f6f4a4bca281779d196acbdd5c017bb90858305trawick# ident "%Z%%M% %I% %E% SMI"
8dd4618c4709236b4ea297d7250d282e463ce2d8rbb
09bd86d0db1114ee23eda0a6eb76ca055877a1cftrawick. /lib/svc/share/smf_include.sh
2deb319e6b3de239f45c16a3e9e836d44f1f7108rbb. /lib/svc/share/net_include.sh
bd929c73ef04789b7183b840d8db6e01d03a4d86rbb
70f6f32765cfaadd6da8de6f0fea97ddd72d8fadmanoj#
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#
af4c982a7cf4515f124935f99a329744035fc699slivesmf_configure_ip || exit $SMF_EXIT_OK
af4c982a7cf4515f124935f99a329744035fc699slive
af4c982a7cf4515f124935f99a329744035fc699slive# Print warnings to console
10270f6f94b2069d0d357805c140a9897449b9ccianhwarn_failed_ifs() {
4b62424416882687387923b3130b96241503cbe0jerenkrantz echo "Failed to $1 interface(s): $2" >/dev/msglog
5ca8e11fadb6f7a8d9d0367c1800205c99d4bcd6jerenkrantz}
0d2f57cf389a981efa5e98d9b451c6baf0af12bfjerenkrantz
0d2f57cf389a981efa5e98d9b451c6baf0af12bfjerenkrantz# Make sure that the libraries essential to this stage of booting can be found.
5ca8e11fadb6f7a8d9d0367c1800205c99d4bcd6jerenkrantzLD_LIBRARY_PATH=/lib; export LD_LIBRARY_PATH
4b62424416882687387923b3130b96241503cbe0jerenkrantz
4b62424416882687387923b3130b96241503cbe0jerenkrantz#
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.
a12b7938cf47a0017a70ba195bbce035aa040e38aaron#
a12b7938cf47a0017a70ba195bbce035aa040e38aaronSUNW_NO_MPATHD=; export SUNW_NO_MPATHD
92e6727dad0094c5a049f903aef92c5caf3cd65fjim
f49387f556886ad6a6b4efc724ed9aa1d3412228jerenkrantzsmf_netstrategy
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantzif smf_is_globalzone; then
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe net_reconfigure || exit $SMF_EXIT_ERR_CONFIG
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz #
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 #
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz upgrade_script=/var/svc/profile/upgrade_datalink
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz if [ -f "${upgrade_script}" ]; then
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz . "${upgrade_script}"
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz fi
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz #
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).
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz #
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz /sbin/dladm up-aggr
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz /sbin/dladm up-vlan
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz /sbin/dladm init-secobj
bcca8071772ad81c16009aea3a7da3ef9da41173trawickfi
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz
f4cb04eb78da02a38fcdd87489dc7b660107d55fjerenkrantz#
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).
a23b1c5a74208b03884c09a6f9dd5d6c97fa6415trawick#
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewroweif [ -n "$_INIT_NET_IF" -a "$_INIT_NET_STRATEGY" = "dhcp" ]; then
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe /sbin/dhcpagent -a
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowefi
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe#
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#
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe/sbin/ifconfig -auD4 netmask + broadcast +
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe#
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# outputs.
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe#
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe#
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.
638a9edaf48cf003cd40ac25ee8c25f572107414stoddard#
638a9edaf48cf003cd40ac25ee8c25f572107414stoddardinterface_names="`echo /etc/hostname.*[0-9] 2>/dev/null`"
83d91d60d00dc345bfbcbc48ff206db4a6b23b2eaaronif [ "$interface_names" != "/etc/hostname.*[0-9]" ]; then
83d91d60d00dc345bfbcbc48ff206db4a6b23b2eaaron ORIGIFS="$IFS"
83d91d60d00dc345bfbcbc48ff206db4a6b23b2eaaron IFS="$IFS."
83d91d60d00dc345bfbcbc48ff206db4a6b23b2eaaron set -- $interface_names
83d91d60d00dc345bfbcbc48ff206db4a6b23b2eaaron IFS="$ORIGIFS"
83d91d60d00dc345bfbcbc48ff206db4a6b23b2eaaron while [ $# -ge 2 ]; do
83d91d60d00dc345bfbcbc48ff206db4a6b23b2eaaron shift
83d91d60d00dc345bfbcbc48ff206db4a6b23b2eaaron if [ $# -gt 1 -a "$2" != "/etc/hostname" ]; then
db2d668e6233d8949b35ee7f9f42f444758f9ce9rbb while [ $# -gt 1 -a "$1" != "/etc/hostname" ]; do
db2d668e6233d8949b35ee7f9f42f444758f9ce9rbb shift
db2d668e6233d8949b35ee7f9f42f444758f9ce9rbb done
db2d668e6233d8949b35ee7f9f42f444758f9ce9rbb else
db2d668e6233d8949b35ee7f9f42f444758f9ce9rbb inet_list="$inet_list $1"
db2d668e6233d8949b35ee7f9f42f444758f9ce9rbb shift
db2d668e6233d8949b35ee7f9f42f444758f9ce9rbb fi
1ea5221b240a8b41a07c6fb04aab5a73adcddabfaaron done
1ea5221b240a8b41a07c6fb04aab5a73adcddabfaaronfi
1ea5221b240a8b41a07c6fb04aab5a73adcddabfaaron
1ea5221b240a8b41a07c6fb04aab5a73adcddabfaaron#
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.
5d12baef135b5d3cb94745e007a1575398469724jerenkrantz#
5d12baef135b5d3cb94745e007a1575398469724jerenkrantzinterface_names="`echo /etc/hostname6.*[0-9] 2>/dev/null`"
5d12baef135b5d3cb94745e007a1575398469724jerenkrantzif [ "$interface_names" != "/etc/hostname6.*[0-9]" ]; then
5d12baef135b5d3cb94745e007a1575398469724jerenkrantz ORIGIFS="$IFS"
5d12baef135b5d3cb94745e007a1575398469724jerenkrantz IFS="$IFS."
5d12baef135b5d3cb94745e007a1575398469724jerenkrantz set -- $interface_names
5d12baef135b5d3cb94745e007a1575398469724jerenkrantz IFS="$ORIGIFS"
5d12baef135b5d3cb94745e007a1575398469724jerenkrantz while [ $# -ge 2 ]; do
5d12baef135b5d3cb94745e007a1575398469724jerenkrantz shift
5d12baef135b5d3cb94745e007a1575398469724jerenkrantz if [ $# -gt 1 -a "$2" != "/etc/hostname6" ]; then
5d12baef135b5d3cb94745e007a1575398469724jerenkrantz while [ $# -gt 1 -a "$1" != "/etc/hostname6" ]; do
5d12baef135b5d3cb94745e007a1575398469724jerenkrantz shift
b865daaa4ef731a7066ee6d97e2aae36c7743939jerenkrantz done
b865daaa4ef731a7066ee6d97e2aae36c7743939jerenkrantz else
b865daaa4ef731a7066ee6d97e2aae36c7743939jerenkrantz inet6_list="$inet6_list $1"
b865daaa4ef731a7066ee6d97e2aae36c7743939jerenkrantz shift
b865daaa4ef731a7066ee6d97e2aae36c7743939jerenkrantz fi
b865daaa4ef731a7066ee6d97e2aae36c7743939jerenkrantz done
b865daaa4ef731a7066ee6d97e2aae36c7743939jerenkrantzfi
b865daaa4ef731a7066ee6d97e2aae36c7743939jerenkrantz
b865daaa4ef731a7066ee6d97e2aae36c7743939jerenkrantz
b865daaa4ef731a7066ee6d97e2aae36c7743939jerenkrantz#
b865daaa4ef731a7066ee6d97e2aae36c7743939jerenkrantz# Step through the IPv4 interface list and try to plumb every interface.
b865daaa4ef731a7066ee6d97e2aae36c7743939jerenkrantz# Generate list of plumbed and failed IPv4 interfaces.
b865daaa4ef731a7066ee6d97e2aae36c7743939jerenkrantz#
b865daaa4ef731a7066ee6d97e2aae36c7743939jerenkrantzif [ -n "$inet_list" ]; then
b865daaa4ef731a7066ee6d97e2aae36c7743939jerenkrantz set -- $inet_list
dc098c7ce5d36179c504d09fc722d190683d0262aaron while [ $# -gt 0 ]; do
dc098c7ce5d36179c504d09fc722d190683d0262aaron /sbin/ifconfig $1 plumb
dc098c7ce5d36179c504d09fc722d190683d0262aaron if /sbin/ifconfig $1 inet >/dev/null 2>&1; then
dc098c7ce5d36179c504d09fc722d190683d0262aaron inet_plumbed="$inet_plumbed $1"
dc098c7ce5d36179c504d09fc722d190683d0262aaron else
dc098c7ce5d36179c504d09fc722d190683d0262aaron inet_failed="$inet_failed $1"
dc098c7ce5d36179c504d09fc722d190683d0262aaron fi
364dfd4527e6ce37b828a42e2c0bbdf9ba19a9b8gregames shift
364dfd4527e6ce37b828a42e2c0bbdf9ba19a9b8gregames done
dc098c7ce5d36179c504d09fc722d190683d0262aaron [ -n "$inet_failed" ] && warn_failed_ifs "plumb IPv4" $inet_failed
0bcb1fe39dfaacf9745b6633f5cc9ebc8e2596caaaronfi
0bcb1fe39dfaacf9745b6633f5cc9ebc8e2596caaaron
0bcb1fe39dfaacf9745b6633f5cc9ebc8e2596caaaron# Run autoconf to connect to a WLAN if the interface is a wireless one
0bcb1fe39dfaacf9745b6633f5cc9ebc8e2596caaaronif [ -x /sbin/wificonfig -a -n "$inet_plumbed" ]; then
0bcb1fe39dfaacf9745b6633f5cc9ebc8e2596caaaron set -- $inet_plumbed
0bcb1fe39dfaacf9745b6633f5cc9ebc8e2596caaaron while [ $# -gt 0 ]; do
33f5961d34a8b5390cebad0543b3ebe67830e5d7jerenkrantz if [ -r /dev/wifi/$1 ]; then
33f5961d34a8b5390cebad0543b3ebe67830e5d7jerenkrantz /sbin/wificonfig -i $1 startconf >/dev/null
33f5961d34a8b5390cebad0543b3ebe67830e5d7jerenkrantz fi
33f5961d34a8b5390cebad0543b3ebe67830e5d7jerenkrantz shift
33f5961d34a8b5390cebad0543b3ebe67830e5d7jerenkrantz done
33f5961d34a8b5390cebad0543b3ebe67830e5d7jerenkrantzfi
ff42f83cbf31893bcde9712332a8e5ee970f6a74trawick
ff42f83cbf31893bcde9712332a8e5ee970f6a74trawick#
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.
54e1babd5a5a56c576eeeace54110150769cc916coar#
54e1babd5a5a56c576eeeace54110150769cc916coarif [ -n "$inet6_list" ]; then
54e1babd5a5a56c576eeeace54110150769cc916coar set -- $inet6_list
54e1babd5a5a56c576eeeace54110150769cc916coar while [ $# -gt 0 ]; do
54e1babd5a5a56c576eeeace54110150769cc916coar /sbin/ifconfig $1 inet6 plumb
54e1babd5a5a56c576eeeace54110150769cc916coar if /sbin/ifconfig $1 inet6 >/dev/null 2>&1; then
54e1babd5a5a56c576eeeace54110150769cc916coar inet6_plumbed="$inet6_plumbed $1"
54e1babd5a5a56c576eeeace54110150769cc916coar else
54e1babd5a5a56c576eeeace54110150769cc916coar inet6_failed="$inet6_failed $1"
54e1babd5a5a56c576eeeace54110150769cc916coar fi
54e1babd5a5a56c576eeeace54110150769cc916coar shift
949aa7bba7f804faa8e6b08cad42a98fc0255d85jerenkrantz done
949aa7bba7f804faa8e6b08cad42a98fc0255d85jerenkrantz [ -n "$inet6_failed" ] && warn_failed_ifs "plumb IPv6" $inet6_failed
949aa7bba7f804faa8e6b08cad42a98fc0255d85jerenkrantzfi
949aa7bba7f804faa8e6b08cad42a98fc0255d85jerenkrantz
949aa7bba7f804faa8e6b08cad42a98fc0255d85jerenkrantzif smf_is_globalzone; then
949aa7bba7f804faa8e6b08cad42a98fc0255d85jerenkrantz #
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.
07021d9f405849228b859d9fb4b877f20e4fbba3jerenkrantz #
07021d9f405849228b859d9fb4b877f20e4fbba3jerenkrantz /sbin/dladm init-linkprop
f126ee03179eb54308118f1ec3de5a7b461685d8aaronfi
f126ee03179eb54308118f1ec3de5a7b461685d8aaron
f126ee03179eb54308118f1ec3de5a7b461685d8aaron#
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#
f126ee03179eb54308118f1ec3de5a7b461685d8aaron# If /etc/hostname.lo0 exists the loop below will do additional
f126ee03179eb54308118f1ec3de5a7b461685d8aaron# configuration of lo0.
f126ee03179eb54308118f1ec3de5a7b461685d8aaron#
f126ee03179eb54308118f1ec3de5a7b461685d8aaronif [ -n "$inet_plumbed" ]; then
f126ee03179eb54308118f1ec3de5a7b461685d8aaron i4s_fail=
f126ee03179eb54308118f1ec3de5a7b461685d8aaron echo "configuring IPv4 interfaces:\c"
f126ee03179eb54308118f1ec3de5a7b461685d8aaron set -- $inet_plumbed
f126ee03179eb54308118f1ec3de5a7b461685d8aaron while [ $# -gt 0 ]; do
109faf633e12ab0bbdd602c7addc795cce59e8addreid inet_process_hostname /sbin/ifconfig $1 inet \
109faf633e12ab0bbdd602c7addc795cce59e8addreid </etc/hostname.$1 >/dev/null
109faf633e12ab0bbdd602c7addc795cce59e8addreid [ $? != 0 ] && i4s_fail="$i4s_fail $1"
109faf633e12ab0bbdd602c7addc795cce59e8addreid echo " $1\c"
109faf633e12ab0bbdd602c7addc795cce59e8addreid shift
109faf633e12ab0bbdd602c7addc795cce59e8addreid done
109faf633e12ab0bbdd602c7addc795cce59e8addreid echo "."
109faf633e12ab0bbdd602c7addc795cce59e8addreid [ -n "$i4s_fail" ] && warn_failed_ifs "configure IPv4" $i4s_fail
109faf633e12ab0bbdd602c7addc795cce59e8addreidfi
109faf633e12ab0bbdd602c7addc795cce59e8addreid
109faf633e12ab0bbdd602c7addc795cce59e8addreid#
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.
4ca13a5e126946272f02637e268a8e09193c553ecoar#
4ca13a5e126946272f02637e268a8e09193c553ecoarif [ -n "$inet6_plumbed" ]; then
4ca13a5e126946272f02637e268a8e09193c553ecoar i6_fail=
4ca13a5e126946272f02637e268a8e09193c553ecoar echo "configuring IPv6 interfaces:\c"
48c0c81cd6fabac9d3386406d97633780365b839coar set -- $inet6_plumbed
48c0c81cd6fabac9d3386406d97633780365b839coar while [ $# -gt 0 ]; do
48c0c81cd6fabac9d3386406d97633780365b839coar inet6_process_hostname /sbin/ifconfig $1 inet6 \
48c0c81cd6fabac9d3386406d97633780365b839coar </etc/hostname6.$1 >/dev/null &&
48c0c81cd6fabac9d3386406d97633780365b839coar /sbin/ifconfig $1 inet6 up
48c0c81cd6fabac9d3386406d97633780365b839coar [ $? != 0 ] && i6_fail="$i6_fail $1"
48c0c81cd6fabac9d3386406d97633780365b839coar echo " $1\c"
e0427bf8e52a8fb920cb8b6adb5cdb3b6535b7fecoar shift
4ca13a5e126946272f02637e268a8e09193c553ecoar done
b84f66c93f820824b1d5455181f55598b766319cwrowe echo "."
b84f66c93f820824b1d5455181f55598b766319cwrowe [ -n "$i6_fail" ] && warn_failed_ifs "configure IPv6" $i6_fail
b84f66c93f820824b1d5455181f55598b766319cwrowefi
b84f66c93f820824b1d5455181f55598b766319cwrowe
7fe18c15b669db9d191859695901dc4fcf3829dawrowe# Run DHCP if requested. Skip boot-configured interface.
7fe18c15b669db9d191859695901dc4fcf3829dawroweinterface_names="`echo /etc/dhcp.*[0-9] 2>/dev/null`"
7fe18c15b669db9d191859695901dc4fcf3829dawroweif [ "$interface_names" != '/etc/dhcp.*[0-9]' ]; then
7fe18c15b669db9d191859695901dc4fcf3829dawrowe #
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.
48c0c81cd6fabac9d3386406d97633780365b839coar #
48c0c81cd6fabac9d3386406d97633780365b839coar i4d_fail=
48c0c81cd6fabac9d3386406d97633780365b839coar firstif=
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe primary=
2fb49a1d25f38421a68d31b4cbb5d9293fdeafbewrowe ORIGIFS="$IFS"
60d567a0c2aae815ee6fc20c0d65032bea52c92cwrowe IFS="${IFS}."
60d567a0c2aae815ee6fc20c0d65032bea52c92cwrowe set -- $interface_names
60d567a0c2aae815ee6fc20c0d65032bea52c92cwrowe
60d567a0c2aae815ee6fc20c0d65032bea52c92cwrowe while [ $# -ge 2 ]; do
60d567a0c2aae815ee6fc20c0d65032bea52c92cwrowe shift
7239216999e746bb4fc7671621becea33c5c1c87stoddard [ -z "$firstif" ] && firstif=$1
d180ec1b29106f4fec480ef7fcdb04df078010cerse
d180ec1b29106f4fec480ef7fcdb04df078010cerse for i in `shcat /etc/dhcp\.$1`; do
3913a3b7e7c72ea11d05da36275db39c2dc39b68jwoolley if [ "$i" = primary ]; then
3913a3b7e7c72ea11d05da36275db39c2dc39b68jwoolley primary=$1
3913a3b7e7c72ea11d05da36275db39c2dc39b68jwoolley break
57710387e669ee41fb211458efe09c4c73194a66jwoolley fi
57710387e669ee41fb211458efe09c4c73194a66jwoolley done
3913a3b7e7c72ea11d05da36275db39c2dc39b68jwoolley
3913a3b7e7c72ea11d05da36275db39c2dc39b68jwoolley [ -n "$primary" ] && break
d180ec1b29106f4fec480ef7fcdb04df078010cerse shift
19cbe4d7b7c931723e7249de6829bf965a1fee72stoddard done
19cbe4d7b7c931723e7249de6829bf965a1fee72stoddard
b187d568e1507d75139ebc13ca945b38fc05d55cstoddard [ -z "$primary" ] && primary="$firstif"
b187d568e1507d75139ebc13ca945b38fc05d55cstoddard cmdline=`shcat /etc/dhcp\.${primary}`
b187d568e1507d75139ebc13ca945b38fc05d55cstoddard
1c6fb1e726ce22694de0e9a957adb67b929e5d4fstoddard if [ "$_INIT_NET_IF" != "$primary" ]; then
1c6fb1e726ce22694de0e9a957adb67b929e5d4fstoddard echo "starting DHCP on primary interface $primary"
a5ed555df952c85bc1b179f5981e8a6c54ba16e6stoddard /sbin/ifconfig $primary auto-dhcp primary $cmdline
d2f8b010487ffa990a9c268df5a25579e7291bcdrbb # Exit code 4 means ifconfig timed out waiting for dhcpagent
d2f8b010487ffa990a9c268df5a25579e7291bcdrbb [ $? != 0 ] && [ $? != 4 ] && i4d_fail="$i4d_fail $primary"
a5ed555df952c85bc1b179f5981e8a6c54ba16e6stoddard fi
0bff2f28ef945280c17099c142126178a78e1e54manoj
0bff2f28ef945280c17099c142126178a78e1e54manoj set -- $interface_names
0bff2f28ef945280c17099c142126178a78e1e54manoj
1e585ba09ea32272e63c4c39c35491e975d21d98stoddard while [ $# -ge 2 ]; do
0bff2f28ef945280c17099c142126178a78e1e54manoj shift
35330e0d79ceb8027223bbb8330a381b1f989d6etrawick cmdline=`shcat /etc/dhcp\.$1`
0bff2f28ef945280c17099c142126178a78e1e54manoj if [ "$1" != "$primary" -a \
9c09943bad734ebd5c7cc10bd6d63b75c4c6e056stoddard "$1" != "$_INIT_NET_IF" ]; then
ff849e4163ed879288f0df15f78b6c9d278ec804fanf echo "starting DHCP on interface $1"
ff849e4163ed879288f0df15f78b6c9d278ec804fanf /sbin/ifconfig $1 dhcp start wait 0 $cmdline
447c6ce3ff08073c44f6785d5256271fcb877512wrowe # Exit code can't be timeout when wait is 0
e0427bf8e52a8fb920cb8b6adb5cdb3b6535b7fecoar [ $? != 0 ] && i4d_fail="$i4d_fail $1"
e0427bf8e52a8fb920cb8b6adb5cdb3b6535b7fecoar fi
e0427bf8e52a8fb920cb8b6adb5cdb3b6535b7fecoar shift
e0427bf8e52a8fb920cb8b6adb5cdb3b6535b7fecoar done
6758b07b4b79f898b0f56375016cea7da0bfb495wrowe IFS="$ORIGIFS"
6758b07b4b79f898b0f56375016cea7da0bfb495wrowe unset ORIGIFS
6758b07b4b79f898b0f56375016cea7da0bfb495wrowe [ -n "$i4d_fail" ] && warn_failed_ifs "configure IPv4 DHCP" $i4d_fail
7fe18c15b669db9d191859695901dc4fcf3829dawrowefi
db3ccce11afac4fc1d4f51a65424412f7480c46cgstein
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
48c0c81cd6fabac9d3386406d97633780365b839coarhostname="`shcat /etc/nodename 2>/dev/null`"
48c0c81cd6fabac9d3386406d97633780365b839coarif [ "$_INIT_NET_STRATEGY" = "rarp" -o -z "$hostname" ]; then
db3ccce11afac4fc1d4f51a65424412f7480c46cgstein /sbin/ifconfig -adD4 auto-revarp netmask + broadcast + up
79d5106a9b65b956d646f5daae4b94bc79e315b8trawickfi
79d5106a9b65b956d646f5daae4b94bc79e315b8trawick
79d5106a9b65b956d646f5daae4b94bc79e315b8trawick#
cf6bf6c34c936e6a6fe731dbce4a5c3c8bf8e9a3gstein# Process IPv4 and IPv6 interfaces that failed to plumb. Find an
cf6bf6c34c936e6a6fe731dbce4a5c3c8bf8e9a3gstein# alternative interface to host the addresses.
cf6bf6c34c936e6a6fe731dbce4a5c3c8bf8e9a3gstein#
6fa71a1bd8c61518b05f5798a7a1594c270e78afrbb[ -n "$inet_failed" ] && move_addresses inet
93c5cba06b623ebe8e4372e886eece12d9a80c3egstein
14cccaddba3a9263cf0d0ddc311e18f3e3dc9b0fgstein[ -n "$inet6_failed" ] && move_addresses inet6
14cccaddba3a9263cf0d0ddc311e18f3e3dc9b0fgstein
14cccaddba3a9263cf0d0ddc311e18f3e3dc9b0fgstein#
14cccaddba3a9263cf0d0ddc311e18f3e3dc9b0fgstein# If the /etc/defaultrouter file exists, process it now so that the next
14cccaddba3a9263cf0d0ddc311e18f3e3dc9b0fgstein# stage of booting will have access to NFS.
14cccaddba3a9263cf0d0ddc311e18f3e3dc9b0fgstein#
823c303d33c9e637a83d82208bcbafaf5f532d7bgsteinif [ -f /etc/defaultrouter ]; then
823c303d33c9e637a83d82208bcbafaf5f532d7bgstein while read router rubbish; do
e636eba7474e0010b5c7198af1c2fe5ad8652dbbmanoj case "$router" in
e636eba7474e0010b5c7198af1c2fe5ad8652dbbmanoj '#'* | '') ;; # Ignore comments, empty lines
e636eba7474e0010b5c7198af1c2fe5ad8652dbbmanoj *) /sbin/route -n add default -gateway $router ;;
281da4c02cf40c663298ded7e4e5b913a8f8b814gstein esac
281da4c02cf40c663298ded7e4e5b913a8f8b814gstein done </etc/defaultrouter
2f728b2e8555fee1b7cc11e886488692f2575fbddougmfi
2f728b2e8555fee1b7cc11e886488692f2575fbddougm
2f728b2e8555fee1b7cc11e886488692f2575fbddougm#
60d567a0c2aae815ee6fc20c0d65032bea52c92cwrowe# If we get here and were not asked to plumb any IPv4 interfaces, look
48c0c81cd6fabac9d3386406d97633780365b839coar# for boot properties that direct us.
60d567a0c2aae815ee6fc20c0d65032bea52c92cwrowe#
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#
fdff4ace2701177219fe1c444f69242372423354aaron# In the case where "xpv-hcp" is set to "dhcp", no further properties
fdff4ace2701177219fe1c444f69242372423354aaron# are required or examined.
fdff4ace2701177219fe1c444f69242372423354aaron#
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.
27757f6699a924d4b493a1b6cceb27df27a43287dreid#
27757f6699a924d4b493a1b6cceb27df27a43287dreidnic="`/sbin/devprop network-interface`"
7169eebe7cef1a6bbd082f28b1906f91b6fc6621stoddardif smf_is_globalzone && [ -z "$inet_list" ] && [ -n "$nic" ]; then
7169eebe7cef1a6bbd082f28b1906f91b6fc6621stoddard hcp="`/sbin/devprop xpv-hcp`"
7169eebe7cef1a6bbd082f28b1906f91b6fc6621stoddard case "$hcp" in
7169eebe7cef1a6bbd082f28b1906f91b6fc6621stoddard "dhcp")
21e01f13f717faeca3e498d7d9c9b4d3af98ae27trawick /sbin/ifconfig $nic plumb 2>/dev/null
21e01f13f717faeca3e498d7d9c9b4d3af98ae27trawick [ -n "`/sbin/ifconfig $nic 2>/dev/null`" ] && (
21e01f13f717faeca3e498d7d9c9b4d3af98ae27trawick # The interface is successfully plumbed, so
21e01f13f717faeca3e498d7d9c9b4d3af98ae27trawick # modify "inet_list" to force the exit code
21e01f13f717faeca3e498d7d9c9b4d3af98ae27trawick # checks to work.
21e01f13f717faeca3e498d7d9c9b4d3af98ae27trawick inet_list=$nic;
21e01f13f717faeca3e498d7d9c9b4d3af98ae27trawick # Given that this is the only IPv4 interface,
64ad864fa0f4493eebb181e393b40a8a90beccb9coar # we assert that it is primary.
64ad864fa0f4493eebb181e393b40a8a90beccb9coar echo "starting DHCP on primary interface $primary";
64ad864fa0f4493eebb181e393b40a8a90beccb9coar /sbin/ifconfig $nic auto-dhcp primary;
64ad864fa0f4493eebb181e393b40a8a90beccb9coar # Exit code 4 means ifconfig timed out waiting
64ad864fa0f4493eebb181e393b40a8a90beccb9coar # for dhcpagent
48c0c81cd6fabac9d3386406d97633780365b839coar [ $? != 0 ] && [ $? != 4 ] && \
64ad864fa0f4493eebb181e393b40a8a90beccb9coar i4d_fail="$i4d_fail $nic";
64ad864fa0f4493eebb181e393b40a8a90beccb9coar )
64ad864fa0f4493eebb181e393b40a8a90beccb9coar ;;
48c0c81cd6fabac9d3386406d97633780365b839coar
64ad864fa0f4493eebb181e393b40a8a90beccb9coar "off"|"")
64ad864fa0f4493eebb181e393b40a8a90beccb9coar /sbin/devprop host-ip subnet-mask router-ip | (
64ad864fa0f4493eebb181e393b40a8a90beccb9coar read ip;
48c0c81cd6fabac9d3386406d97633780365b839coar read mask;
64ad864fa0f4493eebb181e393b40a8a90beccb9coar read router;
64ad864fa0f4493eebb181e393b40a8a90beccb9coar [ -n "$ip" ] && [ -n "$mask" ] && \
64ad864fa0f4493eebb181e393b40a8a90beccb9coar /sbin/ifconfig $nic plumb 2>/dev/null
64ad864fa0f4493eebb181e393b40a8a90beccb9coar [ -n "`/sbin/ifconfig $nic 2>/dev/null`" ] && (
48c0c81cd6fabac9d3386406d97633780365b839coar # The interface is successfully
64ad864fa0f4493eebb181e393b40a8a90beccb9coar # plumbed, so modify "inet_list" to
64ad864fa0f4493eebb181e393b40a8a90beccb9coar # force the exit code checks to work.
64ad864fa0f4493eebb181e393b40a8a90beccb9coar inet_list=$nic;
48c0c81cd6fabac9d3386406d97633780365b839coar /sbin/ifconfig $nic inet $ip \
64ad864fa0f4493eebb181e393b40a8a90beccb9coar netmask $mask broadcast + up 2>/dev/null;
64ad864fa0f4493eebb181e393b40a8a90beccb9coar [ -n "$router" ] && route add \
64ad864fa0f4493eebb181e393b40a8a90beccb9coar default $router 2>/dev/null;
48c0c81cd6fabac9d3386406d97633780365b839coar )
64ad864fa0f4493eebb181e393b40a8a90beccb9coar )
64ad864fa0f4493eebb181e393b40a8a90beccb9coar ;;
64ad864fa0f4493eebb181e393b40a8a90beccb9coar esac
48c0c81cd6fabac9d3386406d97633780365b839coarfi
64ad864fa0f4493eebb181e393b40a8a90beccb9coar
64ad864fa0f4493eebb181e393b40a8a90beccb9coar#
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
64ad864fa0f4493eebb181e393b40a8a90beccb9coar#
48c0c81cd6fabac9d3386406d97633780365b839coar# If we weren't asked to configure any interfaces, exit
64ad864fa0f4493eebb181e393b40a8a90beccb9coarif [ -z "$inet_list" ] && [ -z "$inet6_list" ]; then
64ad864fa0f4493eebb181e393b40a8a90beccb9coar # Config error if DHCP was attempted without plumbed interfaces
64ad864fa0f4493eebb181e393b40a8a90beccb9coar [ -n "$i4d_fail" ] && exit $SMF_EXIT_ERR_CONFIG
48c0c81cd6fabac9d3386406d97633780365b839coar exit $SMF_EXIT_OK
64ad864fa0f4493eebb181e393b40a8a90beccb9coarfi
64ad864fa0f4493eebb181e393b40a8a90beccb9coar
64ad864fa0f4493eebb181e393b40a8a90beccb9coar# Any non-loopback IPv4 interfaces with usable addresses up?
48c0c81cd6fabac9d3386406d97633780365b839coarif [ -n "`/sbin/ifconfig -a4u`" ]; then
64ad864fa0f4493eebb181e393b40a8a90beccb9coar /sbin/ifconfig -a4u | while read intf addr rest; do
64ad864fa0f4493eebb181e393b40a8a90beccb9coar [ $intf = inet ] && [ $addr != 127.0.0.1 ] &&
64ad864fa0f4493eebb181e393b40a8a90beccb9coar [ $addr != 0.0.0.0 ] && exit $SMF_EXIT_OK
48c0c81cd6fabac9d3386406d97633780365b839coar done && exit $SMF_EXIT_OK
64ad864fa0f4493eebb181e393b40a8a90beccb9coarfi
64ad864fa0f4493eebb181e393b40a8a90beccb9coar
64ad864fa0f4493eebb181e393b40a8a90beccb9coar# Any DHCP interfaces started?
48c0c81cd6fabac9d3386406d97633780365b839coar[ -n "`/sbin/ifconfig -a4 dhcp status 2>/dev/null`" ] && exit $SMF_EXIT_OK
64ad864fa0f4493eebb181e393b40a8a90beccb9coar
64ad864fa0f4493eebb181e393b40a8a90beccb9coar# Any non-loopback IPv6 interfaces up?
64ad864fa0f4493eebb181e393b40a8a90beccb9coarif [ -n "`/sbin/ifconfig -au6`" ]; then
48c0c81cd6fabac9d3386406d97633780365b839coar /sbin/ifconfig -au6 | while read intf addr rest; do
64ad864fa0f4493eebb181e393b40a8a90beccb9coar [ $intf = inet6 ] && [ $addr != ::1/128 ] && exit $SMF_EXIT_OK
64ad864fa0f4493eebb181e393b40a8a90beccb9coar done && exit $SMF_EXIT_OK
64ad864fa0f4493eebb181e393b40a8a90beccb9coarfi
48c0c81cd6fabac9d3386406d97633780365b839coar
64ad864fa0f4493eebb181e393b40a8a90beccb9coar# This service was supposed to configure something yet didn't. Exit
64ad864fa0f4493eebb181e393b40a8a90beccb9coar# with config error.
64ad864fa0f4493eebb181e393b40a8a90beccb9coarexit $SMF_EXIT_ERR_CONFIG
64ad864fa0f4493eebb181e393b40a8a90beccb9coar