diff options
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/cmd-inet/sbin/dhcpagent/agent.c | 20 | ||||
-rw-r--r-- | usr/src/cmd/cmd-inet/sbin/dhcpagent/states.c | 30 | ||||
-rw-r--r-- | usr/src/cmd/cmd-inet/sbin/dhcpagent/states.h | 3 |
3 files changed, 31 insertions, 22 deletions
diff --git a/usr/src/cmd/cmd-inet/sbin/dhcpagent/agent.c b/usr/src/cmd/cmd-inet/sbin/dhcpagent/agent.c index d1d4756867..807bc8269b 100644 --- a/usr/src/cmd/cmd-inet/sbin/dhcpagent/agent.c +++ b/usr/src/cmd/cmd-inet/sbin/dhcpagent/agent.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -696,6 +696,9 @@ ipc_event(iu_eh_t *ehp, int fd, short events, iu_event_id_t id, void *arg) switch (iap->ia_cmd) { case DHCP_DROP: + if (dsmp->dsm_droprelease) + break; + dsmp->dsm_droprelease = B_TRUE; (void) script_start(dsmp, isv6 ? EVENT_DROP6 : EVENT_DROP, dhcp_drop, NULL, NULL); break; /* not an immediate function */ @@ -898,6 +901,9 @@ load_option: break; case DHCP_RELEASE: + if (dsmp->dsm_droprelease) + break; + dsmp->dsm_droprelease = B_TRUE; (void) script_start(dsmp, isv6 ? EVENT_RELEASE6 : EVENT_RELEASE, dhcp_release, "Finished with lease.", NULL); break; /* not an immediate function */ @@ -1336,6 +1342,13 @@ rtsock_event(iu_eh_t *ehp, int fd, short events, iu_event_id_t id, void *arg) oldstate = dsmp->dsm_state; /* + * Ignore state machines that are currently processing drop or + * release; there is nothing more we can do for them. + */ + if (dsmp->dsm_droprelease) + continue; + + /* * Look for link up/down notifications. These occur on a * physical interface basis. */ @@ -1376,8 +1389,9 @@ rtsock_event(iu_eh_t *ehp, int fd, short events, iu_event_id_t id, void *arg) (!isv6 && !verify_lif(dsmp->dsm_lif))) { if (dsmp->dsm_script_pid != -1) script_stop(dsmp); - (void) script_start(dsmp, EVENT_DROP6, dhcp_drop, NULL, - NULL); + dsmp->dsm_droprelease = B_TRUE; + (void) script_start(dsmp, isv6 ? EVENT_DROP6 : + EVENT_DROP, dhcp_drop, NULL, NULL); continue; } diff --git a/usr/src/cmd/cmd-inet/sbin/dhcpagent/states.c b/usr/src/cmd/cmd-inet/sbin/dhcpagent/states.c index 63e134fc8f..9ae7fd7aba 100644 --- a/usr/src/cmd/cmd-inet/sbin/dhcpagent/states.c +++ b/usr/src/cmd/cmd-inet/sbin/dhcpagent/states.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * * This module contains core functions for managing DHCP state machine @@ -1205,25 +1205,17 @@ nuke_smach_list(void) for (dsmp = next_smach(NULL, isv6); dsmp != NULL; dsmp = dsmp_next) { int status; - const char *drop = isv6 ? EVENT_DROP6 : EVENT_DROP; - const char *release = isv6 ? EVENT_RELEASE6 : - EVENT_RELEASE; dsmp_next = next_smach(dsmp, isv6); + /* If we're already dropping or releasing, skip */ + if (dsmp->dsm_droprelease) + continue; + dsmp->dsm_droprelease = B_TRUE; + cancel_smach_timers(dsmp); - if (dsmp->dsm_script_pid != -1) { - /* - * Stop a script if it is not for DROP or - * RELEASE - */ - if (strcmp(dsmp->dsm_script_event, drop) == 0 || - strcmp(dsmp->dsm_script_event, release) == - 0) { - continue; - } + if (dsmp->dsm_script_pid != -1) script_stop(dsmp); - } /* * If the script is started by script_start, dhcp_drop @@ -1232,14 +1224,16 @@ nuke_smach_list(void) */ if (df_get_bool(dsmp->dsm_name, isv6, DF_RELEASE_ON_SIGTERM)) { - if (script_start(dsmp, release, dhcp_release, - "DHCP agent is exiting", &status) == 1) { + if (script_start(dsmp, isv6 ? EVENT_RELEASE6 : + EVENT_RELEASE, dhcp_release, + "DHCP agent is exiting", &status)) { continue; } if (status == 1) continue; } - (void) script_start(dsmp, drop, dhcp_drop, NULL, NULL); + (void) script_start(dsmp, isv6 ? EVENT_DROP6 : + EVENT_DROP, dhcp_drop, NULL, NULL); } if (isv6) break; diff --git a/usr/src/cmd/cmd-inet/sbin/dhcpagent/states.h b/usr/src/cmd/cmd-inet/sbin/dhcpagent/states.h index c36232264e..fc80a07112 100644 --- a/usr/src/cmd/cmd-inet/sbin/dhcpagent/states.h +++ b/usr/src/cmd/cmd-inet/sbin/dhcpagent/states.h @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -94,6 +94,7 @@ struct dhcp_smach_s { */ DHCPSTATE dsm_state; + boolean_t dsm_droprelease; /* soon to call finished_smach */ uint16_t dsm_dflags; /* DHCP_IF_* (shared with IPC) */ |