Again, based on minimal information, here’s one possibility:

Passive f64 expiration timer in the session object. Maintain a [per thread?] 
LRU list. See src/vppinfra/llist.h. Each time traffic hits a session, remove it 
from the LRU list, re-add it to the end of the LRU list, and set the expiration 
timer to “now + expires_in_n_seconds” or similar.

In cases like this, I usually set “now = vlib_time_now(vm)” before looping over 
all packets, and use the same value of “now” to update all of the passive 
timers. An error of O(1e-6) won’t make a measurable difference.

When creating a new session, check the head of the LRU list to see if it’s 
expired. If so, remove it from the [hopefully bihash] table and recycle it; 
else, create [pool_get] a new session.

Depending on threading / scaling / expiration precision requirements, you may 
need to create a periodic process to clean out the LRU list every few seconds. 
Otherwise, session creation self-service may be more than enough of a solution.

HTH... Dave

From: vpp-dev@lists.fd.io <vpp-dev@lists.fd.io> On Behalf Of Ashish Prajapati
Sent: Tuesday, July 23, 2019 12:23 PM
To: vpp-dev@lists.fd.io
Subject: Re: [vpp-dev] To trigger a callback function in a regular x interval, 
looking for a sample timer API usage test program in VPP platform.

Hi Dave,

The Aim is to check all the available sessions every 30secs and delete the 
inactive ones along with the corresponding hash entries.
Please suggest what can be the best way to achieve this.

Thanks,
Ashish
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#13551): https://lists.fd.io/g/vpp-dev/message/13551
Mute This Topic: https://lists.fd.io/mt/32571639/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to