dpdk: stop engine after net_pcap PCAP end of file#14817
dpdk: stop engine after net_pcap PCAP end of file#14817
Conversation
When using DPDK's net_pcap PMD to read PCAP files, Suricata previously stayed stuck in the RX loop after the file was fully consumed because no EOF signal exists — only zero packets returned by rte_eth_rx_burst. Detect the net_pcap driver during device configuration and track active pcap workers with an atomic counter in DPDKWorkerSync. When a worker receives zero packets it decrements the counter; the last worker to finish calls EngineStop to initiate graceful shutdown. A separate receive loop (ReceiveDPDKLoopPcap) is used for net_pcap interfaces to keep the zero-RX EOF check and atomic decrement off the live capture fast path entirely — the dispatch happens once at loop entry so the live loop (ReceiveDPDKLoopLive) remains unchanged with no additional branches. The common packet burst processing is extracted into the inline helper ReceiveDPDKPkts shared by both loops. Ticket: OISF#8225 Signed-off-by: mmaatuq <[email protected]>
|
NOTE: This PR may contain new authors. |
|
The PR doesn't work for me with 2+ PCAPs. e.g., here is the output, but the second port (PCAP) is much larger. Suricata is regardless stopped after the first PCAP is finished processing. Here is my example config: dpdk:
eal-params:
proc-type: primary
no-pci:
file-prefix: pcaptest
vdev: ["net_pcap0,rx_pcap=/data/pcap/download_raw.pcap", "net_pcap1,rx_pcap=/data/stratosphere/malware-pcaps/CTU-Mixed-Capture-1/2015-07-28_mixed.pcap"]So perhaps fixing this and adding extra Github CI/suricata-verify tests wouldn't hurt. The tests should primarily test this functionality (the support of net_pcap driver), that packets and bytes read from multiple PCAPs are as expected. |
lukashino
left a comment
There was a problem hiding this comment.
In general it looks ok but needs some fixing + tests.
I did already some tests with multiple pcaps and it was working fine, but now I understand the difference on my tests i was using the same net_pcap name "net_pcap0" and having multiple pcaps was translated to one interface but multiple rx queues, on your test it's multiple interfaces each single rx queue, the synchronization that was implemented is between workers of the same interface. let me handle this. |
Make sure these boxes are checked accordingly before submitting your Pull Request -- thank you.
Contribution style:
https://docs.suricata.io/en/latest/devguide/contributing/contribution-process.html
Our Contribution agreements:
https://suricata.io/about/contribution-agreement/ (note: this is only required once)
Changes (if applicable):
(including schema descriptions)
https://redmine.openinfosecfoundation.org/projects/suricata/issues
Link to ticket: https://redmine.openinfosecfoundation.org/issues/8225
Describe changes:
When using DPDK's net_pcap PMD to read PCAP files, Suricata previously stayed stuck in the RX loop after the file was fully consumed because no EOF signal exists — only zero packets returned by rte_eth_rx_burst.
Detect the net_pcap driver during device configuration and track active pcap workers with an atomic counter in DPDKWorkerSync. When a worker receives zero packets it decrements the counter; the last worker to finish calls EngineStop to initiate graceful shutdown.
A separate receive loop (ReceiveDPDKLoopPcap) is used for net_pcap interfaces to keep the zero-RX EOF check and atomic decrement off the live capture fast path entirely — the dispatch happens once at loop entry so the live loop (ReceiveDPDKLoopLive) remains unchanged with no additional branches.
The common packet burst processing is extracted into the inline helper ReceiveDPDKPkts shared by both loops.
Ticket: #8225
Provide values to any of the below to override the defaults.
link to the pull request in the respective
_BRANCHvariable.SV_REPO=
SV_BRANCH=
SU_REPO=
SU_BRANCH=