changeset 12924:c9b2c6a6a9c0

6969190 nwamd needs to be more persistent in the face of dhcp failures 6939897 /etc/resolv.conf file content is missing when a profile with a static ip address is active
author Anurag S. Maskey <Anurag.Maskey@Oracle.COM>
date Mon, 26 Jul 2010 15:00:52 -0400
parents 3c964548d01f
children fd395ba5d913
files usr/src/cmd/cmd-inet/lib/nwamd/ncu_ip.c usr/src/cmd/cmd-inet/sbin/dhcpagent/inform.c
diffstat 2 files changed, 37 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/cmd-inet/lib/nwamd/ncu_ip.c	Mon Jul 26 11:11:38 2010 -0700
+++ b/usr/src/cmd/cmd-inet/lib/nwamd/ncu_ip.c	Mon Jul 26 15:00:52 2010 -0400
@@ -1346,63 +1346,64 @@
 		}
 		ipstatus = ipadm_refresh_addr(ipadm_handle, aobjname,
 		    IPADM_OPT_ACTIVE | IPADM_OPT_INFORM);
-
 		break;
 	}
 	case DHCP_START:
-	{
 		ipstatus = ipadm_create_addr(ipadm_handle, ipaddr,
 		    IPADM_OPT_ACTIVE);
+		break;
+	default:
+		nlog(LOG_ERR, "start_dhcp: invalid dhcp_ipc_type_t: %d", type);
+		goto done;
+	}
 
-		if (ipstatus == IPADM_DHCP_IPC_TIMEOUT) {
-			/*
-			 * DHCP timed out: change state for this NCU and enqueue
-			 * event to check NCU priority-groups.  Only care for
-			 * DHCP requests (not informs).
-			 */
+	if (ipstatus == IPADM_DHCP_IPC_TIMEOUT) {
+		/*
+		 * DHCP timed out: for DHCP_START requests, change state for
+		 * this NCU and euqueue event to check NCU priority-groups;
+		 * for DHCP_INFORM requests, nothing to do.
+		 */
+		if (type == DHCP_START) {
 			char *object_name;
 
-			nlog(LOG_INFO, "start_dhcp: DHCP timed out for %s",
-			    name);
+			nlog(LOG_INFO,
+			    "start_dhcp: DHCP_START timed out for %s", name);
 
 			if (nwam_ncu_name_to_typed_name(name,
 			    NWAM_NCU_TYPE_INTERFACE, &object_name)
 			    != NWAM_SUCCESS) {
 				nlog(LOG_ERR, "start_dhcp: "
-				    "nwam_ncu_name_to_typed_name failed "
-				    "for %s", name);
+				    "nwam_ncu_name_to_typed_name failed for %s",
+				    name);
 				goto done;
 			}
 			nwamd_object_set_state(NWAM_OBJECT_TYPE_NCU,
 			    object_name, NWAM_STATE_OFFLINE_TO_ONLINE,
 			    NWAM_AUX_STATE_IF_DHCP_TIMED_OUT);
 			nwamd_create_ncu_check_event(0);
-
 			free(object_name);
-			goto done;
+		} else {
+			nlog(LOG_INFO,
+			    "start_dhcp: DHCP_INFORM timed out for %s", name);
+		}
 
-		} else if (ipstatus == IPADM_DHCP_IPC_ERROR &&
-		    retries++ < NWAMD_DHCP_RETRIES) {
-			/*
-			 * Retry DHCP request as we may have been unplumbing
-			 * as part of the configuration phase.
-			 */
-			nlog(LOG_ERR, "start_dhcp: will retry on %s in %d sec",
-			    name, NWAMD_DHCP_RETRY_WAIT_TIME);
-			(void) sleep(NWAMD_DHCP_RETRY_WAIT_TIME);
-			goto retry;
-		}
-		break;
-	}
-	default:
-		nlog(LOG_ERR, "start_dhcp: invalid dhcp_ipc_type_t: %d", type);
-		goto done;
-	}
+	} else if ((ipstatus == IPADM_DHCP_IPC_ERROR ||
+	    ipstatus == IPADM_IPC_ERROR) && retries++ < NWAMD_DHCP_RETRIES) {
+		/*
+		 * Retry DHCP request as we may have been unplumbing as part
+		 * of the configuration phase.
+		 */
+		nlog(LOG_ERR, "start_dhcp: ipadm_%s_addr on %s returned: %s, "
+		    "retrying in %d sec",
+		    (type == DHCP_START ? "create" : "refresh"), name,
+		    ipadm_status2str(ipstatus), NWAMD_DHCP_RETRY_WAIT_TIME);
+		(void) sleep(NWAMD_DHCP_RETRY_WAIT_TIME);
+		goto retry;
 
-	if (ipstatus != IPADM_SUCCESS) {
+	} else if (ipstatus != IPADM_SUCCESS) {
 		nlog(LOG_ERR, "start_dhcp: ipadm_%s_addr failed for %s: %s",
-		    (type == DHCP_START ? "create" : "refresh"),
-		    name, ipadm_status2str(ipstatus));
+		    (type == DHCP_START ? "create" : "refresh"), name,
+		    ipadm_status2str(ipstatus));
 	}
 
 done:
--- a/usr/src/cmd/cmd-inet/sbin/dhcpagent/inform.c	Mon Jul 26 11:11:38 2010 -0700
+++ b/usr/src/cmd/cmd-inet/sbin/dhcpagent/inform.c	Mon Jul 26 15:00:52 2010 -0400
@@ -19,14 +19,11 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  *
  * INFORM_SENT state of the client state machine.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include <sys/types.h>
 #include <time.h>
 #include <sys/socket.h>
@@ -98,7 +95,7 @@
 		(void) add_pkt_opt(dpkt, CD_END, NULL, 0);
 
 		IN6_V4MAPPED_TO_IPADDR(&dsmp->dsm_server, server);
-		if (!send_pkt(dsmp, dpkt, server, NULL)) {
+		if (!send_pkt(dsmp, dpkt, server, stop_informing)) {
 			dhcpmsg(MSG_ERROR, "dhcp_inform: send_pkt failed");
 			goto failed;
 		}