xref: /onnv-gate/usr/src/cmd/svc/milestone/net-loopback (revision 12016:0248e987199b)
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#
23*12016SGirish.Moodalbail@Sun.COM# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate# Use is subject to license terms.
250Sstevel@tonic-gate#
260Sstevel@tonic-gate
270Sstevel@tonic-gate. /lib/svc/share/smf_include.sh
280Sstevel@tonic-gate
290Sstevel@tonic-gate#
303448Sdh155122# In a shared-IP zone we need this service to be up, but all of the work
313448Sdh155122# it tries to do is irrelevant (and will actually lead to the service
323448Sdh155122# failing if we try to do it), so just bail out.
333448Sdh155122# In the global zone and exclusive-IP zones we proceed.
340Sstevel@tonic-gate#
353448Sdh155122smf_configure_ip || exit $SMF_EXIT_OK
360Sstevel@tonic-gate
37*12016SGirish.Moodalbail@Sun.COMif [ -f /etc/hostname.lo0 ] || [ -f /etc/hostname6.lo0 ]; then
38*12016SGirish.Moodalbail@Sun.COM	echo "found /etc/hostname.lo0 or /etc/hostname6.lo0; "\
39*12016SGirish.Moodalbail@Sun.COM		    "using ifconfig to create lo0" > /dev/msglog
40*12016SGirish.Moodalbail@Sun.COM	# IPv4 loopback
41*12016SGirish.Moodalbail@Sun.COM	/sbin/ifconfig lo0 plumb 127.0.0.1 up
42*12016SGirish.Moodalbail@Sun.COM
43*12016SGirish.Moodalbail@Sun.COM	# IPv6 loopback
44*12016SGirish.Moodalbail@Sun.COM	/sbin/ifconfig lo0 inet6 plumb ::1 up
450Sstevel@tonic-gate
46*12016SGirish.Moodalbail@Sun.COM	# Trusted Extensions shares the loopback interface with all zones
47*12016SGirish.Moodalbail@Sun.COM	if (smf_is_system_labeled); then
48*12016SGirish.Moodalbail@Sun.COM		if smf_is_globalzone; then
49*12016SGirish.Moodalbail@Sun.COM			/sbin/ifconfig lo0 all-zones
50*12016SGirish.Moodalbail@Sun.COM			/sbin/ifconfig lo0 inet6 all-zones
51*12016SGirish.Moodalbail@Sun.COM		fi
52*12016SGirish.Moodalbail@Sun.COM	fi
53*12016SGirish.Moodalbail@Sun.COMelse
54*12016SGirish.Moodalbail@Sun.COM	state=`/sbin/ipadm show-if -p -o state lo0 2>/dev/null`
55*12016SGirish.Moodalbail@Sun.COM	if [ $? -eq 0 -a "$state" = "disabled" ]; then
56*12016SGirish.Moodalbail@Sun.COM		/sbin/ipadm enable-if -t lo0
57*12016SGirish.Moodalbail@Sun.COM	else
58*12016SGirish.Moodalbail@Sun.COM		# IPv4 loopback
59*12016SGirish.Moodalbail@Sun.COM		/sbin/ipadm create-addr -t -T static -a 127.0.0.1/8 lo0/v4
605863Sgfaden
61*12016SGirish.Moodalbail@Sun.COM		# IPv6 loopback
62*12016SGirish.Moodalbail@Sun.COM		/sbin/ipadm create-addr -t -T static -a ::1/128 lo0/v6
63*12016SGirish.Moodalbail@Sun.COM	fi
64*12016SGirish.Moodalbail@Sun.COM
65*12016SGirish.Moodalbail@Sun.COM	# Trusted Extensions shares the loopback interface with all zones
66*12016SGirish.Moodalbail@Sun.COM	if (smf_is_system_labeled); then
67*12016SGirish.Moodalbail@Sun.COM		if smf_is_globalzone; then
68*12016SGirish.Moodalbail@Sun.COM			/sbin/ipadm set-addrprop -t -p zone=all-zones lo0/v4
69*12016SGirish.Moodalbail@Sun.COM			/sbin/ipadm set-addrprop -t -p zone=all-zones lo0/v6
70*12016SGirish.Moodalbail@Sun.COM		fi
715863Sgfaden	fi
725863Sgfadenfi
73*12016SGirish.Moodalbail@Sun.COM
74