Home | History | Annotate | Download | only in milestone
      1      0     stevel #!/sbin/sh
      2      0     stevel #
      3      0     stevel # CDDL HEADER START
      4      0     stevel #
      5      0     stevel # The contents of this file are subject to the terms of the
      6   1573         dp # Common Development and Distribution License (the "License").
      7   1573         dp # You may not use this file except in compliance with the License.
      8      0     stevel #
      9      0     stevel # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10      0     stevel # or http://www.opensolaris.org/os/licensing.
     11      0     stevel # See the License for the specific language governing permissions
     12      0     stevel # and limitations under the License.
     13      0     stevel #
     14      0     stevel # When distributing Covered Code, include this CDDL HEADER in each
     15      0     stevel # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16      0     stevel # If applicable, add the following below this CDDL HEADER, with the
     17      0     stevel # fields enclosed by brackets "[]" replaced with your own identifying
     18      0     stevel # information: Portions Copyright [yyyy] [name of copyright owner]
     19      0     stevel #
     20      0     stevel # CDDL HEADER END
     21      0     stevel #
     22      0     stevel #
     23   8485      Peter # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
     24      0     stevel # Use is subject to license terms.
     25      0     stevel #
     26      0     stevel # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
     27      0     stevel # All rights reserved.
     28      0     stevel #
     29   1573         dp 
     30   1573         dp . /lib/svc/share/smf_include.sh
     31   1573         dp . /lib/svc/share/net_include.sh
     32      0     stevel 
     33      0     stevel #
     34   3448   dh155122 # In a shared-IP zone we need this service to be up, but all of the work
     35   3448   dh155122 # it tries to do is irrelevant (and will actually lead to the service 
     36   3448   dh155122 # failing if we try to do it), so just bail out. 
     37   3448   dh155122 # In the global zone and exclusive-IP zones we proceed.
     38      0     stevel #
     39   3448   dh155122 smf_configure_ip || exit $SMF_EXIT_OK
     40      0     stevel 
     41      0     stevel # Make sure that the libraries essential to this stage of booting can be found.
     42      0     stevel LD_LIBRARY_PATH=/lib; export LD_LIBRARY_PATH
     43      0     stevel 
     44      0     stevel smf_netstrategy
     45    269   ericheng 
     46   3448   dh155122 if smf_is_globalzone; then
     47   5895   yz147064 	net_reconfigure || exit $SMF_EXIT_ERR_CONFIG
     48  10491      Rishi 
     49  10491      Rishi 	# Update PVID on interfaces configured with VLAN 1
     50  10491      Rishi 	update_pvid
     51   5895   yz147064 
     52   5895   yz147064 	# 
     53   5895   yz147064 	# Upgrade handling. The upgrade file consists of a series of dladm(1M)
     54   5895   yz147064 	# commands. Note that after we are done, we cannot rename the upgrade
     55   5895   yz147064 	# script file as the file system is still read-only at this point.
     56   5895   yz147064 	# Defer this to the manifest-import service.
     57   5895   yz147064 	#
     58   5895   yz147064 	upgrade_script=/var/svc/profile/upgrade_datalink
     59   5895   yz147064 	if [ -f "${upgrade_script}" ]; then 
     60   5895   yz147064 		. "${upgrade_script}"
     61   5895   yz147064 	fi
     62   5895   yz147064 
     63   3448   dh155122 	#
     64   9815      Rishi 	# Bring up simnets, link aggregations and initialize security objects.
     65   3448   dh155122 	# Note that link property initialization is deferred until after
     66   3448   dh155122 	# IP interfaces are plumbed to ensure that the links will not
     67   9815      Rishi 	# be unloaded (and the property settings lost). We should bring
     68   9815      Rishi 	# up simnets prior to VLANs/Aggrs to enable creation of VLANs/Aggrs
     69   9815      Rishi 	# over simnets.
     70   3448   dh155122 	#
     71   9815      Rishi 	/sbin/dladm up-simnet
     72   3448   dh155122 	/sbin/dladm up-aggr
     73   5895   yz147064 	/sbin/dladm up-vlan
     74   3448   dh155122 	/sbin/dladm init-secobj
     75   8275       Eric 	#
     76   8275       Eric 	# Bring up VNICs
     77   8275       Eric 	#
     78   8275       Eric 	/sbin/dladm up-vnic
     79   8275       Eric 	#
     80   8275       Eric 	# Create flows via flowadm.
     81   8275       Eric 	#
     82   8275       Eric 	/sbin/flowadm init-flow
     83   3448   dh155122 fi
     84      0     stevel 
     85      0     stevel #
     86      0     stevel # If the system was net booted by DHCP, hand DHCP management off to the
     87      0     stevel # DHCP agent (ifconfig communicates to the DHCP agent through the
     88      0     stevel # loopback interface).
     89      0     stevel #
     90      0     stevel if [ -n "$_INIT_NET_IF" -a "$_INIT_NET_STRATEGY" = "dhcp" ]; then
     91      0     stevel 	/sbin/dhcpagent -a
     92      0     stevel fi
     93      0     stevel 
     94      0     stevel #
     95      0     stevel # The network initialization is done early to support diskless and
     96      0     stevel # dataless configurations.  For IPv4 interfaces that were configured by
     97      0     stevel # the kernel (e.g.  those on diskless machines) and not configured by
     98      0     stevel # DHCP, reset the netmask using the local "/etc/netmasks" file if one
     99      0     stevel # exists, and then reset the broadcast address based on the netmask.
    100      0     stevel #
    101      0     stevel /sbin/ifconfig -auD4 netmask + broadcast +
    102      0     stevel 
    103  10616  Sebastien is_iptun ()
    104  10616  Sebastien {
    105  10616  Sebastien 	intf=$1
    106  10616  Sebastien 	# Is this a persistent IP tunnel link?
    107  10616  Sebastien 	/sbin/dladm show-iptun -P $intf > /dev/null 2>&1
    108  10616  Sebastien 	if [ $? -eq 0 ]; then
    109  10616  Sebastien 		return 0
    110  10616  Sebastien 	fi
    111  10616  Sebastien 	# Is this an implicit IP tunnel (i.e., ip.tun0)
    112  10616  Sebastien 	ORIGIFS="$IFS"
    113  10616  Sebastien 	IFS="$IFS."
    114  10616  Sebastien 	set -- $intf
    115  10616  Sebastien 	IFS="$ORIGIFS"
    116  10616  Sebastien 	if [ $# -eq 2 -a \( "$1" = "ip" -o "$1" = "ip6" \) ]; then
    117  10616  Sebastien 		#
    118  10616  Sebastien 		# It looks like one, but another type of link might be
    119  10616  Sebastien 		# using a name that looks like an implicit IP tunnel.
    120  10616  Sebastien 		# If dladm show-link -P finds it, then it's not an IP
    121  10616  Sebastien 		# tunnel.
    122  10616  Sebastien 		#
    123  10616  Sebastien 		/sbin/dladm show-link -Pp $intf > /dev/null 2>&1
    124  10616  Sebastien 		if [ $? -eq 0 ]; then
    125  10616  Sebastien 			return 1
    126  10616  Sebastien 		else
    127  10616  Sebastien 			return 0
    128  10616  Sebastien 		fi
    129  10616  Sebastien 	fi
    130  10616  Sebastien 	return 1
    131  10616  Sebastien }
    132  10616  Sebastien 
    133      0     stevel #
    134      0     stevel # All the IPv4 and IPv6 interfaces are plumbed before doing any
    135      0     stevel # interface configuration.  This prevents errors from plumb failures
    136      0     stevel # getting mixed in with the configured interface lists that the script
    137      0     stevel # outputs.
    138      0     stevel #
    139      0     stevel 
    140      0     stevel #
    141      0     stevel # Get the list of IPv4 interfaces to configure by breaking
    142      0     stevel # /etc/hostname.* into separate args by using "." as a shell separator
    143      0     stevel # character.
    144      0     stevel #
    145      0     stevel interface_names="`echo /etc/hostname.*[0-9] 2>/dev/null`"
    146      0     stevel if [ "$interface_names" != "/etc/hostname.*[0-9]" ]; then
    147      0     stevel 	ORIGIFS="$IFS"
    148      0     stevel 	IFS="$IFS."
    149      0     stevel 	set -- $interface_names
    150      0     stevel 	IFS="$ORIGIFS"
    151      0     stevel 	while [ $# -ge 2 ]; do
    152      0     stevel 		shift
    153   8485      Peter 		intf_name=$1
    154   8485      Peter 		while [ $# -gt 1 -a "$2" != "/etc/hostname" ]; do
    155   8485      Peter 			intf_name="$intf_name.$2"
    156   8485      Peter 			shift
    157   8485      Peter 		done
    158   8485      Peter 		shift
    159  10616  Sebastien 
    160  10616  Sebastien 		# skip IP tunnel interfaces plumbed by net-iptun.
    161  10616  Sebastien 		if is_iptun $intf_name; then
    162  10616  Sebastien 			continue
    163  10616  Sebastien 		fi
    164   8485      Peter 
    165   8485      Peter 	        read one rest < /etc/hostname.$intf_name
    166   8485      Peter 		if [ "$one" = ipmp ]; then
    167   8485      Peter 			ipmp_list="$ipmp_list $intf_name"
    168      0     stevel 		else
    169   8485      Peter 			inet_list="$inet_list $intf_name"
    170      0     stevel 		fi
    171      0     stevel 	done
    172      0     stevel fi
    173      0     stevel 
    174      0     stevel #
    175      0     stevel # Get the list of IPv6 interfaces to configure by breaking
    176      0     stevel # /etc/hostname6.* into separate args by using "." as a shell separator
    177      0     stevel # character.
    178      0     stevel #
    179      0     stevel interface_names="`echo /etc/hostname6.*[0-9] 2>/dev/null`"
    180      0     stevel if [ "$interface_names" != "/etc/hostname6.*[0-9]" ]; then
    181      0     stevel 	ORIGIFS="$IFS"
    182      0     stevel 	IFS="$IFS."
    183      0     stevel 	set -- $interface_names
    184      0     stevel 	IFS="$ORIGIFS"
    185      0     stevel 	while [ $# -ge 2 ]; do
    186      0     stevel 		shift
    187   8485      Peter 		intf_name=$1
    188   8485      Peter 		while [ $# -gt 1 -a "$2" != "/etc/hostname6" ]; do
    189   8485      Peter 			intf_name="$intf_name.$2"
    190   8485      Peter 			shift
    191   8485      Peter 		done
    192   8485      Peter 		shift
    193  10616  Sebastien 
    194  10616  Sebastien 		# skip IP tunnel interfaces plumbed by net-iptun.
    195  10616  Sebastien 		if is_iptun $intf_name; then
    196  10616  Sebastien 			continue
    197  10616  Sebastien 		fi
    198   8485      Peter 
    199   8485      Peter 	        read one rest < /etc/hostname6.$intf_name
    200   8485      Peter 		if [ "$one" = ipmp ]; then
    201   8485      Peter 			ipmp6_list="$ipmp6_list $intf_name"
    202      0     stevel 		else
    203   8485      Peter 			inet6_list="$inet6_list $intf_name"
    204      0     stevel 		fi
    205      0     stevel 	done
    206      0     stevel fi
    207      0     stevel 
    208   8485      Peter #
    209   8485      Peter # Create all of the IPv4 IPMP interfaces.
    210   8485      Peter #
    211   8485      Peter if [ -n "$ipmp_list" ]; then
    212   8485      Peter 	set -- $ipmp_list
    213   8485      Peter 	while [ $# -gt 0 ]; do
    214   8485      Peter 	    	if /sbin/ifconfig $1 ipmp; then
    215   8485      Peter 			ipmp_created="$ipmp_created $1"
    216   8485      Peter 		else
    217   8485      Peter 			ipmp_failed="$ipmp_failed $1"
    218   8485      Peter 		fi	
    219   8485      Peter 		shift
    220   8485      Peter 	done
    221   8485      Peter 	[ -n "$ipmp_failed" ] && warn_failed_ifs "create IPv4 IPMP" \
    222   8485      Peter 	    "$ipmp_failed"
    223   8485      Peter fi
    224      0     stevel 
    225      0     stevel #
    226      0     stevel # Step through the IPv4 interface list and try to plumb every interface.
    227      0     stevel # Generate list of plumbed and failed IPv4 interfaces.
    228      0     stevel #
    229      0     stevel if [ -n "$inet_list" ]; then
    230      0     stevel 	set -- $inet_list
    231      0     stevel 	while [ $# -gt 0 ]; do
    232      0     stevel 		/sbin/ifconfig $1 plumb
    233      0     stevel 		if /sbin/ifconfig $1 inet >/dev/null 2>&1; then
    234      0     stevel 			inet_plumbed="$inet_plumbed $1"
    235      0     stevel 		else
    236      0     stevel 			inet_failed="$inet_failed $1"
    237      0     stevel 		fi
    238      0     stevel 		shift
    239      0     stevel 	done
    240   8485      Peter 	[ -n "$inet_failed" ] && warn_failed_ifs "plumb IPv4" "$inet_failed"
    241    995   hx147065 fi
    242    995   hx147065 
    243    995   hx147065 # Run autoconf to connect to a WLAN if the interface is a wireless one
    244    995   hx147065 if [ -x /sbin/wificonfig -a -n "$inet_plumbed" ]; then
    245    995   hx147065 	set -- $inet_plumbed
    246    995   hx147065 	while [ $# -gt 0 ]; do
    247    995   hx147065 			if [ -r /dev/wifi/$1 ]; then
    248    995   hx147065 				/sbin/wificonfig -i $1 startconf >/dev/null
    249    995   hx147065 			fi
    250    995   hx147065 		shift
    251    995   hx147065 	done
    252      0     stevel fi
    253      0     stevel 
    254      0     stevel #
    255      0     stevel # Step through the IPv6 interface list and plumb every interface.
    256      0     stevel # Generate list of plumbed and failed IPv6 interfaces.  Each plumbed
    257      0     stevel # interface will be brought up later, after processing any contents of
    258      0     stevel # the /etc/hostname6.* file.
    259      0     stevel #
    260      0     stevel if [ -n "$inet6_list" ]; then
    261      0     stevel 	set -- $inet6_list
    262      0     stevel 	while [ $# -gt 0 ]; do
    263      0     stevel 		/sbin/ifconfig $1 inet6 plumb
    264      0     stevel 		if /sbin/ifconfig $1 inet6 >/dev/null 2>&1; then
    265      0     stevel 			inet6_plumbed="$inet6_plumbed $1"
    266      0     stevel 		else
    267      0     stevel 			inet6_failed="$inet6_failed $1"
    268      0     stevel 		fi
    269      0     stevel 		shift
    270      0     stevel 	done
    271   8485      Peter 	[ -n "$inet6_failed" ] && warn_failed_ifs "plumb IPv6" "$inet6_failed"
    272   8485      Peter fi
    273   8485      Peter 
    274   8485      Peter #
    275   8485      Peter # Create all of the IPv6 IPMP interfaces.
    276   8485      Peter #
    277   8485      Peter if [ -n "$ipmp6_list" ]; then
    278   8485      Peter 	set -- $ipmp6_list
    279   8485      Peter 	while [ $# -gt 0 ]; do
    280   8485      Peter 	    	if /sbin/ifconfig $1 inet6 ipmp; then
    281   8485      Peter 			ipmp6_created="$ipmp6_created $1"
    282   8485      Peter 		else
    283   8485      Peter 			ipmp6_failed="$ipmp6_failed $1"
    284   8485      Peter  		fi
    285   8485      Peter 		shift
    286   8485      Peter 	done
    287   8485      Peter 	[ -n "$ipmp6_failed" ] && warn_failed_ifs "create IPv6 IPMP" \
    288   8485      Peter 	    "$ipmp6_failed"
    289      0     stevel fi
    290   3147   xc151355 
    291      0     stevel #
    292   8485      Peter # Process the /etc/hostname[6].* files for IPMP interfaces.  Processing these
    293   8485      Peter # before non-IPMP interfaces avoids accidental implicit IPMP group creation.
    294      0     stevel #
    295   8485      Peter [ -n "$ipmp_created" ] && if_configure inet "IPMP" $ipmp_created
    296   8485      Peter [ -n "$ipmp6_created" ] && if_configure inet6 "IPMP" $ipmp6_created
    297      0     stevel 
    298      0     stevel #
    299   8485      Peter # Process the /etc/hostname[6].* files for non-IPMP interfaces.
    300      0     stevel #
    301   8485      Peter [ -n "$inet_plumbed" ] && if_configure inet "" $inet_plumbed
    302   8485      Peter [ -n "$inet6_plumbed" ] && if_configure inet6 "" $inet6_plumbed
    303   8485      Peter 
    304   8485      Peter #
    305   8485      Peter # For the IPv4 and IPv6 interfaces that failed to plumb, find (or create)
    306   8485      Peter # IPMP meta-interfaces to host their data addresses.
    307   8485      Peter #
    308   8485      Peter [ -n "$inet_failed" ] && move_addresses inet
    309   8485      Peter [ -n "$inet6_failed" ] && move_addresses inet6
    310      0     stevel 
    311      0     stevel # Run DHCP if requested. Skip boot-configured interface.
    312      0     stevel interface_names="`echo /etc/dhcp.*[0-9] 2>/dev/null`"
    313      0     stevel if [ "$interface_names" != '/etc/dhcp.*[0-9]' ]; then
    314      0     stevel 	#
    315      0     stevel 	# First find the primary interface. Default to the first
    316      0     stevel 	# interface if not specified. First primary interface found
    317      0     stevel 	# "wins". Use care not to "reconfigure" a net-booted interface
    318      0     stevel 	# configured using DHCP. Run through the list of interfaces
    319      0     stevel 	# again, this time trying DHCP.
    320      0     stevel 	#
    321      0     stevel 	i4d_fail=
    322      0     stevel 	firstif=
    323      0     stevel 	primary=
    324      0     stevel 	ORIGIFS="$IFS"
    325      0     stevel 	IFS="${IFS}."
    326      0     stevel 	set -- $interface_names
    327      0     stevel 
    328      0     stevel 	while [ $# -ge 2 ]; do
    329      0     stevel 		shift
    330      0     stevel 		[ -z "$firstif" ] && firstif=$1
    331      0     stevel 
    332      0     stevel 		for i in `shcat /etc/dhcp\.$1`; do
    333      0     stevel 			if [ "$i" = primary ]; then
    334      0     stevel 				primary=$1
    335      0     stevel 				break
    336      0     stevel 			fi
    337      0     stevel 		done
    338      0     stevel 
    339      0     stevel 		[ -n "$primary" ] && break
    340      0     stevel 		shift
    341      0     stevel 	done
    342      0     stevel 
    343      0     stevel 	[ -z "$primary" ] && primary="$firstif"
    344      0     stevel 	cmdline=`shcat /etc/dhcp\.${primary}`
    345      0     stevel 
    346      0     stevel 	if [ "$_INIT_NET_IF" != "$primary" ]; then
    347      0     stevel 		echo "starting DHCP on primary interface $primary"
    348      0     stevel 		/sbin/ifconfig $primary auto-dhcp primary $cmdline
    349      0     stevel 		# Exit code 4 means ifconfig timed out waiting for dhcpagent
    350   5084    johnlev 		[ $? != 0 ] && [ $? != 4 ] && i4d_fail="$i4d_fail $primary"
    351      0     stevel 	fi
    352      0     stevel 
    353      0     stevel 	set -- $interface_names
    354      0     stevel 
    355      0     stevel 	while [ $# -ge 2 ]; do
    356      0     stevel 		shift
    357      0     stevel 		cmdline=`shcat /etc/dhcp\.$1`
    358      0     stevel 		if [ "$1" != "$primary" -a \
    359      0     stevel 			"$1" != "$_INIT_NET_IF"  ]; then
    360      0     stevel 			echo "starting DHCP on interface $1"
    361      0     stevel 			/sbin/ifconfig $1 dhcp start wait 0 $cmdline
    362      0     stevel 			# Exit code can't be timeout when wait is 0
    363      0     stevel 			[ $? != 0 ] && i4d_fail="$i4d_fail $1"
    364      0     stevel 		fi
    365      0     stevel 		shift
    366      0     stevel 	done
    367      0     stevel 	IFS="$ORIGIFS"
    368      0     stevel 	unset ORIGIFS
    369   8485      Peter 	[ -n "$i4d_fail" ] && warn_failed_ifs "configure IPv4 DHCP" "$i4d_fail"
    370      0     stevel fi
    371      0     stevel 
    372     67   se146197 # In order to avoid bringing up the interfaces that have
    373     67   se146197 # intentionally been left down, perform RARP only if the system
    374     67   se146197 # has no configured hostname in /etc/nodename
    375     67   se146197 hostname="`shcat /etc/nodename 2>/dev/null`"
    376     67   se146197 if [ "$_INIT_NET_STRATEGY" = "rarp" -o -z "$hostname" ]; then
    377     67   se146197 	/sbin/ifconfig -adD4 auto-revarp netmask + broadcast + up
    378     67   se146197 fi
    379      0     stevel 
    380      0     stevel #
    381      0     stevel # If the /etc/defaultrouter file exists, process it now so that the next
    382      0     stevel # stage of booting will have access to NFS.
    383      0     stevel #
    384      0     stevel if [ -f /etc/defaultrouter ]; then
    385      0     stevel 	while read router rubbish; do
    386      0     stevel 		case "$router" in
    387      0     stevel 			'#'* | '') ;;	#  Ignore comments, empty lines
    388      0     stevel 			*)	/sbin/route -n add default -gateway $router ;;
    389      0     stevel 		esac
    390      0     stevel 	done </etc/defaultrouter
    391      0     stevel fi
    392      0     stevel 
    393      0     stevel #
    394   5084    johnlev # If we get here and were not asked to plumb any IPv4 interfaces, look
    395   5084    johnlev # for boot properties that direct us.
    396   5084    johnlev #
    397   5084    johnlev # - The "network-interface" property is required and indicates the
    398   5084    johnlev #   interface name.
    399   5084    johnlev # - The "xpv-hcp" property, if present, is used by the hypervisor
    400   5084    johnlev #   tools to indicate how the specified interface should be configured.
    401   5084    johnlev #   Permitted values are "dhcp" and "off", where "off" indicates static
    402   5084    johnlev #   IP configuration.
    403   5084    johnlev #
    404   5084    johnlev # In the case where "xpv-hcp" is set to "dhcp", no further properties
    405   5084    johnlev # are required or examined.
    406   5084    johnlev #
    407   5084    johnlev # In the case where "xpv-hcp" is not present or set to "off", the
    408   5084    johnlev # "host-ip" and "subnet-mask" properties are used to configure
    409   5084    johnlev # the specified interface.  The "router-ip" property, if present,
    410   5084    johnlev # is used to add a default route.
    411   5084    johnlev #
    412   5084    johnlev nic="`/sbin/devprop network-interface`"
    413   5084    johnlev if smf_is_globalzone && [ -z "$inet_list" ] && [ -n "$nic" ]; then
    414   5084    johnlev 	hcp="`/sbin/devprop xpv-hcp`"
    415   5084    johnlev 	case "$hcp" in
    416   5084    johnlev 	"dhcp")
    417   5084    johnlev 		/sbin/ifconfig $nic plumb 2>/dev/null
    418   5084    johnlev 		[ -n "`/sbin/ifconfig $nic 2>/dev/null`" ] && (
    419   5084    johnlev 			# The interface is successfully plumbed, so
    420   5084    johnlev 			# modify "inet_list" to force the exit code
    421   5084    johnlev 			# checks to work.
    422   5084    johnlev 			inet_list=$nic;
    423   5084    johnlev 			# Given that this is the only IPv4 interface,
    424   5084    johnlev 			# we assert that it is primary.
    425   5084    johnlev 			echo "starting DHCP on primary interface $primary";
    426   5084    johnlev 			/sbin/ifconfig $nic auto-dhcp primary;
    427   5084    johnlev 			# Exit code 4 means ifconfig timed out waiting
    428   5084    johnlev 			# for dhcpagent
    429   5084    johnlev 			[ $? != 0 ] && [ $? != 4 ] && \
    430   5084    johnlev 			    i4d_fail="$i4d_fail $nic";
    431   5084    johnlev 		)
    432   5084    johnlev 		;;
    433   5084    johnlev 
    434   5084    johnlev 	"off"|"")
    435   5084    johnlev 		/sbin/devprop host-ip subnet-mask router-ip | (
    436   5084    johnlev 			read ip;
    437   5084    johnlev 			read mask;
    438   5084    johnlev 			read router;
    439   5084    johnlev 			[ -n "$ip" ] && [ -n "$mask" ] && \
    440   5084    johnlev 				/sbin/ifconfig $nic plumb 2>/dev/null
    441   5084    johnlev 			[ -n "`/sbin/ifconfig $nic 2>/dev/null`" ] && (
    442   5084    johnlev 				# The interface is successfully
    443   5084    johnlev 				# plumbed, so modify "inet_list" to
    444   5084    johnlev 				# force the exit code checks to work.
    445   5084    johnlev 				inet_list=$nic;
    446   5084    johnlev 				/sbin/ifconfig $nic  inet $ip \
    447   5084    johnlev 				    netmask $mask broadcast + up 2>/dev/null;
    448   5084    johnlev 				[ -n "$router" ] && route add \
    449   5084    johnlev 				    default $router 2>/dev/null;
    450   5084    johnlev 			)
    451   5084    johnlev 		)
    452   5084    johnlev 		;;
    453   5084    johnlev 	esac
    454   5084    johnlev fi
    455   5084    johnlev 
    456   5084    johnlev #
    457      0     stevel # We tell smf this service is online if any of the following is true:
    458      0     stevel # - no interfaces were configured for plumbing and no DHCP failures
    459      0     stevel # - any non-loopback IPv4 interfaces are up and have a non-zero address
    460      0     stevel # - there are any DHCP interfaces started
    461      0     stevel # - any non-loopback IPv6 interfaces are up
    462      0     stevel #
    463      0     stevel # If we weren't asked to configure any interfaces, exit
    464      0     stevel if [ -z "$inet_list" ] && [ -z "$inet6_list" ]; then
    465      0     stevel 	# Config error if DHCP was attempted without plumbed interfaces
    466      0     stevel 	[ -n "$i4d_fail" ] && exit $SMF_EXIT_ERR_CONFIG
    467      0     stevel 	exit $SMF_EXIT_OK
    468      0     stevel fi
    469      0     stevel 
    470      0     stevel # Any non-loopback IPv4 interfaces with usable addresses up?
    471      0     stevel if [ -n "`/sbin/ifconfig -a4u`" ]; then
    472      0     stevel     	/sbin/ifconfig -a4u | while read intf addr rest; do
    473      0     stevel 		[ $intf = inet ] && [ $addr != 127.0.0.1 ] &&
    474   5084    johnlev 		[ $addr != 0.0.0.0 ] && exit $SMF_EXIT_OK
    475      0     stevel 	done && exit $SMF_EXIT_OK
    476      0     stevel fi
    477      0     stevel 
    478      0     stevel # Any DHCP interfaces started?
    479      0     stevel [ -n "`/sbin/ifconfig -a4 dhcp status 2>/dev/null`" ] && exit $SMF_EXIT_OK
    480      0     stevel 
    481      0     stevel # Any non-loopback IPv6 interfaces up?
    482      0     stevel if [ -n "`/sbin/ifconfig -au6`" ]; then
    483      0     stevel 	/sbin/ifconfig -au6 | while read intf addr rest; do
    484   5084    johnlev 		[ $intf = inet6 ] && [ $addr != ::1/128 ] && exit $SMF_EXIT_OK
    485      0     stevel 	done && exit $SMF_EXIT_OK
    486      0     stevel fi
    487      0     stevel 
    488      0     stevel # This service was supposed to configure something yet didn't.  Exit
    489      0     stevel # with config error.
    490      0     stevel exit $SMF_EXIT_ERR_CONFIG
    491