10Sstevel@tonic-gate#!/sbin/sh 20Sstevel@tonic-gate# 30Sstevel@tonic-gate# CDDL HEADER START 40Sstevel@tonic-gate# 50Sstevel@tonic-gate# The contents of this file are subject to the terms of the 61573Sdp# Common Development and Distribution License (the "License"). 71573Sdp# You may not use this file except in compliance with the License. 80Sstevel@tonic-gate# 90Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate# See the License for the specific language governing permissions 120Sstevel@tonic-gate# and limitations under the License. 130Sstevel@tonic-gate# 140Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate# 200Sstevel@tonic-gate# CDDL HEADER END 210Sstevel@tonic-gate# 220Sstevel@tonic-gate# 2312163SRamaswamy.Tummala@Sun.COM# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 240Sstevel@tonic-gate# 250Sstevel@tonic-gate# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T. 260Sstevel@tonic-gate# All rights reserved. 270Sstevel@tonic-gate# 280Sstevel@tonic-gate 291573Sdp. /lib/svc/share/smf_include.sh 301573Sdp. /lib/svc/share/net_include.sh 311573Sdp 320Sstevel@tonic-gate# 333448Sdh155122# In a shared-IP zone we need this service to be up, but all of the work 343448Sdh155122# it tries to do is irrelevant (and will actually lead to the service 353448Sdh155122# failing if we try to do it), so just bail out. 363448Sdh155122# In the global zone and exclusive-IP zones we proceed. 370Sstevel@tonic-gate# 383448Sdh155122smf_configure_ip || exit $SMF_EXIT_OK 390Sstevel@tonic-gate 4012016SGirish.Moodalbail@Sun.COM 410Sstevel@tonic-gate# Make sure that the libraries essential to this stage of booting can be found. 420Sstevel@tonic-gateLD_LIBRARY_PATH=/lib; export LD_LIBRARY_PATH 430Sstevel@tonic-gate 440Sstevel@tonic-gatesmf_netstrategy 450Sstevel@tonic-gate 463448Sdh155122if smf_is_globalzone; then 475895Syz147064 net_reconfigure || exit $SMF_EXIT_ERR_CONFIG 485895Syz147064 4910491SRishi.Srivatsavai@Sun.COM # Update PVID on interfaces configured with VLAN 1 5010491SRishi.Srivatsavai@Sun.COM update_pvid 5110491SRishi.Srivatsavai@Sun.COM 525895Syz147064 # 535895Syz147064 # Upgrade handling. The upgrade file consists of a series of dladm(1M) 545895Syz147064 # commands. Note that after we are done, we cannot rename the upgrade 555895Syz147064 # script file as the file system is still read-only at this point. 565895Syz147064 # Defer this to the manifest-import service. 575895Syz147064 # 585895Syz147064 upgrade_script=/var/svc/profile/upgrade_datalink 595895Syz147064 if [ -f "${upgrade_script}" ]; then 605895Syz147064 . "${upgrade_script}" 615895Syz147064 fi 625895Syz147064 633448Sdh155122 # 6412163SRamaswamy.Tummala@Sun.COM # Upgrade handling for ibd: 6512163SRamaswamy.Tummala@Sun.COM # After we are done with the upgrade handling, we can not set the 6612163SRamaswamy.Tummala@Sun.COM # ibd/ibd_upgraded property to "true" as the file system is 6712163SRamaswamy.Tummala@Sun.COM # read-only at this point. It will be done later by ibd-post-upgrade 6812163SRamaswamy.Tummala@Sun.COM # service. 6912163SRamaswamy.Tummala@Sun.COM # 7012163SRamaswamy.Tummala@Sun.COM ibd_upgraded=`/bin/svcprop -c -p ibd/ibd_upgraded \ 7112163SRamaswamy.Tummala@Sun.COM $SMF_FMRI 2> /dev/null` 7212163SRamaswamy.Tummala@Sun.COM if [ "$ibd_upgraded" != "true" ]; then 7312163SRamaswamy.Tummala@Sun.COM /sbin/ibd_upgrade -v 7412163SRamaswamy.Tummala@Sun.COM fi 7512163SRamaswamy.Tummala@Sun.COM 7612163SRamaswamy.Tummala@Sun.COM # 779815SRishi.Srivatsavai@Sun.COM # Bring up simnets, link aggregations and initialize security objects. 783448Sdh155122 # Note that link property initialization is deferred until after 793448Sdh155122 # IP interfaces are plumbed to ensure that the links will not 809815SRishi.Srivatsavai@Sun.COM # be unloaded (and the property settings lost). We should bring 819815SRishi.Srivatsavai@Sun.COM # up simnets prior to VLANs/Aggrs to enable creation of VLANs/Aggrs 829815SRishi.Srivatsavai@Sun.COM # over simnets. 833448Sdh155122 # 849815SRishi.Srivatsavai@Sun.COM /sbin/dladm up-simnet 853448Sdh155122 /sbin/dladm up-aggr 865895Syz147064 /sbin/dladm up-vlan 8712163SRamaswamy.Tummala@Sun.COM /sbin/dladm up-part 883448Sdh155122 /sbin/dladm init-secobj 898275SEric Cheng # 908275SEric Cheng # Bring up VNICs 918275SEric Cheng # 928275SEric Cheng /sbin/dladm up-vnic 938275SEric Cheng # 948275SEric Cheng # Create flows via flowadm. 958275SEric Cheng # 968275SEric Cheng /sbin/flowadm init-flow 973448Sdh155122fi 98269Sericheng 99269Sericheng# 1000Sstevel@tonic-gate# If the system was net booted by DHCP, hand DHCP management off to the 1010Sstevel@tonic-gate# DHCP agent (ifconfig communicates to the DHCP agent through the 1020Sstevel@tonic-gate# loopback interface). 1030Sstevel@tonic-gate# 1040Sstevel@tonic-gateif [ -n "$_INIT_NET_IF" -a "$_INIT_NET_STRATEGY" = "dhcp" ]; then 1050Sstevel@tonic-gate /sbin/dhcpagent -a 1060Sstevel@tonic-gatefi 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate# 1090Sstevel@tonic-gate# The network initialization is done early to support diskless and 1100Sstevel@tonic-gate# dataless configurations. For IPv4 interfaces that were configured by 1110Sstevel@tonic-gate# the kernel (e.g. those on diskless machines) and not configured by 1120Sstevel@tonic-gate# DHCP, reset the netmask using the local "/etc/netmasks" file if one 1130Sstevel@tonic-gate# exists, and then reset the broadcast address based on the netmask. 1140Sstevel@tonic-gate# 1150Sstevel@tonic-gate/sbin/ifconfig -auD4 netmask + broadcast + 1160Sstevel@tonic-gate 11710616SSebastien.Roy@Sun.COMis_iptun () 11810616SSebastien.Roy@Sun.COM{ 11910616SSebastien.Roy@Sun.COM intf=$1 12010616SSebastien.Roy@Sun.COM # Is this a persistent IP tunnel link? 12110616SSebastien.Roy@Sun.COM /sbin/dladm show-iptun -P $intf > /dev/null 2>&1 12210616SSebastien.Roy@Sun.COM if [ $? -eq 0 ]; then 12310616SSebastien.Roy@Sun.COM return 0 12410616SSebastien.Roy@Sun.COM fi 12510616SSebastien.Roy@Sun.COM # Is this an implicit IP tunnel (i.e., ip.tun0) 12610616SSebastien.Roy@Sun.COM ORIGIFS="$IFS" 12710616SSebastien.Roy@Sun.COM IFS="$IFS." 12810616SSebastien.Roy@Sun.COM set -- $intf 12910616SSebastien.Roy@Sun.COM IFS="$ORIGIFS" 13010616SSebastien.Roy@Sun.COM if [ $# -eq 2 -a \( "$1" = "ip" -o "$1" = "ip6" \) ]; then 13110616SSebastien.Roy@Sun.COM # 13210616SSebastien.Roy@Sun.COM # It looks like one, but another type of link might be 13310616SSebastien.Roy@Sun.COM # using a name that looks like an implicit IP tunnel. 13410616SSebastien.Roy@Sun.COM # If dladm show-link -P finds it, then it's not an IP 13510616SSebastien.Roy@Sun.COM # tunnel. 13610616SSebastien.Roy@Sun.COM # 13710616SSebastien.Roy@Sun.COM /sbin/dladm show-link -Pp $intf > /dev/null 2>&1 13810616SSebastien.Roy@Sun.COM if [ $? -eq 0 ]; then 13910616SSebastien.Roy@Sun.COM return 1 14010616SSebastien.Roy@Sun.COM else 14110616SSebastien.Roy@Sun.COM return 0 14210616SSebastien.Roy@Sun.COM fi 14310616SSebastien.Roy@Sun.COM fi 14410616SSebastien.Roy@Sun.COM return 1 14510616SSebastien.Roy@Sun.COM} 14610616SSebastien.Roy@Sun.COM 1470Sstevel@tonic-gate# 1480Sstevel@tonic-gate# All the IPv4 and IPv6 interfaces are plumbed before doing any 1490Sstevel@tonic-gate# interface configuration. This prevents errors from plumb failures 1500Sstevel@tonic-gate# getting mixed in with the configured interface lists that the script 1510Sstevel@tonic-gate# outputs. 1520Sstevel@tonic-gate# 1530Sstevel@tonic-gate 1540Sstevel@tonic-gate# 15512016SGirish.Moodalbail@Sun.COM# First deal with /etc/hostname 15612016SGirish.Moodalbail@Sun.COM# 1570Sstevel@tonic-gate# Get the list of IPv4 interfaces to configure by breaking 1580Sstevel@tonic-gate# /etc/hostname.* into separate args by using "." as a shell separator 1590Sstevel@tonic-gate# character. 1600Sstevel@tonic-gate# 1610Sstevel@tonic-gateinterface_names="`echo /etc/hostname.*[0-9] 2>/dev/null`" 1620Sstevel@tonic-gateif [ "$interface_names" != "/etc/hostname.*[0-9]" ]; then 1630Sstevel@tonic-gate ORIGIFS="$IFS" 1640Sstevel@tonic-gate IFS="$IFS." 1650Sstevel@tonic-gate set -- $interface_names 1660Sstevel@tonic-gate IFS="$ORIGIFS" 1670Sstevel@tonic-gate while [ $# -ge 2 ]; do 1680Sstevel@tonic-gate shift 1698485SPeter.Memishian@Sun.COM intf_name=$1 1708485SPeter.Memishian@Sun.COM while [ $# -gt 1 -a "$2" != "/etc/hostname" ]; do 1718485SPeter.Memishian@Sun.COM intf_name="$intf_name.$2" 1728485SPeter.Memishian@Sun.COM shift 1738485SPeter.Memishian@Sun.COM done 1748485SPeter.Memishian@Sun.COM shift 1758485SPeter.Memishian@Sun.COM 17610616SSebastien.Roy@Sun.COM # skip IP tunnel interfaces plumbed by net-iptun. 17710616SSebastien.Roy@Sun.COM if is_iptun $intf_name; then 17810616SSebastien.Roy@Sun.COM continue 17910616SSebastien.Roy@Sun.COM fi 18010616SSebastien.Roy@Sun.COM 1818485SPeter.Memishian@Sun.COM read one rest < /etc/hostname.$intf_name 1828485SPeter.Memishian@Sun.COM if [ "$one" = ipmp ]; then 1838485SPeter.Memishian@Sun.COM ipmp_list="$ipmp_list $intf_name" 1840Sstevel@tonic-gate else 1858485SPeter.Memishian@Sun.COM inet_list="$inet_list $intf_name" 1860Sstevel@tonic-gate fi 1870Sstevel@tonic-gate done 1880Sstevel@tonic-gatefi 1890Sstevel@tonic-gate 1900Sstevel@tonic-gate# 1910Sstevel@tonic-gate# Get the list of IPv6 interfaces to configure by breaking 1920Sstevel@tonic-gate# /etc/hostname6.* into separate args by using "." as a shell separator 1930Sstevel@tonic-gate# character. 1940Sstevel@tonic-gate# 1950Sstevel@tonic-gateinterface_names="`echo /etc/hostname6.*[0-9] 2>/dev/null`" 1960Sstevel@tonic-gateif [ "$interface_names" != "/etc/hostname6.*[0-9]" ]; then 1970Sstevel@tonic-gate ORIGIFS="$IFS" 1980Sstevel@tonic-gate IFS="$IFS." 1990Sstevel@tonic-gate set -- $interface_names 2000Sstevel@tonic-gate IFS="$ORIGIFS" 2010Sstevel@tonic-gate while [ $# -ge 2 ]; do 2020Sstevel@tonic-gate shift 2038485SPeter.Memishian@Sun.COM intf_name=$1 2048485SPeter.Memishian@Sun.COM while [ $# -gt 1 -a "$2" != "/etc/hostname6" ]; do 2058485SPeter.Memishian@Sun.COM intf_name="$intf_name.$2" 2068485SPeter.Memishian@Sun.COM shift 2078485SPeter.Memishian@Sun.COM done 2088485SPeter.Memishian@Sun.COM shift 2098485SPeter.Memishian@Sun.COM 21010616SSebastien.Roy@Sun.COM # skip IP tunnel interfaces plumbed by net-iptun. 21110616SSebastien.Roy@Sun.COM if is_iptun $intf_name; then 21210616SSebastien.Roy@Sun.COM continue 21310616SSebastien.Roy@Sun.COM fi 21410616SSebastien.Roy@Sun.COM 2158485SPeter.Memishian@Sun.COM read one rest < /etc/hostname6.$intf_name 2168485SPeter.Memishian@Sun.COM if [ "$one" = ipmp ]; then 2178485SPeter.Memishian@Sun.COM ipmp6_list="$ipmp6_list $intf_name" 2180Sstevel@tonic-gate else 2198485SPeter.Memishian@Sun.COM inet6_list="$inet6_list $intf_name" 2200Sstevel@tonic-gate fi 2210Sstevel@tonic-gate done 2220Sstevel@tonic-gatefi 2230Sstevel@tonic-gate 2248485SPeter.Memishian@Sun.COM# 2258485SPeter.Memishian@Sun.COM# Create all of the IPv4 IPMP interfaces. 2268485SPeter.Memishian@Sun.COM# 2278485SPeter.Memishian@Sun.COMif [ -n "$ipmp_list" ]; then 2288485SPeter.Memishian@Sun.COM set -- $ipmp_list 2298485SPeter.Memishian@Sun.COM while [ $# -gt 0 ]; do 2308485SPeter.Memishian@Sun.COM if /sbin/ifconfig $1 ipmp; then 2318485SPeter.Memishian@Sun.COM ipmp_created="$ipmp_created $1" 2328485SPeter.Memishian@Sun.COM else 2338485SPeter.Memishian@Sun.COM ipmp_failed="$ipmp_failed $1" 2348485SPeter.Memishian@Sun.COM fi 2358485SPeter.Memishian@Sun.COM shift 2368485SPeter.Memishian@Sun.COM done 2378485SPeter.Memishian@Sun.COM [ -n "$ipmp_failed" ] && warn_failed_ifs "create IPv4 IPMP" \ 2388485SPeter.Memishian@Sun.COM "$ipmp_failed" 2398485SPeter.Memishian@Sun.COMfi 2400Sstevel@tonic-gate 2410Sstevel@tonic-gate# 2420Sstevel@tonic-gate# Step through the IPv4 interface list and try to plumb every interface. 2430Sstevel@tonic-gate# Generate list of plumbed and failed IPv4 interfaces. 2440Sstevel@tonic-gate# 2450Sstevel@tonic-gateif [ -n "$inet_list" ]; then 2460Sstevel@tonic-gate set -- $inet_list 2470Sstevel@tonic-gate while [ $# -gt 0 ]; do 2480Sstevel@tonic-gate /sbin/ifconfig $1 plumb 2490Sstevel@tonic-gate if /sbin/ifconfig $1 inet >/dev/null 2>&1; then 2500Sstevel@tonic-gate inet_plumbed="$inet_plumbed $1" 2510Sstevel@tonic-gate else 2520Sstevel@tonic-gate inet_failed="$inet_failed $1" 2530Sstevel@tonic-gate fi 2540Sstevel@tonic-gate shift 2550Sstevel@tonic-gate done 2568485SPeter.Memishian@Sun.COM [ -n "$inet_failed" ] && warn_failed_ifs "plumb IPv4" "$inet_failed" 2570Sstevel@tonic-gatefi 2580Sstevel@tonic-gate 259995Shx147065# Run autoconf to connect to a WLAN if the interface is a wireless one 260995Shx147065if [ -x /sbin/wificonfig -a -n "$inet_plumbed" ]; then 261995Shx147065 set -- $inet_plumbed 262995Shx147065 while [ $# -gt 0 ]; do 263995Shx147065 if [ -r /dev/wifi/$1 ]; then 264995Shx147065 /sbin/wificonfig -i $1 startconf >/dev/null 265995Shx147065 fi 266995Shx147065 shift 267995Shx147065 done 268995Shx147065fi 269995Shx147065 2700Sstevel@tonic-gate# 2710Sstevel@tonic-gate# Step through the IPv6 interface list and plumb every interface. 2720Sstevel@tonic-gate# Generate list of plumbed and failed IPv6 interfaces. Each plumbed 2730Sstevel@tonic-gate# interface will be brought up later, after processing any contents of 2740Sstevel@tonic-gate# the /etc/hostname6.* file. 2750Sstevel@tonic-gate# 2760Sstevel@tonic-gateif [ -n "$inet6_list" ]; then 2770Sstevel@tonic-gate set -- $inet6_list 2780Sstevel@tonic-gate while [ $# -gt 0 ]; do 2790Sstevel@tonic-gate /sbin/ifconfig $1 inet6 plumb 2800Sstevel@tonic-gate if /sbin/ifconfig $1 inet6 >/dev/null 2>&1; then 2810Sstevel@tonic-gate inet6_plumbed="$inet6_plumbed $1" 2820Sstevel@tonic-gate else 2830Sstevel@tonic-gate inet6_failed="$inet6_failed $1" 2840Sstevel@tonic-gate fi 2850Sstevel@tonic-gate shift 2860Sstevel@tonic-gate done 2878485SPeter.Memishian@Sun.COM [ -n "$inet6_failed" ] && warn_failed_ifs "plumb IPv6" "$inet6_failed" 2888485SPeter.Memishian@Sun.COMfi 2898485SPeter.Memishian@Sun.COM 2908485SPeter.Memishian@Sun.COM# 2918485SPeter.Memishian@Sun.COM# Create all of the IPv6 IPMP interfaces. 2928485SPeter.Memishian@Sun.COM# 2938485SPeter.Memishian@Sun.COMif [ -n "$ipmp6_list" ]; then 2948485SPeter.Memishian@Sun.COM set -- $ipmp6_list 2958485SPeter.Memishian@Sun.COM while [ $# -gt 0 ]; do 2968485SPeter.Memishian@Sun.COM if /sbin/ifconfig $1 inet6 ipmp; then 2978485SPeter.Memishian@Sun.COM ipmp6_created="$ipmp6_created $1" 2988485SPeter.Memishian@Sun.COM else 2998485SPeter.Memishian@Sun.COM ipmp6_failed="$ipmp6_failed $1" 3008485SPeter.Memishian@Sun.COM fi 3018485SPeter.Memishian@Sun.COM shift 3028485SPeter.Memishian@Sun.COM done 3038485SPeter.Memishian@Sun.COM [ -n "$ipmp6_failed" ] && warn_failed_ifs "create IPv6 IPMP" \ 3048485SPeter.Memishian@Sun.COM "$ipmp6_failed" 3050Sstevel@tonic-gatefi 3060Sstevel@tonic-gate 3073147Sxc151355# 308*12748SSowmini.Varadhan@oracle.COM# Finally configure interfaces set up with ipadm. Any /etc/hostname*.intf 309*12748SSowmini.Varadhan@oracle.COM# files take precedence over ipadm defined configurations except when 310*12748SSowmini.Varadhan@oracle.COM# we are in a non-global zone and Layer-3 protection of IP addresses is 311*12748SSowmini.Varadhan@oracle.COM# enforced on the interface by the global zone. 31212016SGirish.Moodalbail@Sun.COM# 313*12748SSowmini.Varadhan@oracle.COMfor showif_output in `/sbin/ipadm show-if -p -o ifname,state,current`; do 31412016SGirish.Moodalbail@Sun.COM intf=`echo $showif_output | /usr/bin/cut -f1 -d:` 31512016SGirish.Moodalbail@Sun.COM state=`echo $showif_output | /usr/bin/cut -f2 -d:` 316*12748SSowmini.Varadhan@oracle.COM current=`echo $showif_output | /usr/bin/cut -f3 -d:` 317*12748SSowmini.Varadhan@oracle.COM if [[ "$state" != "disabled" && $current != *Z* ]]; then 318*12748SSowmini.Varadhan@oracle.COM # 319*12748SSowmini.Varadhan@oracle.COM # skip if not a persistent interface, or if it should get IP 320*12748SSowmini.Varadhan@oracle.COM # configuration from the global zone ('Z' flag is set) 321*12748SSowmini.Varadhan@oracle.COM # 32212016SGirish.Moodalbail@Sun.COM continue; 32312016SGirish.Moodalbail@Sun.COM elif is_iptun $intf; then 32412016SGirish.Moodalbail@Sun.COM # skip IP tunnel interfaces plumbed by net-iptun 32512016SGirish.Moodalbail@Sun.COM continue; 32612016SGirish.Moodalbail@Sun.COM elif [ -f /etc/hostname.$intf ] || [ -f /etc/hostname6.$intf ]; then 327*12748SSowmini.Varadhan@oracle.COM if [[ $current != *Z* ]]; then 328*12748SSowmini.Varadhan@oracle.COM echo "found /etc/hostname.$intf "\ 329*12748SSowmini.Varadhan@oracle.COM "or /etc/hostname6.$intf, "\ 330*12748SSowmini.Varadhan@oracle.COM "ignoring ipadm configuration" > /dev/msglog 331*12748SSowmini.Varadhan@oracle.COM continue; 332*12748SSowmini.Varadhan@oracle.COM else 333*12748SSowmini.Varadhan@oracle.COM echo "Ignoring /etc/hostname*.$intf" > /dev/msglog 334*12748SSowmini.Varadhan@oracle.COM /sbin/ifconfig $intf unplumb > /dev/null 2>&1 335*12748SSowmini.Varadhan@oracle.COM /sbin/ifconfig $intf inet6 unplumb > /dev/null 2>&1 336*12748SSowmini.Varadhan@oracle.COM fi 33712016SGirish.Moodalbail@Sun.COM fi 33812016SGirish.Moodalbail@Sun.COM 33912016SGirish.Moodalbail@Sun.COM # Enable the interface managed by ipadm 34012016SGirish.Moodalbail@Sun.COM /sbin/ipadm enable-if -t $intf 34112016SGirish.Moodalbail@Sun.COMdone 34212016SGirish.Moodalbail@Sun.COM 34312016SGirish.Moodalbail@Sun.COM# 3448485SPeter.Memishian@Sun.COM# Process the /etc/hostname[6].* files for IPMP interfaces. Processing these 3458485SPeter.Memishian@Sun.COM# before non-IPMP interfaces avoids accidental implicit IPMP group creation. 3460Sstevel@tonic-gate# 3478485SPeter.Memishian@Sun.COM[ -n "$ipmp_created" ] && if_configure inet "IPMP" $ipmp_created 3488485SPeter.Memishian@Sun.COM[ -n "$ipmp6_created" ] && if_configure inet6 "IPMP" $ipmp6_created 3490Sstevel@tonic-gate 3500Sstevel@tonic-gate# 3518485SPeter.Memishian@Sun.COM# Process the /etc/hostname[6].* files for non-IPMP interfaces. 3528485SPeter.Memishian@Sun.COM# 3538485SPeter.Memishian@Sun.COM[ -n "$inet_plumbed" ] && if_configure inet "" $inet_plumbed 3548485SPeter.Memishian@Sun.COM[ -n "$inet6_plumbed" ] && if_configure inet6 "" $inet6_plumbed 3558485SPeter.Memishian@Sun.COM 3560Sstevel@tonic-gate# 3578485SPeter.Memishian@Sun.COM# For the IPv4 and IPv6 interfaces that failed to plumb, find (or create) 3588485SPeter.Memishian@Sun.COM# IPMP meta-interfaces to host their data addresses. 3598485SPeter.Memishian@Sun.COM# 3608485SPeter.Memishian@Sun.COM[ -n "$inet_failed" ] && move_addresses inet 3618485SPeter.Memishian@Sun.COM[ -n "$inet6_failed" ] && move_addresses inet6 3620Sstevel@tonic-gate 3630Sstevel@tonic-gate# Run DHCP if requested. Skip boot-configured interface. 3640Sstevel@tonic-gateinterface_names="`echo /etc/dhcp.*[0-9] 2>/dev/null`" 3650Sstevel@tonic-gateif [ "$interface_names" != '/etc/dhcp.*[0-9]' ]; then 3660Sstevel@tonic-gate # 3670Sstevel@tonic-gate # First find the primary interface. Default to the first 3680Sstevel@tonic-gate # interface if not specified. First primary interface found 3690Sstevel@tonic-gate # "wins". Use care not to "reconfigure" a net-booted interface 3700Sstevel@tonic-gate # configured using DHCP. Run through the list of interfaces 3710Sstevel@tonic-gate # again, this time trying DHCP. 3720Sstevel@tonic-gate # 3730Sstevel@tonic-gate i4d_fail= 3740Sstevel@tonic-gate firstif= 3750Sstevel@tonic-gate primary= 3760Sstevel@tonic-gate ORIGIFS="$IFS" 3770Sstevel@tonic-gate IFS="${IFS}." 3780Sstevel@tonic-gate set -- $interface_names 3790Sstevel@tonic-gate 3800Sstevel@tonic-gate while [ $# -ge 2 ]; do 3810Sstevel@tonic-gate shift 3820Sstevel@tonic-gate [ -z "$firstif" ] && firstif=$1 3830Sstevel@tonic-gate 3840Sstevel@tonic-gate for i in `shcat /etc/dhcp\.$1`; do 3850Sstevel@tonic-gate if [ "$i" = primary ]; then 3860Sstevel@tonic-gate primary=$1 3870Sstevel@tonic-gate break 3880Sstevel@tonic-gate fi 3890Sstevel@tonic-gate done 3900Sstevel@tonic-gate 3910Sstevel@tonic-gate [ -n "$primary" ] && break 3920Sstevel@tonic-gate shift 3930Sstevel@tonic-gate done 3940Sstevel@tonic-gate 3950Sstevel@tonic-gate [ -z "$primary" ] && primary="$firstif" 3960Sstevel@tonic-gate cmdline=`shcat /etc/dhcp\.${primary}` 3970Sstevel@tonic-gate 3980Sstevel@tonic-gate if [ "$_INIT_NET_IF" != "$primary" ]; then 3990Sstevel@tonic-gate echo "starting DHCP on primary interface $primary" 4000Sstevel@tonic-gate /sbin/ifconfig $primary auto-dhcp primary $cmdline 4010Sstevel@tonic-gate # Exit code 4 means ifconfig timed out waiting for dhcpagent 4025084Sjohnlev [ $? != 0 ] && [ $? != 4 ] && i4d_fail="$i4d_fail $primary" 4030Sstevel@tonic-gate fi 4040Sstevel@tonic-gate 4050Sstevel@tonic-gate set -- $interface_names 4060Sstevel@tonic-gate 4070Sstevel@tonic-gate while [ $# -ge 2 ]; do 4080Sstevel@tonic-gate shift 4090Sstevel@tonic-gate cmdline=`shcat /etc/dhcp\.$1` 4100Sstevel@tonic-gate if [ "$1" != "$primary" -a \ 4110Sstevel@tonic-gate "$1" != "$_INIT_NET_IF" ]; then 4120Sstevel@tonic-gate echo "starting DHCP on interface $1" 4130Sstevel@tonic-gate /sbin/ifconfig $1 dhcp start wait 0 $cmdline 4140Sstevel@tonic-gate # Exit code can't be timeout when wait is 0 4150Sstevel@tonic-gate [ $? != 0 ] && i4d_fail="$i4d_fail $1" 4160Sstevel@tonic-gate fi 4170Sstevel@tonic-gate shift 4180Sstevel@tonic-gate done 4190Sstevel@tonic-gate IFS="$ORIGIFS" 4200Sstevel@tonic-gate unset ORIGIFS 4218485SPeter.Memishian@Sun.COM [ -n "$i4d_fail" ] && warn_failed_ifs "configure IPv4 DHCP" "$i4d_fail" 4220Sstevel@tonic-gatefi 4230Sstevel@tonic-gate 42467Sse146197# In order to avoid bringing up the interfaces that have 42567Sse146197# intentionally been left down, perform RARP only if the system 42667Sse146197# has no configured hostname in /etc/nodename 42767Sse146197hostname="`shcat /etc/nodename 2>/dev/null`" 42867Sse146197if [ "$_INIT_NET_STRATEGY" = "rarp" -o -z "$hostname" ]; then 42967Sse146197 /sbin/ifconfig -adD4 auto-revarp netmask + broadcast + up 43067Sse146197fi 4310Sstevel@tonic-gate 4320Sstevel@tonic-gate# 4330Sstevel@tonic-gate# If the /etc/defaultrouter file exists, process it now so that the next 4340Sstevel@tonic-gate# stage of booting will have access to NFS. 4350Sstevel@tonic-gate# 4360Sstevel@tonic-gateif [ -f /etc/defaultrouter ]; then 4370Sstevel@tonic-gate while read router rubbish; do 4380Sstevel@tonic-gate case "$router" in 4390Sstevel@tonic-gate '#'* | '') ;; # Ignore comments, empty lines 4400Sstevel@tonic-gate *) /sbin/route -n add default -gateway $router ;; 4410Sstevel@tonic-gate esac 4420Sstevel@tonic-gate done </etc/defaultrouter 4430Sstevel@tonic-gatefi 4440Sstevel@tonic-gate 4450Sstevel@tonic-gate# 4465084Sjohnlev# If we get here and were not asked to plumb any IPv4 interfaces, look 4475084Sjohnlev# for boot properties that direct us. 4485084Sjohnlev# 4495084Sjohnlev# - The "network-interface" property is required and indicates the 4505084Sjohnlev# interface name. 4515084Sjohnlev# - The "xpv-hcp" property, if present, is used by the hypervisor 4525084Sjohnlev# tools to indicate how the specified interface should be configured. 4535084Sjohnlev# Permitted values are "dhcp" and "off", where "off" indicates static 4545084Sjohnlev# IP configuration. 4555084Sjohnlev# 4565084Sjohnlev# In the case where "xpv-hcp" is set to "dhcp", no further properties 4575084Sjohnlev# are required or examined. 4585084Sjohnlev# 4595084Sjohnlev# In the case where "xpv-hcp" is not present or set to "off", the 4605084Sjohnlev# "host-ip" and "subnet-mask" properties are used to configure 4615084Sjohnlev# the specified interface. The "router-ip" property, if present, 4625084Sjohnlev# is used to add a default route. 4635084Sjohnlev# 4645084Sjohnlevnic="`/sbin/devprop network-interface`" 4655084Sjohnlevif smf_is_globalzone && [ -z "$inet_list" ] && [ -n "$nic" ]; then 4665084Sjohnlev hcp="`/sbin/devprop xpv-hcp`" 4675084Sjohnlev case "$hcp" in 4685084Sjohnlev "dhcp") 4695084Sjohnlev /sbin/ifconfig $nic plumb 2>/dev/null 4705084Sjohnlev [ -n "`/sbin/ifconfig $nic 2>/dev/null`" ] && ( 4715084Sjohnlev # The interface is successfully plumbed, so 4725084Sjohnlev # modify "inet_list" to force the exit code 4735084Sjohnlev # checks to work. 4745084Sjohnlev inet_list=$nic; 4755084Sjohnlev # Given that this is the only IPv4 interface, 4765084Sjohnlev # we assert that it is primary. 4775084Sjohnlev echo "starting DHCP on primary interface $primary"; 4785084Sjohnlev /sbin/ifconfig $nic auto-dhcp primary; 4795084Sjohnlev # Exit code 4 means ifconfig timed out waiting 4805084Sjohnlev # for dhcpagent 4815084Sjohnlev [ $? != 0 ] && [ $? != 4 ] && \ 4825084Sjohnlev i4d_fail="$i4d_fail $nic"; 4835084Sjohnlev ) 4845084Sjohnlev ;; 4855084Sjohnlev 4865084Sjohnlev "off"|"") 4875084Sjohnlev /sbin/devprop host-ip subnet-mask router-ip | ( 4885084Sjohnlev read ip; 4895084Sjohnlev read mask; 4905084Sjohnlev read router; 4915084Sjohnlev [ -n "$ip" ] && [ -n "$mask" ] && \ 4925084Sjohnlev /sbin/ifconfig $nic plumb 2>/dev/null 4935084Sjohnlev [ -n "`/sbin/ifconfig $nic 2>/dev/null`" ] && ( 4945084Sjohnlev # The interface is successfully 4955084Sjohnlev # plumbed, so modify "inet_list" to 4965084Sjohnlev # force the exit code checks to work. 4975084Sjohnlev inet_list=$nic; 4985084Sjohnlev /sbin/ifconfig $nic inet $ip \ 4995084Sjohnlev netmask $mask broadcast + up 2>/dev/null; 5005084Sjohnlev [ -n "$router" ] && route add \ 5015084Sjohnlev default $router 2>/dev/null; 5025084Sjohnlev ) 5035084Sjohnlev ) 5045084Sjohnlev ;; 5055084Sjohnlev esac 5065084Sjohnlevfi 5075084Sjohnlev 5085084Sjohnlev# 5090Sstevel@tonic-gate# We tell smf this service is online if any of the following is true: 5100Sstevel@tonic-gate# - no interfaces were configured for plumbing and no DHCP failures 5110Sstevel@tonic-gate# - any non-loopback IPv4 interfaces are up and have a non-zero address 5120Sstevel@tonic-gate# - there are any DHCP interfaces started 5130Sstevel@tonic-gate# - any non-loopback IPv6 interfaces are up 5140Sstevel@tonic-gate# 5150Sstevel@tonic-gate# If we weren't asked to configure any interfaces, exit 5160Sstevel@tonic-gateif [ -z "$inet_list" ] && [ -z "$inet6_list" ]; then 5170Sstevel@tonic-gate # Config error if DHCP was attempted without plumbed interfaces 5180Sstevel@tonic-gate [ -n "$i4d_fail" ] && exit $SMF_EXIT_ERR_CONFIG 5190Sstevel@tonic-gate exit $SMF_EXIT_OK 5200Sstevel@tonic-gatefi 5210Sstevel@tonic-gate 5220Sstevel@tonic-gate# Any non-loopback IPv4 interfaces with usable addresses up? 5230Sstevel@tonic-gateif [ -n "`/sbin/ifconfig -a4u`" ]; then 5240Sstevel@tonic-gate /sbin/ifconfig -a4u | while read intf addr rest; do 5250Sstevel@tonic-gate [ $intf = inet ] && [ $addr != 127.0.0.1 ] && 5265084Sjohnlev [ $addr != 0.0.0.0 ] && exit $SMF_EXIT_OK 5270Sstevel@tonic-gate done && exit $SMF_EXIT_OK 5280Sstevel@tonic-gatefi 5290Sstevel@tonic-gate 5300Sstevel@tonic-gate# Any DHCP interfaces started? 5310Sstevel@tonic-gate[ -n "`/sbin/ifconfig -a4 dhcp status 2>/dev/null`" ] && exit $SMF_EXIT_OK 5320Sstevel@tonic-gate 5330Sstevel@tonic-gate# Any non-loopback IPv6 interfaces up? 5340Sstevel@tonic-gateif [ -n "`/sbin/ifconfig -au6`" ]; then 5350Sstevel@tonic-gate /sbin/ifconfig -au6 | while read intf addr rest; do 5365084Sjohnlev [ $intf = inet6 ] && [ $addr != ::1/128 ] && exit $SMF_EXIT_OK 5370Sstevel@tonic-gate done && exit $SMF_EXIT_OK 5380Sstevel@tonic-gatefi 5390Sstevel@tonic-gate 5400Sstevel@tonic-gate# This service was supposed to configure something yet didn't. Exit 5410Sstevel@tonic-gate# with config error. 5420Sstevel@tonic-gateexit $SMF_EXIT_ERR_CONFIG 543