]> git.ipfire.org Git - people/ms/suricata.git/commit
app-layer: add tx iterator API
authorVictor Julien <victor@inliniac.net>
Wed, 31 Jan 2018 14:58:21 +0000 (15:58 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 6 Feb 2018 20:30:47 +0000 (21:30 +0100)
commite96d9c11596e6a2b611902f0c7c601de5dccc6f3
tree88f3a3f10b98eff531ffaf0c5dd9e0d64ad62a4e
parent7da805ffd9a9202c67d53ef6a06c3215436495e9
app-layer: add tx iterator API

Until now, the transaction space is assumed to be terse. Transactions
are handled sequentially so the difference between the lowest and highest
active tx id's is small. For this reason the logic of walking every id
between the 'minimum' and max id made sense. The space might look like:

    [..........TTTT]

Here the looping starts at the first T and loops 4 times.

This assumption isn't a great fit though. A protocol like NFS has 2 types
of transactions. Long running file transfer transactions and short lived
request/reply pairs are causing the id space to be sparse. This leads to
a lot of unnecessary looping in various parts of the engine, but most
prominently: detection, tx house keeping and tx logging.

    [.T..T...TTTT.T]

Here the looping starts at the first T and loops for every spot, even
those where no tx exists anymore.

Cases have been observed where the lowest tx id was 2 and the highest
was 50k. This lead to a lot of unnecessary looping.

This patch add an alternative approach. It allows a protocol to register
an iterator function, that simply returns the next transaction until
all transactions are returned. To do this it uses a bit of state the
caller must keep.

The registration is optional. If no iterator is registered the old
behaviour will be used.
rust/gen-c-headers.py
rust/src/applayer.rs
rust/src/nfs/nfs.rs
src/app-layer-nfs-tcp.c
src/app-layer-nfs-udp.c
src/app-layer-parser.c
src/app-layer-parser.h
src/detect-nfs-procedure.c
src/detect-nfs-version.c
src/detect.c
src/output-tx.c