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# 236e91bba0SGirish Moodalbail# Copyright 2010 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate# Use is subject to license terms. 257c478bd9Sstevel@tonic-gate# 26*0607ca1fSAndy Fiddaman# Copyright 2024 Oxide Computer Company 27*0607ca1fSAndy Fiddaman# 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate. /lib/svc/share/smf_include.sh 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate# 32f4b3ec61Sdh155122# In a shared-IP zone we need this service to be up, but all of the work 337c478bd9Sstevel@tonic-gate# it tries to do is irrelevant (and will actually lead to the service 347c478bd9Sstevel@tonic-gate# failing if we try to do it), so just bail out. 35f4b3ec61Sdh155122# In the global zone and exclusive-IP zones we proceed. 367c478bd9Sstevel@tonic-gate# 37f4b3ec61Sdh155122smf_configure_ip || exit $SMF_EXIT_OK 387c478bd9Sstevel@tonic-gate 39*0607ca1fSAndy Fiddamanrc=$SMF_EXIT_OK 40*0607ca1fSAndy Fiddaman 41*0607ca1fSAndy Fiddamandegrade() { 42*0607ca1fSAndy Fiddaman echo "$@" >&2 43*0607ca1fSAndy Fiddaman rc=$SMF_EXIT_MON_DEGRADE 44*0607ca1fSAndy Fiddaman} 45*0607ca1fSAndy Fiddaman 466e91bba0SGirish Moodalbailif [ -f /etc/hostname.lo0 ] || [ -f /etc/hostname6.lo0 ]; then 476e91bba0SGirish Moodalbail echo "found /etc/hostname.lo0 or /etc/hostname6.lo0; "\ 486e91bba0SGirish Moodalbail "using ifconfig to create lo0" > /dev/msglog 49d71dbb73Sjbeck # IPv4 loopback 50*0607ca1fSAndy Fiddaman if ! /sbin/ifconfig lo0 >/dev/null 2>&1; then 51*0607ca1fSAndy Fiddaman /sbin/ifconfig lo0 plumb 127.0.0.1 up || \ 52*0607ca1fSAndy Fiddaman degrade "Failed to create IPv4 loopback" 53*0607ca1fSAndy Fiddaman fi 547c478bd9Sstevel@tonic-gate 55d71dbb73Sjbeck # IPv6 loopback 56*0607ca1fSAndy Fiddaman if ! /sbin/ifconfig lo0 inet6 >/dev/null 2>&1; then 57*0607ca1fSAndy Fiddaman /sbin/ifconfig lo0 inet6 plumb ::1 up || \ 58*0607ca1fSAndy Fiddaman degrade "Failed to create IPv6 loopback" 59*0607ca1fSAndy Fiddaman fi 60fdb7141fSgfaden 61fdb7141fSgfaden # Trusted Extensions shares the loopback interface with all zones 62fdb7141fSgfaden if (smf_is_system_labeled); then 63fdb7141fSgfaden if smf_is_globalzone; then 64fdb7141fSgfaden /sbin/ifconfig lo0 all-zones 65fdb7141fSgfaden /sbin/ifconfig lo0 inet6 all-zones 66fdb7141fSgfaden fi 67fdb7141fSgfaden fi 686e91bba0SGirish Moodalbailelse 696e91bba0SGirish Moodalbail state=`/sbin/ipadm show-if -p -o state lo0 2>/dev/null` 706e91bba0SGirish Moodalbail if [ $? -eq 0 -a "$state" = "disabled" ]; then 71*0607ca1fSAndy Fiddaman /sbin/ipadm enable-if -t lo0 || \ 72*0607ca1fSAndy Fiddaman degrade "Failed to enable loopback interface" 736e91bba0SGirish Moodalbail else 746e91bba0SGirish Moodalbail # IPv4 loopback 75*0607ca1fSAndy Fiddaman state=`/sbin/ipadm show-addr -po state lo0/v4` 76*0607ca1fSAndy Fiddaman if [ $? -ne 0 -o -z "$state" ]; then 77*0607ca1fSAndy Fiddaman /sbin/ipadm create-addr -t \ 78*0607ca1fSAndy Fiddaman -T static -a 127.0.0.1/8 lo0/v4 || \ 79*0607ca1fSAndy Fiddaman degrade "Failed to create IPv4 loopback" 80*0607ca1fSAndy Fiddaman fi 816e91bba0SGirish Moodalbail 826e91bba0SGirish Moodalbail # IPv6 loopback 83*0607ca1fSAndy Fiddaman state=`/sbin/ipadm show-addr -po state lo0/v6` 84*0607ca1fSAndy Fiddaman if [ $? -ne 0 -o -z "$state" ]; then 85*0607ca1fSAndy Fiddaman /sbin/ipadm create-addr -t \ 86*0607ca1fSAndy Fiddaman -T static -a ::1/128 lo0/v6 || \ 87*0607ca1fSAndy Fiddaman degrade "Failed to create IPv6 loopback" 88*0607ca1fSAndy Fiddaman fi 896e91bba0SGirish Moodalbail fi 906e91bba0SGirish Moodalbail 916e91bba0SGirish Moodalbail # Trusted Extensions shares the loopback interface with all zones 926e91bba0SGirish Moodalbail if (smf_is_system_labeled); then 936e91bba0SGirish Moodalbail if smf_is_globalzone; then 946e91bba0SGirish Moodalbail /sbin/ipadm set-addrprop -t -p zone=all-zones lo0/v4 956e91bba0SGirish Moodalbail /sbin/ipadm set-addrprop -t -p zone=all-zones lo0/v6 966e91bba0SGirish Moodalbail fi 976e91bba0SGirish Moodalbail fi 986e91bba0SGirish Moodalbailfi 996e91bba0SGirish Moodalbail 100*0607ca1fSAndy Fiddamanexit $rc 101