changeset 4121:20cddb15a804

6545585 t_optmgmt System error message appears when rebooting after installation/upgrade 6548363 incorrect formatting of AF_LINK interface name in nwamd
author amaguire
date Fri, 27 Apr 2007 02:36:22 -0700
parents 5fe68351911e
children ff19cef282d8
files usr/src/cmd/cmd-inet/lib/nwamd/events.c usr/src/cmd/cmd-inet/lib/nwamd/interface.c usr/src/cmd/svc/milestone/net-routing-setup usr/src/cmd/svc/milestone/net-svc usr/src/cmd/svc/shell/net_include.sh
diffstat 5 files changed, 114 insertions(+), 60 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/cmd-inet/lib/nwamd/events.c	Fri Apr 27 02:07:51 2007 -0700
+++ b/usr/src/cmd/cmd-inet/lib/nwamd/events.c	Fri Apr 27 02:36:22 2007 -0700
@@ -353,6 +353,11 @@
 			if ((addr_dl = (struct sockaddr_dl *)getaddr
 			    (RTA_IFP, ifa->ifam_addrs, addrs)) == NULL)
 				break;
+			/*
+			 * We don't use the lladdr in this structure so we can
+			 * run over it.
+			 */
+			addr_dl->sdl_data[addr_dl->sdl_nlen] = 0;
 			if_name = addr_dl->sdl_data;
 			ifp = get_interface(if_name);
 			if (ifp == NULL) {
@@ -386,6 +391,11 @@
 			if ((addr_dl = (struct sockaddr_dl *)getaddr(RTA_IFP,
 			    ifm->ifm_addrs, addrs)) == NULL)
 				break;
+			/*
+			 * We don't use the lladdr in this structure so we can
+			 * run over it.
+			 */
+			addr_dl->sdl_data[addr_dl->sdl_nlen] = 0;
 			if_name = addr_dl->sdl_data;
 			ifp = get_interface(if_name);
 			if (ifp == NULL) {
@@ -545,8 +555,8 @@
 			*address = (char *)*address + sizeof (*s6);
 			break;
 		case AF_LINK:
-			(void) snprintf(buffer, sizeof (buffer), "link %s",
-			    dl->sdl_data);
+			(void) snprintf(buffer, sizeof (buffer), "link %.*s",
+			    dl->sdl_nlen, dl->sdl_data);
 			*address = (char *)*address + sizeof (*dl);
 			break;
 		default:
--- a/usr/src/cmd/cmd-inet/lib/nwamd/interface.c	Fri Apr 27 02:07:51 2007 -0700
+++ b/usr/src/cmd/cmd-inet/lib/nwamd/interface.c	Fri Apr 27 02:36:22 2007 -0700
@@ -429,25 +429,26 @@
 	size_t buflen;
 	size_t offset;
 	const char bringup[] = "/bringup";
-
-	if (do_dhcp) {
-		boolean_t should;
-		int res;
+	boolean_t should;
+	int res;
 
-		res = lookup_boolean_property(OUR_PG, "use_net_svc", &should);
-		/*
-		 * If the look-up failed, try anyway: only avoid this if we
-		 * know for sure not to.
-		 */
-		if ((res == 0 && should) || (res == -1)) {
-			if (check_svc_up(NET_SVC_FMRI, 5)) {
-				(void) start_child(NET_SVC_METHOD, "start",
-				    ifname, NULL);
-			} else {
-				syslog(LOG_WARNING, "timed out when waiting "
-				    "for %s to come up, start method %s not "
-				    "executed", NET_SVC_FMRI, NET_SVC_METHOD);
-			}
+	res = lookup_boolean_property(OUR_PG, "use_net_svc", &should);
+	/*
+	 * If the look-up failed, try anyway: only avoid this if we
+	 * know for sure not to.
+	 */
+	if ((res == 0 && should) || (res == -1)) {
+		if (check_svc_up(NET_SVC_FMRI, 5)) {
+			/*
+			 * If doing dhcp, pass in specific interface
+			 * name to net-svc so dhcpinfo can specify it.
+			 */
+			(void) start_child(NET_SVC_METHOD, "start",
+			    do_dhcp ? ifname : NULL, NULL);
+		} else {
+			syslog(LOG_WARNING, "timed out when waiting "
+			    "for %s to come up, start method %s not "
+			    "executed", NET_SVC_FMRI, NET_SVC_METHOD);
 		}
 	}
 	f = popen(ULP_DIR "/check-conditions", "r");
--- a/usr/src/cmd/svc/milestone/net-routing-setup	Fri Apr 27 02:07:51 2007 -0700
+++ b/usr/src/cmd/svc/milestone/net-routing-setup	Fri Apr 27 02:36:22 2007 -0700
@@ -28,6 +28,7 @@
 # This script configures IP routing.
 
 . /lib/svc/share/smf_include.sh
+. /lib/svc/share/net_include.sh
 
 #
 # In a shared-IP zone we need this service to be up, but all of the work
@@ -61,28 +62,10 @@
 	dynamic_routing="true"
 fi
 
-/usr/sbin/ifconfig -a6u >/etc/svc/volatile/ifconfig.$$
-numv6ifs=`/usr/bin/grep -c inet6 /etc/svc/volatile/ifconfig.$$`
-
-if  [ $numv6ifs -gt 1 ]; then
-	#
-	# Add a static route for multicast packets out of a link-local
-	# interface, although would like to specify multicast interface using
-	# an interface name!
-	#
-	set -- `/usr/bin/awk '
-		/inet6 fe80:/ {
-			print substr($2, 1, index($2, "/") - 1)
-		}' /etc/svc/volatile/ifconfig.$$`
-
-	if [ -n "$1" ]; then
-		echo "Setting default IPv6 interface for multicast:" \
-			"add net ff00::/8: gateway $1"
-		/usr/sbin/route -n add -interface -inet6 "ff00::/8" "$1" \
-			>/dev/null
-	fi
-fi
-/usr/bin/rm -f /etc/svc/volatile/ifconfig.$$
+#
+# Add a static route for IPv6 multicast packets.
+#
+update_v6_multicast_route
 
 #
 # Configure default IPv4 routers using the local "/etc/defaultrouter"
--- a/usr/src/cmd/svc/milestone/net-svc	Fri Apr 27 02:07:51 2007 -0700
+++ b/usr/src/cmd/svc/milestone/net-svc	Fri Apr 27 02:36:22 2007 -0700
@@ -32,6 +32,7 @@
 #
 
 . /lib/svc/share/smf_include.sh
+. /lib/svc/share/net_include.sh
 
 case "$1" in
 'start')
@@ -237,20 +238,6 @@
 	mv_file /tmp/hosts.$$ /etc/inet/hosts 444
 fi
 
-if [ -z "$SMF_FMRI" ] || [ "$SMF_FMRI" = "svc:/network/physical:nwam" ]; then
-	exit 0
-fi
-
-#
-# Load the IPQoS configuration.
-# This is backgrounded so that any remote hostname lookups it performs
-# don't unduely delay startup. Any messages go via syslog.
-#
-
-if [ -f /usr/sbin/ipqosconf -a -f /etc/inet/ipqosinit.conf ]; then
-	/usr/sbin/ipqosconf -s -a /etc/inet/ipqosinit.conf &
-fi
-
 #
 # Add a static route for multicast packets out our default interface.
 # The default interface is the interface that corresponds to the node name.
@@ -269,3 +256,23 @@
 
 /usr/sbin/route -n add -interface 224.0/4 -gateway "$mcastif" >/dev/null
 ) &
+
+#
+# NWAM-triggered interface changes may necessitate updating IPv6 multicast
+# route.
+#
+update_v6_multicast_route
+
+if [ -z "$SMF_FMRI" ] || [ "$SMF_FMRI" = "svc:/network/physical:nwam" ]; then
+        exit 0
+fi
+
+#
+# Load the IPQoS configuration.
+# This is backgrounded so that any remote hostname lookups it performs
+# don't unduely delay startup. Any messages go via syslog.
+#
+
+if [ -f /usr/sbin/ipqosconf -a -f /etc/inet/ipqosinit.conf ]; then
+        /usr/sbin/ipqosconf -s -a /etc/inet/ipqosinit.conf &
+fi
--- a/usr/src/cmd/svc/shell/net_include.sh	Fri Apr 27 02:07:51 2007 -0700
+++ b/usr/src/cmd/svc/shell/net_include.sh	Fri Apr 27 02:36:22 2007 -0700
@@ -3,9 +3,8 @@
 # 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.
+# Common Development and Distribution License (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
 # or http://www.opensolaris.org/os/licensing.
@@ -21,7 +20,7 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 #ident	"%Z%%M%	%I%	%E% SMI"
@@ -581,3 +580,57 @@
 	done
 	echo "."
 }
+
+#
+# Add IPv6 multicast route, either for link-local interface (if present)
+# or loopback interface.
+#
+update_v6_multicast_route()
+{
+	#
+	# If we have a persistent multicast route installed, do nothing.
+	#
+	if `/usr/sbin/route -p show | /usr/bin/grep ff00::/8 > /dev/null 2>&1`
+	then
+		return
+	fi
+	#
+	# If we had a previous non-persistent v6 multicast route for link-local
+	# or loopback address, then remove it.
+	#
+	mcast_gateways=`/usr/bin/netstat -f inet6 -rn | /usr/bin/awk \
+	    '/ff00::\/8[ \t]+(::1|fe80:)/ { print $2 }'`
+	for gateway in $mcast_gateways
+	do
+		/usr/sbin/route -n delete -interface -inet6 \
+		    ff00::/8 $gateway > /dev/null
+	done
+
+	ifconfig_out="/etc/svc/volatile/ifconfig.$$"
+
+        /usr/sbin/ifconfig -a6u > $ifconfig_out
+        numv6ifs=`/usr/bin/grep -c inet6 $ifconfig_out`
+
+	if  [ $numv6ifs -gt 1 ]; then
+		#
+		# Add a static route for multicast packets out of a link-local
+		# interface, although would like to specify multicast interface
+		# using an interface name!
+		#
+		link_local=`/usr/bin/awk '/inet6 fe80:/ \
+		    { print substr($2, 1, index($2, "/") - 1) }' $ifconfig_out`
+		if [ -n "$link_local" ]; then
+			echo "Setting default IPv6 interface for multicast:" \
+			    "add net ff00::/8: gateway $link_local"
+			for link in $link_local
+			do
+				/usr/sbin/route -n add -interface -inet6 \
+				    ff00::/8 $link > /dev/null
+			done
+		fi
+	elif [ $numv6ifs -eq 1 ]; then
+		/usr/sbin/route -n add -interface -inet6 "ff00::/8" ::1 \
+		    > /dev/null
+	fi
+	/usr/bin/rm -f $ifconfig_out
+}