Integrated main parts of IKE_REAUTH task into ike_sa_t.reestablish.

This commit is contained in:
Tobias Brunner
2012-05-25 17:05:53 +02:00
parent 12715f1953
commit 23470d849a
2 changed files with 77 additions and 115 deletions
+74 -28
View File
@@ -239,6 +239,11 @@ struct private_ike_sa_t {
* Flush auth configs once established?
*/
bool flush_auth_cfg;
/**
* TRUE if we are currently reauthenticating this IKE_SA
*/
bool is_reauthenticating;
};
/**
@@ -1411,6 +1416,7 @@ METHOD(ike_sa_t, reauth, status_t,
DBG0(DBG_IKE, "reauthenticating IKE_SA %s[%d]",
get_name(this), this->unique_id);
}
this->is_reauthenticating = TRUE;
this->task_manager->queue_ike_reauth(this->task_manager);
return this->task_manager->initiate(this->task_manager);
}
@@ -1427,39 +1433,58 @@ METHOD(ike_sa_t, reestablish, status_t,
bool restart = FALSE;
status_t status = FAILED;
/* check if we have children to keep up at all */
enumerator = this->child_sas->create_enumerator(this->child_sas);
while (enumerator->enumerate(enumerator, (void**)&child_sa))
{
if (this->state == IKE_DELETING)
if (this->is_reauthenticating)
{ /* only reauthenticate if we have children */
if (this->child_sas->get_count(this->child_sas) == 0
#ifdef ME
/* allow reauth of mediation connections without CHILD_SAs */
&& !this->peer_cfg->is_mediation(this->peer_cfg)
#endif /* ME */
)
{
action = child_sa->get_close_action(child_sa);
DBG1(DBG_IKE, "unable to reauthenticate IKE_SA, no CHILD_SA "
"to recreate");
}
else
{
action = child_sa->get_dpd_action(child_sa);
restart = TRUE;
}
switch (action)
}
else
{ /* check if we have children to keep up at all */
enumerator = this->child_sas->create_enumerator(this->child_sas);
while (enumerator->enumerate(enumerator, (void**)&child_sa))
{
case ACTION_RESTART:
restart = TRUE;
break;
case ACTION_ROUTE:
charon->traps->install(charon->traps, this->peer_cfg,
child_sa->get_config(child_sa));
break;
default:
break;
if (this->state == IKE_DELETING)
{
action = child_sa->get_close_action(child_sa);
}
else
{
action = child_sa->get_dpd_action(child_sa);
}
switch (action)
{
case ACTION_RESTART:
restart = TRUE;
break;
case ACTION_ROUTE:
charon->traps->install(charon->traps, this->peer_cfg,
child_sa->get_config(child_sa));
break;
default:
break;
}
}
}
enumerator->destroy(enumerator);
enumerator->destroy(enumerator);
#ifdef ME
/* mediation connections have no children, keep them up anyway */
if (this->peer_cfg->is_mediation(this->peer_cfg))
{
restart = TRUE;
}
/* mediation connections have no children, keep them up anyway */
if (this->peer_cfg->is_mediation(this->peer_cfg))
{
restart = TRUE;
}
#endif /* ME */
}
if (!restart)
{
return FAILED;
@@ -1507,13 +1532,34 @@ METHOD(ike_sa_t, reestablish, status_t,
enumerator = this->child_sas->create_enumerator(this->child_sas);
while (enumerator->enumerate(enumerator, (void**)&child_sa))
{
if (this->state == IKE_DELETING)
if (this->is_reauthenticating)
{
action = child_sa->get_close_action(child_sa);
switch (child_sa->get_state(child_sa))
{
case CHILD_ROUTED:
{ /* move routed child directly */
this->child_sas->remove_at(this->child_sas, enumerator);
new->add_child_sa(new, child_sa);
action = ACTION_NONE;
break;
}
default:
{ /* initiate/queue all other CHILD_SAs */
action = ACTION_RESTART;
break;
}
}
}
else
{
action = child_sa->get_dpd_action(child_sa);
{ /* only restart CHILD_SAs that are configured accordingly */
if (this->state == IKE_DELETING)
{
action = child_sa->get_close_action(child_sa);
}
else
{
action = child_sa->get_dpd_action(child_sa);
}
}
switch (action)
{