reset threads IKE_SA after checking other IKE_SAs

invoke updown script only if we have valid IKE_SA
This commit is contained in:
Martin Willi
2008-10-20 11:38:16 +00:00
parent 7790ab0f37
commit f2e1ff59ab
4 changed files with 26 additions and 9 deletions
+12 -9
View File
@@ -199,16 +199,19 @@ static bool child_state_change(listener_t *this, ike_sa_t *ike_sa,
{ {
child_sa_state_t old; child_sa_state_t old;
old = child_sa->get_state(child_sa); if (ike_sa)
if ((old == CHILD_INSTALLED && state != CHILD_REKEYING ) ||
(old == CHILD_DELETING && state == CHILD_DESTROYING))
{ {
updown(ike_sa, child_sa, FALSE); old = child_sa->get_state(child_sa);
}
else if (state == CHILD_INSTALLED) if ((old == CHILD_INSTALLED && state != CHILD_REKEYING ) ||
{ (old == CHILD_DELETING && state == CHILD_DESTROYING))
updown(ike_sa, child_sa, TRUE); {
updown(ike_sa, child_sa, FALSE);
}
else if (state == CHILD_INSTALLED)
{
updown(ike_sa, child_sa, TRUE);
}
} }
return TRUE; return TRUE;
} }
+2
View File
@@ -146,6 +146,8 @@ static bool check_uniqueness(private_ike_auth_t *this)
charon->ike_sa_manager->checkin(charon->ike_sa_manager, duplicate); charon->ike_sa_manager->checkin(charon->ike_sa_manager, duplicate);
} }
} }
/* set threads active IKE_SA after checkin */
charon->bus->set_sa(charon->bus, this->ike_sa);
return cancel; return cancel;
} }
+6
View File
@@ -104,6 +104,8 @@ static status_t process_i(private_ike_reauth_t *this, message_t *message)
{ {
charon->ike_sa_manager->checkin_and_destroy( charon->ike_sa_manager->checkin_and_destroy(
charon->ike_sa_manager, new); charon->ike_sa_manager, new);
/* set threads active IKE_SA after checkin */
charon->bus->set_sa(charon->bus, this->ike_sa);
DBG1(DBG_IKE, "reauthenticating IKE_SA failed"); DBG1(DBG_IKE, "reauthenticating IKE_SA failed");
return FAILED; return FAILED;
} }
@@ -131,6 +133,8 @@ static status_t process_i(private_ike_reauth_t *this, message_t *message)
iterator->destroy(iterator); iterator->destroy(iterator);
charon->ike_sa_manager->checkin_and_destroy( charon->ike_sa_manager->checkin_and_destroy(
charon->ike_sa_manager, new); charon->ike_sa_manager, new);
/* set threads active IKE_SA after checkin */
charon->bus->set_sa(charon->bus, this->ike_sa);
DBG1(DBG_IKE, "reauthenticating IKE_SA failed"); DBG1(DBG_IKE, "reauthenticating IKE_SA failed");
return FAILED; return FAILED;
} }
@@ -140,6 +144,8 @@ static status_t process_i(private_ike_reauth_t *this, message_t *message)
} }
iterator->destroy(iterator); iterator->destroy(iterator);
charon->ike_sa_manager->checkin(charon->ike_sa_manager, new); charon->ike_sa_manager->checkin(charon->ike_sa_manager, new);
/* set threads active IKE_SA after checkin */
charon->bus->set_sa(charon->bus, this->ike_sa);
/* we always return failed to delete the obsolete IKE_SA */ /* we always return failed to delete the obsolete IKE_SA */
return FAILED; return FAILED;
+6
View File
@@ -242,6 +242,8 @@ static status_t process_i(private_ike_rekey_t *this, message_t *message)
this->new_sa = other->new_sa; this->new_sa = other->new_sa;
other->new_sa = NULL; other->new_sa = NULL;
} }
/* set threads active IKE_SA after checkin */
charon->bus->set_sa(charon->bus, this->ike_sa);
} }
job = (job_t*)delete_ike_sa_job_create(to_delete, TRUE); job = (job_t*)delete_ike_sa_job_create(to_delete, TRUE);
@@ -277,6 +279,8 @@ static void migrate(private_ike_rekey_t *this, ike_sa_t *ike_sa)
{ {
charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager, charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager,
this->new_sa); this->new_sa);
/* set threads active IKE_SA after checkin */
charon->bus->set_sa(charon->bus, this->ike_sa);
} }
DESTROY_IF(this->collision); DESTROY_IF(this->collision);
@@ -303,6 +307,8 @@ static void destroy(private_ike_rekey_t *this)
charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager, charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager,
this->new_sa); this->new_sa);
} }
/* set threads active IKE_SA after checkin */
charon->bus->set_sa(charon->bus, this->ike_sa);
} }
if (this->ike_init) if (this->ike_init)
{ {