Skip to content

Add file rolling support to the dump module#42

Open
ssam18 wants to merge 1 commit into
snort3:masterfrom
ssam18:feature/dump-file-rolling
Open

Add file rolling support to the dump module#42
ssam18 wants to merge 1 commit into
snort3:masterfrom
ssam18:feature/dump-file-rolling

Conversation

@ssam18

@ssam18 ssam18 commented Jun 11, 2026

Copy link
Copy Markdown

This adds optional rolling of the pcap files written by the dump module, as requested in #29. Since the module is a library loaded into the host application, reopening files on a signal like logrotate expects did not seem like a good fit, so the rolling is handled internally through DAQ variables. The new roll-size variable takes a limit in MiB and the new roll-pkts variable takes a packet count, and the current file is rolled as soon as either limit is reached. Rolled files keep the configured name with a numeric suffix, so inline-out.pcap becomes inline-out.pcap.1 and so on, while the TX and RX files are tracked and rolled separately. The duplicated dumper open code in dump_daq_start was pulled into a helper that the roll path reuses, which also fixed a small leak where a failed RX open left the TX dumper unclosed. I added a cmocka based unit test that stacks the dump module on a mock source module and verifies packet counts and file sizes in the generated files, covering the receive and inject paths as well as rejection of invalid variable values. The README was updated to document the new variables.

The dump module can now roll its pcap output files based on a file size limit or a packet count limit. Two new variables named roll-size and roll-pkts control this, and rolled files get a numeric suffix appended to the configured filename. The TX and RX output files are tracked and rolled independently. New cmocka unit tests cover the rolling behavior along with the existing single file output path. Fixes issue snort3#29.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant