Skip to content

rust/ffi: add flow lifecycle callback wrappers - v12#15318

Closed
jasonish wants to merge 5 commits into
OISF:mainfrom
jasonish:suricata-ffi/v12
Closed

rust/ffi: add flow lifecycle callback wrappers - v12#15318
jasonish wants to merge 5 commits into
OISF:mainfrom
jasonish:suricata-ffi/v12

Conversation

@jasonish
Copy link
Copy Markdown
Member

@jasonish jasonish commented May 5, 2026

From my FFI backlog, add nice Rust wrappers around the flow lifecycle
callbacks.

Ticket: https://redmine.openinfosecfoundation.org/issues/8446

Remaining in the backlog:

  • flow storage api
  • thread storage api
  • accessors for flow and packet

jasonish added 4 commits May 5, 2026 07:59
Provide Rust friendly callback registrations for flow init, update and finish events. These
callbacks are implemented as Rust closures.

Ticket: OISF#8446
Document for C and Rust, as the C documentation was missing.

Ticket: OISF#8446
@jasonish jasonish requested review from a team, jufajardini and victorjulien as code owners May 5, 2026 14:52
@jasonish jasonish force-pushed the suricata-ffi/v12 branch from 8f4ad63 to 70bf5c9 Compare May 5, 2026 15:12
@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

❌ Patch coverage is 0% with 60 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.63%. Comparing base (72e3d7a) to head (70bf5c9).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15318      +/-   ##
==========================================
- Coverage   82.66%   82.63%   -0.03%     
==========================================
  Files         993      994       +1     
  Lines      271004   271064      +60     
==========================================
- Hits       224015   223986      -29     
- Misses      46989    47078      +89     
Flag Coverage Δ
fuzzcorpus 61.05% <0.00%> (-0.03%) ⬇️
livemode 18.37% <0.00%> (+<0.01%) ⬆️
netns 22.59% <0.00%> (-0.07%) ⬇️
pcap 45.19% <0.00%> (-0.07%) ⬇️
suricata-verify 66.35% <0.00%> (-0.05%) ⬇️
unittests 58.57% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@suricata-qa
Copy link
Copy Markdown

WARNING:

field baseline test %
SURI_TLPR1_stats_chk
.uptime 667 688 103.15%
.app_layer.flow.ftp-data 761 - -
.app_layer.flow.bittorrent-dht 39597 - -
.app_layer.error.ftp-data.alloc 0 - -
.app_layer.error.ftp-data.parser 0 - -
.app_layer.error.ftp-data.internal 0 - -
.app_layer.error.bittorrent-dht.alloc 0 - -
.app_layer.error.bittorrent-dht.parser 16 - -
.app_layer.error.bittorrent-dht.internal 0 - -
.app_layer.tx.ftp-data 0 - -
.app_layer.tx.bittorrent-dht 93889 - -
.app_layer.flow.ftp_data - 756 -
.app_layer.flow.bittorrent_dht - 39597 -
.app_layer.error.ftp_data.gap - 1 -
.app_layer.error.ftp_data.alloc - 0 -
.app_layer.error.ftp_data.parser - 0 -
.app_layer.error.ftp_data.internal - 0 -
.app_layer.error.bittorrent_dht.alloc - 0 -
.app_layer.error.bittorrent_dht.parser - 16 -
.app_layer.error.bittorrent_dht.internal - 0 -
.app_layer.tx.ftp_data - 0 -
.app_layer.tx.bittorrent_dht - 93889 -

Pipeline = 31179

1 similar comment
@suricata-qa
Copy link
Copy Markdown

WARNING:

field baseline test %
SURI_TLPR1_stats_chk
.uptime 667 688 103.15%
.app_layer.flow.ftp-data 761 - -
.app_layer.flow.bittorrent-dht 39597 - -
.app_layer.error.ftp-data.alloc 0 - -
.app_layer.error.ftp-data.parser 0 - -
.app_layer.error.ftp-data.internal 0 - -
.app_layer.error.bittorrent-dht.alloc 0 - -
.app_layer.error.bittorrent-dht.parser 16 - -
.app_layer.error.bittorrent-dht.internal 0 - -
.app_layer.tx.ftp-data 0 - -
.app_layer.tx.bittorrent-dht 93889 - -
.app_layer.flow.ftp_data - 756 -
.app_layer.flow.bittorrent_dht - 39597 -
.app_layer.error.ftp_data.gap - 1 -
.app_layer.error.ftp_data.alloc - 0 -
.app_layer.error.ftp_data.parser - 0 -
.app_layer.error.ftp_data.internal - 0 -
.app_layer.error.bittorrent_dht.alloc - 0 -
.app_layer.error.bittorrent_dht.parser - 16 -
.app_layer.error.bittorrent_dht.internal - 0 -
.app_layer.tx.ftp_data - 0 -
.app_layer.tx.bittorrent_dht - 93889 -

