xref: /titanic_44/usr/src/cmd/svc/milestone/net-loopback (revision 6e91bba0d6c6bdabbba62cefae583715a4a58e2a)
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#
30f4b3ec61Sdh155122# In a shared-IP zone we need this service to be up, but all of the work
317c478bd9Sstevel@tonic-gate# it tries to do is irrelevant (and will actually lead to the service
327c478bd9Sstevel@tonic-gate# failing if we try to do it), so just bail out.
33f4b3ec61Sdh155122# In the global zone and exclusive-IP zones we proceed.
347c478bd9Sstevel@tonic-gate#
35f4b3ec61Sdh155122smf_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
40d71dbb73Sjbeck	# IPv4 loopback
417c478bd9Sstevel@tonic-gate	/sbin/ifconfig lo0 plumb 127.0.0.1 up
427c478bd9Sstevel@tonic-gate
43d71dbb73Sjbeck	# IPv6 loopback
447c478bd9Sstevel@tonic-gate	/sbin/ifconfig lo0 inet6 plumb ::1 up
45fdb7141fSgfaden
46fdb7141fSgfaden	# Trusted Extensions shares the loopback interface with all zones
47fdb7141fSgfaden	if (smf_is_system_labeled); then
48fdb7141fSgfaden		if smf_is_globalzone; then
49fdb7141fSgfaden			/sbin/ifconfig lo0 all-zones
50fdb7141fSgfaden			/sbin/ifconfig lo0 inet6 all-zones
51fdb7141fSgfaden		fi
52fdb7141fSgfaden	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
60*6e91bba0SGirish Moodalbail
61*6e91bba0SGirish Moodalbail		# IPv6 loopback
62*6e91bba0SGirish Moodalbail		/sbin/ipadm create-addr -t -T static -a ::1/128 lo0/v6
63*6e91bba0SGirish Moodalbail	fi
64*6e91bba0SGirish Moodalbail
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
71*6e91bba0SGirish Moodalbail	fi
72*6e91bba0SGirish Moodalbailfi
73*6e91bba0SGirish Moodalbail
74