fixed jumping IKE_SA unique ids

This commit is contained in:
Martin Willi
2008-04-14 07:55:23 +00:00
parent 45819d7d49
commit cadb5d16e5
+53 -28
View File
@@ -1883,10 +1883,37 @@ static status_t reestablish(private_ike_sa_t *this)
iterator_t *iterator; iterator_t *iterator;
child_sa_t *child_sa; child_sa_t *child_sa;
child_cfg_t *child_cfg; child_cfg_t *child_cfg;
action_t action;
bool required = FALSE; bool required = FALSE;
status_t status = FAILED; status_t status = FAILED;
/* check if we have children to keep up at all*/
iterator = create_child_sa_iterator(this);
while (iterator->iterate(iterator, (void**)&child_sa))
{
child_cfg = child_sa->get_config(child_sa);
switch (child_cfg->get_action(child_cfg))
{
case ACTION_RESTART:
case ACTION_ROUTE:
required = TRUE;
default:
break;
}
}
iterator->destroy(iterator);
#ifdef ME
/* we initiate the new IKE_SA of the mediation connection without CHILD_SA */
if (this->peer_cfg->is_mediation(this->peer_cfg))
{
required = TRUE;
}
#endif /* ME */
if (!required)
{
return FAILED;
}
/* check if we are able to reestablish this IKE_SA */
if (!this->ike_initiator && if (!this->ike_initiator &&
(this->other_virtual_ip != NULL || (this->other_virtual_ip != NULL ||
has_condition(this, COND_EAP_AUTHENTICATED) has_condition(this, COND_EAP_AUTHENTICATED)
@@ -1895,6 +1922,7 @@ static status_t reestablish(private_ike_sa_t *this)
#endif /* ME */ #endif /* ME */
)) ))
{ {
DBG1(DBG_IKE, "unable to reestablish IKE_SA due asymetric setup");
return FAILED; return FAILED;
} }
@@ -1912,52 +1940,49 @@ static status_t reestablish(private_ike_sa_t *this)
} }
#ifdef ME #ifdef ME
/* we initiate the new IKE_SA of the mediation connection without CHILD_SA */
if (this->peer_cfg->is_mediation(this->peer_cfg)) if (this->peer_cfg->is_mediation(this->peer_cfg))
{ {
required = TRUE; status = new->initiate(new, NULL);
} }
else
#endif /* ME */ #endif /* ME */
iterator = create_child_sa_iterator(this);
while (iterator->iterate(iterator, (void**)&child_sa))
{ {
child_cfg = child_sa->get_config(child_sa); iterator = create_child_sa_iterator(this);
action = child_cfg->get_action(child_cfg); while (iterator->iterate(iterator, (void**)&child_sa))
if (action == ACTION_RESTART || action == ACTION_ROUTE)
{ {
required = TRUE; child_cfg = child_sa->get_config(child_sa);
if (action == ACTION_RESTART) switch (child_cfg->get_action(child_cfg))
{ {
DBG1(DBG_IKE, "restarting CHILD_SA %s", case ACTION_RESTART:
child_cfg->get_name(child_cfg)); DBG1(DBG_IKE, "restarting CHILD_SA %s",
child_cfg->get_ref(child_cfg); child_cfg->get_name(child_cfg));
status = new->initiate(new, child_cfg); child_cfg->get_ref(child_cfg);
if (status == DESTROY_ME) status = new->initiate(new, child_cfg);
{
required = FALSE;
break; break;
} case ACTION_ROUTE:
status = new->route(new, child_cfg);
break;
default:
continue;
} }
else if (status == DESTROY_ME)
{ {
new->route(new, child_cfg); break;
} }
} }
iterator->destroy(iterator);
} }
iterator->destroy(iterator);
if (required) if (status == DESTROY_ME)
{ {
charon->ike_sa_manager->checkin(charon->ike_sa_manager, new); charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager, new);
return FAILED;
} }
else else
{ {
charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager, new); charon->ike_sa_manager->checkin(charon->ike_sa_manager, new);
DBG1(DBG_IKE, "unable to reestablish IKE_SA, no CHILD_SA to recreate"); return SUCCESS;
} }
return status;
} }
/** /**