quick-mode: Allow "aborting" task if it's currently active

Basically the same as the previous commit.
This commit is contained in:
Tobias Brunner
2024-09-18 11:53:17 +02:00
parent e81cf3bd36
commit 961763b84d
2 changed files with 27 additions and 2 deletions
+20 -1
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2019 Tobias Brunner * Copyright (C) 2012-2024 Tobias Brunner
* Copyright (C) 2011 Martin Willi * Copyright (C) 2011 Martin Willi
* *
* Copyright (C) secunet Security Networks AG * Copyright (C) secunet Security Networks AG
@@ -164,6 +164,11 @@ struct private_quick_mode_t {
*/ */
bool delete; bool delete;
/**
* Whether the task was aborted
*/
bool aborted;
/** /**
* Negotiated mode, tunnel or transport * Negotiated mode, tunnel or transport
*/ */
@@ -955,6 +960,13 @@ METHOD(task_t, build_i, status_t,
} }
case QM_NEGOTIATED: case QM_NEGOTIATED:
{ {
if (this->aborted)
{
this->ike_sa->queue_task(this->ike_sa,
(task_t*)quick_delete_create(this->ike_sa,
this->proposal->get_protocol(this->proposal),
this->spi_i, TRUE, FALSE));
}
return SUCCESS; return SUCCESS;
} }
default: default:
@@ -1476,6 +1488,12 @@ METHOD(quick_mode_t, rekey, void,
this->rekey = spi; this->rekey = spi;
} }
METHOD(quick_mode_t, abort_, void,
private_quick_mode_t *this)
{
this->aborted = TRUE;
}
METHOD(task_t, migrate, void, METHOD(task_t, migrate, void,
private_quick_mode_t *this, ike_sa_t *ike_sa) private_quick_mode_t *this, ike_sa_t *ike_sa)
{ {
@@ -1545,6 +1563,7 @@ quick_mode_t *quick_mode_create(ike_sa_t *ike_sa, child_cfg_t *config,
.use_marks = _use_marks, .use_marks = _use_marks,
.use_if_ids = _use_if_ids, .use_if_ids = _use_if_ids,
.rekey = _rekey, .rekey = _rekey,
.abort = _abort_,
}, },
.ike_sa = ike_sa, .ike_sa = ike_sa,
.initiator = config != NULL, .initiator = config != NULL,
+7 -1
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015-2019 Tobias Brunner * Copyright (C) 2015-2024 Tobias Brunner
* Copyright (C) 2011 Martin Willi * Copyright (C) 2011 Martin Willi
* *
* Copyright (C) secunet Security Networks AG * Copyright (C) secunet Security Networks AG
@@ -87,6 +87,12 @@ struct quick_mode_t {
* @param spi spi of SA to rekey * @param spi spi of SA to rekey
*/ */
void (*rekey)(quick_mode_t *this, uint32_t spi); void (*rekey)(quick_mode_t *this, uint32_t spi);
/**
* Mark this active task as being aborted, i.e. cause a deletion of the
* created CHILD_SA immediately after its successful creation.
*/
void (*abort)(quick_mode_t *this);
}; };
/** /**