net-physical revision 7c478bd95313f5f23a4c958a745db2134aa03244
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
# All rights reserved.
#
#
# ident "%Z%%M% %I% %E% SMI"
#
# In a zone we need this service to be up, but all of the work
# it tries to do is irrelevant (and will actually lead to the service
# failing if we try to do it), so just bail out.
#
exit 0
fi
# Print warnings to console
}
# Make sure that the libraries essential to this stage of booting can be found.
#
# Cause ifconfig to not automatically start in.mpathd when IPMP groups are
# configured. This is not strictly necessary but makes it so that in.mpathd
# sure that /usr is mounted.
#
SUNW_NO_MPATHD=; export SUNW_NO_MPATHD
#
# If the system was net booted by DHCP, hand DHCP management off to the
# DHCP agent (ifconfig communicates to the DHCP agent through the
# loopback interface).
#
fi
#
# The network initialization is done early to support diskless and
# dataless configurations. For IPv4 interfaces that were configured by
# the kernel (e.g. those on diskless machines) and not configured by
# exists, and then reset the broadcast address based on the netmask.
#
#
# All the IPv4 and IPv6 interfaces are plumbed before doing any
# interface configuration. This prevents errors from plumb failures
# getting mixed in with the configured interface lists that the script
# outputs.
#
#
# Get the list of IPv4 interfaces to configure by breaking
# character.
#
if [ "$interface_names" != "/etc/hostname.*[0-9]" ]; then
set -- $interface_names
while [ $# -ge 2 ]; do
shift
if [ "$1" = "xx0" ]; then
#
# For some unknown historical reason the xx0
# ifname is ignored.
#
shift
continue
fi
shift
done
else
inet_list="$inet_list $1"
shift
fi
done
fi
#
# Get the list of IPv6 interfaces to configure by breaking
# character.
#
if [ "$interface_names" != "/etc/hostname6.*[0-9]" ]; then
set -- $interface_names
while [ $# -ge 2 ]; do
shift
shift
done
else
inet6_list="$inet6_list $1"
shift
fi
done
fi
#
# Step through the IPv4 interface list and try to plumb every interface.
# Generate list of plumbed and failed IPv4 interfaces.
#
if [ -n "$inet_list" ]; then
set -- $inet_list
while [ $# -gt 0 ]; do
else
inet_failed="$inet_failed $1"
fi
shift
done
fi
#
# Step through the IPv6 interface list and plumb every interface.
# Generate list of plumbed and failed IPv6 interfaces. Each plumbed
# interface will be brought up later, after processing any contents of
#
if [ -n "$inet6_list" ]; then
set -- $inet6_list
while [ $# -gt 0 ]; do
else
fi
shift
done
fi
#
# / auto-revarp command will attempt to set the address, later.
#
# If /etc/hostname.lo0 exists the loop below will do additional
# configuration of lo0.
#
if [ -n "$inet_plumbed" ]; then
echo "configuring IPv4 interfaces:\c"
set -- $inet_plumbed
while [ $# -gt 0 ]; do
echo " $1\c"
shift
done
echo "."
fi
#
# processing the hostname6 file, bring the interface up. If
# /etc/hostname6.lo0 exists the loop below will do additional
# configuration of lo0.
#
if [ -n "$inet6_plumbed" ]; then
echo "configuring IPv6 interfaces:\c"
set -- $inet6_plumbed
while [ $# -gt 0 ]; do
echo " $1\c"
shift
done
echo "."
fi
# Run DHCP if requested. Skip boot-configured interface.
if [ "$interface_names" != '/etc/dhcp.*[0-9]' ]; then
#
# First find the primary interface. Default to the first
# interface if not specified. First primary interface found
# "wins". Use care not to "reconfigure" a net-booted interface
# configured using DHCP. Run through the list of interfaces
# again, this time trying DHCP.
#
IFS="${IFS}."
set -- $interface_names
while [ $# -ge 2 ]; do
shift
if [ "$i" = primary ]; then
primary=$1
break
fi
done
[ -n "$primary" ] && break
shift
done
if [ "$_INIT_NET_IF" != "$primary" ]; then
echo "starting DHCP on primary interface $primary"
# Exit code 4 means ifconfig timed out waiting for dhcpagent
fi
set -- $interface_names
while [ $# -ge 2 ]; do
shift
if [ "$1" != "$primary" -a \
"$1" != "$_INIT_NET_IF" ]; then
echo "starting DHCP on interface $1"
# Exit code can't be timeout when wait is 0
fi
shift
done
unset ORIGIFS
fi
# Configure the rest of the IPv4 interfaces automatically, quietly.
#
# Process IPv4 and IPv6 interfaces that failed to plumb. Find an
# alternative interface to host the addresses.
#
#
# If the /etc/defaultrouter file exists, process it now so that the next
# stage of booting will have access to NFS.
#
if [ -f /etc/defaultrouter ]; then
'#'* | '') ;; # Ignore comments, empty lines
esac
done </etc/defaultrouter
fi
#
# We tell smf this service is online if any of the following is true:
# - no interfaces were configured for plumbing and no DHCP failures
# - any non-loopback IPv4 interfaces are up and have a non-zero address
# - there are any DHCP interfaces started
# - any non-loopback IPv6 interfaces are up
#
# If we weren't asked to configure any interfaces, exit
if [ -z "$inet_list" ] && [ -z "$inet6_list" ]; then
# Config error if DHCP was attempted without plumbed interfaces
[ -n "$i4d_fail" ] && exit $SMF_EXIT_ERR_CONFIG
exit $SMF_EXIT_OK
fi
# Any non-loopback IPv4 interfaces with usable addresses up?
done && exit $SMF_EXIT_OK
fi
# Any DHCP interfaces started?
# Any non-loopback IPv6 interfaces up?
done && exit $SMF_EXIT_OK
fi
# This service was supposed to configure something yet didn't. Exit
# with config error.
exit $SMF_EXIT_ERR_CONFIG