Pipeline = 31179

@jasonish
Copy link
Copy Markdown
Member Author

jasonish commented May 5, 2026

WARNING:

field baseline test %
SURI_TLPR1_stats_chk
.uptime 667 688 103.15%
.app_layer.flow.ftp-data 761 - -
.app_layer.flow.bittorrent-dht 39597 - -
.app_layer.error.ftp-data.alloc 0 - -
.app_layer.error.ftp-data.parser 0 - -
.app_layer.error.ftp-data.internal 0 - -
.app_layer.error.bittorrent-dht.alloc 0 - -
.app_layer.error.bittorrent-dht.parser 16 - -
.app_layer.error.bittorrent-dht.internal 0 - -
.app_layer.tx.ftp-data 0 - -
.app_layer.tx.bittorrent-dht 93889 - -
.app_layer.flow.ftp_data - 756 -
.app_layer.flow.bittorrent_dht - 39597 -
.app_layer.error.ftp_data.gap - 1 -
.app_layer.error.ftp_data.alloc - 0 -
.app_layer.error.ftp_data.parser - 0 -
.app_layer.error.ftp_data.internal - 0 -
.app_layer.error.bittorrent_dht.alloc - 0 -
.app_layer.error.bittorrent_dht.parser - 16 -
.app_layer.error.bittorrent_dht.internal - 0 -
.app_layer.tx.ftp_data - 0 -
.app_layer.tx.bittorrent_dht - 93889 -
Pipeline = 31179

Something up? These changes are non-functional to Suricata proper.

@ct0br0
Copy link
Copy Markdown

ct0br0 commented May 5, 2026

I'll rerun it.

@suricata-qa
Copy link
Copy Markdown

WARNING:

field baseline test %
SURI_TLPR1_stats_chk
.uptime 667 646 96.85%
.app_layer.flow.ftp-data 761 - -
.app_layer.flow.bittorrent-dht 39597 - -
.app_layer.error.ftp-data.alloc 0 - -
.app_layer.error.ftp-data.parser 0 - -
.app_layer.error.ftp-data.internal 0 - -
.app_layer.error.bittorrent-dht.alloc 0 - -
.app_layer.error.bittorrent-dht.parser 16 - -
.app_layer.error.bittorrent-dht.internal 0 - -
.app_layer.tx.ftp-data 0 - -
.app_layer.tx.bittorrent-dht 93889 - -
.app_layer.flow.ftp_data - 750 -
.app_layer.flow.bittorrent_dht - 39597 -
.app_layer.error.ftp_data.gap - 1 -
.app_layer.error.ftp_data.alloc - 0 -
.app_layer.error.ftp_data.parser - 0 -
.app_layer.error.ftp_data.internal - 0 -
.app_layer.error.bittorrent_dht.alloc - 0 -
.app_layer.error.bittorrent_dht.parser - 16 -
.app_layer.error.bittorrent_dht.internal - 0 -
.app_layer.tx.ftp_data - 0 -
.app_layer.tx.bittorrent_dht - 93889 -

Pipeline = 31181

@victorjulien
Copy link
Copy Markdown
Member

Weird, the logging changed with #15315 but the issue doesn't show there.

working-directory: examples/plugins/rust
run: cargo build
run: |
cargo fmt --check
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you want to use the rustfmt.toml ?

like -- --config-path ../../../rust/rustfmt.toml

I do that for the applayer plugin

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. If a user uses this as a template and copies it somewhere, they are not going to have that rustfmt.toml available, and will automatically have formatting differences. So I think it's best to keep the default formatting, OR we put a rustfmt.toml in there. But I don't think we should prescribe our formatting to plugin authors.

Comment thread doc/userguide/devguide/extending/flow-lifecycle-callbacks.rst
Comment thread rust/ffi/src/flow.rs
Comment thread src/flow-callbacks.h
@jasonish
Copy link
Copy Markdown
Member Author

jasonish commented May 7, 2026

Replaced by #15334

@jasonish jasonish closed this May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants