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,
|
METHOD(kernel_interface_t, release_reqid, status_t,
|
||||||
private_kernel_interface_t *this, uint32_t reqid,
|
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)
|
|
||||||
{
|
{
|
||||||
reqid_entry_t *entry, tmpl = {
|
reqid_entry_t *entry, tmpl = {
|
||||||
.reqid = reqid,
|
.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);
|
this->mutex->lock(this->mutex);
|
||||||
entry = this->reqids->remove(this->reqids, &tmpl);
|
entry = this->reqids->get(this->reqids, &tmpl);
|
||||||
if (entry)
|
if (entry && --entry->refs == 0)
|
||||||
{
|
{
|
||||||
if (--entry->refs == 0)
|
array_insert_create_value(&this->released_reqids, sizeof(uint32_t),
|
||||||
{
|
ARRAY_TAIL, &entry->reqid);
|
||||||
array_insert_create_value(&this->released_reqids, sizeof(uint32_t),
|
this->reqids->remove(this->reqids, entry);
|
||||||
ARRAY_TAIL, &entry->reqid);
|
this->reqids_by_ts->remove(this->reqids_by_ts, entry);
|
||||||
entry = this->reqids_by_ts->remove(this->reqids_by_ts, entry);
|
reqid_entry_destroy(entry);
|
||||||
if (entry)
|
|
||||||
{
|
|
||||||
reqid_entry_destroy(entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->reqids->put(this->reqids, entry, entry);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this->mutex->unlock(this->mutex);
|
this->mutex->unlock(this->mutex);
|
||||||
|
return entry ? SUCCESS : NOT_FOUND;
|
||||||
if (entry)
|
|
||||||
{
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
return NOT_FOUND;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
METHOD(kernel_interface_t, add_sa, status_t,
|
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) 2006 Daniel Roethlisberger
|
||||||
* Copyright (C) 2005-2006 Martin Willi
|
* Copyright (C) 2005-2006 Martin Willi
|
||||||
* Copyright (C) 2005 Jan Hutter
|
* Copyright (C) 2005 Jan Hutter
|
||||||
@@ -162,17 +162,9 @@ struct kernel_interface_t {
|
|||||||
* Release a previously allocated reqid.
|
* Release a previously allocated reqid.
|
||||||
*
|
*
|
||||||
* @param reqid reqid to release
|
* @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
|
* @return SUCCESS if reqid released
|
||||||
*/
|
*/
|
||||||
status_t (*release_reqid)(kernel_interface_t *this, uint32_t reqid,
|
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);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an SA to the SAD.
|
* Add an SA to the SAD.
|
||||||
|
|||||||
@@ -1810,9 +1810,7 @@ METHOD(child_sa_t, update, status_t,
|
|||||||
{
|
{
|
||||||
if (new_reqid &&
|
if (new_reqid &&
|
||||||
charon->kernel->release_reqid(charon->kernel,
|
charon->kernel->release_reqid(charon->kernel,
|
||||||
new_reqid, this->mark_in, this->mark_out,
|
new_reqid) != SUCCESS)
|
||||||
this->if_id_in, this->if_id_out,
|
|
||||||
label_for(this, LABEL_USE_REQID)) != SUCCESS)
|
|
||||||
{
|
{
|
||||||
DBG1(DBG_CHD, "releasing reqid %u failed", new_reqid);
|
DBG1(DBG_CHD, "releasing reqid %u failed", new_reqid);
|
||||||
}
|
}
|
||||||
@@ -1827,9 +1825,7 @@ METHOD(child_sa_t, update, status_t,
|
|||||||
if (new_reqid)
|
if (new_reqid)
|
||||||
{
|
{
|
||||||
if (charon->kernel->release_reqid(charon->kernel,
|
if (charon->kernel->release_reqid(charon->kernel,
|
||||||
this->reqid, this->mark_in, this->mark_out,
|
this->reqid) != SUCCESS)
|
||||||
this->if_id_in, this->if_id_out,
|
|
||||||
label_for(this, LABEL_USE_REQID)) != SUCCESS)
|
|
||||||
{
|
{
|
||||||
DBG1(DBG_CHD, "releasing reqid %u failed", this->reqid);
|
DBG1(DBG_CHD, "releasing reqid %u failed", this->reqid);
|
||||||
}
|
}
|
||||||
@@ -1950,9 +1946,7 @@ METHOD(child_sa_t, destroy, void,
|
|||||||
if (this->reqid_allocated)
|
if (this->reqid_allocated)
|
||||||
{
|
{
|
||||||
if (charon->kernel->release_reqid(charon->kernel,
|
if (charon->kernel->release_reqid(charon->kernel,
|
||||||
this->reqid, this->mark_in, this->mark_out,
|
this->reqid) != SUCCESS)
|
||||||
this->if_id_in, this->if_id_out,
|
|
||||||
label_for(this, LABEL_USE_REQID)) != SUCCESS)
|
|
||||||
{
|
{
|
||||||
DBG1(DBG_CHD, "releasing reqid %u failed", this->reqid);
|
DBG1(DBG_CHD, "releasing reqid %u failed", this->reqid);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user