controller: Use the CHILD_SA unique_id to terminate CHILD_SAs
This commit is contained in:
@@ -236,7 +236,7 @@ static job_requeue_t close_child(char *config)
|
||||
{
|
||||
if (streq(config, child_sa->get_name(child_sa)))
|
||||
{
|
||||
id = child_sa->get_reqid(child_sa);
|
||||
id = child_sa->get_unique_id(child_sa);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -534,17 +534,15 @@ METHOD(job_t, terminate_child_execute, job_requeue_t,
|
||||
interface_job_t *job)
|
||||
{
|
||||
interface_listener_t *listener = &job->listener;
|
||||
u_int32_t reqid = listener->id;
|
||||
enumerator_t *enumerator;
|
||||
u_int32_t id = listener->id;
|
||||
child_sa_t *child_sa;
|
||||
ike_sa_t *ike_sa;
|
||||
|
||||
ike_sa = charon->ike_sa_manager->checkout_by_id(charon->ike_sa_manager,
|
||||
reqid, TRUE);
|
||||
ike_sa = charon->child_sa_manager->checkout_by_id(charon->child_sa_manager,
|
||||
id, &child_sa);
|
||||
if (!ike_sa)
|
||||
{
|
||||
DBG1(DBG_IKE, "unable to terminate, CHILD_SA with ID %d not found",
|
||||
reqid);
|
||||
DBG1(DBG_IKE, "unable to terminate, CHILD_SA with ID %d not found", id);
|
||||
listener->status = NOT_FOUND;
|
||||
/* release listener */
|
||||
listener_done(listener);
|
||||
@@ -554,22 +552,10 @@ METHOD(job_t, terminate_child_execute, job_requeue_t,
|
||||
listener->ike_sa = ike_sa;
|
||||
listener->lock->unlock(listener->lock);
|
||||
|
||||
enumerator = ike_sa->create_child_sa_enumerator(ike_sa);
|
||||
while (enumerator->enumerate(enumerator, (void**)&child_sa))
|
||||
{
|
||||
if (child_sa->get_state(child_sa) != CHILD_ROUTED &&
|
||||
child_sa->get_reqid(child_sa) == reqid)
|
||||
{
|
||||
break;
|
||||
}
|
||||
child_sa = NULL;
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
if (!child_sa)
|
||||
if (child_sa->get_state(child_sa) == CHILD_ROUTED)
|
||||
{
|
||||
DBG1(DBG_IKE, "unable to terminate, established "
|
||||
"CHILD_SA with ID %d not found", reqid);
|
||||
"CHILD_SA with ID %d not found", id);
|
||||
charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
|
||||
listener->status = NOT_FOUND;
|
||||
/* release listener */
|
||||
@@ -596,7 +582,7 @@ METHOD(job_t, terminate_child_execute, job_requeue_t,
|
||||
}
|
||||
|
||||
METHOD(controller_t, terminate_child, status_t,
|
||||
controller_t *this, u_int32_t reqid,
|
||||
controller_t *this, u_int32_t unique_id,
|
||||
controller_cb_t callback, void *param, u_int timeout)
|
||||
{
|
||||
interface_job_t *job;
|
||||
@@ -617,7 +603,7 @@ METHOD(controller_t, terminate_child, status_t,
|
||||
.param = param,
|
||||
},
|
||||
.status = FAILED,
|
||||
.id = reqid,
|
||||
.id = unique_id,
|
||||
.lock = spinlock_create(),
|
||||
},
|
||||
.public = {
|
||||
|
||||
@@ -118,7 +118,7 @@ struct controller_t {
|
||||
* If a callback is provided the function is synchronous and thus blocks
|
||||
* until the CHILD_SA is properly deleted, or the call timed out.
|
||||
*
|
||||
* @param reqid reqid of the CHILD_SA to terminate
|
||||
* @param unique_id CHILD_SA unique ID to terminate
|
||||
* @param cb logging callback
|
||||
* @param param parameter to include in each call of cb
|
||||
* @param timeout timeout in ms to wait for callbacks, 0 to disable
|
||||
@@ -128,7 +128,7 @@ struct controller_t {
|
||||
* - NEED_MORE, if callback returned FALSE
|
||||
* - OUT_OF_RES if timed out
|
||||
*/
|
||||
status_t (*terminate_child)(controller_t *this, u_int32_t reqid,
|
||||
status_t (*terminate_child)(controller_t *this, u_int32_t unique_id,
|
||||
controller_cb_t callback, void *param,
|
||||
u_int timeout);
|
||||
|
||||
|
||||
@@ -352,7 +352,7 @@ METHOD(stroke_control_t, terminate, void,
|
||||
if (streq(name, child_sa->get_name(child_sa)))
|
||||
{
|
||||
child_list->insert_last(child_list,
|
||||
(void*)(uintptr_t)child_sa->get_reqid(child_sa));
|
||||
(void*)(uintptr_t)child_sa->get_unique_id(child_sa));
|
||||
if (!all)
|
||||
{
|
||||
break;
|
||||
|
||||
@@ -1551,8 +1551,8 @@ static void clear_start_action(private_vici_config_t *this,
|
||||
enumerator_t *enumerator, *children;
|
||||
child_sa_t *child_sa;
|
||||
ike_sa_t *ike_sa;
|
||||
u_int32_t reqid = 0, *del;
|
||||
array_t *reqids = NULL;
|
||||
u_int32_t id = 0, *del;
|
||||
array_t *ids = NULL;
|
||||
char *name;
|
||||
|
||||
name = child_cfg->get_name(child_cfg);
|
||||
@@ -1568,23 +1568,23 @@ static void clear_start_action(private_vici_config_t *this,
|
||||
{
|
||||
if (streq(name, child_sa->get_name(child_sa)))
|
||||
{
|
||||
reqid = child_sa->get_reqid(child_sa);
|
||||
array_insert_create(&reqids, ARRAY_TAIL, &reqid);
|
||||
id = child_sa->get_unique_id(child_sa);
|
||||
array_insert_create(&ids, ARRAY_TAIL, &id);
|
||||
}
|
||||
}
|
||||
children->destroy(children);
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
if (array_count(reqids))
|
||||
if (array_count(ids))
|
||||
{
|
||||
while (array_remove(reqids, ARRAY_HEAD, &del))
|
||||
while (array_remove(ids, ARRAY_HEAD, &del))
|
||||
{
|
||||
DBG1(DBG_CFG, "closing '%s' #%u", name, *del);
|
||||
charon->controller->terminate_child(charon->controller,
|
||||
*del, NULL, NULL, 0);
|
||||
}
|
||||
array_destroy(reqids);
|
||||
array_destroy(ids);
|
||||
}
|
||||
break;
|
||||
case ACTION_ROUTE:
|
||||
@@ -1601,14 +1601,14 @@ static void clear_start_action(private_vici_config_t *this,
|
||||
{
|
||||
if (streq(name, child_sa->get_name(child_sa)))
|
||||
{
|
||||
reqid = child_sa->get_reqid(child_sa);
|
||||
id = child_sa->get_reqid(child_sa);
|
||||
break;
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
if (reqid)
|
||||
if (id)
|
||||
{
|
||||
charon->traps->uninstall(charon->traps, reqid);
|
||||
charon->traps->uninstall(charon->traps, id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -264,11 +264,11 @@ CALLBACK(terminate, vici_message_t*,
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (child_id && child_sa->get_reqid(child_sa) != child_id)
|
||||
if (child_id && child_sa->get_unique_id(child_sa) != child_id)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
current = child_sa->get_reqid(child_sa);
|
||||
current = child_sa->get_unique_id(child_sa);
|
||||
array_insert(ids, ARRAY_TAIL, ¤t);
|
||||
}
|
||||
csas->destroy(csas);
|
||||
|
||||
Reference in New Issue
Block a user