Deactivate all active segments before shutting down
This commit is contained in:
committed by
Martin Willi
parent
4e248733a8
commit
310498f3de
@@ -84,6 +84,7 @@ struct private_ha_sync_plugin_t {
|
||||
static void destroy(private_ha_sync_plugin_t *this)
|
||||
{
|
||||
DESTROY_IF(this->ctl);
|
||||
charon->bus->remove_listener(charon->bus, &this->segments->listener);
|
||||
charon->bus->remove_listener(charon->bus, &this->ike->listener);
|
||||
charon->bus->remove_listener(charon->bus, &this->child->listener);
|
||||
this->ike->destroy(this->ike);
|
||||
@@ -183,6 +184,7 @@ plugin_t *plugin_create()
|
||||
this->dispatcher = ha_sync_dispatcher_create(this->socket, this->segments);
|
||||
this->ike = ha_sync_ike_create(this->socket, this->tunnel);
|
||||
this->child = ha_sync_child_create(this->socket, this->tunnel);
|
||||
charon->bus->add_listener(charon->bus, &this->segments->listener);
|
||||
charon->bus->add_listener(charon->bus, &this->ike->listener);
|
||||
charon->bus->add_listener(charon->bus, &this->child->listener);
|
||||
|
||||
|
||||
@@ -264,6 +264,27 @@ static void resync(private_ha_sync_segments_t *this, u_int segment)
|
||||
list->destroy(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of listener_t.alert
|
||||
*/
|
||||
static bool alert_hook(private_ha_sync_segments_t *this, ike_sa_t *ike_sa,
|
||||
alert_t alert, va_list args)
|
||||
{
|
||||
if (alert == ALERT_SHUTDOWN_SIGNAL)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < SEGMENTS_MAX; i++)
|
||||
{
|
||||
if (this->active & SEGMENTS_BIT(i))
|
||||
{
|
||||
deactivate(this, i, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of ha_sync_segments_t.destroy.
|
||||
*/
|
||||
@@ -282,6 +303,8 @@ ha_sync_segments_t *ha_sync_segments_create(ha_sync_socket_t *socket,
|
||||
{
|
||||
private_ha_sync_segments_t *this = malloc_thing(private_ha_sync_segments_t);
|
||||
|
||||
memset(&this->public.listener, 0, sizeof(listener_t));
|
||||
this->public.listener.alert = (bool(*)(listener_t*, ike_sa_t *, alert_t, va_list))alert_hook;
|
||||
this->public.activate = (void(*)(ha_sync_segments_t*, u_int segment,bool))activate;
|
||||
this->public.deactivate = (void(*)(ha_sync_segments_t*, u_int segment,bool))deactivate;
|
||||
this->public.resync = (void(*)(ha_sync_segments_t*, u_int segment))resync;
|
||||
|
||||
@@ -45,6 +45,11 @@ typedef u_int16_t segment_mask_t;
|
||||
*/
|
||||
struct ha_sync_segments_t {
|
||||
|
||||
/**
|
||||
* Implements listener interface to catch daemon shutdown.
|
||||
*/
|
||||
listener_t listener;
|
||||
|
||||
/**
|
||||
* Activate a set of IKE_SAs identified by a segment.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user