5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
27 # xVM PV domU IP address reporting agent. Reports IP address back to dom0.
32 xs_ipaddr_path
="guest/ipv4/0/address"
33 xs_link_path
="guest/ipv4/default-link"
37 # Look for a valid-seeming address for the given link. Return 0 on success.
41 tmp
=`netstat -I $1 -in -f inet | awk '{print $4}' | grep -v Address`;
42 if [ -z "$tmp" ] ||
[ "$tmp" = "0.0.0.0" ];
55 # Look in the store for a cached link name.
57 link
=`/usr/lib/xen/bin/xenstore-read $xs_link_path 2>/dev/null`
58 if [ -z "$link" ] ||
[ "$link" = "(none)" ]
61 # If it's not there, try to determine what it is
62 # and add it to the store.
63 determine_default_link
68 # Determine the default link name and update xenstore with the details.
70 determine_default_link
()
74 # Choose the first up, non-loopback interface with a valid-looking
77 dladm show-link
-p -o link
,state |
while IFS
=: read LINKNAME STATE
;
79 if [ "$STATE" = "up" ];
81 link_to_addr
"$LINKNAME"
82 if [ $?
-eq 0 ]; then link
=$LINKNAME; break; fi
87 /usr
/lib
/xen
/bin
/xenstore-write
$xs_link_path $link
93 # Determine the default link in use by this domU.
98 # If the link still has a valid-looking IP address, notify dom0 of its
105 # An address could not be determined for the currently cached
106 # default link so determine it again in case it has changed.
107 # We'll still sleep this iteration to rate-limit dladm calls.
109 determine_default_link
;
112 /usr
/lib
/xen
/bin
/xenstore-write
$xs_ipaddr_path $addr