Request a complete resync after daemon startup
This commit is contained in:
committed by
Martin Willi
parent
1466af8556
commit
c866a42737
@@ -635,6 +635,31 @@ static void process_status(private_ha_dispatcher_t *this,
|
|||||||
this->segments->handle_status(this->segments, mask);
|
this->segments->handle_status(this->segments, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process messages of type RESYNC
|
||||||
|
*/
|
||||||
|
static void process_resync(private_ha_dispatcher_t *this,
|
||||||
|
ha_message_t *message)
|
||||||
|
{
|
||||||
|
ha_message_attribute_t attribute;
|
||||||
|
ha_message_value_t value;
|
||||||
|
enumerator_t *enumerator;
|
||||||
|
|
||||||
|
enumerator = message->create_attribute_enumerator(message);
|
||||||
|
while (enumerator->enumerate(enumerator, &attribute, &value))
|
||||||
|
{
|
||||||
|
switch (attribute)
|
||||||
|
{
|
||||||
|
case HA_SEGMENT:
|
||||||
|
this->segments->resync(this->segments, value.u16);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
enumerator->destroy(enumerator);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispatcher job function
|
* Dispatcher job function
|
||||||
*/
|
*/
|
||||||
@@ -669,6 +694,9 @@ static job_requeue_t dispatch(private_ha_dispatcher_t *this)
|
|||||||
case HA_STATUS:
|
case HA_STATUS:
|
||||||
process_status(this, message);
|
process_status(this, message);
|
||||||
break;
|
break;
|
||||||
|
case HA_RESYNC:
|
||||||
|
process_resync(this, message);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
DBG1(DBG_CFG, "received unknown HA message type %d",
|
DBG1(DBG_CFG, "received unknown HA message type %d",
|
||||||
message->get_type(message));
|
message->get_type(message));
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ enum ha_message_type_t {
|
|||||||
HA_SEGMENT_TAKE,
|
HA_SEGMENT_TAKE,
|
||||||
/** status with the segments the sending node is currently serving */
|
/** status with the segments the sending node is currently serving */
|
||||||
HA_STATUS,
|
HA_STATUS,
|
||||||
|
/** segments the receiving node is requested to resync */
|
||||||
|
HA_RESYNC,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -257,15 +257,12 @@ static void resync(private_ha_segments_t *this, u_int segment)
|
|||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
linked_list_t *list;
|
linked_list_t *list;
|
||||||
ike_sa_id_t *id;
|
ike_sa_id_t *id;
|
||||||
u_int16_t mask = SEGMENTS_BIT(segment);
|
|
||||||
|
|
||||||
list = linked_list_create();
|
list = linked_list_create();
|
||||||
this->mutex->lock(this->mutex);
|
this->mutex->lock(this->mutex);
|
||||||
|
|
||||||
if (segment > 0 && segment <= this->count && (this->active & mask))
|
if (segment > 0 && segment <= this->count)
|
||||||
{
|
{
|
||||||
this->active &= ~mask;
|
|
||||||
|
|
||||||
DBG1(DBG_CFG, "resyncing HA segment %d", segment);
|
DBG1(DBG_CFG, "resyncing HA segment %d", segment);
|
||||||
|
|
||||||
/* we do the actual rekeying in a seperate loop to avoid rekeying
|
/* we do the actual rekeying in a seperate loop to avoid rekeying
|
||||||
@@ -322,6 +319,23 @@ static bool alert_hook(private_ha_segments_t *this, ike_sa_t *ike_sa,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request a resync of all segments
|
||||||
|
*/
|
||||||
|
static job_requeue_t request_resync(private_ha_segments_t *this)
|
||||||
|
{
|
||||||
|
ha_message_t *message;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
message = ha_message_create(HA_RESYNC);
|
||||||
|
for (i = 1; i <= this->count; i++)
|
||||||
|
{
|
||||||
|
message->add_attribute(message, HA_SEGMENT, i);
|
||||||
|
}
|
||||||
|
this->socket->push(this->socket, message);
|
||||||
|
return JOB_REQUEUE_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor heartbeat activity of remote node
|
* Monitor heartbeat activity of remote node
|
||||||
*/
|
*/
|
||||||
@@ -463,6 +477,7 @@ ha_segments_t *ha_segments_create(ha_socket_t *socket, ha_kernel_t *kernel,
|
|||||||
this->condvar = condvar_create(CONDVAR_TYPE_DEFAULT);
|
this->condvar = condvar_create(CONDVAR_TYPE_DEFAULT);
|
||||||
this->count = count;
|
this->count = count;
|
||||||
this->master = strcmp(local, remote) > 0;
|
this->master = strcmp(local, remote) > 0;
|
||||||
|
this->job = NULL;
|
||||||
|
|
||||||
/* initially all segments are deactivated */
|
/* initially all segments are deactivated */
|
||||||
this->active = 0;
|
this->active = 0;
|
||||||
@@ -471,6 +486,11 @@ ha_segments_t *ha_segments_create(ha_socket_t *socket, ha_kernel_t *kernel,
|
|||||||
|
|
||||||
start_watchdog(this);
|
start_watchdog(this);
|
||||||
|
|
||||||
|
/* request a resync as soon as we are up */
|
||||||
|
charon->processor->queue_job(charon->processor, (job_t*)
|
||||||
|
callback_job_create((callback_job_cb_t)request_resync,
|
||||||
|
this, NULL, NULL));
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user