mirror of https://github.com/OISF/suricata
flow: also do final flow reassembly for flows stranded on the evicted list
PostRunDeinit stops the flow manager, then runs the final flow sweeps. TCP flows that a foreign thread times out during those sweeps are parked on the flow hash row's evicted list for the manager to pick up, but the manager is gone. FlowRemoveHash only walked the row's head list, so those flows were later recycled without FlowFinish, skipping the final reassembly and pseudo packet pass. Any app layer tx that only completes at flow end is then lost: typically a response arriving after the peer's FIN and never ACKed, as that data only becomes usable at eof in non-inline mode. The result is an intermittent count mismatch in the suricata-verify suite, always exactly one short, e.g. "expected 28 matches; got 27" for http-sticky-server and "expected 7 matches; got 6" for smb2-ntlmssp-negotiateflags. The flow event is still logged, with reason "shutdown", so the flow is not lost, only its tail transactions. The lost records can be spotted in a reference eve.json by "pkt_src": "stream (flow timeout)" and no pcap_cnt. Stranding a flow needs a hash row collision plus a foreign thread sweep inside the [last manager sweep, manager stopped] window, and the row mapping is seeded with a per process random value (flow.c hash_rand). That makes it a per run lottery at the default 65536 rows, and deterministic with a small flow.hash-size such as 12 or 20. Unit tests cannot cover it: FlowBelongsToUs returns true in unittests runmode, so the evicted list is never populated there. Also sweep the evicted list, with the same decision point as the head walk: FlowNeedsReassembly sets ffr_ts/ffr_tc, which CheckWorkQueue requires before running FlowFinish. CheckWorkQueue applies its own bypass and drop guards, so a bypassed flow may now take a worker round trip and have its flow event logged there rather than by the recycler. The evicted list has never been swept on this path. Fixes:pull/16461/head244dd11c34("flow/manager: fix flows not evicted & freed in time") Ticket: #9146. (cherry picked from commitf2e3a2e2a7)
parent
77f02f8291
commit
747b5e2866
Loading…
Reference in New Issue