1*9b5bf10aSMark Haywood#!/sbin/sh
2*9b5bf10aSMark Haywood#
3*9b5bf10aSMark Haywood# CDDL HEADER START
4*9b5bf10aSMark Haywood#
5*9b5bf10aSMark Haywood# The contents of this file are subject to the terms of the
6*9b5bf10aSMark Haywood# Common Development and Distribution License (the "License").
7*9b5bf10aSMark Haywood# You may not use this file except in compliance with the License.
8*9b5bf10aSMark Haywood#
9*9b5bf10aSMark Haywood# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*9b5bf10aSMark Haywood# or http://www.opensolaris.org/os/licensing.
11*9b5bf10aSMark Haywood# See the License for the specific language governing permissions
12*9b5bf10aSMark Haywood# and limitations under the License.
13*9b5bf10aSMark Haywood#
14*9b5bf10aSMark Haywood# When distributing Covered Code, include this CDDL HEADER in each
15*9b5bf10aSMark Haywood# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*9b5bf10aSMark Haywood# If applicable, add the following below this CDDL HEADER, with the
17*9b5bf10aSMark Haywood# fields enclosed by brackets "[]" replaced with your own identifying
18*9b5bf10aSMark Haywood# information: Portions Copyright [yyyy] [name of copyright owner]
19*9b5bf10aSMark Haywood#
20*9b5bf10aSMark Haywood# CDDL HEADER END
21*9b5bf10aSMark Haywood#
22*9b5bf10aSMark Haywood#
23*9b5bf10aSMark Haywood# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24*9b5bf10aSMark Haywood#
25*9b5bf10aSMark Haywood
26*9b5bf10aSMark Haywood. /lib/svc/share/smf_include.sh
27*9b5bf10aSMark Haywood. /lib/svc/share/net_include.sh
28*9b5bf10aSMark Haywood
29*9b5bf10aSMark HaywoodIPADM=/sbin/ipadm
30*9b5bf10aSMark HaywoodSVCCFG=/usr/sbin/svccfg
31*9b5bf10aSMark HaywoodSVCPROP=/usr/bin/svcprop
32*9b5bf10aSMark HaywoodSVCADM=/usr/sbin/svcadm
33*9b5bf10aSMark HaywoodROUTE=/sbin/route
34*9b5bf10aSMark Haywood
35*9b5bf10aSMark HaywoodNET_NWAM_FMRI="svc:/network/physical:nwam"
36*9b5bf10aSMark HaywoodNET_INSTALL_FMRI=$SMF_FMRI
37*9b5bf10aSMark Haywood
38*9b5bf10aSMark HaywoodNET_V4IF=install_ipv4_interface
39*9b5bf10aSMark HaywoodNET_V6IF=install_ipv6_interface
40*9b5bf10aSMark Haywood
41*9b5bf10aSMark HaywoodNET_UNDEFINED_STRING_PROP="\"\""
42*9b5bf10aSMark Haywood
43*9b5bf10aSMark Haywoodnet_install_debug=0
44*9b5bf10aSMark Haywood
45*9b5bf10aSMark Haywoodunset net_install_name net_install_addrtype net_install_addr \
46*9b5bf10aSMark Haywood    net_install_dhcpwait net_install_interface_id \
47*9b5bf10aSMark Haywood    net_install_stateless net_install_stateful net_install_route
48*9b5bf10aSMark Haywood
49*9b5bf10aSMark Haywoodnet_configure_install_if()
50*9b5bf10aSMark Haywood{
51*9b5bf10aSMark Haywood	ipv6_interface=$1
52*9b5bf10aSMark Haywood
53*9b5bf10aSMark Haywood	case $net_install_addrtype in
54*9b5bf10aSMark Haywood	static)
55*9b5bf10aSMark Haywood		cmd="$IPADM create-addr -T static "
56*9b5bf10aSMark Haywood		cmd=$cmd"-a local=$net_install_addr $net_install_name"
57*9b5bf10aSMark Haywood		;;
58*9b5bf10aSMark Haywood
59*9b5bf10aSMark Haywood	dhcp)
60*9b5bf10aSMark Haywood		dhcpwait=""
61*9b5bf10aSMark Haywood		if [ "$net_install_dhcpwait" != "" ]; then
62*9b5bf10aSMark Haywood			dhcpwait="-w $net_install_dhcpwait"
63*9b5bf10aSMark Haywood		fi
64*9b5bf10aSMark Haywood
65*9b5bf10aSMark Haywood		cmd="$IPADM create-addr -T dhcp $dhcpwait $net_install_name"
66*9b5bf10aSMark Haywood		;;
67*9b5bf10aSMark Haywood	addrconf)
68*9b5bf10aSMark Haywood		interface_id=""
69*9b5bf10aSMark Haywood		if [ "$net_install_interface_id" != "" ]; then
70*9b5bf10aSMark Haywood			interface_id="-i $net_install_interface_id"
71*9b5bf10aSMark Haywood		fi
72*9b5bf10aSMark Haywood
73*9b5bf10aSMark Haywood		state=""
74*9b5bf10aSMark Haywood		if [ "$net_install_stateless" != "" ]; then
75*9b5bf10aSMark Haywood			state="-p stateless=$net_install_stateless"
76*9b5bf10aSMark Haywood		fi
77*9b5bf10aSMark Haywood
78*9b5bf10aSMark Haywood		if [ "$net_install_stateful" != "" ]; then
79*9b5bf10aSMark Haywood			if [ "$state" = "" ]; then
80*9b5bf10aSMark Haywood				state="-p stateful=$net_install_stateful"
81*9b5bf10aSMark Haywood			else
82*9b5bf10aSMark Haywood				state=$state",stateful=$net_install_stateful"
83*9b5bf10aSMark Haywood			fi
84*9b5bf10aSMark Haywood		fi
85*9b5bf10aSMark Haywood
86*9b5bf10aSMark Haywood		cmd="$IPADM create-addr -T addrconf "
87*9b5bf10aSMark Haywood		cmd=$cmd"$interface_id $state $net_install_name"
88*9b5bf10aSMark Haywood		;;
89*9b5bf10aSMark Haywood	esac
90*9b5bf10aSMark Haywood
91*9b5bf10aSMark Haywood	$cmd
92*9b5bf10aSMark Haywood	if [ $? -ne 0 ]; then
93*9b5bf10aSMark Haywood		net_record_err "Error configuring interface:\n\"$cmd\"" $?
94*9b5bf10aSMark Haywood		return $SMF_EXIT_ERR_FATAL
95*9b5bf10aSMark Haywood	fi
96*9b5bf10aSMark Haywood
97*9b5bf10aSMark Haywood	if [ "$net_install_route" != "" ]; then
98*9b5bf10aSMark Haywood		if [ $ipv6_interface == 1 ]; then
99*9b5bf10aSMark Haywood			details="-inet6 default"
100*9b5bf10aSMark Haywood		else
101*9b5bf10aSMark Haywood			details="default"
102*9b5bf10aSMark Haywood		fi
103*9b5bf10aSMark Haywood		ifp=`echo $net_install_name | /usr/bin/cut -f1 -d'/'`
104*9b5bf10aSMark Haywood		details="$details $net_install_route -ifp $ifp"
105*9b5bf10aSMark Haywood		cmd="$ROUTE add $details"
106*9b5bf10aSMark Haywood		$cmd
107*9b5bf10aSMark Haywood		cmd="$ROUTE get $details"
108*9b5bf10aSMark Haywood		$cmd
109*9b5bf10aSMark Haywood		if [ $? -ne 0 ]; then
110*9b5bf10aSMark Haywood			err=$?
111*9b5bf10aSMark Haywood			msg="Error creating default route:\n\"$cmd\""
112*9b5bf10aSMark Haywood			net_record_err "$msg" $err
113*9b5bf10aSMark Haywood			return $SMF_EXIT_ERR_FATAL
114*9b5bf10aSMark Haywood		fi
115*9b5bf10aSMark Haywood		rootdir=/etc/svc/volatile
116*9b5bf10aSMark Haywood		/usr/bin/mkdir -p $rootdir/etc/inet
117*9b5bf10aSMark Haywood		if [ $? -ne 0 ]; then
118*9b5bf10aSMark Haywood			err=$?
119*9b5bf10aSMark Haywood			msg="Error creating \"$rootdir/etc/inet\" directory"
120*9b5bf10aSMark Haywood			net_record_err "$msg" $err
121*9b5bf10aSMark Haywood			return $SMF_EXIT_ERR_FATAL
122*9b5bf10aSMark Haywood		fi
123*9b5bf10aSMark Haywood		cmd="$ROUTE -R $rootdir -p add $details"
124*9b5bf10aSMark Haywood		$cmd
125*9b5bf10aSMark Haywood		if [ $? -ne 0 ]; then
126*9b5bf10aSMark Haywood			err=$?
127*9b5bf10aSMark Haywood			msg="Error adding persistent default route:\n\"$cmd\""
128*9b5bf10aSMark Haywood			net_record_err "$msg" $err
129*9b5bf10aSMark Haywood			return $SMF_EXIT_ERR_FATAL
130*9b5bf10aSMark Haywood		fi
131*9b5bf10aSMark Haywood	fi
132*9b5bf10aSMark Haywood
133*9b5bf10aSMark Haywood	return $SMF_EXIT_OK
134*9b5bf10aSMark Haywood}
135*9b5bf10aSMark Haywood
136*9b5bf10aSMark Haywoodnet_process_v4_pg()
137*9b5bf10aSMark Haywood{
138*9b5bf10aSMark Haywood	net_install_name=""
139*9b5bf10aSMark Haywood	net_install_addrtype=""
140*9b5bf10aSMark Haywood	net_install_addr=""
141*9b5bf10aSMark Haywood	net_install_dhcpwait=""
142*9b5bf10aSMark Haywood	net_install_route=""
143*9b5bf10aSMark Haywood
144*9b5bf10aSMark Haywood	#
145*9b5bf10aSMark Haywood	# Retrieve the mandatory interface name property value. If
146*9b5bf10aSMark Haywood	# the value is empty, then no interface is configured.
147*9b5bf10aSMark Haywood	#
148*9b5bf10aSMark Haywood	prop=`$SVCPROP -p $NET_V4IF/name $NET_INSTALL_FMRI`
149*9b5bf10aSMark Haywood	if [ $? -ne 0 -o "$prop" = "$NET_UNDEFINED_STRING_PROP" ]; then
150*9b5bf10aSMark Haywood		return $SMF_EXIT_OK
151*9b5bf10aSMark Haywood	fi
152*9b5bf10aSMark Haywood	net_install_name=$prop
153*9b5bf10aSMark Haywood
154*9b5bf10aSMark Haywood	#
155*9b5bf10aSMark Haywood	# Retrieve the mandatory address type property value. The two
156*9b5bf10aSMark Haywood	# valid values are "static" and "dhcp".
157*9b5bf10aSMark Haywood	#
158*9b5bf10aSMark Haywood	prop=`$SVCPROP -p $NET_V4IF/address_type $NET_INSTALL_FMRI`
159*9b5bf10aSMark Haywood	if [ $? -ne 0 -o "$prop" = "$NET_UNDEFINED_STRING_PROP" ]; then
160*9b5bf10aSMark Haywood		msg="No \"address_type\" property defined in the "
161*9b5bf10aSMark Haywood		msg=$msg"\"$NET_V4IF\" property group"
162*9b5bf10aSMark Haywood		net_record_err "$msg" 0
163*9b5bf10aSMark Haywood		return $SMF_EXIT_ERR_CONFIG
164*9b5bf10aSMark Haywood	fi
165*9b5bf10aSMark Haywood	case $prop in
166*9b5bf10aSMark Haywood	static | dhcp)
167*9b5bf10aSMark Haywood		net_install_addrtype=$prop
168*9b5bf10aSMark Haywood		;;
169*9b5bf10aSMark Haywood	*)
170*9b5bf10aSMark Haywood		msg="Bad value, \"$prop\", defined for the \"address_type\" "
171*9b5bf10aSMark Haywood		msg=$msg"property in the \"$NET_V4IF\" property group"
172*9b5bf10aSMark Haywood		net_record_err "$msg" 0
173*9b5bf10aSMark Haywood		return $SMF_EXIT_ERR_CONFIG
174*9b5bf10aSMark Haywood		;;
175*9b5bf10aSMark Haywood	esac
176*9b5bf10aSMark Haywood
177*9b5bf10aSMark Haywood	#
178*9b5bf10aSMark Haywood	# Retrieve the static address property value. The address property
179*9b5bf10aSMark Haywood	# only applies to static address type configurations. If not
180*9b5bf10aSMark Haywood	# configuring a static address, then the property should still have
181*9b5bf10aSMark Haywood	# its default value of 0.0.0.0/0.
182*9b5bf10aSMark Haywood	#
183*9b5bf10aSMark Haywood	prop=`$SVCPROP -p $NET_V4IF/static_address $NET_INSTALL_FMRI`
184*9b5bf10aSMark Haywood	if [ $? -eq 0 -a "$prop" != "$NET_UNDEFINED_STRING_PROP" ]; then
185*9b5bf10aSMark Haywood		if [ "$net_install_addrtype" = "dhcp" ]; then
186*9b5bf10aSMark Haywood			if [ "$prop" != "${NET_INADDR_ANY}/0" ]; then
187*9b5bf10aSMark Haywood				msg="Warning: static address ignored "
188*9b5bf10aSMark Haywood				msg=$msg"in the \"$NET_V4IF\ property group"
189*9b5bf10aSMark Haywood				net_record_err "$msg" 0
190*9b5bf10aSMark Haywood			fi
191*9b5bf10aSMark Haywood		else
192*9b5bf10aSMark Haywood			if [ "$prop" = "${NET_INADDR_ANY}/0" ]; then
193*9b5bf10aSMark Haywood				msg="Error: static address required in the "
194*9b5bf10aSMark Haywood				msg=$msg"\"$NET_V4IF\" property group"
195*9b5bf10aSMark Haywood				net_record_err "$msg" 0
196*9b5bf10aSMark Haywood				return $SMF_EXIT_ERR_CONFIG
197*9b5bf10aSMark Haywood			fi
198*9b5bf10aSMark Haywood			net_install_addr=$prop
199*9b5bf10aSMark Haywood		fi
200*9b5bf10aSMark Haywood	else
201*9b5bf10aSMark Haywood		if [ "$net_install_addrtype" = "static" ]; then
202*9b5bf10aSMark Haywood			msg="Error: static address required in the "
203*9b5bf10aSMark Haywood			msg=$msg"\"$NET_V4IF\" property group"
204*9b5bf10aSMark Haywood			net_record_err "$msg" 0
205*9b5bf10aSMark Haywood			return $SMF_EXIT_ERR_CONFIG
206*9b5bf10aSMark Haywood		fi
207*9b5bf10aSMark Haywood	fi
208*9b5bf10aSMark Haywood
209*9b5bf10aSMark Haywood	#
210*9b5bf10aSMark Haywood	# Retrieve the optional DHCP wait property value.
211*9b5bf10aSMark Haywood	#
212*9b5bf10aSMark Haywood	prop=`$SVCPROP -p $NET_V4IF/dhcp_wait $NET_INSTALL_FMRI`
213*9b5bf10aSMark Haywood	if [ $? -eq 0 -a "$prop" != "$NET_UNDEFINED_STRING_PROP" ]; then
214*9b5bf10aSMark Haywood		if [ "$net_install_addrtype" != "dhcp" ]; then
215*9b5bf10aSMark Haywood			if [ "$prop" != "120" ]; then
216*9b5bf10aSMark Haywood				msg="Warning: DHCP wait value ignored in the "
217*9b5bf10aSMark Haywood				msg=$msg"\"$NET_V4IF\" property group"
218*9b5bf10aSMark Haywood				net_record_err "$msg" 0
219*9b5bf10aSMark Haywood			fi
220*9b5bf10aSMark Haywood		else
221*9b5bf10aSMark Haywood			net_install_dhcpwait=$prop
222*9b5bf10aSMark Haywood		fi
223*9b5bf10aSMark Haywood	fi
224*9b5bf10aSMark Haywood
225*9b5bf10aSMark Haywood	#
226*9b5bf10aSMark Haywood	# Retrieve the optional default route property value.
227*9b5bf10aSMark Haywood	#
228*9b5bf10aSMark Haywood	prop=`$SVCPROP -p $NET_V4IF/default_route $NET_INSTALL_FMRI`
229*9b5bf10aSMark Haywood	if [ $? -eq 0 -a "$prop" != "$NET_UNDEFINED_STRING_PROP" ]; then
230*9b5bf10aSMark Haywood		if [ "$prop" != "$NET_INADDR_ANY" ]; then
231*9b5bf10aSMark Haywood			net_install_route=$prop
232*9b5bf10aSMark Haywood		fi
233*9b5bf10aSMark Haywood	fi
234*9b5bf10aSMark Haywood
235*9b5bf10aSMark Haywood	net_configure_install_if 0
236*9b5bf10aSMark Haywood
237*9b5bf10aSMark Haywood	return $?
238*9b5bf10aSMark Haywood}
239*9b5bf10aSMark Haywood
240*9b5bf10aSMark Haywoodnet_process_v6_pg()
241*9b5bf10aSMark Haywood{
242*9b5bf10aSMark Haywood	net_install_name=""
243*9b5bf10aSMark Haywood	net_install_addrtype=""
244*9b5bf10aSMark Haywood	net_install_addr=""
245*9b5bf10aSMark Haywood	net_install_stateless=""
246*9b5bf10aSMark Haywood	net_install_stateful=""
247*9b5bf10aSMark Haywood	net_install_interface_id=""
248*9b5bf10aSMark Haywood	net_install_route=""
249*9b5bf10aSMark Haywood
250*9b5bf10aSMark Haywood	#
251*9b5bf10aSMark Haywood	# Retrieve the mandatory interface name property value. If
252*9b5bf10aSMark Haywood	# the value is empty, then no interface is configured.
253*9b5bf10aSMark Haywood	#
254*9b5bf10aSMark Haywood	prop=`$SVCPROP -p $NET_V6IF/name $NET_INSTALL_FMRI`
255*9b5bf10aSMark Haywood	if [ $? -ne 0 -o "$prop" = "$NET_UNDEFINED_STRING_PROP" ]; then
256*9b5bf10aSMark Haywood		return $SMF_EXIT_OK
257*9b5bf10aSMark Haywood	fi
258*9b5bf10aSMark Haywood	net_install_name=$prop
259*9b5bf10aSMark Haywood
260*9b5bf10aSMark Haywood	#
261*9b5bf10aSMark Haywood	# Retrieve the mandatory address type property value. The two
262*9b5bf10aSMark Haywood	# valid values are "static" and "addrconf".
263*9b5bf10aSMark Haywood	#
264*9b5bf10aSMark Haywood	prop=`$SVCPROP -p $NET_V6IF/address_type $NET_INSTALL_FMRI`
265*9b5bf10aSMark Haywood	if [ $? -ne 0 -o "$prop" = "$NET_UNDEFINED_STRING_PROP" ]; then
266*9b5bf10aSMark Haywood		msg="No \"address_type\" property defined in the "
267*9b5bf10aSMark Haywood		msg=$msg"\"$NET_V6IF\" property group"
268*9b5bf10aSMark Haywood		net_record_err "$msg" 0
269*9b5bf10aSMark Haywood		return $SMF_EXIT_ERR_CONFIG
270*9b5bf10aSMark Haywood	fi
271*9b5bf10aSMark Haywood	case $prop in
272*9b5bf10aSMark Haywood	static | addrconf)
273*9b5bf10aSMark Haywood		net_install_addrtype=$prop
274*9b5bf10aSMark Haywood		;;
275*9b5bf10aSMark Haywood	*)
276*9b5bf10aSMark Haywood		msg="Bad value \"$prop\" defined for \"address_type\""
277*9b5bf10aSMark Haywood		net_record_err "$msg" 0
278*9b5bf10aSMark Haywood		return $SMF_EXIT_ERR_CONFIG
279*9b5bf10aSMark Haywood		;;
280*9b5bf10aSMark Haywood	esac
281*9b5bf10aSMark Haywood
282*9b5bf10aSMark Haywood	#
283*9b5bf10aSMark Haywood	# Retrieve the static address property value. The address property
284*9b5bf10aSMark Haywood	# only applies to static address type configurations. If not
285*9b5bf10aSMark Haywood	# configuring a static address, then the property should still have
286*9b5bf10aSMark Haywood	# its default value of ::0/0.
287*9b5bf10aSMark Haywood	#
288*9b5bf10aSMark Haywood	prop=`$SVCPROP -p $NET_V6IF/static_address $NET_INSTALL_FMRI`
289*9b5bf10aSMark Haywood	if [ $? -eq 0 -a "$prop" != "$NET_UNDEFINED_STRING_PROP" ]; then
290*9b5bf10aSMark Haywood		if [ "$net_install_addrtype" = "addrconf" ]; then
291*9b5bf10aSMark Haywood			if [ "$prop" != "${NET_IN6ADDR_ANY_INIT}/0" ]; then
292*9b5bf10aSMark Haywood				msg="Warning: static address ignored in the "
293*9b5bf10aSMark Haywood				msg=$msg"\"$NET_V6IF\" property group"
294*9b5bf10aSMark Haywood				net_record_err "$msg" 0
295*9b5bf10aSMark Haywood			fi
296*9b5bf10aSMark Haywood		else
297*9b5bf10aSMark Haywood			if [ "$prop" = "${NET_IN6ADDR_ANY_INIT}/0" ]; then
298*9b5bf10aSMark Haywood				msg="Error: static address required in the "
299*9b5bf10aSMark Haywood				msg=$msg"\"$NET_V6IF\" property group"
300*9b5bf10aSMark Haywood				net_record_err "$msg" 0
301*9b5bf10aSMark Haywood				return $SMF_EXIT_ERR_CONFIG
302*9b5bf10aSMark Haywood			fi
303*9b5bf10aSMark Haywood			net_install_addr=$prop
304*9b5bf10aSMark Haywood		fi
305*9b5bf10aSMark Haywood	else
306*9b5bf10aSMark Haywood		if [ "$net_install_addrtype" = "static" ]; then
307*9b5bf10aSMark Haywood			msg="Error: static address required in the "
308*9b5bf10aSMark Haywood			msg=$msg"\"$NET_V6IF\" property group"
309*9b5bf10aSMark Haywood			net_record_err "$msg" 0
310*9b5bf10aSMark Haywood			return $SMF_EXIT_ERR_CONFIG
311*9b5bf10aSMark Haywood		fi
312*9b5bf10aSMark Haywood
313*9b5bf10aSMark Haywood	fi
314*9b5bf10aSMark Haywood
315*9b5bf10aSMark Haywood	#
316*9b5bf10aSMark Haywood	# Retrieve the optional interface id property value. The
317*9b5bf10aSMark Haywood	# property only applies to addrconf address type configurations.
318*9b5bf10aSMark Haywood	# If configuring a static address, then the property should still
319*9b5bf10aSMark Haywood	# have its default value of ::0/0.
320*9b5bf10aSMark Haywood	#
321*9b5bf10aSMark Haywood	prop=`$SVCPROP -p $NET_V6IF/interface_id $NET_INSTALL_FMRI`
322*9b5bf10aSMark Haywood	if [ $? -eq 0 -a "$prop" != "$NET_UNDEFINED_STRING_PROP" ]; then
323*9b5bf10aSMark Haywood		if [ "$prop" != "${NET_IN6ADDR_ANY_INIT}/0" ]; then
324*9b5bf10aSMark Haywood			if [ "$net_install_addrtype" != "addrconf" ]; then
325*9b5bf10aSMark Haywood				msg="Warning: interface id value ignored in "
326*9b5bf10aSMark Haywood				msg=$msg"the \"$NET_V6IF\" property group"
327*9b5bf10aSMark Haywood				net_record_err "$msg" 0
328*9b5bf10aSMark Haywood			else
329*9b5bf10aSMark Haywood				net_install_interface_id=$prop
330*9b5bf10aSMark Haywood			fi
331*9b5bf10aSMark Haywood		fi
332*9b5bf10aSMark Haywood	fi
333*9b5bf10aSMark Haywood
334*9b5bf10aSMark Haywood	#
335*9b5bf10aSMark Haywood	# Retrieve the optional stateless property value. The property
336*9b5bf10aSMark Haywood	# only applies to addrconf address type configurations. If
337*9b5bf10aSMark Haywood	# configuring a static address, then the property should still
338*9b5bf10aSMark Haywood	# have its default value of "yes".
339*9b5bf10aSMark Haywood	#
340*9b5bf10aSMark Haywood	prop=`$SVCPROP -p $NET_V6IF/stateless $NET_INSTALL_FMRI`
341*9b5bf10aSMark Haywood	if [ $? -eq 0 -a "$prop" != "$NET_UNDEFINED_STRING_PROP" ]; then
342*9b5bf10aSMark Haywood		case $prop in
343*9b5bf10aSMark Haywood		yes)
344*9b5bf10aSMark Haywood			net_install_stateless=$prop
345*9b5bf10aSMark Haywood			;;
346*9b5bf10aSMark Haywood		no)
347*9b5bf10aSMark Haywood			if [ "$net_install_addrtype" != "addrconf" ]; then
348*9b5bf10aSMark Haywood				msg="Warning: stateless value ignored in the "
349*9b5bf10aSMark Haywood				msg=$msg"\"$NET_V6IF\" property group"
350*9b5bf10aSMark Haywood				net_record_err "$msg" 0
351*9b5bf10aSMark Haywood			else
352*9b5bf10aSMark Haywood				net_install_stateless=$prop
353*9b5bf10aSMark Haywood			fi
354*9b5bf10aSMark Haywood			;;
355*9b5bf10aSMark Haywood		*)
356*9b5bf10aSMark Haywood			msg="Bad value \"$prop\" defined for the \"stateless\""
357*9b5bf10aSMark Haywood			msg=$msg" property in the \"$NET_V6IF\" property group"
358*9b5bf10aSMark Haywood			net_record_err "$msg" 0
359*9b5bf10aSMark Haywood			return $SMF_EXIT_ERR_CONFIG
360*9b5bf10aSMark Haywood		;;
361*9b5bf10aSMark Haywood		esac
362*9b5bf10aSMark Haywood	fi
363*9b5bf10aSMark Haywood
364*9b5bf10aSMark Haywood	#
365*9b5bf10aSMark Haywood	# Retrieve the optional stateful property value. The property
366*9b5bf10aSMark Haywood	# only applies to addrconf address type configurations. If
367*9b5bf10aSMark Haywood	# configuring a static address, then the property should still
368*9b5bf10aSMark Haywood	# have its default value of "yes".
369*9b5bf10aSMark Haywood	#
370*9b5bf10aSMark Haywood	prop=`$SVCPROP -p $NET_V6IF/stateful $NET_INSTALL_FMRI`
371*9b5bf10aSMark Haywood	if [ $? -eq 0 -a "$prop" != "$NET_UNDEFINED_STRING_PROP" ]; then
372*9b5bf10aSMark Haywood		case $prop in
373*9b5bf10aSMark Haywood		yes)
374*9b5bf10aSMark Haywood			net_install_stateful=$prop
375*9b5bf10aSMark Haywood			;;
376*9b5bf10aSMark Haywood		no)
377*9b5bf10aSMark Haywood			if [ "$net_install_addrtype" != "addrconf" ]; then
378*9b5bf10aSMark Haywood				msg="Warning: stateless value ignored in the "
379*9b5bf10aSMark Haywood				msg=$msg"\"$NET_V6IF\" property group"
380*9b5bf10aSMark Haywood				net_record_err "$msg" 0
381*9b5bf10aSMark Haywood			else
382*9b5bf10aSMark Haywood				net_install_stateful=$prop
383*9b5bf10aSMark Haywood			fi
384*9b5bf10aSMark Haywood			;;
385*9b5bf10aSMark Haywood		*)
386*9b5bf10aSMark Haywood			msg="Bad value \"$prop\" defined for the \"stateless\""
387*9b5bf10aSMark Haywood			msg=$msg" property in the \"$NET_V6IF\" property group"
388*9b5bf10aSMark Haywood			net_record_err "$msg" 0
389*9b5bf10aSMark Haywood			return $SMF_EXIT_ERR_CONFIG
390*9b5bf10aSMark Haywood		;;
391*9b5bf10aSMark Haywood		esac
392*9b5bf10aSMark Haywood	fi
393*9b5bf10aSMark Haywood
394*9b5bf10aSMark Haywood	#
395*9b5bf10aSMark Haywood	# Retrieve the optional default route property value.
396*9b5bf10aSMark Haywood	#
397*9b5bf10aSMark Haywood	prop=`$SVCPROP -p $NET_V6IF/default_route $NET_INSTALL_FMRI`
398*9b5bf10aSMark Haywood	if [ $? -eq 0 -a "$prop" != "$NET_UNDEFINED_STRING_PROP" ]; then
399*9b5bf10aSMark Haywood		if [ "$prop" != "$NET_IN6ADDR_ANY_INIT" ]; then
400*9b5bf10aSMark Haywood			net_install_route=$prop
401*9b5bf10aSMark Haywood		fi
402*9b5bf10aSMark Haywood	fi
403*9b5bf10aSMark Haywood
404*9b5bf10aSMark Haywood	net_configure_install_if 1
405*9b5bf10aSMark Haywood
406*9b5bf10aSMark Haywood	return $?
407*9b5bf10aSMark Haywood}
408*9b5bf10aSMark Haywood
409*9b5bf10aSMark Haywoodnet_process_install()
410*9b5bf10aSMark Haywood{
411*9b5bf10aSMark Haywood	vout=`$SVCCFG -s $NET_INSTALL_FMRI validate 2>&1`
412*9b5bf10aSMark Haywood	if [ "$vout" != "" ]; then
413*9b5bf10aSMark Haywood		msg="Validation errors in $NET_INSTALL_FMRI:\n$vout"
414*9b5bf10aSMark Haywood		net_record_err "$msg" 0
415*9b5bf10aSMark Haywood		return $SMF_EXIT_ERR_CONFIG
416*9b5bf10aSMark Haywood	fi
417*9b5bf10aSMark Haywood
418*9b5bf10aSMark Haywood	ecode=$SMF_EXIT_OK
419*9b5bf10aSMark Haywood	errs=0
420*9b5bf10aSMark Haywood	ifcnt=0
421*9b5bf10aSMark Haywood	for intf in $NET_V4IF $NET_V6IF
422*9b5bf10aSMark Haywood	do
423*9b5bf10aSMark Haywood		pg=`$SVCPROP -p $intf $NET_INSTALL_FMRI`
424*9b5bf10aSMark Haywood		if [ $? -eq 0 ]; then
425*9b5bf10aSMark Haywood			if service_is_enabled $NET_NWAM_FMRI; then
426*9b5bf10aSMark Haywood				msg="NWAM enabled. Install static "
427*9b5bf10aSMark Haywood				msg=$msg"configuration ignored."
428*9b5bf10aSMark Haywood				net_record_err "$msg" 0
429*9b5bf10aSMark Haywood				errs=`expr $errs + 1`
430*9b5bf10aSMark Haywood				ecode=$SMF_EXIT_ERR_CONFIG
431*9b5bf10aSMark Haywood			else
432*9b5bf10aSMark Haywood				if [ "$intf" == "$NET_V4IF" ]; then
433*9b5bf10aSMark Haywood					net_process_v4_pg
434*9b5bf10aSMark Haywood				else
435*9b5bf10aSMark Haywood					net_process_v6_pg
436*9b5bf10aSMark Haywood				fi
437*9b5bf10aSMark Haywood				if [ $? -ne $SMF_EXIT_OK ]; then
438*9b5bf10aSMark Haywood					#
439*9b5bf10aSMark Haywood				    	# Last error wins.
440*9b5bf10aSMark Haywood					#
441*9b5bf10aSMark Haywood					ecode=$?
442*9b5bf10aSMark Haywood					errs=`expr $errs + 1`
443*9b5bf10aSMark Haywood				else
444*9b5bf10aSMark Haywood					ifcnt=`expr $ifcnt + 1`
445*9b5bf10aSMark Haywood				fi
446*9b5bf10aSMark Haywood			fi
447*9b5bf10aSMark Haywood			$SVCCFG -s $NET_INSTALL_FMRI delpg $intf
448*9b5bf10aSMark Haywood			$SVCCFG -s $NET_INSTALL_FMRI refresh
449*9b5bf10aSMark Haywood		fi
450*9b5bf10aSMark Haywood	done
451*9b5bf10aSMark Haywood
452*9b5bf10aSMark Haywood 	if [ $net_install_debug -eq 1 ]; then
453*9b5bf10aSMark Haywood		if [ $errs -ne 0 ]; then
454*9b5bf10aSMark Haywood			echo "$errs errors encountered" \
455*9b5bf10aSMark Haywood			    "configuring interfaces on behalf of install"
456*9b5bf10aSMark Haywood		fi
457*9b5bf10aSMark Haywood
458*9b5bf10aSMark Haywood		if [ $ifcnt -ne 0 ]; then
459*9b5bf10aSMark Haywood			echo "$ifcnt interfaces configured on" \
460*9b5bf10aSMark Haywood			    "behalf of install"
461*9b5bf10aSMark Haywood		fi
462*9b5bf10aSMark Haywood	fi
463*9b5bf10aSMark Haywood
464*9b5bf10aSMark Haywood	return $ecode
465*9b5bf10aSMark Haywood}
466*9b5bf10aSMark Haywood
467*9b5bf10aSMark Haywood#
468*9b5bf10aSMark Haywood# The network/install service will be enabled by the install derived profile
469*9b5bf10aSMark Haywood# after the intial install. The service will disable itself after processing
470*9b5bf10aSMark Haywood# the install defined property values.
471*9b5bf10aSMark Haywood#
472*9b5bf10aSMark Haywood# When the non-global shared-IP stack zone boots, it tries to bring up this
473*9b5bf10aSMark Haywood# service as well. We just want to exit successfully.
474*9b5bf10aSMark Haywood#
475*9b5bf10aSMark Haywoodif smf_is_nonglobalzone; then
476*9b5bf10aSMark Haywood	if [ `/sbin/zonename -t` = shared ]; then
477*9b5bf10aSMark Haywood		$SVCADM disable $NET_INSTALL_FMRI
478*9b5bf10aSMark Haywood		exit $SMF_EXIT_OK
479*9b5bf10aSMark Haywood	fi
480*9b5bf10aSMark Haywoodfi
481*9b5bf10aSMark Haywood
482*9b5bf10aSMark Haywoodnet_process_install || exit $?
483*9b5bf10aSMark Haywood
484*9b5bf10aSMark Haywood$SVCADM disable $NET_INSTALL_FMRI
485*9b5bf10aSMark Haywoodexit $SMF_EXIT_OK
486