analytaps / netflow-dpdk

13 stars 20 forks source link

Linked List problem when moving expired flows from bkt to export_list #2

Open craiggarrett opened 8 years ago

craiggarrett commented 8 years ago

In netflow-export.c, function process_hashtable(), the linked list algorithm has a bug: when a flow has expired and is moved from bkt to export_list, the "hole" in bkt is not patched. This results in each bucket having an item that points to an item inside of export_list. The "previous" item in the Bucket needs to be assigned to bkt->next. Unfortunately, there is not a 1-line fix to this problem. Please see the below example of how to iterate over a linked list and remove multiple items from it in one pass. It requires 1 while loop to remove head(s), then another while loop for the rest of the list, and inside of that loop is another loop for skipping items that should not be removed.

Delete all occurrences of a given key in a linked list, by Saransh http://quiz.geeksforgeeks.org/delete-occurrences-given-key-linked-list/