ike-sa-manager: Remove IKE_SA checkout by CHILD_SA reqid

This commit is contained in:
Martin Willi
2015-02-20 13:34:51 +01:00
parent 246dcf8691
commit db80d0d2da
5 changed files with 16 additions and 40 deletions
@@ -426,8 +426,7 @@ CALLBACK(reestablish, job_requeue_t,
{
ike_sa_t *ike_sa;
ike_sa = charon->ike_sa_manager->checkout_by_id(charon->ike_sa_manager,
*id, FALSE);
ike_sa = charon->ike_sa_manager->checkout_by_id(charon->ike_sa_manager, *id);
if (ike_sa)
{
if (ike_sa->reauth(ike_sa) == DESTROY_ME)
+1 -1
View File
@@ -449,7 +449,7 @@ METHOD(job_t, terminate_ike_execute, job_requeue_t,
ike_sa_t *ike_sa;
ike_sa = charon->ike_sa_manager->checkout_by_id(charon->ike_sa_manager,
unique_id, FALSE);
unique_id);
if (!ike_sa)
{
DBG1(DBG_IKE, "unable to terminate IKE_SA: ID %d not found", unique_id);
+1 -1
View File
@@ -210,7 +210,7 @@ static job_requeue_t add_exclude_async(entry_t *entry)
host_t *host;
ike_sa = charon->ike_sa_manager->checkout_by_id(charon->ike_sa_manager,
entry->sa, FALSE);
entry->sa);
if (ike_sa)
{
create_shunt_name(ike_sa, entry->ts, name, sizeof(name));
+10 -29
View File
@@ -1383,54 +1383,35 @@ METHOD(ike_sa_manager_t, checkout_by_config, ike_sa_t*,
}
METHOD(ike_sa_manager_t, checkout_by_id, ike_sa_t*,
private_ike_sa_manager_t *this, u_int32_t id, bool child)
private_ike_sa_manager_t *this, u_int32_t id)
{
enumerator_t *enumerator, *children;
enumerator_t *enumerator;
entry_t *entry;
ike_sa_t *ike_sa = NULL;
child_sa_t *child_sa;
u_int segment;
DBG2(DBG_MGR, "checkout IKE_SA by ID");
DBG2(DBG_MGR, "checkout IKE_SA by ID %u", id);
enumerator = create_table_enumerator(this);
while (enumerator->enumerate(enumerator, &entry, &segment))
{
if (wait_for_entry(this, entry, segment))
{
/* look for a child with such a reqid ... */
if (child)
{
children = entry->ike_sa->create_child_sa_enumerator(entry->ike_sa);
while (children->enumerate(children, (void**)&child_sa))
{
if (child_sa->get_reqid(child_sa) == id)
{
ike_sa = entry->ike_sa;
break;
}
}
children->destroy(children);
}
else /* ... or for a IKE_SA with such a unique id */
{
if (entry->ike_sa->get_unique_id(entry->ike_sa) == id)
{
ike_sa = entry->ike_sa;
}
}
/* got one, return */
if (ike_sa)
if (entry->ike_sa->get_unique_id(entry->ike_sa) == id)
{
ike_sa = entry->ike_sa;
entry->checked_out = TRUE;
DBG2(DBG_MGR, "IKE_SA %s[%u] successfully checked out",
ike_sa->get_name(ike_sa), ike_sa->get_unique_id(ike_sa));
break;
}
}
}
enumerator->destroy(enumerator);
if (ike_sa)
{
DBG2(DBG_MGR, "IKE_SA %s[%u] successfully checked out",
ike_sa->get_name(ike_sa), ike_sa->get_unique_id(ike_sa));
}
charon->bus->set_sa(charon->bus, ike_sa);
return ike_sa;
}
+3 -7
View File
@@ -129,19 +129,15 @@ struct ike_sa_manager_t {
/**
* Check out an IKE_SA a unique ID.
*
* Every IKE_SA and every CHILD_SA is uniquely identified by an ID.
* These checkout function uses, depending
* on the child parameter, the unique ID of the IKE_SA or the reqid
* of one of a IKE_SAs CHILD_SA.
* Every IKE_SA is uniquely identified by a numerical ID. This checkout
* function uses the unique ID of the IKE_SA to check it out.
*
* @param id unique ID of the object
* @param child TRUE to use CHILD, FALSE to use IKE_SA
* @return
* - checked out IKE_SA, if found
* - NULL, if not found
*/
ike_sa_t* (*checkout_by_id) (ike_sa_manager_t* this, u_int32_t id,
bool child);
ike_sa_t* (*checkout_by_id) (ike_sa_manager_t* this, u_int32_t id);
/**
* Check out an IKE_SA by the policy/connection name.