*/
linked_list_t *listeners;
+ /**
+ * Reqid to assign next
+ */
+ uint32_t next_reqid;
+
/**
* Reqid entries indexed by reqids
*/
mark_t mark_in, mark_t mark_out, uint32_t if_id_in, uint32_t if_id_out,
sec_label_t *label, uint32_t *reqid)
{
- static uint32_t counter = 0;
reqid_entry_t *entry = NULL, *tmpl;
- status_t status = SUCCESS;
INIT(tmpl,
.local = array_from_ts_list(local_ts),
entry = tmpl;
if (!array_remove(this->released_reqids, ARRAY_HEAD, &entry->reqid))
{
- entry->reqid = ++counter;
+ if (!this->next_reqid)
+ {
+ this->mutex->unlock(this->mutex);
+ reqid_entry_destroy(entry);
+ return OUT_OF_RES;
+ }
+ entry->reqid = this->next_reqid++;
}
this->reqids_by_ts->put(this->reqids_by_ts, entry, entry);
this->reqids->put(this->reqids, entry, entry);
entry->refs++;
this->mutex->unlock(this->mutex);
- return status;
+ return SUCCESS;
}
METHOD(kernel_interface_t, release_reqid, status_t,
(hashtable_equals_t)equals_reqid, 8),
.reqids_by_ts = hashtable_create((hashtable_hash_t)hash_reqid_by_ts,
(hashtable_equals_t)equals_reqid_by_ts, 8),
+ .next_reqid = lib->settings->get_int(lib->settings, "%s.reqid_base", 1,
+ lib->ns) ?: 1,
);
ifaces = lib->settings->get_str(lib->settings,
* @param if_id_out outbound interface ID on SA
* @param label security label (usually the one on the policy, not SA)
* @param reqid allocated reqid
- * @return SUCCESS if reqid allocated
+ * @return SUCCESS if reqid allocated, OUT_OF_RES if no reqid is
+ * available due to an overflow
*/
status_t (*alloc_reqid)(kernel_interface_t *this,
linked_list_t *local_ts, linked_list_t *remote_ts,