summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnurag S. Maskey <Anurag.Maskey@Oracle.COM>2010-05-10 15:01:49 -0400
committerAnurag S. Maskey <Anurag.Maskey@Oracle.COM>2010-05-10 15:01:49 -0400
commit71ed50cf049ab14d8e0ef8d48ba17d91223e81e7 (patch)
tree1e435768335352cc256d81c3bf8028dd4cc82f65
parent42bf653b44c42fc6b637ae50e590489d69399241 (diff)
downloadillumos-gate-71ed50cf049ab14d8e0ef8d48ba17d91223e81e7.tar.gz
6933954 nwamd fails to retry upgrades when boot timing thwarts early attempts
6944167 network is unavailable when using LiveCD/Text installer/bootable AI in osol_137
-rw-r--r--usr/src/cmd/cmd-inet/lib/nwamd/llp.c36
-rw-r--r--usr/src/cmd/cmd-inet/lib/nwamd/main.c20
-rw-r--r--usr/src/cmd/cmd-inet/lib/nwamd/ncp.c37
-rw-r--r--usr/src/cmd/cmd-inet/lib/nwamd/ncu.c39
4 files changed, 81 insertions, 51 deletions
diff --git a/usr/src/cmd/cmd-inet/lib/nwamd/llp.c b/usr/src/cmd/cmd-inet/lib/nwamd/llp.c
index c963216731..b371493149 100644
--- a/usr/src/cmd/cmd-inet/lib/nwamd/llp.c
+++ b/usr/src/cmd/cmd-inet/lib/nwamd/llp.c
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -306,10 +305,20 @@ upgrade_llp_config(void)
default:
break;
}
- if ((err = nwam_ncp_create(NWAM_NCP_NAME_USER, 0, &user_ncp))
- != NWAM_SUCCESS) {
+
+ err = nwam_ncp_create(NWAM_NCP_NAME_USER, 0, &user_ncp);
+ switch (err) {
+ case NWAM_SUCCESS:
+ break;
+ case NWAM_ERROR_BIND:
+ case NWAM_ERROR_INTERNAL:
nlog(LOG_ERR, "upgrade_llp_config: "
- "could not create user NCP: %s", nwam_strerror(err));
+ "could not create User NCP: %s", nwam_strerror(err));
+ llp_list_free();
+ return (EAGAIN);
+ default:
+ nlog(LOG_ERR, "upgrade_llp_config: error creating User NCP: %s",
+ nwam_strerror(err));
llp_list_free();
return (0);
}
@@ -402,21 +411,22 @@ upgrade_llp_config(void)
nwam_strerror(err));
/* Schedule a retry - root filesystem may be readonly */
llp_list_free();
+ nwam_ncu_free(ip_ncu);
+ nwam_ncu_free(phys_ncu);
+ (void) nwam_ncp_destroy(user_ncp, 0);
return (EAGAIN);
}
- nwam_ncu_free(ip_ncu);
- nwam_ncu_free(phys_ncu);
}
if (err != NWAM_SUCCESS) {
nlog(LOG_ERR, "upgrade_llp_config: llp %s: "
"could not set value for property %s: %s", wp->llp_lname,
prop, nwam_strerror(err));
- nwam_ncu_free(ip_ncu);
- nwam_ncu_free(phys_ncu);
- exit(EXIT_FAILURE);
}
llp_list_free();
+ nwam_ncu_free(ip_ncu);
+ nwam_ncu_free(phys_ncu);
+ nwam_ncp_free(user_ncp);
return (0);
}
@@ -452,8 +462,12 @@ nwamd_handle_upgrade(nwamd_event_t event)
*/
upgrade_event = nwamd_event_init(NWAM_EVENT_TYPE_UPGRADE,
NWAM_OBJECT_TYPE_NCP, 0, NULL);
- if (upgrade_event == NULL)
+ if (upgrade_event == NULL) {
+ nlog(LOG_ERR, "nwamd_handle_upgrade: "
+ "could not create retry event to upgrade "
+ "%s configuration", LLPFILE);
return;
+ }
nwamd_event_enqueue_timed(upgrade_event,
NWAMD_READONLY_RETRY_INTERVAL);
return;
diff --git a/usr/src/cmd/cmd-inet/lib/nwamd/main.c b/usr/src/cmd/cmd-inet/lib/nwamd/main.c
index 332499c80d..108463d603 100644
--- a/usr/src/cmd/cmd-inet/lib/nwamd/main.c
+++ b/usr/src/cmd/cmd-inet/lib/nwamd/main.c
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <errno.h>
@@ -376,6 +375,15 @@ main(int argc, char *argv[])
}
/*
+ * Create the event queue before starting event sources, including
+ * signal handling, so we are ready to handle incoming events. Also
+ * start before attempting to upgrade, in case there's a problem
+ * upgrading and we need to retry (in which case we schedule an event
+ * to do so).
+ */
+ nwamd_event_queue_init();
+
+ /*
* Handle upgrade of legacy config. Absence of version property
* (which did not exist in phase 0 or 0.5) is the indication that
* we need to upgrade to phase 1 (version 1).
@@ -389,13 +397,6 @@ main(int argc, char *argv[])
*/
nwamd_object_lists_init();
- /*
- * Start the event handling thread before starting event sources,
- * including signal handling, so we are ready to handle incoming
- * events.
- */
- nwamd_event_queue_init();
-
init_signalhandling();
/* Enqueue init event */
@@ -403,6 +404,7 @@ main(int argc, char *argv[])
if (event == NULL)
pfail("nwamd could not create init event, exiting");
nwamd_event_enqueue(event);
+
/*
* Collect initial user configuration.
*/
diff --git a/usr/src/cmd/cmd-inet/lib/nwamd/ncp.c b/usr/src/cmd/cmd-inet/lib/nwamd/ncp.c
index 55bbbf707c..7292b3f2df 100644
--- a/usr/src/cmd/cmd-inet/lib/nwamd/ncp.c
+++ b/usr/src/cmd/cmd-inet/lib/nwamd/ncp.c
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <arpa/inet.h>
@@ -116,23 +115,34 @@ nwamd_ncp_handle_enable_event(nwamd_event_t event)
nwamd_fini_ncus();
- err = nwam_ncp_read(new_ncp, 0, &new_ncph);
- switch (err) {
- case NWAM_ENTITY_NOT_FOUND:
+ if ((err = nwam_ncp_read(new_ncp, 0, &new_ncph))
+ == NWAM_ENTITY_NOT_FOUND) {
err = nwam_ncp_create(new_ncp, 0, &new_ncph);
- break;
- case NWAM_SUCCESS:
- break;
- default:
- nlog(LOG_ERR, "nwamd_ncp_handle_enable_event: error %s",
- nwam_strerror(err));
- return;
}
- nwam_ncp_free(new_ncph);
if (err == NWAM_SUCCESS) {
+ nwam_ncp_free(new_ncph);
nwamd_object_set_state(NWAM_OBJECT_TYPE_NCP, new_ncp,
NWAM_STATE_ONLINE, NWAM_AUX_STATE_ACTIVE);
+ } else if (initial_ncp_enable) {
+ /*
+ * We weren't able to enable the NCP when nwamd starts up,
+ * retry in a few seconds.
+ */
+ nwamd_event_t retry_event = nwamd_event_init_object_action
+ (NWAM_OBJECT_TYPE_NCP, new_ncp, NULL, NWAM_ACTION_ENABLE);
+ if (retry_event == NULL) {
+ nlog(LOG_ERR, "nwamd_ncp_handle_enable_event: "
+ "could not create retry event to enable %s NCP",
+ new_ncp);
+ return;
+ }
+
+ nlog(LOG_ERR, "nwamd_ncp_handle_enable_event: "
+ "failed to enable %s NCP, retrying in %d seconds",
+ new_ncp, NWAMD_READONLY_RETRY_INTERVAL);
+ nwamd_event_enqueue_timed(retry_event,
+ NWAMD_READONLY_RETRY_INTERVAL);
} else {
nlog(LOG_ERR, "nwamd_ncp_handle_enable_event: error %s",
nwam_strerror(err));
@@ -240,7 +250,6 @@ find_next_priority_group_cb(nwamd_object_t object, void *data)
return (0);
}
-
/* Set current_pg to next pg in NCP that is >= start_pg */
boolean_t
nwamd_ncp_find_next_priority_group(int64_t minpriority,
diff --git a/usr/src/cmd/cmd-inet/lib/nwamd/ncu.c b/usr/src/cmd/cmd-inet/lib/nwamd/ncu.c
index 9a49ce37b4..b44565c1d7 100644
--- a/usr/src/cmd/cmd-inet/lib/nwamd/ncu.c
+++ b/usr/src/cmd/cmd-inet/lib/nwamd/ncu.c
@@ -20,8 +20,7 @@
*/
/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <arpa/inet.h>
@@ -1275,21 +1274,10 @@ nwamd_ncu_handle_link_action_event(nwamd_event_t event)
if ((err = nwam_ncp_read(NWAM_NCP_NAME_AUTOMATIC, 0, &ncph))
== NWAM_ENTITY_NOT_FOUND) {
/* Automatic NCP doesn't exist, create it */
- if ((err = nwam_ncp_create(NWAM_NCP_NAME_AUTOMATIC, 0,
- &ncph)) != NWAM_SUCCESS) {
- nlog(LOG_ERR,
- "nwamd_ncu_handle_link_action_event: "
- "could not create %s NCP: %s",
- NWAM_NCP_NAME_AUTOMATIC,
- nwam_strerror(err));
- goto cleanup_exit;
- }
- } else if (err != NWAM_SUCCESS) {
- nlog(LOG_ERR, "nwamd_ncu_handle_link_action_event: "
- "failed to read Automatic NCP: %s",
- nwam_strerror(err));
- goto cleanup_exit;
+ err = nwam_ncp_create(NWAM_NCP_NAME_AUTOMATIC, 0, &ncph);
}
+ if (err != NWAM_SUCCESS)
+ goto fail;
/* add or remove NCUs from Automatic NCP */
if (action == NWAM_ACTION_ADD) {
@@ -1323,8 +1311,24 @@ nwamd_ncu_handle_link_action_event(nwamd_event_t event)
nwamd_create_ncu_check_event(NEXT_FEW_SECONDS);
}
-cleanup_exit:
+fail:
free(name);
+ if (err != NWAM_SUCCESS) {
+ nwamd_event_t retry_event = nwamd_event_init_link_action(name,
+ action);
+ if (retry_event == NULL) {
+ nlog(LOG_ERR, "nwamd_ncu_handle_link_action_event: "
+ "could not create retry event to read/create "
+ "%s NCP", NWAM_NCP_NAME_AUTOMATIC);
+ return;
+ }
+
+ nlog(LOG_ERR, "nwamd_ncu_handle_link_action_event: "
+ "could not read/create %s NCP, retrying in %d seconds",
+ NWAM_NCP_NAME_AUTOMATIC, NWAMD_READONLY_RETRY_INTERVAL);
+ nwamd_event_enqueue_timed(retry_event,
+ NWAMD_READONLY_RETRY_INTERVAL);
+ }
}
/*
@@ -1529,6 +1533,7 @@ nwamd_ncu_handle_init_event(nwamd_event_t event)
nlog(LOG_DEBUG,
"nwamd_ncu_handle_init_event: active NCP handle NULL");
nwamd_event_do_not_send(event);
+ free(name);
(void) pthread_mutex_unlock(&active_ncp_mutex);
return;
}