From: Lukas Sismis Date: Fri, 15 Sep 2023 10:08:38 +0000 (-0400) Subject: dpdk: stop devices immediately after Suricata stop command X-Git-Tag: suricata-7.0.2~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3eac0f15c0cff65a7f81f4d6b04426d6599a24ad;p=thirdparty%2Fsuricata.git dpdk: stop devices immediately after Suricata stop command To better represent port stats of Suricata stop the device right after Suricata is deemed to shut down. While Suricata deinitialization happened, the device kept receiving packets. But because Suricata was no longer interested in the packets, the device accounted these packets as missed and it could have alter true stats of Suricata. --- diff --git a/src/source-dpdk.c b/src/source-dpdk.c index 36a6d222e2..ddbb2976c9 100644 --- a/src/source-dpdk.c +++ b/src/source-dpdk.c @@ -212,7 +212,7 @@ static void DevicePostStartPMDSpecificActions(DPDKThreadVars *ptv, const char *d i40eDeviceSetRSS(ptv->port_id, ptv->threads); } -static void DevicePreStopPMDSpecificActions(DPDKThreadVars *ptv, const char *driver_name) +static void DevicePreClosePMDSpecificActions(DPDKThreadVars *ptv, const char *driver_name) { if (strcmp(driver_name, "net_bonding") == 0) { driver_name = BondingDeviceDriverGet(ptv->port_id); @@ -378,6 +378,12 @@ static TmEcode ReceiveDPDKLoop(ThreadVars *tv, void *data, void *slot) while (1) { if (unlikely(suricata_ctl_flags != 0)) { SCLogDebug("Stopping Suricata!"); + if (ptv->queue_id == 0) { + rte_eth_dev_stop(ptv->port_id); + if (ptv->copy_mode == DPDK_COPY_MODE_TAP || ptv->copy_mode == DPDK_COPY_MODE_IPS) { + rte_eth_dev_stop(ptv->out_port_id); + } + } DPDKDumpCounters(ptv); break; } @@ -668,12 +674,7 @@ static TmEcode ReceiveDPDKThreadDeinit(ThreadVars *tv, void *data) SCReturnInt(TM_ECODE_FAILED); } - DevicePreStopPMDSpecificActions(ptv, dev_info.driver_name); - } - - rte_eth_dev_stop(ptv->port_id); - if (ptv->copy_mode == DPDK_COPY_MODE_TAP || ptv->copy_mode == DPDK_COPY_MODE_IPS) { - rte_eth_dev_stop(ptv->out_port_id); + DevicePreClosePMDSpecificActions(ptv, dev_info.driver_name); } ptv->pkt_mempool = NULL; // MP is released when device is closed