17c478bd9Sstevel@tonic-gate#!/sbin/sh
27c478bd9Sstevel@tonic-gate#
37c478bd9Sstevel@tonic-gate# CDDL HEADER START
47c478bd9Sstevel@tonic-gate#
57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
66927f468Sdp# Common Development and Distribution License (the "License").
76927f468Sdp# You may not use this file except in compliance with the License.
87c478bd9Sstevel@tonic-gate#
97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate# and limitations under the License.
137c478bd9Sstevel@tonic-gate#
147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate#
207c478bd9Sstevel@tonic-gate# CDDL HEADER END
217c478bd9Sstevel@tonic-gate#
227c478bd9Sstevel@tonic-gate#
23*6e91bba0SGirish Moodalbail# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate# Use is subject to license terms.
257c478bd9Sstevel@tonic-gate#
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate. /lib/svc/share/smf_include.sh
287c478bd9Sstevel@tonic-gate
297c478bd9Sstevel@tonic-gate#
30f4b3ec61Sdh# In a shared-IP zone we need this service to be up, but all of the work
31f4b3ec61Sdh# it tries to do is irrelevant (and will actually lead to the service
32f4b3ec61Sdh# failing if we try to do it), so just bail out.
33f4b3ec61Sdh# In the global zone and exclusive-IP zones we proceed.
347c478bd9Sstevel@tonic-gate#
35f4b3ec61Sdhsmf_configure_ip || exit $SMF_EXIT_OK
367c478bd9Sstevel@tonic-gate
37*6e91bba0SGirish Moodalbailif [ -f /etc/hostname.lo0 ] || [ -f /etc/hostname6.lo0 ]; then
38*6e91bba0SGirish Moodalbail	echo "found /etc/hostname.lo0 or /etc/hostname6.lo0; "\
39*6e91bba0SGirish Moodalbail		    "using ifconfig to create lo0" > /dev/msglog
40*6e91bba0SGirish Moodalbail	# IPv4 loopback
41*6e91bba0SGirish Moodalbail	/sbin/ifconfig lo0 plumb 127.0.0.1 up
42*6e91bba0SGirish Moodalbail
43*6e91bba0SGirish Moodalbail	# IPv6 loopback
44*6e91bba0SGirish Moodalbail	/sbin/ifconfig lo0 inet6 plumb ::1 up
457c478bd9Sstevel@tonic-gate
46*6e91bba0SGirish Moodalbail	# Trusted Extensions shares the loopback interface with all zones
47*6e91bba0SGirish Moodalbail	if (smf_is_system_labeled); then
48*6e91bba0SGirish Moodalbail		if smf_is_globalzone; then
49*6e91bba0SGirish Moodalbail			/sbin/ifconfig lo0 all-zones
50*6e91bba0SGirish Moodalbail			/sbin/ifconfig lo0 inet6 all-zones
51*6e91bba0SGirish Moodalbail		fi
52*6e91bba0SGirish Moodalbail	fi
53*6e91bba0SGirish Moodalbailelse
54*6e91bba0SGirish Moodalbail	state=`/sbin/ipadm show-if -p -o state lo0 2>/dev/null`
55*6e91bba0SGirish Moodalbail	if [ $? -eq 0 -a "$state" = "disabled" ]; then
56*6e91bba0SGirish Moodalbail		/sbin/ipadm enable-if -t lo0
57*6e91bba0SGirish Moodalbail	else
58*6e91bba0SGirish Moodalbail		# IPv4 loopback
59*6e91bba0SGirish Moodalbail		/sbin/ipadm create-addr -t -T static -a 127.0.0.1/8 lo0/v4
607c478bd9Sstevel@tonic-gate
61*6e91bba0SGirish Moodalbail		# IPv6 loopback
62*6e91bba0SGirish Moodalbail		/sbin/ipadm create-addr -t -T static -a ::1/128 lo0/v6
63*6e91bba0SGirish Moodalbail	fi
64fdb7141fSgfaden
65*6e91bba0SGirish Moodalbail	# Trusted Extensions shares the loopback interface with all zones
66*6e91bba0SGirish Moodalbail	if (smf_is_system_labeled); then
67*6e91bba0SGirish Moodalbail		if smf_is_globalzone; then
68*6e91bba0SGirish Moodalbail			/sbin/ipadm set-addrprop -t -p zone=all-zones lo0/v4
69*6e91bba0SGirish Moodalbail			/sbin/ipadm set-addrprop -t -p zone=all-zones lo0/v6
70*6e91bba0SGirish Moodalbail		fi
71fdb7141fSgfaden	fi
72fdb7141fSgfadenfi
73*6e91bba0SGirish Moodalbail
74