app-layer-expectation: clean expectation and add limits
When a flow timeout, we can have still existing expectations that
are linked to this flow. Given that there is a delay between the
real ending of the flow and its destruction by Suricata, the
expectation should be already honored so we can assume the risk
to clean the expectations that have been triggered by the
to-be-deleted flow.
This patch introduces a limitation in term of number of
expectations attached to one IPPair. This is done using
a circle list so we have a FIFO approach on expectation
handling.
Circleq list code is copied from BSD code like was pre existing code
in queue.h.
(cherry picked from commit
a4cea196c0ea9aa5f2b34a43140056d689003c13)
(cherry picked from commit
230dbafa22dc015552ec73a3b0eb70e209ed2190)
Commits squashed to avoid circular dependeny by Victor Julien.