@@ -115,6 +115,11 @@ struct private_kernel_interface_t {
115
115
*/
116
116
linked_list_t * listeners ;
117
117
118
+ /**
119
+ * Reqid to assign next
120
+ */
121
+ uint32_t next_reqid ;
122
+
118
123
/**
119
124
* Reqid entries indexed by reqids
120
125
*/
@@ -373,9 +378,7 @@ METHOD(kernel_interface_t, alloc_reqid, status_t,
373
378
mark_t mark_in , mark_t mark_out , uint32_t if_id_in , uint32_t if_id_out ,
374
379
sec_label_t * label , uint32_t * reqid )
375
380
{
376
- static uint32_t counter = 0 ;
377
381
reqid_entry_t * entry = NULL , * tmpl ;
378
- status_t status = SUCCESS ;
379
382
380
383
INIT (tmpl ,
381
384
.local = array_from_ts_list (local_ts ),
@@ -415,7 +418,13 @@ METHOD(kernel_interface_t, alloc_reqid, status_t,
415
418
entry = tmpl ;
416
419
if (!array_remove (this -> released_reqids , ARRAY_HEAD , & entry -> reqid ))
417
420
{
418
- entry -> reqid = ++ counter ;
421
+ if (!this -> next_reqid )
422
+ {
423
+ this -> mutex -> unlock (this -> mutex );
424
+ reqid_entry_destroy (entry );
425
+ return OUT_OF_RES ;
426
+ }
427
+ entry -> reqid = this -> next_reqid ++ ;
419
428
}
420
429
this -> reqids_by_ts -> put (this -> reqids_by_ts , entry , entry );
421
430
this -> reqids -> put (this -> reqids , entry , entry );
@@ -425,7 +434,7 @@ METHOD(kernel_interface_t, alloc_reqid, status_t,
425
434
entry -> refs ++ ;
426
435
this -> mutex -> unlock (this -> mutex );
427
436
428
- return status ;
437
+ return SUCCESS ;
429
438
}
430
439
431
440
METHOD (kernel_interface_t , release_reqid , status_t ,
@@ -1105,6 +1114,8 @@ kernel_interface_t *kernel_interface_create()
1105
1114
(hashtable_equals_t )equals_reqid , 8 ),
1106
1115
.reqids_by_ts = hashtable_create ((hashtable_hash_t )hash_reqid_by_ts ,
1107
1116
(hashtable_equals_t )equals_reqid_by_ts , 8 ),
1117
+ .next_reqid = lib -> settings -> get_int (lib -> settings , "%s.reqid_base" , 1 ,
1118
+ lib -> ns ) ?: 1 ,
1108
1119
);
1109
1120
1110
1121
ifaces = lib -> settings -> get_str (lib -> settings ,
0 commit comments