From: Tobias Brunner Date: Mon, 2 Oct 2023 12:08:56 +0000 (+0200) Subject: kernel-interface: Remove unnecessary parameters for release_reqid() X-Git-Tag: 5.9.12rc1~10^2~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=02180ae2fff9d732e1e1be41466543b7e9bdd8ba;p=thirdparty%2Fstrongswan.git kernel-interface: Remove unnecessary parameters for release_reqid() These are not included in the initial lookup anymore. Also simplified the implementation as we always add the same entry to the two hash tables. --- diff --git a/src/libcharon/kernel/kernel_interface.c b/src/libcharon/kernel/kernel_interface.c index d4a7286efd..844af7060c 100644 --- a/src/libcharon/kernel/kernel_interface.c +++ b/src/libcharon/kernel/kernel_interface.c @@ -434,45 +434,24 @@ METHOD(kernel_interface_t, alloc_reqid, status_t, } METHOD(kernel_interface_t, release_reqid, status_t, - private_kernel_interface_t *this, uint32_t reqid, - mark_t mark_in, mark_t mark_out, uint32_t if_id_in, uint32_t if_id_out, - sec_label_t *label) + private_kernel_interface_t *this, uint32_t reqid) { reqid_entry_t *entry, tmpl = { .reqid = reqid, - .mark_in = mark_in, - .mark_out = mark_out, - .if_id_in = if_id_in, - .if_id_out = if_id_out, - .label = label, }; this->mutex->lock(this->mutex); - entry = this->reqids->remove(this->reqids, &tmpl); - if (entry) + entry = this->reqids->get(this->reqids, &tmpl); + if (entry && --entry->refs == 0) { - if (--entry->refs == 0) - { - array_insert_create_value(&this->released_reqids, sizeof(uint32_t), - ARRAY_TAIL, &entry->reqid); - entry = this->reqids_by_ts->remove(this->reqids_by_ts, entry); - if (entry) - { - reqid_entry_destroy(entry); - } - } - else - { - this->reqids->put(this->reqids, entry, entry); - } + array_insert_create_value(&this->released_reqids, sizeof(uint32_t), + ARRAY_TAIL, &entry->reqid); + this->reqids->remove(this->reqids, entry); + this->reqids_by_ts->remove(this->reqids_by_ts, entry); + reqid_entry_destroy(entry); } this->mutex->unlock(this->mutex); - - if (entry) - { - return SUCCESS; - } - return NOT_FOUND; + return entry ? SUCCESS : NOT_FOUND; } METHOD(kernel_interface_t, add_sa, status_t, diff --git a/src/libcharon/kernel/kernel_interface.h b/src/libcharon/kernel/kernel_interface.h index 2bc9d86572..9f8e9b7144 100644 --- a/src/libcharon/kernel/kernel_interface.h +++ b/src/libcharon/kernel/kernel_interface.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2016 Tobias Brunner + * Copyright (C) 2006-2023 Tobias Brunner * Copyright (C) 2006 Daniel Roethlisberger * Copyright (C) 2005-2006 Martin Willi * Copyright (C) 2005 Jan Hutter @@ -162,17 +162,9 @@ struct kernel_interface_t { * Release a previously allocated reqid. * * @param reqid reqid to release - * @param mark_in inbound mark on SA - * @param mark_out outbound mark on SA - * @param if_id_in inbound interface ID on SA - * @param if_id_out outbound interface ID on SA - * @param label security label (usually the one on the policy, not SA) * @return SUCCESS if reqid released */ - status_t (*release_reqid)(kernel_interface_t *this, uint32_t reqid, - mark_t mark_in, mark_t mark_out, - uint32_t if_id_in, uint32_t if_id_out, - sec_label_t *label); + status_t (*release_reqid)(kernel_interface_t *this, uint32_t reqid); /** * Add an SA to the SAD. diff --git a/src/libcharon/sa/child_sa.c b/src/libcharon/sa/child_sa.c index d76d7aebcb..e23accf0ef 100644 --- a/src/libcharon/sa/child_sa.c +++ b/src/libcharon/sa/child_sa.c @@ -1810,9 +1810,7 @@ METHOD(child_sa_t, update, status_t, { if (new_reqid && charon->kernel->release_reqid(charon->kernel, - new_reqid, this->mark_in, this->mark_out, - this->if_id_in, this->if_id_out, - label_for(this, LABEL_USE_REQID)) != SUCCESS) + new_reqid) != SUCCESS) { DBG1(DBG_CHD, "releasing reqid %u failed", new_reqid); } @@ -1827,9 +1825,7 @@ METHOD(child_sa_t, update, status_t, if (new_reqid) { if (charon->kernel->release_reqid(charon->kernel, - this->reqid, this->mark_in, this->mark_out, - this->if_id_in, this->if_id_out, - label_for(this, LABEL_USE_REQID)) != SUCCESS) + this->reqid) != SUCCESS) { DBG1(DBG_CHD, "releasing reqid %u failed", this->reqid); } @@ -1950,9 +1946,7 @@ METHOD(child_sa_t, destroy, void, if (this->reqid_allocated) { if (charon->kernel->release_reqid(charon->kernel, - this->reqid, this->mark_in, this->mark_out, - this->if_id_in, this->if_id_out, - label_for(this, LABEL_USE_REQID)) != SUCCESS) + this->reqid) != SUCCESS) { DBG1(DBG_CHD, "releasing reqid %u failed", this->reqid); }