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.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user