#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2012 Milan Jurik. All rights reserved.
#
# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
# All rights reserved.
#
#
# In a shared-IP zone we need this service to be up, but all of the work
# it tries to do is irrelevant (and will actually lead to the service
# failing if we try to do it), so just bail out.
# In the global zone and exclusive-IP zones we proceed.
#
smf_configure_ip || exit $SMF_EXIT_OK
# Make sure that the libraries essential to this stage of booting can be found.
if smf_is_globalzone; then
net_reconfigure || exit $SMF_EXIT_ERR_CONFIG
# Update PVID on interfaces configured with VLAN 1
#
# Upgrade handling. The upgrade file consists of a series of dladm(1M)
# commands. Note that after we are done, we cannot rename the upgrade
# script file as the file system is still read-only at this point.
# Defer this to the manifest-import service.
#
if [ -f "${upgrade_script}" ]; then
. "${upgrade_script}"
fi
#
# Upgrade handling for ibd:
# After we are done with the upgrade handling, we can not set the
# ibd/ibd_upgraded property to "true" as the file system is
# read-only at this point. It will be done later by ibd-post-upgrade
# service.
#
if [ -x /sbin/ibd_upgrade ]; then
ibd_upgraded=`/bin/svcprop -c -p ibd/ibd_upgraded \
if [ "$ibd_upgraded" != "true" ]; then
/sbin/ibd_upgrade -v
fi
fi
#
# Bring up simnets, link aggregations and initialize security objects.
# Note that link property initialization is deferred until after
# IP interfaces are plumbed to ensure that the links will not
# be unloaded (and the property settings lost). We should bring
# over simnets.
#
#
# Bring up VNICs
#
#
# Create flows via flowadm.
#
fi
#
# If the system was net booted by DHCP, hand DHCP management off to the
# DHCP agent (ifconfig communicates to the DHCP agent through the
# loopback interface).
#
fi
#
# The network initialization is done early to support diskless and
# dataless configurations. For IPv4 interfaces that were configured by
# the kernel (e.g. those on diskless machines) and not configured by
# exists, and then reset the broadcast address based on the netmask.
#
is_iptun ()
{
intf=$1
# Is this a persistent IP tunnel link?
if [ $? -eq 0 ]; then
return 0
fi
set -- $intf
#
# It looks like one, but another type of link might be
# using a name that looks like an implicit IP tunnel.
# If dladm show-link -P finds it, then it's not an IP
# tunnel.
#
if [ $? -eq 0 ]; then
return 1
else
return 0
fi
fi
return 1
}
#
# All the IPv4 and IPv6 interfaces are plumbed before doing any
# interface configuration. This prevents errors from plumb failures
# getting mixed in with the configured interface lists that the script
# outputs.
#
#
#
# Get the list of IPv4 interfaces to configure by breaking
# character.
#
if [ "$interface_names" != "/etc/hostname.*[0-9]" ]; then
set -- $interface_names
while [ $# -ge 2 ]; do
shift
intf_name=$1
intf_name="$intf_name.$2"
shift
done
shift
# skip IP tunnel interfaces plumbed by net-iptun.
if is_iptun $intf_name; then
continue
fi
else
fi
done
fi
#
# Get the list of IPv6 interfaces to configure by breaking
# character.
#
if [ "$interface_names" != "/etc/hostname6.*[0-9]" ]; then
set -- $interface_names
while [ $# -ge 2 ]; do
shift
intf_name=$1
intf_name="$intf_name.$2"
shift
done
shift
# skip IP tunnel interfaces plumbed by net-iptun.
if is_iptun $intf_name; then
continue
fi
else
fi
done
fi
#
# Create all of the IPv4 IPMP interfaces.
#
if [ -n "$ipmp_list" ]; then
set -- $ipmp_list
while [ $# -gt 0 ]; do
else
ipmp_failed="$ipmp_failed $1"
fi
shift
done
fi
#
# Step through the IPv4 interface list and try to plumb every interface.
# Generate list of plumbed and failed IPv4 interfaces.
#
if [ -n "$inet_list" ]; then
set -- $inet_list
while [ $# -gt 0 ]; do
else
inet_failed="$inet_failed $1"
fi
shift
done
fi
# Run autoconf to connect to a WLAN if the interface is a wireless one
set -- $inet_plumbed
while [ $# -gt 0 ]; do
fi
shift
done
fi
#
# Step through the IPv6 interface list and plumb every interface.
# Generate list of plumbed and failed IPv6 interfaces. Each plumbed
# interface will be brought up later, after processing any contents of
#
if [ -n "$inet6_list" ]; then
set -- $inet6_list
while [ $# -gt 0 ]; do
else
fi
shift
done
fi
#
# Create all of the IPv6 IPMP interfaces.
#
if [ -n "$ipmp6_list" ]; then
set -- $ipmp6_list
while [ $# -gt 0 ]; do
else
fi
shift
done
fi
#
# files take precedence over ipadm defined configurations except when
# we are in a non-global zone and Layer-3 protection of IP addresses is
# enforced on the interface by the global zone.
#
#
# skip if not a persistent interface, or if it should get IP
# configuration from the global zone ('Z' flag is set)
#
continue;
# skip IP tunnel interfaces plumbed by net-iptun
continue;
if [[ $current != *Z* ]]; then
continue;
else
fi
fi
# Enable the interface managed by ipadm
done
#
# before non-IPMP interfaces avoids accidental implicit IPMP group creation.
#
#
#
#
# For the IPv4 and IPv6 interfaces that failed to plumb, find (or create)
# IPMP meta-interfaces to host their data addresses.
#
# Run DHCP if requested. Skip boot-configured interface.
if [ "$interface_names" != '/etc/dhcp.*[0-9]' ]; then
#
# First find the primary interface. Default to the first
# interface if not specified. First primary interface found
# "wins". Use care not to "reconfigure" a net-booted interface
# configured using DHCP. Run through the list of interfaces
# again, this time trying DHCP.
#
IFS="${IFS}."
set -- $interface_names
while [ $# -ge 2 ]; do
shift
if [ "$i" = primary ]; then
primary=$1
break
fi
done
[ -n "$primary" ] && break
shift
done
if [ "$_INIT_NET_IF" != "$primary" ]; then
echo "starting DHCP on primary interface $primary"
# Exit code 4 means ifconfig timed out waiting for dhcpagent
fi
set -- $interface_names
while [ $# -ge 2 ]; do
shift
if [ "$1" != "$primary" -a \
"$1" != "$_INIT_NET_IF" ]; then
echo "starting DHCP on interface $1"
# Exit code can't be timeout when wait is 0
fi
shift
done
unset ORIGIFS
fi
# In order to avoid bringing up the interfaces that have
# intentionally been left down, perform RARP only if the system
fi
#
# If the /etc/defaultrouter file exists, process it now so that the next
# stage of booting will have access to NFS.
#
if [ -f /etc/defaultrouter ]; then
'#'* | '') ;; # Ignore comments, empty lines
esac
done </etc/defaultrouter
fi
#
# If we get here and were not asked to plumb any IPv4 interfaces, look
# for boot properties that direct us.
#
# - The "network-interface" property is required and indicates the
# interface name.
# - The "xpv-hcp" property, if present, is used by the hypervisor
# tools to indicate how the specified interface should be configured.
# Permitted values are "dhcp" and "off", where "off" indicates static
# IP configuration.
#
# In the case where "xpv-hcp" is set to "dhcp", no further properties
# are required or examined.
#
# In the case where "xpv-hcp" is not present or set to "off", the
# "host-ip" and "subnet-mask" properties are used to configure
# the specified interface. The "router-ip" property, if present,
# is used to add a default route.
#
"dhcp")
# The interface is successfully plumbed, so
# modify "inet_list" to force the exit code
# checks to work.
# Given that this is the only IPv4 interface,
# we assert that it is primary.
# Exit code 4 means ifconfig timed out waiting
# for dhcpagent
[ $? != 0 ] && [ $? != 4 ] && \
)
;;
"off"|"")
read ip;
read mask;
read router;
# The interface is successfully
# plumbed, so modify "inet_list" to
# force the exit code checks to work.
)
)
;;
esac
fi
#
# We tell smf this service is online if any of the following is true:
# - no interfaces were configured for plumbing and no DHCP failures
# - any non-loopback IPv4 interfaces are up and have a non-zero address
# - there are any DHCP interfaces started
# - any non-loopback IPv6 interfaces are up
#
# If we weren't asked to configure any interfaces, exit
if [ -z "$inet_list" ] && [ -z "$inet6_list" ]; then
# Config error if DHCP was attempted without plumbed interfaces
[ -n "$i4d_fail" ] && exit $SMF_EXIT_ERR_CONFIG
exit $SMF_EXIT_OK
fi
# Any non-loopback IPv4 interfaces with usable addresses up?
done && exit $SMF_EXIT_OK
fi
# Any DHCP interfaces started?
# Any non-loopback IPv6 interfaces up?
done && exit $SMF_EXIT_OK
fi
# This service was supposed to configure something yet didn't. Exit
# with config error.
exit $SMF_EXIT_ERR_CONFIG